mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-15 20:49:41 +00:00
LibWeb/CSS: Add a Property -> CalculationContext factory method
We have this code duplicated in multiple places, and we'll want to handle registered custom properties too at some point, so wrap it in a reusable `CalculationContext::for_property()` method. Noticed while doing this that ValueParsingContext will eventually need to take a PropertyNameAndID, not a PropertyID, so I've added a FIXME.
This commit is contained in:
parent
a3e973970a
commit
0afa93e639
Notes:
github-actions[bot]
2025-10-13 09:01:24 +00:00
Author: https://github.com/AtkinsSJ
Commit: 0afa93e639
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6440
6 changed files with 19 additions and 15 deletions
|
@ -322,11 +322,7 @@ WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSUnitValue::create_an_int
|
|||
}
|
||||
|
||||
auto wrap_in_math_sum = [this, &property](auto&& value) -> NonnullRefPtr<StyleValue const> {
|
||||
CalculationContext context {
|
||||
.percentages_resolve_as = property_resolves_percentages_relative_to(property.id()),
|
||||
.resolve_numbers_as_integers = property_accepts_type(property.id(), ValueType::Integer),
|
||||
.accepted_type_ranges = property_accepted_type_ranges(property.id()),
|
||||
};
|
||||
auto context = CalculationContext::for_property(property);
|
||||
auto numeric_node = NumericCalculationNode::create(value, context);
|
||||
auto math_sum_node = SumCalculationNode::create({ move(numeric_node) });
|
||||
return CalculatedStyleValue::create(move(math_sum_node), NumericType::create_from_unit(m_unit).release_value(), context);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue