mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb: Make HTML::Task IDs a sequential, distinct numeric type
This also fixes a bug where task IDs were being deallocated from the wrong IDAllocator. I don't know if it was actually possible to cause any real trouble with that mistake, nor do I know how to write a test for it, but this makes the bug go away.
This commit is contained in:
parent
0e1256e5a4
commit
08d60d7521
Notes:
github-actions[bot]
2024-08-05 07:12:59 +00:00
Author: https://github.com/awesomekling
Commit: 08d60d7521
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/962
12 changed files with 33 additions and 29 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DistinctNumeric.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibJS/Heap/CellAllocator.h>
|
||||
#include <LibJS/SafeFunction.h>
|
||||
|
@ -15,6 +16,8 @@ namespace Web::HTML {
|
|||
|
||||
struct UniqueTaskSource;
|
||||
|
||||
AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u64, TaskID, Comparison);
|
||||
|
||||
class Task final : public JS::Cell {
|
||||
JS_CELL(Task, JS::Cell);
|
||||
JS_DECLARE_ALLOCATOR(Task);
|
||||
|
@ -69,9 +72,8 @@ public:
|
|||
static JS::NonnullGCPtr<Task> create(JS::VM&, Source, JS::GCPtr<DOM::Document const>, JS::NonnullGCPtr<JS::HeapFunction<void()>> steps);
|
||||
|
||||
virtual ~Task() override;
|
||||
virtual void finalize() override;
|
||||
|
||||
int id() const { return m_id; }
|
||||
[[nodiscard]] TaskID id() const { return m_id; }
|
||||
Source source() const { return m_source; }
|
||||
void execute();
|
||||
|
||||
|
@ -84,7 +86,7 @@ private:
|
|||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
int m_id { 0 };
|
||||
TaskID m_id {};
|
||||
Source m_source { Source::Unspecified };
|
||||
JS::NonnullGCPtr<JS::HeapFunction<void()>> m_steps;
|
||||
JS::GCPtr<DOM::Document const> m_document;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue