summaryrefslogtreecommitdiff
path: root/Userland/Applications/Browser
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-04-06 15:15:07 +0200
committerAndreas Kling <kling@serenityos.org>2022-04-06 19:35:08 +0200
commit06d97c892b6d69e6bcfb5769f7d6b8880d4584ad (patch)
tree92ab3e3a26ef527836d23462693200af153ed9d6 /Userland/Applications/Browser
parent59e8dedea2f3ba572c4804e89c3102132ce8d567 (diff)
downloadserenity-06d97c892b6d69e6bcfb5769f7d6b8880d4584ad.zip
LibWeb+Browser: Remove Web::WebViewHooks class
This was a mixin class that allowed sharing a set of hooks between InProcessWebView and OutOfProcessWebView. Now that there is only OOPWV, we don't need the mixin.
Diffstat (limited to 'Userland/Applications/Browser')
-rw-r--r--Userland/Applications/Browser/BrowserWindow.cpp36
-rw-r--r--Userland/Applications/Browser/Tab.cpp58
-rw-r--r--Userland/Applications/Browser/Tab.h4
3 files changed, 43 insertions, 55 deletions
diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp
index 7996f09a5b..7cf6e186e1 100644
--- a/Userland/Applications/Browser/BrowserWindow.cpp
+++ b/Userland/Applications/Browser/BrowserWindow.cpp
@@ -195,18 +195,18 @@ void BrowserWindow::build_menus()
m_copy_selection_action = GUI::CommonActions::make_copy_action([this](auto&) {
auto& tab = active_tab();
- auto selected_text = tab.m_web_content_view->selected_text();
+ auto selected_text = tab.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&) {
- active_tab().m_web_content_view->select_all();
+ active_tab().view().select_all();
});
m_view_source_action = GUI::Action::create(
"View &Source", { Mod_Ctrl, Key_U }, g_icon_bag.code, [this](auto&) {
- active_tab().m_web_content_view->get_source();
+ active_tab().view().get_source();
},
this);
m_view_source_action->set_status_tip("View source code of the current page");
@@ -278,7 +278,7 @@ void BrowserWindow::build_menus()
auto action = GUI::Action::create_checkable(
name, [=, this](auto&) {
Config::write_string("Browser", "Preferences", "ColorScheme", Web::CSS::preferred_color_scheme_to_string(preference_value));
- active_tab().m_web_content_view->set_preferred_color_scheme(preference_value);
+ active_tab().view().set_preferred_color_scheme(preference_value);
},
this);
if (current_setting == preference_value)
@@ -302,22 +302,22 @@ void BrowserWindow::build_menus()
auto& debug_menu = add_menu("&Debug");
debug_menu.add_action(GUI::Action::create(
"Dump &DOM Tree", g_icon_bag.dom_tree, [this](auto&) {
- active_tab().m_web_content_view->debug_request("dump-dom-tree");
+ active_tab().view().debug_request("dump-dom-tree");
},
this));
debug_menu.add_action(GUI::Action::create(
"Dump &Layout Tree", g_icon_bag.layout, [this](auto&) {
- active_tab().m_web_content_view->debug_request("dump-layout-tree");
+ active_tab().view().debug_request("dump-layout-tree");
},
this));
debug_menu.add_action(GUI::Action::create(
"Dump S&tacking Context Tree", g_icon_bag.layers, [this](auto&) {
- active_tab().m_web_content_view->debug_request("dump-stacking-context-tree");
+ active_tab().view().debug_request("dump-stacking-context-tree");
},
this));
debug_menu.add_action(GUI::Action::create(
"Dump &Style Sheets", g_icon_bag.filetype_css, [this](auto&) {
- active_tab().m_web_content_view->debug_request("dump-style-sheets");
+ active_tab().view().debug_request("dump-style-sheets");
},
this));
debug_menu.add_action(GUI::Action::create("Dump &History", { Mod_Ctrl, Key_H }, g_icon_bag.history, [this](auto&) {
@@ -329,12 +329,12 @@ void BrowserWindow::build_menus()
tab.on_dump_cookies();
}));
debug_menu.add_action(GUI::Action::create("Dump Loc&al Storage", g_icon_bag.local_storage, [this](auto&) {
- active_tab().m_web_content_view->debug_request("dump-local-storage");
+ active_tab().view().debug_request("dump-local-storage");
}));
debug_menu.add_separator();
auto line_box_borders_action = GUI::Action::create_checkable(
"Line &Box Borders", [this](auto& action) {
- active_tab().m_web_content_view->debug_request("set-line-box-borders", action.is_checked() ? "on" : "off");
+ active_tab().view().debug_request("set-line-box-borders", action.is_checked() ? "on" : "off");
},
this);
line_box_borders_action->set_checked(false);
@@ -342,16 +342,16 @@ void BrowserWindow::build_menus()
debug_menu.add_separator();
debug_menu.add_action(GUI::Action::create("Collect &Garbage", { Mod_Ctrl | Mod_Shift, Key_G }, g_icon_bag.trash_can, [this](auto&) {
- active_tab().m_web_content_view->debug_request("collect-garbage");
+ active_tab().view().debug_request("collect-garbage");
}));
debug_menu.add_action(GUI::Action::create("Clear &Cache", { Mod_Ctrl | Mod_Shift, Key_C }, g_icon_bag.clear_cache, [this](auto&) {
- active_tab().m_web_content_view->debug_request("clear-cache");
+ active_tab().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&) {
- active_tab().m_web_content_view->debug_request("spoof-user-agent", Web::default_user_agent);
+ active_tab().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);
@@ -361,7 +361,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&) {
- active_tab().m_web_content_view->debug_request("spoof-user-agent", user_agent);
+ active_tab().view().debug_request("spoof-user-agent", user_agent);
});
action->set_status_tip(user_agent);
spoof_user_agent_menu.add_action(action);
@@ -380,7 +380,7 @@ void BrowserWindow::build_menus()
m_disable_user_agent_spoofing->activate();
return;
}
- active_tab().m_web_content_view->debug_request("spoof-user-agent", user_agent);
+ active_tab().view().debug_request("spoof-user-agent", user_agent);
action.set_status_tip(user_agent);
});
spoof_user_agent_menu.add_action(custom_user_agent);
@@ -389,7 +389,7 @@ void BrowserWindow::build_menus()
debug_menu.add_separator();
auto scripting_enabled_action = GUI::Action::create_checkable(
"Enable Scripting", [this](auto& action) {
- active_tab().m_web_content_view->debug_request("scripting", action.is_checked() ? "on" : "off");
+ active_tab().view().debug_request("scripting", action.is_checked() ? "on" : "off");
},
this);
scripting_enabled_action->set_checked(true);
@@ -397,7 +397,7 @@ void BrowserWindow::build_menus()
auto same_origin_policy_action = GUI::Action::create_checkable(
"Enable Same Origin &Policy", [this](auto& action) {
- active_tab().m_web_content_view->debug_request("same-origin-policy", action.is_checked() ? "on" : "off");
+ active_tab().view().debug_request("same-origin-policy", action.is_checked() ? "on" : "off");
},
this);
same_origin_policy_action->set_checked(false);
@@ -556,7 +556,7 @@ void BrowserWindow::create_new_tab(URL url, bool activate)
};
new_tab.on_get_local_storage_entries = [this]() {
- return active_tab().m_web_content_view->get_local_storage_entries();
+ return active_tab().view().get_local_storage_entries();
};
new_tab.load(url);
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp
index 3e654ee149..e634b2e58f 100644
--- a/Userland/Applications/Browser/Tab.cpp
+++ b/Userland/Applications/Browser/Tab.cpp
@@ -189,7 +189,7 @@ Tab::Tab(BrowserWindow& window)
},
this);
- hooks().on_load_start = [this](auto& url) {
+ view().on_load_start = [this](auto& url) {
m_navigating_url = url;
m_loaded = false;
@@ -213,7 +213,7 @@ Tab::Tab(BrowserWindow& window)
m_console_widget->reset();
};
- hooks().on_load_finish = [this](auto&) {
+ view().on_load_finish = [this](auto&) {
m_navigating_url = {};
m_loaded = true;
@@ -223,7 +223,7 @@ Tab::Tab(BrowserWindow& window)
m_web_content_view->inspect_dom_tree();
};
- hooks().on_link_click = [this](auto& url, auto& target, unsigned modifiers) {
+ view().on_link_click = [this](auto& url, auto& target, unsigned modifiers) {
if (target == "_blank" || modifiers == Mod_Ctrl) {
on_tab_open_request(url);
} else {
@@ -231,18 +231,18 @@ Tab::Tab(BrowserWindow& window)
}
};
- hooks().on_resource_status_change = [this](auto count_waiting) {
+ view().on_resource_status_change = [this](auto count_waiting) {
update_status({}, count_waiting);
};
m_link_context_menu = GUI::Menu::construct();
auto link_default_action = GUI::Action::create("&Open", [this](auto&) {
- hooks().on_link_click(m_link_context_menu_url, "", 0);
+ view().on_link_click(m_link_context_menu_url, "", 0);
});
m_link_context_menu->add_action(link_default_action);
m_link_context_menu_default_action = link_default_action;
m_link_context_menu->add_action(GUI::Action::create("Open in New &Tab", [this](auto&) {
- hooks().on_link_click(m_link_context_menu_url, "_blank", 0);
+ view().on_link_click(m_link_context_menu_url, "_blank", 0);
}));
m_link_context_menu->add_separator();
m_link_context_menu->add_action(GUI::Action::create("&Copy URL", [this](auto&) {
@@ -255,17 +255,17 @@ Tab::Tab(BrowserWindow& window)
m_link_context_menu->add_separator();
m_link_context_menu->add_action(window.inspect_dom_node_action());
- hooks().on_link_context_menu_request = [this](auto& url, auto& screen_position) {
+ view().on_link_context_menu_request = [this](auto& url, auto& screen_position) {
m_link_context_menu_url = url;
m_link_context_menu->popup(screen_position, m_link_context_menu_default_action);
};
m_image_context_menu = GUI::Menu::construct();
m_image_context_menu->add_action(GUI::Action::create("&Open Image", [this](auto&) {
- hooks().on_link_click(m_image_context_menu_url, "", 0);
+ view().on_link_click(m_image_context_menu_url, "", 0);
}));
m_image_context_menu->add_action(GUI::Action::create("Open Image in New &Tab", [this](auto&) {
- hooks().on_link_click(m_image_context_menu_url, "_blank", 0);
+ view().on_link_click(m_image_context_menu_url, "_blank", 0);
}));
m_image_context_menu->add_separator();
m_image_context_menu->add_action(GUI::Action::create("&Copy Image", [this](auto&) {
@@ -282,17 +282,17 @@ Tab::Tab(BrowserWindow& window)
m_image_context_menu->add_separator();
m_image_context_menu->add_action(window.inspect_dom_node_action());
- hooks().on_image_context_menu_request = [this](auto& image_url, auto& screen_position, Gfx::ShareableBitmap const& shareable_bitmap) {
+ view().on_image_context_menu_request = [this](auto& image_url, auto& screen_position, Gfx::ShareableBitmap const& shareable_bitmap) {
m_image_context_menu_url = image_url;
m_image_context_menu_bitmap = shareable_bitmap;
m_image_context_menu->popup(screen_position);
};
- hooks().on_link_middle_click = [this](auto& href, auto&, auto) {
- hooks().on_link_click(href, "_blank", 0);
+ view().on_link_middle_click = [this](auto& href, auto&, auto) {
+ view().on_link_click(href, "_blank", 0);
};
- hooks().on_title_change = [this](auto& title) {
+ view().on_title_change = [this](auto& title) {
if (title.is_null()) {
m_history.update_title(url().to_string());
m_title = url().to_string();
@@ -304,43 +304,43 @@ Tab::Tab(BrowserWindow& window)
on_title_change(m_title);
};
- hooks().on_favicon_change = [this](auto& icon) {
+ view().on_favicon_change = [this](auto& icon) {
m_icon = icon;
m_location_box->set_icon(&icon);
if (on_favicon_change)
on_favicon_change(icon);
};
- hooks().on_get_cookie = [this](auto& url, auto source) -> String {
+ view().on_get_cookie = [this](auto& url, auto source) -> String {
if (on_get_cookie)
return on_get_cookie(url, source);
return {};
};
- hooks().on_set_cookie = [this](auto& url, auto& cookie, auto source) {
+ view().on_set_cookie = [this](auto& url, auto& cookie, auto source) {
if (on_set_cookie)
on_set_cookie(url, cookie, source);
};
- hooks().on_get_source = [this](auto& url, auto& source) {
+ view().on_get_source = [this](auto& url, auto& source) {
view_source(url, source);
};
- hooks().on_get_dom_tree = [this](auto& dom_tree) {
+ view().on_get_dom_tree = [this](auto& dom_tree) {
if (m_dom_inspector_widget)
m_dom_inspector_widget->set_dom_json(dom_tree);
};
- hooks().on_get_dom_node_properties = [this](auto node_id, auto& specified, auto& computed, auto& custom_properties, auto& node_box_sizing) {
+ view().on_get_dom_node_properties = [this](auto node_id, auto& specified, auto& computed, auto& custom_properties, auto& node_box_sizing) {
m_dom_inspector_widget->set_dom_node_properties_json({ node_id }, specified, computed, custom_properties, node_box_sizing);
};
- hooks().on_js_console_new_message = [this](auto message_index) {
+ view().on_js_console_new_message = [this](auto message_index) {
if (m_console_widget)
m_console_widget->notify_about_new_console_message(message_index);
};
- hooks().on_get_js_console_messages = [this](auto start_index, auto& message_types, auto& messages) {
+ view().on_get_js_console_messages = [this](auto start_index, auto& message_types, auto& messages) {
if (m_console_widget)
m_console_widget->handle_console_messages(start_index, message_types, messages);
};
@@ -354,14 +354,14 @@ Tab::Tab(BrowserWindow& window)
m_statusbar = *find_descendant_of_type_named<GUI::Statusbar>("statusbar");
- hooks().on_link_hover = [this](auto& url) {
+ view().on_link_hover = [this](auto& url) {
if (url.is_valid())
update_status(url.to_string());
else
update_status();
};
- hooks().on_url_drop = [this](auto& url) {
+ view().on_url_drop = [this](auto& url) {
load(url);
};
@@ -390,7 +390,7 @@ Tab::Tab(BrowserWindow& window)
m_page_context_menu->add_action(window.view_source_action());
m_page_context_menu->add_action(window.inspect_dom_tree_action());
m_page_context_menu->add_action(window.inspect_dom_node_action());
- hooks().on_context_menu_request = [&](auto& screen_position) {
+ view().on_context_menu_request = [&](auto& screen_position) {
m_page_context_menu->popup(screen_position);
};
}
@@ -516,16 +516,6 @@ void Tab::content_filters_changed()
m_web_content_view->set_content_filters({});
}
-GUI::AbstractScrollableWidget& Tab::view()
-{
- return *m_web_content_view;
-}
-
-Web::WebViewHooks& Tab::hooks()
-{
- return *m_web_content_view;
-}
-
void Tab::action_entered(GUI::Action& action)
{
m_statusbar->set_override_text(action.status_tip());
diff --git a/Userland/Applications/Browser/Tab.h b/Userland/Applications/Browser/Tab.h
index 67f85f0cb6..2e2ee353a7 100644
--- a/Userland/Applications/Browser/Tab.h
+++ b/Userland/Applications/Browser/Tab.h
@@ -18,7 +18,6 @@
namespace Web {
class OutOfProcessWebView;
-class WebViewHooks;
}
namespace Browser {
@@ -79,7 +78,7 @@ public:
String const& title() const { return m_title; }
Gfx::Bitmap const* icon() const { return m_icon; }
- GUI::AbstractScrollableWidget& view();
+ Web::OutOfProcessWebView& view() { return *m_web_content_view; }
private:
explicit Tab(BrowserWindow&);
@@ -87,7 +86,6 @@ private:
BrowserWindow const& window() const;
BrowserWindow& window();
- Web::WebViewHooks& hooks();
void update_actions();
void bookmark_current_url();
void update_bookmark_button(String const& url);