Ver Fonte

LibWeb: Add did_stop_being_active_document_in_navigable()

Aliaksandr Kalenik há 1 ano atrás
pai
commit
2fbb6ae520

+ 13 - 0
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -2882,6 +2882,8 @@ void Document::unload(JS::GCPtr<Document>)
 
 
     // FIXME: 21. If newDocument is given, newDocument's was created via cross-origin redirects is false, and newDocument's origin is the same as oldDocument's origin, then set
     // FIXME: 21. If newDocument is given, newDocument's was created via cross-origin redirects is false, and newDocument's origin is the same as oldDocument's origin, then set
     //            newDocument's previous document unload timing to unloadTimingInfo.
     //            newDocument's previous document unload timing to unloadTimingInfo.
+
+    did_stop_being_active_document_in_navigable();
 }
 }
 
 
 // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#allowed-to-use
 // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#allowed-to-use
@@ -2920,6 +2922,17 @@ void Document::did_stop_being_active_document_in_browsing_context(Badge<HTML::Br
     }
     }
 }
 }
 
 
+void Document::did_stop_being_active_document_in_navigable()
+{
+    tear_down_layout_tree();
+
+    auto observers_to_notify = m_document_observers.values();
+    for (auto& document_observer : observers_to_notify) {
+        if (document_observer->document_became_inactive)
+            document_observer->document_became_inactive();
+    }
+}
+
 // https://w3c.github.io/editing/docs/execCommand/#querycommandsupported()
 // https://w3c.github.io/editing/docs/execCommand/#querycommandsupported()
 bool Document::query_command_supported(String const& command) const
 bool Document::query_command_supported(String const& command) const
 {
 {

+ 1 - 0
Userland/Libraries/LibWeb/DOM/Document.h

@@ -503,6 +503,7 @@ public:
     bool is_allowed_to_use_feature(PolicyControlledFeature) const;
     bool is_allowed_to_use_feature(PolicyControlledFeature) const;
 
 
     void did_stop_being_active_document_in_browsing_context(Badge<HTML::BrowsingContext>);
     void did_stop_being_active_document_in_browsing_context(Badge<HTML::BrowsingContext>);
+    void did_stop_being_active_document_in_navigable();
 
 
     bool query_command_supported(String const&) const;
     bool query_command_supported(String const&) const;