.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 {