diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2021-09-28 16:20:32 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-29 18:57:48 +0200 |
commit | 06f93950568b8e5167f64007fa4980a3050904a2 (patch) | |
tree | 64c2a927e984b9440e1ab68fb938b3e42c8e82a1 /Userland/Libraries | |
parent | eb83d2617caa437bfebdb00967bc71c760d1a3a5 (diff) | |
download | serenity-06f93950568b8e5167f64007fa4980a3050904a2.zip |
LibWeb: Add CSSGroupingRule
This is an abstract base class for CSSRules that hold a CSSRuleList.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp | 33 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h | 34 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/CSSGroupingRule.idl | 6 |
4 files changed, 74 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 5453182e4f..12e3941df5 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -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 diff --git a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp new file mode 100644 index 0000000000..59cc281c69 --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp @@ -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(); +} + +} diff --git a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h new file mode 100644 index 0000000000..e60a7ff8a3 --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h @@ -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; +}; + +} diff --git a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.idl b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.idl new file mode 100644 index 0000000000..6c904e0f74 --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.idl @@ -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); +}; + |