Coverage Report

Created: 2026-10-28 07:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/CSS/Parser/ParsingContext.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2020-2021, the SerenityOS developers.
3
 * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
4
 *
5
 * SPDX-License-Identifier: BSD-2-Clause
6
 */
7
8
#pragma once
9
10
#include <LibJS/Runtime/Realm.h>
11
#include <LibWeb/DOM/Document.h>
12
13
namespace Web::CSS::Parser {
14
15
class ParsingContext {
16
public:
17
    enum class Mode {
18
        Normal,
19
        SVGPresentationAttribute, // See https://svgwg.org/svg2-draft/types.html#presentation-attribute-css-value
20
    };
21
22
    explicit ParsingContext(JS::Realm&, Mode = Mode::Normal);
23
    explicit ParsingContext(JS::Realm&, URL::URL, Mode = Mode::Normal);
24
    explicit ParsingContext(DOM::Document const&, Mode = Mode::Normal);
25
    explicit ParsingContext(DOM::Document const&, URL::URL, Mode = Mode::Normal);
26
    explicit ParsingContext(DOM::ParentNode&, Mode = Mode::Normal);
27
28
0
    Mode mode() const { return m_mode; }
29
0
    bool is_parsing_svg_presentation_attribute() const { return m_mode == Mode::SVGPresentationAttribute; }
30
31
    bool in_quirks_mode() const;
32
0
    DOM::Document const* document() const { return m_document; }
33
    HTML::Window const* window() const;
34
    URL::URL complete_url(StringView) const;
35
36
0
    PropertyID current_property_id() const { return m_current_property_id; }
37
0
    void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; }
38
39
0
    JS::Realm& realm() const { return m_realm; }
40
41
private:
42
    JS::NonnullGCPtr<JS::Realm> m_realm;
43
    JS::GCPtr<DOM::Document const> m_document;
44
    PropertyID m_current_property_id { PropertyID::Invalid };
45
    URL::URL m_url;
46
    Mode m_mode { Mode::Normal };
47
};
48
49
}