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>
|
2025-02-21 14:39:43 -03:00
|
|
|
#include <AK/JsonArray.h>
|
|
|
|
|
#include <AK/JsonObject.h>
|
2023-12-09 18:57:57 -03:00
|
|
|
#include <AK/LexicalPath.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>
|
2024-06-20 15:34:51 -03:00
|
|
|
#include <LibCore/Forward.h>
|
2023-12-31 11:51:02 -03:00
|
|
|
#include <LibCore/Promise.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>
|
|
|
|
|
#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>
|
2022-10-05 09:32:17 -03:00
|
|
|
#include <LibWebView/Forward.h>
|
2024-09-19 11:40:00 -03:00
|
|
|
#include <LibWebView/PageInfo.h>
|
2023-01-12 16:27:17 -03:00
|
|
|
#include <LibWebView/WebContentClient.h>
|
2022-10-05 09:32:17 -03:00
|
|
|
|
|
|
|
|
namespace WebView {
|
|
|
|
|
|
|
|
|
|
class ViewImplementation {
|
|
|
|
|
public:
|
2024-02-02 22:00:48 -03:00
|
|
|
virtual ~ViewImplementation();
|
2022-10-05 09:32:17 -03:00
|
|
|
|
2023-01-12 17:22:14 -03:00
|
|
|
struct DOMNodeProperties {
|
2025-02-21 14:39:43 -03:00
|
|
|
JsonObject computed_style;
|
|
|
|
|
JsonObject resolved_style;
|
|
|
|
|
JsonObject custom_properties;
|
|
|
|
|
JsonObject node_box_sizing;
|
|
|
|
|
JsonObject aria_properties_state;
|
|
|
|
|
JsonArray fonts;
|
2023-01-12 17:22:14 -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; }
|
|
|
|
|
|
2024-03-18 00:22:27 -03:00
|
|
|
void set_url(Badge<WebContentClient>, URL::URL url) { m_url = move(url); }
|
|
|
|
|
URL::URL const& url() const { return m_url; }
|
2023-01-12 17:30:06 -03:00
|
|
|
|
2025-02-17 08:43:06 -03:00
|
|
|
void set_title(Badge<WebContentClient>, ByteString title) { m_title = move(title); }
|
|
|
|
|
ByteString const& title() const { return m_title; }
|
|
|
|
|
|
2023-03-16 12:24:30 -03:00
|
|
|
String const& handle() const { return m_client_state.client_handle; }
|
|
|
|
|
|
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);
|
2023-01-12 17:30:06 -03:00
|
|
|
void load_empty_document();
|
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();
|
2023-03-26 15:41:56 -03:00
|
|
|
float zoom_level() const { return m_zoom_level; }
|
2023-12-12 18:33:36 -03:00
|
|
|
float device_pixel_ratio() const { return m_device_pixel_ratio; }
|
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
|
|
|
|
2024-07-23 17:10:24 -03:00
|
|
|
void set_preferred_languages(Vector<String>);
|
|
|
|
|
|
2024-07-02 16:29:43 -03:00
|
|
|
void set_enable_do_not_track(bool);
|
2023-01-12 17:44:42 -03:00
|
|
|
|
2024-09-22 19:12:36 -03:00
|
|
|
void set_enable_autoplay(bool);
|
|
|
|
|
|
2023-12-16 11:19:34 -03:00
|
|
|
ByteString 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();
|
2024-03-22 07:56:49 -03:00
|
|
|
void paste(String const&);
|
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();
|
|
|
|
|
void inspect_accessibility_tree();
|
2023-12-30 11:42:24 -03:00
|
|
|
void get_hovered_node_id();
|
2023-01-12 17:22:14 -03:00
|
|
|
|
2025-02-21 11:34:02 -03:00
|
|
|
void inspect_dom_node(Web::UniqueNodeID node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element);
|
|
|
|
|
void clear_inspected_dom_node();
|
|
|
|
|
|
|
|
|
|
void highlight_dom_node(Web::UniqueNodeID node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element);
|
|
|
|
|
void clear_highlighted_dom_node();
|
|
|
|
|
|
2024-10-20 05:37:44 -03:00
|
|
|
void set_dom_node_text(Web::UniqueNodeID node_id, String text);
|
|
|
|
|
void set_dom_node_tag(Web::UniqueNodeID node_id, String name);
|
|
|
|
|
void add_dom_node_attributes(Web::UniqueNodeID node_id, Vector<Attribute> attributes);
|
|
|
|
|
void replace_dom_node_attribute(Web::UniqueNodeID node_id, String name, Vector<Attribute> replacement_attributes);
|
|
|
|
|
void create_child_element(Web::UniqueNodeID node_id);
|
|
|
|
|
void create_child_text_node(Web::UniqueNodeID node_id);
|
|
|
|
|
void clone_dom_node(Web::UniqueNodeID node_id);
|
|
|
|
|
void remove_dom_node(Web::UniqueNodeID node_id);
|
|
|
|
|
void get_dom_node_html(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 = {});
|
2023-01-12 17:34:08 -03:00
|
|
|
|
2025-02-23 10:57:40 -03:00
|
|
|
void run_javascript(String);
|
|
|
|
|
void js_console_input(String);
|
2023-05-17 12:54:36 -03:00
|
|
|
void js_console_request_messages(i32 start_index);
|
2023-01-12 17:39:08 -03:00
|
|
|
|
2023-05-17 15:23:34 -03:00
|
|
|
void alert_closed();
|
|
|
|
|
void confirm_closed(bool accepted);
|
|
|
|
|
void prompt_closed(Optional<String> 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
|
|
|
|
2023-06-16 11:51:38 -03:00
|
|
|
void toggle_media_play_state();
|
2023-06-16 12:29:54 -03:00
|
|
|
void toggle_media_mute_state();
|
2023-06-16 11:51:38 -03:00
|
|
|
void toggle_media_loop_state();
|
|
|
|
|
void toggle_media_controls_state();
|
2023-05-15 12:17:58 -03:00
|
|
|
|
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;
|
|
|
|
|
|
2024-06-17 12:50:57 -03:00
|
|
|
void did_allocate_backing_stores(Badge<WebContentClient>, i32 front_bitmap_id, Gfx::ShareableBitmap const&, i32 back_bitmap_id, Gfx::ShareableBitmap const&);
|
2024-06-20 15:34:51 -03:00
|
|
|
#ifdef AK_OS_MACOS
|
|
|
|
|
void did_allocate_iosurface_backing_stores(i32 front_bitmap_id, Core::MachPort&&, i32 back_bitmap_id, Core::MachPort&&);
|
|
|
|
|
#endif
|
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);
|
|
|
|
|
void did_receive_internal_page_info(Badge<WebContentClient>, PageInfoType, String const&);
|
|
|
|
|
|
2023-12-12 09:25:06 -03:00
|
|
|
ErrorOr<LexicalPath> dump_gc_graph();
|
|
|
|
|
|
2023-08-26 14:34:59 -03:00
|
|
|
void set_user_style_sheet(String source);
|
|
|
|
|
// Load Native.css as the User style sheet, which attempts to make WebView content look as close to
|
|
|
|
|
// native GUI widgets as possible.
|
|
|
|
|
void use_native_user_style_sheet();
|
|
|
|
|
|
2023-11-23 14:22:23 -03:00
|
|
|
void enable_inspector_prototype();
|
|
|
|
|
|
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;
|
|
|
|
|
Function<void(Gfx::IntPoint screen_position)> on_context_menu_request;
|
2024-03-28 23:02:55 -03:00
|
|
|
Function<void(URL::URL const&, Gfx::IntPoint screen_position)> on_link_context_menu_request;
|
2025-01-10 06:33:27 -03:00
|
|
|
Function<void(URL::URL const&, Gfx::IntPoint screen_position, Optional<Gfx::ShareableBitmap> const&)> on_image_context_menu_request;
|
2023-06-16 11:51:38 -03:00
|
|
|
Function<void(Gfx::IntPoint screen_position, Web::Page::MediaContextMenu const&)> on_media_context_menu_request;
|
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;
|
2024-03-28 23:02:55 -03:00
|
|
|
Function<void(URL::URL const&, ByteString const& target, unsigned modifiers)> on_link_click;
|
|
|
|
|
Function<void(URL::URL const&, ByteString const& target, unsigned modifiers)> on_link_middle_click;
|
2023-12-16 11:19:34 -03:00
|
|
|
Function<void(ByteString 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;
|
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;
|
2024-10-18 18:20:15 -03:00
|
|
|
Function<void(URL::URL const&, URL::URL const&, String const&)> on_received_source;
|
2025-02-21 14:39:43 -03:00
|
|
|
Function<void(JsonObject)> on_received_dom_tree;
|
|
|
|
|
Function<void(DOMNodeProperties)> on_received_dom_node_properties;
|
|
|
|
|
Function<void(JsonObject)> on_received_accessibility_tree;
|
2024-08-23 07:18:35 -03:00
|
|
|
Function<void(Vector<Web::CSS::StyleSheetIdentifier>)> on_received_style_sheet_list;
|
|
|
|
|
Function<void(Web::CSS::StyleSheetIdentifier const&)> on_inspector_requested_style_sheet_source;
|
2024-10-18 18:20:15 -03:00
|
|
|
Function<void(Web::CSS::StyleSheetIdentifier const&, URL::URL const&, String const&)> on_received_style_sheet_source;
|
2024-10-20 05:37:44 -03:00
|
|
|
Function<void(Web::UniqueNodeID)> on_received_hovered_node_id;
|
|
|
|
|
Function<void(Optional<Web::UniqueNodeID> const& node_id)> on_finshed_editing_dom_node;
|
2023-12-30 16:32:50 -03:00
|
|
|
Function<void(String const&)> on_received_dom_node_html;
|
2025-02-24 13:57:33 -03:00
|
|
|
Function<void(JsonValue)> on_received_js_console_result;
|
2023-08-23 12:25:24 -03:00
|
|
|
Function<void(i32 message_id)> on_received_console_message;
|
2025-02-23 10:57:40 -03:00
|
|
|
Function<void(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages)> on_received_console_messages;
|
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;
|
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;
|
2024-10-02 13:38:10 -03:00
|
|
|
Function<void(String const&)> on_text_test_finish;
|
2024-12-19 11:16:05 -03:00
|
|
|
Function<void(double milliseconds)> on_set_test_timeout;
|
2024-12-23 18:15:06 -03:00
|
|
|
Function<void(double factor)> on_set_browser_zoom;
|
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;
|
2023-11-10 15:35:41 -03:00
|
|
|
Function<void(String const&, String const&, String const&)> on_insert_clipboard_entry;
|
2024-03-26 20:27:06 -03:00
|
|
|
Function<void(Web::HTML::AudioPlayState)> on_audio_play_state_changed;
|
2024-04-13 18:12:55 -03:00
|
|
|
Function<void(bool, bool)> on_navigation_buttons_state_changed;
|
2023-11-23 14:22:23 -03:00
|
|
|
Function<void()> on_inspector_loaded;
|
2024-10-20 05:37:44 -03:00
|
|
|
Function<void(Web::UniqueNodeID, Optional<Web::CSS::Selector::PseudoElement::Type> const&)> on_inspector_selected_dom_node;
|
|
|
|
|
Function<void(Web::UniqueNodeID, String const&)> on_inspector_set_dom_node_text;
|
|
|
|
|
Function<void(Web::UniqueNodeID, String const&)> on_inspector_set_dom_node_tag;
|
|
|
|
|
Function<void(Web::UniqueNodeID, Vector<Attribute> const&)> on_inspector_added_dom_node_attributes;
|
|
|
|
|
Function<void(Web::UniqueNodeID, size_t, Vector<Attribute> const&)> on_inspector_replaced_dom_node_attribute;
|
|
|
|
|
Function<void(Web::UniqueNodeID, Gfx::IntPoint, String const&, Optional<String> const&, Optional<size_t> const&)> on_inspector_requested_dom_tree_context_menu;
|
2024-09-06 14:22:16 -03:00
|
|
|
Function<void(size_t, Gfx::IntPoint)> on_inspector_requested_cookie_context_menu;
|
2023-11-30 21:27:32 -03:00
|
|
|
Function<void(String const&)> on_inspector_executed_console_script;
|
2024-08-19 13:11:39 -03:00
|
|
|
Function<void(String const&)> on_inspector_exported_inspector_html;
|
2024-11-13 18:35:17 -03:00
|
|
|
Function<void()> on_web_content_crashed;
|
2023-01-12 16:27:17 -03:00
|
|
|
|
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:
|
2023-01-12 16:49:49 -03:00
|
|
|
static constexpr auto ZOOM_MIN_LEVEL = 0.3f;
|
|
|
|
|
static constexpr auto ZOOM_MAX_LEVEL = 5.0f;
|
|
|
|
|
static constexpr auto ZOOM_STEP = 0.1f;
|
|
|
|
|
|
2023-08-07 11:44:20 -03:00
|
|
|
ViewImplementation();
|
2023-05-15 02:59:51 -03:00
|
|
|
|
2023-01-12 16:27:17 -03:00
|
|
|
WebContentClient& client();
|
|
|
|
|
WebContentClient const& client() const;
|
2024-02-02 22:00:48 -03:00
|
|
|
u64 page_id() const;
|
2023-01-12 16:49:49 -03:00
|
|
|
virtual void update_zoom() = 0;
|
2023-01-12 16:27:17 -03:00
|
|
|
|
2023-05-15 02:59:51 -03:00
|
|
|
void handle_resize();
|
|
|
|
|
|
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
|
|
|
|
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;
|
2023-01-12 16:27:17 -03:00
|
|
|
RefPtr<Gfx::Bitmap> bitmap;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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-02-17 08:43:06 -03:00
|
|
|
ByteString m_title;
|
2023-01-12 17:30:06 -03:00
|
|
|
|
2023-01-12 16:49:49 -03:00
|
|
|
float m_zoom_level { 1.0 };
|
|
|
|
|
float m_device_pixel_ratio { 1.0 };
|
2023-05-15 02:59:51 -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;
|
|
|
|
|
|
|
|
|
|
RefPtr<Gfx::Bitmap> m_backup_bitmap;
|
2023-12-14 03:17:00 -03:00
|
|
|
Web::DevicePixelSize m_backup_bitmap_size;
|
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
|
|
|
|
|
|
|
|
// 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 };
|
2022-10-05 09:32:17 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|