Skip to content

Commit ffcd3a4

Browse files
lpasgmta
authored andcommitted
LibWeb: Count the width of inline-blocks in InlineNodes only once
An BlockContainer inside an InlineNode is called from the `for each in inclusive_subtree_of_type` but is also a fragment of that InlineNode. Don't count the the Node twice.
1 parent 93fde59 commit ffcd3a4

File tree

6 files changed

+66
-6
lines changed

6 files changed

+66
-6
lines changed

Libraries/LibWeb/Layout/LayoutState.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ void LayoutState::commit(Box& root)
383383
paintable_with_lines->for_each_in_inclusive_subtree_of_type<Painting::PaintableWithLines>([&](auto& paintable) {
384384
if (paintable.line_index() != line_index)
385385
return TraversalDecision::Continue;
386+
if (is<BlockContainer>(paintable.layout_node()))
387+
return TraversalDecision::Continue;
386388

387389
auto used_values = used_values_per_layout_node.get(paintable.layout_node_with_style_and_box_metrics());
388390
if (&paintable != paintable_with_lines && used_values.has_value())

Tests/LibWeb/Layout/expected/abspos-static-position-containing-block-inline-situation.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] children: not-inline
22
BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 18 0+0+0] [BFC] children: inline
3-
InlineNode <body> at [0,13] [8+0+0 36.84375 0+0+8] [8+0+0 0 0+0+8]
3+
InlineNode <body> at [8,13] [8+0+0 0 0+0+8] [8+0+0 0 0+0+8]
44
frag 0 from BlockContainer start: 0, length: 0, rect: [8,13 0x0] baseline: 0
55
BlockContainer <main> at [8,13] inline-block [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
66
BlockContainer <div> at [8,0] positioned [0+0+0 36.84375 0+0+0] [0+0+0 18 0+0+0] [BFC] children: inline
@@ -10,7 +10,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] children: not-
1010

