mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +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:
parent
f377bf862a
commit
f1be662f68
Notes:
github-actions[bot]
2024-09-29 09:47:03 +00:00
Author: https://github.com/awesomekling
Commit: f1be662f68
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1563
12 changed files with 44 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
||||||
Viewport <#document> at (0,0) content-size 800x600 children: inline
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
InlineNode <html>
|
BlockContainer <html> at (0,0) content-size 800x17 [BFC] children: inline
|
||||||
InlineNode <head>
|
InlineNode <head>
|
||||||
InlineNode <style>
|
InlineNode <style>
|
||||||
frag 0 from TextNode start: 1, length: 18, rect: [0,0 134.984375x17] baseline: 13.296875
|
frag 0 from TextNode start: 1, length: 18, rect: [0,0 134.984375x17] baseline: 13.296875
|
||||||
|
@ -11,7 +11,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: inline
|
||||||
TextNode <#text>
|
TextNode <#text>
|
||||||
|
|
||||||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
InlinePaintable (InlineNode<HTML>)
|
PaintableWithLines (BlockContainer<HTML>) [0,0 800x17]
|
||||||
InlinePaintable (InlineNode<HEAD>)
|
InlinePaintable (InlineNode<HEAD>)
|
||||||
InlinePaintable (InlineNode<STYLE>)
|
InlinePaintable (InlineNode<STYLE>)
|
||||||
TextPaintable (TextNode<#text>)
|
TextPaintable (TextNode<#text>)
|
||||||
|
|
11
Tests/LibWeb/Layout/expected/html-display-contents.txt
Normal file
11
Tests/LibWeb/Layout/expected/html-display-contents.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
|
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
|
||||||
|
BlockContainer <body> at (8,8) content-size 784x17 children: inline
|
||||||
|
frag 0 from TextNode start: 0, length: 3, rect: [8,8 18.828125x17] baseline: 13.296875
|
||||||
|
"lol"
|
||||||
|
TextNode <#text>
|
||||||
|
|
||||||
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<BODY>) [8,8 784x17]
|
||||||
|
TextPaintable (TextNode<#text>)
|
11
Tests/LibWeb/Layout/expected/html-display-inline.txt
Normal file
11
Tests/LibWeb/Layout/expected/html-display-inline.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
|
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
|
||||||
|
BlockContainer <body> at (8,8) content-size 784x17 children: inline
|
||||||
|
frag 0 from TextNode start: 0, length: 3, rect: [8,8 18.828125x17] baseline: 13.296875
|
||||||
|
"lol"
|
||||||
|
TextNode <#text>
|
||||||
|
|
||||||
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<BODY>) [8,8 784x17]
|
||||||
|
TextPaintable (TextNode<#text>)
|
|
@ -7,7 +7,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
frag 0 from ImageBox start: 0, length: 0, rect: [8,8 150x150] baseline: 150
|
frag 0 from ImageBox start: 0, length: 0, rect: [8,8 150x150] baseline: 150
|
||||||
ImageBox <img.replaced> at (8,8) content-size 150x150 children: not-inline
|
ImageBox <img.replaced> at (8,8) content-size 150x150 children: not-inline
|
||||||
(SVG-as-image isolated context)
|
(SVG-as-image isolated context)
|
||||||
Viewport <#document> at (0,0) content-size 150x150 [BFC] children: inline
|
Viewport <#document> at (0,0) content-size 150x150 [BFC] children: not-inline
|
||||||
SVGSVGBox <svg> at (0,0) content-size 150x150 [SVG] children: not-inline
|
SVGSVGBox <svg> at (0,0) content-size 150x150 [SVG] children: not-inline
|
||||||
SVGGeometryBox <path> at (0,0) content-size 150x150 children: not-inline
|
SVGGeometryBox <path> at (0,0) content-size 150x150 children: not-inline
|
||||||
TextNode <#text>
|
TextNode <#text>
|
||||||
|
|
|
@ -3,7 +3,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
BlockContainer <body> at (8,8) content-size 784x100 children: not-inline
|
BlockContainer <body> at (8,8) content-size 784x100 children: not-inline
|
||||||
ImageBox <img> at (8,8) content-size 50x100 children: not-inline
|
ImageBox <img> at (8,8) content-size 50x100 children: not-inline
|
||||||
(SVG-as-image isolated context)
|
(SVG-as-image isolated context)
|
||||||
Viewport <#document> at (0,0) content-size 50x100 [BFC] children: inline
|
Viewport <#document> at (0,0) content-size 50x100 [BFC] children: not-inline
|
||||||
SVGSVGBox <svg> at (0,0) content-size 50x100 [SVG] children: not-inline
|
SVGSVGBox <svg> at (0,0) content-size 50x100 [SVG] children: not-inline
|
||||||
SVGGeometryBox <rect> at (0,0) content-size 50x100 children: not-inline
|
SVGGeometryBox <rect> at (0,0) content-size 50x100 children: not-inline
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
BlockContainer <body> at (8,8) content-size 784x1568 children: not-inline
|
BlockContainer <body> at (8,8) content-size 784x1568 children: not-inline
|
||||||
ImageBox <img> at (8,8) content-size 784x1568 children: not-inline
|
ImageBox <img> at (8,8) content-size 784x1568 children: not-inline
|
||||||
(SVG-as-image isolated context)
|
(SVG-as-image isolated context)
|
||||||
Viewport <#document> at (0,0) content-size 784x1568 [BFC] children: inline
|
Viewport <#document> at (0,0) content-size 784x1568 [BFC] children: not-inline
|
||||||
SVGSVGBox <svg> at (0,0) content-size 784x1568 [SVG] children: inline
|
SVGSVGBox <svg> at (0,0) content-size 784x1568 [SVG] children: inline
|
||||||
TextNode <#text>
|
TextNode <#text>
|
||||||
SVGGeometryBox <rect> at (0,0) content-size 784x1568 children: not-inline
|
SVGGeometryBox <rect> at (0,0) content-size 784x1568 children: not-inline
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
Viewport <#document> at (0,0) content-size 800x600 children: inline
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
InlineNode <svg>
|
BlockContainer <svg> at (0,0) content-size 800x0 children: inline
|
||||||
TextNode <#text>
|
TextNode <#text>
|
||||||
InlineNode <rect>
|
InlineNode <rect>
|
||||||
TextNode <#text>
|
TextNode <#text>
|
||||||
|
|
||||||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
InlinePaintable (InlineNode<svg>)
|
PaintableWithLines (BlockContainer<svg>) [0,0 800x0]
|
||||||
InlinePaintable (InlineNode<rect>)
|
InlinePaintable (InlineNode<rect>)
|
||||||
|
|
|
@ -4,7 +4,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
frag 0 from ImageBox start: 0, length: 0, rect: [8,8 300x150] baseline: 150
|
frag 0 from ImageBox start: 0, length: 0, rect: [8,8 300x150] baseline: 150
|
||||||
ImageBox <img> at (8,8) content-size 300x150 children: not-inline
|
ImageBox <img> at (8,8) content-size 300x150 children: not-inline
|
||||||
(SVG-as-image isolated context)
|
(SVG-as-image isolated context)
|
||||||
Viewport <#document> at (0,0) content-size 300x150 [BFC] children: inline
|
Viewport <#document> at (0,0) content-size 300x150 [BFC] children: not-inline
|
||||||
SVGSVGBox <svg> at (0,0) content-size 300x150 [SVG] children: not-inline
|
SVGSVGBox <svg> at (0,0) content-size 300x150 [SVG] children: not-inline
|
||||||
TextNode <#text>
|
TextNode <#text>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
frag 0 from ImageBox start: 0, length: 0, rect: [8,8 300x150] baseline: 150
|
frag 0 from ImageBox start: 0, length: 0, rect: [8,8 300x150] baseline: 150
|
||||||
ImageBox <img> at (8,8) content-size 300x150 children: not-inline
|
ImageBox <img> at (8,8) content-size 300x150 children: not-inline
|
||||||
(SVG-as-image isolated context)
|
(SVG-as-image isolated context)
|
||||||
Viewport <#document> at (0,0) content-size 300x150 [BFC] children: inline
|
Viewport <#document> at (0,0) content-size 300x150 [BFC] children: not-inline
|
||||||
SVGSVGBox <svg> at (0,0) content-size 300x150 [SVG] children: not-inline
|
SVGSVGBox <svg> at (0,0) content-size 300x150 [SVG] children: not-inline
|
||||||
|
|
||||||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
|
|
1
Tests/LibWeb/Layout/input/html-display-contents.html
Normal file
1
Tests/LibWeb/Layout/input/html-display-contents.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<html style="display:contents"><body>lol
|
1
Tests/LibWeb/Layout/input/html-display-inline.html
Normal file
1
Tests/LibWeb/Layout/input/html-display-inline.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<html style="display:inline">lol
|
|
@ -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.)
|
// (This has no effect on display types that generate no box at all, such as none or contents.)
|
||||||
|
|
||||||
auto display = style.display();
|
auto display = style.display();
|
||||||
if (display.is_none() || display.is_contents())
|
|
||||||
|
if (display.is_none() || (display.is_contents() && !element.is_document_element()))
|
||||||
return;
|
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;
|
auto new_display = display;
|
||||||
|
|
||||||
if (display.is_math_inside()) {
|
if (display.is_math_inside()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue