mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:47:42 +00:00
LibWeb: Assign a unique ID to each HTML task
And return that ID when queueing an element task. This is required for some task tracking - specifically, the HTML ToggleTaskTracker struct.
This commit is contained in:
parent
5ae9b2fdaf
commit
f598a357ad
4 changed files with 15 additions and 4 deletions
|
@ -759,10 +759,14 @@ void Element::make_html_uppercased_qualified_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/webappapis.html#queue-an-element-task
|
// https://html.spec.whatwg.org/multipage/webappapis.html#queue-an-element-task
|
||||||
void Element::queue_an_element_task(HTML::Task::Source source, JS::SafeFunction<void()> steps)
|
int Element::queue_an_element_task(HTML::Task::Source source, JS::SafeFunction<void()> steps)
|
||||||
{
|
{
|
||||||
auto task = HTML::Task::create(source, &document(), move(steps));
|
auto task = HTML::Task::create(source, &document(), move(steps));
|
||||||
|
auto id = task->id();
|
||||||
|
|
||||||
HTML::main_thread_event_loop().task_queue().add(move(task));
|
HTML::main_thread_event_loop().task_queue().add(move(task));
|
||||||
|
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
// https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
||||||
|
|
|
@ -197,7 +197,7 @@ public:
|
||||||
void set_custom_properties(Optional<CSS::Selector::PseudoElement>, HashMap<DeprecatedFlyString, CSS::StyleProperty> custom_properties);
|
void set_custom_properties(Optional<CSS::Selector::PseudoElement>, HashMap<DeprecatedFlyString, CSS::StyleProperty> custom_properties);
|
||||||
[[nodiscard]] HashMap<DeprecatedFlyString, CSS::StyleProperty> const& custom_properties(Optional<CSS::Selector::PseudoElement>) const;
|
[[nodiscard]] HashMap<DeprecatedFlyString, CSS::StyleProperty> const& custom_properties(Optional<CSS::Selector::PseudoElement>) const;
|
||||||
|
|
||||||
void queue_an_element_task(HTML::Task::Source, JS::SafeFunction<void()>);
|
int queue_an_element_task(HTML::Task::Source, JS::SafeFunction<void()>);
|
||||||
|
|
||||||
bool is_void_element() const;
|
bool is_void_element() const;
|
||||||
bool serializes_as_void() const;
|
bool serializes_as_void() const;
|
||||||
|
|
|
@ -11,15 +11,20 @@
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
static IDAllocator s_unique_task_source_allocator { static_cast<int>(Task::Source::UniqueTaskSourceStart) };
|
static IDAllocator s_unique_task_source_allocator { static_cast<int>(Task::Source::UniqueTaskSourceStart) };
|
||||||
|
static IDAllocator s_task_id_allocator;
|
||||||
|
|
||||||
Task::Task(Source source, DOM::Document const* document, JS::SafeFunction<void()> steps)
|
Task::Task(Source source, DOM::Document const* document, JS::SafeFunction<void()> steps)
|
||||||
: m_source(source)
|
: m_id(s_task_id_allocator.allocate())
|
||||||
|
, m_source(source)
|
||||||
, m_steps(move(steps))
|
, m_steps(move(steps))
|
||||||
, m_document(JS::make_handle(document))
|
, m_document(JS::make_handle(document))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::~Task() = default;
|
Task::~Task()
|
||||||
|
{
|
||||||
|
s_unique_task_source_allocator.deallocate(m_id);
|
||||||
|
}
|
||||||
|
|
||||||
void Task::execute()
|
void Task::execute()
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
}
|
}
|
||||||
~Task();
|
~Task();
|
||||||
|
|
||||||
|
int id() const { return m_id; }
|
||||||
Source source() const { return m_source; }
|
Source source() const { return m_source; }
|
||||||
void execute();
|
void execute();
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ public:
|
||||||
private:
|
private:
|
||||||
Task(Source, DOM::Document const*, JS::SafeFunction<void()> steps);
|
Task(Source, DOM::Document const*, JS::SafeFunction<void()> steps);
|
||||||
|
|
||||||
|
int m_id { 0 };
|
||||||
Source m_source { Source::Unspecified };
|
Source m_source { Source::Unspecified };
|
||||||
JS::SafeFunction<void()> m_steps;
|
JS::SafeFunction<void()> m_steps;
|
||||||
JS::Handle<DOM::Document const> m_document;
|
JS::Handle<DOM::Document const> m_document;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue