mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-27 19:29:52 +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
|
@ -251,7 +251,7 @@ RefPtr<CalculationNode> Parser::parse_math_function(Function const& function, Ca
|
|||
// NOTE: We have exactly one default value in the data right now, and it's a `<calc-constant>`,
|
||||
// so that's all we handle.
|
||||
if (auto default_value = parameter.get_string("default"sv); default_value.has_value()) {
|
||||
parameter_generator.set("parameter_default", MUST(String::formatted(" = ConstantCalculationNode::create(CalculationNode::constant_type_from_string(\"{}\"sv).value())", default_value.value())));
|
||||
parameter_generator.set("parameter_default", MUST(String::formatted(" = NumericCalculationNode::from_keyword(Keyword::{}, context)", title_casify(default_value.value()))));
|
||||
} else {
|
||||
parameter_generator.set("parameter_default", ""_string);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue