LibWeb: Add CSSGroupingRule

This is an abstract base class for CSSRules that hold a CSSRuleList.
This commit is contained in:
Sam Atkins 2021-09-28 16:20:32 +01:00 committed by Andreas Kling
parent eb83d2617c
commit 06f9395056
Notes: sideshowbarker 2024-07-18 22:57:59 +09:00
4 changed files with 74 additions and 0 deletions

View file

@ -12,6 +12,7 @@ set(SOURCES
Bindings/ScriptExecutionContext.cpp
Bindings/WindowObject.cpp
Bindings/Wrappable.cpp
CSS/CSSGroupingRule.cpp
CSS/CSSImportRule.cpp
CSS/CSSRule.cpp
CSS/CSSRuleList.cpp

View file

@ -0,0 +1,33 @@
/*
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/CSS/CSSGroupingRule.h>
#include <LibWeb/CSS/CSSRuleList.h>
namespace Web::CSS {
CSSGroupingRule::CSSGroupingRule(NonnullRefPtrVector<CSSRule>&& rules)
: m_rules(CSSRuleList { move(rules) })
{
}
CSSGroupingRule::~CSSGroupingRule()
{
}
size_t CSSGroupingRule::insert_rule(StringView const&, size_t)
{
// https://www.w3.org/TR/cssom-1/#insert-a-css-rule
TODO();
}
void CSSGroupingRule::delete_rule(size_t)
{
// https://www.w3.org/TR/cssom-1/#remove-a-css-rule
TODO();
}
}

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#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:
~CSSGroupingRule();
CSSRuleList const& css_rules() const { return m_rules; }
size_t insert_rule(StringView const& rule, size_t index = 0);
void delete_rule(size_t index);
protected:
explicit CSSGroupingRule(NonnullRefPtrVector<CSSRule>&&);
private:
CSSRuleList m_rules;
};
}

View file

@ -0,0 +1,6 @@
interface CSSGroupingRule : CSSRule {
[SameObject] readonly attribute CSSRuleList cssRules;
unsigned long insertRule(CSSOMString rule, optional unsigned long index = 0);
undefined deleteRule(unsigned long index);
};