blob: c458ebb9f8388d5b5c37a40df1943b8354bc1a13 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* Copyright (c) 2020-2021, the SerenityOS developers.
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullRefPtr.h>
#include <AK/RefPtr.h>
#include <LibWeb/CSS/Parser/Token.h>
namespace Web::CSS {
class StyleBlockRule;
class StyleFunctionRule;
class StyleComponentValueRule {
friend class Parser;
public:
enum class ComponentType {
Token,
Function,
Block
};
StyleComponentValueRule(Token);
explicit StyleComponentValueRule(NonnullRefPtr<StyleFunctionRule>);
explicit StyleComponentValueRule(NonnullRefPtr<StyleBlockRule>);
~StyleComponentValueRule();
bool is_block() const { return m_type == ComponentType::Block; }
StyleBlockRule const& block() const
{
VERIFY(is_block());
return *m_block;
}
bool is_function() const { return m_type == ComponentType::Function; }
StyleFunctionRule const& function() const
{
VERIFY(is_function());
return *m_function;
}
bool is(Token::Type type) const
{
return m_type == ComponentType::Token && m_token.is(type);
}
Token const& token() const { return m_token; }
operator Token() const { return m_token; }
String to_string() const;
String to_debug_string() const;
private:
ComponentType m_type;
Token m_token;
RefPtr<StyleFunctionRule> m_function;
RefPtr<StyleBlockRule> m_block;
};
}
|