summaryrefslogtreecommitdiff
path: root/Userland/Applications/Browser
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@gmail.com>2021-08-17 14:16:09 +0100
committerAndreas Kling <kling@serenityos.org>2021-08-23 15:59:29 +0200
commit3ef4ba810a0c99e8c2ad5e32272dc025b255710a (patch)
tree8d339e6f4dcc62beedb7a0334fc9dac339b6dfad /Userland/Applications/Browser
parent607bddac960981221d80d6b705355960517d593b (diff)
downloadserenity-3ef4ba810a0c99e8c2ad5e32272dc025b255710a.zip
Browser: Hide inspected-element outline when DOM Inspector is closed
...and then show it again when the inspector is re-opened. :^)
Diffstat (limited to 'Userland/Applications/Browser')
-rw-r--r--Userland/Applications/Browser/BrowserWindow.cpp3
-rw-r--r--Userland/Applications/Browser/InspectorWidget.cpp2
-rw-r--r--Userland/Applications/Browser/InspectorWidget.h2
3 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp
index 17605bc13f..44351142e0 100644
--- a/Userland/Applications/Browser/BrowserWindow.cpp
+++ b/Userland/Applications/Browser/BrowserWindow.cpp
@@ -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());
diff --git a/Userland/Applications/Browser/InspectorWidget.cpp b/Userland/Applications/Browser/InspectorWidget.cpp
index 11aa631407..9863c010f0 100644
--- a/Userland/Applications/Browser/InspectorWidget.cpp
+++ b/Userland/Applications/Browser/InspectorWidget.cpp
@@ -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;
diff --git a/Userland/Applications/Browser/InspectorWidget.h b/Userland/Applications/Browser/InspectorWidget.h
index 82f74084ab..afbd0e1eea 100644
--- a/Userland/Applications/Browser/InspectorWidget.h
+++ b/Userland/Applications/Browser/InspectorWidget.h
@@ -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;