diff options
author | Andreas Kling <kling@serenityos.org> | 2022-09-24 14:41:18 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-09-24 14:41:18 +0200 |
commit | c04b107e26175033af8a36855f9d3bed9756a734 (patch) | |
tree | 93d2bcd901389d46c190e584b5fb4b15bedd791c /Userland/Libraries/LibWeb | |
parent | a5b72577e618df28684466460535878993839762 (diff) | |
download | serenity-c04b107e26175033af8a36855f9d3bed9756a734.zip |
LibWeb: Treat replaced % sizes as 0 if containing block is indefinite
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FormattingContext.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index 094755fbdb..4124d85347 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -361,8 +361,11 @@ float FormattingContext::compute_auto_height_for_block_formatting_context_root(L // 10.3.2 Inline, replaced elements, https://www.w3.org/TR/CSS22/visudet.html#inline-replaced-width float FormattingContext::tentative_width_for_replaced_element(LayoutState const& state, ReplacedBox const& box, CSS::LengthPercentage const& computed_width) { - auto const& containing_block = *box.containing_block(); - auto height_of_containing_block = CSS::Length::make_px(state.get(containing_block).content_height()); + // Treat percentages of indefinite containing block widths as 0 (the initial width). + if (computed_width.is_percentage() && !state.get(*box.containing_block()).has_definite_width()) + return 0; + + auto height_of_containing_block = CSS::Length::make_px(containing_block_height_for(box, state)); auto computed_height = box.computed_values().height().resolved(box, height_of_containing_block).resolved(box); float used_width = computed_width.resolved(box, CSS::Length::make_px(containing_block_width_for(box, state))).to_px(box); @@ -463,6 +466,10 @@ float FormattingContext::compute_width_for_replaced_element(LayoutState const& s // https://www.w3.org/TR/CSS22/visudet.html#inline-replaced-height float FormattingContext::tentative_height_for_replaced_element(LayoutState const& state, ReplacedBox const& box, CSS::LengthPercentage const& computed_height) { + // Treat percentages of indefinite containing block heights as 0 (the initial height). + if (computed_height.is_percentage() && !state.get(*box.containing_block()).has_definite_height()) + return 0; + auto computed_width = box.computed_values().width(); // If 'height' and 'width' both have computed values of 'auto' and the element also has |