LibWeb: Split out SimilarOriginWindowAgent from HTML::Agent

To allow for adding the concept of a WorkerAgent to be reused
between shared and dedicated workers. An event loop is the
commonality between the different agent types, though, there
are some differences between those event loops which we customize
on the construction of the HTML::EventLoop.
This commit is contained in:
Shannon Booth 2025-04-24 15:04:13 +12:00 committed by Andreas Kling
commit 084cceab5c
Notes: github-actions[bot] 2025-04-25 14:45:55 +00:00
11 changed files with 103 additions and 54 deletions

View file

@ -63,7 +63,7 @@
#include <LibWeb/HTML/HTMLUListElement.h>
#include <LibWeb/HTML/Numbers.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/HTML/Scripting/Agent.h>
#include <LibWeb/HTML/Scripting/SimilarOriginWindowAgent.h>
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
#include <LibWeb/HTML/TraversableNavigable.h>
#include <LibWeb/HTML/Window.h>
@ -2487,7 +2487,7 @@ bool Element::include_in_accessibility_tree() const
void Element::enqueue_an_element_on_the_appropriate_element_queue()
{
// 1. Let reactionsStack be element's relevant agent's custom element reactions stack.
auto& relevant_agent = HTML::relevant_agent(*this);
auto& relevant_agent = HTML::relevant_similar_origin_window_agent(*this);
auto& reactions_stack = relevant_agent.custom_element_reactions_stack;
// 2. If reactionsStack is empty, then:
@ -2505,7 +2505,7 @@ void Element::enqueue_an_element_on_the_appropriate_element_queue()
// 4. Queue a microtask to perform the following steps:
// NOTE: `this` is protected by GC::Function
HTML::queue_a_microtask(&document(), GC::create_function(heap(), [this]() {
auto& reactions_stack = HTML::relevant_agent(*this).custom_element_reactions_stack;
auto& reactions_stack = HTML::relevant_similar_origin_window_agent(*this).custom_element_reactions_stack;
// 1. Invoke custom element reactions in reactionsStack's backup element queue.
Bindings::invoke_custom_element_reactions(reactions_stack.backup_element_queue);