mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
LibWeb: Return a representation of an 'Agent' in 'relevant agent'
This makes it more convenient to use the 'relvant agent' concept, instead of the awkward dynamic casts we needed to do for every call site. mutation_observers is also changed to hold a GC::Root instead of raw GC::Ptr. Somehow this was not causing problems before, but trips up CI after these changes.
This commit is contained in:
parent
5bed8f4055
commit
64eeda6450
Notes:
github-actions[bot]
2025-01-11 15:40:39 +00:00
Author: https://github.com/shannonbooth
Commit: 64eeda6450
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3142
15 changed files with 140 additions and 98 deletions
|
@ -36,6 +36,7 @@
|
|||
#include <LibWeb/HTML/Parser/HTMLEncodingDetection.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLToken.h>
|
||||
#include <LibWeb/HTML/Scripting/Agent.h>
|
||||
#include <LibWeb/HTML/Scripting/ExceptionReporter.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
|
||||
|
@ -752,8 +753,7 @@ GC::Ref<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, Opt
|
|||
perform_a_microtask_checkpoint();
|
||||
|
||||
// 3. Push a new element queue onto document's relevant agent's custom element reactions stack.
|
||||
auto& custom_data = verify_cast<Bindings::WebEngineCustomData>(*vm.custom_data());
|
||||
custom_data.custom_element_reactions_stack.element_queue_stack.append({});
|
||||
relevant_agent(document).custom_element_reactions_stack.element_queue_stack.append({});
|
||||
}
|
||||
|
||||
// 9. Let element be the result of creating an element given document, localName, given namespace, null, is, and willExecuteScript.
|
||||
|
@ -770,9 +770,7 @@ GC::Ref<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, Opt
|
|||
// 11. If willExecuteScript is true:
|
||||
if (will_execute_script) {
|
||||
// 1. Let queue be the result of popping from document's relevant agent's custom element reactions stack. (This will be the same element queue as was pushed above.)
|
||||
auto& vm = main_thread_event_loop().vm();
|
||||
auto& custom_data = verify_cast<Bindings::WebEngineCustomData>(*vm.custom_data());
|
||||
auto queue = custom_data.custom_element_reactions_stack.element_queue_stack.take_last();
|
||||
auto queue = relevant_agent(document).custom_element_reactions_stack.element_queue_stack.take_last();
|
||||
|
||||
// 2. Invoke custom element reactions in queue.
|
||||
Bindings::invoke_custom_element_reactions(queue);
|
||||
|
@ -5150,8 +5148,7 @@ void HTMLParser::insert_an_element_at_the_adjusted_insertion_location(GC::Ref<DO
|
|||
// 3. If the parser was not created as part of the HTML fragment parsing algorithm,
|
||||
// then push a new element queue onto element's relevant agent's custom element reactions stack.
|
||||
if (!m_parsing_fragment) {
|
||||
auto& custom_data = verify_cast<Bindings::WebEngineCustomData>(*relevant_agent(*element).custom_data());
|
||||
custom_data.custom_element_reactions_stack.element_queue_stack.append({});
|
||||
relevant_agent(*element).custom_element_reactions_stack.element_queue_stack.append({});
|
||||
}
|
||||
|
||||
// 4. Insert element at the adjusted insertion location.
|
||||
|
@ -5160,8 +5157,7 @@ void HTMLParser::insert_an_element_at_the_adjusted_insertion_location(GC::Ref<DO
|
|||
// 5. If the parser was not created as part of the HTML fragment parsing algorithm,
|
||||
// then pop the element queue from element's relevant agent's custom element reactions stack, and invoke custom element reactions in that queue.
|
||||
if (!m_parsing_fragment) {
|
||||
auto& custom_data = verify_cast<Bindings::WebEngineCustomData>(*relevant_agent(*element).custom_data());
|
||||
auto queue = custom_data.custom_element_reactions_stack.element_queue_stack.take_last();
|
||||
auto queue = relevant_agent(*element).custom_element_reactions_stack.element_queue_stack.take_last();
|
||||
Bindings::invoke_custom_element_reactions(queue);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue