2020-06-17 17:31:42 +02:00
|
|
|
/*
|
2023-02-20 19:03:06 +01:00
|
|
|
* Copyright (c) 2020-2023, Andreas Kling <kling@serenityos.org>
|
2022-10-12 23:49:23 +02:00
|
|
|
* Copyright (c) 2021-2022, Linus Groh <linusg@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
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "PageHost.h"
|
2022-02-25 12:18:30 +02:00
|
|
|
#include "ConnectionFromClient.h"
|
2021-09-22 21:36:18 +02:00
|
|
|
#include <LibGfx/ShareableBitmap.h>
|
2020-06-17 17:31:42 +02:00
|
|
|
#include <LibGfx/SystemTheme.h>
|
2023-08-23 17:18:33 +01:00
|
|
|
#include <LibWeb/CSS/SystemColor.h>
|
2021-04-15 10:36:20 -04:00
|
|
|
#include <LibWeb/Cookie/ParsedCookie.h>
|
2021-11-18 15:01:28 +01:00
|
|
|
#include <LibWeb/HTML/BrowsingContext.h>
|
2023-08-22 16:00:42 +02:00
|
|
|
#include <LibWeb/HTML/TraversableNavigable.h>
|
2023-02-25 11:04:29 +01:00
|
|
|
#include <LibWeb/Layout/Viewport.h>
|
2022-03-10 23:13:37 +01:00
|
|
|
#include <LibWeb/Painting/PaintableBox.h>
|
2023-10-26 08:45:25 +02:00
|
|
|
#include <LibWeb/Painting/PaintingCommandExecutorCPU.h>
|
2023-08-19 08:38:51 +02:00
|
|
|
#include <LibWeb/Painting/ViewportPaintable.h>
|
2022-10-05 19:33:30 +02:00
|
|
|
#include <LibWeb/Platform/Timer.h>
|
2020-06-17 18:00:18 +02:00
|
|
|
#include <WebContent/WebContentClientEndpoint.h>
|
2022-11-08 10:03:07 -05:00
|
|
|
#include <WebContent/WebDriverConnection.h>
|
2020-06-17 17:31:42 +02:00
|
|
|
|
2023-11-04 20:44:22 +03:00
|
|
|
#ifdef HAS_ACCELERATED_GRAPHICS
|
2023-10-27 17:28:18 +02:00
|
|
|
# include <LibWeb/Painting/PaintingCommandExecutorGPU.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-06-17 17:31:42 +02:00
|
|
|
namespace WebContent {
|
|
|
|
|
|
2023-11-02 00:01:16 +01:00
|
|
|
static bool s_use_gpu_painter = false;
|
|
|
|
|
|
|
|
|
|
void PageHost::set_use_gpu_painter()
|
|
|
|
|
{
|
|
|
|
|
s_use_gpu_painter = true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 12:18:30 +02:00
|
|
|
PageHost::PageHost(ConnectionFromClient& client)
|
2020-06-17 18:00:18 +02:00
|
|
|
: m_client(client)
|
|
|
|
|
, m_page(make<Web::Page>(*this))
|
2020-06-17 17:31:42 +02:00
|
|
|
{
|
|
|
|
|
setup_palette();
|
2022-10-05 19:33:30 +02:00
|
|
|
m_invalidation_coalescing_timer = Web::Platform::Timer::create_single_shot(0, [this] {
|
2022-11-02 17:35:53 +00:00
|
|
|
m_client.async_did_invalidate_content_rect({ m_invalidation_rect.x().value(), m_invalidation_rect.y().value(), m_invalidation_rect.width().value(), m_invalidation_rect.height().value() });
|
2021-09-28 22:53:59 +02:00
|
|
|
m_invalidation_rect = {};
|
|
|
|
|
});
|
2020-06-17 17:31:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-08 10:03:07 -05:00
|
|
|
PageHost::~PageHost() = default;
|
|
|
|
|
|
2022-02-06 19:03:13 +01:00
|
|
|
void PageHost::set_has_focus(bool has_focus)
|
|
|
|
|
{
|
|
|
|
|
m_has_focus = has_focus;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-17 17:31:42 +02:00
|
|
|
void PageHost::setup_palette()
|
|
|
|
|
{
|
|
|
|
|
// FIXME: Get the proper palette from our peer somehow
|
2021-11-06 01:20:51 +01:00
|
|
|
auto buffer_or_error = Core::AnonymousBuffer::create_with_size(sizeof(Gfx::SystemTheme));
|
|
|
|
|
VERIFY(!buffer_or_error.is_error());
|
|
|
|
|
auto buffer = buffer_or_error.release_value();
|
2021-01-16 17:22:35 +01:00
|
|
|
auto* theme = buffer.data<Gfx::SystemTheme>();
|
2020-06-17 17:31:42 +02:00
|
|
|
theme->color[(int)Gfx::ColorRole::Window] = Color::Magenta;
|
|
|
|
|
theme->color[(int)Gfx::ColorRole::WindowText] = Color::Cyan;
|
2021-01-16 17:22:35 +01:00
|
|
|
m_palette_impl = Gfx::PaletteImpl::create_with_anonymous_buffer(buffer);
|
2020-06-17 17:31:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-21 15:18:42 -05:00
|
|
|
bool PageHost::is_connection_open() const
|
|
|
|
|
{
|
|
|
|
|
return m_client.is_open();
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-17 17:31:42 +02:00
|
|
|
Gfx::Palette PageHost::palette() const
|
|
|
|
|
{
|
|
|
|
|
return Gfx::Palette(*m_palette_impl);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 19:03:06 +01:00
|
|
|
void PageHost::set_palette_impl(Gfx::PaletteImpl& impl)
|
2020-06-17 17:31:42 +02:00
|
|
|
{
|
|
|
|
|
m_palette_impl = impl;
|
2022-07-05 17:16:50 +01:00
|
|
|
if (auto* document = page().top_level_browsing_context().active_document())
|
|
|
|
|
document->invalidate_style();
|
2020-06-17 17:31:42 +02:00
|
|
|
}
|
|
|
|
|
|
2021-10-26 17:00:10 +01:00
|
|
|
void PageHost::set_preferred_color_scheme(Web::CSS::PreferredColorScheme color_scheme)
|
|
|
|
|
{
|
|
|
|
|
m_preferred_color_scheme = color_scheme;
|
|
|
|
|
if (auto* document = page().top_level_browsing_context().active_document())
|
|
|
|
|
document->invalidate_style();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 23:23:14 +01:00
|
|
|
void PageHost::set_is_scripting_enabled(bool is_scripting_enabled)
|
|
|
|
|
{
|
|
|
|
|
page().set_is_scripting_enabled(is_scripting_enabled);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-03 12:49:54 +00:00
|
|
|
void PageHost::set_window_position(Web::DevicePixelPoint position)
|
2022-11-01 14:55:53 -04:00
|
|
|
{
|
|
|
|
|
page().set_window_position(position);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-03 12:49:54 +00:00
|
|
|
void PageHost::set_window_size(Web::DevicePixelSize size)
|
2022-11-01 14:55:53 -04:00
|
|
|
{
|
|
|
|
|
page().set_window_size(size);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
ErrorOr<void> PageHost::connect_to_webdriver(DeprecatedString const& webdriver_ipc_path)
|
2022-11-08 10:03:07 -05:00
|
|
|
{
|
|
|
|
|
VERIFY(!m_webdriver);
|
2022-11-21 16:10:57 -05:00
|
|
|
m_webdriver = TRY(WebDriverConnection::connect(*this, webdriver_ipc_path));
|
2023-03-16 08:50:22 -04:00
|
|
|
|
|
|
|
|
if (on_webdriver_connection)
|
|
|
|
|
on_webdriver_connection(*m_webdriver);
|
|
|
|
|
|
2022-11-08 10:03:07 -05:00
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 11:04:29 +01:00
|
|
|
Web::Layout::Viewport* PageHost::layout_root()
|
2020-06-17 17:31:42 +02:00
|
|
|
{
|
2021-09-09 13:14:32 +02:00
|
|
|
auto* document = page().top_level_browsing_context().active_document();
|
2020-06-17 17:31:42 +02:00
|
|
|
if (!document)
|
2020-07-04 23:19:32 +02:00
|
|
|
return nullptr;
|
|
|
|
|
return document->layout_node();
|
|
|
|
|
}
|
2020-06-17 17:31:42 +02:00
|
|
|
|
2023-05-06 07:26:19 +02:00
|
|
|
Gfx::Color PageHost::background_color() const
|
|
|
|
|
{
|
|
|
|
|
auto document = page().top_level_browsing_context().active_document();
|
|
|
|
|
if (!document)
|
|
|
|
|
return Gfx::Color::Transparent;
|
|
|
|
|
return document->background_color();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-25 17:07:19 +00:00
|
|
|
void PageHost::paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap& target)
|
2020-07-04 23:19:32 +02:00
|
|
|
{
|
2022-11-25 17:07:19 +00:00
|
|
|
Gfx::IntRect bitmap_rect { {}, content_rect.size().to_type<int>() };
|
2020-07-04 23:19:32 +02:00
|
|
|
|
2023-08-19 09:29:04 +02:00
|
|
|
auto document = page().top_level_browsing_context().active_document();
|
|
|
|
|
if (document) {
|
2021-10-28 18:29:16 +02:00
|
|
|
document->update_layout();
|
2023-08-19 09:29:04 +02:00
|
|
|
}
|
2021-10-28 18:14:38 +02:00
|
|
|
|
2023-05-06 07:26:19 +02:00
|
|
|
auto background_color = this->background_color();
|
|
|
|
|
|
2023-10-15 04:27:48 +02:00
|
|
|
Web::Painting::RecordingPainter recording_painter;
|
|
|
|
|
Web::PaintContext context(recording_painter, palette(), device_pixels_per_css_pixel());
|
|
|
|
|
|
2023-05-06 07:26:19 +02:00
|
|
|
if (background_color.alpha() < 255)
|
2023-10-21 16:46:59 +02:00
|
|
|
recording_painter.fill_rect(bitmap_rect, Web::CSS::SystemColor::canvas());
|
2023-10-15 04:27:48 +02:00
|
|
|
recording_painter.fill_rect(bitmap_rect, background_color);
|
2023-04-24 22:38:50 +02:00
|
|
|
|
2023-08-19 09:29:04 +02:00
|
|
|
if (!document->paintable())
|
2020-06-17 17:31:42 +02:00
|
|
|
return;
|
|
|
|
|
|
2021-01-31 09:06:25 +01:00
|
|
|
context.set_should_show_line_box_borders(m_should_show_line_box_borders);
|
2022-10-27 14:37:05 +01:00
|
|
|
context.set_device_viewport_rect(content_rect);
|
2022-02-06 19:03:13 +01:00
|
|
|
context.set_has_focus(m_has_focus);
|
2023-08-19 09:29:04 +02:00
|
|
|
document->paintable()->paint_all_phases(context);
|
2023-10-15 04:27:48 +02:00
|
|
|
|
2023-10-27 17:28:18 +02:00
|
|
|
if (s_use_gpu_painter) {
|
2023-10-31 13:47:22 -06:00
|
|
|
#ifdef HAS_ACCELERATED_GRAPHICS
|
2023-11-23 15:28:51 +01:00
|
|
|
Web::Painting::PaintingCommandExecutorGPU painting_command_executor(target);
|
2023-10-27 17:28:18 +02:00
|
|
|
recording_painter.execute(painting_command_executor);
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
|
|
|
|
Web::Painting::PaintingCommandExecutorCPU painting_command_executor(target);
|
|
|
|
|
recording_painter.execute(painting_command_executor);
|
|
|
|
|
}
|
2020-06-17 17:31:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-03 12:49:54 +00:00
|
|
|
void PageHost::set_viewport_rect(Web::DevicePixelRect const& rect)
|
2020-06-17 17:31:42 +02:00
|
|
|
{
|
2023-08-22 16:00:42 +02:00
|
|
|
page().top_level_traversable()->set_viewport_rect(page().device_to_css_rect(rect));
|
2020-06-17 17:31:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-02 17:35:53 +00:00
|
|
|
void PageHost::page_did_invalidate(Web::CSSPixelRect const& content_rect)
|
2020-06-17 18:00:18 +02:00
|
|
|
{
|
2022-11-02 17:35:53 +00:00
|
|
|
m_invalidation_rect = m_invalidation_rect.united(page().enclosing_device_rect(content_rect));
|
2021-09-28 22:53:59 +02:00
|
|
|
if (!m_invalidation_coalescing_timer->is_active())
|
|
|
|
|
m_invalidation_coalescing_timer->start();
|
2020-06-17 18:00:18 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 20:57:57 +02:00
|
|
|
void PageHost::page_did_change_selection()
|
|
|
|
|
{
|
2021-05-03 13:33:59 +02:00
|
|
|
m_client.async_did_change_selection();
|
2020-07-04 20:57:57 +02:00
|
|
|
}
|
|
|
|
|
|
2021-02-27 21:12:12 +00:00
|
|
|
void PageHost::page_did_request_cursor_change(Gfx::StandardCursor cursor)
|
|
|
|
|
{
|
2021-05-03 13:33:59 +02:00
|
|
|
m_client.async_did_request_cursor_change((u32)cursor);
|
2021-02-27 21:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 23:19:32 +02:00
|
|
|
void PageHost::page_did_layout()
|
|
|
|
|
{
|
|
|
|
|
auto* layout_root = this->layout_root();
|
2021-02-23 20:42:32 +01:00
|
|
|
VERIFY(layout_root);
|
2023-07-12 18:55:23 +02:00
|
|
|
if (layout_root->paintable_box()->has_scrollable_overflow())
|
2023-04-20 16:01:38 +01:00
|
|
|
m_content_size = page().enclosing_device_rect(layout_root->paintable_box()->scrollable_overflow_rect().value()).size();
|
2021-10-14 22:23:20 +02:00
|
|
|
else
|
2023-04-20 16:01:38 +01:00
|
|
|
m_content_size = page().enclosing_device_rect(layout_root->paintable_box()->absolute_rect()).size();
|
2022-11-25 17:07:19 +00:00
|
|
|
m_client.async_did_layout(m_content_size.to_type<int>());
|
2020-07-04 23:19:32 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
void PageHost::page_did_change_title(DeprecatedString const& title)
|
2020-07-04 23:40:17 +02:00
|
|
|
{
|
2021-05-03 13:33:59 +02:00
|
|
|
m_client.async_did_change_title(title);
|
2020-07-04 23:40:17 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-21 16:10:57 -05:00
|
|
|
void PageHost::page_did_request_navigate_back()
|
|
|
|
|
{
|
|
|
|
|
m_client.async_did_request_navigate_back();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PageHost::page_did_request_navigate_forward()
|
|
|
|
|
{
|
|
|
|
|
m_client.async_did_request_navigate_forward();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PageHost::page_did_request_refresh()
|
|
|
|
|
{
|
|
|
|
|
m_client.async_did_request_refresh();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-06 21:35:32 +00:00
|
|
|
Gfx::IntSize PageHost::page_did_request_resize_window(Gfx::IntSize size)
|
2022-11-21 16:10:57 -05:00
|
|
|
{
|
|
|
|
|
return m_client.did_request_resize_window(size);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-06 20:27:44 +00:00
|
|
|
Gfx::IntPoint PageHost::page_did_request_reposition_window(Gfx::IntPoint position)
|
2022-11-21 16:10:57 -05:00
|
|
|
{
|
|
|
|
|
return m_client.did_request_reposition_window(position);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PageHost::page_did_request_restore_window()
|
|
|
|
|
{
|
|
|
|
|
m_client.async_did_request_restore_window();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::IntRect PageHost::page_did_request_maximize_window()
|
|
|
|
|
{
|
|
|
|
|
return m_client.did_request_maximize_window();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::IntRect PageHost::page_did_request_minimize_window()
|
|
|
|
|
{
|
|
|
|
|
return m_client.did_request_minimize_window();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::IntRect PageHost::page_did_request_fullscreen_window()
|
|
|
|
|
{
|
|
|
|
|
return m_client.did_request_fullscreen_window();
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-08 11:22:44 +01:00
|
|
|
void PageHost::page_did_request_scroll(i32 x_delta, i32 y_delta)
|
2021-03-02 08:39:07 +11:00
|
|
|
{
|
2021-09-08 11:22:44 +01:00
|
|
|
m_client.async_did_request_scroll(x_delta, y_delta);
|
2021-03-02 08:39:07 +11:00
|
|
|
}
|
|
|
|
|
|
2022-11-02 17:35:53 +00:00
|
|
|
void PageHost::page_did_request_scroll_to(Web::CSSPixelPoint scroll_position)
|
2021-09-08 11:44:36 +01:00
|
|
|
{
|
2023-11-24 12:17:16 -05:00
|
|
|
auto device_scroll_position = page().css_to_device_point(scroll_position);
|
|
|
|
|
m_client.async_did_request_scroll_to(device_scroll_position.to_type<int>());
|
2021-09-08 11:44:36 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-02 17:35:53 +00:00
|
|
|
void PageHost::page_did_request_scroll_into_view(Web::CSSPixelRect const& rect)
|
2020-07-05 15:43:43 +02:00
|
|
|
{
|
2022-11-02 17:35:53 +00:00
|
|
|
auto device_pixel_rect = page().enclosing_device_rect(rect);
|
|
|
|
|
m_client.async_did_request_scroll_into_view({ device_pixel_rect.x().value(),
|
|
|
|
|
device_pixel_rect.y().value(),
|
|
|
|
|
device_pixel_rect.width().value(),
|
|
|
|
|
device_pixel_rect.height().value() });
|
2020-07-05 15:43:43 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-02 17:35:53 +00:00
|
|
|
void PageHost::page_did_enter_tooltip_area(Web::CSSPixelPoint content_position, DeprecatedString const& title)
|
2021-03-30 12:10:06 -04:00
|
|
|
{
|
2023-06-12 21:37:35 +03:00
|
|
|
m_client.async_did_enter_tooltip_area({ content_position.x().to_int(), content_position.y().to_int() }, title);
|
2021-03-30 12:10:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PageHost::page_did_leave_tooltip_area()
|
|
|
|
|
{
|
2021-05-03 13:33:59 +02:00
|
|
|
m_client.async_did_leave_tooltip_area();
|
2021-03-30 12:10:06 -04:00
|
|
|
}
|
|
|
|
|
|
2020-07-05 16:59:20 +02:00
|
|
|
void PageHost::page_did_hover_link(const URL& url)
|
|
|
|
|
{
|
2021-05-03 13:33:59 +02:00
|
|
|
m_client.async_did_hover_link(url);
|
2020-07-05 16:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PageHost::page_did_unhover_link()
|
|
|
|
|
{
|
2021-05-03 13:33:59 +02:00
|
|
|
m_client.async_did_unhover_link();
|
2020-07-05 16:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
void PageHost::page_did_click_link(const URL& url, DeprecatedString const& target, unsigned modifiers)
|
2020-07-06 20:01:46 +02:00
|
|
|
{
|
2021-05-03 13:33:59 +02:00
|
|
|
m_client.async_did_click_link(url, target, modifiers);
|
2020-07-06 20:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
void PageHost::page_did_middle_click_link(const URL& url, [[maybe_unused]] DeprecatedString const& target, [[maybe_unused]] unsigned modifiers)
|
2020-07-06 20:01:46 +02:00
|
|
|
{
|
2021-05-03 13:33:59 +02:00
|
|
|
m_client.async_did_middle_click_link(url, target, modifiers);
|
2020-07-06 20:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-10 00:29:35 +01:00
|
|
|
void PageHost::page_did_start_loading(const URL& url, bool is_redirect)
|
2020-07-06 21:58:16 +02:00
|
|
|
{
|
2022-11-10 00:29:35 +01:00
|
|
|
m_client.async_did_start_loading(url, is_redirect);
|
2020-07-06 21:58:16 +02:00
|
|
|
}
|
|
|
|
|
|
2023-09-07 12:11:37 +02:00
|
|
|
void PageHost::page_did_create_new_document(Web::DOM::Document& document)
|
2020-12-08 21:44:42 +01:00
|
|
|
{
|
2023-09-07 12:11:37 +02:00
|
|
|
m_client.initialize_js_console({}, document);
|
2022-09-21 17:12:00 +02:00
|
|
|
}
|
|
|
|
|
|
2023-09-17 16:11:16 +02:00
|
|
|
void PageHost::page_did_destroy_document(Web::DOM::Document& document)
|
|
|
|
|
{
|
|
|
|
|
m_client.destroy_js_console({}, document);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-21 17:12:00 +02:00
|
|
|
void PageHost::page_did_finish_loading(const URL& url)
|
|
|
|
|
{
|
2021-05-03 13:33:59 +02:00
|
|
|
m_client.async_did_finish_loading(url);
|
2020-12-08 21:44:42 +01:00
|
|
|
}
|
|
|
|
|
|
2023-09-14 19:17:32 +02:00
|
|
|
void PageHost::page_did_finish_text_test()
|
|
|
|
|
{
|
|
|
|
|
m_client.async_did_finish_text_test();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-02 17:35:53 +00:00
|
|
|
void PageHost::page_did_request_context_menu(Web::CSSPixelPoint content_position)
|
2020-07-07 12:24:29 +02:00
|
|
|
{
|
2022-11-02 17:35:53 +00:00
|
|
|
m_client.async_did_request_context_menu(page().css_to_device_point(content_position).to_type<int>());
|
2020-07-07 12:24:29 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-02 17:35:53 +00:00
|
|
|
void PageHost::page_did_request_link_context_menu(Web::CSSPixelPoint content_position, URL const& url, DeprecatedString const& target, unsigned modifiers)
|
2020-07-07 12:24:29 +02:00
|
|
|
{
|
2022-11-02 17:35:53 +00:00
|
|
|
m_client.async_did_request_link_context_menu(page().css_to_device_point(content_position).to_type<int>(), url, target, modifiers);
|
2020-07-07 12:24:29 +02:00
|
|
|
}
|
|
|
|
|
|
2023-08-17 17:59:18 -04:00
|
|
|
void PageHost::page_did_request_image_context_menu(Web::CSSPixelPoint content_position, URL const& url, DeprecatedString const& target, unsigned modifiers, Gfx::Bitmap const* bitmap_pointer)
|
|
|
|
|
{
|
|
|
|
|
auto bitmap = bitmap_pointer ? bitmap_pointer->to_shareable_bitmap() : Gfx::ShareableBitmap();
|
2023-08-17 18:01:05 -04:00
|
|
|
m_client.async_did_request_image_context_menu(page().css_to_device_point(content_position).to_type<int>(), url, target, modifiers, bitmap);
|
2023-08-17 17:59:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PageHost::page_did_request_media_context_menu(Web::CSSPixelPoint content_position, DeprecatedString const& target, unsigned modifiers, Web::Page::MediaContextMenu menu)
|
|
|
|
|
{
|
2023-08-17 18:01:05 -04:00
|
|
|
m_client.async_did_request_media_context_menu(page().css_to_device_point(content_position).to_type<int>(), target, modifiers, move(menu));
|
2023-08-17 17:59:18 -04:00
|
|
|
}
|
|
|
|
|
|
2023-03-13 17:30:51 -04:00
|
|
|
void PageHost::page_did_request_alert(String const& message)
|
2022-11-15 15:49:36 -05:00
|
|
|
{
|
|
|
|
|
m_client.async_did_request_alert(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PageHost::alert_closed()
|
|
|
|
|
{
|
2022-11-21 15:18:42 -05:00
|
|
|
page().alert_closed();
|
2020-09-12 11:56:13 +02:00
|
|
|
}
|
|
|
|
|
|
2023-03-13 17:30:51 -04:00
|
|
|
void PageHost::page_did_request_confirm(String const& message)
|
2021-02-10 08:48:28 +01:00
|
|
|
{
|
2022-11-15 15:49:36 -05:00
|
|
|
m_client.async_did_request_confirm(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PageHost::confirm_closed(bool accepted)
|
|
|
|
|
{
|
2022-11-21 15:18:42 -05:00
|
|
|
page().confirm_closed(accepted);
|
2021-02-10 08:48:28 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-13 17:30:51 -04:00
|
|
|
void PageHost::page_did_request_prompt(String const& message, String const& default_)
|
2021-02-20 12:05:18 +01:00
|
|
|
{
|
2022-11-15 15:49:36 -05:00
|
|
|
m_client.async_did_request_prompt(message, default_);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-13 17:30:51 -04:00
|
|
|
void PageHost::page_did_request_set_prompt_text(String const& text)
|
2022-11-21 16:10:57 -05:00
|
|
|
{
|
|
|
|
|
m_client.async_did_request_set_prompt_text(text);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-13 17:30:51 -04:00
|
|
|
void PageHost::prompt_closed(Optional<String> response)
|
2022-11-15 15:49:36 -05:00
|
|
|
{
|
2022-11-21 15:18:42 -05:00
|
|
|
page().prompt_closed(move(response));
|
2021-02-20 12:05:18 +01:00
|
|
|
}
|
|
|
|
|
|
2023-09-04 11:32:40 +02:00
|
|
|
void PageHost::color_picker_closed(Optional<Color> picked_color)
|
|
|
|
|
{
|
|
|
|
|
page().color_picker_closed(picked_color);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 10:51:38 -04:00
|
|
|
Web::WebIDL::ExceptionOr<void> PageHost::toggle_media_play_state()
|
2023-05-15 11:17:58 -04:00
|
|
|
{
|
2023-06-16 10:51:38 -04:00
|
|
|
return page().toggle_media_play_state();
|
2023-05-15 11:17:58 -04:00
|
|
|
}
|
|
|
|
|
|
2023-06-16 11:29:54 -04:00
|
|
|
void PageHost::toggle_media_mute_state()
|
|
|
|
|
{
|
|
|
|
|
page().toggle_media_mute_state();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 10:51:38 -04:00
|
|
|
Web::WebIDL::ExceptionOr<void> PageHost::toggle_media_loop_state()
|
2023-05-15 11:17:58 -04:00
|
|
|
{
|
2023-06-16 10:51:38 -04:00
|
|
|
return page().toggle_media_loop_state();
|
2023-05-15 11:17:58 -04:00
|
|
|
}
|
|
|
|
|
|
2023-06-16 10:51:38 -04:00
|
|
|
Web::WebIDL::ExceptionOr<void> PageHost::toggle_media_controls_state()
|
2023-05-15 11:17:58 -04:00
|
|
|
{
|
2023-06-16 10:51:38 -04:00
|
|
|
return page().toggle_media_controls_state();
|
2023-05-15 11:17:58 -04:00
|
|
|
}
|
|
|
|
|
|
2023-08-21 15:50:31 +01:00
|
|
|
void PageHost::set_user_style(String source)
|
|
|
|
|
{
|
|
|
|
|
page().set_user_style(source);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-21 15:18:42 -05:00
|
|
|
void PageHost::page_did_request_accept_dialog()
|
2022-11-16 06:58:14 -05:00
|
|
|
{
|
2022-11-21 15:18:42 -05:00
|
|
|
m_client.async_did_request_accept_dialog();
|
2022-11-16 06:58:14 -05:00
|
|
|
}
|
|
|
|
|
|
2022-11-21 15:18:42 -05:00
|
|
|
void PageHost::page_did_request_dismiss_dialog()
|
2022-11-16 07:24:22 -05:00
|
|
|
{
|
2022-11-21 15:18:42 -05:00
|
|
|
m_client.async_did_request_dismiss_dialog();
|
2022-11-16 07:24:22 -05:00
|
|
|
}
|
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
void PageHost::page_did_change_favicon(Gfx::Bitmap const& favicon)
|
2021-03-26 10:41:25 -04:00
|
|
|
{
|
2021-05-03 13:33:59 +02:00
|
|
|
m_client.async_did_change_favicon(favicon.to_shareable_bitmap());
|
2021-03-26 10:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
2022-11-21 16:10:57 -05:00
|
|
|
Vector<Web::Cookie::Cookie> PageHost::page_did_request_all_cookies(URL const& url)
|
|
|
|
|
{
|
|
|
|
|
return m_client.did_request_all_cookies(url);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
Optional<Web::Cookie::Cookie> PageHost::page_did_request_named_cookie(URL const& url, DeprecatedString const& name)
|
2022-11-21 16:10:57 -05:00
|
|
|
{
|
|
|
|
|
return m_client.did_request_named_cookie(url, name);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString PageHost::page_did_request_cookie(const URL& url, Web::Cookie::Source source)
|
2021-04-11 10:54:11 -04:00
|
|
|
{
|
2022-02-16 11:53:21 +01:00
|
|
|
auto response = m_client.send_sync_but_allow_failure<Messages::WebContentClient::DidRequestCookie>(move(url), static_cast<u8>(source));
|
|
|
|
|
if (!response) {
|
|
|
|
|
dbgln("WebContent client disconnected during DidRequestCookie. Exiting peacefully.");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
return response->take_cookie();
|
2021-04-11 10:54:11 -04:00
|
|
|
}
|
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
void PageHost::page_did_set_cookie(const URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source)
|
2021-04-11 10:54:11 -04:00
|
|
|
{
|
2021-05-03 13:33:59 +02:00
|
|
|
m_client.async_did_set_cookie(url, cookie, static_cast<u8>(source));
|
2021-04-11 10:54:11 -04:00
|
|
|
}
|
|
|
|
|
|
2022-11-28 11:24:04 -05:00
|
|
|
void PageHost::page_did_update_cookie(Web::Cookie::Cookie cookie)
|
2022-11-21 16:10:57 -05:00
|
|
|
{
|
2022-11-28 11:24:04 -05:00
|
|
|
m_client.async_did_update_cookie(move(cookie));
|
2022-11-21 16:10:57 -05:00
|
|
|
}
|
|
|
|
|
|
2022-02-20 17:03:39 -05:00
|
|
|
void PageHost::page_did_update_resource_count(i32 count_waiting)
|
|
|
|
|
{
|
|
|
|
|
m_client.async_did_update_resource_count(count_waiting);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 18:39:20 -04:00
|
|
|
String PageHost::page_did_request_new_tab(Web::HTML::ActivateTab activate_tab)
|
2023-03-14 17:12:09 +03:00
|
|
|
{
|
2023-03-20 18:39:20 -04:00
|
|
|
return m_client.did_request_new_tab(activate_tab);
|
2023-03-14 17:12:09 +03:00
|
|
|
}
|
|
|
|
|
|
2023-03-20 19:52:00 -04:00
|
|
|
void PageHost::page_did_request_activate_tab()
|
|
|
|
|
{
|
|
|
|
|
m_client.async_did_request_activate_tab();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-07 06:10:26 +03:00
|
|
|
void PageHost::page_did_close_browsing_context(Web::HTML::BrowsingContext const&)
|
|
|
|
|
{
|
|
|
|
|
m_client.async_did_close_browsing_context();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-30 16:35:47 -05:00
|
|
|
void PageHost::request_file(Web::FileRequest file_request)
|
2022-02-26 17:50:31 +01:00
|
|
|
{
|
2023-01-30 16:35:47 -05:00
|
|
|
m_client.request_file(move(file_request));
|
2022-02-26 17:50:31 +01:00
|
|
|
}
|
|
|
|
|
|
2023-09-04 11:32:40 +02:00
|
|
|
void PageHost::page_did_request_color_picker(Color current_color)
|
|
|
|
|
{
|
|
|
|
|
m_client.async_did_request_color_picker(current_color);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-19 01:51:48 +02:00
|
|
|
void PageHost::page_did_change_theme_color(Gfx::Color color)
|
|
|
|
|
{
|
|
|
|
|
m_client.async_did_change_theme_color(color);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-10 13:35:41 -05:00
|
|
|
void PageHost::page_did_insert_clipboard_entry(String data, String presentation_style, String mime_type)
|
|
|
|
|
{
|
|
|
|
|
m_client.async_did_insert_clipboard_entry(move(data), move(presentation_style), move(mime_type));
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-23 12:22:23 -05:00
|
|
|
void PageHost::inspector_did_load()
|
|
|
|
|
{
|
|
|
|
|
m_client.async_inspector_did_load();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PageHost::inspector_did_select_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement> const& pseudo_element)
|
|
|
|
|
{
|
|
|
|
|
m_client.async_inspector_did_select_dom_node(node_id, pseudo_element);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-17 17:31:42 +02:00
|
|
|
}
|