mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 21:55:07 +00:00
LibWeb: Move/rename StyleBlockRule to Parser::Block
This commit is contained in:
parent
624df40e20
commit
3e49036edf
11 changed files with 36 additions and 39 deletions
|
@ -44,10 +44,10 @@ set(SOURCES
|
||||||
CSS/MediaList.cpp
|
CSS/MediaList.cpp
|
||||||
CSS/MediaQuery.cpp
|
CSS/MediaQuery.cpp
|
||||||
CSS/MediaQueryList.cpp
|
CSS/MediaQueryList.cpp
|
||||||
|
CSS/Parser/Block.cpp
|
||||||
CSS/Parser/ComponentValue.cpp
|
CSS/Parser/ComponentValue.cpp
|
||||||
CSS/Parser/Function.cpp
|
CSS/Parser/Function.cpp
|
||||||
CSS/Parser/Parser.cpp
|
CSS/Parser/Parser.cpp
|
||||||
CSS/Parser/StyleBlockRule.cpp
|
|
||||||
CSS/Parser/StyleRules.cpp
|
CSS/Parser/StyleRules.cpp
|
||||||
CSS/Parser/Token.cpp
|
CSS/Parser/Token.cpp
|
||||||
CSS/Parser/Tokenizer.cpp
|
CSS/Parser/Tokenizer.cpp
|
||||||
|
|
|
@ -5,19 +5,19 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* 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;
|
Block::Block() = default;
|
||||||
StyleBlockRule::StyleBlockRule(Token token, Vector<Parser::ComponentValue>&& values)
|
Block::Block(Token token, Vector<ComponentValue>&& values)
|
||||||
: m_token(move(token))
|
: m_token(move(token))
|
||||||
, m_values(move(values))
|
, m_values(move(values))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
StyleBlockRule::~StyleBlockRule() = default;
|
Block::~Block() = default;
|
||||||
|
|
||||||
String StyleBlockRule::to_string() const
|
String Block::to_string() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
|
@ -13,15 +13,15 @@
|
||||||
#include <LibWeb/CSS/Parser/Token.h>
|
#include <LibWeb/CSS/Parser/Token.h>
|
||||||
#include <LibWeb/Forward.h>
|
#include <LibWeb/Forward.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS::Parser {
|
||||||
|
|
||||||
class StyleBlockRule : public RefCounted<StyleBlockRule> {
|
class Block : public RefCounted<Block> {
|
||||||
friend class Parser::Parser;
|
friend class Parser;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StyleBlockRule();
|
Block();
|
||||||
StyleBlockRule(Token, Vector<Parser::ComponentValue>&&);
|
Block(Token, Vector<ComponentValue>&&);
|
||||||
~StyleBlockRule();
|
~Block();
|
||||||
|
|
||||||
bool is_curly() const { return m_token.is(Token::Type::OpenCurly); }
|
bool is_curly() const { return m_token.is(Token::Type::OpenCurly); }
|
||||||
bool is_paren() const { return m_token.is(Token::Type::OpenParen); }
|
bool is_paren() const { return m_token.is(Token::Type::OpenParen); }
|
||||||
|
@ -29,12 +29,12 @@ public:
|
||||||
|
|
||||||
Token const& token() const { return m_token; }
|
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;
|
String to_string() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Token m_token;
|
Token m_token;
|
||||||
Vector<Parser::ComponentValue> m_values;
|
Vector<ComponentValue> m_values;
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -5,9 +5,9 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/Parser/Block.h>
|
||||||
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
||||||
#include <LibWeb/CSS/Parser/Function.h>
|
#include <LibWeb/CSS/Parser/Function.h>
|
||||||
#include <LibWeb/CSS/Parser/StyleBlockRule.h>
|
|
||||||
|
|
||||||
namespace Web::CSS::Parser {
|
namespace Web::CSS::Parser {
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ ComponentValue::ComponentValue(NonnullRefPtr<Function> function)
|
||||||
: m_value(function)
|
: m_value(function)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
ComponentValue::ComponentValue(NonnullRefPtr<StyleBlockRule> block)
|
ComponentValue::ComponentValue(NonnullRefPtr<Block> block)
|
||||||
: m_value(block)
|
: m_value(block)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ String ComponentValue::to_string() const
|
||||||
{
|
{
|
||||||
return m_value.visit(
|
return m_value.visit(
|
||||||
[](Token const& token) { return token.to_string(); },
|
[](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(); });
|
[](NonnullRefPtr<Function> const& function) { return function->to_string(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ String ComponentValue::to_debug_string() const
|
||||||
[](Token const& token) {
|
[](Token const& token) {
|
||||||
return String::formatted("Token: {}", token.to_debug_string());
|
return String::formatted("Token: {}", token.to_debug_string());
|
||||||
},
|
},
|
||||||
[](NonnullRefPtr<StyleBlockRule> const& block) {
|
[](NonnullRefPtr<Block> const& block) {
|
||||||
return String::formatted("Function: {}", block->to_string());
|
return String::formatted("Function: {}", block->to_string());
|
||||||
},
|
},
|
||||||
[](NonnullRefPtr<Function> const& function) {
|
[](NonnullRefPtr<Function> const& function) {
|
||||||
|
|
|
@ -12,10 +12,6 @@
|
||||||
#include <LibWeb/CSS/Parser/Token.h>
|
#include <LibWeb/CSS/Parser/Token.h>
|
||||||
#include <LibWeb/Forward.h>
|
#include <LibWeb/Forward.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
|
||||||
class StyleBlockRule;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Web::CSS::Parser {
|
namespace Web::CSS::Parser {
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-syntax-3/#component-value
|
// https://www.w3.org/TR/css-syntax-3/#component-value
|
||||||
|
@ -23,11 +19,11 @@ class ComponentValue {
|
||||||
public:
|
public:
|
||||||
ComponentValue(Token);
|
ComponentValue(Token);
|
||||||
explicit ComponentValue(NonnullRefPtr<Function>);
|
explicit ComponentValue(NonnullRefPtr<Function>);
|
||||||
explicit ComponentValue(NonnullRefPtr<StyleBlockRule>);
|
explicit ComponentValue(NonnullRefPtr<Block>);
|
||||||
~ComponentValue();
|
~ComponentValue();
|
||||||
|
|
||||||
bool is_block() const { return m_value.has<NonnullRefPtr<StyleBlockRule>>(); }
|
bool is_block() const { return m_value.has<NonnullRefPtr<Block>>(); }
|
||||||
StyleBlockRule const& block() const { return m_value.get<NonnullRefPtr<StyleBlockRule>>(); }
|
Block const& block() const { return m_value.get<NonnullRefPtr<Block>>(); }
|
||||||
|
|
||||||
bool is_function() const { return m_value.has<NonnullRefPtr<Function>>(); }
|
bool is_function() const { return m_value.has<NonnullRefPtr<Function>>(); }
|
||||||
Function const& function() const { return m_value.get<NonnullRefPtr<Function>>(); }
|
Function const& function() const { return m_value.get<NonnullRefPtr<Function>>(); }
|
||||||
|
@ -41,7 +37,7 @@ public:
|
||||||
String to_debug_string() const;
|
String to_debug_string() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Variant<Token, NonnullRefPtr<Function>, NonnullRefPtr<StyleBlockRule>> m_value;
|
Variant<Token, NonnullRefPtr<Function>, NonnullRefPtr<Block>> m_value;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
#include <LibWeb/CSS/CSSStyleRule.h>
|
#include <LibWeb/CSS/CSSStyleRule.h>
|
||||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||||
#include <LibWeb/CSS/CSSSupportsRule.h>
|
#include <LibWeb/CSS/CSSSupportsRule.h>
|
||||||
|
#include <LibWeb/CSS/Parser/Block.h>
|
||||||
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
||||||
#include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
|
#include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
|
||||||
#include <LibWeb/CSS/Parser/Function.h>
|
#include <LibWeb/CSS/Parser/Function.h>
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/CSS/Parser/StyleBlockRule.h>
|
|
||||||
#include <LibWeb/CSS/Parser/StyleRule.h>
|
#include <LibWeb/CSS/Parser/StyleRule.h>
|
||||||
#include <LibWeb/CSS/Selector.h>
|
#include <LibWeb/CSS/Selector.h>
|
||||||
#include <LibWeb/DOM/Document.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
|
// 5.4.8. Consume a simple block
|
||||||
// https://www.w3.org/TR/css-syntax-3/#consume-simple-block
|
// https://www.w3.org/TR/css-syntax-3/#consume-simple-block
|
||||||
template<typename T>
|
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
|
// Note: This algorithm assumes that the current input token has already been checked
|
||||||
// to be an <{-token>, <[-token>, or <(-token>.
|
// 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
|
// Create a simple block with its associated token set to the current input token
|
||||||
// and with its value initially set to an empty list.
|
// 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();
|
block->m_token = tokens.current_token();
|
||||||
|
|
||||||
// Repeatedly consume the next input token and process it as follows:
|
// 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)
|
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()) {
|
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)))
|
if (token.is_function() && (token.function().name().equals_ignoring_case("var"sv) || token.function().name().equals_ignoring_case("attr"sv)))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
#include <LibWeb/CSS/FontFace.h>
|
#include <LibWeb/CSS/FontFace.h>
|
||||||
#include <LibWeb/CSS/GeneralEnclosed.h>
|
#include <LibWeb/CSS/GeneralEnclosed.h>
|
||||||
#include <LibWeb/CSS/MediaQuery.h>
|
#include <LibWeb/CSS/MediaQuery.h>
|
||||||
|
#include <LibWeb/CSS/Parser/Block.h>
|
||||||
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
||||||
#include <LibWeb/CSS/Parser/Declaration.h>
|
#include <LibWeb/CSS/Parser/Declaration.h>
|
||||||
#include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
|
#include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
|
||||||
#include <LibWeb/CSS/Parser/Function.h>
|
#include <LibWeb/CSS/Parser/Function.h>
|
||||||
#include <LibWeb/CSS/Parser/StyleBlockRule.h>
|
|
||||||
#include <LibWeb/CSS/Parser/StyleRule.h>
|
#include <LibWeb/CSS/Parser/StyleRule.h>
|
||||||
#include <LibWeb/CSS/Parser/Tokenizer.h>
|
#include <LibWeb/CSS/Parser/Tokenizer.h>
|
||||||
#include <LibWeb/CSS/Ratio.h>
|
#include <LibWeb/CSS/Ratio.h>
|
||||||
|
@ -193,7 +193,7 @@ private:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
[[nodiscard]] ComponentValue consume_a_component_value(TokenStream<T>&);
|
[[nodiscard]] ComponentValue consume_a_component_value(TokenStream<T>&);
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NonnullRefPtr<StyleBlockRule> consume_a_simple_block(TokenStream<T>&);
|
NonnullRefPtr<Block> consume_a_simple_block(TokenStream<T>&);
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NonnullRefPtr<Function> consume_a_function(TokenStream<T>&);
|
NonnullRefPtr<Function> consume_a_function(TokenStream<T>&);
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
#include <LibWeb/CSS/Parser/Block.h>
|
||||||
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
||||||
#include <LibWeb/CSS/Parser/StyleBlockRule.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public:
|
||||||
bool is_at_rule() const { return m_type == Type::At; }
|
bool is_at_rule() const { return m_type == Type::At; }
|
||||||
|
|
||||||
Vector<Parser::ComponentValue> const& prelude() const { return m_prelude; }
|
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 const& at_rule_name() const { return m_at_rule_name; }
|
||||||
|
|
||||||
String to_string() const;
|
String to_string() const;
|
||||||
|
@ -39,7 +39,7 @@ private:
|
||||||
Type const m_type;
|
Type const m_type;
|
||||||
String m_at_rule_name;
|
String m_at_rule_name;
|
||||||
Vector<Parser::ComponentValue> m_prelude;
|
Vector<Parser::ComponentValue> m_prelude;
|
||||||
RefPtr<StyleBlockRule> m_block;
|
RefPtr<Parser::Block> m_block;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/Parser/Block.h>
|
||||||
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
||||||
#include <LibWeb/CSS/Parser/Declaration.h>
|
#include <LibWeb/CSS/Parser/Declaration.h>
|
||||||
#include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
|
#include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
|
||||||
#include <LibWeb/CSS/Parser/Function.h>
|
#include <LibWeb/CSS/Parser/Function.h>
|
||||||
#include <LibWeb/CSS/Parser/StyleBlockRule.h>
|
|
||||||
#include <LibWeb/CSS/Parser/StyleRule.h>
|
#include <LibWeb/CSS/Parser/StyleRule.h>
|
||||||
#include <LibWeb/CSS/Serialize.h>
|
#include <LibWeb/CSS/Serialize.h>
|
||||||
|
|
||||||
|
|
|
@ -631,8 +631,8 @@ bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView p
|
||||||
Vector<Parser::ComponentValue> block_values;
|
Vector<Parser::ComponentValue> block_values;
|
||||||
if (!expand_unresolved_values(element, property_name, dependencies, source_block.values(), block_values, 0))
|
if (!expand_unresolved_values(element, property_name, dependencies, source_block.values(), block_values, 0))
|
||||||
return false;
|
return false;
|
||||||
NonnullRefPtr<StyleBlockRule> block = adopt_ref(*new StyleBlockRule(source_block.token(), move(block_values)));
|
NonnullRefPtr<Parser::Block> block = adopt_ref(*new Parser::Block(source_block.token(), move(block_values)));
|
||||||
dest.empend(block);
|
dest.empend(move(block));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
dest.empend(value.token());
|
dest.empend(value.token());
|
||||||
|
|
|
@ -99,6 +99,7 @@ enum class ValueID;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Web::CSS::Parser {
|
namespace Web::CSS::Parser {
|
||||||
|
class Block;
|
||||||
class ComponentValue;
|
class ComponentValue;
|
||||||
class Function;
|
class Function;
|
||||||
class Parser;
|
class Parser;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue