2021-09-08 23:09:18 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibWeb/DOM/Document.h>
|
|
|
|
#include <LibWeb/HTML/EventLoop/Task.h>
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2021-09-08 23:53:55 +02:00
|
|
|
Task::Task(Source source, DOM::Document* document, Function<void()> steps)
|
|
|
|
: m_source(source)
|
|
|
|
, m_steps(move(steps))
|
2021-09-08 23:09:18 +02:00
|
|
|
, m_document(document)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-03-14 13:21:51 -06:00
|
|
|
Task::~Task() = default;
|
2021-09-08 23:09:18 +02:00
|
|
|
|
|
|
|
void Task::execute()
|
|
|
|
{
|
|
|
|
m_steps();
|
|
|
|
}
|
|
|
|
|
2021-10-03 15:38:11 +02:00
|
|
|
// https://html.spec.whatwg.org/#concept-task-runnable
|
|
|
|
bool Task::is_runnable() const
|
|
|
|
{
|
|
|
|
// A task is runnable if its document is either null or fully active.
|
|
|
|
return !m_document || m_document->is_fully_active();
|
|
|
|
}
|
|
|
|
|
2021-09-08 23:09:18 +02:00
|
|
|
}
|