Browser+LibWebView: Run with the JavaScript bytecode VM by default

The AST interpreter is still available behind a new `--ast` flag.
This commit is contained in:
Andreas Kling 2023-07-25 17:42:22 +02:00
parent c3e5487f00
commit a3e97ea153
Notes: sideshowbarker 2024-07-17 03:05:16 +09:00
9 changed files with 25 additions and 7 deletions

View File

@ -57,9 +57,10 @@ static DeprecatedString search_engines_file_path()
return builder.to_deprecated_string();
}
BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url, WebView::UseJavaScriptBytecode use_javascript_bytecode)
: 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);
@ -563,7 +564,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"_short_string, *this);
auto& new_tab = m_tab_widget->add_tab<Browser::Tab>("New tab"_short_string, *this, m_use_javascript_bytecode);
m_tab_widget->set_bar_visible(!is_fullscreen() && m_tab_widget->children().size() > 1);

View File

@ -50,7 +50,7 @@ public:
void broadcast_window_size(Gfx::IntSize);
private:
explicit BrowserWindow(CookieJar&, URL);
BrowserWindow(CookieJar&, URL, WebView::UseJavaScriptBytecode);
void build_menus();
ErrorOr<void> load_search_engines(GUI::Menu& settings_menu);
@ -86,6 +86,8 @@ 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)
Tab::Tab(BrowserWindow& window, WebView::UseJavaScriptBytecode use_javascript_bytecode)
{
load_from_gml(tab_gml).release_value_but_fixme_should_propagate_errors();
@ -123,7 +123,7 @@ Tab::Tab(BrowserWindow& window)
auto& webview_container = *find_descendant_of_type_named<GUI::Widget>("webview_container");
m_web_content_view = webview_container.add<WebView::OutOfProcessWebView>();
m_web_content_view = webview_container.add<WebView::OutOfProcessWebView>(use_javascript_bytecode);
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

@ -15,6 +15,7 @@
#include <LibGfx/ShareableBitmap.h>
#include <LibHTTP/Job.h>
#include <LibWeb/Forward.h>
#include <LibWebView/ViewImplementation.h>
namespace WebView {
class OutOfProcessWebView;
@ -98,7 +99,7 @@ public:
WebView::OutOfProcessWebView& view() { return *m_web_content_view; }
private:
explicit Tab(BrowserWindow&);
Tab(BrowserWindow&, WebView::UseJavaScriptBytecode);
virtual void show_event(GUI::ShowEvent&) override;
virtual void hide_event(GUI::HideEvent&) override;

View File

@ -96,10 +96,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio recvfd sendfd unix fattr cpath rpath wpath proc exec"));
Vector<DeprecatedString> specified_urls;
bool use_ast_interpreter = false;
Core::ArgsParser args_parser;
args_parser.add_positional_argument(specified_urls, "URLs to open", "url", Core::ArgsParser::Required::No);
args_parser.add_option(Browser::g_webdriver_content_ipc_path, "Path to WebDriver IPC for WebContent", "webdriver-content-path", 0, "path");
args_parser.add_option(use_ast_interpreter, "Enable JavaScript AST interpreter (deprecated)", "ast", 0);
args_parser.parse(arguments);
@ -173,7 +175,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);
auto window = Browser::BrowserWindow::construct(cookie_jar, first_url, use_ast_interpreter ? WebView::UseJavaScriptBytecode::No : WebView::UseJavaScriptBytecode::Yes);
auto content_filters_watcher = TRY(Core::FileWatcher::create());
content_filters_watcher->on_change = [&](Core::FileWatcherEvent const&) {

View File

@ -47,6 +47,8 @@ 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

@ -14,6 +14,7 @@
#include <LibGfx/Bitmap.h>
#include <LibGfx/Font/FontDatabase.h>
#include <LibGfx/SystemTheme.h>
#include <LibJS/Bytecode/Interpreter.h>
#include <LibJS/Console.h>
#include <LibJS/Heap/Heap.h>
#include <LibJS/Runtime/ConsoleObject.h>
@ -64,6 +65,11 @@ 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,6 +48,7 @@ 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,6 +9,9 @@
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) =|