mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 07:05:08 +00:00
LibWeb: Add HTML::Task::Source to model "generic task sources"
This commit is contained in:
parent
462120d900
commit
bc3a432cb2
2 changed files with 17 additions and 5 deletions
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue