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().
This commit is contained in:
Timothy Flynn 2023-12-01 12:18:40 -05:00 committed by Tim Flynn
parent 8504d8f588
commit 07e9a8f79b
Notes: sideshowbarker 2024-07-17 06:54:15 +09:00
22 changed files with 104 additions and 74 deletions

View File

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

View File

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

View File

@ -93,7 +93,7 @@ struct HideCursor {
// This returns device pixel ratio of the screen the window is opened in
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];
auto* area = [[NSTrackingArea alloc] initWithRect:[self bounds]

View File

@ -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>();
}
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_web_content_options(web_content_options)
, m_webdriver_content_ipc_path(move(webdriver_content_ipc_path))
, m_preferred_color_scheme(preferred_color_scheme)
{
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) {
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());
}
void WebViewBridge::create_client(WebView::EnableCallgrindProfiling enable_callgrind_profiling)
void WebViewBridge::create_client()
{
m_client_state = {};
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->on_web_content_process_crash = [this] {

View File

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

View File

@ -5,6 +5,7 @@
*/
#include <BrowserSettings/Defaults.h>
#include <Ladybird/Types.h>
#include <Ladybird/Utilities.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/EventLoop.h>
@ -61,9 +62,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (initial_urls.is_empty())
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)
newTabPageURL:move(new_tab_page_url)
withCookieJar:move(cookie_jar)
webContentOptions:web_content_options
webdriverContentIPCPath:webdriver_content_ipc_path];
[NSApp setDelegate:delegate];

View File

@ -6,12 +6,10 @@
#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,
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] {};
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_string
};
if (enable_callgrind_profiling == WebView::EnableCallgrindProfiling::No)
if (web_content_options.enable_callgrind_profiling == Ladybird::EnableCallgrindProfiling::No)
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);
if (use_lagom_networking == Ladybird::UseLagomNetworking::Yes)
if (web_content_options.use_lagom_networking == Ladybird::UseLagomNetworking::Yes)
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);
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)));
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("\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");

View File

@ -16,12 +16,10 @@
#include <LibWebView/ViewImplementation.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,
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<Protocol::RequestClient>> launch_request_server_process(ReadonlySpan<String> candidate_request_server_paths, StringView serenity_resource_root);

View File

@ -42,12 +42,10 @@ static QIcon const& app_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_web_content_options(web_content_options)
, 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());
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)
{
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();
m_tabs.append(std::move(tab));

View File

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

View File

@ -25,7 +25,7 @@ ConsoleWidget::ConsoleWidget(WebContentView& content_view)
{
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))
m_output_view->update_palette(WebContentView::PaletteMode::Dark);

View File

@ -15,7 +15,7 @@ extern bool is_using_dark_system_theme(QWidget&);
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))
m_inspector_view->update_palette(WebContentView::PaletteMode::Dark);

View File

@ -52,7 +52,7 @@ static QIcon create_tvg_icon_with_theme_colors(QString name, QPalette const& pal
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)
, m_window(window)
{
@ -60,7 +60,7 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
m_layout->setSpacing(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_location_edit = new LocationEdit(this);

View File

@ -27,8 +27,9 @@ class InspectorWidget;
class Tab final : public QWidget {
Q_OBJECT
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;
WebContentView& view() { return *m_view; }

View File

@ -53,9 +53,8 @@ namespace Ladybird {
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)
{
setMouseTracking(true);
@ -76,7 +75,7 @@ WebContentView::WebContentView(StringView webdriver_content_ipc_path, WebView::E
update_viewport_rect();
});
create_client(enable_callgrind_profiling);
create_client();
on_did_layout = [this](auto content_size) {
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));
}
void WebContentView::create_client(WebView::EnableCallgrindProfiling enable_callgrind_profiling)
void WebContentView::create_client()
{
m_client_state = {};
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->on_web_content_process_crash = [this] {

View File

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

View File

@ -140,7 +140,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
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");
app.on_open_file = [&](auto file_url) {

View File

@ -8,9 +8,31 @@
namespace Ladybird {
enum UseLagomNetworking {
enum class EnableCallgrindProfiling {
No,
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 };
};
}

View File

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

View File

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

View File

@ -19,22 +19,6 @@
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 {
public:
virtual ~ViewImplementation() { }
@ -190,7 +174,7 @@ protected:
void request_repaint();
void handle_resize();
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) { }
virtual void create_client() { }
void handle_web_content_process_crash();

View File

@ -18,6 +18,7 @@
#include <AK/String.h>
#include <AK/URL.h>
#include <AK/Vector.h>
#include <Ladybird/Types.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
#include <LibCore/Directory.h>
@ -54,7 +55,7 @@ constexpr int DEFAULT_TIMEOUT_MS = 30000; // 30sec
class HeadlessWebContentView final : public WebView::ViewImplementation {
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));
@ -62,8 +63,10 @@ public:
view->m_client_state.client = TRY(WebView::WebContentClient::try_create(*view));
(void)is_layout_test_mode;
#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));
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
view->client().async_update_system_theme(move(theme));
@ -108,7 +111,7 @@ private:
HeadlessWebContentView() = default;
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::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;
}
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;
if (!test_root_path.is_empty()) {