/src/serenity/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/NonnullRefPtr.h> |
10 | | #include <LibWeb/CSS/CSSConditionRule.h> |
11 | | #include <LibWeb/CSS/CSSRule.h> |
12 | | #include <LibWeb/CSS/Supports.h> |
13 | | #include <LibWeb/Forward.h> |
14 | | |
15 | | namespace Web::CSS { |
16 | | |
17 | | // https://www.w3.org/TR/css-conditional-3/#the-csssupportsrule-interface |
18 | | class CSSSupportsRule final : public CSSConditionRule { |
19 | | WEB_PLATFORM_OBJECT(CSSSupportsRule, CSSConditionRule); |
20 | | JS_DECLARE_ALLOCATOR(CSSSupportsRule); |
21 | | |
22 | | public: |
23 | | static JS::NonnullGCPtr<CSSSupportsRule> create(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&); |
24 | | |
25 | 0 | virtual ~CSSSupportsRule() = default; |
26 | | |
27 | 0 | virtual Type type() const override { return Type::Supports; } |
28 | | |
29 | | String condition_text() const override; |
30 | 0 | virtual bool condition_matches() const override { return m_supports->matches(); } |
31 | | |
32 | | private: |
33 | | CSSSupportsRule(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&); |
34 | | |
35 | | virtual void initialize(JS::Realm&) override; |
36 | | virtual String serialized() const override; |
37 | | |
38 | | NonnullRefPtr<Supports> m_supports; |
39 | | }; |
40 | | |
41 | | template<> |
42 | 0 | inline bool CSSRule::fast_is<CSSSupportsRule>() const { return type() == CSSRule::Type::Supports; } |
43 | | |
44 | | } |