diff options
author | Andreas Kling <kling@serenityos.org> | 2022-07-17 19:38:06 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-26 01:53:41 +0200 |
commit | 02c59fe8c9362e0d1ea566e114867bac0c814e29 (patch) | |
tree | 13ff20067c8c250d01afe76e467a911e597545e2 /Userland | |
parent | 71a707480c6c580dbf88a88dde8d0c3d7898d930 (diff) | |
download | serenity-02c59fe8c9362e0d1ea566e114867bac0c814e29.zip |
LibWeb: Containing block always has definite width during abspos layout
From CSS-SIZING-3:
"...the size of the containing block of an absolutely positioned element
is always definite with respect to that element."
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FormattingContext.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index a8221c1738..4a6d6fd5c9 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -697,6 +697,15 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el void FormattingContext::layout_absolutely_positioned_element(Box const& box) { + // https://drafts.csswg.org/css-sizing-3/#definite + // Additionally, the size of the containing block of an absolutely positioned element is always definite with respect to that element. + auto& containing_block_state = m_state.get_mutable(*box.containing_block()); + auto containing_block_had_definite_width = containing_block_state.has_definite_width(); + containing_block_state.set_has_definite_width(true); + auto containing_block_definite_width_guard = ScopeGuard([&] { + containing_block_state.set_has_definite_width(containing_block_had_definite_width); + }); + auto width_of_containing_block = containing_block_width_for(box); auto height_of_containing_block = containing_block_height_for(box); auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block); |