summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorDexesTTP <dexes.ttp@gmail.com>2022-04-30 10:46:33 +0200
committerAndreas Kling <kling@serenityos.org>2022-05-15 12:17:36 +0200
commitdcbbbf5b4a5dcb67184dc9f97c0f434aa301098c (patch)
tree3c4b47a4ea514104796f317f9bca349bab99b509 /Userland/Libraries/LibWeb
parent31c00224295bfbe71e6533b447751d745c0f06cc (diff)
downloadserenity-dcbbbf5b4a5dcb67184dc9f97c0f434aa301098c.zip
LibWebView: Move OutOfProcessWebView to a new LibWebView library
Also moves WebContentClient and the references to the generated IPC descriptions, since they are all components of OutOfProcessWebView. This patch has no functional changes.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/CMakeLists.txt4
-rw-r--r--Userland/Libraries/LibWeb/DumpLayoutTree/CMakeLists.txt2
-rw-r--r--Userland/Libraries/LibWeb/DumpLayoutTree/main.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Forward.h1
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.cpp523
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.h163
-rw-r--r--Userland/Libraries/LibWeb/WebContentClient.cpp203
-rw-r--r--Userland/Libraries/LibWeb/WebContentClient.h68
8 files changed, 3 insertions, 965 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt
index 624f6fbcd5..e74c563763 100644
--- a/Userland/Libraries/LibWeb/CMakeLists.txt
+++ b/Userland/Libraries/LibWeb/CMakeLists.txt
@@ -285,7 +285,6 @@ set(SOURCES
MimeSniff/MimeType.cpp
Namespace.cpp
NavigationTiming/PerformanceTiming.cpp
- OutOfProcessWebView.cpp
Page/EditEventHandler.cpp
Page/EventHandler.cpp
Page/Page.cpp
@@ -355,7 +354,6 @@ set(SOURCES
WebAssembly/WebAssemblyTableConstructor.cpp
WebAssembly/WebAssemblyTableObject.cpp
WebAssembly/WebAssemblyTablePrototype.cpp
- WebContentClient.cpp
WebSockets/WebSocket.cpp
XHR/EventNames.cpp
XHR/XMLHttpRequest.cpp
@@ -366,8 +364,6 @@ set(SOURCES
set(GENERATED_SOURCES
../../Services/RequestServer/RequestClientEndpoint.h
../../Services/RequestServer/RequestServerEndpoint.h
- ../../Services/WebContent/WebContentClientEndpoint.h
- ../../Services/WebContent/WebContentServerEndpoint.h
)
generate_css_implementation()
diff --git a/Userland/Libraries/LibWeb/DumpLayoutTree/CMakeLists.txt b/Userland/Libraries/LibWeb/DumpLayoutTree/CMakeLists.txt
index 11a7ce62f5..5891a69932 100644
--- a/Userland/Libraries/LibWeb/DumpLayoutTree/CMakeLists.txt
+++ b/Userland/Libraries/LibWeb/DumpLayoutTree/CMakeLists.txt
@@ -3,4 +3,4 @@ set(SOURCES
)
serenity_bin(DumpLayoutTree)
-target_link_libraries(DumpLayoutTree LibWeb)
+target_link_libraries(DumpLayoutTree LibWebView LibWeb)
diff --git a/Userland/Libraries/LibWeb/DumpLayoutTree/main.cpp b/Userland/Libraries/LibWeb/DumpLayoutTree/main.cpp
index f4fcb5ad4c..577c8b144b 100644
--- a/Userland/Libraries/LibWeb/DumpLayoutTree/main.cpp
+++ b/Userland/Libraries/LibWeb/DumpLayoutTree/main.cpp
@@ -6,7 +6,7 @@
#include <LibGUI/Application.h>
#include <LibGUI/Window.h>
-#include <LibWeb/OutOfProcessWebView.h>
+#include <LibWebView/OutOfProcessWebView.h>
#include <unistd.h>
int main(int argc, char** argv)
@@ -16,7 +16,7 @@ int main(int argc, char** argv)
window->set_title("DumpLayoutTree");
window->resize(800, 600);
window->show();
- auto& web_view = window->set_main_widget<Web::OutOfProcessWebView>();
+ auto& web_view = window->set_main_widget<WebView::OutOfProcessWebView>();
web_view.load(URL::create_with_file_protocol(argv[1]));
web_view.on_load_finish = [&](auto&) {
auto dump = web_view.dump_layout_tree();
diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h
index de34410f9a..71a6c8922a 100644
--- a/Userland/Libraries/LibWeb/Forward.h
+++ b/Userland/Libraries/LibWeb/Forward.h
@@ -370,7 +370,6 @@ class EventHandler;
class FrameLoader;
class LoadRequest;
class Origin;
-class OutOfProcessWebView;
class Page;
class PageClient;
class PaintContext;
diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
deleted file mode 100644
index 08f89d3151..0000000000
--- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
+++ /dev/null
@@ -1,523 +0,0 @@
-/*
- * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include "OutOfProcessWebView.h"
-#include "WebContentClient.h"
-#include <AK/String.h>
-#include <LibGUI/Application.h>
-#include <LibGUI/Desktop.h>
-#include <LibGUI/InputBox.h>
-#include <LibGUI/MessageBox.h>
-#include <LibGUI/Painter.h>
-#include <LibGUI/Scrollbar.h>
-#include <LibGUI/Window.h>
-#include <LibGfx/Font/FontDatabase.h>
-#include <LibGfx/Palette.h>
-#include <LibGfx/SystemTheme.h>
-
-REGISTER_WIDGET(Web, OutOfProcessWebView)
-
-namespace Web {
-
-OutOfProcessWebView::OutOfProcessWebView()
-{
- set_should_hide_unnecessary_scrollbars(true);
- set_focus_policy(GUI::FocusPolicy::StrongFocus);
-
- create_client();
-}
-
-OutOfProcessWebView::~OutOfProcessWebView() = default;
-
-void OutOfProcessWebView::handle_web_content_process_crash()
-{
- create_client();
- VERIFY(m_client_state.client);
-
- // Don't keep a stale backup bitmap around.
- m_backup_bitmap = nullptr;
-
- handle_resize();
- StringBuilder builder;
- builder.append("<html><head><title>Crashed: ");
- builder.append(escape_html_entities(m_url.to_string()));
- builder.append("</title></head><body>");
- builder.append("<h1>Web page crashed");
- if (!m_url.host().is_empty()) {
- builder.appendff(" on {}", escape_html_entities(m_url.host()));
- }
- builder.append("</h1>");
- auto escaped_url = escape_html_entities(m_url.to_string());
- builder.appendff("The web page <a href=\"{}\">{}</a> has crashed.<br><br>You can reload the page to try again.", escaped_url, escaped_url);
- builder.append("</body></html>");
- load_html(builder.to_string(), m_url);
-}
-
-void OutOfProcessWebView::create_client()
-{
- m_client_state = {};
-
- m_client_state.client = WebContentClient::try_create(*this).release_value_but_fixme_should_propagate_errors();
- m_client_state.client->on_web_content_process_crash = [this] {
- deferred_invoke([this] {
- handle_web_content_process_crash();
- });
- };
-
- client().async_update_system_theme(Gfx::current_system_theme_buffer());
- client().async_update_system_fonts(Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query());
- client().async_update_screen_rects(GUI::Desktop::the().rects(), GUI::Desktop::the().main_screen_index());
-}
-
-void OutOfProcessWebView::load(const AK::URL& url)
-{
- m_url = url;
- client().async_load_url(url);
-}
-
-void OutOfProcessWebView::load_html(StringView html, const AK::URL& url)
-{
- m_url = url;
- client().async_load_html(html, url);
-}
-
-void OutOfProcessWebView::load_empty_document()
-{
- m_url = {};
- client().async_load_html("", {});
-}
-
-void OutOfProcessWebView::paint_event(GUI::PaintEvent& event)
-{
- GUI::AbstractScrollableWidget::paint_event(event);
-
- // If the available size is empty, we don't have a front or back bitmap to draw.
- if (available_size().is_empty())
- return;
-
- GUI::Painter painter(*this);
- painter.add_clip_rect(event.rect());
-
- if (auto* bitmap = m_client_state.has_usable_bitmap ? m_client_state.front_bitmap.bitmap.ptr() : m_backup_bitmap.ptr()) {
- painter.add_clip_rect(frame_inner_rect());
- painter.translate(frame_thickness(), frame_thickness());
- painter.blit({ 0, 0 }, *bitmap, bitmap->rect());
- return;
- }
-
- painter.fill_rect(frame_inner_rect(), palette().base());
-}
-
-void OutOfProcessWebView::resize_event(GUI::ResizeEvent& event)
-{
- GUI::AbstractScrollableWidget::resize_event(event);
- handle_resize();
-}
-
-void OutOfProcessWebView::handle_resize()
-{
- client().async_set_viewport_rect(Gfx::IntRect({ horizontal_scrollbar().value(), vertical_scrollbar().value() }, available_size()));
-
- if (m_client_state.has_usable_bitmap) {
- // NOTE: We keep the outgoing front bitmap as a backup so we have something to paint until we get a new one.
- m_backup_bitmap = m_client_state.front_bitmap.bitmap;
- }
-
- if (m_client_state.front_bitmap.bitmap)
- client().async_remove_backing_store(m_client_state.front_bitmap.id);
-
- if (m_client_state.back_bitmap.bitmap)
- client().async_remove_backing_store(m_client_state.back_bitmap.id);
-
- m_client_state.front_bitmap = {};
- m_client_state.back_bitmap = {};
- m_client_state.has_usable_bitmap = false;
-
- if (available_size().is_empty())
- return;
-
- if (auto new_bitmap_or_error = Gfx::Bitmap::try_create_shareable(Gfx::BitmapFormat::BGRx8888, available_size()); !new_bitmap_or_error.is_error()) {
- m_client_state.front_bitmap.bitmap = new_bitmap_or_error.release_value();
- m_client_state.front_bitmap.id = m_client_state.next_bitmap_id++;
- client().async_add_backing_store(m_client_state.front_bitmap.id, m_client_state.front_bitmap.bitmap->to_shareable_bitmap());
- }
-
- if (auto new_bitmap_or_error = Gfx::Bitmap::try_create_shareable(Gfx::BitmapFormat::BGRx8888, available_size()); !new_bitmap_or_error.is_error()) {
- m_client_state.back_bitmap.bitmap = new_bitmap_or_error.release_value();
- m_client_state.back_bitmap.id = m_client_state.next_bitmap_id++;
- client().async_add_backing_store(m_client_state.back_bitmap.id, m_client_state.back_bitmap.bitmap->to_shareable_bitmap());
- }
-
- request_repaint();
-}
-
-void OutOfProcessWebView::keydown_event(GUI::KeyEvent& event)
-{
- client().async_key_down(event.key(), event.modifiers(), event.code_point());
-}
-
-void OutOfProcessWebView::keyup_event(GUI::KeyEvent& event)
-{
- client().async_key_up(event.key(), event.modifiers(), event.code_point());
-}
-
-void OutOfProcessWebView::mousedown_event(GUI::MouseEvent& event)
-{
- client().async_mouse_down(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers());
-}
-
-void OutOfProcessWebView::mouseup_event(GUI::MouseEvent& event)
-{
- client().async_mouse_up(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers());
-}
-
-void OutOfProcessWebView::mousemove_event(GUI::MouseEvent& event)
-{
- client().async_mouse_move(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers());
-}
-
-void OutOfProcessWebView::mousewheel_event(GUI::MouseEvent& event)
-{
- client().async_mouse_wheel(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers(), event.wheel_delta_x(), event.wheel_delta_y());
-}
-
-void OutOfProcessWebView::theme_change_event(GUI::ThemeChangeEvent& event)
-{
- GUI::AbstractScrollableWidget::theme_change_event(event);
- client().async_update_system_theme(Gfx::current_system_theme_buffer());
- request_repaint();
-}
-
-void OutOfProcessWebView::screen_rects_change_event(GUI::ScreenRectsChangeEvent& event)
-{
- client().async_update_screen_rects(event.rects(), event.main_screen_index());
-}
-
-void OutOfProcessWebView::notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id)
-{
- if (m_client_state.back_bitmap.id == bitmap_id) {
- m_client_state.has_usable_bitmap = true;
- m_client_state.back_bitmap.pending_paints--;
- swap(m_client_state.back_bitmap, m_client_state.front_bitmap);
- // We don't need the backup bitmap anymore, so drop it.
- m_backup_bitmap = nullptr;
- update();
-
- if (m_client_state.got_repaint_requests_while_painting) {
- m_client_state.got_repaint_requests_while_painting = false;
- request_repaint();
- }
- }
-}
-
-void OutOfProcessWebView::notify_server_did_invalidate_content_rect(Badge<WebContentClient>, [[maybe_unused]] Gfx::IntRect const& content_rect)
-{
- request_repaint();
-}
-
-void OutOfProcessWebView::notify_server_did_change_selection(Badge<WebContentClient>)
-{
- request_repaint();
-}
-
-void OutOfProcessWebView::notify_server_did_request_cursor_change(Badge<WebContentClient>, Gfx::StandardCursor cursor)
-{
- set_override_cursor(cursor);
-}
-
-void OutOfProcessWebView::notify_server_did_layout(Badge<WebContentClient>, Gfx::IntSize const& content_size)
-{
- set_content_size(content_size);
-}
-
-void OutOfProcessWebView::notify_server_did_change_title(Badge<WebContentClient>, String const& title)
-{
- if (on_title_change)
- on_title_change(title);
-}
-
-void OutOfProcessWebView::notify_server_did_request_scroll(Badge<WebContentClient>, i32 x_delta, i32 y_delta)
-{
- horizontal_scrollbar().increase_slider_by(x_delta);
- vertical_scrollbar().increase_slider_by(y_delta);
-}
-
-void OutOfProcessWebView::notify_server_did_request_scroll_to(Badge<WebContentClient>, Gfx::IntPoint const& scroll_position)
-{
- horizontal_scrollbar().set_value(scroll_position.x());
- vertical_scrollbar().set_value(scroll_position.y());
-}
-
-void OutOfProcessWebView::notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const& rect)
-{
- scroll_into_view(rect, true, true);
-}
-
-void OutOfProcessWebView::notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint const&, String const& title)
-{
- GUI::Application::the()->show_tooltip(title, nullptr);
-}
-
-void OutOfProcessWebView::notify_server_did_leave_tooltip_area(Badge<WebContentClient>)
-{
- GUI::Application::the()->hide_tooltip();
-}
-
-void OutOfProcessWebView::notify_server_did_hover_link(Badge<WebContentClient>, const AK::URL& url)
-{
- if (on_link_hover)
- on_link_hover(url);
-}
-
-void OutOfProcessWebView::notify_server_did_unhover_link(Badge<WebContentClient>)
-{
- set_override_cursor(Gfx::StandardCursor::None);
- if (on_link_hover)
- on_link_hover({});
-}
-
-void OutOfProcessWebView::notify_server_did_click_link(Badge<WebContentClient>, const AK::URL& url, String const& target, unsigned int modifiers)
-{
- if (on_link_click)
- on_link_click(url, target, modifiers);
-}
-
-void OutOfProcessWebView::notify_server_did_middle_click_link(Badge<WebContentClient>, const AK::URL& url, String const& target, unsigned int modifiers)
-{
- if (on_link_middle_click)
- on_link_middle_click(url, target, modifiers);
-}
-
-void OutOfProcessWebView::notify_server_did_start_loading(Badge<WebContentClient>, const AK::URL& url)
-{
- if (on_load_start)
- on_load_start(url);
-}
-
-void OutOfProcessWebView::notify_server_did_finish_loading(Badge<WebContentClient>, const AK::URL& url)
-{
- if (on_load_finish)
- on_load_finish(url);
-}
-
-void OutOfProcessWebView::notify_server_did_request_context_menu(Badge<WebContentClient>, Gfx::IntPoint const& content_position)
-{
- if (on_context_menu_request)
- on_context_menu_request(screen_relative_rect().location().translated(to_widget_position(content_position)));
-}
-
-void OutOfProcessWebView::notify_server_did_request_link_context_menu(Badge<WebContentClient>, Gfx::IntPoint const& content_position, const AK::URL& url, String const&, unsigned)
-{
- if (on_link_context_menu_request)
- on_link_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position)));
-}
-
-void OutOfProcessWebView::notify_server_did_request_image_context_menu(Badge<WebContentClient>, Gfx::IntPoint const& content_position, const AK::URL& url, String const&, unsigned, Gfx::ShareableBitmap const& bitmap)
-{
- if (on_image_context_menu_request)
- on_image_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position)), bitmap);
-}
-
-void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient>, String const& message)
-{
- GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information);
-}
-
-bool OutOfProcessWebView::notify_server_did_request_confirm(Badge<WebContentClient>, String const& message)
-{
- auto confirm_result = GUI::MessageBox::show(window(), message, "Confirm", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel);
- return confirm_result == GUI::Dialog::ExecResult::OK;
-}
-
-String OutOfProcessWebView::notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_)
-{
- String response { default_ };
- if (GUI::InputBox::show(window(), response, message, "Prompt") == GUI::InputBox::ExecResult::OK)
- return response;
- return {};
-}
-
-void OutOfProcessWebView::notify_server_did_get_source(const AK::URL& url, String const& source)
-{
- if (on_get_source)
- on_get_source(url, source);
-}
-
-void OutOfProcessWebView::notify_server_did_get_dom_tree(String const& dom_tree)
-{
- if (on_get_dom_tree)
- on_get_dom_tree(dom_tree);
-}
-
-void OutOfProcessWebView::notify_server_did_get_dom_node_properties(i32 node_id, String const& specified_style, String const& computed_style, String const& custom_properties, String const& node_box_sizing)
-{
- if (on_get_dom_node_properties)
- on_get_dom_node_properties(node_id, specified_style, computed_style, custom_properties, node_box_sizing);
-}
-
-void OutOfProcessWebView::notify_server_did_output_js_console_message(i32 message_index)
-{
- if (on_js_console_new_message)
- on_js_console_new_message(message_index);
-}
-
-void OutOfProcessWebView::notify_server_did_get_js_console_messages(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages)
-{
- if (on_get_js_console_messages)
- on_get_js_console_messages(start_index, message_types, messages);
-}
-
-void OutOfProcessWebView::notify_server_did_change_favicon(Gfx::Bitmap const& favicon)
-{
- if (on_favicon_change)
- on_favicon_change(favicon);
-}
-
-String OutOfProcessWebView::notify_server_did_request_cookie(Badge<WebContentClient>, const AK::URL& url, Cookie::Source source)
-{
- if (on_get_cookie)
- return on_get_cookie(url, source);
- return {};
-}
-
-void OutOfProcessWebView::notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, Cookie::ParsedCookie const& cookie, Cookie::Source source)
-{
- if (on_set_cookie)
- on_set_cookie(url, cookie, source);
-}
-
-void OutOfProcessWebView::notify_server_did_update_resource_count(i32 count_waiting)
-{
- if (on_resource_status_change)
- on_resource_status_change(count_waiting);
-}
-
-void OutOfProcessWebView::did_scroll()
-{
- client().async_set_viewport_rect(visible_content_rect());
- request_repaint();
-}
-
-void OutOfProcessWebView::request_repaint()
-{
- // If this widget was instantiated but not yet added to a window,
- // it won't have a back bitmap yet, so we can just skip repaint requests.
- if (!m_client_state.back_bitmap.bitmap)
- return;
- // Don't request a repaint until pending paint requests have finished.
- if (m_client_state.back_bitmap.pending_paints) {
- m_client_state.got_repaint_requests_while_painting = true;
- return;
- }
- m_client_state.back_bitmap.pending_paints++;
- client().async_paint(m_client_state.back_bitmap.bitmap->rect().translated(horizontal_scrollbar().value(), vertical_scrollbar().value()), m_client_state.back_bitmap.id);
-}
-
-WebContentClient& OutOfProcessWebView::client()
-{
- VERIFY(m_client_state.client);
- return *m_client_state.client;
-}
-
-void OutOfProcessWebView::debug_request(String const& request, String const& argument)
-{
- client().async_debug_request(request, argument);
-}
-
-void OutOfProcessWebView::get_source()
-{
- client().async_get_source();
-}
-
-void OutOfProcessWebView::inspect_dom_tree()
-{
- client().async_inspect_dom_tree();
-}
-
-Optional<OutOfProcessWebView::DOMNodeProperties> OutOfProcessWebView::inspect_dom_node(i32 node_id, Optional<CSS::Selector::PseudoElement> pseudo_element)
-{
- auto response = client().inspect_dom_node(node_id, pseudo_element);
- if (!response.has_style())
- return {};
- return DOMNodeProperties {
- .specified_values_json = response.specified_style(),
- .computed_values_json = response.computed_style(),
- .custom_properties_json = response.custom_properties(),
- .node_box_sizing_json = response.node_box_sizing()
- };
-}
-
-void OutOfProcessWebView::clear_inspected_dom_node()
-{
- client().inspect_dom_node(0, {});
-}
-
-i32 OutOfProcessWebView::get_hovered_node_id()
-{
- return client().get_hovered_node_id();
-}
-
-void OutOfProcessWebView::js_console_input(String const& js_source)
-{
- client().async_js_console_input(js_source);
-}
-
-void OutOfProcessWebView::js_console_request_messages(i32 start_index)
-{
- client().async_js_console_request_messages(start_index);
-}
-
-void OutOfProcessWebView::run_javascript(StringView js_source)
-{
- client().async_run_javascript(js_source);
-}
-
-String OutOfProcessWebView::selected_text()
-{
- return client().get_selected_text();
-}
-
-void OutOfProcessWebView::select_all()
-{
- client().async_select_all();
-}
-
-String OutOfProcessWebView::dump_layout_tree()
-{
- return client().dump_layout_tree();
-}
-
-OrderedHashMap<String, String> OutOfProcessWebView::get_local_storage_entries()
-{
- return client().get_local_storage_entries();
-}
-
-void OutOfProcessWebView::set_content_filters(Vector<String> filters)
-{
- client().async_set_content_filters(filters);
-}
-
-void OutOfProcessWebView::set_proxy_mappings(Vector<String> proxies, HashMap<String, size_t> mappings)
-{
- client().async_set_proxy_mappings(move(proxies), move(mappings));
-}
-
-void OutOfProcessWebView::set_preferred_color_scheme(Web::CSS::PreferredColorScheme color_scheme)
-{
- client().async_set_preferred_color_scheme(color_scheme);
-}
-
-void OutOfProcessWebView::focusin_event(GUI::FocusEvent&)
-{
- client().async_set_has_focus(true);
-}
-
-void OutOfProcessWebView::focusout_event(GUI::FocusEvent&)
-{
- client().async_set_has_focus(false);
-}
-
-}
diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.h b/Userland/Libraries/LibWeb/OutOfProcessWebView.h
deleted file mode 100644
index 55f513c47c..0000000000
--- a/Userland/Libraries/LibWeb/OutOfProcessWebView.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/URL.h>
-#include <LibGUI/AbstractScrollableWidget.h>
-#include <LibGUI/Widget.h>
-#include <LibWeb/CSS/Selector.h>
-#include <LibWeb/Page/Page.h>
-
-namespace Web {
-
-class WebContentClient;
-
-class OutOfProcessWebView final : public GUI::AbstractScrollableWidget {
- C_OBJECT(OutOfProcessWebView);
-
-public:
- virtual ~OutOfProcessWebView() override;
-
- AK::URL url() const { return m_url; }
- void load(const AK::URL&);
-
- void load_html(StringView, const AK::URL&);
- void load_empty_document();
-
- void debug_request(String const& request, String const& argument = {});
- void get_source();
-
- void inspect_dom_tree();
- struct DOMNodeProperties {
- String specified_values_json;
- String computed_values_json;
- String custom_properties_json;
- String node_box_sizing_json;
- };
- Optional<DOMNodeProperties> inspect_dom_node(i32 node_id, Optional<CSS::Selector::PseudoElement>);
- void clear_inspected_dom_node();
- i32 get_hovered_node_id();
-
- void js_console_input(String const& js_source);
- void js_console_request_messages(i32 start_index);
-
- void run_javascript(StringView);
-
- String selected_text();
- void select_all();
-
- String dump_layout_tree();
-
- OrderedHashMap<String, String> get_local_storage_entries();
-
- void set_content_filters(Vector<String>);
- void set_proxy_mappings(Vector<String> proxies, HashMap<String, size_t> mappings);
- void set_preferred_color_scheme(Web::CSS::PreferredColorScheme);
-
- Function<void(Gfx::IntPoint const& screen_position)> on_context_menu_request;
- Function<void(const AK::URL&, String const& target, unsigned modifiers)> on_link_click;
- Function<void(const AK::URL&, Gfx::IntPoint const& screen_position)> on_link_context_menu_request;
- Function<void(const AK::URL&, Gfx::IntPoint const& screen_position, Gfx::ShareableBitmap const&)> on_image_context_menu_request;
- Function<void(const AK::URL&, String const& target, unsigned modifiers)> on_link_middle_click;
- Function<void(const AK::URL&)> on_link_hover;
- Function<void(String const&)> on_title_change;
- Function<void(const AK::URL&)> on_load_start;
- Function<void(const AK::URL&)> on_load_finish;
- Function<void(Gfx::Bitmap const&)> on_favicon_change;
- Function<void(const AK::URL&)> on_url_drop;
- Function<void(DOM::Document*)> on_set_document;
- Function<void(const AK::URL&, String const&)> on_get_source;
- Function<void(String const&)> on_get_dom_tree;
- Function<void(i32 node_id, String const& specified_style, String const& computed_style, String const& custom_properties, String const& node_box_sizing)> on_get_dom_node_properties;
- Function<void(i32 message_id)> on_js_console_new_message;
- Function<void(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages)> on_get_js_console_messages;
- Function<String(const AK::URL& url, Cookie::Source source)> on_get_cookie;
- Function<void(const AK::URL& url, Cookie::ParsedCookie const& cookie, Cookie::Source source)> on_set_cookie;
- Function<void(i32 count_waiting)> on_resource_status_change;
-
- void notify_server_did_layout(Badge<WebContentClient>, Gfx::IntSize const& content_size);
- void notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id);
- void notify_server_did_invalidate_content_rect(Badge<WebContentClient>, Gfx::IntRect const&);
- void notify_server_did_change_selection(Badge<WebContentClient>);
- void notify_server_did_request_cursor_change(Badge<WebContentClient>, Gfx::StandardCursor cursor);
- void notify_server_did_change_title(Badge<WebContentClient>, String const&);
- void notify_server_did_request_scroll(Badge<WebContentClient>, i32, i32);
- void notify_server_did_request_scroll_to(Badge<WebContentClient>, Gfx::IntPoint const&);
- void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&);
- void notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint const&, String const&);
- void notify_server_did_leave_tooltip_area(Badge<WebContentClient>);
- void notify_server_did_hover_link(Badge<WebContentClient>, const AK::URL&);
- void notify_server_did_unhover_link(Badge<WebContentClient>);
- void notify_server_did_click_link(Badge<WebContentClient>, const AK::URL&, String const& target, unsigned modifiers);
- void notify_server_did_middle_click_link(Badge<WebContentClient>, const AK::URL&, String const& target, unsigned modifiers);
- void notify_server_did_start_loading(Badge<WebContentClient>, const AK::URL&);
- void notify_server_did_finish_loading(Badge<WebContentClient>, const AK::URL&);
- void notify_server_did_request_context_menu(Badge<WebContentClient>, Gfx::IntPoint const&);
- void notify_server_did_request_link_context_menu(Badge<WebContentClient>, Gfx::IntPoint const&, const AK::URL&, String const& target, unsigned modifiers);
- void notify_server_did_request_image_context_menu(Badge<WebContentClient>, Gfx::IntPoint const&, const AK::URL&, String const& target, unsigned modifiers, Gfx::ShareableBitmap const&);
- void notify_server_did_request_alert(Badge<WebContentClient>, String const& message);
- bool notify_server_did_request_confirm(Badge<WebContentClient>, String const& message);
- String notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_);
- void notify_server_did_get_source(const AK::URL& url, String const& source);
- void notify_server_did_get_dom_tree(String const& dom_tree);
- void notify_server_did_get_dom_node_properties(i32 node_id, String const& specified_style, String const& computed_style, String const& custom_properties, String const& node_box_sizing);
- void notify_server_did_output_js_console_message(i32 message_index);
- void notify_server_did_get_js_console_messages(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages);
- void notify_server_did_change_favicon(Gfx::Bitmap const& favicon);
- String notify_server_did_request_cookie(Badge<WebContentClient>, const AK::URL& url, Cookie::Source source);
- void notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, Cookie::ParsedCookie const& cookie, Cookie::Source source);
- void notify_server_did_update_resource_count(i32 count_waiting);
-
-private:
- OutOfProcessWebView();
-
- // ^Widget
- virtual void paint_event(GUI::PaintEvent&) override;
- virtual void resize_event(GUI::ResizeEvent&) override;
- virtual void mousedown_event(GUI::MouseEvent&) override;
- virtual void mouseup_event(GUI::MouseEvent&) override;
- virtual void mousemove_event(GUI::MouseEvent&) override;
- virtual void mousewheel_event(GUI::MouseEvent&) override;
- virtual void keydown_event(GUI::KeyEvent&) override;
- virtual void keyup_event(GUI::KeyEvent&) override;
- virtual void theme_change_event(GUI::ThemeChangeEvent&) override;
- virtual void screen_rects_change_event(GUI::ScreenRectsChangeEvent&) override;
- virtual void focusin_event(GUI::FocusEvent&) override;
- virtual void focusout_event(GUI::FocusEvent&) override;
-
- // ^AbstractScrollableWidget
- virtual void did_scroll() override;
-
- void request_repaint();
- void handle_resize();
-
- void create_client();
- WebContentClient& client();
-
- void handle_web_content_process_crash();
-
- AK::URL m_url;
-
- struct SharedBitmap {
- i32 id { -1 };
- i32 pending_paints { 0 };
- RefPtr<Gfx::Bitmap> bitmap;
- };
-
- struct ClientState {
- RefPtr<WebContentClient> client;
- SharedBitmap front_bitmap;
- SharedBitmap back_bitmap;
- i32 next_bitmap_id { 0 };
- bool has_usable_bitmap { false };
- bool got_repaint_requests_while_painting { false };
- } m_client_state;
-
- RefPtr<Gfx::Bitmap> m_backup_bitmap;
-};
-
-}
diff --git a/Userland/Libraries/LibWeb/WebContentClient.cpp b/Userland/Libraries/LibWeb/WebContentClient.cpp
deleted file mode 100644
index ae75861d6c..0000000000
--- a/Userland/Libraries/LibWeb/WebContentClient.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include "WebContentClient.h"
-#include "OutOfProcessWebView.h"
-#include <AK/Debug.h>
-#include <LibWeb/Cookie/ParsedCookie.h>
-
-namespace Web {
-
-WebContentClient::WebContentClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket, OutOfProcessWebView& view)
- : IPC::ConnectionToServer<WebContentClientEndpoint, WebContentServerEndpoint>(*this, move(socket))
- , m_view(view)
-{
-}
-
-void WebContentClient::die()
-{
- VERIFY(on_web_content_process_crash);
- on_web_content_process_crash();
-}
-
-void WebContentClient::did_paint(Gfx::IntRect const&, i32 bitmap_id)
-{
- m_view.notify_server_did_paint({}, bitmap_id);
-}
-
-void WebContentClient::did_finish_loading(AK::URL const& url)
-{
- m_view.notify_server_did_finish_loading({}, url);
-}
-
-void WebContentClient::did_invalidate_content_rect(Gfx::IntRect const& content_rect)
-{
- dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidInvalidateContentRect! content_rect={}", content_rect);
-
- // FIXME: Figure out a way to coalesce these messages to reduce unnecessary painting
- m_view.notify_server_did_invalidate_content_rect({}, content_rect);
-}
-
-void WebContentClient::did_change_selection()
-{
- dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidChangeSelection!");
- m_view.notify_server_did_change_selection({});
-}
-
-void WebContentClient::did_request_cursor_change(i32 cursor_type)
-{
- if (cursor_type < 0 || cursor_type >= (i32)Gfx::StandardCursor::__Count) {
- dbgln("DidRequestCursorChange: Bad cursor type");
- return;
- }
- m_view.notify_server_did_request_cursor_change({}, (Gfx::StandardCursor)cursor_type);
-}
-
-void WebContentClient::did_layout(Gfx::IntSize const& content_size)
-{
- dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidLayout! content_size={}", content_size);
- m_view.notify_server_did_layout({}, content_size);
-}
-
-void WebContentClient::did_change_title(String const& title)
-{
- dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidChangeTitle! title={}", title);
- m_view.notify_server_did_change_title({}, title);
-}
-
-void WebContentClient::did_request_scroll(i32 x_delta, i32 y_delta)
-{
- m_view.notify_server_did_request_scroll({}, x_delta, y_delta);
-}
-
-void WebContentClient::did_request_scroll_to(Gfx::IntPoint const& scroll_position)
-{
- m_view.notify_server_did_request_scroll_to({}, scroll_position);
-}
-
-void WebContentClient::did_request_scroll_into_view(Gfx::IntRect const& rect)
-{
- dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidRequestScrollIntoView! rect={}", rect);
- m_view.notify_server_did_request_scroll_into_view({}, rect);
-}
-
-void WebContentClient::did_enter_tooltip_area(Gfx::IntPoint const& content_position, String const& title)
-{
- m_view.notify_server_did_enter_tooltip_area({}, content_position, title);
-}
-
-void WebContentClient::did_leave_tooltip_area()
-{
- m_view.notify_server_did_leave_tooltip_area({});
-}
-
-void WebContentClient::did_hover_link(AK::URL const& url)
-{
- dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidHoverLink! url={}", url);
- m_view.notify_server_did_hover_link({}, url);
-}
-
-void WebContentClient::did_unhover_link()
-{
- dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidUnhoverLink!");
- m_view.notify_server_did_unhover_link({});
-}
-
-void WebContentClient::did_click_link(AK::URL const& url, String const& target, unsigned modifiers)
-{
- m_view.notify_server_did_click_link({}, url, target, modifiers);
-}
-
-void WebContentClient::did_middle_click_link(AK::URL const& url, String const& target, unsigned modifiers)
-{
- m_view.notify_server_did_middle_click_link({}, url, target, modifiers);
-}
-
-void WebContentClient::did_start_loading(AK::URL const& url)
-{
- m_view.notify_server_did_start_loading({}, url);
-}
-
-void WebContentClient::did_request_context_menu(Gfx::IntPoint const& content_position)
-{
- m_view.notify_server_did_request_context_menu({}, content_position);
-}
-
-void WebContentClient::did_request_link_context_menu(Gfx::IntPoint const& content_position, AK::URL const& url, String const& target, unsigned modifiers)
-{
- m_view.notify_server_did_request_link_context_menu({}, content_position, url, target, modifiers);
-}
-
-void WebContentClient::did_request_image_context_menu(Gfx::IntPoint const& content_position, AK::URL const& url, String const& target, unsigned modifiers, Gfx::ShareableBitmap const& bitmap)
-{
- m_view.notify_server_did_request_image_context_menu({}, content_position, url, target, modifiers, bitmap);
-}
-
-void WebContentClient::did_get_source(AK::URL const& url, String const& source)
-{
- m_view.notify_server_did_get_source(url, source);
-}
-
-void WebContentClient::did_get_dom_tree(String const& dom_tree)
-{
- m_view.notify_server_did_get_dom_tree(dom_tree);
-}
-
-void WebContentClient::did_get_dom_node_properties(i32 node_id, String const& specified_style, String const& computed_style, String const& custom_properties, String const& node_box_sizing)
-{
- m_view.notify_server_did_get_dom_node_properties(node_id, specified_style, computed_style, custom_properties, node_box_sizing);
-}
-
-void WebContentClient::did_output_js_console_message(i32 message_index)
-{
- m_view.notify_server_did_output_js_console_message(message_index);
-}
-
-void WebContentClient::did_get_js_console_messages(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages)
-{
- m_view.notify_server_did_get_js_console_messages(start_index, message_types, messages);
-}
-
-void WebContentClient::did_request_alert(String const& message)
-{
- m_view.notify_server_did_request_alert({}, message);
-}
-
-Messages::WebContentClient::DidRequestConfirmResponse WebContentClient::did_request_confirm(String const& message)
-{
- return m_view.notify_server_did_request_confirm({}, message);
-}
-
-Messages::WebContentClient::DidRequestPromptResponse WebContentClient::did_request_prompt(String const& message, String const& default_)
-{
- return m_view.notify_server_did_request_prompt({}, message, default_);
-}
-
-void WebContentClient::did_change_favicon(Gfx::ShareableBitmap const& favicon)
-{
- if (!favicon.is_valid()) {
- dbgln("DidChangeFavicon: Received invalid favicon");
- return;
- }
- m_view.notify_server_did_change_favicon(*favicon.bitmap());
-}
-
-Messages::WebContentClient::DidRequestCookieResponse WebContentClient::did_request_cookie(AK::URL const& url, u8 source)
-{
- return m_view.notify_server_did_request_cookie({}, url, static_cast<Cookie::Source>(source));
-}
-
-void WebContentClient::did_set_cookie(AK::URL const& url, Web::Cookie::ParsedCookie const& cookie, u8 source)
-{
- m_view.notify_server_did_set_cookie({}, url, cookie, static_cast<Cookie::Source>(source));
-}
-
-void WebContentClient::did_update_resource_count(i32 count_waiting)
-{
- m_view.notify_server_did_update_resource_count(count_waiting);
-}
-
-}
diff --git a/Userland/Libraries/LibWeb/WebContentClient.h b/Userland/Libraries/LibWeb/WebContentClient.h
deleted file mode 100644
index 5beef79b29..0000000000
--- a/Userland/Libraries/LibWeb/WebContentClient.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/HashMap.h>
-#include <LibIPC/ConnectionToServer.h>
-#include <LibWeb/Cookie/ParsedCookie.h>
-#include <WebContent/WebContentClientEndpoint.h>
-#include <WebContent/WebContentServerEndpoint.h>
-
-namespace Web {
-
-class OutOfProcessWebView;
-
-class WebContentClient final
- : public IPC::ConnectionToServer<WebContentClientEndpoint, WebContentServerEndpoint>
- , public WebContentClientEndpoint {
- IPC_CLIENT_CONNECTION(WebContentClient, "/tmp/portal/webcontent");
-
-public:
- Function<void()> on_web_content_process_crash;
-
-private:
- WebContentClient(NonnullOwnPtr<Core::Stream::LocalSocket>, OutOfProcessWebView&);
-
- virtual void die() override;
-
- virtual void did_paint(Gfx::IntRect const&, i32) override;
- virtual void did_finish_loading(AK::URL const&) override;
- virtual void did_invalidate_content_rect(Gfx::IntRect const&) override;
- virtual void did_change_selection() override;
- virtual void did_request_cursor_change(i32) override;
- virtual void did_layout(Gfx::IntSize const&) override;
- virtual void did_change_title(String const&) override;
- virtual void did_request_scroll(i32, i32) override;
- virtual void did_request_scroll_to(Gfx::IntPoint const&) override;
- virtual void did_request_scroll_into_view(Gfx::IntRect const&) override;
- virtual void did_enter_tooltip_area(Gfx::IntPoint const&, String const&) override;
- virtual void did_leave_tooltip_area() override;
- virtual void did_hover_link(AK::URL const&) override;
- virtual void did_unhover_link() override;
- virtual void did_click_link(AK::URL const&, String const&, unsigned) override;
- virtual void did_middle_click_link(AK::URL const&, String const&, unsigned) override;
- virtual void did_start_loading(AK::URL const&) override;
- virtual void did_request_context_menu(Gfx::IntPoint const&) override;
- virtual void did_request_link_context_menu(Gfx::IntPoint const&, AK::URL const&, String const&, unsigned) override;
- virtual void did_request_image_context_menu(Gfx::IntPoint const&, AK::URL const&, String const&, unsigned, Gfx::ShareableBitmap const&) override;
- virtual void did_get_source(AK::URL const&, String const&) override;
- virtual void did_get_dom_tree(String const&) override;
- virtual void did_get_dom_node_properties(i32 node_id, String const& specified_style, String const& computed_style, String const& custom_properties, String const& node_box_sizing) override;
- virtual void did_output_js_console_message(i32 message_index) override;
- virtual void did_get_js_console_messages(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages) override;
- virtual void did_change_favicon(Gfx::ShareableBitmap const&) override;
- virtual void did_request_alert(String const&) override;
- virtual Messages::WebContentClient::DidRequestConfirmResponse did_request_confirm(String const&) override;
- virtual Messages::WebContentClient::DidRequestPromptResponse did_request_prompt(String const&, String const&) override;
- virtual Messages::WebContentClient::DidRequestCookieResponse did_request_cookie(AK::URL const&, u8) override;
- virtual void did_set_cookie(AK::URL const&, Web::Cookie::ParsedCookie const&, u8) override;
- virtual void did_update_resource_count(i32 count_waiting) override;
-
- OutOfProcessWebView& m_view;
-};
-
-}