Ladybird+LibWebView+Browser: Remove ability to run with AST interpreter

This commit is contained in:
Andreas Kling 2023-08-07 16:44:20 +02:00
parent e769776bdd
commit 99ac34eeae
24 changed files with 28 additions and 68 deletions

View file

@ -10,7 +10,6 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(Web
ReadonlySpan<String> candidate_web_content_paths,
WebView::EnableCallgrindProfiling enable_callgrind_profiling,
WebView::IsLayoutTestMode is_layout_test_mode,
WebView::UseJavaScriptBytecode use_javascript_bytecode,
Ladybird::UseLagomNetworking use_lagom_networking)
{
int socket_fds[2] {};
@ -53,8 +52,6 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(Web
arguments.remove(0, callgrind_prefix_length);
if (is_layout_test_mode == WebView::IsLayoutTestMode::Yes)
arguments.append("--layout-test-mode"sv);
if (use_javascript_bytecode == WebView::UseJavaScriptBytecode::Yes)
arguments.append("--use-bytecode"sv);
if (use_lagom_networking == Ladybird::UseLagomNetworking::Yes)
arguments.append("--use-lagom-networking"sv);

View file

@ -19,7 +19,6 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(Web
ReadonlySpan<String> candidate_web_content_paths,
WebView::EnableCallgrindProfiling,
WebView::IsLayoutTestMode,
WebView::UseJavaScriptBytecode,
Ladybird::UseLagomNetworking);
ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(ReadonlySpan<String> candidate_request_server_paths, StringView serenity_resource_root);

View file

@ -40,11 +40,10 @@ static QIcon const& app_icon()
return icon;
}
BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, WebView::UseJavaScriptBytecode use_javascript_bytecode, UseLagomNetworking use_lagom_networking)
BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, UseLagomNetworking use_lagom_networking)
: m_cookie_jar(cookie_jar)
, m_webdriver_content_ipc_path(webdriver_content_ipc_path)
, m_enable_callgrind_profiling(enable_callgrind_profiling)
, m_use_javascript_bytecode(use_javascript_bytecode)
, m_use_lagom_networking(use_lagom_networking)
{
setWindowIcon(app_icon());
@ -420,7 +419,7 @@ void BrowserWindow::debug_request(DeprecatedString const& request, DeprecatedStr
Tab& BrowserWindow::new_tab(QString const& url, Web::HTML::ActivateTab activate_tab)
{
auto tab = make<Tab>(this, m_webdriver_content_ipc_path, m_enable_callgrind_profiling, m_use_javascript_bytecode, m_use_lagom_networking);
auto tab = make<Tab>(this, m_webdriver_content_ipc_path, m_enable_callgrind_profiling, m_use_lagom_networking);
auto tab_ptr = tab.ptr();
m_tabs.append(std::move(tab));

View file

@ -28,7 +28,7 @@ class WebContentView;
class BrowserWindow : public QMainWindow {
Q_OBJECT
public:
explicit BrowserWindow(Browser::CookieJar&, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, WebView::UseJavaScriptBytecode, UseLagomNetworking);
explicit BrowserWindow(Browser::CookieJar&, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, UseLagomNetworking);
WebContentView& view() const { return m_current_tab->view(); }
@ -119,7 +119,6 @@ private:
StringView m_webdriver_content_ipc_path;
WebView::EnableCallgrindProfiling m_enable_callgrind_profiling;
WebView::UseJavaScriptBytecode m_use_javascript_bytecode;
UseLagomNetworking m_use_lagom_networking;
};

View file

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

View file

@ -50,7 +50,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, WebView::UseJavaScriptBytecode use_javascript_bytecode, UseLagomNetworking use_lagom_networking)
Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, UseLagomNetworking use_lagom_networking)
: QWidget(window)
, m_window(window)
{
@ -58,7 +58,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_javascript_bytecode, use_lagom_networking);
m_view = new WebContentView(webdriver_content_ipc_path, enable_callgrind_profiling, use_lagom_networking);
m_toolbar = new QToolBar(this);
m_location_edit = new LocationEdit(this);

View file

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

View file

@ -54,9 +54,8 @@ namespace Ladybird {
bool is_using_dark_system_theme(QWidget&);
WebContentView::WebContentView(StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, WebView::UseJavaScriptBytecode use_javascript_bytecode, UseLagomNetworking use_lagom_networking)
: WebView::ViewImplementation(use_javascript_bytecode)
, m_use_lagom_networking(use_lagom_networking)
WebContentView::WebContentView(StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, UseLagomNetworking use_lagom_networking)
: m_use_lagom_networking(use_lagom_networking)
, m_webdriver_content_ipc_path(webdriver_content_ipc_path)
{
setMouseTracking(true);
@ -545,7 +544,7 @@ void WebContentView::create_client(WebView::EnableCallgrindProfiling enable_call
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, use_javascript_bytecode(), m_use_lagom_networking).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).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

@ -43,7 +43,7 @@ class WebContentView final
, public WebView::ViewImplementation {
Q_OBJECT
public:
explicit WebContentView(StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, WebView::UseJavaScriptBytecode, UseLagomNetworking);
explicit WebContentView(StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, UseLagomNetworking);
virtual ~WebContentView() override;
Function<String(const AK::URL&, Web::HTML::ActivateTab)> on_tab_open_request;

View file

@ -108,7 +108,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto cookie_jar = database ? TRY(Browser::CookieJar::create(*database)) : Browser::CookieJar::create();
Ladybird::s_settings = adopt_own_if_nonnull(new Ladybird::Settings());
Ladybird::BrowserWindow window(cookie_jar, webdriver_content_ipc_path, enable_callgrind_profiling ? WebView::EnableCallgrindProfiling::Yes : WebView::EnableCallgrindProfiling::No, WebView::UseJavaScriptBytecode::Yes, use_lagom_networking ? Ladybird::UseLagomNetworking::Yes : Ladybird::UseLagomNetworking::No);
Ladybird::BrowserWindow window(cookie_jar, webdriver_content_ipc_path, enable_callgrind_profiling ? WebView::EnableCallgrindProfiling::Yes : WebView::EnableCallgrindProfiling::No, use_lagom_networking ? Ladybird::UseLagomNetworking::Yes : Ladybird::UseLagomNetworking::No);
window.setWindowTitle("Ladybird");
window.resize(800, 600);
window.show();

View file

@ -65,13 +65,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
int webcontent_fd_passing_socket { -1 };
bool is_layout_test_mode = false;
bool use_javascript_bytecode = false;
bool use_lagom_networking = false;
Core::ArgsParser args_parser;
args_parser.add_option(webcontent_fd_passing_socket, "File descriptor of the passing socket for the WebContent connection", "webcontent-fd-passing-socket", 'c', "webcontent_fd_passing_socket");
args_parser.add_option(is_layout_test_mode, "Is layout test mode", "layout-test-mode", 0);
args_parser.add_option(use_javascript_bytecode, "Enable JavaScript bytecode VM", "use-bytecode", 0);
args_parser.add_option(use_lagom_networking, "Enable Lagom servers for networking", "use-lagom-networking", 0);
args_parser.parse(arguments);
@ -90,8 +88,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Web::HTML::Window::set_internals_object_exposed(is_layout_test_mode);
JS::Bytecode::Interpreter::set_enabled(use_javascript_bytecode);
VERIFY(webcontent_fd_passing_socket >= 0);
Web::Platform::FontPlugin::install(*new Ladybird::FontPlugin(is_layout_test_mode));

View file

@ -57,10 +57,9 @@ static DeprecatedString search_engines_file_path()
return builder.to_deprecated_string();
}
BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url, WebView::UseJavaScriptBytecode use_javascript_bytecode)
BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
: m_cookie_jar(cookie_jar)
, m_window_actions(*this)
, m_use_javascript_bytecode(use_javascript_bytecode)
{
auto app_icon = GUI::Icon::default_icon("app-browser"sv);
m_bookmarks_bar = Browser::BookmarksBarWidget::construct(Browser::bookmarks_file_path(), true);
@ -564,7 +563,7 @@ void BrowserWindow::set_window_title_for_tab(Tab const& tab)
Tab& BrowserWindow::create_new_tab(URL url, Web::HTML::ActivateTab activate)
{
auto& new_tab = m_tab_widget->add_tab<Browser::Tab>("New tab"_string, *this, m_use_javascript_bytecode);
auto& new_tab = m_tab_widget->add_tab<Browser::Tab>("New tab"_string, *this);
m_tab_widget->set_bar_visible(!is_fullscreen() && m_tab_widget->children().size() > 1);

View file

@ -51,7 +51,7 @@ public:
void broadcast_window_size(Gfx::IntSize);
private:
BrowserWindow(CookieJar&, URL, WebView::UseJavaScriptBytecode);
BrowserWindow(CookieJar&, URL);
void build_menus();
ErrorOr<void> load_search_engines(GUI::Menu& settings_menu);
@ -87,8 +87,6 @@ private:
RefPtr<GUI::Action> m_disable_user_agent_spoofing;
RefPtr<GUI::Action> m_disable_search_engine_action;
RefPtr<GUI::Action> m_change_homepage_action;
WebView::UseJavaScriptBytecode m_use_javascript_bytecode {};
};
}

View file

@ -114,7 +114,7 @@ void Tab::update_status(Optional<String> text_override, i32 count_waiting)
}
}
Tab::Tab(BrowserWindow& window, WebView::UseJavaScriptBytecode use_javascript_bytecode)
Tab::Tab(BrowserWindow& window)
{
load_from_gml(tab_gml).release_value_but_fixme_should_propagate_errors();
@ -123,7 +123,7 @@ Tab::Tab(BrowserWindow& window, WebView::UseJavaScriptBytecode use_javascript_by
auto& webview_container = *find_descendant_of_type_named<GUI::Widget>("webview_container");
m_web_content_view = webview_container.add<WebView::OutOfProcessWebView>(use_javascript_bytecode);
m_web_content_view = webview_container.add<WebView::OutOfProcessWebView>();
auto preferred_color_scheme = Web::CSS::preferred_color_scheme_from_string(Config::read_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, Browser::default_color_scheme));
m_web_content_view->set_preferred_color_scheme(preferred_color_scheme);

View file

@ -99,7 +99,7 @@ public:
WebView::OutOfProcessWebView& view() { return *m_web_content_view; }
private:
Tab(BrowserWindow&, WebView::UseJavaScriptBytecode);
explicit Tab(BrowserWindow&);
virtual void show_event(GUI::ShowEvent&) override;
virtual void hide_event(GUI::HideEvent&) override;

View file

@ -173,7 +173,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
first_url = TRY(url_from_argument_string(specified_urls.first()));
auto cookie_jar = TRY(Browser::CookieJar::create(*database));
auto window = Browser::BrowserWindow::construct(cookie_jar, first_url, WebView::UseJavaScriptBytecode::Yes);
auto window = Browser::BrowserWindow::construct(cookie_jar, first_url);
auto content_filters_watcher = TRY(Core::FileWatcher::create());
content_filters_watcher->on_change = [&](Core::FileWatcherEvent const&) {

View file

@ -25,8 +25,7 @@ REGISTER_WIDGET(WebView, OutOfProcessWebView)
namespace WebView {
OutOfProcessWebView::OutOfProcessWebView(UseJavaScriptBytecode use_javascript_bytecode)
: ViewImplementation(use_javascript_bytecode)
OutOfProcessWebView::OutOfProcessWebView()
{
set_should_hide_unnecessary_scrollbars(true);
set_focus_policy(GUI::FocusPolicy::StrongFocus);
@ -47,8 +46,6 @@ void OutOfProcessWebView::create_client(EnableCallgrindProfiling)
});
};
client().async_set_use_javascript_bytecode(use_javascript_bytecode() == UseJavaScriptBytecode::Yes);
m_client_state.client_handle = Web::Crypto::generate_random_uuid().release_value_but_fixme_should_propagate_errors();
client().async_set_window_handle(m_client_state.client_handle);

View file

@ -55,7 +55,7 @@ public:
void set_content_scales_to_viewport(bool);
private:
explicit OutOfProcessWebView(UseJavaScriptBytecode = UseJavaScriptBytecode::No);
OutOfProcessWebView();
// ^Widget
virtual void paint_event(GUI::PaintEvent&) override;

View file

@ -14,8 +14,7 @@
namespace WebView {
ViewImplementation::ViewImplementation(UseJavaScriptBytecode use_javascript_bytecode)
: m_use_javascript_bytecode(use_javascript_bytecode)
ViewImplementation::ViewImplementation()
{
m_backing_store_shrink_timer = Core::Timer::create_single_shot(3000, [this] {
resize_backing_stores_if_needed(WindowResizeInProgress::No);

View file

@ -30,11 +30,6 @@ enum class IsLayoutTestMode {
Yes
};
enum class UseJavaScriptBytecode {
No,
Yes
};
class ViewImplementation {
public:
virtual ~ViewImplementation() { }
@ -74,8 +69,6 @@ public:
void clear_inspected_dom_node();
i32 get_hovered_node_id();
UseJavaScriptBytecode use_javascript_bytecode() const { return m_use_javascript_bytecode; }
void debug_request(DeprecatedString const& request, DeprecatedString const& argument = {});
void run_javascript(StringView);
@ -160,7 +153,7 @@ protected:
static constexpr auto ZOOM_MAX_LEVEL = 5.0f;
static constexpr auto ZOOM_STEP = 0.1f;
explicit ViewImplementation(UseJavaScriptBytecode);
ViewImplementation();
WebContentClient& client();
WebContentClient const& client() const;
@ -208,8 +201,6 @@ protected:
size_t m_crash_count = 0;
RefPtr<Core::Timer> m_repeated_crash_timer;
UseJavaScriptBytecode m_use_javascript_bytecode {};
};
}

View file

@ -65,11 +65,6 @@ Web::Page const& ConnectionFromClient::page() const
return m_page_host->page();
}
void ConnectionFromClient::set_use_javascript_bytecode(bool use_bytecode)
{
JS::Bytecode::Interpreter::set_enabled(use_bytecode);
}
Messages::WebContentServer::GetWindowHandleResponse ConnectionFromClient::get_window_handle()
{
return m_page_host->page().top_level_browsing_context().window_handle();

View file

@ -48,7 +48,6 @@ private:
Web::Page& page();
Web::Page const& page() const;
virtual void set_use_javascript_bytecode(bool) override;
virtual Messages::WebContentServer::GetWindowHandleResponse get_window_handle() override;
virtual void set_window_handle(String const& handle) override;
virtual void connect_to_webdriver(DeprecatedString const& webdriver_ipc_path) override;

View file

@ -9,9 +9,6 @@
endpoint WebContentServer
{
// NOTE: This is only used on SerenityOS when attaching to a WebContent process served by SystemServer.
set_use_javascript_bytecode(bool use_javascript_bytecode) =|
get_window_handle() => (String handle)
set_window_handle(String handle) =|

View file

@ -47,17 +47,16 @@
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, WebView::UseJavaScriptBytecode use_javascript_bytecode = WebView::UseJavaScriptBytecode::No)
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)
{
auto view = TRY(adopt_nonnull_own_or_enomem(new (nothrow) HeadlessWebContentView(use_javascript_bytecode)));
auto view = TRY(adopt_nonnull_own_or_enomem(new (nothrow) HeadlessWebContentView));
#if defined(AK_OS_SERENITY)
view->m_client_state.client = TRY(WebView::WebContentClient::try_create(*view));
(void)is_layout_test_mode;
(void)use_javascript_bytecode;
#else
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, use_javascript_bytecode, Ladybird::UseLagomNetworking::No));
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));
#endif
view->client().async_update_system_theme(move(theme));
@ -99,10 +98,7 @@ public:
}
private:
HeadlessWebContentView(WebView::UseJavaScriptBytecode use_javascript_bytecode)
: WebView::ViewImplementation(use_javascript_bytecode)
{
}
HeadlessWebContentView() = default;
void notify_server_did_layout(Badge<WebView::WebContentClient>, Gfx::IntSize) override { }
void notify_server_did_paint(Badge<WebView::WebContentClient>, i32, Gfx::IntSize) override { }
@ -414,7 +410,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, WebView::UseJavaScriptBytecode::Yes));
auto view = TRY(HeadlessWebContentView::create(move(theme), window_size, web_driver_ipc_path, is_layout_test_mode ? WebView::IsLayoutTestMode::Yes : WebView::IsLayoutTestMode::No));
RefPtr<Core::Timer> timer;
if (!test_root_path.is_empty()) {