Skip to content

Truly independent web browser

Hub+UI/Qt: Put a RemoteView between Qt and a tab's view

Andreas Kling3dc064e96e39
diff --git a/Services/CMakeLists.txt b/Services/CMakeLists.txt
index 50d932929ba..0b93a50f176 100644
--- a/Services/CMakeLists.txt
+++ b/Services/CMakeLists.txt
@@ -1,5 +1,6 @@
add_subdirectory(AudioServer)
add_subdirectory(Compositor)
+add_subdirectory(Hub)
add_subdirectory(ImageDecoder)
add_subdirectory(MediaServer)
if (APPLE)
diff --git a/Services/Hub/CMakeLists.txt b/Services/Hub/CMakeLists.txt
new file mode 100644
index 00000000000..c839476dba6
--- /dev/null
+++ b/Services/Hub/CMakeLists.txt
@@ -0,0 +1,14 @@
+set(CMAKE_AUTOMOC OFF)
+set(CMAKE_AUTORCC OFF)
+set(CMAKE_AUTOUIC OFF)
+
+set(SOURCES
+ View.cpp
+)
+
+add_library(hubservice STATIC ${SOURCES})
+
+target_include_directories(hubservice PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../..)
+target_include_directories(hubservice PRIVATE ${LADYBIRD_SOURCE_DIR}/Services/)
+
+target_link_libraries(hubservice PRIVATE LibCore LibGfx LibIPC LibURL LibWebView)
diff --git a/Services/Hub/View.cpp b/Services/Hub/View.cpp
new file mode 100644
index 00000000000..813cb8e4d98
--- /dev/null
+++ b/Services/Hub/View.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <Hub/View.h>
+
+namespace Hub {
+
+View::View(ViewHost& host, InitialState initial_state)
+ : ViewImplementation(initial_state.is_private)
+ , m_host(&host)
+{
+ m_device_pixel_ratio = initial_state.device_pixel_ratio;
+ m_maximum_frames_per_second = initial_state.maximum_frames_per_second;
+ m_display_id = initial_state.display_id;
+}
+
+void View::prepare_page_for_navigable(WebView::WebContentPage& page)
+{
+ ViewImplementation::prepare_page_for_navigable(page);
+
+ update_compositor_display_metadata(page);
+}
+
+Core::AnonymousBuffer View::system_theme()
+{
+ return m_host ? m_host->system_theme() : Core::AnonymousBuffer {};
+}
+
+Optional<View::ScreenRects> View::screen_rects() const
+{
+ return m_host ? m_host->screen_rects() : Optional<ScreenRects> {};
+}
+
+void View::update_zoom()
+{
+ ViewImplementation::update_zoom();
+ if (m_host)
+ m_host->update_zoom();
+}
+
+Web::DevicePixelSize View::viewport_size() const
+{
+ return m_host ? m_host->viewport_size() : Web::DevicePixelSize {};
+}
+
+void View::show_context_menu(WebView::Menu& menu, Gfx::IntPoint widget_position)
+{
+ if (m_host)
+ m_host->show_context_menu(menu, widget_position);
+}
+
+void View::did_accept_presented_backing_store(i32 bitmap_id, Gfx::IntRect damage_rect)
+{
+ if (m_host)
+ m_host->did_accept_presented_backing_store(bitmap_id, damage_rect);
+}
+
+void View::release_backing_store(i32 bitmap_id)
+{
+ if (m_host)
+ m_host->release_backing_store(bitmap_id);
+ else
+ ViewImplementation::release_backing_store(bitmap_id);
+}
+
+}
diff --git a/Services/Hub/View.h b/Services/Hub/View.h
new file mode 100644
index 00000000000..9661c727191
--- /dev/null
+++ b/Services/Hub/View.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibWebView/ViewImplementation.h>
+
+namespace Hub {
+
+// What a view needs from the UI that shows it.
+class ViewHost {
+public:
+ virtual ~ViewHost() = default;
+
+ virtual Core::AnonymousBuffer system_theme() = 0;
+ virtual Optional<WebView::ViewImplementation::ScreenRects> screen_rects() const = 0;
+ virtual Web::DevicePixelSize viewport_size() const = 0;
+ virtual void update_zoom() = 0;
+ virtual void show_context_menu(WebView::Menu&, Gfx::IntPoint widget_position) = 0;
+ virtual void did_accept_presented_backing_store(i32 bitmap_id, Gfx::IntRect damage_rect) = 0;
+ virtual void release_backing_store(i32 bitmap_id) = 0;
+};
+
+// A tab's view. It holds the tab's pages and everything else about them, and leaves showing them to its ViewHost.
+class View final : public WebView::ViewImplementation {
+public:
+ AK_ALLOC_WITH_KMALLOC;
+
+ struct InitialState {
+ WebView::IsPrivate is_private { WebView::IsPrivate::No };
+ double device_pixel_ratio { 1.0 };
+ double maximum_frames_per_second { 60.0 };
+ Optional<u64> display_id;
+ };
+
+ View(ViewHost&, InitialState);
+
+ ViewHost* host() const { return m_host; }
+
+ // The host is going away, and takes no more calls.
+ void detach_from_host() { m_host = nullptr; }
+
+ void set_device_pixel_ratio(double device_pixel_ratio) { m_device_pixel_ratio = device_pixel_ratio; }
+ bool scales_frames_to_fit() const { return m_scales_frames_to_fit; }
+ void release_backing_store_to_page(i32 bitmap_id) { ViewImplementation::release_backing_store(bitmap_id); }
+
+ using ViewImplementation::handle_resize;
+ using ViewImplementation::initialize_tab;
+ using ViewImplementation::microphone_authorizer;
+ using ViewImplementation::rect_fitting_frame;
+ using ViewImplementation::set_owner_view;
+ using ViewImplementation::set_page_background_color_to_system_canvas;
+
+private:
+ // ^WebView::ViewImplementation
+ virtual void prepare_page_for_navigable(WebView::WebContentPage&) override;
+ virtual Core::AnonymousBuffer system_theme() override;
+ virtual Optional<ScreenRects> screen_rects() const override;
+ virtual void update_zoom() override;
+ virtual Web::DevicePixelSize viewport_size() const override;
+ virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override { return widget_position; }
+ virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override { return content_position; }
+ virtual void show_context_menu(WebView::Menu&, Gfx::IntPoint widget_position) override;
+ virtual void did_accept_presented_backing_store(i32 bitmap_id, Gfx::IntRect damage_rect) override;
+ virtual void release_backing_store(i32 bitmap_id) override;
+
+ ViewHost* m_host { nullptr };
+};
+
+}
diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt
index fc47d8adead..5d5e25d5dca 100644
--- a/UI/CMakeLists.txt
+++ b/UI/CMakeLists.txt
@@ -111,7 +111,7 @@ else()
set(LADYBIRD_TARGET ladybird PRIVATE)
endif()
-set(LADYBIRD_LIBS AK LibCore LibGfx LibIPC LibMain LibWebView LibURL LibWakeLock)
+set(LADYBIRD_LIBS AK LibCore LibGfx LibIPC LibMain LibWebView LibURL LibWakeLock hubservice)
target_link_libraries(${LADYBIRD_TARGET} ${LADYBIRD_LIBS})
target_link_libraries(${LADYBIRD_TARGET} OpenSSL::Crypto OpenSSL::SSL)
diff --git a/UI/Qt/Application.cpp b/UI/Qt/Application.cpp
index ff95dad402d..b985a2988bc 100644
--- a/UI/Qt/Application.cpp
+++ b/UI/Qt/Application.cpp
@@ -730,7 +730,7 @@ Web::CSS::PreferredColorScheme Application::interface_color_scheme() const
// Bookmarking the page from the menu or its shortcut does what the star in the address field does.
void Application::toggle_bookmark_for_view(WebView::ViewImplementation& view)
{
- if (auto* tab = active_tab(); tab && &tab->view() == &view) {
+ if (auto* tab = active_tab(); tab && &tab->view().hub_view() == &view) {
tab->show_bookmark_popover();
return;
}
@@ -1400,7 +1400,7 @@ void Application::open_url_in_new_tab_from_notification(URL::URL const& url, Web
Optional<WebView::ViewImplementation&> Application::active_web_view() const
{
if (auto* active_tab = this->active_tab())
- return active_tab->view();
+ return active_tab->view().hub_view();
return {};
}
@@ -1452,7 +1452,7 @@ Optional<WebView::ViewImplementation&> Application::activate_tab_with_url(URL::U
window->setWindowState(window->windowState() & ~Qt::WindowMinimized);
window->raise();
window->activateWindow();
- return tab->view();
+ return tab->view().hub_view();
}
return {};
}
@@ -1462,12 +1462,12 @@ Optional<WebView::ViewImplementation&> Application::open_blank_new_tab(Web::HTML
if (!m_active_window) {
auto& window = const_cast<Application&>(*this).new_window({ WebView::Application::settings().new_tab_page_url() });
if (auto* tab = window.current_tab())
- return tab->view();
+ return tab->view().hub_view();
return {};
}
auto& tab = active_window().create_new_tab(activate_tab, BrowserWindow::TabLocation::end());
- return tab.view();
+ return tab.view().hub_view();
}
void Application::open_url_in_new_tab(URL::URL const& url, Web::HTML::ActivateTab activate_tab) const
diff --git a/UI/Qt/BrowserWindow.cpp b/UI/Qt/BrowserWindow.cpp
index 6ceb00c5616..3d5cdeddd81 100644
--- a/UI/Qt/BrowserWindow.cpp
+++ b/UI/Qt/BrowserWindow.cpp
@@ -2108,7 +2108,7 @@ Tab* BrowserWindow::tab_for_view(WebView::ViewImplementation const& view) const
{
for (int index = 0; index < m_tabs_container->count(); ++index) {
auto* tab = m_tabs_container->tab(index);
- if (tab && &tab->view() == &view)
+ if (tab && &tab->view().hub_view() == &view)
return tab;
}
return nullptr;
diff --git a/UI/Qt/CMakeLists.txt b/UI/Qt/CMakeLists.txt
index 737d27395ce..b4c0a9b4c45 100644
--- a/UI/Qt/CMakeLists.txt
+++ b/UI/Qt/CMakeLists.txt
@@ -42,6 +42,7 @@ add_library(ladybird_impl STATIC
PlainText.cpp
Popover.cpp
ProcessManagerWindow.cpp
+ RemoteView.cpp
ReportReview.cpp
RestoreSessionCard.cpp
ScreenshotSelectionOverlay.cpp
diff --git a/UI/Qt/PictureInPictureWindow.cpp b/UI/Qt/PictureInPictureWindow.cpp
index 431ca572623..52f896ae7e3 100644
--- a/UI/Qt/PictureInPictureWindow.cpp
+++ b/UI/Qt/PictureInPictureWindow.cpp
@@ -60,7 +60,7 @@ public:
: QWidget(nullptr, window_flags())
{
// The window's native window and view are created for the screen of the browser window it is opened from.
- auto* screen = static_cast<WebContentView const&>(owner_view).screen();
+ auto* screen = static_cast<WebContentView&>(RemoteView::of(owner_view)).screen();
setScreen(screen);
setAttribute(Qt::WA_ShowWithoutActivating);
@@ -91,7 +91,7 @@ public:
m_screen_observer->on_display_metadata_change = [this] {
m_view->set_display_metadata(m_screen_observer->display_id(), m_screen_observer->refresh_rate());
};
- report_page_close_of(*m_view);
+ report_page_close_of(m_view->hub_view());
m_view->installEventFilter(this);
// The window's controls, and its page's, show on hover, which works while Ladybird is in the background too.
m_view->set_follows_mouse_while_inactive(true);
@@ -232,7 +232,7 @@ private:
void go_back_to_tab(u64 owner_view_id)
{
if (auto owner = WebView::ViewImplementation::find_view_by_id(owner_view_id); owner.has_value()) {
- auto* browser_window = static_cast<WebContentView&>(*owner).window();
+ auto* browser_window = static_cast<WebContentView&>(RemoteView::of(*owner)).window();
browser_window->setWindowState(browser_window->windowState() & ~Qt::WindowMinimized);
browser_window->raise();
browser_window->activateWindow();
diff --git a/UI/Qt/RemoteView.cpp b/UI/Qt/RemoteView.cpp
new file mode 100644
index 00000000000..fa83dd1af2f
--- /dev/null
+++ b/UI/Qt/RemoteView.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <UI/Qt/RemoteView.h>
+
+namespace Ladybird {
+
+RemoteView::RemoteView(Hub::View::InitialState initial_state)
+ : m_view(make<Hub::View>(*this, move(initial_state)))
+{
+}
+
+RemoteView::~RemoteView()
+{
+ m_view->detach_from_host();
+}
+
+RemoteView& RemoteView::of(WebView::ViewImplementation const& view)
+{
+ return static_cast<RemoteView&>(*static_cast<Hub::View const&>(view).host());
+}
+
+}
diff --git a/UI/Qt/RemoteView.h b/UI/Qt/RemoteView.h
new file mode 100644
index 00000000000..f81e5a2c08f
--- /dev/null
+++ b/UI/Qt/RemoteView.h
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/NonnullOwnPtr.h>
+#include <Hub/View.h>
+#include <LibWebView/HistoryStore.h>
+
+namespace Ladybird {
+
+// The UI's side of a tab's view. The view itself lives in the Hub. This holds what the UI needs to show it, and offers
+// the rest of the UI the calls and callbacks that it takes to use the view.
+class RemoteView : public Hub::ViewHost {
+public:
+ using InputMethodState = WebView::ViewImplementation::InputMethodState;
+ using NavigationListener = WebView::ViewImplementation::NavigationListener;
+ using ScreenRects = WebView::ViewImplementation::ScreenRects;
+ using ScreenshotType = WebView::ViewImplementation::ScreenshotType;
+ using SessionHistoryTraversalMenuItem = WebView::ViewImplementation::SessionHistoryTraversalMenuItem;
+
+ explicit RemoteView(Hub::View::InitialState);
+ virtual ~RemoteView() override;
+
+ // The UI's side of a view that the UI shows.
+ static RemoteView& of(WebView::ViewImplementation const&);
+
+ Hub::View& hub_view() { return *m_view; }
+ Hub::View const& hub_view() const { return *m_view; }
+
+ WebView::IsPrivate is_private() const { return m_view->is_private(); }
+ WebView::BrowsingSession& session() const { return m_view->session(); }
+ URL::Origin permission_origin() const { return m_view->permission_origin(); }
+ Vector<WebView::SitePermissionRow> site_permission_rows() const { return m_view->site_permission_rows(); }
+ void set_site_permission(URL::Origin const& origin, Web::Permissions::PermissionName permission_name, Optional<WebView::PermissionDecision> decision) { m_view->set_site_permission(origin, permission_name, decision); }
+ void reset_site_permissions(URL::Origin const& origin) { m_view->reset_site_permissions(origin); }
+ void did_show_permission_prompt(WebView::PermissionPromptRequest const& permission_prompt_request) { m_view->did_show_permission_prompt(permission_prompt_request); }
+ u64 view_id() const { return m_view->view_id(); }
+ pid_t web_content_pid() const { return m_view->web_content_pid(); }
+ WebView::CanonicalTraversable& traversable() const { return m_view->traversable(); }
+ URL::URL url() const { return m_view->url(); }
+ URL::URL const& displayed_url() const { return m_view->displayed_url(); }
+ Utf16String const& title() const { return m_view->title(); }
+ Optional<String> const& favicon_hash() const { return m_view->favicon_hash(); }
+ String const& handle() const { return m_view->handle(); }
+ void set_window_position(Gfx::IntPoint position) { m_view->set_window_position(position); }
+ void set_window_size(Gfx::IntSize size) { m_view->set_window_size(size); }
+ void set_system_visibility_state(Web::HTML::VisibilityState visibility_state) { m_view->set_system_visibility_state(move(visibility_state)); }
+ void set_presents_from_cpu_memory(bool presents_from_cpu_memory) { m_view->set_presents_from_cpu_memory(presents_from_cpu_memory); }
+ void set_has_system_focus(bool has_system_focus) { m_view->set_has_system_focus(has_system_focus); }
+ void load(URL::URL const& url, Web::Bindings::NavigationHistoryBehavior navigation_history_behavior = Web::Bindings::NavigationHistoryBehavior::Auto) { m_view->load(url, move(navigation_history_behavior)); }
+ void load_from_user_input(URL::URL const& url) { m_view->load_from_user_input(url); }
+ void load_from_user_input(StringView input) { m_view->load_from_user_input(input); }
+ void load_from_user_input(StringView input, Optional<URL::URL> fallback_url) { m_view->load_from_user_input(input, move(fallback_url)); }
+ void open_url_in_new_tab(URL::URL const& url, Web::HTML::ActivateTab activate_tab) { m_view->open_url_in_new_tab(url, move(activate_tab)); }
+ void open_url_in_new_window(URL::URL const& url, WebView::IsPrivate is_private) { m_view->open_url_in_new_window(url, move(is_private)); }
+ void load(Web::HTML::PreparedNavigationDescriptor navigation) { m_view->load(move(navigation)); }
+ void open_navigation_in_new_tab(Web::HTML::PreparedNavigationDescriptor navigation, Web::HTML::ActivateTab activate_tab) { m_view->open_navigation_in_new_tab(move(navigation), move(activate_tab)); }
+ void open_navigation_in_new_window(Web::HTML::PreparedNavigationDescriptor navigation, WebView::IsPrivate is_private) { m_view->open_navigation_in_new_window(move(navigation), move(is_private)); }
+ void set_next_history_visit_transition(WebView::HistoryVisitTransition transition) { m_view->set_next_history_visit_transition(move(transition)); }
+ void load_html(StringView html) { m_view->load_html(html); }
+ void load_navigation_error_page(StringView html) { m_view->load_navigation_error_page(html); }
+ void reload(WebView::BypassCache bypass_cache = WebView::BypassCache::No) { m_view->reload(move(bypass_cache)); }
+ void stop_loading() { m_view->stop_loading(); }
+ bool is_loading() const { return m_view->is_loading(); }
+ bool crash_overlay_active() const { return m_view->crash_overlay_active(); }
+ String crash_overlay_failed_url() const { return m_view->crash_overlay_failed_url(); }
+ Optional<ByteString> crash_report_name() const { return m_view->crash_report_name(); }
+ Optional<String> crash_report_website() const { return m_view->crash_report_website(); }
+ void traverse_the_history_to_step(i32 step, WebView::CheckForCancelation check_for_cancelation = WebView::CheckForCancelation::Yes, Function<void()> on_ready = nullptr) { m_view->traverse_the_history_to_step(step, move(check_for_cancelation), move(on_ready)); }
+ Vector<WebView::HistoryEntry> recent_history_entries(size_t limit) const { return m_view->recent_history_entries(limit); }
+ Optional<WebView::SessionTabId> session_tab_id() const { return m_view->session_tab_id(); }
+ void set_session_tab_id(WebView::SessionTabId session_tab_id) { m_view->set_session_tab_id(move(session_tab_id)); }
+ void clear_session_tab_id() { m_view->clear_session_tab_id(); }
+ void zoom_in() { m_view->zoom_in(); }
+ void zoom_out() { m_view->zoom_out(); }
+ void reset_zoom() { m_view->reset_zoom(); }
+ double zoom_level() const { return m_view->zoom_level(); }
+ double device_pixel_ratio() const { return m_view->device_pixel_ratio(); }
+ Optional<u64> display_id() const { return m_view->display_id(); }
+ void set_display_metadata(Optional<u64> display_id, double maximum_frames_per_second) { m_view->set_display_metadata(move(display_id), maximum_frames_per_second); }
+ void update_screen_rects() { m_view->update_screen_rects(); }
+ void set_scales_frames_to_fit(bool scales_frames_to_fit) { m_view->set_scales_frames_to_fit(scales_frames_to_fit); }
+ void enable_picture_in_picture_controls() { m_view->enable_picture_in_picture_controls(); }
+ void enqueue_input_event(Web::InputEvent input_event) { m_view->enqueue_input_event(move(input_event)); }
+ String force_dark_host() const { return m_view->force_dark_host(); }
+ void update_interface_color_scheme() { m_view->update_interface_color_scheme(); }
+ void update_system_theme(Core::AnonymousBuffer const& anonymous_buffer) { m_view->update_system_theme(anonymous_buffer); }
+ NonnullRefPtr<Core::Promise<ByteString>> selected_text() { return m_view->selected_text(); }
+ bool look_up_selected_text_at(Gfx::IntPoint widget_position) { return m_view->look_up_selected_text_at(move(widget_position)); }
+ void find_in_page(Utf16String const& query, CaseSensitivity case_sensitivity = CaseSensitivity::CaseInsensitive, bool highlight_all_matches = false) { m_view->find_in_page(query, move(case_sensitivity), highlight_all_matches); }
+ void find_in_page_next_match() { m_view->find_in_page_next_match(); }
+ void find_in_page_previous_match() { m_view->find_in_page_previous_match(); }
+ void find_in_page_end() { m_view->find_in_page_end(); }
+ bool can_report_website_issue() const { return m_view->can_report_website_issue(); }
+ void report_website_issue() { m_view->report_website_issue(); }
+ void request_accessibility_tree() { m_view->request_accessibility_tree(); }
+ void perform_accessibility_action(i64 node_id, String action) { m_view->perform_accessibility_action(node_id, move(action)); }
+ void clear_node_picker() { m_view->clear_node_picker(); }
+ bool is_node_picker_active() const { return m_view->is_node_picker_active(); }
+ void node_picker_hover(Web::DevicePixelPoint device_pixel_point) { m_view->node_picker_hover(move(device_pixel_point)); }
+ void node_picker_pick(Web::DevicePixelPoint device_pixel_point) { m_view->node_picker_pick(move(device_pixel_point)); }
+ void node_picker_preview(Web::DevicePixelPoint device_pixel_point) { m_view->node_picker_preview(move(device_pixel_point)); }
+ void node_picker_cancel() { m_view->node_picker_cancel(); }
+ WebView::ContentBlockingSnapshot content_blocking_snapshot() const { return m_view->content_blocking_snapshot(); }
+ void alert_closed() { m_view->alert_closed(); }
+ void confirm_closed(bool accepted) { m_view->confirm_closed(accepted); }
+ void prompt_closed(Optional<Utf16String> const& response) { m_view->prompt_closed(response); }
+ void color_picker_update(Optional<Color> picked_color, Web::HTML::ColorPickerUpdateState state) { m_view->color_picker_update(move(picked_color), move(state)); }
+ void date_picker_closed(Optional<Utf16String> picked_value) { m_view->date_picker_closed(move(picked_value)); }
+ void file_picker_closed(Vector<Web::HTML::SelectedFile> selected_files) { m_view->file_picker_closed(move(selected_files)); }
+ void select_dropdown_closed(Optional<u32> const& selected_item_id) { m_view->select_dropdown_closed(selected_item_id); }
+ void set_marked_text_from_input_method(Utf16String const& text) { m_view->set_marked_text_from_input_method(text); }
+ void commit_text_from_input_method(Utf16String const& text, i32 replacement_start = 0, i32 replacement_length = 0) { m_view->commit_text_from_input_method(text, replacement_start, replacement_length); }
+ InputMethodState const& input_method_state() const { return m_view->input_method_state(); }
+ Web::HTML::MuteState page_mute_state() const { return m_view->page_mute_state(); }
+ void toggle_page_mute_state() { m_view->toggle_page_mute_state(); }
+ bool tab_indicator_visible(WebView::TabIndicator indicator) const { return m_view->tab_indicator_visible(move(indicator)); }
+ Gfx::Color page_background_color() const { return m_view->page_background_color(); }
+ WebView::PageBackingStores const& backing_stores() const { return m_view->backing_stores(); }
+ void take_and_save_screenshot(ScreenshotType screenshot_type) { m_view->take_and_save_screenshot(move(screenshot_type)); }
+ void save_screenshot(Gfx::Bitmap const& bitmap) { m_view->save_screenshot(bitmap); }
+ void request_close() { m_view->request_close(); }
+ void request_close_preflight(Function<void(bool)> on_complete) { m_view->request_close_preflight(move(on_complete)); }
+ bool needs_beforeunload_check() const { return m_view->needs_beforeunload_check(); }
+ u64 add_navigation_listener(NavigationListener navigation_listener) { return m_view->add_navigation_listener(move(navigation_listener)); }
+ void remove_navigation_listener(u64 listener_id) { m_view->remove_navigation_listener(listener_id); }
+ WebView::Menu& bookmarks_bar_context_menu() { return m_view->bookmarks_bar_context_menu(); }
+ WebView::Menu& bookmark_context_menu() { return m_view->bookmark_context_menu(); }
+ WebView::Menu& bookmark_folder_context_menu() { return m_view->bookmark_folder_context_menu(); }
+ WebView::Action& navigate_back_action() { return m_view->navigate_back_action(); }
+ WebView::Action& navigate_forward_action() { return m_view->navigate_forward_action(); }
+ WebView::Action& toggle_bookmark_action() { return m_view->toggle_bookmark_action(); }
+ WebView::Action& reset_zoom_action() { return m_view->reset_zoom_action(); }
+ WebView::PageTranslation& page_translation() { return m_view->page_translation(); }
+ WebView::WebContentPage& page() const { return m_view->page(); }
+
+ Vector<SessionHistoryTraversalMenuItem> session_history_traversal_menu_items(int direction) const { return m_view->session_history_traversal_menu_items(direction); }
+ WebView::SessionHistorySnapshot session_history_snapshot() const { return m_view->session_history_snapshot(); }
+ ErrorOr<void> restore_session_history_from_snapshot(WebView::SessionHistorySnapshot snapshot) { return m_view->restore_session_history_from_snapshot(move(snapshot)); }
+ void exit_fullscreen() { m_view->exit_fullscreen(); }
+ void deny_fullscreen_window() { m_view->deny_fullscreen_window(); }
+ void set_is_fullscreen(Web::ViewportIsFullscreen is_fullscreen) { m_view->set_is_fullscreen(is_fullscreen); }
+ Function<void()> prepare_for_close_without_prompting() { return m_view->prepare_for_close_without_prompting(); }
+ Function<void()> prepare_for_immediate_close() { return m_view->prepare_for_immediate_close(); }
+
+ bool scales_frames_to_fit() const { return m_view->scales_frames_to_fit(); }
+
+ // ^Hub::ViewHost
+ virtual void release_backing_store(i32 bitmap_id) override { m_view->release_backing_store_to_page(bitmap_id); }
+
+protected:
+ void initialize_tab(Web::HTML::VisibilityState state, Optional<WebView::CanonicalTraversable&> traversable = {}) { m_view->initialize_tab(state, traversable); }
+ void handle_resize() { m_view->handle_resize(); }
+ void set_owner_view(WebView::ViewImplementation const& owner_view) { m_view->set_owner_view(owner_view); }
+ void set_page_background_color_to_system_canvas(bool dark) { m_view->set_page_background_color_to_system_canvas(dark); }
+ WebView::MicrophoneAuthorizer& microphone_authorizer() const { return m_view->microphone_authorizer(); }
+ static Gfx::IntRect rect_fitting_frame(Gfx::IntSize frame_size, Gfx::IntSize target_size) { return Hub::View::rect_fitting_frame(frame_size, target_size); }
+
+private:
+ NonnullOwnPtr<Hub::View> m_view;
+
+public:
+ decltype(Hub::View::on_load_start)& on_load_start { m_view->on_load_start };
+ decltype(Hub::View::on_load_finish)& on_load_finish { m_view->on_load_finish };
+ decltype(Hub::View::on_ready_to_paint)& on_ready_to_paint { m_view->on_ready_to_paint };
+ decltype(Hub::View::on_performance_stats)& on_performance_stats { m_view->on_performance_stats };
+ decltype(Hub::View::on_new_web_view)& on_new_web_view { m_view->on_new_web_view };
+ decltype(Hub::View::on_activate_tab)& on_activate_tab { m_view->on_activate_tab };
+ decltype(Hub::View::on_close)& on_close { m_view->on_close };
+ decltype(Hub::View::on_link_hover)& on_link_hover { m_view->on_link_hover };
+ decltype(Hub::View::on_link_unhover)& on_link_unhover { m_view->on_link_unhover };
+ decltype(Hub::View::on_title_change)& on_title_change { m_view->on_title_change };
+ decltype(Hub::View::on_url_change)& on_url_change { m_view->on_url_change };
+ decltype(Hub::View::on_loading_state_change)& on_loading_state_change { m_view->on_loading_state_change };
+ decltype(Hub::View::on_top_level_navigation_commit)& on_top_level_navigation_commit { m_view->on_top_level_navigation_commit };
+ decltype(Hub::View::on_browser_history_traversal_complete)& on_browser_history_traversal_complete { m_view->on_browser_history_traversal_complete };
+ decltype(Hub::View::on_request_dictionary_lookup)& on_request_dictionary_lookup { m_view->on_request_dictionary_lookup };
+ decltype(Hub::View::on_favicon_change)& on_favicon_change { m_view->on_favicon_change };
+ decltype(Hub::View::on_cursor_change)& on_cursor_change { m_view->on_cursor_change };
+ decltype(Hub::View::on_input_method_state_change)& on_input_method_state_change { m_view->on_input_method_state_change };
+ decltype(Hub::View::on_enter_tooltip_area)& on_enter_tooltip_area { m_view->on_enter_tooltip_area };
+ decltype(Hub::View::on_leave_tooltip_area)& on_leave_tooltip_area { m_view->on_leave_tooltip_area };
+ decltype(Hub::View::on_content_blocking_change)& on_content_blocking_change { m_view->on_content_blocking_change };
+ decltype(Hub::View::on_request_alert)& on_request_alert { m_view->on_request_alert };
+ decltype(Hub::View::on_request_before_unload)& on_request_before_unload { m_view->on_request_before_unload };
+ decltype(Hub::View::on_request_confirm)& on_request_confirm { m_view->on_request_confirm };
+ decltype(Hub::View::on_request_prompt)& on_request_prompt { m_view->on_request_prompt };
+ decltype(Hub::View::on_request_set_prompt_text)& on_request_set_prompt_text { m_view->on_request_set_prompt_text };
+ decltype(Hub::View::on_before_browser_initiated_navigation)& on_before_browser_initiated_navigation { m_view->on_before_browser_initiated_navigation };
+ decltype(Hub::View::on_request_external_url_confirmation)& on_request_external_url_confirmation { m_view->on_request_external_url_confirmation };
+ decltype(Hub::View::on_request_accept_dialog)& on_request_accept_dialog { m_view->on_request_accept_dialog };
+ decltype(Hub::View::on_request_website_issue_report)& on_request_website_issue_report { m_view->on_request_website_issue_report };
+ decltype(Hub::View::on_request_screenshot)& on_request_screenshot { m_view->on_request_screenshot };
+ decltype(Hub::View::on_request_dismiss_dialog)& on_request_dismiss_dialog { m_view->on_request_dismiss_dialog };
+ decltype(Hub::View::on_accessibility_tree_received)& on_accessibility_tree_received { m_view->on_accessibility_tree_received };
+ decltype(Hub::View::on_accessibility_tree_changed)& on_accessibility_tree_changed { m_view->on_accessibility_tree_changed };
+ decltype(Hub::View::on_accessibility_focus_changed)& on_accessibility_focus_changed { m_view->on_accessibility_focus_changed };
+ decltype(Hub::View::on_restore_window)& on_restore_window { m_view->on_restore_window };
+ decltype(Hub::View::on_reposition_window)& on_reposition_window { m_view->on_reposition_window };
+ decltype(Hub::View::on_resize_window)& on_resize_window { m_view->on_resize_window };
+ decltype(Hub::View::on_maximize_window)& on_maximize_window { m_view->on_maximize_window };
+ decltype(Hub::View::on_minimize_window)& on_minimize_window { m_view->on_minimize_window };
+ decltype(Hub::View::on_fullscreen_window)& on_fullscreen_window { m_view->on_fullscreen_window };
+ decltype(Hub::View::on_exit_fullscreen_window)& on_exit_fullscreen_window { m_view->on_exit_fullscreen_window };
+ decltype(Hub::View::on_request_color_picker)& on_request_color_picker { m_view->on_request_color_picker };
+ decltype(Hub::View::on_request_date_picker)& on_request_date_picker { m_view->on_request_date_picker };
+ decltype(Hub::View::on_request_permission)& on_request_permission { m_view->on_request_permission };
+ decltype(Hub::View::on_cancel_permission_prompt)& on_cancel_permission_prompt { m_view->on_cancel_permission_prompt };
+ decltype(Hub::View::on_tab_indicator_change)& on_tab_indicator_change { m_view->on_tab_indicator_change };
+ decltype(Hub::View::on_request_file_picker)& on_request_file_picker { m_view->on_request_file_picker };
+ decltype(Hub::View::on_request_select_dropdown)& on_request_select_dropdown { m_view->on_request_select_dropdown };
+ decltype(Hub::View::on_finish_handling_key_event)& on_finish_handling_key_event { m_view->on_finish_handling_key_event };
+ decltype(Hub::View::on_finish_handling_mouse_event)& on_finish_handling_mouse_event { m_view->on_finish_handling_mouse_event };
+ decltype(Hub::View::on_picture_in_picture_control_activated)& on_picture_in_picture_control_activated { m_view->on_picture_in_picture_control_activated };
+ decltype(Hub::View::on_finish_handling_drag_event)& on_finish_handling_drag_event { m_view->on_finish_handling_drag_event };
+ decltype(Hub::View::on_find_in_page)& on_find_in_page { m_view->on_find_in_page };
+ decltype(Hub::View::on_page_background_color_change)& on_page_background_color_change { m_view->on_page_background_color_change };
+ decltype(Hub::View::on_screen_wake_lock_state_changed)& on_screen_wake_lock_state_changed { m_view->on_screen_wake_lock_state_changed };
+ decltype(Hub::View::on_web_content_crashed)& on_web_content_crashed { m_view->on_web_content_crashed };
+ decltype(Hub::View::on_crash_overlay_state_change)& on_crash_overlay_state_change { m_view->on_crash_overlay_state_change };
+ decltype(Hub::View::on_crash_report_saved)& on_crash_report_saved { m_view->on_crash_report_saved };
+};
+
+}
diff --git a/UI/Qt/WebContentView.cpp b/UI/Qt/WebContentView.cpp
index 9fd63da0276..95db1d9db08 100644
--- a/UI/Qt/WebContentView.cpp
+++ b/UI/Qt/WebContentView.cpp
@@ -122,7 +122,12 @@ static QWidget* initial_web_content_view_parent([[maybe_unused]] QWidget* window
WebContentView::WebContentView(QWidget* window, Optional<WebView::CanonicalTraversable&> traversable, WebContentViewInitialState initial_state)
: WebContentViewBase(initial_web_content_view_parent(window))
- , WebView::ViewImplementation(initial_state.is_private)
+ , RemoteView({
+ .is_private = initial_state.is_private,
+ .device_pixel_ratio = devicePixelRatio(),
+ .maximum_frames_per_second = initial_state.maximum_frames_per_second,
+ .display_id = initial_state.display_id,
+ })
{
#ifdef LADYBIRD_QT_USE_RHI_WIDGET
// Keep the QRhiWidget out of the top-level QWidget backing store. If it is
@@ -162,10 +167,6 @@ WebContentView::WebContentView(QWidget* window, Optional<WebView::CanonicalTrave
create_vulkan_window();
#endif
- m_device_pixel_ratio = devicePixelRatio();
- m_maximum_frames_per_second = initial_state.maximum_frames_per_second;
- m_display_id = initial_state.display_id;
-
set_page_background_color_to_system_canvas(websites_prefer_dark());
#ifdef LADYBIRD_QT_USE_IOSURFACE_LAYER
on_page_background_color_change = [this](Gfx::Color) {
@@ -1109,10 +1110,10 @@ void WebContentView::schedule_frame_damage_repaint()
return;
}
- auto logical_left = static_cast<int>(floor(m_pending_frame_damage.x() / m_device_pixel_ratio));
- auto logical_top = static_cast<int>(floor(m_pending_frame_damage.y() / m_device_pixel_ratio));
- auto logical_right = static_cast<int>(ceil(m_pending_frame_damage.right() / m_device_pixel_ratio));
- auto logical_bottom = static_cast<int>(ceil(m_pending_frame_damage.bottom() / m_device_pixel_ratio));
+ auto logical_left = static_cast<int>(floor(m_pending_frame_damage.x() / device_pixel_ratio()));
+ auto logical_top = static_cast<int>(floor(m_pending_frame_damage.y() / device_pixel_ratio()));
+ auto logical_right = static_cast<int>(ceil(m_pending_frame_damage.right() / device_pixel_ratio()));
+ auto logical_bottom = static_cast<int>(ceil(m_pending_frame_damage.bottom() / device_pixel_ratio()));
update(QRect(logical_left, logical_top, logical_right - logical_left, logical_bottom - logical_top).intersected(rect()));
}
#endif
@@ -1146,7 +1147,7 @@ void WebContentView::paintEvent(QPaintEvent*)
# endif
QPainter painter(this);
- painter.scale(1 / m_device_pixel_ratio, 1 / m_device_pixel_ratio);
+ painter.scale(1 / device_pixel_ratio(), 1 / device_pixel_ratio());
auto paintable = current_paintable();
RefPtr<Gfx::Bitmap const> bitmap;
@@ -1163,7 +1164,7 @@ void WebContentView::paintEvent(QPaintEvent*)
auto background_color = page_background_color();
auto fallback_color = QColor(background_color.red(), background_color.green(), background_color.blue());
- if (m_scales_frames_to_fit && !bitmap_size.is_empty()) {
+ if (scales_frames_to_fit() && !bitmap_size.is_empty()) {
auto destination = rect_fitting_frame(bitmap_size, m_viewport_size);
painter.fillRect(QRect(0, 0, m_viewport_size.width(), m_viewport_size.height()), fallback_color);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
@@ -1520,9 +1521,9 @@ void WebContentView::start_web_compat_report()
return;
WebCompatReportCapture capture {
- .page = WebView::WebCompatReport::describe_page(*this),
+ .page = WebView::WebCompatReport::describe_page(hub_view()),
.screenshot = {},
- .page_dumps = WebView::WebCompatReport::request_page_dumps(*this),
+ .page_dumps = WebView::WebCompatReport::request_page_dumps(hub_view()),
};
select_web_compat_report_screenshot([this, capture = AK::move(capture)](QImage screenshot) mutable {
capture.screenshot = AK::move(screenshot);
@@ -1794,7 +1795,7 @@ void WebContentView::resizeEvent(QResizeEvent* event)
#endif
#ifdef LADYBIRD_HAS_WAYLAND_GPU_QUERY
// NB: The page surface would stick out of a browser window that shrinks, so it is cropped to the view.
- if (m_page_surface && !QRect { QPoint { 0, 0 }, size() * m_device_pixel_ratio }.contains(m_page_surface_rect))
+ if (m_page_surface && !QRect { QPoint { 0, 0 }, size() * device_pixel_ratio() }.contains(m_page_surface_rect))
update_page_surface(PageSurfaceContent::Unchanged);
#endif
// One window resize reaches the view as several resize events in one turn of the event loop
@@ -1828,7 +1829,7 @@ void WebContentView::push_viewport_size()
void WebContentView::set_device_pixel_ratio(double device_pixel_ratio)
{
- m_device_pixel_ratio = device_pixel_ratio;
+ hub_view().set_device_pixel_ratio(device_pixel_ratio);
update_viewport_size();
#ifdef LADYBIRD_QT_USE_IOSURFACE_LAYER
present_current_paintable_as_layer_contents();
@@ -1882,17 +1883,10 @@ void WebContentView::set_bookmarks_bar_overlay_height([[maybe_unused]] int heigh
#endif
}
-void WebContentView::set_zoom_level(double zoom_level)
-{
- m_zoom_level = zoom_level;
- page().async_set_zoom_level(m_zoom_level);
- update_zoom();
-}
-
void WebContentView::update_viewport_size()
{
- auto scaled_width = int(width() * m_device_pixel_ratio);
- auto scaled_height = int(height() * m_device_pixel_ratio);
+ auto scaled_width = int(width() * device_pixel_ratio());
+ auto scaled_height = int(height() * device_pixel_ratio());
Gfx::IntRect rect(0, 0, scaled_width, scaled_height);
set_viewport_rect(rect);
@@ -1900,7 +1894,6 @@ void WebContentView::update_viewport_size()
void WebContentView::update_zoom()
{
- ViewImplementation::update_zoom();
update_viewport_size();
}
@@ -2194,13 +2187,6 @@ Optional<WebView::ViewImplementation::ScreenRects> WebContentView::screen_rects(
return {};
}
-void WebContentView::prepare_page_for_navigable(WebView::WebContentPage& page)
-{
- ViewImplementation::prepare_page_for_navigable(page);
-
- update_compositor_display_metadata(page);
-}
-
void WebContentView::update_cursor(Gfx::Cursor cursor)
{
cursor.visit([this](Gfx::StandardCursor standard_cursor) {
@@ -2288,7 +2274,7 @@ void WebContentView::update_cursor(Gfx::Cursor cursor)
Web::DevicePixelPoint WebContentView::node_picker_position_for(QSinglePointEvent const& event) const
{
- return { event.position().x() * m_device_pixel_ratio, event.position().y() * m_device_pixel_ratio };
+ return { event.position().x() * device_pixel_ratio(), event.position().y() * device_pixel_ratio() };
}
Web::DevicePixelSize WebContentView::viewport_size() const
@@ -2301,16 +2287,6 @@ QPoint WebContentView::map_point_to_global_position(Gfx::IntPoint position) cons
return mapToGlobal(QPoint { position.x(), position.y() } / device_pixel_ratio());
}
-Gfx::IntPoint WebContentView::to_content_position(Gfx::IntPoint widget_position) const
-{
- return widget_position;
-}
-
-Gfx::IntPoint WebContentView::to_widget_position(Gfx::IntPoint content_position) const
-{
- return content_position;
-}
-
void WebContentView::show_context_menu(WebView::Menu& menu, Gfx::IntPoint widget_position)
{
execute_context_menu_later(m_context_menu, *this, menu, map_point_to_global_position(widget_position));
@@ -2437,7 +2413,7 @@ bool WebContentView::handle_native_gesture_event(QNativeGestureEvent const& even
case Qt::ZoomNativeGesture: {
Web::PinchEvent pinch_event;
auto const local_position = mapFromGlobal(event.globalPosition());
- pinch_event.position = { local_position.x() * m_device_pixel_ratio, local_position.y() * m_device_pixel_ratio };
+ pinch_event.position = { local_position.x() * device_pixel_ratio(), local_position.y() * device_pixel_ratio() };
pinch_event.modifiers = get_modifiers_from_qt_keyboard_modifiers(event.modifiers());
pinch_event.scale_delta = event.value();
pinch_event.continues_gesture = m_native_gesture_state == NativeGestureState::Zooming;
@@ -2453,8 +2429,8 @@ bool WebContentView::handle_native_gesture_event(QNativeGestureEvent const& even
void WebContentView::enqueue_native_event(Web::MouseEvent::Type type, QSinglePointEvent const& event, Optional<Web::ScrollGesturePhase> scroll_gesture_phase_the_platform_reports)
{
- Web::DevicePixelPoint position = { event.position().x() * m_device_pixel_ratio, event.position().y() * m_device_pixel_ratio };
- auto screen_position = Gfx::IntPoint { event.globalPosition().x() * m_device_pixel_ratio, event.globalPosition().y() * m_device_pixel_ratio };
+ Web::DevicePixelPoint position = { event.position().x() * device_pixel_ratio(), event.position().y() * device_pixel_ratio() };
+ auto screen_position = Gfx::IntPoint { event.globalPosition().x() * device_pixel_ratio(), event.globalPosition().y() * device_pixel_ratio() };
auto button = get_button_from_qt_mouse_button(event.button());
auto buttons = get_buttons_from_qt_mouse_buttons(event.buttons());
@@ -2498,10 +2474,10 @@ struct DragData : Web::BrowserInputData {
void WebContentView::enqueue_native_event(Web::DragEvent::Type type, QDropEvent const& event)
{
- Web::DevicePixelPoint position = { event.position().x() * m_device_pixel_ratio, event.position().y() * m_device_pixel_ratio };
+ Web::DevicePixelPoint position = { event.position().x() * device_pixel_ratio(), event.position().y() * device_pixel_ratio() };
auto global_position = mapToGlobal(event.position());
- auto screen_position = Gfx::IntPoint { global_position.x() * m_device_pixel_ratio, global_position.y() * m_device_pixel_ratio };
+ auto screen_position = Gfx::IntPoint { global_position.x() * device_pixel_ratio(), global_position.y() * device_pixel_ratio() };
auto button = get_button_from_qt_mouse_button(Qt::LeftButton);
auto buttons = get_buttons_from_qt_mouse_buttons(event.buttons());
diff --git a/UI/Qt/WebContentView.h b/UI/Qt/WebContentView.h
index 5fa264b456d..0b46280147f 100644
--- a/UI/Qt/WebContentView.h
+++ b/UI/Qt/WebContentView.h
@@ -26,9 +26,9 @@
#include <LibWebCommon/Page/PageId.h>
#include <LibWebView/AccessibilityTreeManager.h>
#include <LibWebView/BrowsingSession.h>
-#include <LibWebView/ViewImplementation.h>
#include <LibWebView/WebCompatReport.h>
#include <UI/Qt/BackingStoreRelease.h>
+#include <UI/Qt/RemoteView.h>
#include <UI/Qt/ScreenshotSelectionOverlay.h>
#include <LibWebCommon/Page/QueuedInputEvent.h>
@@ -117,7 +117,7 @@ struct WebContentViewInitialState {
class WebContentView final
: public WebContentViewBase
- , public WebView::ViewImplementation
+ , public RemoteView
#if !defined(Q_OS_WIN)
, public QAccessible::ActivationObserver
#endif
@@ -168,7 +168,6 @@ public:
void set_viewport_rect(Gfx::IntRect);
void push_viewport_size();
void set_device_pixel_ratio(double);
- void set_zoom_level(double);
void set_vertical_tab_overlay_insets(int left, int right);
void set_bookmarks_bar_overlay_height(int);
// How much the page is dimmed under a page dialog, from 0 to 1, where the page is presented above anything Qt paints
@@ -218,14 +217,11 @@ signals:
void urls_dropped(QList<QUrl> const&);
private:
- // ^WebView::ViewImplementation
- virtual void prepare_page_for_navigable(WebView::WebContentPage&) override;
+ // ^Hub::ViewHost
virtual Core::AnonymousBuffer system_theme() override;
virtual Optional<ScreenRects> screen_rects() const override;
virtual void update_zoom() override;
virtual Web::DevicePixelSize viewport_size() const override;
- virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override;
- virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override;
virtual void show_context_menu(WebView::Menu&, Gfx::IntPoint widget_position) override;
virtual void did_accept_presented_backing_store(i32, Gfx::IntRect) override;
diff --git a/UI/Qt/WebContentViewLinux.cpp b/UI/Qt/WebContentViewLinux.cpp
index ea213a55810..052b5b640e5 100644
--- a/UI/Qt/WebContentViewLinux.cpp
+++ b/UI/Qt/WebContentViewLinux.cpp
@@ -204,7 +204,7 @@ RefPtr<Gfx::Bitmap const> WebContentView::cpu_bitmap_to_paint(Paintable const& p
// what it paints, and painting the frame there would be slow: from GPU memory it has to be read back, and a
// linear frame is mapped from memory that is slow to read.
QRect visible_frame { 0, 0, paintable.bitmap_size.width(), paintable.bitmap_size.height() };
- visible_frame &= QRect { QPoint { 0, 0 }, size() * m_device_pixel_ratio };
+ visible_frame &= QRect { QPoint { 0, 0 }, size() * device_pixel_ratio() };
if (visible_frame.isEmpty() || rect_covered_by_page_window().contains(visible_frame))
return {};
return cpu_bitmap_of(paintable);
@@ -941,7 +941,7 @@ struct WebContentView::VulkanWindowRenderer final : public QVulkanWindowRenderer
};
vkCmdBeginRenderPass(command_buffer, &render_pass_begin_info, VK_SUBPASS_CONTENTS_INLINE);
- bool rendered = m_renderer.render(command_buffer, *paintable->shared_image_buffer, paintable->bitmap_size, target_size, m_view.m_scales_frames_to_fit);
+ bool rendered = m_renderer.render(command_buffer, *paintable->shared_image_buffer, paintable->bitmap_size, target_size, m_view.scales_frames_to_fit());
if (rendered && m_view.m_vulkan_window_supports_alpha_blending.value_or(false)) {
// Clear the regions covered by hover-expanded browser chrome to transparent so widgets painted in the
@@ -1110,7 +1110,7 @@ bool WebContentView::vulkan_window_update_would_only_resize() const
if (!m_vulkan_window || m_presented_page_window_size.isEmpty() || QGuiApplication::platformName() != "wayland")
return false;
// NB: A frame scaled to fit the view has to be scaled again for its new size.
- if (m_scales_frames_to_fit)
+ if (scales_frames_to_fit())
return false;
if (m_presented_page_window_content_serial != m_page_window_content_serial)
return false;
@@ -1270,7 +1270,7 @@ void WebContentView::release_backing_store(i32 bitmap_id)
return;
}
#endif
- WebView::ViewImplementation::release_backing_store(bitmap_id);
+ RemoteView::release_backing_store(bitmap_id);
}
#ifdef LADYBIRD_HAS_WAYLAND_GPU_QUERY
@@ -1304,7 +1304,7 @@ bool WebContentView::page_surface_can_show_frames() const
return false;
// NB: The page surface leaves the strips that hover-expanded chrome covers to Qt, except for a frame scaled to fit.
auto has_hover_expanded_chrome = m_vertical_tab_overlay_left != 0 || m_vertical_tab_overlay_right != 0 || m_bookmarks_bar_overlay_height != 0;
- return !m_scales_frames_to_fit || !has_hover_expanded_chrome;
+ return !scales_frames_to_fit() || !has_hover_expanded_chrome;
}
void WebContentView::hide_page_surface()
@@ -1334,7 +1334,7 @@ void WebContentView::update_page_surface(PageSurfaceContent content)
QRect frame_rect;
QRect source;
QRect target;
- if (m_scales_frames_to_fit) {
+ if (scales_frames_to_fit()) {
auto fitted = rect_fitting_frame(bitmap_size, m_viewport_size);
frame_rect = { fitted.x(), fitted.y(), fitted.width(), fitted.height() };
source = { 0, 0, bitmap_size.width(), bitmap_size.height() };
@@ -1342,21 +1342,21 @@ void WebContentView::update_page_surface(PageSurfaceContent content)
} else {
// NB: The view can already be smaller than the viewport the page has, and the compositor doesn't clip the
// page surface to the browser window.
- auto view_size = size() * m_device_pixel_ratio;
+ auto view_size = size() * device_pixel_ratio();
frame_rect = { 0, 0, min(min(bitmap_size.width(), m_viewport_size.width()), view_size.width()), min(min(bitmap_size.height(), m_viewport_size.height()), view_size.height()) };
// NB: Hover-expanded chrome paints in the view over strips of the page, which the page surface would cover.
- auto left = qRound(m_vertical_tab_overlay_left * m_device_pixel_ratio);
- auto right = qRound(m_vertical_tab_overlay_right * m_device_pixel_ratio);
- auto top = qRound(m_bookmarks_bar_overlay_height * m_device_pixel_ratio);
+ auto left = qRound(m_vertical_tab_overlay_left * device_pixel_ratio());
+ auto right = qRound(m_vertical_tab_overlay_right * device_pixel_ratio());
+ auto top = qRound(m_bookmarks_bar_overlay_height * device_pixel_ratio());
source = frame_rect.intersected({ left, top, view_size.width() - left - right, view_size.height() - top });
// NB: Qt clips the view to the widgets it is in, such as while the page slides along with a toggling sidebar,
// but the compositor clips the page surface to nothing.
auto shown = rect_shown_in_window();
- source &= QRect { qRound(shown.x() * m_device_pixel_ratio), qRound(shown.y() * m_device_pixel_ratio), qRound(shown.width() * m_device_pixel_ratio), qRound(shown.height() * m_device_pixel_ratio) };
+ source &= QRect { qRound(shown.x() * device_pixel_ratio()), qRound(shown.y() * device_pixel_ratio()), qRound(shown.width() * device_pixel_ratio()), qRound(shown.height() * device_pixel_ratio()) };
target = source;
}
- auto to_logical = [&](int device_pixels) { return max(1, qRound(device_pixels / m_device_pixel_ratio)); };
+ auto to_logical = [&](int device_pixels) { return max(1, qRound(device_pixels / device_pixel_ratio())); };
auto view_position = mapTo(window(), QPoint { 0, 0 });
WaylandPageSurface::Frame frame {
.shared_image_buffer = *paintable->shared_image_buffer,
@@ -1364,7 +1364,7 @@ void WebContentView::update_page_surface(PageSurfaceContent content)
.page_id = paintable->page_id,
.bitmap_id = paintable->bitmap_id,
.source = source,
- .position = view_position + QPoint { qRound(target.x() / m_device_pixel_ratio), qRound(target.y() / m_device_pixel_ratio) },
+ .position = view_position + QPoint { qRound(target.x() / device_pixel_ratio()), qRound(target.y() / device_pixel_ratio()) },
.destination = { to_logical(target.width()), to_logical(target.height()) },
.has_new_content = content == PageSurfaceContent::MayHaveChanged,
};
diff --git a/UI/Qt/WebContentViewMac.mm b/UI/Qt/WebContentViewMac.mm
index 5d16f32818a..4929b12b19e 100644
--- a/UI/Qt/WebContentViewMac.mm
+++ b/UI/Qt/WebContentViewMac.mm
@@ -73,7 +73,7 @@ void WebContentView::present_current_paintable_as_layer_contents()
ScopeGuard update_painting_for_new_contents = [this] { update_whether_qt_paints_view(); };
auto* layer = as_layer(m_iosurface_layer);
- layer.contentsScale = m_device_pixel_ratio;
+ layer.contentsScale = device_pixel_ratio();
auto paintable = current_paintable();
if (!paintable.has_value()) {
@@ -99,7 +99,7 @@ void WebContentView::present_current_paintable_as_layer_contents()
// and the unit rectangle upside down.
bool y_axis_points_down = [layer contentsAreFlipped];
auto top_left_gravity = y_axis_points_down ? kCAGravityBottomLeft : kCAGravityTopLeft;
- layer.contentsGravity = m_scales_frames_to_fit ? kCAGravityResizeAspect : top_left_gravity;
+ layer.contentsGravity = scales_frames_to_fit() ? kCAGravityResizeAspect : top_left_gravity;
layer.contentsRect = y_axis_points_down
? CGRectMake(0, 0, painted_unit_width, painted_unit_height)
: CGRectMake(0, 1 - painted_unit_height, painted_unit_width, painted_unit_height);