/* * Copyright (c) 2023-2024, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #import @protocol LadybirdWebViewObserver - (String const&)onCreateNewTab:(Optional const&)url activateTab:(Web::HTML::ActivateTab)activate_tab; - (String const&)onCreateNewTab:(StringView)html url:(URL::URL const&)url activateTab:(Web::HTML::ActivateTab)activate_tab; - (String const&)onCreateChildTab:(Optional const&)url activateTab:(Web::HTML::ActivateTab)activate_tab pageIndex:(u64)page_index; - (void)loadURL:(URL::URL const&)url; - (void)onLoadStart:(URL::URL const&)url isRedirect:(BOOL)is_redirect; - (void)onLoadFinish:(URL::URL const&)url; - (void)onURLChange:(URL::URL const&)url; - (void)onBackNavigationEnabled:(BOOL)back_enabled forwardNavigationEnabled:(BOOL)forward_enabled; - (void)onTitleChange:(ByteString const&)title; - (void)onFaviconChange:(Gfx::Bitmap const&)bitmap; - (void)onAudioPlayStateChange:(Web::HTML::AudioPlayState)play_state; - (void)onFindInPageResult:(size_t)current_match_index totalMatchCount:(Optional const&)total_match_count; @end @interface LadybirdWebView : NSView - (instancetype)init:(id)observer; - (instancetype)initAsChild:(id)observer parent:(LadybirdWebView*)parent pageIndex:(u64)page_index; - (void)loadURL:(URL::URL const&)url; - (void)loadHTML:(StringView)html; - (void)navigateBack; - (void)navigateForward; - (void)reload; - (WebView::ViewImplementation&)view; - (String const&)handle; - (void)setWindowPosition:(Gfx::IntPoint)position; - (void)setWindowSize:(Gfx::IntSize)size; - (void)handleResize; - (void)handleDevicePixelRatioChange; - (void)handleVisibility:(BOOL)is_visible; - (void)setPreferredColorScheme:(Web::CSS::PreferredColorScheme)color_scheme; - (void)setPreferredContrast:(Web::CSS::PreferredContrast)contrast; - (void)setPreferredMotion:(Web::CSS::PreferredMotion)motion; - (void)findInPage:(NSString*)query caseSensitivity:(CaseSensitivity)case_sensitivity; - (void)findInPageNextMatch; - (void)findInPagePreviousMatch; - (void)zoomIn; - (void)zoomOut; - (void)resetZoom; - (float)zoomLevel; - (void)debugRequest:(ByteString const&)request argument:(ByteString const&)argument; - (void)setEnableAutoplay:(BOOL)enabled; - (void)viewSource; @end