diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/html-element-height-quirks-mode-off.txt b/Tests/LibWeb/Layout/expected/block-and-inline/html-element-height-quirks-mode-off.txt new file mode 100644 index 0000000000..0f0d8da3a9 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/block-and-inline/html-element-height-quirks-mode-off.txt @@ -0,0 +1,9 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x136 [BFC] children: not-inline + BlockContainer at (18,18) content-size 764x100 children: not-inline + BlockContainer at (18,18) content-size 100x100 children: not-inline + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x136] + PaintableWithLines (BlockContainer) [8,8 784x120] + PaintableWithLines (BlockContainer
.box) [18,18 100x100] diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/html-element-height-quirks-mode-on.txt b/Tests/LibWeb/Layout/expected/block-and-inline/html-element-height-quirks-mode-on.txt new file mode 100644 index 0000000000..2c2f5b3314 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/block-and-inline/html-element-height-quirks-mode-on.txt @@ -0,0 +1,9 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline + BlockContainer at (18,18) content-size 764x300 children: not-inline + BlockContainer at (18,18) content-size 100x100 children: not-inline + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x600] + PaintableWithLines (BlockContainer) [8,8 784x320] + PaintableWithLines (BlockContainer
.box) [18,18 100x100] diff --git a/Tests/LibWeb/Layout/expected/viewport-overflow-propagation-2.txt b/Tests/LibWeb/Layout/expected/viewport-overflow-propagation-2.txt index dc4c1e68ee..6729183f1c 100644 --- a/Tests/LibWeb/Layout/expected/viewport-overflow-propagation-2.txt +++ b/Tests/LibWeb/Layout/expected/viewport-overflow-propagation-2.txt @@ -1,10 +1,10 @@ Viewport <#document> at (0,0) content-size 800x600 [BFC] children: not-inline - BlockContainer at (0,0) content-size 800x616 [BFC] children: not-inline - BlockContainer at (8,8) content-size 784x600 children: not-inline + BlockContainer at (0,0) content-size 800x2016 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x2000 children: not-inline BlockContainer at (8,8) content-size 784x2000 children: inline TextNode <#text> -ViewportPaintable (Viewport<#document>) [0,0 800x600] overflow: [0,0 800x2008] - PaintableWithLines (BlockContainer) [0,0 800x616] overflow: [0,0 800x2008] - PaintableWithLines (BlockContainer) [8,8 784x600] overflow: [8,8 784x2000] +ViewportPaintable (Viewport<#document>) [0,0 800x600] overflow: [0,0 800x2016] + PaintableWithLines (BlockContainer) [0,0 800x2016] + PaintableWithLines (BlockContainer) [8,8 784x2000] PaintableWithLines (BlockContainer
.long) [8,8 784x2000] diff --git a/Tests/LibWeb/Layout/input/block-and-inline/html-element-height-quirks-mode-off.html b/Tests/LibWeb/Layout/input/block-and-inline/html-element-height-quirks-mode-off.html new file mode 100644 index 0000000000..cddab6b57c --- /dev/null +++ b/Tests/LibWeb/Layout/input/block-and-inline/html-element-height-quirks-mode-off.html @@ -0,0 +1,15 @@ +
\ No newline at end of file diff --git a/Tests/LibWeb/Layout/input/block-and-inline/html-element-height-quirks-mode-on.html b/Tests/LibWeb/Layout/input/block-and-inline/html-element-height-quirks-mode-on.html new file mode 100644 index 0000000000..4f78655a4e --- /dev/null +++ b/Tests/LibWeb/Layout/input/block-and-inline/html-element-height-quirks-mode-on.html @@ -0,0 +1,15 @@ +
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 88915bb43d..435668b090 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -996,7 +996,6 @@ void Document::update_layout() VERIFY(document_element->layout_node()); auto& icb_state = layout_state.get_mutable(verify_cast(*document_element->layout_node())); icb_state.set_content_width(viewport_rect.width()); - icb_state.set_content_height(viewport_rect.height()); } root_formatting_context.run( diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index f76ba708ac..61b6cdd98d 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -478,7 +478,7 @@ void BlockFormattingContext::compute_height(Box const& box, AvailableSpace const auto margins = box_state.margin_top + box_state.margin_bottom; // 2. Let size be the size of the initial containing block in the block flow direction minus margins. - auto size = box_state.content_height() - margins; + auto size = m_state.get(*box.containing_block()).content_height() - margins; // 3. Return the bigger value of size and the normal border box size the element would have // according to the CSS specification. @@ -630,7 +630,13 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain auto const y = m_y_offset_of_current_block_container.value(); - if (box_state.has_definite_height()) { + auto box_is_html_element_in_quirks_mode = box.document().in_quirks_mode() + && box.dom_node() + && box.dom_node()->is_html_html_element() + && box.computed_values().height().is_auto(); + + // NOTE: In quirks mode, the html element's height matches the viewport so it can be treated as definite + if (box_state.has_definite_height() || box_is_html_element_in_quirks_mode) { compute_height(box, available_space); } @@ -881,6 +887,8 @@ void BlockFormattingContext::layout_viewport(LayoutMode layout_mode, AvailableSp // and we call directly into the SVG layout code from here. if (root().first_child() && root().first_child()->is_svg_svg_box()) { auto const& svg_root = verify_cast(*root().first_child()); + auto content_height = m_state.get(*svg_root.containing_block()).content_height(); + m_state.get_mutable(svg_root).set_content_height(content_height); auto svg_formatting_context = create_independent_formatting_context_if_needed(m_state, svg_root); svg_formatting_context->run(svg_root, layout_mode, available_space); } else {