Skip to content

Commit 2302481

Browse files
committed
[line-clamp][IFC] Line with 0px constrain should still be considered as a non-empty line if it has content
https://bugs.webkit.org/show_bug.cgi?id=248882 Reviewed by Antti Koivisto. Just because lineLogicalRect is empty (width: 0px;) it does not necessarily mean it has no (overflowing) content. * LayoutTests/fast/block/zero-width-block-with-line-clamp-multiple-lines-expected.html: Added. * LayoutTests/fast/block/zero-width-block-with-line-clamp-multiple-lines.html: Added. * Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp: (WebCore::Layout::InlineFormattingContext::lineLayout): Canonical link: https://commits.webkit.org/257528@main
1 parent fc8aae2 commit 2302481

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<style>
2+
.ellipsis {
3+
overflow: hidden;
4+
text-overflow: ellipsis;
5+
width: 30px;
6+
}
7+
</style>
8+
<div class=ellipsis>PASS</div>
9+
<div style="width: 0px">if only the first line has ellipsis</div>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<style>
2+
div {
3+
display: -webkit-box;
4+
-webkit-line-clamp: 1;
5+
-webkit-box-orient: vertical;
6+
width: 0px;
7+
}
8+
</style>
9+
<div>PASS if only the first line has ellipsis</div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void InlineFormattingContext::lineLayout(InlineItems& inlineItems, const LineBui
266266
break;
267267
}
268268

269-
if (!lineContent.runs.isEmpty() && !lineLogicalRect.isEmpty())
269+
if (!lineContent.runs.isEmpty() && lineContent.contentLogicalWidth)
270270
++numberOfLines;
271271
lineLogicalTop = formattingGeometry().logicalTopForNextLine(lineContent, lineLogicalRect, floatingContext);
272272
previousLine = LineBuilder::PreviousLine { !lineContent.runs.isEmpty() && lineContent.runs.last().isLineBreak(), lineContent.inlineBaseDirection, lineContent.partialOverflowingContent, WTFMove(lineContent.overflowingFloats), lineContent.trailingOverflowingContentWidth };

0 commit comments

Comments
 (0)