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

  Changed paths:
    M LayoutTests/TestExpectations
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-overflow/line-clamp/line-clamp-dynamic-removal-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-overflow/line-clamp/line-clamp-dynamic-removal.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-overflow/line-clamp/reference/line-clamp-dynamic-removal-ref.html
    M 
Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBoxInlines.h
    M Source/WebCore/rendering/LineClampUpdater.cpp
    M Source/WebCore/rendering/LineClampUpdater.h
    M Source/WebCore/rendering/RenderBlockFlow.cpp

  Log Message:
  -----------
  [line-clamp] Block boxes after the clamp point are still visible
https://bugs.webkit.org/show_bug.cgi?id=326848
<rdar://problem/189543433>

Reviewed by Antti Koivisto.

<div style="line-clamp: 2"><div>Line 1<br>Line 2<br>Line 3</div><div 
style="background-color: red">Line 4</div></div>

Line 3 is gone, but the red box after the clamp point (and its "Line 4") still 
paints.
"Within a line-clamp container, the following boxes and line boxes become 
invisible boxes: Any in-flow or floating boxes
that follow the clamp point in the box tree."
https://drafts.csswg.org/css-overflow-4/#line-clamp-containers

Now block layout marks each in-flow child that comes after the clamp point (the 
line-clamp budget is used up), and every
renderer in it, hidden by line-clamp, which makes their used visibility hidden. 
This happens before the child's own
layout and only when the child changes between visible and hidden, so the 
subtree is walked once per change, and a box
that stops being a line-clamp container shows its content again. An out-of-flow 
box in it is only hidden when its
containing block is in it too ("Any absolutely positioned box which has an 
invisible box within its containing block
chain, and all of its descendants."). Inline display boxes now take their
visibility from the used style of their renderer, so text and inline boxes 
inside such a block are hidden too.
These boxes still take up space; that is a separate change.

Tests: 
imported/w3c/web-platform-tests/css/css-overflow/line-clamp/line-clamp-dynamic-removal.html
       
imported/w3c/web-platform-tests/css/css-overflow/line-clamp/reference/line-clamp-dynamic-removal-ref.html

* LayoutTests/TestExpectations: 18 tests pass now.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-overflow/line-clamp/line-clamp-dynamic-removal-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-overflow/line-clamp/line-clamp-dynamic-removal.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-overflow/line-clamp/reference/line-clamp-dynamic-removal-ref.html:
 Added.
* 
Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBoxInlines.h:
(WebCore::InlineDisplay::Box::isVisible const):
* Source/WebCore/rendering/LineClampUpdater.cpp:
(WebCore::LineClampUpdater::isAfterClampPoint):
(WebCore::LineClampUpdater::setIsForcedHidden):
* Source/WebCore/rendering/LineClampUpdater.h:
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):

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



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

Reply via email to