Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5530f57c35814c7581824480a4ca3c0b246e40fd
https://github.com/WebKit/WebKit/commit/5530f57c35814c7581824480a4ca3c0b246e40fd
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/InlineLineBuilder.cpp
M
Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.cpp
M Source/WebCore/rendering/LineClampUpdater.h
M Source/WebCore/rendering/RenderBlockFlow.cpp
Log Message:
-----------
[line-clamp] Count the lines of nested blocks towards max-lines
https://bugs.webkit.org/show_bug.cgi?id=325435
<rdar://problem/188535368>
Reviewed by Antti Koivisto.
<div style="line-clamp: 4">
<div>Line 1</div>
<div><div>Line 2</div><div>Line 3</div></div>
<div>Line 4</div>
<div>Line 5</div>
</div>
Line 4 should get the ellipsis and Line 5 should not show. Each block takes its
lines off the line-clamp budget
when its layout finishes, but a block with block children put the budget back
to what it was before its layout,
so Line 2 and Line 3 were forgotten. Now the budget keeps what nested blocks
used, independent formatting contexts
give it back untouched (their lines do not count), and a block inside an inline
box (block-in-inline) tells the
surrounding inline layout how many lines it used. That inline layout also tells
the block ellipsis take-back
whether anything but whitespace follows the block-in-inline.
https://drafts.csswg.org/css-overflow-4/#max-lines
* LayoutTests/TestExpectations: line-clamp-007, -030, -038,
line-clamp-with-abspos-010 and line-clamp-with-fixed-pos-010 pass now.
* Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::lineLayout): Also record whether the
content fits when coming back from a block that took the clamp point.
* Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::layoutInlineContent):
*
Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.cpp:
(WebCore::LayoutIntegration::remainingLinesForLineClamp):
(WebCore::LayoutIntegration::updateRenderTreeLineClampBeforeLayout): Start from
the budget the inline layout started with, not the one an earlier nested block
lowered.
(WebCore::LayoutIntegration::updateIFCLineClampAfterLayout): Count what the
nested block took off its budget, including the lines of its own nested blocks.
(WebCore::LayoutIntegration::layoutWithFormattingContextForBlockInInline):
* Source/WebCore/rendering/LineClampUpdater.h:
(WebCore::LineClampUpdater::~LineClampUpdater): Independent formatting contexts
give the budget back, block children's lines stay taken.
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::contentFitsWithinMaximumLines): Inside inline content, ask the inline
layout instead of looking at siblings.
Canonical link: https://commits.webkit.org/322521@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications