diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 2d74867e527..6f206ab842f 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1512,32 +1512,44 @@ JS::NonnullGCPtr Document::take_pending_parsing_blockin void Document::add_script_to_execute_when_parsing_has_finished(Badge, HTML::HTMLScriptElement& script) { - m_scripts_to_execute_when_parsing_has_finished.append(JS::make_handle(script)); + m_scripts_to_execute_when_parsing_has_finished.append(script); } Vector> Document::take_scripts_to_execute_when_parsing_has_finished(Badge) { - return move(m_scripts_to_execute_when_parsing_has_finished); + Vector> handles; + for (auto script : m_scripts_to_execute_when_parsing_has_finished) + handles.append(JS::make_handle(script)); + m_scripts_to_execute_when_parsing_has_finished.clear(); + return handles; } void Document::add_script_to_execute_as_soon_as_possible(Badge, HTML::HTMLScriptElement& script) { - m_scripts_to_execute_as_soon_as_possible.append(JS::make_handle(script)); + m_scripts_to_execute_as_soon_as_possible.append(script); } Vector> Document::take_scripts_to_execute_as_soon_as_possible(Badge) { - return move(m_scripts_to_execute_as_soon_as_possible); + Vector> handles; + for (auto script : m_scripts_to_execute_as_soon_as_possible) + handles.append(JS::make_handle(script)); + m_scripts_to_execute_as_soon_as_possible.clear(); + return handles; } void Document::add_script_to_execute_in_order_as_soon_as_possible(Badge, HTML::HTMLScriptElement& script) { - m_scripts_to_execute_in_order_as_soon_as_possible.append(JS::make_handle(script)); + m_scripts_to_execute_in_order_as_soon_as_possible.append(script); } Vector> Document::take_scripts_to_execute_in_order_as_soon_as_possible(Badge) { - return move(m_scripts_to_execute_in_order_as_soon_as_possible); + Vector> handles; + for (auto script : m_scripts_to_execute_in_order_as_soon_as_possible) + handles.append(JS::make_handle(script)); + m_scripts_to_execute_in_order_as_soon_as_possible.clear(); + return handles; } // https://dom.spec.whatwg.org/#dom-document-importnode @@ -1942,8 +1954,8 @@ void Document::completely_finish_loading() auto observers_to_notify = m_document_observers.values(); for (auto& document_observer : observers_to_notify) { - if (document_observer->document_completely_loaded) - document_observer->document_completely_loaded(); + if (document_observer->document_completely_loaded()) + document_observer->document_completely_loaded()->function()(); } } @@ -2897,8 +2909,8 @@ void Document::did_stop_being_active_document_in_browsing_context(Badgedocument_became_inactive) - document_observer->document_became_inactive(); + if (document_observer->document_became_inactive()) + document_observer->document_became_inactive()->function()(); } } @@ -2908,8 +2920,8 @@ void Document::did_stop_being_active_document_in_navigable() 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(); + if (document_observer->document_became_inactive()) + document_observer->document_became_inactive()->function()(); } } diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 703516575ff..8c8c7bfabee 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -253,15 +253,15 @@ public: void add_script_to_execute_when_parsing_has_finished(Badge, HTML::HTMLScriptElement&); Vector> take_scripts_to_execute_when_parsing_has_finished(Badge); - Vector>& scripts_to_execute_when_parsing_has_finished() { return m_scripts_to_execute_when_parsing_has_finished; } + Vector>& scripts_to_execute_when_parsing_has_finished() { return m_scripts_to_execute_when_parsing_has_finished; } void add_script_to_execute_as_soon_as_possible(Badge, HTML::HTMLScriptElement&); Vector> take_scripts_to_execute_as_soon_as_possible(Badge); - Vector>& scripts_to_execute_as_soon_as_possible() { return m_scripts_to_execute_as_soon_as_possible; } + Vector>& scripts_to_execute_as_soon_as_possible() { return m_scripts_to_execute_as_soon_as_possible; } void add_script_to_execute_in_order_as_soon_as_possible(Badge, HTML::HTMLScriptElement&); Vector> take_scripts_to_execute_in_order_as_soon_as_possible(Badge); - Vector>& scripts_to_execute_in_order_as_soon_as_possible() { return m_scripts_to_execute_in_order_as_soon_as_possible; } + Vector>& scripts_to_execute_in_order_as_soon_as_possible() { return m_scripts_to_execute_in_order_as_soon_as_possible; } QuirksMode mode() const { return m_quirks_mode; } bool in_quirks_mode() const { return m_quirks_mode == QuirksMode::Yes; } @@ -583,13 +583,13 @@ private: JS::GCPtr m_pending_parsing_blocking_script; - Vector> m_scripts_to_execute_when_parsing_has_finished; + Vector> m_scripts_to_execute_when_parsing_has_finished; // https://html.spec.whatwg.org/multipage/scripting.html#list-of-scripts-that-will-execute-in-order-as-soon-as-possible - Vector> m_scripts_to_execute_in_order_as_soon_as_possible; + Vector> m_scripts_to_execute_in_order_as_soon_as_possible; // https://html.spec.whatwg.org/multipage/scripting.html#set-of-scripts-that-will-execute-as-soon-as-possible - Vector> m_scripts_to_execute_as_soon_as_possible; + Vector> m_scripts_to_execute_as_soon_as_possible; QuirksMode m_quirks_mode { QuirksMode::No };