mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +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:
parent
7b13ccabd4
commit
f97ac33cb3
Notes:
github-actions[bot]
2025-02-27 20:43:53 +00:00
Author: https://github.com/AtkinsSJ
Commit: f97ac33cb3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3719
6 changed files with 45 additions and 140 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue