Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 963125d1f1440dca433af8e41e3530abd975dd10
      
https://github.com/WebKit/WebKit/commit/963125d1f1440dca433af8e41e3530abd975dd10
  Author: Alan Baradlay <[email protected]>
  Date:   2026-10-12 (Mon, 12 Oct 2026)

  Changed paths:
    M LayoutTests/TestExpectations
    M Source/WebCore/layout/formattingContexts/block/BlockLayoutState.h
    M 
Source/WebCore/layout/formattingContexts/inline/InlineContentConstrainer.cpp
    M Source/WebCore/layout/formattingContexts/inline/InlineContentConstrainer.h
    M 
Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp
    M 
Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.cpp
    M Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp
    M Source/WebCore/rendering/LineClampUpdater.cpp
    M Source/WebCore/rendering/LineClampUpdater.h
    M Source/WebCore/rendering/RenderBlockFlow.cpp
    M Source/WebCore/rendering/RenderLayoutState.h

  Log Message:
  -----------
  [line-clamp] line-clamp: auto balances content before finding the clamp point
https://bugs.webkit.org/show_bug.cgi?id=327198
<rdar://problem/189774214>

Reviewed by Antti Koivisto.

<div style="line-clamp: auto; max-height: 3lh; line-height: 1; width: 9ch; 
text-wrap: balance; font-family: monospace">1 2 <span style="font-size: 
2em">3</span> <span style="font-size: 2em">4</span> 5 6 7 8 <span 
style="font-size: 2em">9</span></div>

The line-clamp container shows "1 2 3…" instead of "1 2 3 4" and "5 6 7 8…".
"When 'text-wrap-style' is set to 'balance' on a block container whose 
'continue' has a value other than 'auto', or which
participates in the block formatting context established by an element whose 
'continue' has a value other than 'auto',
layout must first be computed as if 'text-wrap-style' were set to 'stable'. 
Then, after any excess content has been truncated
and after any necessary block overflow ellipsis has been inserted, the 
remaining content must be rebalanced, as per
'text-wrap-style: balance'. If this rebalancing would cause the logical height 
of the content to grow, the cutoff point
(clamp point or fragmentation break) must be reevaluated, and any necessary 
block overflow ellipsis reapplied accordingly."
https://drafts.csswg.org/css-overflow-4/#line-clamp

The layout that finds the auto clamp point balanced the content, so the clamp 
point came from the balanced lines.

Now the line clamp of that layout (set up by LineClampUpdater for the 
line-clamp: auto container and carried over to the blocks
of its block formatting context) says to lay out inline content as if 
'text-wrap-style' were 'stable', and inline layout notes
when that changed anything. The clamped layout balances the lines before the 
clamp point as before, and when nothing gets
clamped, the content gets laid out again, balanced (and clamped if that makes 
it too tall).

* LayoutTests/TestExpectations: line-clamp-balance-003.html and 
line-clamp-balance-006.html pass now.
* Source/WebCore/layout/formattingContexts/block/BlockLayoutState.h:
* Source/WebCore/layout/formattingContexts/inline/InlineContentConstrainer.cpp:
(WebCore::Layout::InlineContentConstrainer::constrainsContent):
* Source/WebCore/layout/formattingContexts/inline/InlineContentConstrainer.h:
* Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::layout):
* 
Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.cpp:
(WebCore::LayoutIntegration::updateRenderTreeLineClampBeforeLayout):
* Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::lineClamp):
(WebCore::LayoutIntegration::LineLayout::layout):
* Source/WebCore/rendering/LineClampUpdater.cpp:
(WebCore::LineClampUpdater::LineClampUpdater):
(WebCore::LineClampUpdater::~LineClampUpdater):
(WebCore::LineClampUpdater::hasConstrainedTextWrapContent const):
(WebCore::LineClampUpdater::setIsStableTextWrap):
* Source/WebCore/rendering/LineClampUpdater.h:
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutInFlowChildren):
* Source/WebCore/rendering/RenderLayoutState.h:

Canonical link: https://commits.webkit.org/323481@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to