Ladybird: Allow right clicking and inspecting elements

This adds "Inspect Element" (currently the only entry) to the context
menu for the page, which will do what you expect (most of the time),
and bring up the Inspector with hovered element selected.
This commit is contained in:
MacDue 2023-05-08 21:15:35 +01:00 committed by Andreas Kling
commit 09773048b6
Notes: sideshowbarker 2024-07-16 20:26:59 +09:00
7 changed files with 101 additions and 9 deletions

View file

@ -540,12 +540,22 @@ bool WebContentView::is_inspector_open() const
return m_inspector_widget && m_inspector_widget->isVisible();
}
void WebContentView::show_inspector()
void WebContentView::show_inspector(InspectorTarget inspector_target)
{
bool inspector_previously_loaded = m_inspector_widget;
ensure_inspector_widget();
if (!inspector_previously_loaded || !m_inspector_widget->dom_loaded()) {
inspect_dom_tree();
inspect_accessibility_tree();
}
m_inspector_widget->show();
inspect_dom_tree();
inspect_accessibility_tree();
if (inspector_target == InspectorTarget::HoveredElement) {
auto hovered_node = get_hovered_node_id();
m_inspector_widget->set_selection({ hovered_node });
} else {
m_inspector_widget->select_default_node();
}
}
void WebContentView::update_zoom()