diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-24 16:35:46 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-24 16:37:28 +0200 |
commit | 6b2aadce112f51fe6412868630a4d8fcf12a2d9e (patch) | |
tree | 16f92dba875218f80b731d7ecd36d2ebdd80a041 /Userland/Applications/Browser/BrowserWindow.cpp | |
parent | dfa9dcca9892227d51b1bb545e6eab544d5d9e2c (diff) | |
download | serenity-6b2aadce112f51fe6412868630a4d8fcf12a2d9e.zip |
Browser: Remove single-process mode :^)
Browser now only supports multi-process mode (Web::OutOfProcessWebView).
This is where we want to go, so let's just jump in the cold water. :^)
Diffstat (limited to 'Userland/Applications/Browser/BrowserWindow.cpp')
-rw-r--r-- | Userland/Applications/Browser/BrowserWindow.cpp | 138 |
1 files changed, 27 insertions, 111 deletions
diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index 8cd6c6d82e..f35c918513 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -175,37 +175,18 @@ void BrowserWindow::build_menus() m_copy_selection_action = GUI::CommonActions::make_copy_action([this](auto&) { auto& tab = active_tab(); - String selected_text; - - if (tab.m_type == Tab::Type::InProcessWebView) - selected_text = tab.m_page_view->selected_text(); - else - selected_text = tab.m_web_content_view->selected_text(); - + auto selected_text = tab.m_web_content_view->selected_text(); if (!selected_text.is_empty()) GUI::Clipboard::the().set_plain_text(selected_text); }); m_select_all_action = GUI::CommonActions::make_select_all_action([this](auto&) { - auto& tab = active_tab(); - - if (tab.m_type == Tab::Type::InProcessWebView) - tab.m_page_view->select_all(); - else - tab.m_web_content_view->select_all(); + active_tab().m_web_content_view->select_all(); }); m_view_source_action = GUI::Action::create( "View &Source", { Mod_Ctrl, Key_U }, [this](auto&) { - auto& tab = active_tab(); - if (tab.m_type == Tab::Type::InProcessWebView) { - VERIFY(tab.m_page_view->document()); - auto url = tab.m_page_view->document()->url(); - auto source = tab.m_page_view->document()->source(); - tab.view_source(url, source); - } else { - tab.m_web_content_view->get_source(); - } + active_tab().m_web_content_view->get_source(); }, this); m_view_source_action->set_status_tip("View source code of the current page"); @@ -231,35 +212,21 @@ void BrowserWindow::build_menus() auto js_console_action = GUI::Action::create( "Open &JS Console", { Mod_Ctrl, Key_I }, [this](auto&) { auto& tab = active_tab(); - if (tab.m_type == Tab::Type::InProcessWebView) { - if (!tab.m_console_window) { - tab.m_console_window = GUI::Window::construct(this); - tab.m_console_window->resize(500, 300); - tab.m_console_window->set_title("JS Console"); - tab.m_console_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png")); - tab.m_console_window->set_main_widget<ConsoleWidget>(); - } - auto* console_widget = static_cast<ConsoleWidget*>(tab.m_console_window->main_widget()); - console_widget->set_interpreter(tab.m_page_view->document()->interpreter().make_weak_ptr()); - tab.m_console_window->show(); - tab.m_console_window->move_to_front(); - } else { - if (!tab.m_console_window) { - tab.m_console_window = GUI::Window::construct(this); - tab.m_console_window->resize(500, 300); - tab.m_console_window->set_title("JS Console"); - tab.m_console_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png")); - tab.m_console_window->set_main_widget<ConsoleWidget>(); - } - auto* console_widget = static_cast<ConsoleWidget*>(tab.m_console_window->main_widget()); - console_widget->on_js_input = [&tab](const String& js_source) { - tab.m_web_content_view->js_console_input(js_source); - }; - console_widget->clear_output(); - tab.m_web_content_view->js_console_initialize(); - tab.m_console_window->show(); - tab.m_console_window->move_to_front(); + if (!tab.m_console_window) { + tab.m_console_window = GUI::Window::construct(this); + tab.m_console_window->resize(500, 300); + tab.m_console_window->set_title("JS Console"); + tab.m_console_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png")); + tab.m_console_window->set_main_widget<ConsoleWidget>(); } + auto* console_widget = static_cast<ConsoleWidget*>(tab.m_console_window->main_widget()); + console_widget->on_js_input = [&tab](const String& js_source) { + tab.m_web_content_view->js_console_input(js_source); + }; + console_widget->clear_output(); + tab.m_web_content_view->js_console_initialize(); + tab.m_console_window->show(); + tab.m_console_window->move_to_front(); }, this); js_console_action->set_status_tip("Open JavaScript console for this page"); @@ -354,34 +321,17 @@ void BrowserWindow::build_menus() auto& debug_menu = add_menu("&Debug"); debug_menu.add_action(GUI::Action::create( "Dump &DOM Tree", [this](auto&) { - auto& tab = active_tab(); - if (tab.m_type == Tab::Type::InProcessWebView) { - Web::dump_tree(*tab.m_page_view->document()); - } else { - tab.m_web_content_view->debug_request("dump-dom-tree"); - } + active_tab().m_web_content_view->debug_request("dump-dom-tree"); }, this)); debug_menu.add_action(GUI::Action::create( "Dump &Layout Tree", [this](auto&) { - auto& tab = active_tab(); - if (tab.m_type == Tab::Type::InProcessWebView) { - Web::dump_tree(*tab.m_page_view->document()->layout_node()); - } else { - tab.m_web_content_view->debug_request("dump-layout-tree"); - } + active_tab().m_web_content_view->debug_request("dump-layout-tree"); }, this)); debug_menu.add_action(GUI::Action::create( "Dump &Style Sheets", [this](auto&) { - auto& tab = active_tab(); - if (tab.m_type == Tab::Type::InProcessWebView) { - for (auto& sheet : tab.m_page_view->document()->style_sheets().sheets()) { - Web::dump_sheet(sheet); - } - } else { - tab.m_web_content_view->debug_request("dump-style-sheets"); - } + active_tab().m_web_content_view->debug_request("dump-style-sheets"); }, this)); debug_menu.add_action(GUI::Action::create("Dump &History", { Mod_Ctrl, Key_H }, [this](auto&) { @@ -395,13 +345,7 @@ void BrowserWindow::build_menus() debug_menu.add_separator(); auto line_box_borders_action = GUI::Action::create_checkable( "Line &Box Borders", [this](auto& action) { - auto& tab = active_tab(); - if (tab.m_type == Tab::Type::InProcessWebView) { - tab.m_page_view->set_should_show_line_box_borders(action.is_checked()); - tab.m_page_view->update(); - } else { - tab.m_web_content_view->debug_request("set-line-box-borders", action.is_checked() ? "on" : "off"); - } + active_tab().m_web_content_view->debug_request("set-line-box-borders", action.is_checked() ? "on" : "off"); }, this); line_box_borders_action->set_checked(false); @@ -409,33 +353,16 @@ void BrowserWindow::build_menus() debug_menu.add_separator(); debug_menu.add_action(GUI::Action::create("Collect &Garbage", { Mod_Ctrl | Mod_Shift, Key_G }, [this](auto&) { - auto& tab = active_tab(); - if (tab.m_type == Tab::Type::InProcessWebView) { - if (auto* document = tab.m_page_view->document()) { - document->interpreter().heap().collect_garbage(JS::Heap::CollectionType::CollectGarbage, true); - } - } else { - tab.m_web_content_view->debug_request("collect-garbage"); - } + active_tab().m_web_content_view->debug_request("collect-garbage"); })); debug_menu.add_action(GUI::Action::create("Clear &Cache", { Mod_Ctrl | Mod_Shift, Key_C }, [this](auto&) { - auto& tab = active_tab(); - if (tab.m_type == Tab::Type::InProcessWebView) { - Web::ResourceLoader::the().clear_cache(); - } else { - tab.m_web_content_view->debug_request("clear-cache"); - } + active_tab().m_web_content_view->debug_request("clear-cache"); })); m_user_agent_spoof_actions.set_exclusive(true); auto& spoof_user_agent_menu = debug_menu.add_submenu("Spoof &User Agent"); m_disable_user_agent_spoofing = GUI::Action::create_checkable("Disabled", [this](auto&) { - auto& tab = active_tab(); - if (tab.m_type == Tab::Type::InProcessWebView) { - Web::ResourceLoader::the().set_user_agent(Web::default_user_agent); - } else { - tab.m_web_content_view->debug_request("spoof-user-agent", Web::default_user_agent); - } + active_tab().m_web_content_view->debug_request("spoof-user-agent", Web::default_user_agent); }); m_disable_user_agent_spoofing->set_status_tip(Web::default_user_agent); spoof_user_agent_menu.add_action(*m_disable_user_agent_spoofing); @@ -444,12 +371,7 @@ void BrowserWindow::build_menus() auto add_user_agent = [this, &spoof_user_agent_menu](auto& name, auto& user_agent) { auto action = GUI::Action::create_checkable(name, [this, user_agent](auto&) { - auto& tab = active_tab(); - if (tab.m_type == Tab::Type::InProcessWebView) { - Web::ResourceLoader::the().set_user_agent(user_agent); - } else { - tab.m_web_content_view->debug_request("spoof-user-agent", user_agent); - } + active_tab().m_web_content_view->debug_request("spoof-user-agent", user_agent); }); action->set_status_tip(user_agent); spoof_user_agent_menu.add_action(action); @@ -463,17 +385,12 @@ void BrowserWindow::build_menus() add_user_agent("Safari iOS Mobile", "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1"); auto custom_user_agent = GUI::Action::create_checkable("Custom...", [this](auto& action) { - auto& tab = active_tab(); String user_agent; if (GUI::InputBox::show(this, user_agent, "Enter User Agent:", "Custom User Agent") != GUI::InputBox::ExecOK || user_agent.is_empty() || user_agent.is_null()) { m_disable_user_agent_spoofing->activate(); return; } - if (tab.m_type == Tab::Type::InProcessWebView) { - Web::ResourceLoader::the().set_user_agent(user_agent); - } else { - tab.m_web_content_view->debug_request("spoof-user-agent", user_agent); - } + active_tab().m_web_content_view->debug_request("spoof-user-agent", user_agent); action.set_status_tip(user_agent); }); spoof_user_agent_menu.add_action(custom_user_agent); @@ -502,8 +419,7 @@ void BrowserWindow::set_window_title_for_tab(Tab const& tab) void BrowserWindow::create_new_tab(URL url, bool activate) { - auto type = Browser::g_single_process ? Browser::Tab::Type::InProcessWebView : Browser::Tab::Type::OutOfProcessWebView; - auto& new_tab = m_tab_widget->add_tab<Browser::Tab>("New tab", *this, type); + auto& new_tab = m_tab_widget->add_tab<Browser::Tab>("New tab", *this); m_tab_widget->set_bar_visible(!is_fullscreen() && m_tab_widget->children().size() > 1); |