mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 01:51:03 +09:00
Browser: Hide inspected-element outline when DOM Inspector is closed
...and then show it again when the inspector is re-opened. :^)
This commit is contained in:
parent
607bddac96
commit
3ef4ba810a
Notes:
sideshowbarker
2024-07-18 05:20:59 +09:00
Author: https://github.com/AtkinsSJ
Commit: 3ef4ba810a
Pull-request: https://github.com/SerenityOS/serenity/pull/9474
Issue: https://github.com/SerenityOS/serenity/issues/8936
3 changed files with 7 additions and 0 deletions
|
@ -220,6 +220,9 @@ void BrowserWindow::build_menus()
|
|||
tab.m_dom_inspector_window->set_title("DOM inspector");
|
||||
tab.m_dom_inspector_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"));
|
||||
tab.m_dom_inspector_window->set_main_widget<InspectorWidget>();
|
||||
tab.m_dom_inspector_window->on_close = [&]() {
|
||||
tab.m_page_view->document()->set_inspected_node(nullptr);
|
||||
};
|
||||
}
|
||||
auto* inspector_widget = static_cast<InspectorWidget*>(tab.m_dom_inspector_window->main_widget());
|
||||
inspector_widget->set_document(tab.m_page_view->document());
|
||||
|
|
|
@ -26,6 +26,7 @@ void InspectorWidget::set_inspected_node(GUI::ModelIndex const index)
|
|||
return;
|
||||
}
|
||||
auto* node = static_cast<Web::DOM::Node*>(index.internal_data());
|
||||
m_inspected_node = node;
|
||||
m_document->set_inspected_node(node);
|
||||
if (node && node->is_element()) {
|
||||
auto& element = verify_cast<Web::DOM::Element>(*node);
|
||||
|
@ -70,6 +71,7 @@ InspectorWidget::~InspectorWidget()
|
|||
|
||||
void InspectorWidget::set_document(Web::DOM::Document* document)
|
||||
{
|
||||
document->set_inspected_node(m_inspected_node);
|
||||
if (m_document == document)
|
||||
return;
|
||||
m_document = document;
|
||||
|
|
|
@ -29,6 +29,8 @@ private:
|
|||
RefPtr<GUI::TableView> m_style_table_view;
|
||||
RefPtr<GUI::TableView> m_computed_style_table_view;
|
||||
|
||||
RefPtr<Web::DOM::Node> m_inspected_node;
|
||||
|
||||
// One of these will be available, depending on if we're
|
||||
// in-process (m_document) or out-of-process (m_dom_json)
|
||||
RefPtr<Web::DOM::Document> m_document;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue