Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f150bb535660c9a209b262c3c44f472e26b4e3a3
https://github.com/WebKit/WebKit/commit/f150bb535660c9a209b262c3c44f472e26b4e3a3
Author: Alan Baradlay <[email protected]>
Date: 2026-10-02 (Fri, 02 Oct 2026)
Changed paths:
M LayoutTests/TestExpectations
M
Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp
M Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.h
M Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp
M Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.h
M Source/WebCore/layout/formattingContexts/inline/LineLayoutResult.h
M Source/WebCore/layout/integration/inline/LayoutIntegrationInlineContent.h
M Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp
M Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.h
M Source/WebCore/rendering/LineClampUpdater.h
M Source/WebCore/rendering/RenderBlockFlow.cpp
Log Message:
-----------
[line-clamp] Do not add the block ellipsis to the last line
https://bugs.webkit.org/show_bug.cgi?id=325391
<rdar://problem/188500712>
Reviewed by Antti Koivisto.
<div style="line-clamp: 2">first line<br>second line</div>
Both lines fit, so there is no clamp point and no ellipsis should show.
https://drafts.csswg.org/css-overflow-4/#max-lines
LineBuilder places the ellipsis on the 2nd line before it knows whether
anything comes after it.
Now it reports when nothing does (or when the ellipsis only pushed the last
word off the line),
and the line-clamp root lays out its content again without the clamp.
* LayoutTests/TestExpectations: block-ellipsis-011, block-ellipsis-029,
line-clamp-003 and line-clamp-037 pass now.
* Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::lineLayout):
* Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.h:
* Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::layoutInlineContent): The clamped line is the
last line when nothing follows it (a block-in-inline does count) or the
ellipsis only pushed the last content off.
(WebCore::Layout::LineBuilder::initialize):
(WebCore::Layout::LineBuilder::placeInlineAndFloatContent):
(WebCore::Layout::LineBuilder::handleInlineContent):
(WebCore::Layout::inlineItemIndex): Shared by processLineBreakingResult and
rebuildLineWithInlineContent; the partial leading text item maps to the range
start.
(WebCore::Layout::LineBuilder::processLineBreakingResult): On the clamped line,
check whether the content the ellipsis pushed off is the last content and would
fit without the ellipsis.
(WebCore::Layout::LineBuilder::rebuildLineWithInlineContent):
(WebCore::Layout::LineBuilder::nextContentfulInlineItem const): Look-ahead
shared with isLastLineWithInlineContent; returns the item so callers decide
what a block-in-inline means.
(WebCore::Layout::LineBuilder::isLastLineWithInlineContent const):
* Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.h:
* Source/WebCore/layout/formattingContexts/inline/LineLayoutResult.h:
* Source/WebCore/layout/integration/inline/LayoutIntegrationInlineContent.h:
(WebCore::LayoutIntegration::InlineContent::contentFitsWithinMaximumLines
const):
(WebCore::LayoutIntegration::InlineContent::setContentFitsWithinMaximumLines):
* Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::layout):
(WebCore::LayoutIntegration::LineLayout::constructContent):
* Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.h:
(WebCore::LayoutIntegration::LineLayout::contentFitsWithinMaximumLines const):
* Source/WebCore/rendering/LineClampUpdater.h:
(WebCore::LineClampUpdater::isLineClampRoot const):
(WebCore::LineClampUpdater::LineClampUpdater):
(WebCore::LineClampUpdater::resetLineClamp):
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::contentFitsWithinMaximumLines): Asks the IFC with the clamped line,
and requires no in-flow sibling (a clamp point) after it up to the root.
(WebCore::RenderBlockFlow::layoutInFlowChildren): When the content fits within
max-lines lines, the line-clamp root lays it out again without the clamp.
Canonical link: https://commits.webkit.org/322510@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications