Browse Source

Ladybird+LibWebView: Move options used to launch WebContent to a struct

It is currently a bit messy to pass these options along from main() to
where WebContent is actually launched. If a new flag were to be added,
there are a couple dozen files that need to be updated to pass that flag
along. With this change, the flag can just be added to the struct, set
in main(), and handled in launch_web_content_process().
Timothy Flynn 1 year ago
parent
commit
07e9a8f79b

+ 3 - 0
Ladybird/AppKit/Application/ApplicationDelegate.h

@@ -10,6 +10,7 @@
 #include <AK/StringView.h>
 #include <AK/StringView.h>
 #include <AK/URL.h>
 #include <AK/URL.h>
 #include <AK/Vector.h>
 #include <AK/Vector.h>
+#include <Ladybird/Types.h>
 #include <LibWeb/CSS/PreferredColorScheme.h>
 #include <LibWeb/CSS/PreferredColorScheme.h>
 #include <LibWeb/HTML/ActivateTab.h>
 #include <LibWeb/HTML/ActivateTab.h>
 #include <LibWebView/CookieJar.h>
 #include <LibWebView/CookieJar.h>
@@ -24,6 +25,7 @@
 - (nullable instancetype)init:(Vector<URL>)initial_urls
 - (nullable instancetype)init:(Vector<URL>)initial_urls
                 newTabPageURL:(URL)new_tab_page_url
                 newTabPageURL:(URL)new_tab_page_url
                 withCookieJar:(WebView::CookieJar)cookie_jar
                 withCookieJar:(WebView::CookieJar)cookie_jar
+            webContentOptions:(Ladybird::WebContentOptions const&)web_content_options
       webdriverContentIPCPath:(StringView)webdriver_content_ipc_path;
       webdriverContentIPCPath:(StringView)webdriver_content_ipc_path;
 
 
 - (nonnull TabController*)createNewTab:(Optional<URL> const&)url
 - (nonnull TabController*)createNewTab:(Optional<URL> const&)url
@@ -38,6 +40,7 @@
 - (void)removeTab:(nonnull TabController*)controller;
 - (void)removeTab:(nonnull TabController*)controller;
 
 
 - (WebView::CookieJar&)cookieJar;
 - (WebView::CookieJar&)cookieJar;
+- (Ladybird::WebContentOptions const&)webContentOptions;
 - (Optional<StringView> const&)webdriverContentIPCPath;
 - (Optional<StringView> const&)webdriverContentIPCPath;
 - (Web::CSS::PreferredColorScheme)preferredColorScheme;
 - (Web::CSS::PreferredColorScheme)preferredColorScheme;
 - (WebView::SearchEngine const&)searchEngine;
 - (WebView::SearchEngine const&)searchEngine;

+ 9 - 0
Ladybird/AppKit/Application/ApplicationDelegate.mm

@@ -25,6 +25,7 @@
     // This will always be populated, but we cannot have a non-default constructible instance variable.
     // This will always be populated, but we cannot have a non-default constructible instance variable.
     Optional<WebView::CookieJar> m_cookie_jar;
     Optional<WebView::CookieJar> m_cookie_jar;
 
 
+    Ladybird::WebContentOptions m_web_content_options;
     Optional<StringView> m_webdriver_content_ipc_path;
     Optional<StringView> m_webdriver_content_ipc_path;
 
 
     Web::CSS::PreferredColorScheme m_preferred_color_scheme;
     Web::CSS::PreferredColorScheme m_preferred_color_scheme;
@@ -52,6 +53,7 @@
 - (instancetype)init:(Vector<URL>)initial_urls
 - (instancetype)init:(Vector<URL>)initial_urls
               newTabPageURL:(URL)new_tab_page_url
               newTabPageURL:(URL)new_tab_page_url
               withCookieJar:(WebView::CookieJar)cookie_jar
               withCookieJar:(WebView::CookieJar)cookie_jar
+          webContentOptions:(Ladybird::WebContentOptions const&)web_content_options
     webdriverContentIPCPath:(StringView)webdriver_content_ipc_path
     webdriverContentIPCPath:(StringView)webdriver_content_ipc_path
 {
 {
     if (self = [super init]) {
     if (self = [super init]) {
@@ -75,6 +77,8 @@
 
 
         m_cookie_jar = move(cookie_jar);
         m_cookie_jar = move(cookie_jar);
 
 
+        m_web_content_options = web_content_options;
+
         if (!webdriver_content_ipc_path.is_empty()) {
         if (!webdriver_content_ipc_path.is_empty()) {
             m_webdriver_content_ipc_path = webdriver_content_ipc_path;
             m_webdriver_content_ipc_path = webdriver_content_ipc_path;
         }
         }
@@ -122,6 +126,11 @@
     return *m_cookie_jar;
     return *m_cookie_jar;
 }
 }
 
 
+- (Ladybird::WebContentOptions const&)webContentOptions
+{
+    return m_web_content_options;
+}
+
 - (Optional<StringView> const&)webdriverContentIPCPath
 - (Optional<StringView> const&)webdriverContentIPCPath
 {
 {
     return m_webdriver_content_ipc_path;
     return m_webdriver_content_ipc_path;

+ 1 - 1
Ladybird/AppKit/UI/LadybirdWebView.mm

@@ -93,7 +93,7 @@ struct HideCursor {
         // This returns device pixel ratio of the screen the window is opened in
         // This returns device pixel ratio of the screen the window is opened in
         auto device_pixel_ratio = [[NSScreen mainScreen] backingScaleFactor];
         auto device_pixel_ratio = [[NSScreen mainScreen] backingScaleFactor];
 
 
-        m_web_view_bridge = MUST(Ladybird::WebViewBridge::create(move(screen_rects), device_pixel_ratio, [delegate webdriverContentIPCPath], [delegate preferredColorScheme]));
+        m_web_view_bridge = MUST(Ladybird::WebViewBridge::create(move(screen_rects), device_pixel_ratio, [delegate webContentOptions], [delegate webdriverContentIPCPath], [delegate preferredColorScheme]));
         [self setWebViewCallbacks];
         [self setWebViewCallbacks];
 
 
         auto* area = [[NSTrackingArea alloc] initWithRect:[self bounds]
         auto* area = [[NSTrackingArea alloc] initWithRect:[self bounds]

+ 7 - 6
Ladybird/AppKit/UI/LadybirdWebViewBridge.cpp

@@ -23,19 +23,20 @@ static T scale_for_device(T size, float device_pixel_ratio)
     return size.template to_type<float>().scaled(device_pixel_ratio).template to_type<int>();
     return size.template to_type<float>().scaled(device_pixel_ratio).template to_type<int>();
 }
 }
 
 
-ErrorOr<NonnullOwnPtr<WebViewBridge>> WebViewBridge::create(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, Optional<StringView> webdriver_content_ipc_path, Web::CSS::PreferredColorScheme preferred_color_scheme)
+ErrorOr<NonnullOwnPtr<WebViewBridge>> WebViewBridge::create(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, WebContentOptions const& web_content_options, Optional<StringView> webdriver_content_ipc_path, Web::CSS::PreferredColorScheme preferred_color_scheme)
 {
 {
-    return adopt_nonnull_own_or_enomem(new (nothrow) WebViewBridge(move(screen_rects), device_pixel_ratio, move(webdriver_content_ipc_path), preferred_color_scheme));
+    return adopt_nonnull_own_or_enomem(new (nothrow) WebViewBridge(move(screen_rects), device_pixel_ratio, web_content_options, move(webdriver_content_ipc_path), preferred_color_scheme));
 }
 }
 
 
-WebViewBridge::WebViewBridge(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, Optional<StringView> webdriver_content_ipc_path, Web::CSS::PreferredColorScheme preferred_color_scheme)
+WebViewBridge::WebViewBridge(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, WebContentOptions const& web_content_options, Optional<StringView> webdriver_content_ipc_path, Web::CSS::PreferredColorScheme preferred_color_scheme)
     : m_screen_rects(move(screen_rects))
     : m_screen_rects(move(screen_rects))
+    , m_web_content_options(web_content_options)
     , m_webdriver_content_ipc_path(move(webdriver_content_ipc_path))
     , m_webdriver_content_ipc_path(move(webdriver_content_ipc_path))
     , m_preferred_color_scheme(preferred_color_scheme)
     , m_preferred_color_scheme(preferred_color_scheme)
 {
 {
     m_device_pixel_ratio = device_pixel_ratio;
     m_device_pixel_ratio = device_pixel_ratio;
 
 
-    create_client(WebView::EnableCallgrindProfiling::No);
+    create_client();
 
 
     on_scroll_by_delta = [this](auto x_delta, auto y_delta) {
     on_scroll_by_delta = [this](auto x_delta, auto y_delta) {
         auto position = m_viewport_rect.location();
         auto position = m_viewport_rect.location();
@@ -184,12 +185,12 @@ Gfx::IntPoint WebViewBridge::to_widget_position(Gfx::IntPoint content_position)
     return scale_for_device(content_position, inverse_device_pixel_ratio());
     return scale_for_device(content_position, inverse_device_pixel_ratio());
 }
 }
 
 
-void WebViewBridge::create_client(WebView::EnableCallgrindProfiling enable_callgrind_profiling)
+void WebViewBridge::create_client()
 {
 {
     m_client_state = {};
     m_client_state = {};
 
 
     auto candidate_web_content_paths = MUST(get_paths_for_helper_process("WebContent"sv));
     auto candidate_web_content_paths = MUST(get_paths_for_helper_process("WebContent"sv));
-    auto new_client = MUST(launch_web_content_process(*this, candidate_web_content_paths, enable_callgrind_profiling, WebView::IsLayoutTestMode::No, Ladybird::UseLagomNetworking::Yes, WebView::EnableGPUPainting::No));
+    auto new_client = MUST(launch_web_content_process(*this, candidate_web_content_paths, m_web_content_options));
 
 
     m_client_state.client = new_client;
     m_client_state.client = new_client;
     m_client_state.client->on_web_content_process_crash = [this] {
     m_client_state.client->on_web_content_process_crash = [this] {

+ 6 - 3
Ladybird/AppKit/UI/LadybirdWebViewBridge.h

@@ -7,6 +7,7 @@
 #pragma once
 #pragma once
 
 
 #include <AK/Vector.h>
 #include <AK/Vector.h>
+#include <Ladybird/Types.h>
 #include <LibGfx/Point.h>
 #include <LibGfx/Point.h>
 #include <LibGfx/Rect.h>
 #include <LibGfx/Rect.h>
 #include <LibGfx/Size.h>
 #include <LibGfx/Size.h>
@@ -22,7 +23,7 @@ namespace Ladybird {
 
 
 class WebViewBridge final : public WebView::ViewImplementation {
 class WebViewBridge final : public WebView::ViewImplementation {
 public:
 public:
-    static ErrorOr<NonnullOwnPtr<WebViewBridge>> create(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, Optional<StringView> webdriver_content_ipc_path, Web::CSS::PreferredColorScheme);
+    static ErrorOr<NonnullOwnPtr<WebViewBridge>> create(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, WebContentOptions const&, Optional<StringView> webdriver_content_ipc_path, Web::CSS::PreferredColorScheme);
     virtual ~WebViewBridge() override;
     virtual ~WebViewBridge() override;
 
 
     float device_pixel_ratio() const { return m_device_pixel_ratio; }
     float device_pixel_ratio() const { return m_device_pixel_ratio; }
@@ -59,19 +60,21 @@ public:
     Function<void(Gfx::IntPoint)> on_scroll;
     Function<void(Gfx::IntPoint)> on_scroll;
 
 
 private:
 private:
-    WebViewBridge(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, Optional<StringView> webdriver_content_ipc_path, Web::CSS::PreferredColorScheme);
+    WebViewBridge(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, WebContentOptions const&, Optional<StringView> webdriver_content_ipc_path, Web::CSS::PreferredColorScheme);
 
 
     virtual void update_zoom() override;
     virtual void update_zoom() override;
     virtual Gfx::IntRect viewport_rect() const override;
     virtual Gfx::IntRect viewport_rect() const override;
     virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) 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 Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override;
 
 
-    virtual void create_client(WebView::EnableCallgrindProfiling) override;
+    virtual void create_client() override;
 
 
     Vector<Gfx::IntRect> m_screen_rects;
     Vector<Gfx::IntRect> m_screen_rects;
     Gfx::IntRect m_viewport_rect;
     Gfx::IntRect m_viewport_rect;
 
 
+    WebContentOptions m_web_content_options;
     Optional<StringView> m_webdriver_content_ipc_path;
     Optional<StringView> m_webdriver_content_ipc_path;
+
     Web::CSS::PreferredColorScheme m_preferred_color_scheme { Web::CSS::PreferredColorScheme::Auto };
     Web::CSS::PreferredColorScheme m_preferred_color_scheme { Web::CSS::PreferredColorScheme::Auto };
 };
 };
 
 

+ 6 - 0
Ladybird/AppKit/main.mm

@@ -5,6 +5,7 @@
  */
  */
 
 
 #include <BrowserSettings/Defaults.h>
 #include <BrowserSettings/Defaults.h>
+#include <Ladybird/Types.h>
 #include <Ladybird/Utilities.h>
 #include <Ladybird/Utilities.h>
 #include <LibCore/ArgsParser.h>
 #include <LibCore/ArgsParser.h>
 #include <LibCore/EventLoop.h>
 #include <LibCore/EventLoop.h>
@@ -61,9 +62,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     if (initial_urls.is_empty())
     if (initial_urls.is_empty())
         initial_urls.append(new_tab_page_url);
         initial_urls.append(new_tab_page_url);
 
 
+    Ladybird::WebContentOptions web_content_options {
+        .use_lagom_networking = Ladybird::UseLagomNetworking::Yes,
+    };
+
     auto* delegate = [[ApplicationDelegate alloc] init:move(initial_urls)
     auto* delegate = [[ApplicationDelegate alloc] init:move(initial_urls)
                                          newTabPageURL:move(new_tab_page_url)
                                          newTabPageURL:move(new_tab_page_url)
                                          withCookieJar:move(cookie_jar)
                                          withCookieJar:move(cookie_jar)
+                                     webContentOptions:web_content_options
                                webdriverContentIPCPath:webdriver_content_ipc_path];
                                webdriverContentIPCPath:webdriver_content_ipc_path];
 
 
     [NSApp setDelegate:delegate];
     [NSApp setDelegate:delegate];

+ 8 - 10
Ladybird/HelperProcess.cpp

@@ -6,12 +6,10 @@
 
 
 #include "HelperProcess.h"
 #include "HelperProcess.h"
 
 
-ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(WebView::ViewImplementation& view,
+ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
+    WebView::ViewImplementation& view,
     ReadonlySpan<String> candidate_web_content_paths,
     ReadonlySpan<String> candidate_web_content_paths,
-    WebView::EnableCallgrindProfiling enable_callgrind_profiling,
-    WebView::IsLayoutTestMode is_layout_test_mode,
-    Ladybird::UseLagomNetworking use_lagom_networking,
-    WebView::EnableGPUPainting enable_gpu_painting)
+    Ladybird::WebContentOptions const& web_content_options)
 {
 {
     int socket_fds[2] {};
     int socket_fds[2] {};
     TRY(Core::System::socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fds));
     TRY(Core::System::socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fds));
@@ -49,13 +47,13 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(Web
                 "--webcontent-fd-passing-socket"sv,
                 "--webcontent-fd-passing-socket"sv,
                 webcontent_fd_passing_socket_string
                 webcontent_fd_passing_socket_string
             };
             };
-            if (enable_callgrind_profiling == WebView::EnableCallgrindProfiling::No)
+            if (web_content_options.enable_callgrind_profiling == Ladybird::EnableCallgrindProfiling::No)
                 arguments.remove(0, callgrind_prefix_length);
                 arguments.remove(0, callgrind_prefix_length);
-            if (is_layout_test_mode == WebView::IsLayoutTestMode::Yes)
+            if (web_content_options.is_layout_test_mode == Ladybird::IsLayoutTestMode::Yes)
                 arguments.append("--layout-test-mode"sv);
                 arguments.append("--layout-test-mode"sv);
-            if (use_lagom_networking == Ladybird::UseLagomNetworking::Yes)
+            if (web_content_options.use_lagom_networking == Ladybird::UseLagomNetworking::Yes)
                 arguments.append("--use-lagom-networking"sv);
                 arguments.append("--use-lagom-networking"sv);
-            if (enable_gpu_painting == WebView::EnableGPUPainting::Yes)
+            if (web_content_options.enable_gpu_painting == Ladybird::EnableGPUPainting::Yes)
                 arguments.append("--use-gpu-painting"sv);
                 arguments.append("--use-gpu-painting"sv);
 
 
             result = Core::System::exec(arguments[0], arguments.span(), Core::System::SearchInPath::Yes);
             result = Core::System::exec(arguments[0], arguments.span(), Core::System::SearchInPath::Yes);
@@ -77,7 +75,7 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(Web
     auto new_client = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) WebView::WebContentClient(move(socket), view)));
     auto new_client = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) WebView::WebContentClient(move(socket), view)));
     new_client->set_fd_passing_socket(TRY(Core::LocalSocket::adopt_fd(ui_fd_passing_fd)));
     new_client->set_fd_passing_socket(TRY(Core::LocalSocket::adopt_fd(ui_fd_passing_fd)));
 
 
-    if (enable_callgrind_profiling == WebView::EnableCallgrindProfiling::Yes) {
+    if (web_content_options.enable_callgrind_profiling == Ladybird::EnableCallgrindProfiling::Yes) {
         dbgln();
         dbgln();
         dbgln("\033[1;45mLaunched WebContent process under callgrind!\033[0m");
         dbgln("\033[1;45mLaunched WebContent process under callgrind!\033[0m");
         dbgln("\033[100mRun `\033[4mcallgrind_control -i on\033[24m` to start instrumentation and `\033[4mcallgrind_control -i off\033[24m` stop it again.\033[0m");
         dbgln("\033[100mRun `\033[4mcallgrind_control -i on\033[24m` to start instrumentation and `\033[4mcallgrind_control -i off\033[24m` stop it again.\033[0m");

+ 3 - 5
Ladybird/HelperProcess.h

@@ -16,12 +16,10 @@
 #include <LibWebView/ViewImplementation.h>
 #include <LibWebView/ViewImplementation.h>
 #include <LibWebView/WebContentClient.h>
 #include <LibWebView/WebContentClient.h>
 
 
-ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(WebView::ViewImplementation& view,
+ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
+    WebView::ViewImplementation& view,
     ReadonlySpan<String> candidate_web_content_paths,
     ReadonlySpan<String> candidate_web_content_paths,
-    WebView::EnableCallgrindProfiling,
-    WebView::IsLayoutTestMode,
-    Ladybird::UseLagomNetworking,
-    WebView::EnableGPUPainting);
+    Ladybird::WebContentOptions const&);
 
 
 ErrorOr<NonnullRefPtr<ImageDecoderClient::Client>> launch_image_decoder_process(ReadonlySpan<String> candidate_image_decoder_paths);
 ErrorOr<NonnullRefPtr<ImageDecoderClient::Client>> launch_image_decoder_process(ReadonlySpan<String> candidate_image_decoder_paths);
 ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(ReadonlySpan<String> candidate_request_server_paths, StringView serenity_resource_root);
 ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(ReadonlySpan<String> candidate_request_server_paths, StringView serenity_resource_root);

+ 3 - 5
Ladybird/Qt/BrowserWindow.cpp

@@ -42,12 +42,10 @@ static QIcon const& app_icon()
     return icon;
     return icon;
 }
 }
 
 
-BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar& cookie_jar, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, UseLagomNetworking use_lagom_networking, WebView::EnableGPUPainting use_gpu_painting)
+BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path)
     : m_cookie_jar(cookie_jar)
     : m_cookie_jar(cookie_jar)
+    , m_web_content_options(web_content_options)
     , m_webdriver_content_ipc_path(webdriver_content_ipc_path)
     , m_webdriver_content_ipc_path(webdriver_content_ipc_path)
-    , m_enable_callgrind_profiling(enable_callgrind_profiling)
-    , m_use_lagom_networking(use_lagom_networking)
-    , m_use_gpu_painting(use_gpu_painting)
 {
 {
     setWindowIcon(app_icon());
     setWindowIcon(app_icon());
     m_tabs_container = new QTabWidget(this);
     m_tabs_container = new QTabWidget(this);
@@ -464,7 +462,7 @@ Tab& BrowserWindow::new_tab(StringView html, Web::HTML::ActivateTab activate_tab
 
 
 Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
 Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
 {
 {
-    auto tab = make<Tab>(this, m_webdriver_content_ipc_path, m_enable_callgrind_profiling, m_use_lagom_networking, m_use_gpu_painting);
+    auto tab = make<Tab>(this, m_web_content_options, m_webdriver_content_ipc_path);
     auto tab_ptr = tab.ptr();
     auto tab_ptr = tab.ptr();
     m_tabs.append(std::move(tab));
     m_tabs.append(std::move(tab));
 
 

+ 4 - 4
Ladybird/Qt/BrowserWindow.h

@@ -8,6 +8,7 @@
 #pragma once
 #pragma once
 
 
 #include "Tab.h"
 #include "Tab.h"
+#include <Ladybird/Types.h>
 #include <LibCore/Forward.h>
 #include <LibCore/Forward.h>
 #include <LibWeb/HTML/ActivateTab.h>
 #include <LibWeb/HTML/ActivateTab.h>
 #include <LibWebView/Forward.h>
 #include <LibWebView/Forward.h>
@@ -24,8 +25,9 @@ class WebContentView;
 
 
 class BrowserWindow : public QMainWindow {
 class BrowserWindow : public QMainWindow {
     Q_OBJECT
     Q_OBJECT
+
 public:
 public:
-    explicit BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar&, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, UseLagomNetworking, WebView::EnableGPUPainting);
+    BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path);
 
 
     WebContentView& view() const { return m_current_tab->view(); }
     WebContentView& view() const { return m_current_tab->view(); }
 
 
@@ -118,10 +120,8 @@ private:
 
 
     WebView::CookieJar& m_cookie_jar;
     WebView::CookieJar& m_cookie_jar;
 
 
+    WebContentOptions m_web_content_options;
     StringView m_webdriver_content_ipc_path;
     StringView m_webdriver_content_ipc_path;
-    WebView::EnableCallgrindProfiling m_enable_callgrind_profiling;
-    UseLagomNetworking m_use_lagom_networking;
-    WebView::EnableGPUPainting m_use_gpu_painting;
 };
 };
 
 
 }
 }

+ 1 - 1
Ladybird/Qt/ConsoleWidget.cpp

@@ -25,7 +25,7 @@ ConsoleWidget::ConsoleWidget(WebContentView& content_view)
 {
 {
     setLayout(new QVBoxLayout);
     setLayout(new QVBoxLayout);
 
 
-    m_output_view = new WebContentView({}, WebView::EnableCallgrindProfiling::No, UseLagomNetworking::No, WebView::EnableGPUPainting::No);
+    m_output_view = new WebContentView({}, {});
     if (is_using_dark_system_theme(*this))
     if (is_using_dark_system_theme(*this))
         m_output_view->update_palette(WebContentView::PaletteMode::Dark);
         m_output_view->update_palette(WebContentView::PaletteMode::Dark);
 
 

+ 1 - 1
Ladybird/Qt/InspectorWidget.cpp

@@ -15,7 +15,7 @@ extern bool is_using_dark_system_theme(QWidget&);
 
 
 InspectorWidget::InspectorWidget(WebContentView& content_view)
 InspectorWidget::InspectorWidget(WebContentView& content_view)
 {
 {
-    m_inspector_view = make<WebContentView>(StringView {}, WebView::EnableCallgrindProfiling::No, UseLagomNetworking::No, WebView::EnableGPUPainting::No);
+    m_inspector_view = make<WebContentView>(WebContentOptions {}, StringView {});
 
 
     if (is_using_dark_system_theme(*this))
     if (is_using_dark_system_theme(*this))
         m_inspector_view->update_palette(WebContentView::PaletteMode::Dark);
         m_inspector_view->update_palette(WebContentView::PaletteMode::Dark);

+ 2 - 2
Ladybird/Qt/Tab.cpp

@@ -52,7 +52,7 @@ static QIcon create_tvg_icon_with_theme_colors(QString name, QPalette const& pal
     return QIcon(icon_engine);
     return QIcon(icon_engine);
 }
 }
 
 
-Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, UseLagomNetworking use_lagom_networking, WebView::EnableGPUPainting enable_gpu_painting)
+Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path)
     : QWidget(window)
     : QWidget(window)
     , m_window(window)
     , m_window(window)
 {
 {
@@ -60,7 +60,7 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
     m_layout->setSpacing(0);
     m_layout->setSpacing(0);
     m_layout->setContentsMargins(0, 0, 0, 0);
     m_layout->setContentsMargins(0, 0, 0, 0);
 
 
-    m_view = new WebContentView(webdriver_content_ipc_path, enable_callgrind_profiling, use_lagom_networking, enable_gpu_painting);
+    m_view = new WebContentView(web_content_options, webdriver_content_ipc_path);
     m_toolbar = new QToolBar(this);
     m_toolbar = new QToolBar(this);
     m_location_edit = new LocationEdit(this);
     m_location_edit = new LocationEdit(this);
 
 

+ 2 - 1
Ladybird/Qt/Tab.h

@@ -27,8 +27,9 @@ class InspectorWidget;
 
 
 class Tab final : public QWidget {
 class Tab final : public QWidget {
     Q_OBJECT
     Q_OBJECT
+
 public:
 public:
-    Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, UseLagomNetworking, WebView::EnableGPUPainting);
+    Tab(BrowserWindow* window, WebContentOptions const&, StringView webdriver_content_ipc_path);
     virtual ~Tab() override;
     virtual ~Tab() override;
 
 
     WebContentView& view() { return *m_view; }
     WebContentView& view() { return *m_view; }

+ 5 - 6
Ladybird/Qt/WebContentView.cpp

@@ -53,9 +53,8 @@ namespace Ladybird {
 
 
 bool is_using_dark_system_theme(QWidget&);
 bool is_using_dark_system_theme(QWidget&);
 
 
-WebContentView::WebContentView(StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, UseLagomNetworking use_lagom_networking, WebView::EnableGPUPainting enable_gpu_painting)
-    : m_use_lagom_networking(use_lagom_networking)
-    , m_use_gpu_painting(enable_gpu_painting)
+WebContentView::WebContentView(WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path)
+    : m_web_content_options(web_content_options)
     , m_webdriver_content_ipc_path(webdriver_content_ipc_path)
     , m_webdriver_content_ipc_path(webdriver_content_ipc_path)
 {
 {
     setMouseTracking(true);
     setMouseTracking(true);
@@ -76,7 +75,7 @@ WebContentView::WebContentView(StringView webdriver_content_ipc_path, WebView::E
         update_viewport_rect();
         update_viewport_rect();
     });
     });
 
 
-    create_client(enable_callgrind_profiling);
+    create_client();
 
 
     on_did_layout = [this](auto content_size) {
     on_did_layout = [this](auto content_size) {
         verticalScrollBar()->setMinimum(0);
         verticalScrollBar()->setMinimum(0);
@@ -600,12 +599,12 @@ void WebContentView::update_palette(PaletteMode mode)
     client().async_update_system_theme(make_system_theme_from_qt_palette(*this, mode));
     client().async_update_system_theme(make_system_theme_from_qt_palette(*this, mode));
 }
 }
 
 
-void WebContentView::create_client(WebView::EnableCallgrindProfiling enable_callgrind_profiling)
+void WebContentView::create_client()
 {
 {
     m_client_state = {};
     m_client_state = {};
 
 
     auto candidate_web_content_paths = get_paths_for_helper_process("WebContent"sv).release_value_but_fixme_should_propagate_errors();
     auto candidate_web_content_paths = get_paths_for_helper_process("WebContent"sv).release_value_but_fixme_should_propagate_errors();
-    auto new_client = launch_web_content_process(*this, candidate_web_content_paths, enable_callgrind_profiling, WebView::IsLayoutTestMode::No, m_use_lagom_networking, m_use_gpu_painting).release_value_but_fixme_should_propagate_errors();
+    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;
     m_client_state.client = new_client;
     m_client_state.client->on_web_content_process_crash = [this] {
     m_client_state.client->on_web_content_process_crash = [this] {

+ 3 - 4
Ladybird/Qt/WebContentView.h

@@ -42,7 +42,7 @@ class WebContentView final
     , public WebView::ViewImplementation {
     , public WebView::ViewImplementation {
     Q_OBJECT
     Q_OBJECT
 public:
 public:
-    explicit WebContentView(StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, UseLagomNetworking, WebView::EnableGPUPainting);
+    WebContentView(WebContentOptions const&, StringView webdriver_content_ipc_path);
     virtual ~WebContentView() override;
     virtual ~WebContentView() override;
 
 
     Function<String(const AK::URL&, Web::HTML::ActivateTab)> on_tab_open_request;
     Function<String(const AK::URL&, Web::HTML::ActivateTab)> on_tab_open_request;
@@ -81,7 +81,7 @@ signals:
 
 
 private:
 private:
     // ^WebView::ViewImplementation
     // ^WebView::ViewImplementation
-    virtual void create_client(WebView::EnableCallgrindProfiling = WebView::EnableCallgrindProfiling::No) override;
+    virtual void create_client() override;
     virtual void update_zoom() override;
     virtual void update_zoom() override;
     virtual Gfx::IntRect viewport_rect() const override;
     virtual Gfx::IntRect viewport_rect() const override;
     virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override;
     virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override;
@@ -92,11 +92,10 @@ private:
 
 
     qreal m_inverse_pixel_scaling_ratio { 1.0 };
     qreal m_inverse_pixel_scaling_ratio { 1.0 };
     bool m_should_show_line_box_borders { false };
     bool m_should_show_line_box_borders { false };
-    UseLagomNetworking m_use_lagom_networking {};
-    WebView::EnableGPUPainting m_use_gpu_painting {};
 
 
     Gfx::IntRect m_viewport_rect;
     Gfx::IntRect m_viewport_rect;
 
 
+    WebContentOptions m_web_content_options;
     StringView m_webdriver_content_ipc_path;
     StringView m_webdriver_content_ipc_path;
 };
 };
 
 

+ 7 - 1
Ladybird/Qt/main.cpp

@@ -140,7 +140,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
         initial_urls.append(MUST(ak_string_from_qstring(new_tab_page)));
         initial_urls.append(MUST(ak_string_from_qstring(new_tab_page)));
     }
     }
 
 
-    Ladybird::BrowserWindow window(initial_urls, cookie_jar, webdriver_content_ipc_path, enable_callgrind_profiling ? WebView::EnableCallgrindProfiling::Yes : WebView::EnableCallgrindProfiling::No, use_lagom_networking ? Ladybird::UseLagomNetworking::Yes : Ladybird::UseLagomNetworking::No, use_gpu_painting ? WebView::EnableGPUPainting::Yes : WebView::EnableGPUPainting::No);
+    Ladybird::WebContentOptions web_content_options {
+        .enable_callgrind_profiling = enable_callgrind_profiling ? Ladybird::EnableCallgrindProfiling::Yes : Ladybird::EnableCallgrindProfiling::No,
+        .enable_gpu_painting = use_gpu_painting ? Ladybird::EnableGPUPainting::Yes : Ladybird::EnableGPUPainting::No,
+        .use_lagom_networking = use_lagom_networking ? Ladybird::UseLagomNetworking::Yes : Ladybird::UseLagomNetworking::No,
+    };
+
+    Ladybird::BrowserWindow window(initial_urls, cookie_jar, web_content_options, webdriver_content_ipc_path);
     window.setWindowTitle("Ladybird");
     window.setWindowTitle("Ladybird");
 
 
     app.on_open_file = [&](auto file_url) {
     app.on_open_file = [&](auto file_url) {

+ 23 - 1
Ladybird/Types.h

@@ -8,9 +8,31 @@
 
 
 namespace Ladybird {
 namespace Ladybird {
 
 
-enum UseLagomNetworking {
+enum class EnableCallgrindProfiling {
     No,
     No,
     Yes
     Yes
 };
 };
 
 
+enum class EnableGPUPainting {
+    No,
+    Yes
+};
+
+enum class IsLayoutTestMode {
+    No,
+    Yes
+};
+
+enum class UseLagomNetworking {
+    No,
+    Yes
+};
+
+struct WebContentOptions {
+    EnableCallgrindProfiling enable_callgrind_profiling { EnableCallgrindProfiling::No };
+    EnableGPUPainting enable_gpu_painting { EnableGPUPainting::No };
+    IsLayoutTestMode is_layout_test_mode { IsLayoutTestMode::No };
+    UseLagomNetworking use_lagom_networking { UseLagomNetworking::No };
+};
+
 }
 }

+ 1 - 1
Userland/Libraries/LibWebView/OutOfProcessWebView.cpp

@@ -79,7 +79,7 @@ OutOfProcessWebView::OutOfProcessWebView()
 
 
 OutOfProcessWebView::~OutOfProcessWebView() = default;
 OutOfProcessWebView::~OutOfProcessWebView() = default;
 
 
-void OutOfProcessWebView::create_client(EnableCallgrindProfiling)
+void OutOfProcessWebView::create_client()
 {
 {
     m_client_state = {};
     m_client_state = {};
 
 

+ 1 - 1
Userland/Libraries/LibWebView/OutOfProcessWebView.h

@@ -78,7 +78,7 @@ private:
     virtual void did_scroll() override;
     virtual void did_scroll() override;
 
 
     // ^WebView::ViewImplementation
     // ^WebView::ViewImplementation
-    virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) override;
+    virtual void create_client() override;
     virtual void update_zoom() override;
     virtual void update_zoom() override;
 
 
     virtual Gfx::IntRect viewport_rect() const override;
     virtual Gfx::IntRect viewport_rect() const override;

+ 1 - 17
Userland/Libraries/LibWebView/ViewImplementation.h

@@ -19,22 +19,6 @@
 
 
 namespace WebView {
 namespace WebView {
 
 
-// Note: This only exists inside Serenity to avoid #ifdefs in all implementors of ViewImplementation.
-enum class EnableCallgrindProfiling {
-    No,
-    Yes
-};
-
-enum class EnableGPUPainting {
-    No,
-    Yes
-};
-
-enum class IsLayoutTestMode {
-    No,
-    Yes
-};
-
 class ViewImplementation {
 class ViewImplementation {
 public:
 public:
     virtual ~ViewImplementation() { }
     virtual ~ViewImplementation() { }
@@ -190,7 +174,7 @@ protected:
     void request_repaint();
     void request_repaint();
     void handle_resize();
     void handle_resize();
 
 
-    virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) { }
+    virtual void create_client() { }
 
 
     void handle_web_content_process_crash();
     void handle_web_content_process_crash();
 
 

+ 7 - 4
Userland/Utilities/headless-browser.cpp

@@ -18,6 +18,7 @@
 #include <AK/String.h>
 #include <AK/String.h>
 #include <AK/URL.h>
 #include <AK/URL.h>
 #include <AK/Vector.h>
 #include <AK/Vector.h>
+#include <Ladybird/Types.h>
 #include <LibCore/ArgsParser.h>
 #include <LibCore/ArgsParser.h>
 #include <LibCore/DirIterator.h>
 #include <LibCore/DirIterator.h>
 #include <LibCore/Directory.h>
 #include <LibCore/Directory.h>
@@ -54,7 +55,7 @@ constexpr int DEFAULT_TIMEOUT_MS = 30000; // 30sec
 
 
 class HeadlessWebContentView final : public WebView::ViewImplementation {
 class HeadlessWebContentView final : public WebView::ViewImplementation {
 public:
 public:
-    static ErrorOr<NonnullOwnPtr<HeadlessWebContentView>> create(Core::AnonymousBuffer theme, Gfx::IntSize const& window_size, StringView web_driver_ipc_path, WebView::IsLayoutTestMode is_layout_test_mode = WebView::IsLayoutTestMode::No)
+    static ErrorOr<NonnullOwnPtr<HeadlessWebContentView>> create(Core::AnonymousBuffer theme, Gfx::IntSize const& window_size, StringView web_driver_ipc_path, Ladybird::IsLayoutTestMode is_layout_test_mode = Ladybird::IsLayoutTestMode::No)
     {
     {
         auto view = TRY(adopt_nonnull_own_or_enomem(new (nothrow) HeadlessWebContentView));
         auto view = TRY(adopt_nonnull_own_or_enomem(new (nothrow) HeadlessWebContentView));
 
 
@@ -62,8 +63,10 @@ public:
         view->m_client_state.client = TRY(WebView::WebContentClient::try_create(*view));
         view->m_client_state.client = TRY(WebView::WebContentClient::try_create(*view));
         (void)is_layout_test_mode;
         (void)is_layout_test_mode;
 #else
 #else
+        Ladybird::WebContentOptions web_content_options { .is_layout_test_mode = is_layout_test_mode };
+
         auto candidate_web_content_paths = TRY(get_paths_for_helper_process("WebContent"sv));
         auto candidate_web_content_paths = TRY(get_paths_for_helper_process("WebContent"sv));
-        view->m_client_state.client = TRY(launch_web_content_process(*view, candidate_web_content_paths, WebView::EnableCallgrindProfiling::No, is_layout_test_mode, Ladybird::UseLagomNetworking::No, WebView::EnableGPUPainting::No));
+        view->m_client_state.client = TRY(launch_web_content_process(*view, candidate_web_content_paths, web_content_options));
 #endif
 #endif
 
 
         view->client().async_update_system_theme(move(theme));
         view->client().async_update_system_theme(move(theme));
@@ -108,7 +111,7 @@ private:
     HeadlessWebContentView() = default;
     HeadlessWebContentView() = default;
 
 
     void update_zoom() override { }
     void update_zoom() override { }
-    void create_client(WebView::EnableCallgrindProfiling) override { }
+    void create_client() override { }
 
 
     virtual Gfx::IntRect viewport_rect() const override { return m_viewport_rect; }
     virtual Gfx::IntRect viewport_rect() const override { return m_viewport_rect; }
     virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override { return widget_position; }
     virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override { return widget_position; }
@@ -451,7 +454,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
         is_layout_test_mode = true;
         is_layout_test_mode = true;
     }
     }
 
 
-    auto view = TRY(HeadlessWebContentView::create(move(theme), window_size, web_driver_ipc_path, is_layout_test_mode ? WebView::IsLayoutTestMode::Yes : WebView::IsLayoutTestMode::No));
+    auto view = TRY(HeadlessWebContentView::create(move(theme), window_size, web_driver_ipc_path, is_layout_test_mode ? Ladybird::IsLayoutTestMode::Yes : Ladybird::IsLayoutTestMode::No));
     RefPtr<Core::Timer> timer;
     RefPtr<Core::Timer> timer;
 
 
     if (!test_root_path.is_empty()) {
     if (!test_root_path.is_empty()) {