mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 01:08:56 +00:00
LibWeb/CSS: Resolve percentages against values in their canonical unit
This commit is contained in:
parent
923dce4ec1
commit
7afcf305b2
Notes:
github-actions[bot]
2025-09-07 14:56:31 +00:00
Author: https://github.com/InvalidUsernameException
Commit: 7afcf305b2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6083
Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 4 additions and 4 deletions
|
@ -3214,19 +3214,19 @@ NonnullRefPtr<CalculationNode const> simplify_a_calculation_tree(CalculationNode
|
|||
[&](Angle const& angle) -> RefPtr<NumericCalculationNode const> {
|
||||
VERIFY(context.percentages_resolve_as == ValueType::Angle);
|
||||
if (angle.type() == Angle::Type::Deg)
|
||||
return nullptr;
|
||||
return NumericCalculationNode::create(angle.percentage_of(*percentage), context);
|
||||
return NumericCalculationNode::create(Angle::make_degrees(angle.to_degrees()).percentage_of(*percentage), context);
|
||||
},
|
||||
[&](Frequency const& frequency) -> RefPtr<NumericCalculationNode const> {
|
||||
VERIFY(context.percentages_resolve_as == ValueType::Frequency);
|
||||
if (frequency.type() == Frequency::Type::Hz)
|
||||
return nullptr;
|
||||
return NumericCalculationNode::create(frequency.percentage_of(*percentage), context);
|
||||
return NumericCalculationNode::create(Frequency::make_hertz(frequency.to_hertz()).percentage_of(*percentage), context);
|
||||
},
|
||||
[&](Length const& length) -> RefPtr<NumericCalculationNode const> {
|
||||
VERIFY(context.percentages_resolve_as == ValueType::Length);
|
||||
if (length.type() == Length::Type::Px)
|
||||
return nullptr;
|
||||
return NumericCalculationNode::create(length.percentage_of(*percentage), context);
|
||||
if (length.is_absolute())
|
||||
return NumericCalculationNode::create(Length::make_px(length.absolute_length_to_px()).percentage_of(*percentage), context);
|
||||
if (resolution_context.length_resolution_context.has_value())
|
||||
|
@ -3236,7 +3236,7 @@ NonnullRefPtr<CalculationNode const> simplify_a_calculation_tree(CalculationNode
|
|||
[&](Time const& time) -> RefPtr<NumericCalculationNode const> {
|
||||
VERIFY(context.percentages_resolve_as == ValueType::Time);
|
||||
if (time.type() == Time::Type::S)
|
||||
return nullptr;
|
||||
return NumericCalculationNode::create(time.percentage_of(*percentage), context);
|
||||
return NumericCalculationNode::create(Time::make_seconds(time.to_seconds()).percentage_of(*percentage), context);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue