瀏覽代碼

LibWeb: Add document_fully_loaded event to DocumentObserver

SVGUseElement needs to be able to query the fully loaded document for
its referenced element.
PrestonLTaylor 2 年之前
父節點
當前提交
b322abd8d0
共有 2 個文件被更改,包括 6 次插入0 次删除
  1. 5 0
      Userland/Libraries/LibWeb/DOM/Document.cpp
  2. 1 0
      Userland/Libraries/LibWeb/DOM/DocumentObserver.h

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

@@ -1679,6 +1679,11 @@ void Document::completely_finish_loading()
             container->dispatch_event(DOM::Event::create(container->realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
         });
     }
+
+    for (auto& document_observer : m_document_observers) {
+        if (document_observer->document_fully_loaded)
+            document_observer->document_fully_loaded();
+    }
 }
 
 DeprecatedString Document::cookie(Cookie::Source source)

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

@@ -18,6 +18,7 @@ class DocumentObserver final : public Bindings::PlatformObject {
 
 public:
     JS::SafeFunction<void()> document_became_inactive;
+    JS::SafeFunction<void()> document_fully_loaded;
 
 private:
     explicit DocumentObserver(JS::Realm&, DOM::Document&);