Skip to content

Truly independent web browser

LibWebView+UI/Qt: Query process and view data instead of core objects

Andreas Klingd5dca94a4c4f
diff --git a/Libraries/LibWebView/CMakeLists.txt b/Libraries/LibWebView/CMakeLists.txt
index a10bd97e0b3..a8360b8573c 100644
--- a/Libraries/LibWebView/CMakeLists.txt
+++ b/Libraries/LibWebView/CMakeLists.txt
@@ -48,6 +48,7 @@ set(SOURCES
PictureInPictureWindow.cpp
Process.cpp
ProcessManager.cpp
+ ProcessSnapshot.cpp
TabPerformanceStats.cpp
TabPerformanceMonitor.cpp
ProcessMonitor.cpp
diff --git a/Libraries/LibWebView/HeadlessWebView.cpp b/Libraries/LibWebView/HeadlessWebView.cpp
index b7b5aa72267..586a548049d 100644
--- a/Libraries/LibWebView/HeadlessWebView.cpp
+++ b/Libraries/LibWebView/HeadlessWebView.cpp
@@ -267,16 +267,9 @@ void HeadlessWebView::schedule_forced_close()
m_forced_close_timer->start();
}
-void HeadlessWebView::send_system_theme_to_page(WebContentPage& page)
+Optional<ViewImplementation::ScreenRects> HeadlessWebView::screen_rects() const
{
- page.async_update_system_theme(m_theme);
-}
-
-void HeadlessWebView::prepare_page_for_navigable(WebContentPage& page)
-{
- ViewImplementation::prepare_page_for_navigable(page);
-
- page.async_update_screen_rects({ { screen_rect } }, { { screen_rect } }, 0);
+ return ScreenRects { .rects = { screen_rect }, .available_rects = { screen_rect }, .main_screen_index = 0 };
}
void HeadlessWebView::reset_viewport_size(Web::DevicePixelSize size)
diff --git a/Libraries/LibWebView/HeadlessWebView.h b/Libraries/LibWebView/HeadlessWebView.h
index fc5eddcf54e..e9f41fc35af 100644
--- a/Libraries/LibWebView/HeadlessWebView.h
+++ b/Libraries/LibWebView/HeadlessWebView.h
@@ -58,8 +58,8 @@ protected:
HeadlessWebView& adopt_child_web_view(NonnullOwnPtr<HeadlessWebView>);
void discard_child_web_view(HeadlessWebView&);
void schedule_forced_close();
- void prepare_page_for_navigable(WebContentPage&) override;
- void send_system_theme_to_page(WebContentPage&) override;
+ virtual Core::AnonymousBuffer system_theme() override { return m_theme; }
+ virtual Optional<ScreenRects> screen_rects() const override;
void update_zoom() override;
ViewImplementation* create_view_for_new_tab_or_window(IsPrivate) override;
diff --git a/Libraries/LibWebView/ProcessSnapshot.cpp b/Libraries/LibWebView/ProcessSnapshot.cpp
new file mode 100644
index 00000000000..c42514ff5f9
--- /dev/null
+++ b/Libraries/LibWebView/ProcessSnapshot.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <AK/HashMap.h>
+#include <LibWebView/Application.h>
+#include <LibWebView/CanonicalTraversable.h>
+#include <LibWebView/FaviconStore.h>
+#include <LibWebView/ProcessManager.h>
+#include <LibWebView/ProcessSnapshot.h>
+#include <LibWebView/ViewImplementation.h>
+
+namespace WebView {
+
+Vector<ProcessSnapshot> process_snapshots(ProcessManager& manager)
+{
+ // A process that hosts pages of several views is shown with the most relevant one: the active view's, then a
+ // visible view's, with ties going to the lower view ID. Within a view, its top-level page wins over its frames.
+ struct ProcessPage {
+ ViewImplementation* view;
+ URL::URL url;
+ ProcessPageKind kind;
+ };
+ HashMap<u64, ProcessPage> process_pages;
+ // NB: The Application is only asked once there is a view, so that a ProcessManager without one can be described.
+ bool did_look_up_active_view = false;
+ Optional<ViewImplementation&> active_view;
+ ViewImplementation::for_each_view([&](auto& view) {
+ // An owned view's page shares its owner's process, which the owner's tab already lists.
+ if (view.owner_view_id().has_value())
+ return IterationDecision::Continue;
+ if (!did_look_up_active_view) {
+ active_view = Application::the().active_web_view();
+ did_look_up_active_view = true;
+ }
+ auto priority = [&](auto const& candidate) {
+ if (active_view.has_value() && &*active_view == &candidate)
+ return 2;
+ return candidate.traversable().system_visibility_state() == Web::HTML::VisibilityState::Visible ? 1 : 0;
+ };
+ auto add_page = [&](u64 child_id, URL::URL const& url, ProcessPageKind kind) {
+ auto current = process_pages.get(child_id);
+ if (!current.has_value() || priority(view) > priority(*current->view)
+ || (priority(view) == priority(*current->view) && view.view_id() < current->view->view_id())
+ || (current->view == &view && kind == ProcessPageKind::TopLevel && current->kind == ProcessPageKind::Frame))
+ process_pages.set(child_id, ProcessPage { &view, url, kind });
+ };
+ add_page(view.page().client().child_id(), view.url(), ProcessPageKind::TopLevel);
+ view.traversable().for_each_in_subtree([&](auto const& navigable) {
+ if (navigable.has_remote_host() && navigable.replicated_state().has_value())
+ add_page(navigable.remote_host().client().child_id(), navigable.replicated_state()->active_document_url, ProcessPageKind::Frame);
+ return IterationDecision::Continue;
+ });
+ return IterationDecision::Continue;
+ });
+
+ manager.update_all_process_statistics();
+ Vector<ProcessSnapshot> snapshots;
+ manager.for_each_process_statistics([&](auto& process, auto const& statistics) {
+ ProcessSnapshot snapshot {
+ .child_id = process.child_id(),
+ .pid = statistics.pid,
+ .type = process.type(),
+ .title = process.title(),
+ .owner_child_id = process.owner_child_id(),
+ .cpu_percent = statistics.cpu_percent,
+ .memory_usage_bytes = statistics.memory_usage_bytes,
+ .page = {},
+ };
+ if (auto page = process_pages.get(process.child_id()); page.has_value()) {
+ snapshot.page = ProcessPageSnapshot {
+ .view_id = page->view->view_id(),
+ .url = page->url,
+ .kind = page->kind,
+ .favicon_hash = page->view->favicon_hash(),
+ };
+ }
+ snapshots.append(move(snapshot));
+ });
+ return snapshots;
+}
+
+Optional<ByteBuffer> favicon_png_for_page(ProcessPageSnapshot const& page)
+{
+ if (!page.favicon_hash.has_value())
+ return {};
+ auto view = ViewImplementation::find_view_by_id(page.view_id);
+ if (!view.has_value())
+ return {};
+ return view->session().favicon_store->favicon_png(*page.favicon_hash);
+}
+
+}
diff --git a/Libraries/LibWebView/ProcessSnapshot.h b/Libraries/LibWebView/ProcessSnapshot.h
new file mode 100644
index 00000000000..0fc44ef3e79
--- /dev/null
+++ b/Libraries/LibWebView/ProcessSnapshot.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/ByteBuffer.h>
+#include <AK/Optional.h>
+#include <AK/String.h>
+#include <AK/Utf16String.h>
+#include <AK/Vector.h>
+#include <LibURL/URL.h>
+#include <LibWebView/Export.h>
+#include <LibWebView/Forward.h>
+#include <LibWebView/ProcessType.h>
+
+namespace WebView {
+
+enum class ProcessPageKind : u8 {
+ TopLevel,
+ Frame,
+};
+
+// The page that a WebContent process is shown with in the task manager.
+struct ProcessPageSnapshot {
+ u64 view_id { 0 };
+ URL::URL url;
+ ProcessPageKind kind { ProcessPageKind::TopLevel };
+ Optional<String> favicon_hash;
+};
+
+struct ProcessSnapshot {
+ u64 child_id { 0 };
+ pid_t pid { 0 };
+ ProcessType type { ProcessType::Browser };
+ Optional<Utf16String> title;
+ Optional<u64> owner_child_id;
+ float cpu_percent { 0 };
+ u64 memory_usage_bytes { 0 };
+ Optional<ProcessPageSnapshot> page;
+};
+
+// Updates the process statistics, and describes every process with the page that best represents it.
+WEBVIEW_API Vector<ProcessSnapshot> process_snapshots(ProcessManager&);
+
+WEBVIEW_API Optional<ByteBuffer> favicon_png_for_page(ProcessPageSnapshot const&);
+
+}
diff --git a/Libraries/LibWebView/ViewImplementation.cpp b/Libraries/LibWebView/ViewImplementation.cpp
index 0ad924bce06..efbf1ad3df5 100644
--- a/Libraries/LibWebView/ViewImplementation.cpp
+++ b/Libraries/LibWebView/ViewImplementation.cpp
@@ -123,6 +123,16 @@ ViewImplementation::~ViewImplementation()
CanonicalTraversable::remove_from_user_agent_top_level_traversable_set(*m_top_level_traversable);
}
+pid_t ViewImplementation::web_content_pid() const
+{
+ return page().client().pid();
+}
+
+Vector<HistoryEntry> ViewImplementation::recent_history_entries(size_t limit) const
+{
+ return m_session->history_store->list_entries({}, 0, limit);
+}
+
CanonicalTraversable& ViewImplementation::traversable() const
{
VERIFY(m_top_level_traversable);
@@ -667,6 +677,49 @@ void ViewImplementation::set_zoom(double zoom_level)
update_zoom();
}
+void ViewImplementation::set_display_metadata(Optional<u64> display_id, double maximum_frames_per_second)
+{
+ m_display_id = display_id;
+ m_maximum_frames_per_second = maximum_frames_per_second;
+ traversable().for_each_hosting_page([&](WebContentPage& page) {
+ page.async_set_maximum_frames_per_second(m_maximum_frames_per_second);
+ update_compositor_display_metadata(page);
+ });
+}
+
+void ViewImplementation::update_compositor_display_metadata(WebContentPage& page)
+{
+ Application::the().update_compositor_display_metadata(page.compositor_context_id(), m_display_id, m_maximum_frames_per_second);
+}
+
+static void send_screen_rects_to_page(WebContentPage& page, ViewImplementation::ScreenRects const& screens)
+{
+ page.async_update_screen_rects(screens.rects, screens.available_rects, screens.main_screen_index);
+}
+
+void ViewImplementation::update_screen_rects()
+{
+ auto screens = screen_rects();
+ if (!screens.has_value())
+ return;
+ traversable().for_each_hosting_page([&](WebContentPage& page) {
+ send_screen_rects_to_page(page, *screens);
+ });
+}
+
+void ViewImplementation::update_system_theme(Core::AnonymousBuffer const& theme)
+{
+ traversable().for_each_hosting_page([&](WebContentPage& page) {
+ page.async_update_system_theme(theme);
+ });
+}
+
+void ViewImplementation::send_system_theme_to_page(WebContentPage& page)
+{
+ if (auto theme = system_theme(); theme.is_valid())
+ page.async_update_system_theme(theme);
+}
+
void ViewImplementation::reset_zoom()
{
m_zoom_level = 1.0;
@@ -2944,6 +2997,8 @@ void ViewImplementation::prepare_page_for_navigable(WebContentPage& page)
Application::the().apply_view_options({}, *this, page);
send_force_dark(page);
send_preferences_to_page(page);
+ if (auto screens = screen_rects(); screens.has_value())
+ send_screen_rects_to_page(page, *screens);
}
void ViewImplementation::prepare_page_for_tab(WebContentPage& page)
diff --git a/Libraries/LibWebView/ViewImplementation.h b/Libraries/LibWebView/ViewImplementation.h
index 24e574ead96..f8c41d623f3 100644
--- a/Libraries/LibWebView/ViewImplementation.h
+++ b/Libraries/LibWebView/ViewImplementation.h
@@ -109,6 +109,7 @@ public:
BrowsingSession& session() const { return *m_session; }
u64 view_id() const { return m_view_id; }
+ pid_t web_content_pid() const;
// A view that shows a page on behalf of another view, such as a Picture-in-Picture window, is part of that view's
// tab rather than a tab or window of its own.
@@ -187,6 +188,7 @@ public:
CheckForCancelation = CheckForCancelation::Yes,
Function<void()> on_ready = nullptr);
[[nodiscard]] Vector<SessionHistoryTraversalMenuItem> session_history_traversal_menu_items(int direction) const;
+ Vector<HistoryEntry> recent_history_entries(size_t limit) const;
[[nodiscard]] SessionHistorySnapshot session_history_snapshot() const;
[[nodiscard]] ErrorOr<void> restore_session_history_from_snapshot(SessionHistorySnapshot);
@@ -204,6 +206,17 @@ public:
double device_pixel_ratio() const { return m_device_pixel_ratio; }
Optional<u64> display_id() const { return m_display_id; }
double maximum_frames_per_second() const { return m_maximum_frames_per_second; }
+ // Sends the display metadata to every page hosting documents of the tab.
+ void set_display_metadata(Optional<u64> display_id, double maximum_frames_per_second);
+
+ struct ScreenRects {
+ Vector<Web::DevicePixelRect> rects;
+ // The available rects leave out what the system keeps for itself, such as a menu bar or a dock.
+ Vector<Web::DevicePixelRect> available_rects;
+ u32 main_screen_index { 0 };
+ };
+ // Sends the screens that screen_rects() reports to every page hosting documents of the tab.
+ void update_screen_rects();
void set_scales_frames_to_fit(bool scales_frames_to_fit) { m_scales_frames_to_fit = scales_frames_to_fit; }
void enable_picture_in_picture_controls();
void enqueue_input_event(Web::InputEvent);
@@ -243,7 +256,9 @@ public:
void set_preferred_motion(Web::CSS::PreferredMotion);
// A page created to host documents of the tab in another process takes the preferences the view's page has.
void send_preferences_to_page(WebContentPage&);
- virtual void send_system_theme_to_page(WebContentPage&) { }
+ void send_system_theme_to_page(WebContentPage&);
+ // Sends the theme to every page hosting documents of the tab, including the pages of out-of-process iframes.
+ void update_system_theme(Core::AnonymousBuffer const&);
void notify_cookies_changed(HashTable<String> const& changed_domains, ReadonlySpan<HTTP::Cookie::Cookie> page_cookies, ReadonlySpan<HTTP::Cookie::Cookie> host_cookies);
void listen_for_host_cookie_changes(DevTools::DevToolsDelegate::OnHostCookieChange);
@@ -613,6 +628,10 @@ protected:
static constexpr auto ZOOM_STEP = 0.1;
+ virtual Core::AnonymousBuffer system_theme() { return {}; }
+ virtual Optional<ScreenRects> screen_rects() const { return {}; }
+ void update_compositor_display_metadata(WebContentPage&);
+
explicit ViewImplementation(IsPrivate = IsPrivate::No);
void set_owner_view(ViewImplementation const& owner_view) { m_owner_view_id = owner_view.view_id(); }
diff --git a/Tests/LibWeb/test-web/TestWebView.cpp b/Tests/LibWeb/test-web/TestWebView.cpp
index 49257cc94ad..c2a20f1938a 100644
--- a/Tests/LibWeb/test-web/TestWebView.cpp
+++ b/Tests/LibWeb/test-web/TestWebView.cpp
@@ -56,11 +56,6 @@ NonnullRefPtr<Core::Promise<Empty>> TestWebView::reset_session_history()
return WebView::ViewImplementation::reset_session_history_for_testing();
}
-pid_t TestWebView::web_content_pid() const
-{
- return page().client().pid();
-}
-
NonnullRefPtr<Core::Promise<RefPtr<Gfx::Bitmap const>>> TestWebView::take_screenshot()
{
VERIFY(!m_pending_screenshot);
diff --git a/Tests/LibWeb/test-web/TestWebView.h b/Tests/LibWeb/test-web/TestWebView.h
index 69800e304ae..5babdb54a81 100644
--- a/Tests/LibWeb/test-web/TestWebView.h
+++ b/Tests/LibWeb/test-web/TestWebView.h
@@ -27,7 +27,6 @@ public:
void reset_line_box_borders();
void reset_geolocation_emulated_position();
NonnullRefPtr<Core::Promise<Empty>> reset_session_history();
- pid_t web_content_pid() const;
NonnullRefPtr<Core::Promise<RefPtr<Gfx::Bitmap const>>> take_screenshot();
diff --git a/UI/Qt/Menu.cpp b/UI/Qt/Menu.cpp
index e9ac0bf44c3..990775b201e 100644
--- a/UI/Qt/Menu.cpp
+++ b/UI/Qt/Menu.cpp
@@ -435,7 +435,7 @@ void update_history_menu(QMenu& menu, WebContentView* view)
insert_dynamic_history_action(menu, insertion_point, *create_history_navigation_action(menu, *view, view->navigate_forward_action(), QKeySequence::StandardKey::Forward));
insert_dynamic_history_action(menu, insertion_point, *create_dynamic_history_separator(menu));
- auto entries = view->session().history_store->list_entries({}, 0, RECENT_HISTORY_MENU_ITEM_LIMIT);
+ auto entries = view->recent_history_entries(RECENT_HISTORY_MENU_ITEM_LIMIT);
for (auto const& entry : entries) {
auto* action = create_recent_history_menu_action(menu, *view, entry);
insert_dynamic_history_action(menu, insertion_point, *action);
diff --git a/UI/Qt/ProcessManagerWindow.cpp b/UI/Qt/ProcessManagerWindow.cpp
index cd89b28429a..cf45c10e019 100644
--- a/UI/Qt/ProcessManagerWindow.cpp
+++ b/UI/Qt/ProcessManagerWindow.cpp
@@ -7,10 +7,8 @@
#include <AK/HashMap.h>
#include <AK/kmalloc.h>
#include <LibURL/InternalURLs.h>
-#include <LibWebView/Application.h>
-#include <LibWebView/CanonicalTraversable.h>
-#include <LibWebView/FaviconStore.h>
-#include <LibWebView/ViewImplementation.h>
+#include <LibWebView/ProcessManager.h>
+#include <LibWebView/ProcessSnapshot.h>
#include <UI/Qt/BrandColors.h>
#include <UI/Qt/ChromeStyle.h>
#include <UI/Qt/Icon.h>
@@ -160,18 +158,18 @@ class ProcessItem final : public QTreeWidgetItem {
public:
AK_ALLOC_WITH_KMALLOC;
- void update_page_icon(WebView::ViewImplementation const* view, QIcon const& fallback)
+ void update_page_icon(WebView::ProcessPageSnapshot const* page, QIcon const& fallback)
{
- auto view_id = view ? Optional<u64> { view->view_id() } : Optional<u64> {};
- auto favicon_hash = view ? view->favicon_hash() : Optional<String> {};
- auto url = view ? Optional<URL::URL> { view->url() } : Optional<URL::URL> {};
+ auto view_id = page ? Optional<u64> { page->view_id } : Optional<u64> {};
+ auto favicon_hash = page ? page->favicon_hash : Optional<String> {};
+ auto url = page ? Optional<URL::URL> { page->url } : Optional<URL::URL> {};
if (view_id != m_view_id || favicon_hash != m_favicon_hash || url != m_url) {
m_view_id = view_id;
m_favicon_hash = favicon_hash;
m_url = url;
m_favicon = {};
- if (view && favicon_hash.has_value()) {
- if (auto png = view->session().favicon_store->favicon_png(*favicon_hash); png.has_value())
+ if (page) {
+ if (auto png = WebView::favicon_png_for_page(*page); png.has_value())
m_favicon = icon_from_png(png->bytes(), 16);
}
}
@@ -357,8 +355,7 @@ void ProcessManagerWindow::hideEvent(QHideEvent* event)
void ProcessManagerWindow::refresh()
{
- auto& manager = m_process_manager;
- manager.update_all_process_statistics();
+ auto processes = WebView::process_snapshots(m_process_manager);
auto scroll_position = m_processes->verticalScrollBar()->value();
auto selected_child_id = m_processes->currentItem() && m_processes->currentItem()->isSelected() ? m_processes->currentItem()->data(PID, ChildIDRole) : QVariant {};
@@ -394,68 +391,36 @@ void ProcessManagerWindow::refresh()
auto service_icon = create_chrome_icon(ChromeIcon::WindowRestore, muted_palette);
auto spare_icon = create_chrome_icon(ChromeIcon::WindowMaximize, muted_palette);
- enum class PageKind {
- TopLevel,
- Frame,
- };
- struct ProcessPage {
- WebView::ViewImplementation* view;
- URL::URL url;
- PageKind kind;
- };
- HashMap<pid_t, ProcessPage> process_pages;
- WebView::ViewImplementation::for_each_view([&](auto& view) {
- // An owned view's page shares its owner's process, which the owner's tab already lists.
- if (view.owner_view_id().has_value())
- return IterationDecision::Continue;
- auto active_view = WebView::Application::the().active_web_view();
- auto priority = [&](auto const& candidate) {
- if (active_view.has_value() && &*active_view == &candidate)
- return 2;
- return candidate.traversable().system_visibility_state() == Web::HTML::VisibilityState::Visible ? 1 : 0;
- };
- auto add_page = [&](pid_t pid, URL::URL const& url, PageKind kind) {
- auto current = process_pages.get(pid);
- if (!current.has_value() || priority(view) > priority(*current->view)
- || (priority(view) == priority(*current->view) && view.view_id() < current->view->view_id())
- || (current->view == &view && kind == PageKind::TopLevel && current->kind == PageKind::Frame))
- process_pages.set(pid, ProcessPage { &view, url, kind });
- };
- add_page(view.page().client().pid(), view.url(), PageKind::TopLevel);
- view.traversable().for_each_in_subtree([&](auto const& navigable) {
- if (navigable.has_remote_host() && navigable.replicated_state().has_value())
- add_page(navigable.remote_host().client().pid(), navigable.replicated_state()->active_document_url, PageKind::Frame);
- return IterationDecision::Continue;
- });
- return IterationDecision::Continue;
- });
- manager.for_each_process_statistics([&](auto& process, auto const& statistics) {
- auto* item = static_cast<ProcessItem*>(items.take(process.child_id()).value_or_lazy_evaluated([] { return new ProcessItem; }));
- auto name = qstring_from_ak_string(WebView::process_name_from_type(process.type()));
- if (process.type() == WebView::ProcessType::WebContent || process.type() == WebView::ProcessType::ImageDecoder) {
+ HashMap<u64, WebView::ProcessSnapshot const*> processes_by_child_id;
+ for (auto const& process : processes)
+ processes_by_child_id.set(process.child_id, &process);
+
+ for (auto const& process : processes) {
+ auto* item = static_cast<ProcessItem*>(items.take(process.child_id).value_or_lazy_evaluated([] { return new ProcessItem; }));
+ auto name = qstring_from_ak_string(WebView::process_name_from_type(process.type));
+ if (process.type == WebView::ProcessType::WebContent || process.type == WebView::ProcessType::ImageDecoder) {
auto* label_process = &process;
- if (process.type() == WebView::ProcessType::ImageDecoder && process.owner_child_id().has_value()) {
- if (auto owner = manager.find_child(*process.owner_child_id()); owner.has_value())
- label_process = &*owner;
+ if (process.type == WebView::ProcessType::ImageDecoder && process.owner_child_id.has_value()) {
+ if (auto owner = processes_by_child_id.get(*process.owner_child_id); owner.has_value())
+ label_process = *owner;
}
- auto page = process_pages.get(label_process->pid());
- auto* view = page.has_value() ? page->view : nullptr;
- bool is_spare = label_process->title().has_value() && *label_process->title() == "(spare)"_utf16;
- if (view) {
+ auto const& page = label_process->page;
+ bool is_spare = label_process->title.has_value() && *label_process->title == "(spare)"_utf16;
+ if (page.has_value()) {
auto site = task_manager_site_label(page->url);
if (!site.isEmpty())
name += QStringLiteral(" — ") + site;
- } else if (label_process->title().has_value()) {
- name += QStringLiteral(" — ") + qstring_from_utf16_string(*label_process->title());
+ } else if (label_process->title.has_value()) {
+ name += QStringLiteral(" — ") + qstring_from_utf16_string(*label_process->title);
}
- if (process.type() == WebView::ProcessType::WebContent)
- item->update_page_icon(page.has_value() && page->url != URL::about_blank() ? view : nullptr, is_spare ? spare_icon : web_content_icon);
+ if (process.type == WebView::ProcessType::WebContent)
+ item->update_page_icon(page.has_value() && page->url != URL::about_blank() ? &*page : nullptr, is_spare ? spare_icon : web_content_icon);
else
item->setIcon(Name, service_icon);
} else {
- if (process.title().has_value())
- name += QStringLiteral(" — ") + qstring_from_utf16_string(*process.title());
- if (process.type() == WebView::ProcessType::Browser) {
+ if (process.title.has_value())
+ name += QStringLiteral(" — ") + qstring_from_utf16_string(*process.title);
+ if (process.type == WebView::ProcessType::Browser) {
browser_item = item;
item->setIcon(Name, browser_icon);
} else {
@@ -464,19 +429,19 @@ void ProcessManagerWindow::refresh()
}
item->setText(Name, name);
item->setToolTip(Name, name);
- item->setText(PID, QString::number(statistics.pid));
- item->setText(CPU, locale.toString(statistics.cpu_percent, 'f', 2) + '%');
- item->setText(Memory, locale.formattedDataSize(statistics.memory_usage_bytes, 2));
- item->setData(PID, Qt::UserRole, static_cast<qlonglong>(statistics.pid));
- item->setData(PID, ChildIDRole, static_cast<qulonglong>(process.child_id()));
- item->setData(CPU, Qt::UserRole, statistics.cpu_percent);
- item->setData(Memory, Qt::UserRole, static_cast<qulonglong>(statistics.memory_usage_bytes));
+ item->setText(PID, QString::number(process.pid));
+ item->setText(CPU, locale.toString(process.cpu_percent, 'f', 2) + '%');
+ item->setText(Memory, locale.formattedDataSize(process.memory_usage_bytes, 2));
+ item->setData(PID, Qt::UserRole, static_cast<qlonglong>(process.pid));
+ item->setData(PID, ChildIDRole, static_cast<qulonglong>(process.child_id));
+ item->setData(CPU, Qt::UserRole, process.cpu_percent);
+ item->setData(Memory, Qt::UserRole, static_cast<qulonglong>(process.memory_usage_bytes));
for (auto column : { PID, CPU, Memory })
item->setTextAlignment(column, Qt::AlignRight | Qt::AlignVCenter);
- live_items.set(process.child_id(), item);
- total_cpu += statistics.cpu_percent;
- total_memory += statistics.memory_usage_bytes;
- });
+ live_items.set(process.child_id, item);
+ total_cpu += process.cpu_percent;
+ total_memory += process.memory_usage_bytes;
+ }
for (auto& entry : items)
delete entry.value;
for (auto& entry : live_items) {
diff --git a/UI/Qt/Tab.cpp b/UI/Qt/Tab.cpp
index c1a556f790e..dadf7c34fde 100644
--- a/UI/Qt/Tab.cpp
+++ b/UI/Qt/Tab.cpp
@@ -1446,7 +1446,7 @@ QString Tab::title() const
if (!WebView::Application::settings().config_variable_as_bool(WebView::ConfigVariableID::ShowWebContentProcessIDInTabTitle))
return title;
- return QString("%1 [%2]").arg(title).arg(view().page().client().pid());
+ return QString("%1 [%2]").arg(title).arg(view().web_content_pid());
}
// A tab opened only for a review shows it over a blank page, under the review's own title if it has one, and closing it
diff --git a/UI/Qt/WebContentView.cpp b/UI/Qt/WebContentView.cpp
index 0f894d37d96..fbea95c88e6 100644
--- a/UI/Qt/WebContentView.cpp
+++ b/UI/Qt/WebContentView.cpp
@@ -1755,30 +1755,6 @@ void WebContentView::set_zoom_level(double zoom_level)
update_zoom();
}
-void WebContentView::set_maximum_frames_per_second(double maximum_frames_per_second)
-{
- set_display_metadata(m_display_id, maximum_frames_per_second);
-}
-
-void WebContentView::set_display_metadata(Optional<u64> display_id, double maximum_frames_per_second)
-{
- m_display_id = display_id;
- m_maximum_frames_per_second = maximum_frames_per_second;
- page().async_set_maximum_frames_per_second(m_maximum_frames_per_second);
- update_compositor_display_metadata();
-}
-
-void WebContentView::update_compositor_display_metadata()
-{
- update_compositor_display_metadata(page());
-}
-
-void WebContentView::update_compositor_display_metadata(WebView::WebContentPage& page)
-{
- auto compositor_context_id = page.compositor_context_id();
- WebView::Application::the().update_compositor_display_metadata(compositor_context_id, m_display_id, m_maximum_frames_per_second);
-}
-
void WebContentView::update_viewport_size()
{
auto scaled_width = int(width() * m_device_pixel_ratio);
@@ -1887,15 +1863,12 @@ void WebContentView::update_palette(PaletteMode mode)
// NB: Every page hosting documents of this tab takes the palette, including the pages of out-of-process iframes.
// Their prefers-color-scheme and system colors resolve against it.
- auto theme = make_system_theme_from_qt_palette(*this, mode);
- traversable().for_each_hosting_page([&](WebView::WebContentPage& page) {
- page.async_update_system_theme(theme);
- });
+ update_system_theme(make_system_theme_from_qt_palette(*this, mode));
}
-void WebContentView::send_system_theme_to_page(WebView::WebContentPage& page)
+Core::AnonymousBuffer WebContentView::system_theme()
{
- page.async_update_system_theme(make_system_theme_from_qt_palette(*this, PaletteMode::Default));
+ return make_system_theme_from_qt_palette(*this, PaletteMode::Default);
}
#if !defined(Q_OS_MACOS) && !defined(Q_OS_WIN)
@@ -1976,20 +1949,12 @@ void WebContentView::watch_screen_geometry(QScreen& screen)
});
}
-void WebContentView::update_screen_rects()
-{
- traversable().for_each_hosting_page([&](WebView::WebContentPage& page) {
- update_screen_rects(page);
- });
-}
-
-void WebContentView::update_screen_rects(WebView::WebContentPage& page)
+Optional<WebView::ViewImplementation::ScreenRects> WebContentView::screen_rects() const
{
auto screens = QGuiApplication::screens();
if (!screens.empty()) {
- Vector<Web::DevicePixelRect> screen_rects;
- Vector<Web::DevicePixelRect> available_screen_rects;
+ ScreenRects result;
for (auto const& screen : screens) {
// NOTE: QScreen::geometry() returns the 'device-independent pixels', we multiply
// by the device pixel ratio to get the 'physical pixels' of the display.
@@ -1997,16 +1962,16 @@ void WebContentView::update_screen_rects(WebView::WebContentPage& page)
auto to_device_pixels = [&](QRect const& geometry) {
return Web::DevicePixelRect(geometry.x() * device_pixel_ratio, geometry.y() * device_pixel_ratio, geometry.width() * device_pixel_ratio, geometry.height() * device_pixel_ratio);
};
- screen_rects.append(to_device_pixels(screen->geometry()));
- // The available geometry leaves out what the system keeps for itself, such as a menu bar or a dock.
- available_screen_rects.append(to_device_pixels(screen->availableGeometry()));
+ result.rects.append(to_device_pixels(screen->geometry()));
+ result.available_rects.append(to_device_pixels(screen->availableGeometry()));
}
// 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.
- page.async_update_screen_rects(screen_rects, available_screen_rects, 0);
+ // always returns the first item in the list if it isn't empty, so main_screen_index stays 0.
+ return result;
}
+ return {};
}
void WebContentView::prepare_page_for_navigable(WebView::WebContentPage& page)
@@ -2014,7 +1979,6 @@ void WebContentView::prepare_page_for_navigable(WebView::WebContentPage& page)
ViewImplementation::prepare_page_for_navigable(page);
update_compositor_display_metadata(page);
- update_screen_rects(page);
}
void WebContentView::update_cursor(Gfx::Cursor cursor)
diff --git a/UI/Qt/WebContentView.h b/UI/Qt/WebContentView.h
index ad5146065d2..d508df40ef3 100644
--- a/UI/Qt/WebContentView.h
+++ b/UI/Qt/WebContentView.h
@@ -148,8 +148,6 @@ public:
void push_viewport_size();
void set_device_pixel_ratio(double);
void set_zoom_level(double);
- void set_maximum_frames_per_second(double);
- void set_display_metadata(Optional<u64> display_id, double maximum_frames_per_second);
void set_vertical_tab_overlay_insets(int left, int right);
void set_bookmarks_bar_overlay_height(int);
void prepare_for_window_move();
@@ -188,7 +186,8 @@ signals:
private:
// ^WebView::ViewImplementation
virtual void prepare_page_for_navigable(WebView::WebContentPage&) override;
- virtual void send_system_theme_to_page(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;
@@ -217,9 +216,6 @@ private:
#ifdef LADYBIRD_QT_USE_RHI_WIDGET
void schedule_frame_damage_repaint();
#endif
- void update_compositor_display_metadata();
- void update_compositor_display_metadata(WebView::WebContentPage&);
-
Web::DevicePixelPoint node_picker_position_for(QSinglePointEvent const&) const;
void enqueue_native_event(Web::MouseEvent::Type, QSinglePointEvent const& event);
@@ -232,8 +228,6 @@ private:
void finish_handling_key_event(Web::KeyEvent const&);
void watch_screen_geometry(QScreen&);
- void update_screen_rects();
- void update_screen_rects(WebView::WebContentPage&);
void set_crash_overlay_visible(bool);
void show_crash_report_review(Optional<ByteString> const& hidden_crash_report_name = {});