diff --git a/Tests/LibWeb/Layout/expected/height-of-absolute-position-box-with-padding.txt b/Tests/LibWeb/Layout/expected/height-of-absolute-position-box-with-padding.txt new file mode 100644 index 0000000000..618bf940fd --- /dev/null +++ b/Tests/LibWeb/Layout/expected/height-of-absolute-position-box-with-padding.txt @@ -0,0 +1,12 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x16 [BFC] children: not-inline + BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline + TextNode <#text> + BlockContainer at (8,8) content-size 784x0 children: inline + TextNode <#text> + BlockContainer

at (76.590553,103.754333) content-size 126x38 positioned [BFC] children: inline + line 0 width: 37.21875, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 4, rect: [120.590553,103.754333 37.21875x17.46875] + "Test" + TextNode <#text> + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/height-of-absolute-position-box-with-padding.html b/Tests/LibWeb/Layout/input/height-of-absolute-position-box-with-padding.html new file mode 100644 index 0000000000..b3f5b97bc3 --- /dev/null +++ b/Tests/LibWeb/Layout/input/height-of-absolute-position-box-with-padding.html @@ -0,0 +1,27 @@ + + + + + + + +

Test

+ + + \ No newline at end of file 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.