mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Ladybird+WebContent: Update IPC calls to handle multiple traversables
The IPC layer between chromes and LibWeb now understands that multiple top level traversables can live in each WebContent process. This largely mechanical change adds a billion page_id/page_index arguments to make sure that pages that end up opening new WebViews through mechanisms like window.open() still work properly with those extra windows.
This commit is contained in:
parent
adb5c27331
commit
36cd2fb7c5
Notes:
sideshowbarker
2024-07-17 10:10:18 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/36cd2fb7c5 Pull-request: https://github.com/SerenityOS/serenity/pull/23051 Reviewed-by: https://github.com/kalenikaliaksandr Reviewed-by: https://github.com/trflynn89 ✅
@ -63,12 +63,12 @@ WebViewBridge::~WebViewBridge() = default;
|
||||
void WebViewBridge::set_device_pixel_ratio(float device_pixel_ratio)
|
||||
{
|
||||
m_device_pixel_ratio = device_pixel_ratio;
|
||||
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio * m_zoom_level);
|
||||
client().async_set_device_pixels_per_css_pixel(m_client_state.page_index, m_device_pixel_ratio * m_zoom_level);
|
||||
}
|
||||
|
||||
void WebViewBridge::set_system_visibility_state(bool is_visible)
|
||||
{
|
||||
client().async_set_system_visibility_state(is_visible);
|
||||
client().async_set_system_visibility_state(m_client_state.page_index, is_visible);
|
||||
}
|
||||
|
||||
void WebViewBridge::set_viewport_rect(Gfx::IntRect viewport_rect, ForResize for_resize)
|
||||
@ -76,7 +76,7 @@ void WebViewBridge::set_viewport_rect(Gfx::IntRect viewport_rect, ForResize for_
|
||||
viewport_rect.set_size(scale_for_device(viewport_rect.size(), m_device_pixel_ratio));
|
||||
m_viewport_rect = viewport_rect;
|
||||
|
||||
client().async_set_viewport_rect(m_viewport_rect.to_type<Web::DevicePixels>());
|
||||
client().async_set_viewport_rect(m_client_state.page_index, m_viewport_rect.to_type<Web::DevicePixels>());
|
||||
|
||||
if (for_resize == ForResize::Yes) {
|
||||
handle_resize();
|
||||
@ -86,48 +86,48 @@ void WebViewBridge::set_viewport_rect(Gfx::IntRect viewport_rect, ForResize for_
|
||||
void WebViewBridge::update_palette()
|
||||
{
|
||||
auto theme = create_system_palette();
|
||||
client().async_update_system_theme(move(theme));
|
||||
client().async_update_system_theme(m_client_state.page_index, move(theme));
|
||||
}
|
||||
|
||||
void WebViewBridge::set_preferred_color_scheme(Web::CSS::PreferredColorScheme color_scheme)
|
||||
{
|
||||
m_preferred_color_scheme = color_scheme;
|
||||
client().async_set_preferred_color_scheme(color_scheme);
|
||||
client().async_set_preferred_color_scheme(m_client_state.page_index, color_scheme);
|
||||
}
|
||||
|
||||
void WebViewBridge::mouse_down_event(Gfx::IntPoint position, Gfx::IntPoint screen_position, GUI::MouseButton button, KeyModifier modifiers)
|
||||
{
|
||||
client().async_mouse_down(to_content_position(position).to_type<Web::DevicePixels>(), to_content_position(screen_position).to_type<Web::DevicePixels>(), to_underlying(button), to_underlying(button), modifiers);
|
||||
client().async_mouse_down(m_client_state.page_index, to_content_position(position).to_type<Web::DevicePixels>(), to_content_position(screen_position).to_type<Web::DevicePixels>(), to_underlying(button), to_underlying(button), modifiers);
|
||||
}
|
||||
|
||||
void WebViewBridge::mouse_up_event(Gfx::IntPoint position, Gfx::IntPoint screen_position, GUI::MouseButton button, KeyModifier modifiers)
|
||||
{
|
||||
client().async_mouse_up(to_content_position(position).to_type<Web::DevicePixels>(), to_content_position(screen_position).to_type<Web::DevicePixels>(), to_underlying(button), to_underlying(button), modifiers);
|
||||
client().async_mouse_up(m_client_state.page_index, to_content_position(position).to_type<Web::DevicePixels>(), to_content_position(screen_position).to_type<Web::DevicePixels>(), to_underlying(button), to_underlying(button), modifiers);
|
||||
}
|
||||
|
||||
void WebViewBridge::mouse_move_event(Gfx::IntPoint position, Gfx::IntPoint screen_position, GUI::MouseButton button, KeyModifier modifiers)
|
||||
{
|
||||
client().async_mouse_move(to_content_position(position).to_type<Web::DevicePixels>(), to_content_position(screen_position).to_type<Web::DevicePixels>(), 0, to_underlying(button), modifiers);
|
||||
client().async_mouse_move(m_client_state.page_index, to_content_position(position).to_type<Web::DevicePixels>(), to_content_position(screen_position).to_type<Web::DevicePixels>(), 0, to_underlying(button), modifiers);
|
||||
}
|
||||
|
||||
void WebViewBridge::mouse_wheel_event(Gfx::IntPoint position, Gfx::IntPoint screen_position, GUI::MouseButton button, KeyModifier modifiers, int wheel_delta_x, int wheel_delta_y)
|
||||
{
|
||||
client().async_mouse_wheel(to_content_position(position).to_type<Web::DevicePixels>(), to_content_position(screen_position).to_type<Web::DevicePixels>(), to_underlying(button), to_underlying(button), modifiers, wheel_delta_x, wheel_delta_y);
|
||||
client().async_mouse_wheel(m_client_state.page_index, to_content_position(position).to_type<Web::DevicePixels>(), to_content_position(screen_position).to_type<Web::DevicePixels>(), to_underlying(button), to_underlying(button), modifiers, wheel_delta_x, wheel_delta_y);
|
||||
}
|
||||
|
||||
void WebViewBridge::mouse_double_click_event(Gfx::IntPoint position, Gfx::IntPoint screen_position, GUI::MouseButton button, KeyModifier modifiers)
|
||||
{
|
||||
client().async_doubleclick(to_content_position(position).to_type<Web::DevicePixels>(), to_content_position(screen_position).to_type<Web::DevicePixels>(), button, to_underlying(button), modifiers);
|
||||
client().async_doubleclick(m_client_state.page_index, to_content_position(position).to_type<Web::DevicePixels>(), to_content_position(screen_position).to_type<Web::DevicePixels>(), button, to_underlying(button), modifiers);
|
||||
}
|
||||
|
||||
void WebViewBridge::key_down_event(KeyCode key_code, KeyModifier modifiers, u32 code_point)
|
||||
{
|
||||
client().async_key_down(key_code, modifiers, code_point);
|
||||
client().async_key_down(m_client_state.page_index, key_code, modifiers, code_point);
|
||||
}
|
||||
|
||||
void WebViewBridge::key_up_event(KeyCode key_code, KeyModifier modifiers, u32 code_point)
|
||||
{
|
||||
client().async_key_up(key_code, modifiers, code_point);
|
||||
client().async_key_up(m_client_state.page_index, key_code, modifiers, code_point);
|
||||
}
|
||||
|
||||
Optional<WebViewBridge::Paintable> WebViewBridge::paintable()
|
||||
@ -150,7 +150,7 @@ Optional<WebViewBridge::Paintable> WebViewBridge::paintable()
|
||||
|
||||
void WebViewBridge::update_zoom()
|
||||
{
|
||||
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio * m_zoom_level);
|
||||
client().async_set_device_pixels_per_css_pixel(m_client_state.page_index, m_device_pixel_ratio * m_zoom_level);
|
||||
|
||||
if (on_zoom_level_changed)
|
||||
on_zoom_level_changed();
|
||||
@ -188,20 +188,20 @@ void WebViewBridge::initialize_client(CreateNewClient)
|
||||
};
|
||||
|
||||
m_client_state.client_handle = MUST(Web::Crypto::generate_random_uuid());
|
||||
client().async_set_window_handle(m_client_state.client_handle);
|
||||
client().async_set_window_handle(m_client_state.page_index, m_client_state.client_handle);
|
||||
|
||||
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio);
|
||||
client().async_update_system_fonts(Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query(), Gfx::FontDatabase::window_title_font_query());
|
||||
client().async_set_preferred_color_scheme(m_preferred_color_scheme);
|
||||
client().async_set_device_pixels_per_css_pixel(m_client_state.page_index, m_device_pixel_ratio);
|
||||
client().async_update_system_fonts(m_client_state.page_index, Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query(), Gfx::FontDatabase::window_title_font_query());
|
||||
client().async_set_preferred_color_scheme(m_client_state.page_index, m_preferred_color_scheme);
|
||||
update_palette();
|
||||
|
||||
if (!m_screen_rects.is_empty()) {
|
||||
// FIXME: Update the screens again if they ever change.
|
||||
client().async_update_screen_rects(m_screen_rects, 0);
|
||||
client().async_update_screen_rects(m_client_state.page_index, m_screen_rects, 0);
|
||||
}
|
||||
|
||||
if (m_webdriver_content_ipc_path.has_value()) {
|
||||
client().async_connect_to_webdriver(*m_webdriver_content_ipc_path);
|
||||
client().async_connect_to_webdriver(m_client_state.page_index, *m_webdriver_content_ipc_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,11 @@ WebContentView::WebContentView(WebContentOptions const& web_content_options, Str
|
||||
};
|
||||
}
|
||||
|
||||
WebContentView::~WebContentView() = default;
|
||||
WebContentView::~WebContentView()
|
||||
{
|
||||
if (m_client_state.client)
|
||||
m_client_state.client->unregister_view(m_client_state.page_index);
|
||||
}
|
||||
|
||||
unsigned get_button_from_qt_event(QSinglePointEvent const& event)
|
||||
{
|
||||
@ -326,7 +330,7 @@ void WebContentView::mouseMoveEvent(QMouseEvent* event)
|
||||
Gfx::IntPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio);
|
||||
auto buttons = get_buttons_from_qt_event(*event);
|
||||
auto modifiers = get_modifiers_from_qt_mouse_event(*event);
|
||||
client().async_mouse_move(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, 0, buttons, modifiers);
|
||||
client().async_mouse_move(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, 0, buttons, modifiers);
|
||||
}
|
||||
|
||||
void WebContentView::mousePressEvent(QMouseEvent* event)
|
||||
@ -342,7 +346,7 @@ void WebContentView::mousePressEvent(QMouseEvent* event)
|
||||
}
|
||||
auto modifiers = get_modifiers_from_qt_mouse_event(*event);
|
||||
auto buttons = get_buttons_from_qt_event(*event);
|
||||
client().async_mouse_down(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers);
|
||||
client().async_mouse_down(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers);
|
||||
}
|
||||
|
||||
void WebContentView::mouseReleaseEvent(QMouseEvent* event)
|
||||
@ -367,7 +371,7 @@ void WebContentView::mouseReleaseEvent(QMouseEvent* event)
|
||||
}
|
||||
auto modifiers = get_modifiers_from_qt_mouse_event(*event);
|
||||
auto buttons = get_buttons_from_qt_event(*event);
|
||||
client().async_mouse_up(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers);
|
||||
client().async_mouse_up(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers);
|
||||
}
|
||||
|
||||
void WebContentView::wheelEvent(QWheelEvent* event)
|
||||
@ -381,7 +385,7 @@ void WebContentView::wheelEvent(QWheelEvent* event)
|
||||
|
||||
auto num_pixels = -event->pixelDelta();
|
||||
if (!num_pixels.isNull()) {
|
||||
client().async_mouse_wheel(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint(screen_position), button, buttons, modifiers, num_pixels.x(), num_pixels.y());
|
||||
client().async_mouse_wheel(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint(screen_position), button, buttons, modifiers, num_pixels.x(), num_pixels.y());
|
||||
} else {
|
||||
auto num_degrees = -event->angleDelta();
|
||||
float delta_x = -num_degrees.x() / 120;
|
||||
@ -389,7 +393,7 @@ void WebContentView::wheelEvent(QWheelEvent* event)
|
||||
auto step_x = delta_x * QApplication::wheelScrollLines() * m_device_pixel_ratio;
|
||||
auto step_y = delta_y * QApplication::wheelScrollLines() * m_device_pixel_ratio;
|
||||
int scroll_step_size = verticalScrollBar()->singleStep();
|
||||
client().async_mouse_wheel(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint(screen_position), button, buttons, modifiers, step_x * scroll_step_size, step_y * scroll_step_size);
|
||||
client().async_mouse_wheel(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint(screen_position), button, buttons, modifiers, step_x * scroll_step_size, step_y * scroll_step_size);
|
||||
}
|
||||
event->accept();
|
||||
return;
|
||||
@ -410,7 +414,7 @@ void WebContentView::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
}
|
||||
auto modifiers = get_modifiers_from_qt_mouse_event(*event);
|
||||
auto buttons = get_buttons_from_qt_event(*event);
|
||||
client().async_doubleclick(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers);
|
||||
client().async_doubleclick(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers);
|
||||
}
|
||||
|
||||
void WebContentView::dragEnterEvent(QDragEnterEvent* event)
|
||||
@ -443,7 +447,7 @@ void WebContentView::keyPressEvent(QKeyEvent* event)
|
||||
|
||||
if (event->key() == Qt::Key_Backtab) {
|
||||
// NOTE: Qt transforms Shift+Tab into a "Backtab", so we undo that transformation here.
|
||||
client().async_key_down(KeyCode::Key_Tab, Mod_Shift, '\t');
|
||||
client().async_key_down(m_client_state.page_index, KeyCode::Key_Tab, Mod_Shift, '\t');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -451,7 +455,7 @@ void WebContentView::keyPressEvent(QKeyEvent* event)
|
||||
auto point = text.isEmpty() ? 0u : event->text()[0].unicode();
|
||||
auto keycode = get_keycode_from_qt_keyboard_event(*event);
|
||||
auto modifiers = get_modifiers_from_qt_keyboard_event(*event);
|
||||
client().async_key_down(keycode, modifiers, point);
|
||||
client().async_key_down(m_client_state.page_index, keycode, modifiers, point);
|
||||
}
|
||||
|
||||
void WebContentView::keyReleaseEvent(QKeyEvent* event)
|
||||
@ -460,17 +464,17 @@ void WebContentView::keyReleaseEvent(QKeyEvent* event)
|
||||
auto point = text.isEmpty() ? 0u : event->text()[0].unicode();
|
||||
auto keycode = get_keycode_from_qt_keyboard_event(*event);
|
||||
auto modifiers = get_modifiers_from_qt_keyboard_event(*event);
|
||||
client().async_key_up(keycode, modifiers, point);
|
||||
client().async_key_up(m_client_state.page_index, keycode, modifiers, point);
|
||||
}
|
||||
|
||||
void WebContentView::focusInEvent(QFocusEvent*)
|
||||
{
|
||||
client().async_set_has_focus(true);
|
||||
client().async_set_has_focus(m_client_state.page_index, true);
|
||||
}
|
||||
|
||||
void WebContentView::focusOutEvent(QFocusEvent*)
|
||||
{
|
||||
client().async_set_has_focus(false);
|
||||
client().async_set_has_focus(m_client_state.page_index, false);
|
||||
}
|
||||
|
||||
void WebContentView::paintEvent(QPaintEvent*)
|
||||
@ -517,23 +521,23 @@ void WebContentView::resizeEvent(QResizeEvent* event)
|
||||
void WebContentView::set_viewport_rect(Gfx::IntRect rect)
|
||||
{
|
||||
m_viewport_rect = rect;
|
||||
client().async_set_viewport_rect(rect.to_type<Web::DevicePixels>());
|
||||
client().async_set_viewport_rect(m_client_state.page_index, rect.to_type<Web::DevicePixels>());
|
||||
}
|
||||
|
||||
void WebContentView::set_window_size(Gfx::IntSize size)
|
||||
{
|
||||
client().async_set_window_size(size.to_type<Web::DevicePixels>());
|
||||
client().async_set_window_size(m_client_state.page_index, size.to_type<Web::DevicePixels>());
|
||||
}
|
||||
|
||||
void WebContentView::set_window_position(Gfx::IntPoint position)
|
||||
{
|
||||
client().async_set_window_position(position.to_type<Web::DevicePixels>());
|
||||
client().async_set_window_position(m_client_state.page_index, position.to_type<Web::DevicePixels>());
|
||||
}
|
||||
|
||||
void WebContentView::set_device_pixel_ratio(double device_pixel_ratio)
|
||||
{
|
||||
m_device_pixel_ratio = device_pixel_ratio;
|
||||
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio * m_zoom_level);
|
||||
client().async_set_device_pixels_per_css_pixel(m_client_state.page_index, m_device_pixel_ratio * m_zoom_level);
|
||||
update_viewport_rect();
|
||||
handle_resize();
|
||||
}
|
||||
@ -549,20 +553,20 @@ void WebContentView::update_viewport_rect()
|
||||
|
||||
void WebContentView::update_zoom()
|
||||
{
|
||||
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio * m_zoom_level);
|
||||
client().async_set_device_pixels_per_css_pixel(m_client_state.page_index, m_device_pixel_ratio * m_zoom_level);
|
||||
update_viewport_rect();
|
||||
}
|
||||
|
||||
void WebContentView::showEvent(QShowEvent* event)
|
||||
{
|
||||
QAbstractScrollArea::showEvent(event);
|
||||
client().async_set_system_visibility_state(true);
|
||||
client().async_set_system_visibility_state(m_client_state.page_index, true);
|
||||
}
|
||||
|
||||
void WebContentView::hideEvent(QHideEvent* event)
|
||||
{
|
||||
QAbstractScrollArea::hideEvent(event);
|
||||
client().async_set_system_visibility_state(false);
|
||||
client().async_set_system_visibility_state(m_client_state.page_index, false);
|
||||
}
|
||||
|
||||
static Core::AnonymousBuffer make_system_theme_from_qt_palette(QWidget& widget, WebContentView::PaletteMode mode)
|
||||
@ -599,7 +603,7 @@ static Core::AnonymousBuffer make_system_theme_from_qt_palette(QWidget& widget,
|
||||
|
||||
void WebContentView::update_palette(PaletteMode mode)
|
||||
{
|
||||
client().async_update_system_theme(make_system_theme_from_qt_palette(*this, mode));
|
||||
client().async_update_system_theme(m_client_state.page_index, make_system_theme_from_qt_palette(*this, mode));
|
||||
}
|
||||
|
||||
void WebContentView::initialize_client(WebView::ViewImplementation::CreateNewClient create_new_client)
|
||||
@ -611,6 +615,8 @@ void WebContentView::initialize_client(WebView::ViewImplementation::CreateNewCli
|
||||
auto new_client = launch_web_content_process(*this, candidate_web_content_paths, m_web_content_options).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
m_client_state.client = new_client;
|
||||
} else {
|
||||
m_client_state.client->register_view(m_client_state.page_index, *this);
|
||||
}
|
||||
|
||||
m_client_state.client->on_web_content_process_crash = [this] {
|
||||
@ -620,11 +626,11 @@ void WebContentView::initialize_client(WebView::ViewImplementation::CreateNewCli
|
||||
};
|
||||
|
||||
m_client_state.client_handle = Web::Crypto::generate_random_uuid().release_value_but_fixme_should_propagate_errors();
|
||||
client().async_set_window_handle(m_client_state.client_handle);
|
||||
client().async_set_window_handle(m_client_state.page_index, m_client_state.client_handle);
|
||||
|
||||
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio);
|
||||
client().async_set_device_pixels_per_css_pixel(m_client_state.page_index, m_device_pixel_ratio);
|
||||
update_palette();
|
||||
client().async_update_system_fonts(Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query(), Gfx::FontDatabase::window_title_font_query());
|
||||
client().async_update_system_fonts(m_client_state.page_index, Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query(), Gfx::FontDatabase::window_title_font_query());
|
||||
|
||||
auto screens = QGuiApplication::screens();
|
||||
|
||||
@ -640,11 +646,11 @@ void WebContentView::initialize_client(WebView::ViewImplementation::CreateNewCli
|
||||
// NOTE: The first item in QGuiApplication::screens is always the primary screen.
|
||||
// This is not specified in the documentation but QGuiApplication::primaryScreen
|
||||
// always returns the first item in the list if it isn't empty.
|
||||
client().async_update_screen_rects(screen_rects, 0);
|
||||
client().async_update_screen_rects(m_client_state.page_index, screen_rects, 0);
|
||||
}
|
||||
|
||||
if (!m_webdriver_content_ipc_path.is_empty())
|
||||
client().async_connect_to_webdriver(m_webdriver_content_ipc_path);
|
||||
client().async_connect_to_webdriver(m_client_state.page_index, m_webdriver_content_ipc_path);
|
||||
}
|
||||
|
||||
void WebContentView::update_cursor(Gfx::StandardCursor cursor)
|
||||
@ -749,7 +755,7 @@ bool WebContentView::event(QEvent* event)
|
||||
|
||||
ErrorOr<String> WebContentView::dump_layout_tree()
|
||||
{
|
||||
return String::from_byte_string(client().dump_layout_tree());
|
||||
return String::from_byte_string(client().dump_layout_tree(m_client_state.page_index));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -890,7 +890,8 @@ void TraversableNavigable::destroy_top_level_traversable()
|
||||
// 3. Remove browsingContext.
|
||||
browsing_context->remove();
|
||||
|
||||
// FIXME: 4. Remove traversable from the user interface (e.g., close or hide its tab in a tabbed browser).
|
||||
// 4. Remove traversable from the user interface (e.g., close or hide its tab in a tabbed browser).
|
||||
page().client().page_did_close_top_level_traversable();
|
||||
|
||||
// 5. Remove traversable from the user agent's top-level traversable set.
|
||||
user_agent_top_level_traversable_set().remove(this);
|
||||
|
@ -276,7 +276,7 @@ public:
|
||||
};
|
||||
virtual NewWebViewResult page_did_request_new_web_view(HTML::ActivateTab, HTML::WebViewHints, HTML::TokenizedFeature::NoOpener) { return {}; }
|
||||
virtual void page_did_request_activate_tab() { }
|
||||
virtual void page_did_close_browsing_context(HTML::BrowsingContext const&) { }
|
||||
virtual void page_did_close_top_level_traversable() { }
|
||||
|
||||
virtual void request_file(FileRequest) = 0;
|
||||
|
||||
|
@ -42,9 +42,9 @@ OutOfProcessWebView::OutOfProcessWebView()
|
||||
auto file = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), path);
|
||||
|
||||
if (file.is_error())
|
||||
client().async_handle_file_return(file.error().code(), {}, request_id);
|
||||
client().async_handle_file_return(m_client_state.page_index, file.error().code(), {}, request_id);
|
||||
else
|
||||
client().async_handle_file_return(0, IPC::File(file.value().stream()), request_id);
|
||||
client().async_handle_file_return(m_client_state.page_index, 0, IPC::File(file.value().stream()), request_id);
|
||||
};
|
||||
|
||||
on_scroll_by_delta = [this](auto x_delta, auto y_delta) {
|
||||
@ -95,16 +95,16 @@ void OutOfProcessWebView::initialize_client(WebView::ViewImplementation::CreateN
|
||||
};
|
||||
|
||||
m_client_state.client_handle = Web::Crypto::generate_random_uuid().release_value_but_fixme_should_propagate_errors();
|
||||
client().async_set_window_handle(m_client_state.client_handle);
|
||||
client().async_set_window_handle(m_client_state.page_index, m_client_state.client_handle);
|
||||
|
||||
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(), Gfx::FontDatabase::window_title_font_query());
|
||||
client().async_update_system_theme(m_client_state.page_index, Gfx::current_system_theme_buffer());
|
||||
client().async_update_system_fonts(m_client_state.page_index, Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query(), Gfx::FontDatabase::window_title_font_query());
|
||||
|
||||
Vector<Web::DevicePixelRect> screen_rects;
|
||||
for (auto const& screen_rect : GUI::Desktop::the().rects()) {
|
||||
screen_rects.append(screen_rect.to_type<Web::DevicePixels>());
|
||||
}
|
||||
client().async_update_screen_rects(screen_rects, GUI::Desktop::the().main_screen_index());
|
||||
client().async_update_screen_rects(m_client_state.page_index, screen_rects, GUI::Desktop::the().main_screen_index());
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::paint_event(GUI::PaintEvent& event)
|
||||
@ -141,7 +141,7 @@ void OutOfProcessWebView::paint_event(GUI::PaintEvent& event)
|
||||
void OutOfProcessWebView::resize_event(GUI::ResizeEvent& event)
|
||||
{
|
||||
Super::resize_event(event);
|
||||
client().async_set_viewport_rect(Web::DevicePixelRect({ horizontal_scrollbar().value(), vertical_scrollbar().value() }, available_size()));
|
||||
client().async_set_viewport_rect(m_client_state.page_index, Web::DevicePixelRect({ horizontal_scrollbar().value(), vertical_scrollbar().value() }, available_size()));
|
||||
handle_resize();
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ Gfx::IntPoint OutOfProcessWebView::to_widget_position(Gfx::IntPoint content_posi
|
||||
|
||||
void OutOfProcessWebView::update_zoom()
|
||||
{
|
||||
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio * m_zoom_level);
|
||||
client().async_set_device_pixels_per_css_pixel(m_client_state.page_index, m_device_pixel_ratio * m_zoom_level);
|
||||
// FIXME: Refactor this into separate update_viewport_rect() + request_repaint() like in Ladybird
|
||||
handle_resize();
|
||||
}
|
||||
@ -213,7 +213,7 @@ void OutOfProcessWebView::doubleclick_event(GUI::MouseEvent& event)
|
||||
void OutOfProcessWebView::theme_change_event(GUI::ThemeChangeEvent& event)
|
||||
{
|
||||
Super::theme_change_event(event);
|
||||
client().async_update_system_theme(Gfx::current_system_theme_buffer());
|
||||
client().async_update_system_theme(m_client_state.page_index, Gfx::current_system_theme_buffer());
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::screen_rects_change_event(GUI::ScreenRectsChangeEvent& event)
|
||||
@ -222,77 +222,77 @@ void OutOfProcessWebView::screen_rects_change_event(GUI::ScreenRectsChangeEvent&
|
||||
for (auto const& screen_rect : event.rects()) {
|
||||
screen_rects.append(screen_rect.to_type<Web::DevicePixels>());
|
||||
}
|
||||
client().async_update_screen_rects(screen_rects, event.main_screen_index());
|
||||
client().async_update_screen_rects(m_client_state.page_index, screen_rects, event.main_screen_index());
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::did_scroll()
|
||||
{
|
||||
client().async_set_viewport_rect(visible_content_rect().to_type<Web::DevicePixels>());
|
||||
client().async_set_viewport_rect(m_client_state.page_index, visible_content_rect().to_type<Web::DevicePixels>());
|
||||
}
|
||||
|
||||
ByteString OutOfProcessWebView::dump_layout_tree()
|
||||
{
|
||||
return client().dump_layout_tree();
|
||||
return client().dump_layout_tree(m_client_state.page_index);
|
||||
}
|
||||
|
||||
OrderedHashMap<String, String> OutOfProcessWebView::get_local_storage_entries()
|
||||
{
|
||||
return client().get_local_storage_entries();
|
||||
return client().get_local_storage_entries(m_client_state.page_index);
|
||||
}
|
||||
|
||||
OrderedHashMap<String, String> OutOfProcessWebView::get_session_storage_entries()
|
||||
{
|
||||
return client().get_session_storage_entries();
|
||||
return client().get_session_storage_entries(m_client_state.page_index);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::set_content_filters(Vector<String> filters)
|
||||
{
|
||||
client().async_set_content_filters(move(filters));
|
||||
client().async_set_content_filters(m_client_state.page_index, move(filters));
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::set_autoplay_allowed_on_all_websites()
|
||||
{
|
||||
client().async_set_autoplay_allowed_on_all_websites();
|
||||
client().async_set_autoplay_allowed_on_all_websites(m_client_state.page_index);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::set_autoplay_allowlist(Vector<String> allowlist)
|
||||
{
|
||||
client().async_set_autoplay_allowlist(move(allowlist));
|
||||
client().async_set_autoplay_allowlist(m_client_state.page_index, move(allowlist));
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::set_proxy_mappings(Vector<ByteString> proxies, HashMap<ByteString, size_t> mappings)
|
||||
{
|
||||
client().async_set_proxy_mappings(move(proxies), move(mappings));
|
||||
client().async_set_proxy_mappings(m_client_state.page_index, move(proxies), move(mappings));
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::connect_to_webdriver(ByteString const& webdriver_ipc_path)
|
||||
{
|
||||
client().async_connect_to_webdriver(webdriver_ipc_path);
|
||||
client().async_connect_to_webdriver(m_client_state.page_index, webdriver_ipc_path);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::set_window_position(Gfx::IntPoint position)
|
||||
{
|
||||
client().async_set_window_position(position.to_type<Web::DevicePixels>());
|
||||
client().async_set_window_position(m_client_state.page_index, position.to_type<Web::DevicePixels>());
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::set_window_size(Gfx::IntSize size)
|
||||
{
|
||||
client().async_set_window_size(size.to_type<Web::DevicePixels>());
|
||||
client().async_set_window_size(m_client_state.page_index, size.to_type<Web::DevicePixels>());
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::focusin_event(GUI::FocusEvent&)
|
||||
{
|
||||
client().async_set_has_focus(true);
|
||||
client().async_set_has_focus(m_client_state.page_index, true);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::focusout_event(GUI::FocusEvent&)
|
||||
{
|
||||
client().async_set_has_focus(false);
|
||||
client().async_set_has_focus(m_client_state.page_index, false);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::set_system_visibility_state(bool visible)
|
||||
{
|
||||
client().async_set_system_visibility_state(visible);
|
||||
client().async_set_system_visibility_state(m_client_state.page_index, visible);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::show_event(GUI::ShowEvent&)
|
||||
@ -328,10 +328,10 @@ void OutOfProcessWebView::process_next_input_event()
|
||||
[this](GUI::KeyEvent const& event) {
|
||||
switch (event.type()) {
|
||||
case GUI::Event::Type::KeyDown:
|
||||
client().async_key_down(event.key(), event.modifiers(), event.code_point());
|
||||
client().async_key_down(m_client_state.page_index, event.key(), event.modifiers(), event.code_point());
|
||||
break;
|
||||
case GUI::Event::Type::KeyUp:
|
||||
client().async_key_up(event.key(), event.modifiers(), event.code_point());
|
||||
client().async_key_up(m_client_state.page_index, event.key(), event.modifiers(), event.code_point());
|
||||
break;
|
||||
default:
|
||||
dbgln("Unrecognized key event type in OOPWV input event queue: {}", event.type());
|
||||
@ -343,22 +343,22 @@ void OutOfProcessWebView::process_next_input_event()
|
||||
auto screen_position = (event.position() + (window()->position() + relative_position())).to_type<Web::DevicePixels>();
|
||||
switch (event.type()) {
|
||||
case GUI::Event::Type::MouseDown:
|
||||
client().async_mouse_down(position, screen_position, event.button(), event.buttons(), event.modifiers());
|
||||
client().async_mouse_down(m_client_state.page_index, position, screen_position, event.button(), event.buttons(), event.modifiers());
|
||||
break;
|
||||
case GUI::Event::Type::MouseUp:
|
||||
client().async_mouse_up(position, screen_position, event.button(), event.buttons(), event.modifiers());
|
||||
client().async_mouse_up(m_client_state.page_index, position, screen_position, event.button(), event.buttons(), event.modifiers());
|
||||
break;
|
||||
case GUI::Event::Type::MouseMove:
|
||||
client().async_mouse_move(position, screen_position, event.button(), event.buttons(), event.modifiers());
|
||||
client().async_mouse_move(m_client_state.page_index, position, screen_position, event.button(), event.buttons(), event.modifiers());
|
||||
break;
|
||||
case GUI::Event::Type::MouseWheel: {
|
||||
// FIXME: This wheel delta step size multiplier is used to remain the old scroll behaviour, in future use system step size.
|
||||
constexpr int scroll_step_size = 24;
|
||||
client().async_mouse_wheel(position, screen_position, event.button(), event.buttons(), event.modifiers(), event.wheel_delta_x() * scroll_step_size, event.wheel_delta_y() * scroll_step_size);
|
||||
client().async_mouse_wheel(m_client_state.page_index, position, screen_position, event.button(), event.buttons(), event.modifiers(), event.wheel_delta_x() * scroll_step_size, event.wheel_delta_y() * scroll_step_size);
|
||||
break;
|
||||
}
|
||||
case GUI::Event::Type::MouseDoubleClick:
|
||||
client().async_doubleclick(position, screen_position, event.button(), event.buttons(), event.modifiers());
|
||||
client().async_doubleclick(m_client_state.page_index, position, screen_position, event.button(), event.buttons(), event.modifiers());
|
||||
break;
|
||||
default:
|
||||
dbgln("Unrecognized mouse event type in OOPWV input event queue: {}", event.type());
|
||||
|
@ -30,12 +30,18 @@ ViewImplementation::ViewImplementation()
|
||||
auto file = Core::File::open(path, Core::File::OpenMode::Read);
|
||||
|
||||
if (file.is_error())
|
||||
client().async_handle_file_return(file.error().code(), {}, request_id);
|
||||
client().async_handle_file_return(page_id(), file.error().code(), {}, request_id);
|
||||
else
|
||||
client().async_handle_file_return(0, IPC::File(*file.value()), request_id);
|
||||
client().async_handle_file_return(page_id(), 0, IPC::File(*file.value()), request_id);
|
||||
};
|
||||
}
|
||||
|
||||
ViewImplementation::~ViewImplementation()
|
||||
{
|
||||
if (m_client_state.client)
|
||||
m_client_state.client->unregister_view(m_client_state.page_index);
|
||||
}
|
||||
|
||||
WebContentClient& ViewImplementation::client()
|
||||
{
|
||||
VERIFY(m_client_state.client);
|
||||
@ -48,6 +54,12 @@ WebContentClient const& ViewImplementation::client() const
|
||||
return *m_client_state.client;
|
||||
}
|
||||
|
||||
u64 ViewImplementation::page_id() const
|
||||
{
|
||||
VERIFY(m_client_state.client);
|
||||
return m_client_state.page_index;
|
||||
}
|
||||
|
||||
void ViewImplementation::server_did_paint(Badge<WebContentClient>, i32 bitmap_id, Gfx::IntSize size)
|
||||
{
|
||||
if (m_client_state.back_bitmap.id == bitmap_id) {
|
||||
@ -59,18 +71,18 @@ void ViewImplementation::server_did_paint(Badge<WebContentClient>, i32 bitmap_id
|
||||
on_ready_to_paint();
|
||||
}
|
||||
|
||||
client().async_ready_to_paint();
|
||||
client().async_ready_to_paint(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::load(AK::URL const& url)
|
||||
{
|
||||
m_url = url;
|
||||
client().async_load_url(url);
|
||||
client().async_load_url(page_id(), url);
|
||||
}
|
||||
|
||||
void ViewImplementation::load_html(StringView html)
|
||||
{
|
||||
client().async_load_html(html);
|
||||
client().async_load_html(page_id(), html);
|
||||
}
|
||||
|
||||
void ViewImplementation::load_empty_document()
|
||||
@ -102,12 +114,12 @@ void ViewImplementation::reset_zoom()
|
||||
|
||||
void ViewImplementation::set_preferred_color_scheme(Web::CSS::PreferredColorScheme color_scheme)
|
||||
{
|
||||
client().async_set_preferred_color_scheme(color_scheme);
|
||||
client().async_set_preferred_color_scheme(page_id(), color_scheme);
|
||||
}
|
||||
|
||||
ByteString ViewImplementation::selected_text()
|
||||
{
|
||||
return client().get_selected_text();
|
||||
return client().get_selected_text(page_id());
|
||||
}
|
||||
|
||||
Optional<String> ViewImplementation::selected_text_with_whitespace_collapsed()
|
||||
@ -120,27 +132,27 @@ Optional<String> ViewImplementation::selected_text_with_whitespace_collapsed()
|
||||
|
||||
void ViewImplementation::select_all()
|
||||
{
|
||||
client().async_select_all();
|
||||
client().async_select_all(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::get_source()
|
||||
{
|
||||
client().async_get_source();
|
||||
client().async_get_source(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::inspect_dom_tree()
|
||||
{
|
||||
client().async_inspect_dom_tree();
|
||||
client().async_inspect_dom_tree(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element)
|
||||
{
|
||||
client().async_inspect_dom_node(node_id, move(pseudo_element));
|
||||
client().async_inspect_dom_node(page_id(), node_id, move(pseudo_element));
|
||||
}
|
||||
|
||||
void ViewImplementation::inspect_accessibility_tree()
|
||||
{
|
||||
client().async_inspect_accessibility_tree();
|
||||
client().async_inspect_accessibility_tree(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::clear_inspected_dom_node()
|
||||
@ -150,117 +162,117 @@ void ViewImplementation::clear_inspected_dom_node()
|
||||
|
||||
void ViewImplementation::get_hovered_node_id()
|
||||
{
|
||||
client().async_get_hovered_node_id();
|
||||
client().async_get_hovered_node_id(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::set_dom_node_text(i32 node_id, String text)
|
||||
{
|
||||
client().async_set_dom_node_text(node_id, move(text));
|
||||
client().async_set_dom_node_text(page_id(), node_id, move(text));
|
||||
}
|
||||
|
||||
void ViewImplementation::set_dom_node_tag(i32 node_id, String name)
|
||||
{
|
||||
client().async_set_dom_node_tag(node_id, move(name));
|
||||
client().async_set_dom_node_tag(page_id(), node_id, move(name));
|
||||
}
|
||||
|
||||
void ViewImplementation::add_dom_node_attributes(i32 node_id, Vector<Attribute> attributes)
|
||||
{
|
||||
client().async_add_dom_node_attributes(node_id, move(attributes));
|
||||
client().async_add_dom_node_attributes(page_id(), node_id, move(attributes));
|
||||
}
|
||||
|
||||
void ViewImplementation::replace_dom_node_attribute(i32 node_id, String name, Vector<Attribute> replacement_attributes)
|
||||
{
|
||||
client().async_replace_dom_node_attribute(node_id, move(name), move(replacement_attributes));
|
||||
client().async_replace_dom_node_attribute(page_id(), node_id, move(name), move(replacement_attributes));
|
||||
}
|
||||
|
||||
void ViewImplementation::create_child_element(i32 node_id)
|
||||
{
|
||||
client().async_create_child_element(node_id);
|
||||
client().async_create_child_element(page_id(), node_id);
|
||||
}
|
||||
|
||||
void ViewImplementation::create_child_text_node(i32 node_id)
|
||||
{
|
||||
client().async_create_child_text_node(node_id);
|
||||
client().async_create_child_text_node(page_id(), node_id);
|
||||
}
|
||||
|
||||
void ViewImplementation::clone_dom_node(i32 node_id)
|
||||
{
|
||||
client().async_clone_dom_node(node_id);
|
||||
client().async_clone_dom_node(page_id(), node_id);
|
||||
}
|
||||
|
||||
void ViewImplementation::remove_dom_node(i32 node_id)
|
||||
{
|
||||
client().async_remove_dom_node(node_id);
|
||||
client().async_remove_dom_node(page_id(), node_id);
|
||||
}
|
||||
|
||||
void ViewImplementation::get_dom_node_html(i32 node_id)
|
||||
{
|
||||
client().async_get_dom_node_html(node_id);
|
||||
client().async_get_dom_node_html(page_id(), node_id);
|
||||
}
|
||||
|
||||
void ViewImplementation::debug_request(ByteString const& request, ByteString const& argument)
|
||||
{
|
||||
client().async_debug_request(request, argument);
|
||||
client().async_debug_request(page_id(), request, argument);
|
||||
}
|
||||
|
||||
void ViewImplementation::run_javascript(StringView js_source)
|
||||
{
|
||||
client().async_run_javascript(js_source);
|
||||
client().async_run_javascript(page_id(), js_source);
|
||||
}
|
||||
|
||||
void ViewImplementation::js_console_input(ByteString const& js_source)
|
||||
{
|
||||
client().async_js_console_input(js_source);
|
||||
client().async_js_console_input(page_id(), js_source);
|
||||
}
|
||||
|
||||
void ViewImplementation::js_console_request_messages(i32 start_index)
|
||||
{
|
||||
client().async_js_console_request_messages(start_index);
|
||||
client().async_js_console_request_messages(page_id(), start_index);
|
||||
}
|
||||
|
||||
void ViewImplementation::alert_closed()
|
||||
{
|
||||
client().async_alert_closed();
|
||||
client().async_alert_closed(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::confirm_closed(bool accepted)
|
||||
{
|
||||
client().async_confirm_closed(accepted);
|
||||
client().async_confirm_closed(page_id(), accepted);
|
||||
}
|
||||
|
||||
void ViewImplementation::prompt_closed(Optional<String> response)
|
||||
{
|
||||
client().async_prompt_closed(move(response));
|
||||
client().async_prompt_closed(page_id(), move(response));
|
||||
}
|
||||
|
||||
void ViewImplementation::color_picker_update(Optional<Color> picked_color, Web::HTML::ColorPickerUpdateState state)
|
||||
{
|
||||
client().async_color_picker_update(picked_color, state);
|
||||
client().async_color_picker_update(page_id(), picked_color, state);
|
||||
}
|
||||
|
||||
void ViewImplementation::select_dropdown_closed(Optional<String> value)
|
||||
{
|
||||
client().async_select_dropdown_closed(value);
|
||||
client().async_select_dropdown_closed(page_id(), value);
|
||||
}
|
||||
|
||||
void ViewImplementation::toggle_media_play_state()
|
||||
{
|
||||
client().async_toggle_media_play_state();
|
||||
client().async_toggle_media_play_state(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::toggle_media_mute_state()
|
||||
{
|
||||
client().async_toggle_media_mute_state();
|
||||
client().async_toggle_media_mute_state(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::toggle_media_loop_state()
|
||||
{
|
||||
client().async_toggle_media_loop_state();
|
||||
client().async_toggle_media_loop_state(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::toggle_media_controls_state()
|
||||
{
|
||||
client().async_toggle_media_controls_state();
|
||||
client().async_toggle_media_controls_state(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::handle_resize()
|
||||
@ -315,9 +327,9 @@ void ViewImplementation::resize_backing_stores_if_needed(WindowResizeInProgress
|
||||
auto& back_bitmap = m_client_state.back_bitmap;
|
||||
|
||||
if (front_bitmap.id != old_front_bitmap_id || back_bitmap.id != old_back_bitmap_id) {
|
||||
client().async_add_backing_store(front_bitmap.id, front_bitmap.bitmap->to_shareable_bitmap(), back_bitmap.id,
|
||||
client().async_add_backing_store(page_id(), front_bitmap.id, front_bitmap.bitmap->to_shareable_bitmap(), back_bitmap.id,
|
||||
back_bitmap.bitmap->to_shareable_bitmap());
|
||||
client().async_set_viewport_rect(viewport_rect);
|
||||
client().async_set_viewport_rect(page_id(), viewport_rect);
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,7 +409,7 @@ NonnullRefPtr<Core::Promise<LexicalPath>> ViewImplementation::take_screenshot(Sc
|
||||
|
||||
case ScreenshotType::Full:
|
||||
m_pending_screenshot = promise;
|
||||
client().async_take_document_screenshot();
|
||||
client().async_take_document_screenshot(page_id());
|
||||
break;
|
||||
}
|
||||
|
||||
@ -416,7 +428,7 @@ NonnullRefPtr<Core::Promise<LexicalPath>> ViewImplementation::take_dom_node_scre
|
||||
}
|
||||
|
||||
m_pending_screenshot = promise;
|
||||
client().async_take_dom_node_screenshot(node_id);
|
||||
client().async_take_dom_node_screenshot(page_id(), node_id);
|
||||
|
||||
return promise;
|
||||
}
|
||||
@ -435,7 +447,7 @@ void ViewImplementation::did_receive_screenshot(Badge<WebContentClient>, Gfx::Sh
|
||||
|
||||
ErrorOr<LexicalPath> ViewImplementation::dump_gc_graph()
|
||||
{
|
||||
auto gc_graph_json = client().dump_gc_graph();
|
||||
auto gc_graph_json = client().dump_gc_graph(page_id());
|
||||
|
||||
LexicalPath path { Core::StandardPaths::tempfile_directory() };
|
||||
path = path.append(TRY(Core::DateTime::now().to_string("gc-graph-%Y-%m-%d-%H-%M-%S.json"sv)));
|
||||
@ -448,7 +460,7 @@ ErrorOr<LexicalPath> ViewImplementation::dump_gc_graph()
|
||||
|
||||
void ViewImplementation::set_user_style_sheet(String source)
|
||||
{
|
||||
client().async_set_user_style(move(source));
|
||||
client().async_set_user_style(page_id(), move(source));
|
||||
}
|
||||
|
||||
void ViewImplementation::use_native_user_style_sheet()
|
||||
@ -459,7 +471,7 @@ void ViewImplementation::use_native_user_style_sheet()
|
||||
|
||||
void ViewImplementation::enable_inspector_prototype()
|
||||
{
|
||||
client().async_enable_inspector_prototype();
|
||||
client().async_enable_inspector_prototype(page_id());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace WebView {
|
||||
|
||||
class ViewImplementation {
|
||||
public:
|
||||
virtual ~ViewImplementation() { }
|
||||
virtual ~ViewImplementation();
|
||||
|
||||
struct DOMNodeProperties {
|
||||
String computed_style_json;
|
||||
@ -192,6 +192,7 @@ protected:
|
||||
|
||||
WebContentClient& client();
|
||||
WebContentClient const& client() const;
|
||||
u64 page_id() const;
|
||||
virtual void update_zoom() = 0;
|
||||
|
||||
enum class WindowResizeInProgress {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -26,82 +26,86 @@ class WebContentClient final
|
||||
public:
|
||||
WebContentClient(NonnullOwnPtr<Core::LocalSocket>, ViewImplementation&);
|
||||
|
||||
void register_view(u64 page_id, ViewImplementation&);
|
||||
void unregister_view(u64 page_id);
|
||||
|
||||
Function<void()> on_web_content_process_crash;
|
||||
|
||||
private:
|
||||
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_request_navigate_back() override;
|
||||
virtual void did_request_navigate_forward() override;
|
||||
virtual void did_request_refresh() override;
|
||||
virtual void did_request_cursor_change(i32) override;
|
||||
virtual void did_layout(Gfx::IntSize) override;
|
||||
virtual void did_change_title(ByteString const&) override;
|
||||
virtual void did_request_scroll(i32, i32) override;
|
||||
virtual void did_request_scroll_to(Gfx::IntPoint) override;
|
||||
virtual void did_enter_tooltip_area(Gfx::IntPoint, ByteString 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&, ByteString const&, unsigned) override;
|
||||
virtual void did_middle_click_link(AK::URL const&, ByteString const&, unsigned) override;
|
||||
virtual void did_start_loading(AK::URL const&, bool) override;
|
||||
virtual void did_request_context_menu(Gfx::IntPoint) override;
|
||||
virtual void did_request_link_context_menu(Gfx::IntPoint, AK::URL const&, ByteString const&, unsigned) override;
|
||||
virtual void did_request_image_context_menu(Gfx::IntPoint, AK::URL const&, ByteString const&, unsigned, Gfx::ShareableBitmap const&) override;
|
||||
virtual void did_request_media_context_menu(Gfx::IntPoint, ByteString const&, unsigned, Web::Page::MediaContextMenu const&) override;
|
||||
virtual void did_get_source(AK::URL const&, ByteString const&) override;
|
||||
virtual void did_inspect_dom_tree(ByteString const&) override;
|
||||
virtual void did_inspect_dom_node(bool has_style, ByteString const& computed_style, ByteString const& resolved_style, ByteString const& custom_properties, ByteString const& node_box_sizing, ByteString const& aria_properties_state) override;
|
||||
virtual void did_inspect_accessibility_tree(ByteString const&) override;
|
||||
virtual void did_get_hovered_node_id(i32 node_id) override;
|
||||
virtual void did_finish_editing_dom_node(Optional<i32> const& node_id) override;
|
||||
virtual void did_get_dom_node_html(String const& html) override;
|
||||
virtual void did_take_screenshot(Gfx::ShareableBitmap const& screenshot) override;
|
||||
virtual void did_output_js_console_message(i32 message_index) override;
|
||||
virtual void did_get_js_console_messages(i32 start_index, Vector<ByteString> const& message_types, Vector<ByteString> const& messages) override;
|
||||
virtual void did_change_favicon(Gfx::ShareableBitmap const&) override;
|
||||
virtual void did_request_alert(String const&) override;
|
||||
virtual void did_request_confirm(String const&) override;
|
||||
virtual void did_request_prompt(String const&, String const&) override;
|
||||
virtual void did_request_set_prompt_text(String const& message) override;
|
||||
virtual void did_request_accept_dialog() override;
|
||||
virtual void did_request_dismiss_dialog() override;
|
||||
virtual Messages::WebContentClient::DidRequestAllCookiesResponse did_request_all_cookies(AK::URL const&) override;
|
||||
virtual Messages::WebContentClient::DidRequestNamedCookieResponse did_request_named_cookie(AK::URL const&, String const&) override;
|
||||
virtual Messages::WebContentClient::DidRequestCookieResponse did_request_cookie(AK::URL const&, Web::Cookie::Source) override;
|
||||
virtual void did_set_cookie(AK::URL const&, Web::Cookie::ParsedCookie const&, Web::Cookie::Source) override;
|
||||
virtual void did_update_cookie(Web::Cookie::Cookie const&) override;
|
||||
virtual Messages::WebContentClient::DidRequestNewWebViewResponse did_request_new_web_view(Web::HTML::ActivateTab const&, Web::HTML::WebViewHints const&, Optional<u64> const& page_index) override;
|
||||
virtual void did_request_activate_tab() override;
|
||||
virtual void did_close_browsing_context() override;
|
||||
virtual void did_update_resource_count(i32 count_waiting) override;
|
||||
virtual void did_request_restore_window() override;
|
||||
virtual Messages::WebContentClient::DidRequestRepositionWindowResponse did_request_reposition_window(Gfx::IntPoint) override;
|
||||
virtual Messages::WebContentClient::DidRequestResizeWindowResponse did_request_resize_window(Gfx::IntSize) override;
|
||||
virtual Messages::WebContentClient::DidRequestMaximizeWindowResponse did_request_maximize_window() override;
|
||||
virtual Messages::WebContentClient::DidRequestMinimizeWindowResponse did_request_minimize_window() override;
|
||||
virtual Messages::WebContentClient::DidRequestFullscreenWindowResponse did_request_fullscreen_window() override;
|
||||
virtual void did_request_file(ByteString const& path, i32) override;
|
||||
virtual void did_request_color_picker(Color const& current_color) override;
|
||||
virtual void did_request_select_dropdown(Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> const& items) override;
|
||||
virtual void did_finish_handling_input_event(bool event_was_accepted) override;
|
||||
virtual void did_finish_text_test() override;
|
||||
virtual void did_change_theme_color(Gfx::Color color) override;
|
||||
virtual void did_insert_clipboard_entry(String const& data, String const& presentation_style, String const& mime_type) override;
|
||||
virtual void inspector_did_load() override;
|
||||
virtual void inspector_did_select_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> const& pseudo_element) override;
|
||||
virtual void inspector_did_set_dom_node_text(i32 node_id, String const& text) override;
|
||||
virtual void inspector_did_set_dom_node_tag(i32 node_id, String const& tag) override;
|
||||
virtual void inspector_did_add_dom_node_attributes(i32 node_id, Vector<Attribute> const& attributes) override;
|
||||
virtual void inspector_did_replace_dom_node_attribute(i32 node_id, String const& name, Vector<Attribute> const& replacement_attributes) override;
|
||||
virtual void inspector_did_request_dom_tree_context_menu(i32 node_id, Gfx::IntPoint position, String const& type, Optional<String> const& tag, Optional<Attribute> const& attribute) override;
|
||||
virtual void inspector_did_execute_console_script(String const& script) override;
|
||||
virtual Messages::WebContentClient::RequestWorkerAgentResponse request_worker_agent() override;
|
||||
virtual void did_paint(u64 page_id, Gfx::IntRect const&, i32) override;
|
||||
virtual void did_finish_loading(u64 page_id, AK::URL const&) override;
|
||||
virtual void did_request_navigate_back(u64 page_id) override;
|
||||
virtual void did_request_navigate_forward(u64 page_id) override;
|
||||
virtual void did_request_refresh(u64 page_id) override;
|
||||
virtual void did_request_cursor_change(u64 page_id, i32) override;
|
||||
virtual void did_layout(u64 page_id, Gfx::IntSize) override;
|
||||
virtual void did_change_title(u64 page_id, ByteString const&) override;
|
||||
virtual void did_request_scroll(u64 page_id, i32, i32) override;
|
||||
virtual void did_request_scroll_to(u64 page_id, Gfx::IntPoint) override;
|
||||
virtual void did_enter_tooltip_area(u64 page_id, Gfx::IntPoint, ByteString const&) override;
|
||||
virtual void did_leave_tooltip_area(u64 page_id) override;
|
||||
virtual void did_hover_link(u64 page_id, AK::URL const&) override;
|
||||
virtual void did_unhover_link(u64 page_id) override;
|
||||
virtual void did_click_link(u64 page_id, AK::URL const&, ByteString const&, unsigned) override;
|
||||
virtual void did_middle_click_link(u64 page_id, AK::URL const&, ByteString const&, unsigned) override;
|
||||
virtual void did_start_loading(u64 page_id, AK::URL const&, bool) override;
|
||||
virtual void did_request_context_menu(u64 page_id, Gfx::IntPoint) override;
|
||||
virtual void did_request_link_context_menu(u64 page_id, Gfx::IntPoint, AK::URL const&, ByteString const&, unsigned) override;
|
||||
virtual void did_request_image_context_menu(u64 page_id, Gfx::IntPoint, AK::URL const&, ByteString const&, unsigned, Gfx::ShareableBitmap const&) override;
|
||||
virtual void did_request_media_context_menu(u64 page_id, Gfx::IntPoint, ByteString const&, unsigned, Web::Page::MediaContextMenu const&) override;
|
||||
virtual void did_get_source(u64 page_id, AK::URL const&, ByteString const&) override;
|
||||
virtual void did_inspect_dom_tree(u64 page_id, ByteString const&) override;
|
||||
virtual void did_inspect_dom_node(u64 page_id, bool has_style, ByteString const& computed_style, ByteString const& resolved_style, ByteString const& custom_properties, ByteString const& node_box_sizing, ByteString const& aria_properties_state) override;
|
||||
virtual void did_inspect_accessibility_tree(u64 page_id, ByteString const&) override;
|
||||
virtual void did_get_hovered_node_id(u64 page_id, i32 node_id) override;
|
||||
virtual void did_finish_editing_dom_node(u64 page_id, Optional<i32> const& node_id) override;
|
||||
virtual void did_get_dom_node_html(u64 page_id, String const& html) override;
|
||||
virtual void did_take_screenshot(u64 page_id, Gfx::ShareableBitmap const& screenshot) override;
|
||||
virtual void did_output_js_console_message(u64 page_id, i32 message_index) override;
|
||||
virtual void did_get_js_console_messages(u64 page_id, i32 start_index, Vector<ByteString> const& message_types, Vector<ByteString> const& messages) override;
|
||||
virtual void did_change_favicon(u64 page_id, Gfx::ShareableBitmap const&) override;
|
||||
virtual void did_request_alert(u64 page_id, String const&) override;
|
||||
virtual void did_request_confirm(u64 page_id, String const&) override;
|
||||
virtual void did_request_prompt(u64 page_id, String const&, String const&) override;
|
||||
virtual void did_request_set_prompt_text(u64 page_id, String const& message) override;
|
||||
virtual void did_request_accept_dialog(u64 page_id) override;
|
||||
virtual void did_request_dismiss_dialog(u64 page_id) override;
|
||||
virtual Messages::WebContentClient::DidRequestAllCookiesResponse did_request_all_cookies(u64 page_id, AK::URL const&) override;
|
||||
virtual Messages::WebContentClient::DidRequestNamedCookieResponse did_request_named_cookie(u64 page_id, AK::URL const&, String const&) override;
|
||||
virtual Messages::WebContentClient::DidRequestCookieResponse did_request_cookie(u64 page_id, AK::URL const&, Web::Cookie::Source) override;
|
||||
virtual void did_set_cookie(u64 page_id, AK::URL const&, Web::Cookie::ParsedCookie const&, Web::Cookie::Source) override;
|
||||
virtual void did_update_cookie(u64 page_id, Web::Cookie::Cookie const&) override;
|
||||
virtual Messages::WebContentClient::DidRequestNewWebViewResponse did_request_new_web_view(u64 page_id, Web::HTML::ActivateTab const&, Web::HTML::WebViewHints const&, Optional<u64> const& page_index) override;
|
||||
virtual void did_request_activate_tab(u64 page_id) override;
|
||||
virtual void did_close_browsing_context(u64 page_id) override;
|
||||
virtual void did_update_resource_count(u64 page_id, i32 count_waiting) override;
|
||||
virtual void did_request_restore_window(u64 page_id) override;
|
||||
virtual Messages::WebContentClient::DidRequestRepositionWindowResponse did_request_reposition_window(u64 page_id, Gfx::IntPoint) override;
|
||||
virtual Messages::WebContentClient::DidRequestResizeWindowResponse did_request_resize_window(u64 page_id, Gfx::IntSize) override;
|
||||
virtual Messages::WebContentClient::DidRequestMaximizeWindowResponse did_request_maximize_window(u64 page_id) override;
|
||||
virtual Messages::WebContentClient::DidRequestMinimizeWindowResponse did_request_minimize_window(u64 page_id) override;
|
||||
virtual Messages::WebContentClient::DidRequestFullscreenWindowResponse did_request_fullscreen_window(u64 page_id) override;
|
||||
virtual void did_request_file(u64 page_id, ByteString const& path, i32) override;
|
||||
virtual void did_request_color_picker(u64 page_id, Color const& current_color) override;
|
||||
virtual void did_request_select_dropdown(u64 page_id, Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> const& items) override;
|
||||
virtual void did_finish_handling_input_event(u64 page_id, bool event_was_accepted) override;
|
||||
virtual void did_finish_text_test(u64 page_id) override;
|
||||
virtual void did_change_theme_color(u64 page_id, Gfx::Color color) override;
|
||||
virtual void did_insert_clipboard_entry(u64 page_id, String const& data, String const& presentation_style, String const& mime_type) override;
|
||||
virtual void inspector_did_load(u64 page_id) override;
|
||||
virtual void inspector_did_select_dom_node(u64 page_id, i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> const& pseudo_element) override;
|
||||
virtual void inspector_did_set_dom_node_text(u64 page_id, i32 node_id, String const& text) override;
|
||||
virtual void inspector_did_set_dom_node_tag(u64 page_id, i32 node_id, String const& tag) override;
|
||||
virtual void inspector_did_add_dom_node_attributes(u64 page_id, i32 node_id, Vector<Attribute> const& attributes) override;
|
||||
virtual void inspector_did_replace_dom_node_attribute(u64 page_id, i32 node_id, String const& name, Vector<Attribute> const& replacement_attributes) override;
|
||||
virtual void inspector_did_request_dom_tree_context_menu(u64 page_id, i32 node_id, Gfx::IntPoint position, String const& type, Optional<String> const& tag, Optional<Attribute> const& attribute) override;
|
||||
virtual void inspector_did_execute_console_script(u64 page_id, String const& script) override;
|
||||
virtual Messages::WebContentClient::RequestWorkerAgentResponse request_worker_agent(u64 page_id) override;
|
||||
|
||||
ViewImplementation& m_view;
|
||||
// FIXME: Does a HashMap holding references make sense?
|
||||
HashMap<u64, ViewImplementation*> m_views;
|
||||
};
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,122 +34,104 @@ public:
|
||||
|
||||
virtual void die() override;
|
||||
|
||||
void initialize_js_console(Badge<PageClient>, Web::DOM::Document& document);
|
||||
void destroy_js_console(Badge<PageClient>, Web::DOM::Document& document);
|
||||
|
||||
void request_file(Web::FileRequest);
|
||||
void request_file(u64 page_id, Web::FileRequest);
|
||||
|
||||
Optional<int> fd() { return socket().fd(); }
|
||||
|
||||
PageHost& page_host() { return *m_page_host; }
|
||||
PageHost const& page_host() const { return *m_page_host; }
|
||||
|
||||
auto& backing_stores() { return m_backing_stores; }
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||
|
||||
PageClient& page(u64 index = 0);
|
||||
PageClient const& page(u64 index = 0) const;
|
||||
PageClient& page(u64 index);
|
||||
PageClient const& page(u64 index) const;
|
||||
|
||||
virtual Messages::WebContentServer::GetWindowHandleResponse get_window_handle() override;
|
||||
virtual void set_window_handle(String const& handle) override;
|
||||
virtual void connect_to_webdriver(ByteString const& webdriver_ipc_path) override;
|
||||
virtual void update_system_theme(Core::AnonymousBuffer const&) override;
|
||||
virtual void update_system_fonts(ByteString const&, ByteString const&, ByteString const&) override;
|
||||
virtual void update_screen_rects(Vector<Web::DevicePixelRect> const&, u32) override;
|
||||
virtual void load_url(URL const&) override;
|
||||
virtual void load_html(ByteString const&) override;
|
||||
virtual void set_viewport_rect(Web::DevicePixelRect const&) override;
|
||||
virtual void mouse_down(Web::DevicePixelPoint, Web::DevicePixelPoint, u32, u32, u32) override;
|
||||
virtual void mouse_move(Web::DevicePixelPoint, Web::DevicePixelPoint, u32, u32, u32) override;
|
||||
virtual void mouse_up(Web::DevicePixelPoint, Web::DevicePixelPoint, u32, u32, u32) override;
|
||||
virtual void mouse_wheel(Web::DevicePixelPoint, Web::DevicePixelPoint, u32, u32, u32, Web::DevicePixels, Web::DevicePixels) override;
|
||||
virtual void doubleclick(Web::DevicePixelPoint, Web::DevicePixelPoint, u32, u32, u32) override;
|
||||
virtual void key_down(i32, u32, u32) override;
|
||||
virtual void key_up(i32, u32, u32) override;
|
||||
virtual void add_backing_store(i32 front_bitmap_id, Gfx::ShareableBitmap const& front_bitmap, i32 back_bitmap_id, Gfx::ShareableBitmap const& back_bitmap) override;
|
||||
virtual void ready_to_paint() override;
|
||||
virtual void debug_request(ByteString const&, ByteString const&) override;
|
||||
virtual void get_source() override;
|
||||
virtual void inspect_dom_tree() override;
|
||||
virtual void inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> const& pseudo_element) override;
|
||||
virtual void inspect_accessibility_tree() override;
|
||||
virtual void get_hovered_node_id() override;
|
||||
virtual Messages::WebContentServer::GetWindowHandleResponse get_window_handle(u64 page_id) override;
|
||||
virtual void set_window_handle(u64 page_id, String const& handle) override;
|
||||
virtual void connect_to_webdriver(u64 page_id, ByteString const& webdriver_ipc_path) override;
|
||||
virtual void update_system_theme(u64 page_id, Core::AnonymousBuffer const&) override;
|
||||
virtual void update_system_fonts(u64 page_id, ByteString const&, ByteString const&, ByteString const&) override;
|
||||
virtual void update_screen_rects(u64 page_id, Vector<Web::DevicePixelRect> const&, u32) override;
|
||||
virtual void load_url(u64 page_id, URL const&) override;
|
||||
virtual void load_html(u64 page_id, ByteString const&) override;
|
||||
virtual void set_viewport_rect(u64 page_id, Web::DevicePixelRect const&) override;
|
||||
virtual void mouse_down(u64 page_id, Web::DevicePixelPoint, Web::DevicePixelPoint, u32, u32, u32) override;
|
||||
virtual void mouse_move(u64 page_id, Web::DevicePixelPoint, Web::DevicePixelPoint, u32, u32, u32) override;
|
||||
virtual void mouse_up(u64 page_id, Web::DevicePixelPoint, Web::DevicePixelPoint, u32, u32, u32) override;
|
||||
virtual void mouse_wheel(u64 page_id, Web::DevicePixelPoint, Web::DevicePixelPoint, u32, u32, u32, Web::DevicePixels, Web::DevicePixels) override;
|
||||
virtual void doubleclick(u64 page_id, Web::DevicePixelPoint, Web::DevicePixelPoint, u32, u32, u32) override;
|
||||
virtual void key_down(u64 page_id, i32, u32, u32) override;
|
||||
virtual void key_up(u64 page_id, i32, u32, u32) override;
|
||||
virtual void add_backing_store(u64 page_id, i32 front_bitmap_id, Gfx::ShareableBitmap const& front_bitmap, i32 back_bitmap_id, Gfx::ShareableBitmap const& back_bitmap) override;
|
||||
virtual void ready_to_paint(u64 page_id) override;
|
||||
virtual void debug_request(u64 page_id, ByteString const&, ByteString const&) override;
|
||||
virtual void get_source(u64 page_id) override;
|
||||
virtual void inspect_dom_tree(u64 page_id) override;
|
||||
virtual void inspect_dom_node(u64 page_id, i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> const& pseudo_element) override;
|
||||
virtual void inspect_accessibility_tree(u64 page_id) override;
|
||||
virtual void get_hovered_node_id(u64 page_id) override;
|
||||
|
||||
virtual void set_dom_node_text(i32 node_id, String const& text) override;
|
||||
virtual void set_dom_node_tag(i32 node_id, String const& name) override;
|
||||
virtual void add_dom_node_attributes(i32 node_id, Vector<WebView::Attribute> const& attributes) override;
|
||||
virtual void replace_dom_node_attribute(i32 node_id, String const& name, Vector<WebView::Attribute> const& replacement_attributes) override;
|
||||
virtual void create_child_element(i32 node_id) override;
|
||||
virtual void create_child_text_node(i32 node_id) override;
|
||||
virtual void clone_dom_node(i32 node_id) override;
|
||||
virtual void remove_dom_node(i32 node_id) override;
|
||||
virtual void get_dom_node_html(i32 node_id) override;
|
||||
virtual void set_dom_node_text(u64 page_id, i32 node_id, String const& text) override;
|
||||
virtual void set_dom_node_tag(u64 page_id, i32 node_id, String const& name) override;
|
||||
virtual void add_dom_node_attributes(u64 page_id, i32 node_id, Vector<WebView::Attribute> const& attributes) override;
|
||||
virtual void replace_dom_node_attribute(u64 page_id, i32 node_id, String const& name, Vector<WebView::Attribute> const& replacement_attributes) override;
|
||||
virtual void create_child_element(u64 page_id, i32 node_id) override;
|
||||
virtual void create_child_text_node(u64 page_id, i32 node_id) override;
|
||||
virtual void clone_dom_node(u64 page_id, i32 node_id) override;
|
||||
virtual void remove_dom_node(u64 page_id, i32 node_id) override;
|
||||
virtual void get_dom_node_html(u64 page_id, i32 node_id) override;
|
||||
|
||||
virtual Messages::WebContentServer::DumpLayoutTreeResponse dump_layout_tree() override;
|
||||
virtual Messages::WebContentServer::DumpPaintTreeResponse dump_paint_tree() override;
|
||||
virtual Messages::WebContentServer::DumpTextResponse dump_text() override;
|
||||
virtual void set_content_filters(Vector<String> const&) override;
|
||||
virtual void set_autoplay_allowed_on_all_websites() override;
|
||||
virtual void set_autoplay_allowlist(Vector<String> const& allowlist) override;
|
||||
virtual void set_proxy_mappings(Vector<ByteString> const&, HashMap<ByteString, size_t> const&) override;
|
||||
virtual void set_preferred_color_scheme(Web::CSS::PreferredColorScheme const&) override;
|
||||
virtual void set_has_focus(bool) override;
|
||||
virtual void set_is_scripting_enabled(bool) override;
|
||||
virtual void set_device_pixels_per_css_pixel(float) override;
|
||||
virtual void set_window_position(Web::DevicePixelPoint) override;
|
||||
virtual void set_window_size(Web::DevicePixelSize) override;
|
||||
virtual void handle_file_return(i32 error, Optional<IPC::File> const& file, i32 request_id) override;
|
||||
virtual void set_system_visibility_state(bool visible) override;
|
||||
virtual Messages::WebContentServer::DumpLayoutTreeResponse dump_layout_tree(u64 page_id) override;
|
||||
virtual Messages::WebContentServer::DumpPaintTreeResponse dump_paint_tree(u64 page_id) override;
|
||||
virtual Messages::WebContentServer::DumpTextResponse dump_text(u64 page_id) override;
|
||||
virtual void set_content_filters(u64 page_id, Vector<String> const&) override;
|
||||
virtual void set_autoplay_allowed_on_all_websites(u64 page_id) override;
|
||||
virtual void set_autoplay_allowlist(u64 page_id, Vector<String> const& allowlist) override;
|
||||
virtual void set_proxy_mappings(u64 page_id, Vector<ByteString> const&, HashMap<ByteString, size_t> const&) override;
|
||||
virtual void set_preferred_color_scheme(u64 page_id, Web::CSS::PreferredColorScheme const&) override;
|
||||
virtual void set_has_focus(u64 page_id, bool) override;
|
||||
virtual void set_is_scripting_enabled(u64 page_id, bool) override;
|
||||
virtual void set_device_pixels_per_css_pixel(u64 page_id, float) override;
|
||||
virtual void set_window_position(u64 page_id, Web::DevicePixelPoint) override;
|
||||
virtual void set_window_size(u64 page_id, Web::DevicePixelSize) override;
|
||||
virtual void handle_file_return(u64 page_id, i32 error, Optional<IPC::File> const& file, i32 request_id) override;
|
||||
virtual void set_system_visibility_state(u64 page_id, bool visible) override;
|
||||
|
||||
virtual void js_console_input(ByteString const&) override;
|
||||
virtual void run_javascript(ByteString const&) override;
|
||||
virtual void js_console_request_messages(i32) override;
|
||||
virtual void js_console_input(u64 page_id, ByteString const&) override;
|
||||
virtual void run_javascript(u64 page_id, ByteString const&) override;
|
||||
virtual void js_console_request_messages(u64 page_id, i32) override;
|
||||
|
||||
virtual void alert_closed() override;
|
||||
virtual void confirm_closed(bool accepted) override;
|
||||
virtual void prompt_closed(Optional<String> const& response) override;
|
||||
virtual void color_picker_update(Optional<Color> const& picked_color, Web::HTML::ColorPickerUpdateState const& state) override;
|
||||
virtual void select_dropdown_closed(Optional<String> const& value) override;
|
||||
virtual void alert_closed(u64 page_id) override;
|
||||
virtual void confirm_closed(u64 page_id, bool accepted) override;
|
||||
virtual void prompt_closed(u64 page_id, Optional<String> const& response) override;
|
||||
virtual void color_picker_update(u64 page_id, Optional<Color> const& picked_color, Web::HTML::ColorPickerUpdateState const& state) override;
|
||||
virtual void select_dropdown_closed(u64 page_id, Optional<String> const& value) override;
|
||||
|
||||
virtual void toggle_media_play_state() override;
|
||||
virtual void toggle_media_mute_state() override;
|
||||
virtual void toggle_media_loop_state() override;
|
||||
virtual void toggle_media_controls_state() override;
|
||||
virtual void toggle_media_play_state(u64 page_id) override;
|
||||
virtual void toggle_media_mute_state(u64 page_id) override;
|
||||
virtual void toggle_media_loop_state(u64 page_id) override;
|
||||
virtual void toggle_media_controls_state(u64 page_id) override;
|
||||
|
||||
virtual void set_user_style(String const&) override;
|
||||
virtual void set_user_style(u64 page_id, String const&) override;
|
||||
|
||||
virtual void enable_inspector_prototype() override;
|
||||
virtual void enable_inspector_prototype(u64 page_id) override;
|
||||
|
||||
virtual void take_document_screenshot() override;
|
||||
virtual void take_dom_node_screenshot(i32 node_id) override;
|
||||
virtual void take_document_screenshot(u64 page_id) override;
|
||||
virtual void take_dom_node_screenshot(u64 page_id, i32 node_id) override;
|
||||
|
||||
virtual Messages::WebContentServer::DumpGcGraphResponse dump_gc_graph() override;
|
||||
virtual Messages::WebContentServer::DumpGcGraphResponse dump_gc_graph(u64 page_id) override;
|
||||
|
||||
virtual Messages::WebContentServer::GetLocalStorageEntriesResponse get_local_storage_entries() override;
|
||||
virtual Messages::WebContentServer::GetSessionStorageEntriesResponse get_session_storage_entries() override;
|
||||
virtual Messages::WebContentServer::GetLocalStorageEntriesResponse get_local_storage_entries(u64 page_id) override;
|
||||
virtual Messages::WebContentServer::GetSessionStorageEntriesResponse get_session_storage_entries(u64 page_id) override;
|
||||
|
||||
virtual Messages::WebContentServer::GetSelectedTextResponse get_selected_text() override;
|
||||
virtual void select_all() override;
|
||||
virtual Messages::WebContentServer::GetSelectedTextResponse get_selected_text(u64 page_id) override;
|
||||
virtual void select_all(u64 page_id) override;
|
||||
|
||||
void report_finished_handling_input_event(bool event_was_handled);
|
||||
void report_finished_handling_input_event(u64 page_id, bool event_was_handled);
|
||||
|
||||
NonnullOwnPtr<PageHost> m_page_host;
|
||||
|
||||
struct BackingStores {
|
||||
i32 front_bitmap_id { -1 };
|
||||
i32 back_bitmap_id { -1 };
|
||||
RefPtr<Gfx::Bitmap> front_bitmap;
|
||||
RefPtr<Gfx::Bitmap> back_bitmap;
|
||||
};
|
||||
BackingStores m_backing_stores;
|
||||
|
||||
HashMap<Web::DOM::Document*, NonnullOwnPtr<WebContentConsoleClient>> m_console_clients;
|
||||
WeakPtr<WebContentConsoleClient> m_top_level_document_console_client;
|
||||
|
||||
JS::Handle<JS::GlobalObject> m_console_global_object;
|
||||
|
||||
HashMap<int, Web::FileRequest> m_requested_files {};
|
||||
int last_id { 0 };
|
||||
|
||||
@ -170,6 +152,7 @@ private:
|
||||
Web::DevicePixels wheel_delta_x {};
|
||||
Web::DevicePixels wheel_delta_y {};
|
||||
size_t coalesced_event_count { 0 };
|
||||
u64 page_id { 0 };
|
||||
};
|
||||
|
||||
struct QueuedKeyboardEvent {
|
||||
@ -181,6 +164,7 @@ private:
|
||||
i32 key {};
|
||||
u32 modifiers {};
|
||||
u32 code_point {};
|
||||
u64 page_id { 0 };
|
||||
};
|
||||
|
||||
void enqueue_input_event(Variant<QueuedMouseEvent, QueuedKeyboardEvent>);
|
||||
|
@ -8,12 +8,15 @@
|
||||
|
||||
#include <LibGfx/ShareableBitmap.h>
|
||||
#include <LibGfx/SystemTheme.h>
|
||||
#include <LibJS/Console.h>
|
||||
#include <LibJS/Runtime/ConsoleObject.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/CSS/SystemColor.h>
|
||||
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||
#include <LibWeb/DOM/Attr.h>
|
||||
#include <LibWeb/DOM/NamedNodeMap.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
||||
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
@ -54,20 +57,20 @@ PageClient::PageClient(PageHost& owner, u64 id)
|
||||
setup_palette();
|
||||
|
||||
m_repaint_timer = Web::Platform::Timer::create_single_shot(0, [this] {
|
||||
if (!client().backing_stores().back_bitmap) {
|
||||
if (!m_backing_stores.back_bitmap) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& back_bitmap = *client().backing_stores().back_bitmap;
|
||||
auto& back_bitmap = *m_backing_stores.back_bitmap;
|
||||
auto viewport_rect = page().css_to_device_rect(page().top_level_traversable()->viewport_rect());
|
||||
paint(viewport_rect, back_bitmap);
|
||||
|
||||
auto& backing_stores = client().backing_stores();
|
||||
auto& backing_stores = m_backing_stores;
|
||||
swap(backing_stores.front_bitmap, backing_stores.back_bitmap);
|
||||
swap(backing_stores.front_bitmap_id, backing_stores.back_bitmap_id);
|
||||
|
||||
m_paint_state = PaintState::WaitingForClient;
|
||||
client().async_did_paint(viewport_rect.to_type<int>(), backing_stores.front_bitmap_id);
|
||||
client().async_did_paint(m_id, viewport_rect.to_type<int>(), backing_stores.front_bitmap_id);
|
||||
});
|
||||
|
||||
#ifdef HAS_ACCELERATED_GRAPHICS
|
||||
@ -101,6 +104,14 @@ void PageClient::ready_to_paint()
|
||||
schedule_repaint();
|
||||
}
|
||||
|
||||
void PageClient::add_backing_store(i32 front_bitmap_id, Gfx::ShareableBitmap const& front_bitmap, i32 back_bitmap_id, Gfx::ShareableBitmap const& back_bitmap)
|
||||
{
|
||||
m_backing_stores.front_bitmap_id = front_bitmap_id;
|
||||
m_backing_stores.back_bitmap_id = back_bitmap_id;
|
||||
m_backing_stores.front_bitmap = *const_cast<Gfx::ShareableBitmap&>(front_bitmap).bitmap();
|
||||
m_backing_stores.back_bitmap = *const_cast<Gfx::ShareableBitmap&>(back_bitmap).bitmap();
|
||||
}
|
||||
|
||||
void PageClient::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
@ -220,7 +231,7 @@ void PageClient::page_did_invalidate(Web::CSSPixelRect const&)
|
||||
|
||||
void PageClient::page_did_request_cursor_change(Gfx::StandardCursor cursor)
|
||||
{
|
||||
client().async_did_request_cursor_change((u32)cursor);
|
||||
client().async_did_request_cursor_change(m_id, (u32)cursor);
|
||||
}
|
||||
|
||||
void PageClient::page_did_layout()
|
||||
@ -231,62 +242,62 @@ void PageClient::page_did_layout()
|
||||
m_content_size = page().enclosing_device_rect(layout_root->paintable_box()->scrollable_overflow_rect().value()).size();
|
||||
else
|
||||
m_content_size = page().enclosing_device_rect(layout_root->paintable_box()->absolute_rect()).size();
|
||||
client().async_did_layout(m_content_size.to_type<int>());
|
||||
client().async_did_layout(m_id, m_content_size.to_type<int>());
|
||||
}
|
||||
|
||||
void PageClient::page_did_change_title(ByteString const& title)
|
||||
{
|
||||
client().async_did_change_title(title);
|
||||
client().async_did_change_title(m_id, title);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_navigate_back()
|
||||
{
|
||||
client().async_did_request_navigate_back();
|
||||
client().async_did_request_navigate_back(m_id);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_navigate_forward()
|
||||
{
|
||||
client().async_did_request_navigate_forward();
|
||||
client().async_did_request_navigate_forward(m_id);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_refresh()
|
||||
{
|
||||
client().async_did_request_refresh();
|
||||
client().async_did_request_refresh(m_id);
|
||||
}
|
||||
|
||||
Gfx::IntSize PageClient::page_did_request_resize_window(Gfx::IntSize size)
|
||||
{
|
||||
return client().did_request_resize_window(size);
|
||||
return client().did_request_resize_window(m_id, size);
|
||||
}
|
||||
|
||||
Gfx::IntPoint PageClient::page_did_request_reposition_window(Gfx::IntPoint position)
|
||||
{
|
||||
return client().did_request_reposition_window(position);
|
||||
return client().did_request_reposition_window(m_id, position);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_restore_window()
|
||||
{
|
||||
client().async_did_request_restore_window();
|
||||
client().async_did_request_restore_window(m_id);
|
||||
}
|
||||
|
||||
Gfx::IntRect PageClient::page_did_request_maximize_window()
|
||||
{
|
||||
return client().did_request_maximize_window();
|
||||
return client().did_request_maximize_window(m_id);
|
||||
}
|
||||
|
||||
Gfx::IntRect PageClient::page_did_request_minimize_window()
|
||||
{
|
||||
return client().did_request_minimize_window();
|
||||
return client().did_request_minimize_window(m_id);
|
||||
}
|
||||
|
||||
Gfx::IntRect PageClient::page_did_request_fullscreen_window()
|
||||
{
|
||||
return client().did_request_fullscreen_window();
|
||||
return client().did_request_fullscreen_window(m_id);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_scroll(i32 x_delta, i32 y_delta)
|
||||
{
|
||||
client().async_did_request_scroll(x_delta, y_delta);
|
||||
client().async_did_request_scroll(m_id, x_delta, y_delta);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_scroll_to(Web::CSSPixelPoint scroll_position)
|
||||
@ -299,83 +310,83 @@ void PageClient::page_did_request_scroll_to(Web::CSSPixelPoint scroll_position)
|
||||
page().top_level_traversable()->set_viewport_rect(viewport);
|
||||
|
||||
auto device_scroll_position = page().css_to_device_point(scroll_position);
|
||||
client().async_did_request_scroll_to(device_scroll_position.to_type<int>());
|
||||
client().async_did_request_scroll_to(m_id, device_scroll_position.to_type<int>());
|
||||
}
|
||||
|
||||
void PageClient::page_did_enter_tooltip_area(Web::CSSPixelPoint content_position, ByteString const& title)
|
||||
{
|
||||
client().async_did_enter_tooltip_area({ content_position.x().to_int(), content_position.y().to_int() }, title);
|
||||
client().async_did_enter_tooltip_area(m_id, { content_position.x().to_int(), content_position.y().to_int() }, title);
|
||||
}
|
||||
|
||||
void PageClient::page_did_leave_tooltip_area()
|
||||
{
|
||||
client().async_did_leave_tooltip_area();
|
||||
client().async_did_leave_tooltip_area(m_id);
|
||||
}
|
||||
|
||||
void PageClient::page_did_hover_link(const URL& url)
|
||||
{
|
||||
client().async_did_hover_link(url);
|
||||
client().async_did_hover_link(m_id, url);
|
||||
}
|
||||
|
||||
void PageClient::page_did_unhover_link()
|
||||
{
|
||||
client().async_did_unhover_link();
|
||||
client().async_did_unhover_link(m_id);
|
||||
}
|
||||
|
||||
void PageClient::page_did_middle_click_link(const URL& url, [[maybe_unused]] ByteString const& target, [[maybe_unused]] unsigned modifiers)
|
||||
{
|
||||
client().async_did_middle_click_link(url, target, modifiers);
|
||||
client().async_did_middle_click_link(m_id, url, target, modifiers);
|
||||
}
|
||||
|
||||
void PageClient::page_did_start_loading(const URL& url, bool is_redirect)
|
||||
{
|
||||
client().async_did_start_loading(url, is_redirect);
|
||||
client().async_did_start_loading(m_id, url, is_redirect);
|
||||
}
|
||||
|
||||
void PageClient::page_did_create_new_document(Web::DOM::Document& document)
|
||||
{
|
||||
client().initialize_js_console({}, document);
|
||||
initialize_js_console(document);
|
||||
}
|
||||
|
||||
void PageClient::page_did_destroy_document(Web::DOM::Document& document)
|
||||
{
|
||||
client().destroy_js_console({}, document);
|
||||
destroy_js_console(document);
|
||||
}
|
||||
|
||||
void PageClient::page_did_finish_loading(const URL& url)
|
||||
{
|
||||
client().async_did_finish_loading(url);
|
||||
client().async_did_finish_loading(m_id, url);
|
||||
}
|
||||
|
||||
void PageClient::page_did_finish_text_test()
|
||||
{
|
||||
client().async_did_finish_text_test();
|
||||
client().async_did_finish_text_test(m_id);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_context_menu(Web::CSSPixelPoint content_position)
|
||||
{
|
||||
client().async_did_request_context_menu(page().css_to_device_point(content_position).to_type<int>());
|
||||
client().async_did_request_context_menu(m_id, page().css_to_device_point(content_position).to_type<int>());
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_link_context_menu(Web::CSSPixelPoint content_position, URL const& url, ByteString const& target, unsigned modifiers)
|
||||
{
|
||||
client().async_did_request_link_context_menu(page().css_to_device_point(content_position).to_type<int>(), url, target, modifiers);
|
||||
client().async_did_request_link_context_menu(m_id, page().css_to_device_point(content_position).to_type<int>(), url, target, modifiers);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_image_context_menu(Web::CSSPixelPoint content_position, URL const& url, ByteString const& target, unsigned modifiers, Gfx::Bitmap const* bitmap_pointer)
|
||||
{
|
||||
auto bitmap = bitmap_pointer ? bitmap_pointer->to_shareable_bitmap() : Gfx::ShareableBitmap();
|
||||
client().async_did_request_image_context_menu(page().css_to_device_point(content_position).to_type<int>(), url, target, modifiers, bitmap);
|
||||
client().async_did_request_image_context_menu(m_id, page().css_to_device_point(content_position).to_type<int>(), url, target, modifiers, bitmap);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_media_context_menu(Web::CSSPixelPoint content_position, ByteString const& target, unsigned modifiers, Web::Page::MediaContextMenu menu)
|
||||
{
|
||||
client().async_did_request_media_context_menu(page().css_to_device_point(content_position).to_type<int>(), target, modifiers, move(menu));
|
||||
client().async_did_request_media_context_menu(m_id, page().css_to_device_point(content_position).to_type<int>(), target, modifiers, move(menu));
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_alert(String const& message)
|
||||
{
|
||||
client().async_did_request_alert(message);
|
||||
client().async_did_request_alert(m_id, message);
|
||||
}
|
||||
|
||||
void PageClient::alert_closed()
|
||||
@ -385,7 +396,7 @@ void PageClient::alert_closed()
|
||||
|
||||
void PageClient::page_did_request_confirm(String const& message)
|
||||
{
|
||||
client().async_did_request_confirm(message);
|
||||
client().async_did_request_confirm(m_id, message);
|
||||
}
|
||||
|
||||
void PageClient::confirm_closed(bool accepted)
|
||||
@ -395,12 +406,12 @@ void PageClient::confirm_closed(bool accepted)
|
||||
|
||||
void PageClient::page_did_request_prompt(String const& message, String const& default_)
|
||||
{
|
||||
client().async_did_request_prompt(message, default_);
|
||||
client().async_did_request_prompt(m_id, message, default_);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_set_prompt_text(String const& text)
|
||||
{
|
||||
client().async_did_request_set_prompt_text(text);
|
||||
client().async_did_request_set_prompt_text(m_id, text);
|
||||
}
|
||||
|
||||
void PageClient::prompt_closed(Optional<String> response)
|
||||
@ -445,32 +456,32 @@ void PageClient::set_user_style(String source)
|
||||
|
||||
void PageClient::page_did_request_accept_dialog()
|
||||
{
|
||||
client().async_did_request_accept_dialog();
|
||||
client().async_did_request_accept_dialog(m_id);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_dismiss_dialog()
|
||||
{
|
||||
client().async_did_request_dismiss_dialog();
|
||||
client().async_did_request_dismiss_dialog(m_id);
|
||||
}
|
||||
|
||||
void PageClient::page_did_change_favicon(Gfx::Bitmap const& favicon)
|
||||
{
|
||||
client().async_did_change_favicon(favicon.to_shareable_bitmap());
|
||||
client().async_did_change_favicon(m_id, favicon.to_shareable_bitmap());
|
||||
}
|
||||
|
||||
Vector<Web::Cookie::Cookie> PageClient::page_did_request_all_cookies(URL const& url)
|
||||
{
|
||||
return client().did_request_all_cookies(url);
|
||||
return client().did_request_all_cookies(m_id, url);
|
||||
}
|
||||
|
||||
Optional<Web::Cookie::Cookie> PageClient::page_did_request_named_cookie(URL const& url, String const& name)
|
||||
{
|
||||
return client().did_request_named_cookie(url, name);
|
||||
return client().did_request_named_cookie(m_id, url, name);
|
||||
}
|
||||
|
||||
String PageClient::page_did_request_cookie(const URL& url, Web::Cookie::Source source)
|
||||
{
|
||||
auto response = client().send_sync_but_allow_failure<Messages::WebContentClient::DidRequestCookie>(move(url), source);
|
||||
auto response = client().send_sync_but_allow_failure<Messages::WebContentClient::DidRequestCookie>(m_id, move(url), source);
|
||||
if (!response) {
|
||||
dbgln("WebContent client disconnected during DidRequestCookie. Exiting peacefully.");
|
||||
exit(0);
|
||||
@ -480,7 +491,7 @@ String PageClient::page_did_request_cookie(const URL& url, Web::Cookie::Source s
|
||||
|
||||
void PageClient::page_did_set_cookie(const URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source)
|
||||
{
|
||||
auto response = client().send_sync_but_allow_failure<Messages::WebContentClient::DidSetCookie>(url, cookie, source);
|
||||
auto response = client().send_sync_but_allow_failure<Messages::WebContentClient::DidSetCookie>(m_id, url, cookie, source);
|
||||
if (!response) {
|
||||
dbgln("WebContent client disconnected during DidSetCookie. Exiting peacefully.");
|
||||
exit(0);
|
||||
@ -489,12 +500,12 @@ void PageClient::page_did_set_cookie(const URL& url, Web::Cookie::ParsedCookie c
|
||||
|
||||
void PageClient::page_did_update_cookie(Web::Cookie::Cookie cookie)
|
||||
{
|
||||
client().async_did_update_cookie(move(cookie));
|
||||
client().async_did_update_cookie(m_id, move(cookie));
|
||||
}
|
||||
|
||||
void PageClient::page_did_update_resource_count(i32 count_waiting)
|
||||
{
|
||||
client().async_did_update_resource_count(count_waiting);
|
||||
client().async_did_update_resource_count(m_id, count_waiting);
|
||||
}
|
||||
|
||||
PageClient::NewWebViewResult PageClient::page_did_request_new_web_view(Web::HTML::ActivateTab activate_tab, Web::HTML::WebViewHints hints, Web::HTML::TokenizedFeature::NoOpener no_opener)
|
||||
@ -509,7 +520,7 @@ PageClient::NewWebViewResult PageClient::page_did_request_new_web_view(Web::HTML
|
||||
|
||||
page_id = new_client.m_id;
|
||||
|
||||
auto response = client().send_sync_but_allow_failure<Messages::WebContentClient::DidRequestNewWebView>(activate_tab, hints, page_id);
|
||||
auto response = client().send_sync_but_allow_failure<Messages::WebContentClient::DidRequestNewWebView>(m_id, activate_tab, hints, page_id);
|
||||
if (!response) {
|
||||
dbgln("WebContent client disconnected during DidRequestNewWebView. Exiting peacefully.");
|
||||
exit(0);
|
||||
@ -520,42 +531,47 @@ PageClient::NewWebViewResult PageClient::page_did_request_new_web_view(Web::HTML
|
||||
|
||||
void PageClient::page_did_request_activate_tab()
|
||||
{
|
||||
client().async_did_request_activate_tab();
|
||||
client().async_did_request_activate_tab(m_id);
|
||||
}
|
||||
|
||||
void PageClient::page_did_close_browsing_context(Web::HTML::BrowsingContext const&)
|
||||
void PageClient::page_did_close_top_level_traversable()
|
||||
{
|
||||
client().async_did_close_browsing_context();
|
||||
// FIXME: Rename this IPC call
|
||||
client().async_did_close_browsing_context(m_id);
|
||||
|
||||
// NOTE: This only removes the strong reference the PageHost has for this PageClient.
|
||||
// It will be GC'd 'later'.
|
||||
m_owner.remove_page({}, m_id);
|
||||
}
|
||||
|
||||
void PageClient::request_file(Web::FileRequest file_request)
|
||||
{
|
||||
client().request_file(move(file_request));
|
||||
client().request_file(m_id, move(file_request));
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_color_picker(Color current_color)
|
||||
{
|
||||
client().async_did_request_color_picker(current_color);
|
||||
client().async_did_request_color_picker(m_id, current_color);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_select_dropdown(Web::CSSPixelPoint content_position, Web::CSSPixels minimum_width, Vector<Web::HTML::SelectItem> items)
|
||||
{
|
||||
client().async_did_request_select_dropdown(page().css_to_device_point(content_position).to_type<int>(), minimum_width * device_pixels_per_css_pixel(), items);
|
||||
client().async_did_request_select_dropdown(m_id, page().css_to_device_point(content_position).to_type<int>(), minimum_width * device_pixels_per_css_pixel(), items);
|
||||
}
|
||||
|
||||
void PageClient::page_did_change_theme_color(Gfx::Color color)
|
||||
{
|
||||
client().async_did_change_theme_color(color);
|
||||
client().async_did_change_theme_color(m_id, color);
|
||||
}
|
||||
|
||||
void PageClient::page_did_insert_clipboard_entry(String data, String presentation_style, String mime_type)
|
||||
{
|
||||
client().async_did_insert_clipboard_entry(move(data), move(presentation_style), move(mime_type));
|
||||
client().async_did_insert_clipboard_entry(m_id, move(data), move(presentation_style), move(mime_type));
|
||||
}
|
||||
|
||||
WebView::SocketPair PageClient::request_worker_agent()
|
||||
{
|
||||
auto response = client().send_sync_but_allow_failure<Messages::WebContentClient::RequestWorkerAgent>();
|
||||
auto response = client().send_sync_but_allow_failure<Messages::WebContentClient::RequestWorkerAgent>(m_id);
|
||||
if (!response) {
|
||||
dbgln("WebContent client disconnected during RequestWorkerAgent. Exiting peacefully.");
|
||||
exit(0);
|
||||
@ -566,22 +582,22 @@ WebView::SocketPair PageClient::request_worker_agent()
|
||||
|
||||
void PageClient::inspector_did_load()
|
||||
{
|
||||
client().async_inspector_did_load();
|
||||
client().async_inspector_did_load(m_id);
|
||||
}
|
||||
|
||||
void PageClient::inspector_did_select_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> const& pseudo_element)
|
||||
{
|
||||
client().async_inspector_did_select_dom_node(node_id, pseudo_element);
|
||||
client().async_inspector_did_select_dom_node(m_id, node_id, pseudo_element);
|
||||
}
|
||||
|
||||
void PageClient::inspector_did_set_dom_node_text(i32 node_id, String const& text)
|
||||
{
|
||||
client().async_inspector_did_set_dom_node_text(node_id, text);
|
||||
client().async_inspector_did_set_dom_node_text(m_id, node_id, text);
|
||||
}
|
||||
|
||||
void PageClient::inspector_did_set_dom_node_tag(i32 node_id, String const& tag)
|
||||
{
|
||||
client().async_inspector_did_set_dom_node_tag(node_id, tag);
|
||||
client().async_inspector_did_set_dom_node_tag(m_id, node_id, tag);
|
||||
}
|
||||
|
||||
static Vector<WebView::Attribute> named_node_map_to_vector(JS::NonnullGCPtr<Web::DOM::NamedNodeMap> map)
|
||||
@ -601,12 +617,12 @@ static Vector<WebView::Attribute> named_node_map_to_vector(JS::NonnullGCPtr<Web:
|
||||
|
||||
void PageClient::inspector_did_add_dom_node_attributes(i32 node_id, JS::NonnullGCPtr<Web::DOM::NamedNodeMap> attributes)
|
||||
{
|
||||
client().async_inspector_did_add_dom_node_attributes(node_id, named_node_map_to_vector(attributes));
|
||||
client().async_inspector_did_add_dom_node_attributes(m_id, node_id, named_node_map_to_vector(attributes));
|
||||
}
|
||||
|
||||
void PageClient::inspector_did_replace_dom_node_attribute(i32 node_id, String const& name, JS::NonnullGCPtr<Web::DOM::NamedNodeMap> replacement_attributes)
|
||||
{
|
||||
client().async_inspector_did_replace_dom_node_attribute(node_id, name, named_node_map_to_vector(replacement_attributes));
|
||||
client().async_inspector_did_replace_dom_node_attribute(m_id, node_id, name, named_node_map_to_vector(replacement_attributes));
|
||||
}
|
||||
|
||||
void PageClient::inspector_did_request_dom_tree_context_menu(i32 node_id, Web::CSSPixelPoint position, String const& type, Optional<String> const& tag, Optional<String> const& attribute_name, Optional<String> const& attribute_value)
|
||||
@ -615,12 +631,12 @@ void PageClient::inspector_did_request_dom_tree_context_menu(i32 node_id, Web::C
|
||||
if (attribute_name.has_value() && attribute_value.has_value())
|
||||
attribute = WebView::Attribute { *attribute_name, *attribute_value };
|
||||
|
||||
client().async_inspector_did_request_dom_tree_context_menu(node_id, page().css_to_device_point(position).to_type<int>(), type, tag, move(attribute));
|
||||
client().async_inspector_did_request_dom_tree_context_menu(m_id, node_id, page().css_to_device_point(position).to_type<int>(), type, tag, move(attribute));
|
||||
}
|
||||
|
||||
void PageClient::inspector_did_execute_console_script(String const& script)
|
||||
{
|
||||
client().async_inspector_did_execute_console_script(script);
|
||||
client().async_inspector_did_execute_console_script(m_id, script);
|
||||
}
|
||||
|
||||
ErrorOr<void> PageClient::connect_to_webdriver(ByteString const& webdriver_ipc_path)
|
||||
@ -634,4 +650,78 @@ ErrorOr<void> PageClient::connect_to_webdriver(ByteString const& webdriver_ipc_p
|
||||
return {};
|
||||
}
|
||||
|
||||
void PageClient::initialize_js_console(Web::DOM::Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
auto console_object = realm.intrinsics().console_object();
|
||||
auto console_client = make<WebContentConsoleClient>(console_object->console(), document.realm(), *this);
|
||||
console_object->console().set_client(*console_client);
|
||||
|
||||
VERIFY(document.browsing_context());
|
||||
if (document.browsing_context()->is_top_level()) {
|
||||
m_top_level_document_console_client = console_client->make_weak_ptr();
|
||||
}
|
||||
|
||||
m_console_clients.set(&document, move(console_client));
|
||||
}
|
||||
|
||||
void PageClient::destroy_js_console(Web::DOM::Document& document)
|
||||
{
|
||||
m_console_clients.remove(&document);
|
||||
}
|
||||
|
||||
void PageClient::js_console_input(ByteString const& js_source)
|
||||
{
|
||||
if (m_top_level_document_console_client)
|
||||
m_top_level_document_console_client->handle_input(js_source);
|
||||
}
|
||||
|
||||
void PageClient::run_javascript(ByteString const& js_source)
|
||||
{
|
||||
auto* active_document = page().top_level_browsing_context().active_document();
|
||||
|
||||
if (!active_document)
|
||||
return;
|
||||
|
||||
// This is partially based on "execute a javascript: URL request" https://html.spec.whatwg.org/multipage/browsing-the-web.html#javascript-protocol
|
||||
|
||||
// Let settings be browsingContext's active document's relevant settings object.
|
||||
auto& settings = active_document->relevant_settings_object();
|
||||
|
||||
// Let baseURL be settings's API base URL.
|
||||
auto base_url = settings.api_base_url();
|
||||
|
||||
// Let script be the result of creating a classic script given scriptSource, settings, baseURL, and the default classic script fetch options.
|
||||
// FIXME: This doesn't pass in "default classic script fetch options"
|
||||
// FIXME: What should the filename be here?
|
||||
auto script = Web::HTML::ClassicScript::create("(client connection run_javascript)", js_source, settings, move(base_url));
|
||||
|
||||
// Let evaluationStatus be the result of running the classic script script.
|
||||
auto evaluation_status = script->run();
|
||||
|
||||
if (evaluation_status.is_error())
|
||||
dbgln("Exception :(");
|
||||
}
|
||||
|
||||
void PageClient::js_console_request_messages(i32 start_index)
|
||||
{
|
||||
if (m_top_level_document_console_client)
|
||||
m_top_level_document_console_client->send_messages(start_index);
|
||||
}
|
||||
|
||||
void PageClient::did_output_js_console_message(i32 message_index)
|
||||
{
|
||||
client().async_did_output_js_console_message(m_id, message_index);
|
||||
}
|
||||
|
||||
void PageClient::console_peer_did_misbehave(char const* reason)
|
||||
{
|
||||
client().did_misbehave(reason);
|
||||
}
|
||||
|
||||
void PageClient::did_get_js_console_messages(i32 start_index, Vector<ByteString> message_types, Vector<ByteString> messages)
|
||||
{
|
||||
client().async_did_get_js_console_messages(m_id, start_index, move(message_types), move(messages));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -65,6 +65,17 @@ public:
|
||||
|
||||
void ready_to_paint();
|
||||
|
||||
void add_backing_store(i32 front_bitmap_id, Gfx::ShareableBitmap const& front_bitmap, i32 back_bitmap_id, Gfx::ShareableBitmap const& back_bitmap);
|
||||
|
||||
void initialize_js_console(Web::DOM::Document& document);
|
||||
void destroy_js_console(Web::DOM::Document& document);
|
||||
void js_console_input(ByteString const& js_source);
|
||||
void run_javascript(ByteString const& js_source);
|
||||
void js_console_request_messages(i32 start_index);
|
||||
void did_output_js_console_message(i32 message_index);
|
||||
void console_peer_did_misbehave(char const* reason);
|
||||
void did_get_js_console_messages(i32 start_index, Vector<ByteString> message_types, Vector<ByteString> messages);
|
||||
|
||||
virtual double device_pixels_per_css_pixel() const override { return m_device_pixels_per_css_pixel; }
|
||||
|
||||
private:
|
||||
@ -120,7 +131,7 @@ private:
|
||||
virtual void page_did_update_resource_count(i32) override;
|
||||
virtual NewWebViewResult page_did_request_new_web_view(Web::HTML::ActivateTab, Web::HTML::WebViewHints, Web::HTML::TokenizedFeature::NoOpener) override;
|
||||
virtual void page_did_request_activate_tab() override;
|
||||
virtual void page_did_close_browsing_context(Web::HTML::BrowsingContext const&) override;
|
||||
virtual void page_did_close_top_level_traversable() override;
|
||||
virtual void request_file(Web::FileRequest) override;
|
||||
virtual void page_did_request_color_picker(Color current_color) override;
|
||||
virtual void page_did_request_select_dropdown(Web::CSSPixelPoint content_position, Web::CSSPixels minimum_width, Vector<Web::HTML::SelectItem> items) override;
|
||||
@ -167,6 +178,19 @@ private:
|
||||
#ifdef HAS_ACCELERATED_GRAPHICS
|
||||
OwnPtr<AccelGfx::Context> m_accelerated_graphics_context;
|
||||
#endif
|
||||
|
||||
struct BackingStores {
|
||||
i32 front_bitmap_id { -1 };
|
||||
i32 back_bitmap_id { -1 };
|
||||
RefPtr<Gfx::Bitmap> front_bitmap;
|
||||
RefPtr<Gfx::Bitmap> back_bitmap;
|
||||
};
|
||||
BackingStores m_backing_stores;
|
||||
|
||||
HashMap<Web::DOM::Document*, NonnullOwnPtr<WebContentConsoleClient>> m_console_clients;
|
||||
WeakPtr<WebContentConsoleClient> m_top_level_document_console_client;
|
||||
|
||||
JS::Handle<JS::GlobalObject> m_console_global_object;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,11 @@ PageClient& PageHost::create_page()
|
||||
return *m_pages.get(m_next_id - 1).value();
|
||||
}
|
||||
|
||||
void PageHost::remove_page(Badge<PageClient>, u64 index)
|
||||
{
|
||||
m_pages.remove(index);
|
||||
}
|
||||
|
||||
PageHost::~PageHost() = default;
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
|
||||
PageClient& page(u64 index) { return *m_pages.find(index)->value; }
|
||||
PageClient& create_page();
|
||||
void remove_page(Badge<PageClient>, u64 index);
|
||||
|
||||
ConnectionFromClient& client() const { return m_client; }
|
||||
|
||||
|
@ -14,81 +14,81 @@
|
||||
|
||||
endpoint WebContentClient
|
||||
{
|
||||
did_start_loading(URL url, bool is_redirect) =|
|
||||
did_finish_loading(URL url) =|
|
||||
did_request_navigate_back() =|
|
||||
did_request_navigate_forward() =|
|
||||
did_request_refresh() =|
|
||||
did_paint(Gfx::IntRect content_rect, i32 bitmap_id) =|
|
||||
did_request_cursor_change(i32 cursor_type) =|
|
||||
did_layout(Gfx::IntSize content_size) =|
|
||||
did_change_title(ByteString title) =|
|
||||
did_request_scroll(i32 x_delta, i32 y_delta) =|
|
||||
did_request_scroll_to(Gfx::IntPoint scroll_position) =|
|
||||
did_enter_tooltip_area(Gfx::IntPoint content_position, ByteString title) =|
|
||||
did_leave_tooltip_area() =|
|
||||
did_hover_link(URL url) =|
|
||||
did_unhover_link() =|
|
||||
did_click_link(URL url, ByteString target, unsigned modifiers) =|
|
||||
did_middle_click_link(URL url, ByteString target, unsigned modifiers) =|
|
||||
did_request_context_menu(Gfx::IntPoint content_position) =|
|
||||
did_request_link_context_menu(Gfx::IntPoint content_position, URL url, ByteString target, unsigned modifiers) =|
|
||||
did_request_image_context_menu(Gfx::IntPoint content_position, URL url, ByteString target, unsigned modifiers, Gfx::ShareableBitmap bitmap) =|
|
||||
did_request_media_context_menu(Gfx::IntPoint content_position, ByteString target, unsigned modifiers, Web::Page::MediaContextMenu menu) =|
|
||||
did_request_alert(String message) =|
|
||||
did_request_confirm(String message) =|
|
||||
did_request_prompt(String message, String default_) =|
|
||||
did_request_set_prompt_text(String message) =|
|
||||
did_request_accept_dialog() =|
|
||||
did_request_dismiss_dialog() =|
|
||||
did_get_source(URL url, ByteString source) =|
|
||||
did_start_loading(u64 page_id, URL url, bool is_redirect) =|
|
||||
did_finish_loading(u64 page_id, URL url) =|
|
||||
did_request_navigate_back(u64 page_id) =|
|
||||
did_request_navigate_forward(u64 page_id) =|
|
||||
did_request_refresh(u64 page_id) =|
|
||||
did_paint(u64 page_id, Gfx::IntRect content_rect, i32 bitmap_id) =|
|
||||
did_request_cursor_change(u64 page_id, i32 cursor_type) =|
|
||||
did_layout(u64 page_id, Gfx::IntSize content_size) =|
|
||||
did_change_title(u64 page_id, ByteString title) =|
|
||||
did_request_scroll(u64 page_id, i32 x_delta, i32 y_delta) =|
|
||||
did_request_scroll_to(u64 page_id, Gfx::IntPoint scroll_position) =|
|
||||
did_enter_tooltip_area(u64 page_id, Gfx::IntPoint content_position, ByteString title) =|
|
||||
did_leave_tooltip_area(u64 page_id) =|
|
||||
did_hover_link(u64 page_id, URL url) =|
|
||||
did_unhover_link(u64 page_id) =|
|
||||
did_click_link(u64 page_id, URL url, ByteString target, unsigned modifiers) =|
|
||||
did_middle_click_link(u64 page_id, URL url, ByteString target, unsigned modifiers) =|
|
||||
did_request_context_menu(u64 page_id, Gfx::IntPoint content_position) =|
|
||||
did_request_link_context_menu(u64 page_id, Gfx::IntPoint content_position, URL url, ByteString target, unsigned modifiers) =|
|
||||
did_request_image_context_menu(u64 page_id, Gfx::IntPoint content_position, URL url, ByteString target, unsigned modifiers, Gfx::ShareableBitmap bitmap) =|
|
||||
did_request_media_context_menu(u64 page_id, Gfx::IntPoint content_position, ByteString target, unsigned modifiers, Web::Page::MediaContextMenu menu) =|
|
||||
did_request_alert(u64 page_id, String message) =|
|
||||
did_request_confirm(u64 page_id, String message) =|
|
||||
did_request_prompt(u64 page_id, String message, String default_) =|
|
||||
did_request_set_prompt_text(u64 page_id, String message) =|
|
||||
did_request_accept_dialog(u64 page_id) =|
|
||||
did_request_dismiss_dialog(u64 page_id) =|
|
||||
did_get_source(u64 page_id, URL url, ByteString source) =|
|
||||
|
||||
did_inspect_dom_tree(ByteString dom_tree) =|
|
||||
did_inspect_dom_node(bool has_style, ByteString computed_style, ByteString resolved_style, ByteString custom_properties, ByteString node_box_sizing, ByteString aria_properties_state) =|
|
||||
did_inspect_accessibility_tree(ByteString accessibility_tree) =|
|
||||
did_get_hovered_node_id(i32 node_id) =|
|
||||
did_finish_editing_dom_node(Optional<i32> node_id) =|
|
||||
did_get_dom_node_html(String html) =|
|
||||
did_inspect_dom_tree(u64 page_id, ByteString dom_tree) =|
|
||||
did_inspect_dom_node(u64 page_id, bool has_style, ByteString computed_style, ByteString resolved_style, ByteString custom_properties, ByteString node_box_sizing, ByteString aria_properties_state) =|
|
||||
did_inspect_accessibility_tree(u64 page_id, ByteString accessibility_tree) =|
|
||||
did_get_hovered_node_id(u64 page_id, i32 node_id) =|
|
||||
did_finish_editing_dom_node(u64 page_id, Optional<i32> node_id) =|
|
||||
did_get_dom_node_html(u64 page_id, String html) =|
|
||||
|
||||
did_take_screenshot(Gfx::ShareableBitmap screenshot) =|
|
||||
did_take_screenshot(u64 page_id, Gfx::ShareableBitmap screenshot) =|
|
||||
|
||||
did_change_favicon(Gfx::ShareableBitmap favicon) =|
|
||||
did_request_all_cookies(URL url) => (Vector<Web::Cookie::Cookie> cookies)
|
||||
did_request_named_cookie(URL url, String name) => (Optional<Web::Cookie::Cookie> cookie)
|
||||
did_request_cookie(URL url, Web::Cookie::Source source) => (String cookie)
|
||||
did_set_cookie(URL url, Web::Cookie::ParsedCookie cookie, Web::Cookie::Source source) => ()
|
||||
did_update_cookie(Web::Cookie::Cookie cookie) =|
|
||||
did_update_resource_count(i32 count_waiting) =|
|
||||
did_request_new_web_view(Web::HTML::ActivateTab activate_tab, Web::HTML::WebViewHints hints, Optional<u64> page_index) => (String handle)
|
||||
did_request_activate_tab() =|
|
||||
did_close_browsing_context() =|
|
||||
did_request_restore_window() =|
|
||||
did_request_reposition_window(Gfx::IntPoint position) => (Gfx::IntPoint window_position)
|
||||
did_request_resize_window(Gfx::IntSize size) => (Gfx::IntSize window_size)
|
||||
did_request_maximize_window() => (Gfx::IntRect window_rect)
|
||||
did_request_minimize_window() => (Gfx::IntRect window_rect)
|
||||
did_request_fullscreen_window() => (Gfx::IntRect window_rect)
|
||||
did_request_file(ByteString path, i32 request_id) =|
|
||||
did_request_color_picker(Color current_color) =|
|
||||
did_request_select_dropdown(Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> items) =|
|
||||
did_finish_handling_input_event(bool event_was_accepted) =|
|
||||
did_change_theme_color(Gfx::Color color) =|
|
||||
did_insert_clipboard_entry(String data, String presentation_style, String mime_type) =|
|
||||
did_change_favicon(u64 page_id, Gfx::ShareableBitmap favicon) =|
|
||||
did_request_all_cookies(u64 page_id, URL url) => (Vector<Web::Cookie::Cookie> cookies)
|
||||
did_request_named_cookie(u64 page_id, URL url, String name) => (Optional<Web::Cookie::Cookie> cookie)
|
||||
did_request_cookie(u64 page_id, URL url, Web::Cookie::Source source) => (String cookie)
|
||||
did_set_cookie(u64 page_id, URL url, Web::Cookie::ParsedCookie cookie, Web::Cookie::Source source) => ()
|
||||
did_update_cookie(u64 page_id, Web::Cookie::Cookie cookie) =|
|
||||
did_update_resource_count(u64 page_id, i32 count_waiting) =|
|
||||
did_request_new_web_view(u64 page_id, Web::HTML::ActivateTab activate_tab, Web::HTML::WebViewHints hints, Optional<u64> page_index) => (String handle)
|
||||
did_request_activate_tab(u64 page_id) =|
|
||||
did_close_browsing_context(u64 page_id) =|
|
||||
did_request_restore_window(u64 page_id) =|
|
||||
did_request_reposition_window(u64 page_id, Gfx::IntPoint position) => (Gfx::IntPoint window_position)
|
||||
did_request_resize_window(u64 page_id, Gfx::IntSize size) => (Gfx::IntSize window_size)
|
||||
did_request_maximize_window(u64 page_id) => (Gfx::IntRect window_rect)
|
||||
did_request_minimize_window(u64 page_id) => (Gfx::IntRect window_rect)
|
||||
did_request_fullscreen_window(u64 page_id) => (Gfx::IntRect window_rect)
|
||||
did_request_file(u64 page_id, ByteString path, i32 request_id) =|
|
||||
did_request_color_picker(u64 page_id, Color current_color) =|
|
||||
did_request_select_dropdown(u64 page_id, Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> items) =|
|
||||
did_finish_handling_input_event(u64 page_id, bool event_was_accepted) =|
|
||||
did_change_theme_color(u64 page_id, Gfx::Color color) =|
|
||||
did_insert_clipboard_entry(u64 page_id, String data, String presentation_style, String mime_type) =|
|
||||
|
||||
did_output_js_console_message(i32 message_index) =|
|
||||
did_get_js_console_messages(i32 start_index, Vector<ByteString> message_types, Vector<ByteString> messages) =|
|
||||
did_output_js_console_message(u64 page_id, i32 message_index) =|
|
||||
did_get_js_console_messages(u64 page_id, i32 start_index, Vector<ByteString> message_types, Vector<ByteString> messages) =|
|
||||
|
||||
did_finish_text_test() =|
|
||||
did_finish_text_test(u64 page_id) =|
|
||||
|
||||
request_worker_agent() => (WebView::SocketPair sockets) // FIXME: Add required attributes to select a SharedWorker Agent
|
||||
request_worker_agent(u64 page_id) => (WebView::SocketPair sockets) // FIXME: Add required attributes to select a SharedWorker Agent
|
||||
|
||||
inspector_did_load() =|
|
||||
inspector_did_select_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element) =|
|
||||
inspector_did_set_dom_node_text(i32 node_id, String text) =|
|
||||
inspector_did_set_dom_node_tag(i32 node_id, String tag) =|
|
||||
inspector_did_add_dom_node_attributes(i32 node_id, Vector<WebView::Attribute> attributes) =|
|
||||
inspector_did_replace_dom_node_attribute(i32 node_id, String name, Vector<WebView::Attribute> replacement_attributes) =|
|
||||
inspector_did_request_dom_tree_context_menu(i32 node_id, Gfx::IntPoint position, String type, Optional<String> tag, Optional<WebView::Attribute> attribute) =|
|
||||
inspector_did_execute_console_script(String script) =|
|
||||
inspector_did_load(u64 page_id) =|
|
||||
inspector_did_select_dom_node(u64 page_id, i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element) =|
|
||||
inspector_did_set_dom_node_text(u64 page_id, i32 node_id, String text) =|
|
||||
inspector_did_set_dom_node_tag(u64 page_id, i32 node_id, String tag) =|
|
||||
inspector_did_add_dom_node_attributes(u64 page_id, i32 node_id, Vector<WebView::Attribute> attributes) =|
|
||||
inspector_did_replace_dom_node_attribute(u64 page_id, i32 node_id, String name, Vector<WebView::Attribute> replacement_attributes) =|
|
||||
inspector_did_request_dom_tree_context_menu(u64 page_id, i32 node_id, Gfx::IntPoint position, String type, Optional<String> tag, Optional<WebView::Attribute> attribute) =|
|
||||
inspector_did_execute_console_script(u64 page_id, String script) =|
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "WebContentConsoleClient.h"
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/TemporaryChange.h>
|
||||
#include <LibJS/MarkupGenerator.h>
|
||||
@ -20,10 +19,12 @@
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <WebContent/ConsoleGlobalEnvironmentExtensions.h>
|
||||
#include <WebContent/PageClient.h>
|
||||
#include <WebContent/WebContentConsoleClient.h>
|
||||
|
||||
namespace WebContent {
|
||||
|
||||
WebContentConsoleClient::WebContentConsoleClient(JS::Console& console, JS::Realm& realm, ConnectionFromClient& client)
|
||||
WebContentConsoleClient::WebContentConsoleClient(JS::Console& console, JS::Realm& realm, PageClient& client)
|
||||
: ConsoleClient(console)
|
||||
, m_client(client)
|
||||
{
|
||||
@ -58,25 +59,25 @@ void WebContentConsoleClient::report_exception(JS::Error const& exception, bool
|
||||
void WebContentConsoleClient::print_html(ByteString const& line)
|
||||
{
|
||||
m_message_log.append({ .type = ConsoleOutput::Type::HTML, .data = line });
|
||||
m_client.async_did_output_js_console_message(m_message_log.size() - 1);
|
||||
m_client.did_output_js_console_message(m_message_log.size() - 1);
|
||||
}
|
||||
|
||||
void WebContentConsoleClient::clear_output()
|
||||
{
|
||||
m_message_log.append({ .type = ConsoleOutput::Type::Clear, .data = "" });
|
||||
m_client.async_did_output_js_console_message(m_message_log.size() - 1);
|
||||
m_client.did_output_js_console_message(m_message_log.size() - 1);
|
||||
}
|
||||
|
||||
void WebContentConsoleClient::begin_group(ByteString const& label, bool start_expanded)
|
||||
{
|
||||
m_message_log.append({ .type = start_expanded ? ConsoleOutput::Type::BeginGroup : ConsoleOutput::Type::BeginGroupCollapsed, .data = label });
|
||||
m_client.async_did_output_js_console_message(m_message_log.size() - 1);
|
||||
m_client.did_output_js_console_message(m_message_log.size() - 1);
|
||||
}
|
||||
|
||||
void WebContentConsoleClient::end_group()
|
||||
{
|
||||
m_message_log.append({ .type = ConsoleOutput::Type::EndGroup, .data = "" });
|
||||
m_client.async_did_output_js_console_message(m_message_log.size() - 1);
|
||||
m_client.did_output_js_console_message(m_message_log.size() - 1);
|
||||
}
|
||||
|
||||
void WebContentConsoleClient::send_messages(i32 start_index)
|
||||
@ -88,7 +89,7 @@ void WebContentConsoleClient::send_messages(i32 start_index)
|
||||
// then, by requesting with start_index=0. If we don't have any messages at all, that
|
||||
// is still a valid request, and we can just ignore it.
|
||||
if (start_index != 0)
|
||||
m_client.did_misbehave("Requested non-existent console message index.");
|
||||
m_client.console_peer_did_misbehave("Requested non-existent console message index.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -121,7 +122,7 @@ void WebContentConsoleClient::send_messages(i32 start_index)
|
||||
messages.append(message.data);
|
||||
}
|
||||
|
||||
m_client.async_did_get_js_console_messages(start_index, message_types, messages);
|
||||
m_client.did_get_js_console_messages(start_index, message_types, messages);
|
||||
}
|
||||
|
||||
void WebContentConsoleClient::clear()
|
||||
|
@ -8,10 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ConnectionFromClient.h"
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibJS/Console.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <WebContent/ConsoleGlobalEnvironmentExtensions.h>
|
||||
#include <WebContent/Forward.h>
|
||||
|
||||
namespace WebContent {
|
||||
@ -19,7 +21,7 @@ namespace WebContent {
|
||||
class WebContentConsoleClient final : public JS::ConsoleClient
|
||||
, public Weakable<WebContentConsoleClient> {
|
||||
public:
|
||||
WebContentConsoleClient(JS::Console&, JS::Realm&, ConnectionFromClient&);
|
||||
WebContentConsoleClient(JS::Console&, JS::Realm&, PageClient&);
|
||||
|
||||
void handle_input(ByteString const& js_source);
|
||||
void send_messages(i32 start_index);
|
||||
@ -35,7 +37,7 @@ private:
|
||||
m_current_message_style.append(';');
|
||||
}
|
||||
|
||||
ConnectionFromClient& m_client;
|
||||
PageClient& m_client;
|
||||
JS::Handle<ConsoleGlobalEnvironmentExtensions> m_console_global_environment_extensions;
|
||||
|
||||
void clear_output();
|
||||
|
@ -11,96 +11,96 @@
|
||||
|
||||
endpoint WebContentServer
|
||||
{
|
||||
get_window_handle() => (String handle)
|
||||
set_window_handle(String handle) =|
|
||||
get_window_handle(u64 page_id) => (String handle)
|
||||
set_window_handle(u64 page_id, String handle) =|
|
||||
|
||||
connect_to_webdriver(ByteString webdriver_ipc_path) =|
|
||||
connect_to_webdriver(u64 page_id, ByteString webdriver_ipc_path) =|
|
||||
|
||||
update_system_theme(Core::AnonymousBuffer theme_buffer) =|
|
||||
update_system_fonts(ByteString default_font_query, ByteString fixed_width_font_query, ByteString window_title_font_query) =|
|
||||
update_screen_rects(Vector<Web::DevicePixelRect> rects, u32 main_screen_index) =|
|
||||
update_system_theme(u64 page_id, Core::AnonymousBuffer theme_buffer) =|
|
||||
update_system_fonts(u64 page_id, ByteString default_font_query, ByteString fixed_width_font_query, ByteString window_title_font_query) =|
|
||||
update_screen_rects(u64 page_id, Vector<Web::DevicePixelRect> rects, u32 main_screen_index) =|
|
||||
|
||||
load_url(URL url) =|
|
||||
load_html(ByteString html) =|
|
||||
load_url(u64 page_id, URL url) =|
|
||||
load_html(u64 page_id, ByteString html) =|
|
||||
|
||||
add_backing_store(i32 front_bitmap_id, Gfx::ShareableBitmap front_bitmap, i32 back_bitmap_id, Gfx::ShareableBitmap back_bitmap) =|
|
||||
ready_to_paint() =|
|
||||
add_backing_store(u64 page_id, i32 front_bitmap_id, Gfx::ShareableBitmap front_bitmap, i32 back_bitmap_id, Gfx::ShareableBitmap back_bitmap) =|
|
||||
ready_to_paint(u64 page_id) =|
|
||||
|
||||
set_viewport_rect(Web::DevicePixelRect rect) =|
|
||||
set_viewport_rect(u64 page_id, Web::DevicePixelRect rect) =|
|
||||
|
||||
mouse_down(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, u32 button, u32 buttons, u32 modifiers) =|
|
||||
mouse_move(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, u32 button, u32 buttons, u32 modifiers) =|
|
||||
mouse_up(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, u32 button, u32 buttons, u32 modifiers) =|
|
||||
mouse_wheel(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, u32 button, u32 buttons, u32 modifiers, Web::DevicePixels wheel_delta_x, Web::DevicePixels wheel_delta_y) =|
|
||||
doubleclick(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, u32 button, u32 buttons, u32 modifiers) =|
|
||||
mouse_down(u64 page_id, Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, u32 button, u32 buttons, u32 modifiers) =|
|
||||
mouse_move(u64 page_id, Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, u32 button, u32 buttons, u32 modifiers) =|
|
||||
mouse_up(u64 page_id, Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, u32 button, u32 buttons, u32 modifiers) =|
|
||||
mouse_wheel(u64 page_id, Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, u32 button, u32 buttons, u32 modifiers, Web::DevicePixels wheel_delta_x, Web::DevicePixels wheel_delta_y) =|
|
||||
doubleclick(u64 page_id, Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, u32 button, u32 buttons, u32 modifiers) =|
|
||||
|
||||
key_down(i32 key, u32 modifiers, u32 code_point) =|
|
||||
key_up(i32 key, u32 modifiers, u32 code_point) =|
|
||||
key_down(u64 page_id, i32 key, u32 modifiers, u32 code_point) =|
|
||||
key_up(u64 page_id, i32 key, u32 modifiers, u32 code_point) =|
|
||||
|
||||
debug_request(ByteString request, ByteString argument) =|
|
||||
get_source() =|
|
||||
inspect_dom_tree() =|
|
||||
inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element) =|
|
||||
inspect_accessibility_tree() =|
|
||||
get_hovered_node_id() =|
|
||||
js_console_input(ByteString js_source) =|
|
||||
js_console_request_messages(i32 start_index) =|
|
||||
debug_request(u64 page_id, ByteString request, ByteString argument) =|
|
||||
get_source(u64 page_id) =|
|
||||
inspect_dom_tree(u64 page_id) =|
|
||||
inspect_dom_node(u64 page_id, i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element) =|
|
||||
inspect_accessibility_tree(u64 page_id) =|
|
||||
get_hovered_node_id(u64 page_id) =|
|
||||
js_console_input(u64 page_id, ByteString js_source) =|
|
||||
js_console_request_messages(u64 page_id, i32 start_index) =|
|
||||
|
||||
set_dom_node_text(i32 node_id, String text) =|
|
||||
set_dom_node_tag(i32 node_id, String name) =|
|
||||
add_dom_node_attributes(i32 node_id, Vector<WebView::Attribute> attributes) =|
|
||||
replace_dom_node_attribute(i32 node_id, String name, Vector<WebView::Attribute> replacement_attributes) =|
|
||||
create_child_element(i32 node_id) =|
|
||||
create_child_text_node(i32 node_id) =|
|
||||
clone_dom_node(i32 node_id) =|
|
||||
remove_dom_node(i32 node_id) =|
|
||||
get_dom_node_html(i32 node_id) =|
|
||||
set_dom_node_text(u64 page_id, i32 node_id, String text) =|
|
||||
set_dom_node_tag(u64 page_id, i32 node_id, String name) =|
|
||||
add_dom_node_attributes(u64 page_id, i32 node_id, Vector<WebView::Attribute> attributes) =|
|
||||
replace_dom_node_attribute(u64 page_id, i32 node_id, String name, Vector<WebView::Attribute> replacement_attributes) =|
|
||||
create_child_element(u64 page_id, i32 node_id) =|
|
||||
create_child_text_node(u64 page_id, i32 node_id) =|
|
||||
clone_dom_node(u64 page_id, i32 node_id) =|
|
||||
remove_dom_node(u64 page_id, i32 node_id) =|
|
||||
get_dom_node_html(u64 page_id, i32 node_id) =|
|
||||
|
||||
take_document_screenshot() =|
|
||||
take_dom_node_screenshot(i32 node_id) =|
|
||||
take_document_screenshot(u64 page_id) =|
|
||||
take_dom_node_screenshot(u64 page_id, i32 node_id) =|
|
||||
|
||||
dump_gc_graph() => (String json)
|
||||
dump_gc_graph(u64 page_id) => (String json)
|
||||
|
||||
run_javascript(ByteString js_source) =|
|
||||
run_javascript(u64 page_id, ByteString js_source) =|
|
||||
|
||||
dump_layout_tree() => (ByteString dump)
|
||||
dump_paint_tree() => (ByteString dump)
|
||||
dump_text() => (ByteString dump)
|
||||
dump_layout_tree(u64 page_id) => (ByteString dump)
|
||||
dump_paint_tree(u64 page_id) => (ByteString dump)
|
||||
dump_text(u64 page_id) => (ByteString dump)
|
||||
|
||||
get_selected_text() => (ByteString selection)
|
||||
select_all() =|
|
||||
get_selected_text(u64 page_id) => (ByteString selection)
|
||||
select_all(u64 page_id) =|
|
||||
|
||||
set_content_filters(Vector<String> filters) =|
|
||||
set_autoplay_allowed_on_all_websites() =|
|
||||
set_autoplay_allowlist(Vector<String> allowlist) =|
|
||||
set_proxy_mappings(Vector<ByteString> proxies, HashMap<ByteString,size_t> mappings) =|
|
||||
set_preferred_color_scheme(Web::CSS::PreferredColorScheme color_scheme) =|
|
||||
set_has_focus(bool has_focus) =|
|
||||
set_is_scripting_enabled(bool is_scripting_enabled) =|
|
||||
set_device_pixels_per_css_pixel(float device_pixels_per_css_pixel) =|
|
||||
set_content_filters(u64 page_id, Vector<String> filters) =|
|
||||
set_autoplay_allowed_on_all_websites(u64 page_id) =|
|
||||
set_autoplay_allowlist(u64 page_id, Vector<String> allowlist) =|
|
||||
set_proxy_mappings(u64 page_id, Vector<ByteString> proxies, HashMap<ByteString,size_t> mappings) =|
|
||||
set_preferred_color_scheme(u64 page_id, Web::CSS::PreferredColorScheme color_scheme) =|
|
||||
set_has_focus(u64 page_id, bool has_focus) =|
|
||||
set_is_scripting_enabled(u64 page_id, bool is_scripting_enabled) =|
|
||||
set_device_pixels_per_css_pixel(u64 page_id, float device_pixels_per_css_pixel) =|
|
||||
|
||||
set_window_position(Web::DevicePixelPoint position) =|
|
||||
set_window_size(Web::DevicePixelSize size) =|
|
||||
set_window_position(u64 page_id, Web::DevicePixelPoint position) =|
|
||||
set_window_size(u64 page_id, Web::DevicePixelSize size) =|
|
||||
|
||||
get_local_storage_entries() => (OrderedHashMap<String,String> entries)
|
||||
get_session_storage_entries() => (OrderedHashMap<String,String> entries)
|
||||
get_local_storage_entries(u64 page_id) => (OrderedHashMap<String,String> entries)
|
||||
get_session_storage_entries(u64 page_id) => (OrderedHashMap<String,String> entries)
|
||||
|
||||
handle_file_return(i32 error, Optional<IPC::File> file, i32 request_id) =|
|
||||
handle_file_return(u64 page_id, i32 error, Optional<IPC::File> file, i32 request_id) =|
|
||||
|
||||
set_system_visibility_state(bool visible) =|
|
||||
set_system_visibility_state(u64 page_id, bool visible) =|
|
||||
|
||||
alert_closed() =|
|
||||
confirm_closed(bool accepted) =|
|
||||
prompt_closed(Optional<String> response) =|
|
||||
color_picker_update(Optional<Color> picked_color, Web::HTML::ColorPickerUpdateState state) =|
|
||||
select_dropdown_closed(Optional<String> value) =|
|
||||
alert_closed(u64 page_id) =|
|
||||
confirm_closed(u64 page_id, bool accepted) =|
|
||||
prompt_closed(u64 page_id, Optional<String> response) =|
|
||||
color_picker_update(u64 page_id, Optional<Color> picked_color, Web::HTML::ColorPickerUpdateState state) =|
|
||||
select_dropdown_closed(u64 page_id, Optional<String> value) =|
|
||||
|
||||
toggle_media_play_state() =|
|
||||
toggle_media_mute_state() =|
|
||||
toggle_media_loop_state() =|
|
||||
toggle_media_controls_state() =|
|
||||
toggle_media_play_state(u64 page_id) =|
|
||||
toggle_media_mute_state(u64 page_id) =|
|
||||
toggle_media_loop_state(u64 page_id) =|
|
||||
toggle_media_controls_state(u64 page_id) =|
|
||||
|
||||
set_user_style(String source) =|
|
||||
set_user_style(u64 page_id, String source) =|
|
||||
|
||||
enable_inspector_prototype() =|
|
||||
enable_inspector_prototype(u64 page_id) =|
|
||||
}
|
||||
|
@ -90,15 +90,15 @@ public:
|
||||
view->m_client_state.client = TRY(launch_web_content_process(*view, candidate_web_content_paths, web_content_options));
|
||||
#endif
|
||||
|
||||
view->client().async_update_system_theme(move(theme));
|
||||
view->client().async_update_system_fonts(Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query(), Gfx::FontDatabase::window_title_font_query());
|
||||
view->client().async_update_system_theme(0, move(theme));
|
||||
view->client().async_update_system_fonts(0, Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query(), Gfx::FontDatabase::window_title_font_query());
|
||||
|
||||
view->m_viewport_rect = { { 0, 0 }, window_size };
|
||||
view->client().async_set_viewport_rect(view->m_viewport_rect.to_type<Web::DevicePixels>());
|
||||
view->client().async_set_window_size(window_size.to_type<Web::DevicePixels>());
|
||||
view->client().async_set_viewport_rect(0, view->m_viewport_rect.to_type<Web::DevicePixels>());
|
||||
view->client().async_set_window_size(0, window_size.to_type<Web::DevicePixels>());
|
||||
|
||||
if (!web_driver_ipc_path.is_empty())
|
||||
view->client().async_connect_to_webdriver(web_driver_ipc_path);
|
||||
view->client().async_connect_to_webdriver(0, web_driver_ipc_path);
|
||||
|
||||
view->m_client_state.client->on_web_content_process_crash = [] {
|
||||
warnln("\033[31;1mWebContent Crashed!!\033[0m");
|
||||
@ -116,7 +116,7 @@ public:
|
||||
VERIFY(!m_pending_screenshot);
|
||||
|
||||
m_pending_screenshot = Core::Promise<RefPtr<Gfx::Bitmap>>::construct();
|
||||
client().async_take_document_screenshot();
|
||||
client().async_take_document_screenshot(0);
|
||||
|
||||
auto screenshot = MUST(m_pending_screenshot->await());
|
||||
m_pending_screenshot = nullptr;
|
||||
@ -132,22 +132,22 @@ public:
|
||||
|
||||
ErrorOr<String> dump_layout_tree()
|
||||
{
|
||||
return String::from_byte_string(client().dump_layout_tree());
|
||||
return String::from_byte_string(client().dump_layout_tree(0));
|
||||
}
|
||||
|
||||
ErrorOr<String> dump_paint_tree()
|
||||
{
|
||||
return String::from_byte_string(client().dump_paint_tree());
|
||||
return String::from_byte_string(client().dump_paint_tree(0));
|
||||
}
|
||||
|
||||
ErrorOr<String> dump_text()
|
||||
{
|
||||
return String::from_byte_string(client().dump_text());
|
||||
return String::from_byte_string(client().dump_text(0));
|
||||
}
|
||||
|
||||
void clear_content_filters()
|
||||
{
|
||||
client().async_set_content_filters({});
|
||||
client().async_set_content_filters(0, {});
|
||||
}
|
||||
|
||||
private:
|
||||
@ -157,7 +157,7 @@ private:
|
||||
{
|
||||
on_scroll_to_point = [this](auto position) {
|
||||
m_viewport_rect.set_location(position);
|
||||
client().async_set_viewport_rect(m_viewport_rect.to_type<Web::DevicePixels>());
|
||||
client().async_set_viewport_rect(0, m_viewport_rect.to_type<Web::DevicePixels>());
|
||||
};
|
||||
|
||||
on_scroll_by_delta = [this](auto x_delta, auto y_delta) {
|
||||
|
Loading…
Reference in New Issue
Block a user