/src/serenity/Userland/Libraries/LibWeb/CSS/CSSNestedDeclarations.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2024, Sam Atkins <sam@ladybird.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include "CSSNestedDeclarations.h" |
8 | | #include <LibWeb/Bindings/CSSNestedDeclarationsPrototype.h> |
9 | | #include <LibWeb/Bindings/Intrinsics.h> |
10 | | |
11 | | namespace Web::CSS { |
12 | | |
13 | | JS_DEFINE_ALLOCATOR(CSSNestedDeclarations); |
14 | | |
15 | | JS::NonnullGCPtr<CSSNestedDeclarations> CSSNestedDeclarations::create(JS::Realm& realm, PropertyOwningCSSStyleDeclaration& declaration) |
16 | 0 | { |
17 | 0 | return realm.heap().allocate<CSSNestedDeclarations>(realm, realm, declaration); |
18 | 0 | } |
19 | | |
20 | | CSSNestedDeclarations::CSSNestedDeclarations(JS::Realm& realm, PropertyOwningCSSStyleDeclaration& declaration) |
21 | 0 | : CSSRule(realm) |
22 | 0 | , m_declaration(declaration) |
23 | 0 | { |
24 | 0 | m_declaration->set_parent_rule(*this); |
25 | 0 | } |
26 | | |
27 | | void CSSNestedDeclarations::initialize(JS::Realm& realm) |
28 | 0 | { |
29 | 0 | Base::initialize(realm); |
30 | 0 | WEB_SET_PROTOTYPE_FOR_INTERFACE(CSSNestedDeclarations); |
31 | 0 | } |
32 | | |
33 | | void CSSNestedDeclarations::visit_edges(Cell::Visitor& visitor) |
34 | 0 | { |
35 | 0 | Base::visit_edges(visitor); |
36 | 0 | visitor.visit(m_declaration); |
37 | 0 | } |
38 | | |
39 | | CSSStyleDeclaration* CSSNestedDeclarations::style() |
40 | 0 | { |
41 | 0 | return m_declaration; |
42 | 0 | } |
43 | | |
44 | | String CSSNestedDeclarations::serialized() const |
45 | 0 | { |
46 | | // NOTE: There's no proper spec for this yet, only this note: |
47 | | // "The CSSNestedDeclarations rule serializes as if its declaration block had been serialized directly." |
48 | | // - https://drafts.csswg.org/css-nesting-1/#ref-for-cssnesteddeclarations%E2%91%A1 |
49 | | // So, we'll do the simple thing and hope it's good. |
50 | 0 | return m_declaration->serialized(); |
51 | 0 | } |
52 | | |
53 | | } |