summaryrefslogtreecommitdiff
path: root/Userland/Applications/Browser
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-24 16:35:46 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-24 16:37:28 +0200
commit6b2aadce112f51fe6412868630a4d8fcf12a2d9e (patch)
tree16f92dba875218f80b731d7ecd36d2ebdd80a041 /Userland/Applications/Browser
parentdfa9dcca9892227d51b1bb545e6eab544d5d9e2c (diff)
downloadserenity-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')
-rw-r--r--Userland/Applications/Browser/Browser.h1
-rw-r--r--Userland/Applications/Browser/BrowserWindow.cpp138
-rw-r--r--Userland/Applications/Browser/Tab.cpp72
-rw-r--r--Userland/Applications/Browser/Tab.h11
-rw-r--r--Userland/Applications/Browser/main.cpp8
5 files changed, 34 insertions, 196 deletions
diff --git a/Userland/Applications/Browser/Browser.h b/Userland/Applications/Browser/Browser.h
index f953d49651..b3152d2881 100644
--- a/Userland/Applications/Browser/Browser.h
+++ b/Userland/Applications/Browser/Browser.h
@@ -10,7 +10,6 @@
namespace Browser {
-extern bool g_single_process;
extern String g_home_url;
extern String g_search_engine;
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);
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp
index 53b4449014..588d71e899 100644
--- a/Userland/Applications/Browser/Tab.cpp
+++ b/Userland/Applications/Browser/Tab.cpp
@@ -29,7 +29,6 @@
#include <LibGUI/Window.h>
#include <LibJS/Interpreter.h>
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
-#include <LibWeb/InProcessWebView.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/InitialContainingBlockBox.h>
#include <LibWeb/Loader/ResourceLoader.h>
@@ -94,8 +93,7 @@ void Tab::view_dom_tree(const String& dom_tree)
window->move_to_front();
}
-Tab::Tab(BrowserWindow& window, Type type)
- : m_type(type)
+Tab::Tab(BrowserWindow& window)
{
load_from_gml(tab_gml);
@@ -104,10 +102,7 @@ Tab::Tab(BrowserWindow& window, Type type)
auto& webview_container = *find_descendant_of_type_named<GUI::Widget>("webview_container");
- if (m_type == Type::InProcessWebView)
- m_page_view = webview_container.add<Web::InProcessWebView>();
- else
- m_web_content_view = webview_container.add<Web::OutOfProcessWebView>();
+ m_web_content_view = webview_container.add<Web::OutOfProcessWebView>();
auto& go_back_button = toolbar.add_action(window.go_back_action());
go_back_button.on_context_menu_request = [this](auto& context_menu_event) {
@@ -305,15 +300,6 @@ Tab::Tab(BrowserWindow& window, Type type)
}
};
- if (m_type == Type::InProcessWebView) {
- hooks().on_set_document = [this](auto* document) {
- if (document && m_console_window) {
- auto* console_widget = static_cast<ConsoleWidget*>(m_console_window->main_widget());
- console_widget->set_interpreter(document->interpreter().make_weak_ptr());
- }
- };
- }
-
auto focus_location_box_action = GUI::Action::create(
"Focus location box", { Mod_Ctrl, Key_L }, Key_F6, [this](auto&) {
m_location_box->set_focus(true);
@@ -364,7 +350,7 @@ Tab::Tab(BrowserWindow& window, Type type)
};
// FIXME: This is temporary, until the OOPWV properly supports the DOM Inspector
- window.inspect_dom_node_action().set_enabled(type == Type::InProcessWebView);
+ window.inspect_dom_node_action().set_enabled(false);
}
Tab::~Tab()
@@ -374,19 +360,12 @@ Tab::~Tab()
void Tab::load(const URL& url, LoadType load_type)
{
m_is_history_navigation = (load_type == LoadType::HistoryNavigation);
-
- if (m_type == Type::InProcessWebView)
- m_page_view->load(url);
- else
- m_web_content_view->load(url);
-
+ m_web_content_view->load(url);
m_location_box->set_focus(false);
}
URL Tab::url() const
{
- if (m_type == Type::InProcessWebView)
- return m_page_view->url();
return m_web_content_view->url();
}
@@ -442,16 +421,6 @@ void Tab::update_bookmark_button(const String& url)
void Tab::did_become_active()
{
- if (m_type == Type::InProcessWebView) {
- Web::ResourceLoader::the().on_load_counter_change = [this] {
- if (Web::ResourceLoader::the().pending_loads() == 0) {
- m_statusbar->set_text("");
- return;
- }
- m_statusbar->set_text(String::formatted("Loading ({} pending resources...)", Web::ResourceLoader::the().pending_loads()));
- };
- }
-
BookmarksBarWidget::the().on_bookmark_click = [this](auto& url, unsigned modifiers) {
if (modifiers & Mod_Ctrl)
on_tab_open_request(url);
@@ -480,15 +449,11 @@ void Tab::context_menu_requested(const Gfx::IntPoint& screen_position)
GUI::AbstractScrollableWidget& Tab::view()
{
- if (m_type == Type::InProcessWebView)
- return *m_page_view;
return *m_web_content_view;
}
Web::WebViewHooks& Tab::hooks()
{
- if (m_type == Type::InProcessWebView)
- return *m_page_view;
return *m_web_content_view;
}
@@ -512,34 +477,9 @@ BrowserWindow& Tab::window()
return static_cast<BrowserWindow&>(*Widget::window());
}
-void Tab::show_inspector_window(Browser::Tab::InspectorTarget target)
+void Tab::show_inspector_window(Browser::Tab::InspectorTarget)
{
- if (m_type == Tab::Type::InProcessWebView) {
- if (!m_dom_inspector_window) {
- m_dom_inspector_window = GUI::Window::construct(this);
- m_dom_inspector_window->resize(300, 500);
- m_dom_inspector_window->set_title("DOM inspector");
- m_dom_inspector_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"));
- m_dom_inspector_window->set_main_widget<InspectorWidget>();
- m_dom_inspector_window->on_close = [&]() {
- m_page_view->document()->set_inspected_node(nullptr);
- };
- }
- auto* inspector_widget = static_cast<InspectorWidget*>(m_dom_inspector_window->main_widget());
- inspector_widget->set_document(m_page_view->document());
- switch (target) {
- case InspectorTarget::Document:
- inspector_widget->set_inspected_node(nullptr);
- break;
- case InspectorTarget::HoveredElement:
- inspector_widget->set_inspected_node(m_page_view->document()->hovered_node());
- break;
- }
- m_dom_inspector_window->show();
- m_dom_inspector_window->move_to_front();
- } else {
- m_web_content_view->inspect_dom_tree();
- }
+ m_web_content_view->inspect_dom_tree();
}
}
diff --git a/Userland/Applications/Browser/Tab.h b/Userland/Applications/Browser/Tab.h
index ff9a9c63a0..2cfbef51f9 100644
--- a/Userland/Applications/Browser/Tab.h
+++ b/Userland/Applications/Browser/Tab.h
@@ -30,11 +30,6 @@ class Tab final : public GUI::Widget {
friend class BrowserWindow;
public:
- enum class Type {
- InProcessWebView,
- OutOfProcessWebView,
- };
-
virtual ~Tab() override;
URL url() const;
@@ -76,7 +71,7 @@ public:
GUI::AbstractScrollableWidget& view();
private:
- explicit Tab(BrowserWindow&, Type);
+ explicit Tab(BrowserWindow&);
BrowserWindow const& window() const;
BrowserWindow& window();
@@ -89,16 +84,12 @@ private:
void view_source(const URL& url, const String& source);
void view_dom_tree(const String&);
- Type m_type;
-
History m_history;
- RefPtr<Web::InProcessWebView> m_page_view;
RefPtr<Web::OutOfProcessWebView> m_web_content_view;
RefPtr<GUI::UrlBox> m_location_box;
RefPtr<GUI::Button> m_bookmark_button;
- RefPtr<GUI::Window> m_dom_inspector_window;
RefPtr<GUI::Window> m_console_window;
RefPtr<GUI::Statusbar> m_statusbar;
RefPtr<GUI::ToolbarContainer> m_toolbar_container;
diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp
index 91f9a14c19..81d314e387 100644
--- a/Userland/Applications/Browser/main.cpp
+++ b/Userland/Applications/Browser/main.cpp
@@ -29,7 +29,6 @@ namespace Browser {
String g_search_engine;
String g_home_url;
-bool g_single_process = false;
}
@@ -48,18 +47,11 @@ int main(int argc, char** argv)
const char* specified_url = nullptr;
Core::ArgsParser args_parser;
- args_parser.add_option(Browser::g_single_process, "Single-process mode", "single-process", 's');
args_parser.add_positional_argument(specified_url, "URL to open", "url", Core::ArgsParser::Required::No);
args_parser.parse(argc, argv);
auto app = GUI::Application::construct(argc, argv);
- if (Browser::g_single_process) {
- // Connect to the RequestServer and the WebSocket service immediately so we don't need to unveil their portals.
- Web::ResourceLoader::the();
- Web::HTML::WebSocketClientManager::the();
- }
-
// Connect to LaunchServer immediately and let it know that we won't ask for anything other than opening
// the user's downloads directory.
// FIXME: This should go away with a standalone download manager at some point.