1111
ViewportPaintable (Viewport<#document>) [0,0 800x600]
1212
PaintableWithLines (BlockContainer<HTML>) [0,0 800x18]
13-
PaintableWithLines (InlineNode<BODY>) [0,13 36.84375x0]
13+
PaintableWithLines (InlineNode<BODY>) [8,13 0x0]
1414
PaintableWithLines (BlockContainer<MAIN>) [8,13 0x0]
1515
PaintableWithLines (BlockContainer<DIV>) [8,0 36.84375x18]
1616
TextPaintable (TextNode<#text>)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] children: not-inline
2+
BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 34 0+0+0] [BFC] children: not-inline
3+
BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 18 0+0+8] children: inline
4+
TextNode <#text> (not painted)
5+
InlineNode <span> at [8,8] [0+0+0 193.453125 0+0+0] [0+0+0 18 0+0+0]
6+
frag 0 from BlockContainer start: 0, length: 0, rect: [8,8 185.453125x18] baseline: 13.796875
7+
frag 1 from TextNode start: 0, length: 1, rect: [193.453125,8 8x18] baseline: 13.796875
8+
" "
9+
TextNode <#text> (not painted)
10+
BlockContainer <div> at [8,8] inline-block [0+0+0 185.453125 0+0+0] [0+0+0 18 0+0+0] [BFC] children: inline
11+
frag 0 from TextNode start: 0, length: 13, rect: [8,8 185.453125x18] baseline: 13.796875
12+
"AAAAAAAAAAAAA"
13+
TextNode <#text> (not painted)
14+
TextNode <#text> (not painted)
15+
TextNode <#text> (not painted)
16+
InlineNode <span> at [201.453125,8] [0+0+0 46.71875 0+0+0] [0+0+0 18 0+0+0]
17+
frag 0 from BlockContainer start: 0, length: 0, rect: [201.453125,8 46.71875x18] baseline: 13.796875
18+
TextNode <#text> (not painted)
19+
BlockContainer <div> at [201.453125,8] inline-block [0+0+0 46.71875 0+0+0] [0+0+0 18 0+0+0] [BFC] children: inline
20+
frag 0 from TextNode start: 0, length: 5, rect: [201.453125,8 46.71875x18] baseline: 13.796875
21+
"BBBBB"
22+
TextNode <#text> (not painted)
23+
TextNode <#text> (not painted)
24+
TextNode <#text> (not painted)
25+
26+
ViewportPaintable (Viewport<#document>) [0,0 800x600]
27+
PaintableWithLines (BlockContainer<HTML>) [0,0 800x34]
28+
PaintableWithLines (BlockContainer<BODY>) [8,8 784x18]
29+
PaintableWithLines (InlineNode<SPAN>) [8,8 193.453125x18]
30+
PaintableWithLines (BlockContainer<DIV>) [8,8 185.453125x18]
31+
TextPaintable (TextNode<#text>)
32+
TextPaintable (TextNode<#text>)
33+
PaintableWithLines (InlineNode<SPAN>) [201.453125,8 46.71875x18]
34+
PaintableWithLines (BlockContainer<DIV>) [201.453125,8 46.71875x18]
35+
TextPaintable (TextNode<#text>)
36+
37+
SC for Viewport<#document> [0,0 800x600] [children: 1] (z-index: auto)
38+
SC for BlockContainer<HTML> [0,0 800x34] [children: 0] (z-index: auto)

Tests/LibWeb/Layout/expected/block-and-inline/no-relocation-of-atomic-inline-fragments.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] children: not-inline
22
BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 18 0+0+0] [BFC] children: inline
3-
InlineNode <body> at [0,0] [8+0+0 23.59375 0+0+8] [8+0+0 18 0+0+8]
3+
InlineNode <body> at [8,0] [8+0+0 11.796875 0+0+8] [8+0+0 18 0+0+8]
44
frag 0 from BlockContainer start: 0, length: 0, rect: [8,0 11.796875x18] baseline: 13.796875
55
BlockContainer <div> at [8,0] positioned inline-block [0+0+0 11.796875 0+0+0] [0+0+0 18 0+0+0] [BFC] children: inline
66
frag 0 from TextNode start: 0, length: 1, rect: [8,0 11.796875x18] baseline: 13.796875
@@ -9,7 +9,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] children: not-
99

1010
ViewportPaintable (Viewport<#document>) [0,0 800x600]
1111
PaintableWithLines (BlockContainer<HTML>) [0,0 800x18]
12-
PaintableWithLines (InlineNode<BODY>) [0,0 23.59375x18]
12+
PaintableWithLines (InlineNode<BODY>) [8,0 11.796875x18]
1313
PaintableWithLines (BlockContainer<DIV>) [8,0 11.796875x18]
1414
TextPaintable (TextNode<#text>)
1515

Tests/LibWeb/Layout/expected/inline-fragment-ordering-flakiness.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] children: not-inline
22
BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 18 0+0+0] [BFC] children: inline
3-
InlineNode <body> at [0,0] [8+0+0 73.6875 0+0+8] [8+0+0 18 0+0+8]
3+
InlineNode <body> at [8,0] [8+0+0 36.84375 0+0+8] [8+0+0 18 0+0+8]
44
frag 0 from BlockContainer start: 0, length: 0, rect: [8,0 36.84375x18] baseline: 13.796875
55
BlockContainer <main> at [8,0] inline-block [0+0+0 36.84375 0+0+0] [0+0+0 18 0+0+0] [BFC] children: not-inline
66
BlockContainer <div> at [8,0] [0+0+0 36.84375 0+0+0] [0+0+0 18 0+0+0] children: inline
@@ -11,7 +11,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] children: not-
1111

1212
ViewportPaintable (Viewport<#document>) [0,0 800x600]
1313
PaintableWithLines (BlockContainer<HTML>) [0,0 800x18]
14-
PaintableWithLines (InlineNode<BODY>) [0,0 73.6875x18]
14+
PaintableWithLines (InlineNode<BODY>) [8,0 36.84375x18]
1515
PaintableWithLines (BlockContainer<MAIN>) [8,0 36.84375x18]
1616
PaintableWithLines (BlockContainer<DIV>) [8,0 36.84375x18]
1717
TextPaintable (TextNode<#text>)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<style>
3+
body>span {
4+
background-color: red;
5+
}
6+
7+
div {
8+
display: inline-block
9+
}
10+
</style>
11+
12+
<body>
13+
<span style="background-color: red;">
14+
<div>AAAAAAAAAAAAA</div>
15+
</span>
16+
<span style="background-color: green;">
17+
<div>BBBBB</div>
18+
</span>
19+
20+
</body>

0 commit comments

Comments
 (0)