mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb: Always blockify the root element
This is what the spec tells us to do:
The root element’s display type is always blockified,
and its principal box always establishes an independent
formatting context.
Additionally, a display of contents computes to block
on the root element.
Spec link: https://drafts.csswg.org/css-display/#root
Fixes #1562
This commit is contained in:
committed by
Andreas Kling
parent
f377bf862a
commit
f1be662f68
@@ -2177,9 +2177,17 @@ void StyleComputer::transform_box_type_if_needed(StyleProperties& style, DOM::El
|
||||
// (This has no effect on display types that generate no box at all, such as none or contents.)
|
||||
|
||||
auto display = style.display();
|
||||
if (display.is_none() || display.is_contents())
|
||||
|
||||
if (display.is_none() || (display.is_contents() && !element.is_document_element()))
|
||||
return;
|
||||
|
||||
// https://drafts.csswg.org/css-display/#root
|
||||
// The root element’s display type is always blockified, and its principal box always establishes an independent formatting context.
|
||||
if (element.is_document_element() && !display.is_block_outside()) {
|
||||
style.set_property(CSS::PropertyID::Display, DisplayStyleValue::create(Display::from_short(CSS::Display::Short::Block)));
|
||||
return;
|
||||
}
|
||||
|
||||
auto new_display = display;
|
||||
|
||||
if (display.is_math_inside()) {
|
||||
|
||||
Reference in New Issue
Block a user