/* * Copyright (c) 2021-2022, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include namespace Web::HTML { class Task { public: // https://html.spec.whatwg.org/multipage/webappapis.html#generic-task-sources enum class Source { Unspecified, DOMManipulation, UserInteraction, Networking, HistoryTraversal, IdleTask, PostedMessage, Microtask, TimerTask, JavaScriptEngine, }; static NonnullOwnPtr create(Source source, DOM::Document* document, JS::SafeFunction steps) { return adopt_own(*new Task(source, document, move(steps))); } ~Task(); Source source() const { return m_source; } void execute(); DOM::Document* document(); DOM::Document const* document() const; bool is_runnable() const; private: Task(Source, DOM::Document*, JS::SafeFunction steps); Source m_source { Source::Unspecified }; JS::SafeFunction m_steps; JS::Handle m_document; }; }