diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-08 23:53:55 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-09 02:18:31 +0200 |
commit | bc3a432cb229a4fb8fb1607608f55accff23f3c1 (patch) | |
tree | 7419a10ed2869d664c69b5b8421cc23b75165365 /Userland/Libraries | |
parent | 462120d900666a2cfdace25586d979150806fd6c (diff) | |
download | serenity-bc3a432cb229a4fb8fb1607608f55accff23f3c1.zip |
LibWeb: Add HTML::Task::Source to model "generic task sources"
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/EventLoop/Task.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/EventLoop/Task.h | 17 |
2 files changed, 17 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/Task.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/Task.cpp index a913fcb815..ab282941ae 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/Task.cpp +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/Task.cpp @@ -9,8 +9,9 @@ namespace Web::HTML { -Task::Task(DOM::Document* document, Function<void()> steps) - : m_steps(move(steps)) +Task::Task(Source source, DOM::Document* document, Function<void()> steps) + : m_source(source) + , m_steps(move(steps)) , m_document(document) { } diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/Task.h b/Userland/Libraries/LibWeb/HTML/EventLoop/Task.h index d84ec08db6..6e56d5c565 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/Task.h +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/Task.h @@ -15,20 +15,31 @@ namespace Web::HTML { class Task { public: - static NonnullOwnPtr<Task> create(DOM::Document* document, Function<void()> steps) + // https://html.spec.whatwg.org/multipage/webappapis.html#generic-task-sources + enum class Source { + Unspecified, + DOMManipulation, + UserInteraction, + Networking, + HistoryTraversal, + }; + + static NonnullOwnPtr<Task> create(Source source, DOM::Document* document, Function<void()> steps) { - return adopt_own(*new Task(document, move(steps))); + return adopt_own(*new Task(source, document, move(steps))); } ~Task(); + Source source() const { return m_source; } void execute(); DOM::Document* document() { return m_document; } DOM::Document const* document() const { return m_document; } private: - Task(DOM::Document*, Function<void()> steps); + Task(Source, DOM::Document*, Function<void()> steps); + Source m_source { Source::Unspecified }; Function<void()> m_steps; RefPtr<DOM::Document> m_document; }; |