1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:57:44 +00:00

Browser: Implement "Inspect Element" context menu action

This is finally working for OOPWV! :^)
This commit is contained in:
Sam Atkins 2021-08-27 17:40:25 +01:00 committed by Andreas Kling
parent 1ccf10789e
commit 97379ace25
3 changed files with 44 additions and 14 deletions

View file

@ -340,9 +340,6 @@ Tab::Tab(BrowserWindow& window)
hooks().on_context_menu_request = [&](auto& screen_position) {
m_page_context_menu->popup(screen_position);
};
// FIXME: This is temporary, until the OOPWV properly supports the DOM Inspector
window.inspect_dom_node_action().set_enabled(false);
}
Tab::~Tab()
@ -469,7 +466,7 @@ BrowserWindow& Tab::window()
return static_cast<BrowserWindow&>(*Widget::window());
}
void Tab::show_inspector_window(Browser::Tab::InspectorTarget)
void Tab::show_inspector_window(Browser::Tab::InspectorTarget inspector_target)
{
if (!m_dom_inspector_widget) {
auto window = GUI::Window::construct(&this->window());
@ -482,9 +479,14 @@ void Tab::show_inspector_window(Browser::Tab::InspectorTarget)
m_dom_inspector_widget = window->set_main_widget<InspectorWidget>();
m_dom_inspector_widget->set_web_view(*m_web_content_view);
}
m_web_content_view->inspect_dom_tree();
if (inspector_target == InspectorTarget::HoveredElement) {
Optional<i32> hovered_node = m_web_content_view->get_hovered_node_id();
VERIFY(hovered_node.has_value());
m_dom_inspector_widget->set_inspected_node(hovered_node.value());
}
auto* window = m_dom_inspector_widget->window();
window->show();
window->move_to_front();