mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +00:00
LibWeb: Add direct StyleComponentValueRule constructors
Rather than passing a ComponentType, and then manually modifying the data fields, we now create them initialized. The constructor that takes a Token is intentionally left implicit, so that we can automatically convert when using the TokenStream later.
This commit is contained in:
parent
82d12b170a
commit
8671d79ba4
Notes:
sideshowbarker
2024-07-18 09:14:16 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/8671d79ba48 Pull-request: https://github.com/SerenityOS/serenity/pull/8341
|
@ -559,21 +559,13 @@ StyleComponentValueRule Parser::consume_a_component_value()
|
|||
{
|
||||
auto token = next_token();
|
||||
|
||||
if (token.is_open_curly() || token.is_open_square() || token.is_open_paren()) {
|
||||
auto component = StyleComponentValueRule(StyleComponentValueRule::ComponentType::Block);
|
||||
component.m_block = consume_a_simple_block();
|
||||
return component;
|
||||
}
|
||||
if (token.is_open_curly() || token.is_open_square() || token.is_open_paren())
|
||||
return StyleComponentValueRule(consume_a_simple_block());
|
||||
|
||||
if (token.is_function()) {
|
||||
auto component = StyleComponentValueRule(StyleComponentValueRule::ComponentType::Function);
|
||||
component.m_function = consume_a_function();
|
||||
return component;
|
||||
}
|
||||
if (token.is_function())
|
||||
return StyleComponentValueRule(consume_a_function());
|
||||
|
||||
auto component = StyleComponentValueRule(StyleComponentValueRule::ComponentType::Token);
|
||||
component.m_token = token;
|
||||
return component;
|
||||
return StyleComponentValueRule(token);
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleBlockRule> Parser::consume_a_simple_block()
|
||||
|
@ -722,10 +714,7 @@ Vector<DeclarationOrAtRule> Parser::consume_a_list_of_declarations()
|
|||
|
||||
if (token.is_ident()) {
|
||||
Vector<StyleComponentValueRule> temp;
|
||||
|
||||
auto component = StyleComponentValueRule(StyleComponentValueRule::ComponentType::Token);
|
||||
component.m_token = token;
|
||||
temp.append(component);
|
||||
temp.append(StyleComponentValueRule(token));
|
||||
|
||||
for (;;) {
|
||||
auto peek = peek_token();
|
||||
|
|
|
@ -26,7 +26,9 @@ public:
|
|||
Block
|
||||
};
|
||||
|
||||
explicit StyleComponentValueRule(ComponentType);
|
||||
StyleComponentValueRule(Token);
|
||||
explicit StyleComponentValueRule(NonnullRefPtr<StyleFunctionRule>);
|
||||
explicit StyleComponentValueRule(NonnullRefPtr<StyleBlockRule>);
|
||||
~StyleComponentValueRule();
|
||||
|
||||
bool is_block() const { return m_type == ComponentType::Block; }
|
||||
|
|
|
@ -35,8 +35,19 @@ StyleRule::~StyleRule() { }
|
|||
StyleBlockRule::StyleBlockRule() { }
|
||||
StyleBlockRule::~StyleBlockRule() { }
|
||||
|
||||
StyleComponentValueRule::StyleComponentValueRule(ComponentType type)
|
||||
: m_type(type)
|
||||
StyleComponentValueRule::StyleComponentValueRule(Token token)
|
||||
: m_type(StyleComponentValueRule::ComponentType::Token)
|
||||
, m_token(token)
|
||||
{
|
||||
}
|
||||
StyleComponentValueRule::StyleComponentValueRule(NonnullRefPtr<StyleFunctionRule> function)
|
||||
: m_type(StyleComponentValueRule::ComponentType::Function)
|
||||
, m_function(function)
|
||||
{
|
||||
}
|
||||
StyleComponentValueRule::StyleComponentValueRule(NonnullRefPtr<StyleBlockRule> block)
|
||||
: m_type(StyleComponentValueRule::ComponentType::Block)
|
||||
, m_block(block)
|
||||
{
|
||||
}
|
||||
StyleComponentValueRule::~StyleComponentValueRule() { }
|
||||
|
|
Loading…
Reference in a new issue