diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-04-12 14:08:26 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-12 23:03:46 +0200 |
commit | 3e49036edf703cd2a487b096faa072f1682e367c (patch) | |
tree | f8452b1e8ca146f236a33ad86e48bcd5d03d8b82 /Userland | |
parent | 624df40e20c5560b962d969769f8301b579ec405 (diff) | |
download | serenity-3e49036edf703cd2a487b096faa072f1682e367c.zip |
LibWeb: Move/rename StyleBlockRule to Parser::Block
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Block.cpp (renamed from Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.cpp) | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Block.h (renamed from Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.h) | 16 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.h | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/StyleRule.h | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Forward.h | 1 |
11 files changed, 36 insertions, 39 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index e29d0d6e5e..560da1fc2f 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -44,10 +44,10 @@ set(SOURCES CSS/MediaList.cpp CSS/MediaQuery.cpp CSS/MediaQueryList.cpp + CSS/Parser/Block.cpp CSS/Parser/ComponentValue.cpp CSS/Parser/Function.cpp CSS/Parser/Parser.cpp - CSS/Parser/StyleBlockRule.cpp CSS/Parser/StyleRules.cpp CSS/Parser/Token.cpp CSS/Parser/Tokenizer.cpp diff --git a/Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Block.cpp index dc7f8d365a..87fba27fc1 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Block.cpp @@ -5,19 +5,19 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <LibWeb/CSS/Parser/StyleBlockRule.h> +#include <LibWeb/CSS/Parser/Block.h> -namespace Web::CSS { +namespace Web::CSS::Parser { -StyleBlockRule::StyleBlockRule() = default; -StyleBlockRule::StyleBlockRule(Token token, Vector<Parser::ComponentValue>&& values) +Block::Block() = default; +Block::Block(Token token, Vector<ComponentValue>&& values) : m_token(move(token)) , m_values(move(values)) { } -StyleBlockRule::~StyleBlockRule() = default; +Block::~Block() = default; -String StyleBlockRule::to_string() const +String Block::to_string() const { StringBuilder builder; diff --git a/Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.h b/Userland/Libraries/LibWeb/CSS/Parser/Block.h index 34314fa376..2ea17f0d9d 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Block.h @@ -13,15 +13,15 @@ #include <LibWeb/CSS/Parser/Token.h> #include <LibWeb/Forward.h> -namespace Web::CSS { +namespace Web::CSS::Parser { -class StyleBlockRule : public RefCounted<StyleBlockRule> { - friend class Parser::Parser; +class Block : public RefCounted<Block> { + friend class Parser; public: - StyleBlockRule(); - StyleBlockRule(Token, Vector<Parser::ComponentValue>&&); - ~StyleBlockRule(); + Block(); + Block(Token, Vector<ComponentValue>&&); + ~Block(); bool is_curly() const { return m_token.is(Token::Type::OpenCurly); } bool is_paren() const { return m_token.is(Token::Type::OpenParen); } @@ -29,12 +29,12 @@ public: Token const& token() const { return m_token; } - Vector<Parser::ComponentValue> const& values() const { return m_values; } + Vector<ComponentValue> const& values() const { return m_values; } String to_string() const; private: Token m_token; - Vector<Parser::ComponentValue> m_values; + Vector<ComponentValue> m_values; }; } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp b/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp index cd5463ebd4..0fd67c9131 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp @@ -5,9 +5,9 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <LibWeb/CSS/Parser/Block.h> #include <LibWeb/CSS/Parser/ComponentValue.h> #include <LibWeb/CSS/Parser/Function.h> -#include <LibWeb/CSS/Parser/StyleBlockRule.h> namespace Web::CSS::Parser { @@ -19,7 +19,7 @@ ComponentValue::ComponentValue(NonnullRefPtr<Function> function) : m_value(function) { } -ComponentValue::ComponentValue(NonnullRefPtr<StyleBlockRule> block) +ComponentValue::ComponentValue(NonnullRefPtr<Block> block) : m_value(block) { } @@ -30,7 +30,7 @@ String ComponentValue::to_string() const { return m_value.visit( [](Token const& token) { return token.to_string(); }, - [](NonnullRefPtr<StyleBlockRule> const& block) { return block->to_string(); }, + [](NonnullRefPtr<Block> const& block) { return block->to_string(); }, [](NonnullRefPtr<Function> const& function) { return function->to_string(); }); } @@ -40,7 +40,7 @@ String ComponentValue::to_debug_string() const [](Token const& token) { return String::formatted("Token: {}", token.to_debug_string()); }, - [](NonnullRefPtr<StyleBlockRule> const& block) { + [](NonnullRefPtr<Block> const& block) { return String::formatted("Function: {}", block->to_string()); }, [](NonnullRefPtr<Function> const& function) { diff --git a/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.h b/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.h index 9ec4e146d0..2685a7eeed 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.h @@ -12,10 +12,6 @@ #include <LibWeb/CSS/Parser/Token.h> #include <LibWeb/Forward.h> -namespace Web::CSS { -class StyleBlockRule; -} - namespace Web::CSS::Parser { // https://www.w3.org/TR/css-syntax-3/#component-value @@ -23,11 +19,11 @@ class ComponentValue { public: ComponentValue(Token); explicit ComponentValue(NonnullRefPtr<Function>); - explicit ComponentValue(NonnullRefPtr<StyleBlockRule>); + explicit ComponentValue(NonnullRefPtr<Block>); ~ComponentValue(); - bool is_block() const { return m_value.has<NonnullRefPtr<StyleBlockRule>>(); } - StyleBlockRule const& block() const { return m_value.get<NonnullRefPtr<StyleBlockRule>>(); } + bool is_block() const { return m_value.has<NonnullRefPtr<Block>>(); } + Block const& block() const { return m_value.get<NonnullRefPtr<Block>>(); } bool is_function() const { return m_value.has<NonnullRefPtr<Function>>(); } Function const& function() const { return m_value.get<NonnullRefPtr<Function>>(); } @@ -41,7 +37,7 @@ public: String to_debug_string() const; private: - Variant<Token, NonnullRefPtr<Function>, NonnullRefPtr<StyleBlockRule>> m_value; + Variant<Token, NonnullRefPtr<Function>, NonnullRefPtr<Block>> m_value; }; } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index d4402a462b..624f2b8723 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -19,11 +19,11 @@ #include <LibWeb/CSS/CSSStyleRule.h> #include <LibWeb/CSS/CSSStyleSheet.h> #include <LibWeb/CSS/CSSSupportsRule.h> +#include <LibWeb/CSS/Parser/Block.h> #include <LibWeb/CSS/Parser/ComponentValue.h> #include <LibWeb/CSS/Parser/DeclarationOrAtRule.h> #include <LibWeb/CSS/Parser/Function.h> #include <LibWeb/CSS/Parser/Parser.h> -#include <LibWeb/CSS/Parser/StyleBlockRule.h> #include <LibWeb/CSS/Parser/StyleRule.h> #include <LibWeb/CSS/Selector.h> #include <LibWeb/DOM/Document.h> @@ -1821,7 +1821,7 @@ ComponentValue Parser::consume_a_component_value(TokenStream<T>& tokens) // 5.4.8. Consume a simple block // https://www.w3.org/TR/css-syntax-3/#consume-simple-block template<typename T> -NonnullRefPtr<StyleBlockRule> Parser::consume_a_simple_block(TokenStream<T>& tokens) +NonnullRefPtr<Block> Parser::consume_a_simple_block(TokenStream<T>& tokens) { // Note: This algorithm assumes that the current input token has already been checked // to be an <{-token>, <[-token>, or <(-token>. @@ -1834,7 +1834,7 @@ NonnullRefPtr<StyleBlockRule> Parser::consume_a_simple_block(TokenStream<T>& tok // Create a simple block with its associated token set to the current input token // and with its value initially set to an empty list. - auto block = make_ref_counted<StyleBlockRule>(); + auto block = make_ref_counted<Block>(); block->m_token = tokens.current_token(); // Repeatedly consume the next input token and process it as follows: @@ -4938,7 +4938,7 @@ RefPtr<StyleValue> Parser::parse_as_css_value(PropertyID property_id) Result<NonnullRefPtr<StyleValue>, Parser::ParsingResult> Parser::parse_css_value(PropertyID property_id, TokenStream<ComponentValue>& tokens) { - auto block_contains_var_or_attr = [](StyleBlockRule const& block, auto&& recurse) -> bool { + auto block_contains_var_or_attr = [](Block const& block, auto&& recurse) -> bool { for (auto const& token : block.values()) { if (token.is_function() && (token.function().name().equals_ignoring_case("var"sv) || token.function().name().equals_ignoring_case("attr"sv))) return true; diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index eedb78b8ee..617105fd1d 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -16,11 +16,11 @@ #include <LibWeb/CSS/FontFace.h> #include <LibWeb/CSS/GeneralEnclosed.h> #include <LibWeb/CSS/MediaQuery.h> +#include <LibWeb/CSS/Parser/Block.h> #include <LibWeb/CSS/Parser/ComponentValue.h> #include <LibWeb/CSS/Parser/Declaration.h> #include <LibWeb/CSS/Parser/DeclarationOrAtRule.h> #include <LibWeb/CSS/Parser/Function.h> -#include <LibWeb/CSS/Parser/StyleBlockRule.h> #include <LibWeb/CSS/Parser/StyleRule.h> #include <LibWeb/CSS/Parser/Tokenizer.h> #include <LibWeb/CSS/Ratio.h> @@ -193,7 +193,7 @@ private: template<typename T> [[nodiscard]] ComponentValue consume_a_component_value(TokenStream<T>&); template<typename T> - NonnullRefPtr<StyleBlockRule> consume_a_simple_block(TokenStream<T>&); + NonnullRefPtr<Block> consume_a_simple_block(TokenStream<T>&); template<typename T> NonnullRefPtr<Function> consume_a_function(TokenStream<T>&); diff --git a/Userland/Libraries/LibWeb/CSS/Parser/StyleRule.h b/Userland/Libraries/LibWeb/CSS/Parser/StyleRule.h index 018599e3de..1b5a146377 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/StyleRule.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/StyleRule.h @@ -9,8 +9,8 @@ #include <AK/RefCounted.h> #include <AK/Vector.h> +#include <LibWeb/CSS/Parser/Block.h> #include <LibWeb/CSS/Parser/ComponentValue.h> -#include <LibWeb/CSS/Parser/StyleBlockRule.h> namespace Web::CSS { @@ -30,7 +30,7 @@ public: bool is_at_rule() const { return m_type == Type::At; } Vector<Parser::ComponentValue> const& prelude() const { return m_prelude; } - RefPtr<StyleBlockRule const> block() const { return m_block; } + RefPtr<Parser::Block const> block() const { return m_block; } String const& at_rule_name() const { return m_at_rule_name; } String to_string() const; @@ -39,7 +39,7 @@ private: Type const m_type; String m_at_rule_name; Vector<Parser::ComponentValue> m_prelude; - RefPtr<StyleBlockRule> m_block; + RefPtr<Parser::Block> m_block; }; } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp b/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp index 989ad0f421..20065c9b58 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp @@ -5,11 +5,11 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <LibWeb/CSS/Parser/Block.h> #include <LibWeb/CSS/Parser/ComponentValue.h> #include <LibWeb/CSS/Parser/Declaration.h> #include <LibWeb/CSS/Parser/DeclarationOrAtRule.h> #include <LibWeb/CSS/Parser/Function.h> -#include <LibWeb/CSS/Parser/StyleBlockRule.h> #include <LibWeb/CSS/Parser/StyleRule.h> #include <LibWeb/CSS/Serialize.h> diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 08f5d93c10..cf9c7f8db5 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -631,8 +631,8 @@ bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView p Vector<Parser::ComponentValue> block_values; if (!expand_unresolved_values(element, property_name, dependencies, source_block.values(), block_values, 0)) return false; - NonnullRefPtr<StyleBlockRule> block = adopt_ref(*new StyleBlockRule(source_block.token(), move(block_values))); - dest.empend(block); + NonnullRefPtr<Parser::Block> block = adopt_ref(*new Parser::Block(source_block.token(), move(block_values))); + dest.empend(move(block)); continue; } dest.empend(value.token()); diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index a443f0e47e..848939d4d1 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -99,6 +99,7 @@ enum class ValueID; } namespace Web::CSS::Parser { +class Block; class ComponentValue; class Function; class Parser; |