summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndi Gallo <andigallo@proton.me>2023-05-15 06:33:06 +0000
committerAndreas Kling <kling@serenityos.org>2023-05-16 14:34:53 +0200
commit9a6a635e51822516d3c4f05be5837a2e8dec09a3 (patch)
tree31c14c0093433741b2d4281184a21c16ab378067 /Userland
parent3e12d84f0f61ab31c476d8f655ae0655b39a9a84 (diff)
downloadserenity-9a6a635e51822516d3c4f05be5837a2e8dec09a3.zip
LibWeb: Fix for absolutely positioned elements with specified height
Use inner height since the paintable adds padding back. Fixes #18842.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index 42816e4fe6..11fb9add66 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -876,14 +876,25 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
}
}
- auto used_height = height.to_px(box, height_of_containing_block);
+ // Compute the height based on box type and CSS properties:
+ // https://www.w3.org/TR/css-sizing-3/#box-sizing
+ CSSPixels used_height = 0;
+ if (should_treat_height_as_auto(box, available_space)) {
+ used_height = height.to_px(box, height_of_containing_block);
+ } else {
+ used_height = calculate_inner_height(box, available_space.height, height).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.to_px(box, height_of_containing_block));
- if (!computed_min_height.is_auto())
- used_height = max(used_height, computed_min_height.to_px(box, height_of_containing_block));
+ if (!computed_max_height.is_none()) {
+ auto inner_max_height = calculate_inner_height(box, available_space.height, computed_max_height);
+ used_height = min(used_height, inner_max_height.to_px(box));
+ }
+ if (!computed_min_height.is_auto()) {
+ auto inner_min_height = calculate_inner_height(box, available_space.height, computed_min_height);
+ used_height = max(used_height, inner_min_height.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.