2020-06-17 17:31:42 +02:00
|
|
|
/*
|
2022-04-06 15:15:07 +02:00
|
|
|
* Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
|
2022-11-21 16:07:47 +00:00
|
|
|
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
2020-06-17 17:31:42 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-17 17:31:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-11-21 16:07:47 +00:00
|
|
|
#include <AK/Queue.h>
|
2020-07-06 21:18:16 +02:00
|
|
|
#include <AK/URL.h>
|
2021-05-03 20:31:58 +02:00
|
|
|
#include <LibGUI/AbstractScrollableWidget.h>
|
2020-06-17 17:31:42 +02:00
|
|
|
#include <LibGUI/Widget.h>
|
2022-03-04 16:29:05 +00:00
|
|
|
#include <LibWeb/CSS/Selector.h>
|
2023-03-20 18:39:20 -04:00
|
|
|
#include <LibWeb/HTML/ActivateTab.h>
|
2021-10-26 17:00:10 +01:00
|
|
|
#include <LibWeb/Page/Page.h>
|
2022-10-05 14:32:17 +02:00
|
|
|
#include <LibWebView/ViewImplementation.h>
|
2020-06-17 17:31:42 +02:00
|
|
|
|
2022-11-02 18:08:48 +00:00
|
|
|
namespace Messages::WebContentServer {
|
|
|
|
|
class WebdriverExecuteScriptResponse;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 10:46:33 +02:00
|
|
|
namespace WebView {
|
2020-08-24 15:33:18 +04:30
|
|
|
|
2020-06-17 17:31:42 +02:00
|
|
|
class WebContentClient;
|
|
|
|
|
|
2022-10-05 14:32:17 +02:00
|
|
|
class OutOfProcessWebView final
|
|
|
|
|
: public GUI::AbstractScrollableWidget
|
|
|
|
|
, public ViewImplementation {
|
2020-08-17 16:20:47 +02:00
|
|
|
C_OBJECT(OutOfProcessWebView);
|
2020-06-17 17:31:42 +02:00
|
|
|
|
2022-11-21 15:54:18 +00:00
|
|
|
using Super = GUI::AbstractScrollableWidget;
|
|
|
|
|
|
2020-06-17 17:31:42 +02:00
|
|
|
public:
|
2020-08-17 16:20:47 +02:00
|
|
|
virtual ~OutOfProcessWebView() override;
|
2020-06-17 17:31:42 +02:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString dump_layout_tree();
|
2021-09-08 00:55:35 +02:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
OrderedHashMap<DeprecatedString, DeprecatedString> get_local_storage_entries();
|
|
|
|
|
OrderedHashMap<DeprecatedString, DeprecatedString> get_session_storage_entries();
|
2022-04-02 00:14:04 +03:00
|
|
|
|
2023-04-21 07:54:56 -04:00
|
|
|
void set_content_filters(Vector<String>);
|
2023-04-17 13:21:19 -04:00
|
|
|
void set_autoplay_allowed_on_all_websites();
|
|
|
|
|
void set_autoplay_allowlist(Vector<String>);
|
2022-12-04 18:02:33 +00:00
|
|
|
void set_proxy_mappings(Vector<DeprecatedString> proxies, HashMap<DeprecatedString, size_t> mappings);
|
|
|
|
|
void connect_to_webdriver(DeprecatedString const& webdriver_ipc_path);
|
2021-09-27 11:39:17 +02:00
|
|
|
|
2022-12-06 20:27:44 +00:00
|
|
|
void set_window_position(Gfx::IntPoint);
|
2022-12-06 21:35:32 +00:00
|
|
|
void set_window_size(Gfx::IntSize);
|
2022-11-01 14:55:53 -04:00
|
|
|
|
2022-11-09 09:51:39 -05:00
|
|
|
void set_system_visibility_state(bool visible);
|
|
|
|
|
|
2023-01-09 18:55:22 +01:00
|
|
|
// This is a hint that tells OOPWV that the content will scale to the viewport size.
|
|
|
|
|
// In practice, this means that OOPWV may render scaled stale versions of the content while resizing.
|
|
|
|
|
void set_content_scales_to_viewport(bool);
|
|
|
|
|
|
2020-06-17 17:31:42 +02:00
|
|
|
private:
|
2020-08-17 16:20:47 +02:00
|
|
|
OutOfProcessWebView();
|
2020-06-17 17:31:42 +02:00
|
|
|
|
2020-07-04 23:19:32 +02:00
|
|
|
// ^Widget
|
2020-06-17 17:31:42 +02:00
|
|
|
virtual void paint_event(GUI::PaintEvent&) override;
|
|
|
|
|
virtual void resize_event(GUI::ResizeEvent&) override;
|
2020-06-17 18:05:08 +02:00
|
|
|
virtual void mousedown_event(GUI::MouseEvent&) override;
|
|
|
|
|
virtual void mouseup_event(GUI::MouseEvent&) override;
|
|
|
|
|
virtual void mousemove_event(GUI::MouseEvent&) override;
|
2021-02-22 19:45:41 +01:00
|
|
|
virtual void mousewheel_event(GUI::MouseEvent&) override;
|
2022-06-14 19:38:32 +02:00
|
|
|
virtual void doubleclick_event(GUI::MouseEvent&) override;
|
2020-08-03 19:58:59 +02:00
|
|
|
virtual void keydown_event(GUI::KeyEvent&) override;
|
2021-09-28 15:39:35 +02:00
|
|
|
virtual void keyup_event(GUI::KeyEvent&) override;
|
2020-10-08 22:13:54 +01:00
|
|
|
virtual void theme_change_event(GUI::ThemeChangeEvent&) override;
|
2021-06-13 06:16:06 -06:00
|
|
|
virtual void screen_rects_change_event(GUI::ScreenRectsChangeEvent&) override;
|
2022-02-06 19:03:13 +01:00
|
|
|
virtual void focusin_event(GUI::FocusEvent&) override;
|
|
|
|
|
virtual void focusout_event(GUI::FocusEvent&) override;
|
2022-09-19 20:50:33 +02:00
|
|
|
virtual void show_event(GUI::ShowEvent&) override;
|
|
|
|
|
virtual void hide_event(GUI::HideEvent&) override;
|
2020-06-17 17:31:42 +02:00
|
|
|
|
2021-05-03 20:31:58 +02:00
|
|
|
// ^AbstractScrollableWidget
|
2020-07-04 23:19:32 +02:00
|
|
|
virtual void did_scroll() override;
|
|
|
|
|
|
2022-10-05 14:32:17 +02:00
|
|
|
// ^WebView::ViewImplementation
|
2023-06-17 13:16:35 +02:00
|
|
|
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No, UseJavaScriptBytecode = UseJavaScriptBytecode::No) override;
|
2023-01-12 19:49:49 +00:00
|
|
|
virtual void update_zoom() override;
|
2022-12-06 21:35:32 +00:00
|
|
|
virtual void notify_server_did_layout(Badge<WebContentClient>, Gfx::IntSize content_size) override;
|
2023-05-14 18:53:29 +02:00
|
|
|
virtual void notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id, Gfx::IntSize) override;
|
2022-10-05 14:32:17 +02:00
|
|
|
virtual void notify_server_did_invalidate_content_rect(Badge<WebContentClient>, Gfx::IntRect const&) override;
|
|
|
|
|
virtual void notify_server_did_change_selection(Badge<WebContentClient>) override;
|
|
|
|
|
virtual void notify_server_did_request_cursor_change(Badge<WebContentClient>, Gfx::StandardCursor cursor) override;
|
|
|
|
|
virtual void notify_server_did_request_scroll(Badge<WebContentClient>, i32, i32) override;
|
2022-12-06 20:27:44 +00:00
|
|
|
virtual void notify_server_did_request_scroll_to(Badge<WebContentClient>, Gfx::IntPoint) override;
|
2022-10-05 14:32:17 +02:00
|
|
|
virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) override;
|
2022-12-06 20:27:44 +00:00
|
|
|
virtual void notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint, DeprecatedString const&) override;
|
2022-10-05 14:32:17 +02:00
|
|
|
virtual void notify_server_did_leave_tooltip_area(Badge<WebContentClient>) override;
|
2023-03-13 17:30:51 -04:00
|
|
|
virtual void notify_server_did_request_alert(Badge<WebContentClient>, String const& message) override;
|
|
|
|
|
virtual void notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) override;
|
|
|
|
|
virtual void notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) override;
|
|
|
|
|
virtual void notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message) override;
|
2022-11-16 06:58:14 -05:00
|
|
|
virtual void notify_server_did_request_accept_dialog(Badge<WebContentClient>) override;
|
|
|
|
|
virtual void notify_server_did_request_dismiss_dialog(Badge<WebContentClient>) override;
|
2022-12-04 18:02:33 +00:00
|
|
|
virtual void notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32) override;
|
2022-11-21 16:07:47 +00:00
|
|
|
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
|
2022-10-05 14:32:17 +02:00
|
|
|
|
2023-05-15 07:59:51 +02:00
|
|
|
virtual Gfx::IntRect viewport_rect() const override;
|
2023-05-17 10:12:13 -04:00
|
|
|
virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override;
|
|
|
|
|
virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override;
|
2020-07-04 20:57:57 +02:00
|
|
|
|
2022-11-21 16:07:47 +00:00
|
|
|
using InputEvent = Variant<GUI::KeyEvent, GUI::MouseEvent>;
|
|
|
|
|
void enqueue_input_event(InputEvent const&);
|
|
|
|
|
void process_next_input_event();
|
|
|
|
|
|
2022-11-16 06:58:14 -05:00
|
|
|
RefPtr<GUI::Dialog> m_dialog;
|
2022-11-21 16:07:47 +00:00
|
|
|
|
|
|
|
|
bool m_is_awaiting_response_for_input_event { false };
|
|
|
|
|
Queue<InputEvent> m_pending_input_events;
|
2023-01-09 18:55:22 +01:00
|
|
|
|
|
|
|
|
bool m_content_scales_to_viewport { false };
|
2020-06-17 17:31:42 +02:00
|
|
|
};
|
2020-08-24 15:33:18 +04:30
|
|
|
|
|
|
|
|
}
|