1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

LibWeb: Store PositionStyleValue's edges as EdgeStyleValues

They can't be anything else, so this will make working with them easier.
This commit is contained in:
Sam Atkins 2023-11-06 17:46:19 +00:00 committed by Sam Atkins
parent 875661a584
commit 4ad58f0204
2 changed files with 11 additions and 8 deletions

View file

@ -825,11 +825,13 @@ static ErrorOr<NonnullRefPtr<StyleValue>> interpolate_property(StyleValue const&
case StyleValue::Type::Percentage:
return PercentageStyleValue::create(Percentage(interpolate_raw(from.as_percentage().percentage().value(), to.as_percentage().percentage().value())));
case StyleValue::Type::Position: {
// https://www.w3.org/TR/css-values-4/#combine-positions
// FIXME: Interpolation of <position> is defined as the independent interpolation of each component (x, y) normalized as an offset from the top left corner as a <length-percentage>.
auto& from_position = from.as_position();
auto& to_position = to.as_position();
return PositionStyleValue::create(
TRY(interpolate_property(from_position.edge_x(), to_position.edge_x(), delta)),
TRY(interpolate_property(from_position.edge_y(), to_position.edge_y(), delta)));
TRY(interpolate_property(from_position.edge_x(), to_position.edge_x(), delta))->as_edge(),
TRY(interpolate_property(from_position.edge_y(), to_position.edge_y(), delta))->as_edge());
}
case StyleValue::Type::Rect: {
auto from_rect = from.as_rect().rect();