/src/serenity/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2023, Ali Mohammad Pur <mpfard@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/CSSRule.h> |
11 | | #include <LibWeb/CSS/CSSStyleDeclaration.h> |
12 | | #include <LibWeb/CSS/Percentage.h> |
13 | | #include <LibWeb/Forward.h> |
14 | | #include <LibWeb/WebIDL/ExceptionOr.h> |
15 | | |
16 | | namespace Web::CSS { |
17 | | |
18 | | // https://drafts.csswg.org/css-animations/#interface-csskeyframerule |
19 | | class CSSKeyframeRule final : public CSSRule { |
20 | | WEB_PLATFORM_OBJECT(CSSKeyframeRule, CSSRule); |
21 | | JS_DECLARE_ALLOCATOR(CSSKeyframeRule); |
22 | | |
23 | | public: |
24 | | static JS::NonnullGCPtr<CSSKeyframeRule> create(JS::Realm&, CSS::Percentage key, PropertyOwningCSSStyleDeclaration&); |
25 | | |
26 | | virtual ~CSSKeyframeRule() = default; |
27 | | |
28 | 0 | virtual Type type() const override { return Type::Keyframe; } |
29 | | |
30 | 0 | CSS::Percentage key() const { return m_key; } |
31 | 0 | JS::NonnullGCPtr<CSSStyleDeclaration> style() const { return m_declarations; } |
32 | 0 | JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration> style_as_property_owning_style_declaration() const { return m_declarations; } |
33 | | |
34 | | String key_text() const |
35 | 0 | { |
36 | 0 | return m_key.to_string(); |
37 | 0 | } |
38 | | |
39 | | void set_key_text(String const& key_text) |
40 | 0 | { |
41 | 0 | dbgln("FIXME: CSSKeyframeRule::set_key_text is not implemented: {}", key_text); |
42 | 0 | } |
43 | | |
44 | | private: |
45 | | CSSKeyframeRule(JS::Realm&, CSS::Percentage, PropertyOwningCSSStyleDeclaration&); |
46 | | |
47 | | virtual void visit_edges(Visitor&) override; |
48 | | virtual void initialize(JS::Realm&) override; |
49 | | virtual String serialized() const override; |
50 | | |
51 | | CSS::Percentage m_key; |
52 | | JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration> m_declarations; |
53 | | }; |
54 | | |
55 | | template<> |
56 | 0 | inline bool CSSRule::fast_is<CSSKeyframeRule>() const { return type() == CSSRule::Type::Keyframe; } |
57 | | |
58 | | } |