2022-10-05 09:32:17 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2023-01-12 17:22:14 -03:00
|
|
|
* Copyright (c) 2023, Linus Groh <linusg@serenityos.org>
|
2022-10-05 09:32:17 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Forward.h>
|
2023-05-17 13:37:31 -03:00
|
|
|
#include <AK/Function.h>
|
2026-05-22 10:42:29 -03:00
|
|
|
#include <AK/JsonArray.h>
|
2025-02-21 14:39:43 -03:00
|
|
|
#include <AK/JsonObject.h>
|
2026-05-22 10:42:29 -03:00
|
|
|
#include <AK/JsonValue.h>
|
2023-12-09 18:57:57 -03:00
|
|
|
#include <AK/LexicalPath.h>
|
2026-04-07 13:35:26 -03:00
|
|
|
#include <AK/OwnPtr.h>
|
2024-03-04 00:07:49 -03:00
|
|
|
#include <AK/Queue.h>
|
2023-01-12 17:22:14 -03:00
|
|
|
#include <AK/String.h>
|
2025-07-28 17:51:01 -03:00
|
|
|
#include <AK/Utf16String.h>
|
2026-05-21 12:46:17 -03:00
|
|
|
#include <LibCore/AnonymousBuffer.h>
|
2024-06-20 15:34:51 -03:00
|
|
|
#include <LibCore/Forward.h>
|
2023-12-31 11:51:02 -03:00
|
|
|
#include <LibCore/Promise.h>
|
2026-02-01 15:27:19 -03:00
|
|
|
#include <LibCore/SharedVersion.h>
|
2026-05-28 08:14:41 -03:00
|
|
|
#include <LibDevTools/DevToolsDelegate.h>
|
2026-05-24 15:44:30 -03:00
|
|
|
#include <LibGfx/Color.h>
|
2025-02-17 12:49:05 -03:00
|
|
|
#include <LibGfx/Cursor.h>
|
2022-10-05 09:32:17 -03:00
|
|
|
#include <LibGfx/Forward.h>
|
2026-04-07 13:35:26 -03:00
|
|
|
#include <LibGfx/SharedImage.h>
|
|
|
|
|
#include <LibGfx/SharedImageBuffer.h>
|
2026-01-14 14:43:48 -03:00
|
|
|
#include <LibHTTP/Header.h>
|
|
|
|
|
#include <LibRequests/Forward.h>
|
|
|
|
|
#include <LibRequests/NetworkError.h>
|
2022-10-05 09:32:17 -03:00
|
|
|
#include <LibWeb/Forward.h>
|
2023-03-20 19:39:20 -03:00
|
|
|
#include <LibWeb/HTML/ActivateTab.h>
|
2024-03-26 20:27:06 -03:00
|
|
|
#include <LibWeb/HTML/AudioPlayState.h>
|
2023-12-11 02:53:10 -03:00
|
|
|
#include <LibWeb/HTML/ColorPickerUpdateState.h>
|
2024-03-14 13:26:00 -03:00
|
|
|
#include <LibWeb/HTML/FileFilter.h>
|
2023-12-07 11:53:49 -03:00
|
|
|
#include <LibWeb/HTML/SelectItem.h>
|
2024-09-12 13:56:31 -03:00
|
|
|
#include <LibWeb/Page/EventResult.h>
|
2024-03-04 00:07:49 -03:00
|
|
|
#include <LibWeb/Page/InputEvent.h>
|
2026-03-16 21:28:02 -03:00
|
|
|
#include <LibWeb/Page/ViewportIsFullscreen.h>
|
2026-03-22 12:44:54 -03:00
|
|
|
#include <LibWebView/BookmarkStore.h>
|
2025-03-19 16:50:56 -03:00
|
|
|
#include <LibWebView/DOMNodeProperties.h>
|
2022-10-05 09:32:17 -03:00
|
|
|
#include <LibWebView/Forward.h>
|
2024-09-19 11:40:00 -03:00
|
|
|
#include <LibWebView/PageInfo.h>
|
2025-03-29 09:19:00 -03:00
|
|
|
#include <LibWebView/Settings.h>
|
2023-01-12 16:27:17 -03:00
|
|
|
#include <LibWebView/WebContentClient.h>
|
2022-10-05 09:32:17 -03:00
|
|
|
|
|
|
|
|
namespace WebView {
|
|
|
|
|
|
2026-03-22 12:44:54 -03:00
|
|
|
class WEBVIEW_API ViewImplementation
|
|
|
|
|
: public SettingsObserver
|
|
|
|
|
, public BookmarkStoreObserver {
|
2026-01-13 19:32:16 -03:00
|
|
|
friend class WebContentClient;
|
|
|
|
|
|
2022-10-05 09:32:17 -03:00
|
|
|
public:
|
2024-02-02 22:00:48 -03:00
|
|
|
virtual ~ViewImplementation();
|
2022-10-05 09:32:17 -03:00
|
|
|
|
2025-02-15 10:06:36 -03:00
|
|
|
static void for_each_view(Function<IterationDecision(ViewImplementation&)>);
|
|
|
|
|
static Optional<ViewImplementation&> find_view_by_id(u64);
|
|
|
|
|
|
|
|
|
|
u64 view_id() const { return m_view_id; }
|
|
|
|
|
|
2026-03-22 12:44:54 -03:00
|
|
|
void set_url(Badge<WebContentClient>, URL::URL url) { set_url(move(url)); }
|
2024-03-18 00:22:27 -03:00
|
|
|
URL::URL const& url() const { return m_url; }
|
2023-01-12 17:30:06 -03:00
|
|
|
|
2025-07-28 17:51:01 -03:00
|
|
|
void set_title(Badge<WebContentClient>, Utf16String title) { m_title = move(title); }
|
|
|
|
|
Utf16String const& title() const { return m_title; }
|
2025-02-17 08:43:06 -03:00
|
|
|
|
2026-03-22 12:44:54 -03:00
|
|
|
void set_favicon(Badge<WebContentClient>, Gfx::Bitmap const&);
|
|
|
|
|
Optional<String> const& favicon_base64_png() const { return m_favicon_base64_png; }
|
|
|
|
|
|
2023-03-16 12:24:30 -03:00
|
|
|
String const& handle() const { return m_client_state.client_handle; }
|
|
|
|
|
|
2025-03-09 12:40:34 -03:00
|
|
|
void create_new_process_for_cross_site_navigation(URL::URL const&);
|
|
|
|
|
|
2023-05-20 11:50:05 -03:00
|
|
|
void server_did_paint(Badge<WebContentClient>, i32 bitmap_id, Gfx::IntSize size);
|
|
|
|
|
|
2024-10-28 08:48:49 -03:00
|
|
|
void set_window_position(Gfx::IntPoint);
|
|
|
|
|
void set_window_size(Gfx::IntSize);
|
2024-10-29 00:37:11 -03:00
|
|
|
void did_update_window_rect();
|
2024-10-28 08:48:49 -03:00
|
|
|
|
2024-11-13 13:24:16 -03:00
|
|
|
void set_system_visibility_state(Web::HTML::VisibilityState);
|
|
|
|
|
|
2024-03-18 00:22:27 -03:00
|
|
|
void load(URL::URL const&);
|
2023-09-17 12:12:17 -03:00
|
|
|
void load_html(StringView);
|
2026-04-24 09:36:55 -03:00
|
|
|
void load_navigation_error_page(StringView);
|
|
|
|
|
|
2024-04-13 13:51:27 -03:00
|
|
|
void reload();
|
2024-04-13 17:33:48 -03:00
|
|
|
void traverse_the_history_by_delta(int delta);
|
2023-01-12 17:30:06 -03:00
|
|
|
|
2023-01-12 16:49:49 -03:00
|
|
|
void zoom_in();
|
|
|
|
|
void zoom_out();
|
2024-12-23 18:15:06 -03:00
|
|
|
void set_zoom(double zoom_level);
|
2023-01-12 16:49:49 -03:00
|
|
|
void reset_zoom();
|
2026-01-05 22:05:10 -03:00
|
|
|
double zoom_level() const { return m_zoom_level; }
|
|
|
|
|
double device_pixel_ratio() const { return m_device_pixel_ratio; }
|
2026-05-31 15:16:39 -03:00
|
|
|
Optional<u64> display_id() const { return m_display_id; }
|
2025-07-25 09:10:00 -03:00
|
|
|
double maximum_frames_per_second() const { return m_maximum_frames_per_second; }
|
2023-01-12 17:22:14 -03:00
|
|
|
|
2024-03-04 00:07:49 -03:00
|
|
|
void enqueue_input_event(Web::InputEvent);
|
2024-09-12 13:56:31 -03:00
|
|
|
void did_finish_handling_input_event(Badge<WebContentClient>, Web::EventResult event_result);
|
2024-03-04 00:07:49 -03:00
|
|
|
|
2023-01-12 17:44:42 -03:00
|
|
|
void set_preferred_color_scheme(Web::CSS::PreferredColorScheme);
|
2024-06-12 20:03:56 -03:00
|
|
|
void set_preferred_contrast(Web::CSS::PreferredContrast);
|
2024-06-13 11:15:59 -03:00
|
|
|
void set_preferred_motion(Web::CSS::PreferredMotion);
|
2024-07-02 16:29:43 -03:00
|
|
|
|
2026-06-10 07:19:44 -03:00
|
|
|
void notify_cookies_changed(HashTable<String> const& changed_domains, ReadonlySpan<HTTP::Cookie::Cookie> page_cookies, ReadonlySpan<HTTP::Cookie::Cookie> host_cookies);
|
|
|
|
|
void listen_for_host_cookie_changes(DevTools::DevToolsDelegate::OnHostCookieChange);
|
|
|
|
|
void stop_listening_for_host_cookie_changes();
|
2026-02-01 15:27:19 -03:00
|
|
|
ErrorOr<Core::SharedVersionIndex> ensure_document_cookie_version_index(Badge<WebContentClient>, String const&);
|
|
|
|
|
Optional<Core::SharedVersion> document_cookie_version(URL::URL const&) const;
|
2026-01-30 10:52:34 -03:00
|
|
|
|
2023-12-16 11:19:34 -03:00
|
|
|
ByteString selected_text();
|
2026-05-06 13:00:59 -03:00
|
|
|
ByteString cut_selected_text();
|
2023-10-23 17:52:57 -03:00
|
|
|
Optional<String> selected_text_with_whitespace_collapsed();
|
2023-01-12 17:42:42 -03:00
|
|
|
void select_all();
|
2024-05-31 17:01:34 -03:00
|
|
|
void find_in_page(String const& query, CaseSensitivity = CaseSensitivity::CaseInsensitive);
|
2024-05-29 16:09:33 -03:00
|
|
|
void find_in_page_next_match();
|
|
|
|
|
void find_in_page_previous_match();
|
2023-01-12 17:42:42 -03:00
|
|
|
|
2023-01-12 16:58:00 -03:00
|
|
|
void get_source();
|
2023-01-12 16:49:49 -03:00
|
|
|
|
2023-01-12 17:22:14 -03:00
|
|
|
void inspect_dom_tree();
|
2026-06-10 12:15:21 -03:00
|
|
|
void inspect_storage(Web::StorageAPI::StorageEndpointType, u64 request_id);
|
2023-01-12 17:22:14 -03:00
|
|
|
void inspect_accessibility_tree();
|
2023-12-30 11:42:24 -03:00
|
|
|
void get_hovered_node_id();
|
2026-05-28 08:14:41 -03:00
|
|
|
void start_node_picker(DevTools::DevToolsDelegate::OnNodePickerEvent);
|
|
|
|
|
void stop_node_picker();
|
|
|
|
|
void clear_node_picker();
|
|
|
|
|
bool is_node_picker_active() const { return m_node_picker_active; }
|
|
|
|
|
void node_picker_hover(Web::DevicePixelPoint);
|
|
|
|
|
void node_picker_pick(Web::DevicePixelPoint);
|
|
|
|
|
void node_picker_preview(Web::DevicePixelPoint);
|
|
|
|
|
void node_picker_cancel();
|
2023-01-12 17:22:14 -03:00
|
|
|
|
2026-06-04 11:17:17 -03:00
|
|
|
void inspect_dom_node(Web::UniqueNodeID node_id, DOMNodeProperties::Type, Optional<Web::CSS::PseudoElement> pseudo_element, JsonValue options = {});
|
2026-05-22 10:42:29 -03:00
|
|
|
void inspect_grid_layouts(Web::UniqueNodeID root_node_id);
|
|
|
|
|
void inspect_current_grid(Web::UniqueNodeID node_id);
|
2026-05-27 12:41:13 -03:00
|
|
|
void inspect_current_flexbox(Web::UniqueNodeID node_id, bool only_look_at_parents);
|
2025-02-21 11:34:02 -03:00
|
|
|
void clear_inspected_dom_node();
|
|
|
|
|
|
2025-03-20 13:56:46 -03:00
|
|
|
void highlight_dom_node(Web::UniqueNodeID node_id, Optional<Web::CSS::PseudoElement> pseudo_element);
|
2025-02-21 11:34:02 -03:00
|
|
|
void clear_highlighted_dom_node();
|
2026-05-27 13:12:14 -03:00
|
|
|
void highlight_flexbox(Web::UniqueNodeID node_id, JsonValue options);
|
|
|
|
|
void clear_flexbox_highlight(Web::UniqueNodeID node_id);
|
2026-05-22 10:42:29 -03:00
|
|
|
void highlight_grid(Web::UniqueNodeID node_id, JsonValue options);
|
|
|
|
|
void clear_grid_highlight(Web::UniqueNodeID node_id);
|
2025-02-21 11:34:02 -03:00
|
|
|
|
2025-03-06 19:32:43 -03:00
|
|
|
void set_listen_for_dom_mutations(bool);
|
2026-01-15 10:28:42 -03:00
|
|
|
void did_connect_devtools_client();
|
|
|
|
|
void did_disconnect_devtools_client();
|
2025-03-10 19:15:31 -03:00
|
|
|
void get_dom_node_inner_html(Web::UniqueNodeID node_id);
|
2025-03-10 18:36:41 -03:00
|
|
|
void get_dom_node_outer_html(Web::UniqueNodeID node_id);
|
|
|
|
|
void set_dom_node_outer_html(Web::UniqueNodeID node_id, String const& html);
|
2025-03-08 13:00:03 -03:00
|
|
|
void set_dom_node_text(Web::UniqueNodeID node_id, String const& text);
|
|
|
|
|
void set_dom_node_tag(Web::UniqueNodeID node_id, String const& name);
|
|
|
|
|
void add_dom_node_attributes(Web::UniqueNodeID node_id, ReadonlySpan<Attribute> attributes);
|
|
|
|
|
void replace_dom_node_attribute(Web::UniqueNodeID node_id, String const& name, ReadonlySpan<Attribute> replacement_attributes);
|
2024-10-20 05:37:44 -03:00
|
|
|
void create_child_element(Web::UniqueNodeID node_id);
|
|
|
|
|
void create_child_text_node(Web::UniqueNodeID node_id);
|
2025-03-10 19:01:29 -03:00
|
|
|
void insert_dom_node_before(Web::UniqueNodeID node_id, Web::UniqueNodeID parent_node_id, Optional<Web::UniqueNodeID> sibling_node_id);
|
2024-10-20 05:37:44 -03:00
|
|
|
void clone_dom_node(Web::UniqueNodeID node_id);
|
|
|
|
|
void remove_dom_node(Web::UniqueNodeID node_id);
|
2023-11-19 12:42:11 -03:00
|
|
|
|
2024-08-23 07:18:35 -03:00
|
|
|
void list_style_sheets();
|
|
|
|
|
void request_style_sheet_source(Web::CSS::StyleSheetIdentifier const&);
|
|
|
|
|
|
2023-12-16 11:19:34 -03:00
|
|
|
void debug_request(ByteString const& request, ByteString const& argument = {});
|
2026-05-21 12:46:17 -03:00
|
|
|
void set_content_blockers(Core::AnonymousBuffer const& patterns);
|
2023-01-12 17:34:08 -03:00
|
|
|
|
2025-03-08 13:00:03 -03:00
|
|
|
void run_javascript(String const&);
|
|
|
|
|
void js_console_input(String const&);
|
2025-04-01 09:23:04 -03:00
|
|
|
void exit_fullscreen();
|
2023-01-12 17:39:08 -03:00
|
|
|
|
2026-03-16 21:28:02 -03:00
|
|
|
void set_is_fullscreen(Web::ViewportIsFullscreen is_fullscreen);
|
2026-03-22 20:25:10 -03:00
|
|
|
Web::ViewportIsFullscreen is_fullscreen() const { return m_is_fullscreen; }
|
2026-03-16 21:28:02 -03:00
|
|
|
|
2023-05-17 15:23:34 -03:00
|
|
|
void alert_closed();
|
|
|
|
|
void confirm_closed(bool accepted);
|
2025-03-08 13:00:03 -03:00
|
|
|
void prompt_closed(Optional<String> const& response);
|
2023-12-11 02:53:10 -03:00
|
|
|
void color_picker_update(Optional<Color> picked_color, Web::HTML::ColorPickerUpdateState state);
|
2024-02-25 15:02:47 -03:00
|
|
|
void file_picker_closed(Vector<Web::HTML::SelectedFile> selected_files);
|
2024-04-03 14:19:08 -03:00
|
|
|
void select_dropdown_closed(Optional<u32> const& selected_item_id);
|
2023-05-17 15:23:34 -03:00
|
|
|
|
2025-09-01 09:20:14 -03:00
|
|
|
void paste_text_from_clipboard();
|
2025-05-01 12:38:31 -03:00
|
|
|
void retrieved_clipboard_entries(u64 request_id, ReadonlySpan<Web::Clipboard::SystemClipboardItem>);
|
|
|
|
|
|
2026-05-28 11:48:50 -03:00
|
|
|
// Used by platform input methods to drive marked/preedit-text composition, and to query the on-screen caret
|
|
|
|
|
// position for placing IME overlays.
|
|
|
|
|
void set_marked_text_from_input_method(Utf16String const& text);
|
|
|
|
|
void commit_text_from_input_method(Utf16String const& text);
|
|
|
|
|
void unmark_text_from_input_method();
|
|
|
|
|
Optional<Web::DevicePixelRect> get_input_caret_rect();
|
|
|
|
|
void set_input_caret_rect(Badge<WebContentClient>, Optional<Web::DevicePixelRect>);
|
|
|
|
|
|
2024-03-30 10:41:15 -03:00
|
|
|
Web::HTML::MuteState page_mute_state() const { return m_mute_state; }
|
|
|
|
|
void toggle_page_mute_state();
|
|
|
|
|
|
2024-03-26 20:27:06 -03:00
|
|
|
void did_change_audio_play_state(Badge<WebContentClient>, Web::HTML::AudioPlayState);
|
|
|
|
|
Web::HTML::AudioPlayState audio_play_state() const { return m_audio_play_state; }
|
|
|
|
|
|
2024-04-13 18:12:55 -03:00
|
|
|
void did_update_navigation_buttons_state(Badge<WebContentClient>, bool back_enabled, bool forward_enabled) const;
|
2026-05-26 13:03:07 -03:00
|
|
|
void did_change_needs_beforeunload_check(Badge<WebContentClient>, bool needs_beforeunload_check);
|
2026-05-24 15:44:30 -03:00
|
|
|
void did_change_background_color(Badge<WebContentClient>, Gfx::Color);
|
|
|
|
|
Gfx::Color page_background_color() const { return m_page_background_color; }
|
2024-04-13 18:12:55 -03:00
|
|
|
|
2026-04-07 13:35:26 -03:00
|
|
|
void did_allocate_backing_stores(Badge<WebContentClient>, i32 front_bitmap_id, Gfx::SharedImage front_backing_store, i32 back_bitmap_id, Gfx::SharedImage back_backing_store);
|
2024-06-17 12:50:57 -03:00
|
|
|
|
2023-05-17 10:53:13 -03:00
|
|
|
enum class ScreenshotType {
|
|
|
|
|
Visible,
|
|
|
|
|
Full,
|
|
|
|
|
};
|
2023-12-31 11:51:02 -03:00
|
|
|
NonnullRefPtr<Core::Promise<LexicalPath>> take_screenshot(ScreenshotType);
|
2024-10-20 05:37:44 -03:00
|
|
|
NonnullRefPtr<Core::Promise<LexicalPath>> take_dom_node_screenshot(Web::UniqueNodeID);
|
2023-12-31 11:51:02 -03:00
|
|
|
virtual void did_receive_screenshot(Badge<WebContentClient>, Gfx::ShareableBitmap const&);
|
2023-05-17 10:53:13 -03:00
|
|
|
|
2024-09-19 11:40:00 -03:00
|
|
|
NonnullRefPtr<Core::Promise<String>> request_internal_page_info(PageInfoType);
|
2026-02-01 16:18:43 -03:00
|
|
|
void did_receive_internal_page_info(Badge<WebContentClient>, PageInfoType, Optional<Core::AnonymousBuffer> const&);
|
2024-09-19 11:40:00 -03:00
|
|
|
|
2023-12-12 09:25:06 -03:00
|
|
|
ErrorOr<LexicalPath> dump_gc_graph();
|
|
|
|
|
|
2025-03-08 13:00:03 -03:00
|
|
|
void set_user_style_sheet(String const& source);
|
2023-08-26 14:34:59 -03:00
|
|
|
|
2025-11-07 12:35:05 -03:00
|
|
|
void request_close();
|
2026-05-26 13:03:07 -03:00
|
|
|
Function<void()> prepare_for_immediate_close();
|
|
|
|
|
bool needs_beforeunload_check() const { return m_needs_beforeunload_check; }
|
2025-11-07 12:35:05 -03:00
|
|
|
|
2023-05-20 11:50:05 -03:00
|
|
|
Function<void()> on_ready_to_paint;
|
2024-01-31 00:05:00 -03:00
|
|
|
Function<String(Web::HTML::ActivateTab, Web::HTML::WebViewHints, Optional<u64>)> on_new_web_view;
|
2023-05-17 13:37:31 -03:00
|
|
|
Function<void()> on_activate_tab;
|
|
|
|
|
Function<void()> on_close;
|
2024-03-28 23:02:55 -03:00
|
|
|
Function<void(URL::URL const&)> on_link_hover;
|
2023-05-17 13:37:31 -03:00
|
|
|
Function<void()> on_link_unhover;
|
2025-07-28 17:51:01 -03:00
|
|
|
Function<void(Utf16String const&)> on_title_change;
|
2024-04-14 05:27:20 -03:00
|
|
|
Function<void(URL::URL const&)> on_url_change;
|
2024-03-28 23:02:55 -03:00
|
|
|
Function<void(URL::URL const&, bool)> on_load_start;
|
|
|
|
|
Function<void(URL::URL const&)> on_load_finish;
|
2026-01-14 15:03:16 -03:00
|
|
|
|
|
|
|
|
struct NavigationListener {
|
|
|
|
|
Function<void(URL::URL const&, bool)> on_load_start;
|
|
|
|
|
Function<void(URL::URL const&)> on_load_finish;
|
|
|
|
|
};
|
|
|
|
|
u64 add_navigation_listener(NavigationListener);
|
|
|
|
|
void remove_navigation_listener(u64 listener_id);
|
|
|
|
|
|
2023-12-16 11:19:34 -03:00
|
|
|
Function<void(ByteString const& path, i32)> on_request_file;
|
2023-05-17 13:37:31 -03:00
|
|
|
Function<void(Gfx::Bitmap const&)> on_favicon_change;
|
2025-02-20 09:17:29 -03:00
|
|
|
Function<void(Gfx::Cursor const&)> on_cursor_change;
|
2024-07-02 11:48:57 -03:00
|
|
|
Function<void(Gfx::IntPoint, ByteString const&)> on_request_tooltip_override;
|
|
|
|
|
Function<void()> on_stop_tooltip_override;
|
2024-07-02 09:16:24 -03:00
|
|
|
Function<void(ByteString const&)> on_enter_tooltip_area;
|
2023-08-23 12:11:39 -03:00
|
|
|
Function<void()> on_leave_tooltip_area;
|
2023-05-17 15:23:34 -03:00
|
|
|
Function<void(String const& message)> on_request_alert;
|
|
|
|
|
Function<void(String const& message)> on_request_confirm;
|
|
|
|
|
Function<void(String const& message, String const& default_)> on_request_prompt;
|
|
|
|
|
Function<void(String const& message)> on_request_set_prompt_text;
|
|
|
|
|
Function<void()> on_request_accept_dialog;
|
|
|
|
|
Function<void()> on_request_dismiss_dialog;
|
2025-02-21 14:39:43 -03:00
|
|
|
Function<void(JsonObject)> on_received_dom_tree;
|
|
|
|
|
Function<void(DOMNodeProperties)> on_received_dom_node_properties;
|
2026-06-10 12:15:21 -03:00
|
|
|
HashMap<u64, Function<void(ErrorOr<Vector<DevTools::DevToolsDelegate::StorageItem>>)>> on_received_storage_items;
|
2026-05-22 10:42:29 -03:00
|
|
|
Function<void(JsonArray)> on_received_grid_layouts;
|
|
|
|
|
Function<void(Optional<JsonObject>)> on_received_current_grid;
|
2026-05-27 12:41:13 -03:00
|
|
|
Function<void(Optional<JsonObject>)> on_received_current_flexbox;
|
2025-02-21 14:39:43 -03:00
|
|
|
Function<void(JsonObject)> on_received_accessibility_tree;
|
2024-10-20 05:37:44 -03:00
|
|
|
Function<void(Web::UniqueNodeID)> on_received_hovered_node_id;
|
2025-03-06 19:32:43 -03:00
|
|
|
Function<void(Mutation)> on_dom_mutation_received;
|
2025-04-07 07:46:22 -03:00
|
|
|
Function<void(Optional<Web::UniqueNodeID> const& node_id)> on_finished_editing_dom_node;
|
2025-03-10 18:36:41 -03:00
|
|
|
Function<void(String)> on_received_dom_node_html;
|
2025-03-14 17:22:16 -03:00
|
|
|
Function<void(Vector<Web::CSS::StyleSheetIdentifier>)> on_received_style_sheet_list;
|
|
|
|
|
Function<void(Web::CSS::StyleSheetIdentifier const&, URL::URL const&, String const&)> on_received_style_sheet_source;
|
2025-02-24 13:57:33 -03:00
|
|
|
Function<void(JsonValue)> on_received_js_console_result;
|
2026-01-14 16:13:24 -03:00
|
|
|
Function<void(ConsoleOutput)> on_console_message;
|
2026-01-14 19:24:51 -03:00
|
|
|
Function<void(u64 request_id, URL::URL const&, ByteString const&, Vector<HTTP::Header> const&, ByteBuffer, Optional<String>)> on_network_request_started;
|
2026-01-14 14:43:48 -03:00
|
|
|
Function<void(u64 request_id, u32 status_code, Optional<String> const&, Vector<HTTP::Header> const&)> on_network_response_headers_received;
|
2026-01-14 16:47:04 -03:00
|
|
|
Function<void(u64 request_id, ByteBuffer)> on_network_response_body_received;
|
2026-01-14 14:43:48 -03:00
|
|
|
Function<void(u64 request_id, u64 body_size, Requests::RequestTimingInfo const&, Optional<Requests::NetworkError> const&)> on_network_request_finished;
|
2023-05-17 13:37:31 -03:00
|
|
|
Function<void(i32 count_waiting)> on_resource_status_change;
|
|
|
|
|
Function<void()> on_restore_window;
|
2024-10-29 00:37:11 -03:00
|
|
|
Function<void(Gfx::IntPoint)> on_reposition_window;
|
|
|
|
|
Function<void(Gfx::IntSize)> on_resize_window;
|
2024-10-29 00:45:18 -03:00
|
|
|
Function<void()> on_maximize_window;
|
|
|
|
|
Function<void()> on_minimize_window;
|
|
|
|
|
Function<void()> on_fullscreen_window;
|
2025-03-27 11:59:17 -03:00
|
|
|
Function<void()> on_exit_fullscreen_window;
|
2023-09-04 06:32:40 -03:00
|
|
|
Function<void(Color current_color)> on_request_color_picker;
|
2024-03-14 13:26:00 -03:00
|
|
|
Function<void(Web::HTML::FileFilter const& accepted_file_types, Web::HTML::AllowMultipleFiles)> on_request_file_picker;
|
2023-12-07 11:53:49 -03:00
|
|
|
Function<void(Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> items)> on_request_select_dropdown;
|
2024-03-04 00:07:49 -03:00
|
|
|
Function<void(Web::KeyEvent const&)> on_finish_handling_key_event;
|
2024-08-17 14:36:28 -03:00
|
|
|
Function<void(Web::DragEvent const&)> on_finish_handling_drag_event;
|
2025-03-18 13:37:32 -03:00
|
|
|
Function<void(String const&)> on_test_finish;
|
2024-12-19 11:16:05 -03:00
|
|
|
Function<void(double milliseconds)> on_set_test_timeout;
|
2025-07-16 05:24:15 -03:00
|
|
|
Function<void(JsonValue)> on_reference_test_metadata;
|
2024-06-09 14:35:32 -03:00
|
|
|
Function<void(size_t current_match_index, Optional<size_t> const& total_match_count)> on_find_in_page;
|
2023-09-18 20:51:48 -03:00
|
|
|
Function<void(Gfx::Color)> on_theme_color_change;
|
2026-05-24 15:44:30 -03:00
|
|
|
Function<void(Gfx::Color)> on_page_background_color_change;
|
2024-03-26 20:27:06 -03:00
|
|
|
Function<void(Web::HTML::AudioPlayState)> on_audio_play_state_changed;
|
2024-11-13 18:35:17 -03:00
|
|
|
Function<void()> on_web_content_crashed;
|
2026-02-20 12:21:22 -03:00
|
|
|
Function<void()> on_web_content_process_change_for_cross_site_navigation;
|
2023-01-12 16:27:17 -03:00
|
|
|
|
2025-09-01 09:20:14 -03:00
|
|
|
Menu& page_context_menu() { return *m_page_context_menu; }
|
|
|
|
|
Menu& link_context_menu() { return *m_link_context_menu; }
|
|
|
|
|
Menu& image_context_menu() { return *m_image_context_menu; }
|
|
|
|
|
Menu& media_context_menu() { return *m_media_context_menu; }
|
|
|
|
|
|
2026-05-06 13:00:59 -03:00
|
|
|
void did_request_page_context_menu(Badge<WebContentClient>, Gfx::IntPoint content_position, Web::ContextMenuForInputEventsTarget for_input_events_target);
|
2025-09-01 09:20:14 -03:00
|
|
|
void did_request_link_context_menu(Badge<WebContentClient>, Gfx::IntPoint content_position, URL::URL url);
|
|
|
|
|
void did_request_image_context_menu(Badge<WebContentClient>, Gfx::IntPoint content_position, URL::URL url, Optional<Gfx::ShareableBitmap> bitmap);
|
|
|
|
|
void did_request_media_context_menu(Badge<WebContentClient>, Gfx::IntPoint content_position, Web::Page::MediaContextMenu menu);
|
|
|
|
|
|
|
|
|
|
Action& navigate_back_action() { return *m_navigate_back_action; }
|
|
|
|
|
Action& navigate_forward_action() { return *m_navigate_forward_action; }
|
2026-03-22 12:44:54 -03:00
|
|
|
Action& toggle_bookmark_action() { return *m_toggle_bookmark_action; }
|
2025-09-10 08:23:15 -03:00
|
|
|
Action& reset_zoom_action() { return *m_reset_zoom_action; }
|
2025-09-01 09:20:14 -03:00
|
|
|
|
2026-05-24 05:02:05 -03:00
|
|
|
WebContentClient& client();
|
|
|
|
|
WebContentClient const& client() const;
|
|
|
|
|
|
2024-06-03 11:53:55 -03:00
|
|
|
virtual Web::DevicePixelSize viewport_size() const = 0;
|
2023-05-17 11:12:13 -03:00
|
|
|
virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const = 0;
|
|
|
|
|
virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const = 0;
|
2023-05-15 02:59:51 -03:00
|
|
|
|
2023-01-12 16:27:17 -03:00
|
|
|
protected:
|
2026-01-05 22:05:10 -03:00
|
|
|
static constexpr auto ZOOM_MIN_LEVEL = 0.3;
|
|
|
|
|
static constexpr auto ZOOM_MAX_LEVEL = 5.0;
|
|
|
|
|
static constexpr auto ZOOM_STEP = 0.1;
|
2023-01-12 16:49:49 -03:00
|
|
|
|
2023-08-07 11:44:20 -03:00
|
|
|
ViewImplementation();
|
2023-05-15 02:59:51 -03:00
|
|
|
|
2024-02-02 22:00:48 -03:00
|
|
|
u64 page_id() const;
|
2025-09-10 08:23:15 -03:00
|
|
|
|
2026-03-22 12:44:54 -03:00
|
|
|
void set_url(URL::URL);
|
|
|
|
|
|
2025-09-10 08:23:15 -03:00
|
|
|
virtual void update_zoom();
|
2026-05-04 15:59:22 -03:00
|
|
|
String current_host() const;
|
|
|
|
|
void apply_zoom_for_current_host();
|
2023-01-12 16:27:17 -03:00
|
|
|
|
2023-05-15 02:59:51 -03:00
|
|
|
void handle_resize();
|
2026-05-26 20:11:14 -03:00
|
|
|
void set_page_background_color_to_system_canvas(bool dark);
|
|
|
|
|
void set_page_background_color(Gfx::Color);
|
2026-05-27 05:25:08 -03:00
|
|
|
Gfx::Color preferred_canvas_background_color() const;
|
2026-05-20 11:42:08 -03:00
|
|
|
void load_crash_page_html(StringView, URL::URL const& crashed_url);
|
2023-05-15 02:59:51 -03:00
|
|
|
|
2024-01-30 13:12:14 -03:00
|
|
|
enum class CreateNewClient {
|
|
|
|
|
No,
|
|
|
|
|
Yes,
|
|
|
|
|
};
|
2024-11-13 18:35:17 -03:00
|
|
|
virtual void initialize_client(CreateNewClient = CreateNewClient::Yes);
|
2023-04-14 21:04:28 -03:00
|
|
|
|
2024-11-12 10:43:37 -03:00
|
|
|
enum class LoadErrorPage {
|
|
|
|
|
No,
|
|
|
|
|
Yes,
|
|
|
|
|
};
|
|
|
|
|
void handle_web_content_process_crash(LoadErrorPage = LoadErrorPage::Yes);
|
2023-05-17 10:53:13 -03:00
|
|
|
|
2025-08-23 13:15:31 -03:00
|
|
|
virtual void default_zoom_level_factor_changed() override;
|
2026-05-04 15:59:22 -03:00
|
|
|
virtual void zoom_per_host_changed(StringView host) override;
|
2025-04-03 14:53:02 -03:00
|
|
|
virtual void languages_changed() override;
|
2026-04-13 11:55:24 -03:00
|
|
|
virtual void browsing_behavior_changed() override;
|
2025-03-29 09:19:00 -03:00
|
|
|
virtual void autoplay_settings_changed() override;
|
2025-04-02 10:30:34 -03:00
|
|
|
virtual void global_privacy_control_changed() override;
|
2025-03-29 09:19:00 -03:00
|
|
|
|
2026-03-22 12:44:54 -03:00
|
|
|
virtual void bookmarks_changed() override;
|
|
|
|
|
void update_bookmark_action();
|
|
|
|
|
|
2025-09-01 09:20:14 -03:00
|
|
|
void initialize_context_menus();
|
|
|
|
|
|
2023-01-12 16:27:17 -03:00
|
|
|
struct SharedBitmap {
|
|
|
|
|
i32 id { -1 };
|
2023-12-14 03:17:00 -03:00
|
|
|
Web::DevicePixelSize last_painted_size;
|
2026-04-07 13:35:26 -03:00
|
|
|
OwnPtr<Gfx::SharedImageBuffer> shared_image_buffer;
|
2023-01-12 16:27:17 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ClientState {
|
|
|
|
|
RefPtr<WebContentClient> client;
|
2023-03-16 12:24:30 -03:00
|
|
|
String client_handle;
|
2023-01-12 16:27:17 -03:00
|
|
|
SharedBitmap front_bitmap;
|
|
|
|
|
SharedBitmap back_bitmap;
|
2024-01-30 13:12:14 -03:00
|
|
|
u64 page_index { 0 };
|
2023-01-12 16:27:17 -03:00
|
|
|
bool has_usable_bitmap { false };
|
|
|
|
|
} m_client_state;
|
2023-01-12 16:49:49 -03:00
|
|
|
|
2024-03-18 00:22:27 -03:00
|
|
|
URL::URL m_url;
|
2025-07-28 17:51:01 -03:00
|
|
|
Utf16String m_title;
|
2026-03-22 12:44:54 -03:00
|
|
|
Optional<String> m_favicon_base64_png;
|
2023-01-12 17:30:06 -03:00
|
|
|
|
2026-01-05 22:05:10 -03:00
|
|
|
double m_zoom_level { 1.0 };
|
|
|
|
|
double m_device_pixel_ratio { 1.0 };
|
2026-05-31 15:16:39 -03:00
|
|
|
Optional<u64> m_display_id;
|
2025-07-25 09:10:00 -03:00
|
|
|
double m_maximum_frames_per_second { 60.0 };
|
2023-05-15 02:59:51 -03:00
|
|
|
|
2025-09-01 09:20:14 -03:00
|
|
|
RefPtr<Menu> m_page_context_menu;
|
|
|
|
|
RefPtr<Menu> m_link_context_menu;
|
|
|
|
|
RefPtr<Menu> m_image_context_menu;
|
|
|
|
|
RefPtr<Menu> m_media_context_menu;
|
|
|
|
|
|
|
|
|
|
RefPtr<Action> m_navigate_back_action;
|
|
|
|
|
RefPtr<Action> m_navigate_forward_action;
|
|
|
|
|
|
2026-03-22 12:44:54 -03:00
|
|
|
RefPtr<Action> m_toggle_bookmark_action;
|
|
|
|
|
|
2025-09-10 08:23:15 -03:00
|
|
|
RefPtr<Action> m_reset_zoom_action;
|
|
|
|
|
|
2025-09-01 09:20:14 -03:00
|
|
|
RefPtr<Action> m_search_selected_text_action;
|
|
|
|
|
Optional<String> m_search_text;
|
|
|
|
|
|
|
|
|
|
RefPtr<Action> m_take_visible_screenshot_action;
|
|
|
|
|
RefPtr<Action> m_take_full_screenshot_action;
|
|
|
|
|
|
|
|
|
|
RefPtr<Action> m_open_in_new_tab_action;
|
2026-02-17 16:23:45 -03:00
|
|
|
RefPtr<Action> m_open_in_new_window_action;
|
2025-09-01 09:20:14 -03:00
|
|
|
RefPtr<Action> m_copy_url_action;
|
|
|
|
|
URL::URL m_context_menu_url;
|
|
|
|
|
|
|
|
|
|
RefPtr<Action> m_open_image_action;
|
2026-02-03 10:00:15 -03:00
|
|
|
RefPtr<Action> m_save_image_action;
|
2025-09-01 09:20:14 -03:00
|
|
|
RefPtr<Action> m_copy_image_action;
|
|
|
|
|
Optional<Gfx::ShareableBitmap> m_image_context_menu_bitmap;
|
|
|
|
|
|
|
|
|
|
RefPtr<Action> m_open_audio_action;
|
|
|
|
|
RefPtr<Action> m_open_video_action;
|
|
|
|
|
RefPtr<Action> m_media_play_action;
|
|
|
|
|
RefPtr<Action> m_media_pause_action;
|
|
|
|
|
RefPtr<Action> m_media_mute_action;
|
|
|
|
|
RefPtr<Action> m_media_unmute_action;
|
2025-09-16 13:55:37 -03:00
|
|
|
RefPtr<Action> m_media_show_controls_action;
|
|
|
|
|
RefPtr<Action> m_media_hide_controls_action;
|
2025-09-01 09:20:14 -03:00
|
|
|
RefPtr<Action> m_media_loop_action;
|
2026-02-28 11:36:32 -03:00
|
|
|
RefPtr<Action> m_media_enter_fullscreen_action;
|
|
|
|
|
RefPtr<Action> m_media_exit_fullscreen_action;
|
2025-09-01 09:20:14 -03:00
|
|
|
|
2024-03-04 00:07:49 -03:00
|
|
|
Queue<Web::InputEvent> m_pending_input_events;
|
|
|
|
|
|
2023-05-15 02:59:51 -03:00
|
|
|
RefPtr<Core::Timer> m_backing_store_shrink_timer;
|
|
|
|
|
|
2026-04-07 13:35:26 -03:00
|
|
|
OwnPtr<Gfx::SharedImageBuffer> m_backup_shared_image_buffer;
|
2023-12-14 03:17:00 -03:00
|
|
|
Web::DevicePixelSize m_backup_bitmap_size;
|
2026-05-24 15:44:30 -03:00
|
|
|
Gfx::Color m_page_background_color { 255, 255, 255 };
|
2026-05-26 20:11:14 -03:00
|
|
|
Gfx::Color m_system_canvas_background_color { 255, 255, 255 };
|
2026-05-27 05:25:08 -03:00
|
|
|
Web::CSS::PreferredColorScheme m_preferred_color_scheme { Web::CSS::PreferredColorScheme::Auto };
|
2023-05-27 13:46:45 -03:00
|
|
|
|
2026-05-20 11:42:08 -03:00
|
|
|
bool m_should_suppress_history_for_current_load { false };
|
|
|
|
|
bool m_should_suppress_history_for_next_load { false };
|
2023-05-27 13:46:45 -03:00
|
|
|
size_t m_crash_count = 0;
|
|
|
|
|
RefPtr<Core::Timer> m_repeated_crash_timer;
|
2023-12-31 11:51:02 -03:00
|
|
|
|
|
|
|
|
RefPtr<Core::Promise<LexicalPath>> m_pending_screenshot;
|
2024-09-19 11:40:00 -03:00
|
|
|
RefPtr<Core::Promise<String>> m_pending_info_request;
|
2024-03-26 20:27:06 -03:00
|
|
|
|
2024-11-13 13:24:16 -03:00
|
|
|
Web::HTML::VisibilityState m_system_visibility_state { Web::HTML::VisibilityState::Hidden };
|
|
|
|
|
|
2024-03-26 20:27:06 -03:00
|
|
|
Web::HTML::AudioPlayState m_audio_play_state { Web::HTML::AudioPlayState::Paused };
|
2024-03-30 10:34:23 -03:00
|
|
|
size_t m_number_of_elements_playing_audio { 0 };
|
2024-03-30 10:41:15 -03:00
|
|
|
|
|
|
|
|
Web::HTML::MuteState m_mute_state { Web::HTML::MuteState::Unmuted };
|
2025-02-15 10:06:36 -03:00
|
|
|
|
2026-05-28 11:48:50 -03:00
|
|
|
// Most recent caret position pushed by WebContent, Used for placing platform IME overlays without a sync IPC.
|
|
|
|
|
Optional<Web::DevicePixelRect> m_input_caret_rect;
|
|
|
|
|
|
2026-03-16 21:28:02 -03:00
|
|
|
Web::ViewportIsFullscreen m_is_fullscreen { Web::ViewportIsFullscreen::No };
|
|
|
|
|
|
2026-02-01 15:27:19 -03:00
|
|
|
Core::AnonymousBuffer m_document_cookie_version_buffer;
|
|
|
|
|
HashMap<String, Core::SharedVersionIndex> m_document_cookie_version_indices;
|
2026-06-10 07:19:44 -03:00
|
|
|
DevTools::DevToolsDelegate::OnHostCookieChange m_on_host_cookie_change;
|
2026-02-01 15:27:19 -03:00
|
|
|
|
2025-02-15 10:06:36 -03:00
|
|
|
// FIXME: Reconcile this ID with `page_id`. The latter is only unique per WebContent connection, whereas the view ID
|
|
|
|
|
// is required to be globally unique for Firefox DevTools.
|
|
|
|
|
u64 m_view_id { 0 };
|
2026-01-14 15:03:16 -03:00
|
|
|
|
|
|
|
|
HashMap<u64, NavigationListener> m_navigation_listeners;
|
|
|
|
|
u64 m_next_navigation_listener_id { 1 };
|
2026-01-15 10:28:42 -03:00
|
|
|
|
2026-05-28 08:14:41 -03:00
|
|
|
enum class NodePickerRequestType : u8 {
|
|
|
|
|
Hovered,
|
|
|
|
|
Picked,
|
|
|
|
|
Previewed,
|
|
|
|
|
};
|
|
|
|
|
void request_node_picker_hit_test(NodePickerRequestType, Web::DevicePixelPoint);
|
|
|
|
|
void did_receive_node_picker_hit_test(u64 request_id, Web::UniqueNodeID);
|
|
|
|
|
|
|
|
|
|
bool m_node_picker_active { false };
|
|
|
|
|
Optional<Web::UniqueNodeID> m_node_picker_hovered_node_id;
|
|
|
|
|
u64 m_next_node_picker_request_id { 1 };
|
|
|
|
|
HashMap<u64, NodePickerRequestType> m_pending_node_picker_requests;
|
|
|
|
|
DevTools::DevToolsDelegate::OnNodePickerEvent m_on_node_picker_event;
|
|
|
|
|
|
2026-01-15 10:28:42 -03:00
|
|
|
bool m_devtools_connected { false };
|
2026-05-26 13:03:07 -03:00
|
|
|
bool m_needs_beforeunload_check { true };
|
2022-10-05 09:32:17 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|