/src/serenity/Userland/Libraries/LibWeb/CSS/CSSPropertyRule.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2024, Alex Ungurianu <alex@ungurianu.com> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/FlyString.h> |
10 | | #include <AK/NonnullRefPtr.h> |
11 | | #include <AK/Optional.h> |
12 | | #include <AK/String.h> |
13 | | #include <LibWeb/CSS/CSSRule.h> |
14 | | #include <LibWeb/Forward.h> |
15 | | |
16 | | namespace Web::CSS { |
17 | | |
18 | | // https://drafts.css-houdini.org/css-properties-values-api/#the-css-property-rule-interface |
19 | | class CSSPropertyRule final : public CSSRule { |
20 | | WEB_PLATFORM_OBJECT(CSSPropertyRule, CSSRule); |
21 | | JS_DECLARE_ALLOCATOR(CSSPropertyRule); |
22 | | |
23 | | public: |
24 | | static JS::NonnullGCPtr<CSSPropertyRule> create(JS::Realm&, FlyString name, FlyString syntax, bool inherits, Optional<String> initial_value); |
25 | | |
26 | 0 | virtual ~CSSPropertyRule() = default; |
27 | | |
28 | 0 | FlyString const& name() const { return m_name; } |
29 | 0 | FlyString const& syntax() const { return m_syntax; } |
30 | 0 | bool inherits() const { return m_inherits; } |
31 | 0 | Optional<String> initial_value() const { return m_initial_value; } |
32 | | |
33 | | private: |
34 | | CSSPropertyRule(JS::Realm&, FlyString name, FlyString syntax, bool inherits, Optional<String> initial_value); |
35 | | |
36 | | virtual void initialize(JS::Realm&) override; |
37 | | virtual String serialized() const override; |
38 | | |
39 | | FlyString m_name; |
40 | | FlyString m_syntax; |
41 | | bool m_inherits; |
42 | | // FIXME: This should hold an actual CSS value, matching the syntax |
43 | | Optional<String> m_initial_value; |
44 | | }; |
45 | | |
46 | | template<> |
47 | 0 | inline bool CSSRule::fast_is<CSSPropertyRule>() const { return type() == CSSRule::Type::Property; } |
48 | | |
49 | | } |