summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-10-11 22:31:51 +0200
committerAndreas Kling <kling@serenityos.org>2022-10-11 22:31:51 +0200
commite6de3826794594784e1648c46d16cb7526c0b572 (patch)
tree3556039b7da1a59b0b52f188f392df397fde0816
parent0e295f727a2da39af1e296b987a7c949c3d5d024 (diff)
downloadserenity-e6de3826794594784e1648c46d16cb7526c0b572.zip
LibWeb: Constrain abspos element heights by min-height and max-height
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index 1b348f79b7..7d060a0886 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -876,6 +876,15 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
}
}
+ auto used_height = height.resolved(box, height_of_containing_block_as_length).to_px(box);
+ auto const& computed_min_height = box.computed_values().min_height();
+ auto const& computed_max_height = box.computed_values().max_height();
+
+ if (!computed_max_height.is_none())
+ used_height = min(used_height, computed_max_height.resolved(box, height_of_containing_block_as_length).resolved(box).to_px(box));
+ if (!computed_min_height.is_auto())
+ used_height = max(used_height, computed_min_height.resolved(box, height_of_containing_block_as_length).resolved(box).to_px(box));
+
// NOTE: The following is not directly part of any spec, but this is where we resolve
// the final used values for vertical margin/border/padding.
@@ -891,7 +900,7 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
box_state.padding_bottom = box.computed_values().padding().bottom().resolved(box, width_of_containing_block_as_length).to_px(box);
// And here is where we assign the box's content height.
- box_state.set_content_height(height.resolved(box, height_of_containing_block_as_length).to_px(box));
+ box_state.set_content_height(used_height);
}
// NOTE: This is different from content_box_rect_in_ancestor_coordinate_space() as this does *not* follow the containing block chain up, but rather the parent() chain.