summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h
blob: 0f533b6c50c0b1bba5103b6a272c47978cc6db3a (plain)
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
/*
 * Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Function.h>
#include <AK/NonnullRefPtr.h>
#include <LibWeb/CSS/CSSRule.h>
#include <LibWeb/CSS/CSSRuleList.h>
#include <LibWeb/Forward.h>

namespace Web::CSS {

class CSSGroupingRule : public CSSRule {
    AK_MAKE_NONCOPYABLE(CSSGroupingRule);
    AK_MAKE_NONMOVABLE(CSSGroupingRule);

public:
    using WrapperType = Bindings::CSSGroupingRuleWrapper;

    virtual ~CSSGroupingRule() = default;

    CSSRuleList const& css_rules() const { return m_rules; }
    CSSRuleList& css_rules() { return m_rules; }
    NonnullRefPtr<CSSRuleList> css_rules_for_bindings() { return m_rules; }
    DOM::ExceptionOr<u32> insert_rule(StringView rule, u32 index = 0);
    DOM::ExceptionOr<void> delete_rule(u32 index);

    virtual void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const;

    virtual void set_parent_style_sheet(CSSStyleSheet*) override;

protected:
    explicit CSSGroupingRule(NonnullRefPtrVector<CSSRule>&&);

private:
    NonnullRefPtr<CSSRuleList> m_rules;
};

}