浏览代码

LibWeb: Add did_stop_being_active_document_in_navigable()

Aliaksandr Kalenik 1 年之前
父节点
当前提交
2fbb6ae520
共有 2 个文件被更改,包括 14 次插入0 次删除
  1. 13 0
      Userland/Libraries/LibWeb/DOM/Document.cpp
  2. 1 0
      Userland/Libraries/LibWeb/DOM/Document.h

+ 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
     //            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
@@ -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()
 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;
 
     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;