summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/EventLoop/Task.cpp
blob: 4e9a49b385fa94664710b1fffb9c22feb4e0df7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * 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 {

Task::Task(Source source, DOM::Document* document, Function<void()> steps)
    : m_source(source)
    , m_steps(move(steps))
    , m_document(document)
{
}

Task::~Task() = default;

void Task::execute()
{
    m_steps();
}

// 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();
}

}