-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathCSSGroupingRule.cpp
62 lines (52 loc) · 1.68 KB
/
CSSGroupingRule.cpp
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
/*
* Copyright (c) 2021-2024, Sam Atkins <[email protected]>
* Copyright (c) 2022, Andreas Kling <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/CSSGroupingRulePrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/CSS/CSSGroupingRule.h>
#include <LibWeb/CSS/CSSRuleList.h>
#include <LibWeb/HTML/Window.h>
namespace Web::CSS {
CSSGroupingRule::CSSGroupingRule(JS::Realm& realm, CSSRuleList& rules)
: CSSRule(realm)
, m_rules(rules)
{
for (auto& rule : *m_rules)
rule->set_parent_rule(this);
}
void CSSGroupingRule::initialize(JS::Realm& realm)
{
Base::initialize(realm);
WEB_SET_PROTOTYPE_FOR_INTERFACE(CSSGroupingRule);
}
void CSSGroupingRule::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_rules);
}
WebIDL::ExceptionOr<u32> CSSGroupingRule::insert_rule(StringView rule, u32 index)
{
TRY(m_rules->insert_a_css_rule(rule, index));
// NOTE: The spec doesn't say where to set the parent rule, so we'll do it here.
m_rules->item(index)->set_parent_rule(this);
return index;
}
WebIDL::ExceptionOr<void> CSSGroupingRule::delete_rule(u32 index)
{
return m_rules->remove_a_css_rule(index);
}
void CSSGroupingRule::for_each_effective_rule(TraversalOrder order, Function<void(Web::CSS::CSSRule const&)> const& callback) const
{
m_rules->for_each_effective_rule(order, callback);
}
void CSSGroupingRule::set_parent_style_sheet(CSSStyleSheet* parent_style_sheet)
{
CSSRule::set_parent_style_sheet(parent_style_sheet);
for (auto& rule : *m_rules)
rule->set_parent_style_sheet(parent_style_sheet);
}
}