mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-24 08:59:50 +00:00
This migrates all duplicated context menus from the UIs to LibWebView. The context menu actions are now largely handled directly in LibWebView, with some UI-specific callbacks added to display e.g. confirmation dialogs. Actions that only ever apply to a specific web view are stored on the ViewImplementation itself. Actions that need to be dynamically applied to the active web view are stored on the Application.
85 lines
2.6 KiB
Objective-C
85 lines
2.6 KiB
Objective-C
/*
|
|
* Copyright (c) 2023-2025, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Forward.h>
|
|
#include <LibGfx/Forward.h>
|
|
#include <LibURL/Forward.h>
|
|
#include <LibWeb/CSS/PreferredColorScheme.h>
|
|
#include <LibWeb/CSS/PreferredContrast.h>
|
|
#include <LibWeb/CSS/PreferredMotion.h>
|
|
#include <LibWeb/HTML/ActivateTab.h>
|
|
#include <LibWeb/HTML/AudioPlayState.h>
|
|
#include <LibWebView/Forward.h>
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
@protocol LadybirdWebViewObserver <NSObject>
|
|
|
|
- (String const&)onCreateNewTab:(Optional<URL::URL> 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<URL::URL> 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)onTitleChange:(Utf16String const&)title;
|
|
- (void)onFaviconChange:(Gfx::Bitmap const&)bitmap;
|
|
- (void)onAudioPlayStateChange:(Web::HTML::AudioPlayState)play_state;
|
|
|
|
- (void)onFindInPageResult:(size_t)current_match_index
|
|
totalMatchCount:(Optional<size_t> const&)total_match_count;
|
|
|
|
@end
|
|
|
|
@interface LadybirdWebView : NSView <NSMenuDelegate>
|
|
|
|
- (instancetype)init:(id<LadybirdWebViewObserver>)observer;
|
|
- (instancetype)initAsChild:(id<LadybirdWebViewObserver>)observer
|
|
parent:(LadybirdWebView*)parent
|
|
pageIndex:(u64)page_index;
|
|
|
|
- (void)loadURL:(URL::URL const&)url;
|
|
- (void)loadHTML:(StringView)html;
|
|
|
|
- (WebView::ViewImplementation&)view;
|
|
- (String const&)handle;
|
|
|
|
- (void)setWindowPosition:(Gfx::IntPoint)position;
|
|
- (void)setWindowSize:(Gfx::IntSize)size;
|
|
|
|
- (void)handleResize;
|
|
- (void)handleDevicePixelRatioChange;
|
|
- (void)handleDisplayRefreshRateChange;
|
|
- (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;
|
|
|
|
@end
|