mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb/CSS: Use NumericCalculationNode for constants
Having multiple kinds of node that hold numeric values made things more complicated than they needed to be, and we were already converting ConstantCalculationNodes to NumericCalculationNodes in the first simplification pass that happens at parse-time, so they didn't exist after that. As noted, the spec allows for other contexts to introduce their own numeric keywords, which might be resolved later than parse-time. We'll need a different mechanism to support those, but ConstantCalculationNode could not have done so anyway.
This commit is contained in:
committed by
Andreas Kling
parent
7b13ccabd4
commit
f97ac33cb3
@@ -3340,10 +3340,10 @@ RefPtr<CalculationNode> Parser::convert_to_calculation_node(CalcParsing::Node co
|
||||
// AD-HOC: We also need to convert tokens into their numeric types.
|
||||
|
||||
if (component_value->is(Token::Type::Ident)) {
|
||||
auto maybe_constant = CalculationNode::constant_type_from_string(component_value->token().ident());
|
||||
if (!maybe_constant.has_value())
|
||||
auto maybe_keyword = keyword_from_string(component_value->token().ident());
|
||||
if (!maybe_keyword.has_value())
|
||||
return nullptr;
|
||||
return ConstantCalculationNode::create(*maybe_constant);
|
||||
return NumericCalculationNode::from_keyword(*maybe_keyword, context);
|
||||
}
|
||||
|
||||
if (component_value->is(Token::Type::Number))
|
||||
|
||||
Reference in New Issue
Block a user