Skip to content

Commit 2062ed7

Browse files
committed
WebKit handles text layout inconsistently depending on list-style-type
https://bugs.webkit.org/show_bug.cgi?id=302099 <rdar://problem/164650313> Reviewed by Antti Koivisto. Outside list markers should not contribute to the min/max width (they are not even supposed to be here in IFC.) Test: fast/lists/list-marker-outside-inside-flex-item.html * LayoutTests/fast/lists/list-marker-outside-inside-flex-item-expected.html: Added. * LayoutTests/fast/lists/list-marker-outside-inside-flex-item.html: Added. * Source/WebCore/layout/formattingContexts/inline/IntrinsicWidthHandler.cpp: (WebCore::Layout::IntrinsicWidthHandler::computedIntrinsicWidthForConstraint): Canonical link: https://commits.webkit.org/304947@main
1 parent c7a581a commit 2062ed7

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<style>
2+
.flexBox {
3+
font-family: Ahem;
4+
font-size: 20px;
5+
outline: 1px solid green;
6+
width: 20px;
7+
}
8+
</style>
9+
<ul>
10+
<li>
11+
<div class=flexBox>X</div>
12+
</li>
13+
</ul>
14+
15+
<ul>
16+
<li>
17+
<div class=flexBox style="margin-left: 8px">X</div>
18+
</li>
19+
</ul>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<style>
2+
.flexBox {
3+
display: flex;
4+
justify-content: center;
5+
6+
font-family: Ahem;
7+
font-size: 20px;
8+
outline: 1px solid green;
9+
width: 20px;
10+
}
11+
</style>
12+
<!-- PASS if black box is enclosed by green outline -->
13+
<ul>
14+
<li>
15+
<div class=flexBox>X</div>
16+
</li>
17+
</ul>
18+
19+
<ul>
20+
<li>
21+
<div class=flexBox style="margin-left: 8px">X</div>
22+
</li>
23+
</ul>

Source/WebCore/layout/formattingContexts/inline/IntrinsicWidthHandler.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,15 @@ InlineLayoutUnit IntrinsicWidthHandler::computedIntrinsicWidthForConstraint(Intr
202202
return InlineLayoutUnit { leftWidth + rightWidth };
203203
};
204204

205-
auto lineContentLogicalWidth = lineLayoutResult.lineGeometry.logicalTopLeft.x() + lineLayoutResult.contentGeometry.logicalWidth + floatContentWidth();
205+
auto lineContentLogicalWidth = [&] {
206+
auto contentWidth = lineLayoutResult.lineGeometry.logicalTopLeft.x() + lineLayoutResult.contentGeometry.logicalWidth + floatContentWidth();
207+
if (lineLayoutResult.runs.isEmpty())
208+
return contentWidth;
209+
auto& leadingRun = lineLayoutResult.runs.first();
210+
if (leadingRun.isListMarkerOutside())
211+
contentWidth -= leadingRun.logicalRight();
212+
return contentWidth;
213+
}();
206214
maximumContentWidth = std::max(maximumContentWidth, lineContentLogicalWidth);
207215
contentWidthBetweenLineBreaks.current += (lineContentLogicalWidth + lineLayoutResult.hangingContent.logicalWidth);
208216
if (lineLayoutResult.endsWithLineBreak())

0 commit comments

Comments
 (0)