1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:08:10 +00:00

LibWeb: Solve width for absolute positioned elemenent according to spec

https://www.w3.org/TR/css-position-3/#abs-non-replaced-width
If left and width are auto and right is not auto, then
the width is shrink-to-fit. Then solve for left.
This commit is contained in:
Aliaksandr Kalenik 2022-11-16 03:57:38 +03:00 committed by Andreas Kling
parent 70559e9d14
commit 1b5b7e3b01

View file

@ -595,9 +595,9 @@ void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_ele
// then the width is shrink-to-fit. Then solve for 'left'
if (left.is_auto() && width.is_auto() && !right.is_auto()) {
auto result = calculate_shrink_to_fit_widths(box);
left = solve_for_left();
auto available_width = solve_for_width();
width = CSS::Length(min(max(result.preferred_minimum_width, available_width.to_px(box)), result.preferred_width), CSS::Length::Type::Px);
left = solve_for_left();
}
// 2. 'left' and 'right' are 'auto' and 'width' is not 'auto',