ladybird/Userland/Libraries/LibWeb/HTML/EventLoop/Task.h
Andreas Kling ecb72f3b57 LibWeb: Add a bare-bones HTML event loop with a task queue
This patch attaches a HTML::EventLoop to the main thread JS::VM used
for JavaScript bindings in the web engine.

The goal here is to model the various task scheduling mechanisms of the
HTML specification.
2021-09-09 02:18:31 +02:00

36 lines
724 B
C++

/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Function.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/RefPtr.h>
#include <LibWeb/Forward.h>
namespace Web::HTML {
class Task {
public:
static NonnullOwnPtr<Task> create(DOM::Document* document, Function<void()> steps)
{
return adopt_own(*new Task(document, move(steps)));
}
~Task();
void execute();
DOM::Document* document() { return m_document; }
DOM::Document const* document() const { return m_document; }
private:
Task(DOM::Document*, Function<void()> steps);
Function<void()> m_steps;
RefPtr<DOM::Document> m_document;
};
}