Skip to content

Commit feedd64

Browse files
committed
-webkit-line-clamp doesn't support inline-block children
https://bugs.webkit.org/show_bug.cgi?id=301944 <rdar://problem/164488778> Reviewed by Antti Koivisto. Let's not propagate legacy line-clamp to inline-block containers. While propagation should happen across block level containers, inline blocks are quite different as they already participate in the parent inline layout (they themselves sit on lines) and the lines they produce are visually detached from the line-clamp flow. e.g. <div line-clamp: 2> text before <div style="display: inline-block>first<br>second<br>thrid</div> text after </div> first second text before third text after (should not clamp after "second") This also aligns with Chrome's behavior. Test: fast/flexbox/legacy-line-clamp-on-display-block.html * LayoutTests/fast/flexbox/legacy-line-clamp-on-display-block-expected.html: Added. * LayoutTests/fast/flexbox/legacy-line-clamp-on-display-block.html: Added. * LayoutTests/fast/overflow/line-clamp-on-last-formatted-line-expected.html: * LayoutTests/fast/overflow/line-clamp-on-last-formatted-line.html: * Source/WebCore/rendering/LineClampUpdater.h: (WebCore::LineClampUpdater::LineClampUpdater): Canonical link: https://commits.webkit.org/304956@main
1 parent 2526a45 commit feedd64

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<style>
2+
.container {
3+
display: -webkit-box;
4+
-webkit-box-orient: vertical;
5+
}
6+
7+
.inline_block {
8+
display: inline-block;
9+
background-color: green;
10+
}
11+
</style>
12+
<div class=container>
13+
<div class=inline_block>PASS<br>if<br>line-clamp<br>is<br>not<br>applied<br>here</div>
14+
<div>but<br>only here&hellip;
15+
</div>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<meta name="fuzzy" content="maxDifference=0-2; totalPixels=0" />
2+
<style>
3+
.container {
4+
display: -webkit-box;
5+
-webkit-box-orient: vertical;
6+
-webkit-line-clamp: 3;
7+
overflow: hidden;
8+
}
9+
10+
.inline_block {
11+
display: inline-block;
12+
background-color: green;
13+
}
14+
</style>
15+
<div class=container>
16+
<div class=inline_block>PASS<br>if<br>line-clamp<br>is<br>not<br>applied<br>here</div>
17+
<div>but<br>only here<br>and some clipped content here.
18+
</div>

LayoutTests/fast/overflow/line-clamp-on-last-formatted-line-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div>PASS if trailing ellipsis does NOT show</div>
99
<div>PASS if trailing ellipsis shows&#x2026;</div>
1010
<div>PASS if trailing ellipsis shows&#x2026;</div>
11-
<div>PASS if trailing ellipsis shows&#x2026;</div>
11+
<div>PASS if trailing ellipsis shows (but it's scrolled off)</div>
1212
<div>PASS if trailing ellipsis shows&#x2026;</div>
1313
<div>PASS if trailing ellipsis shows&#x2026;</div>
1414
<div>PASS if trailing ellipsis shows&#x2026;</div>

LayoutTests/fast/overflow/line-clamp-on-last-formatted-line.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</div>
2525

2626
<div class="clamp">
27-
<div><div><div style="display: inline-block; width: 1000px;">PASS if trailing ellipsis shows</div></div></div>
27+
<div><div><div style="display: inline-block; width: 10000px;">PASS if trailing ellipsis shows (but it's scrolled off)</div></div></div>
2828
<div>second line</div>
2929
</div>
3030

Source/WebCore/rendering/LineClampUpdater.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ inline LineClampUpdater::LineClampUpdater(const RenderBlockFlow& blockContainer)
5050
return;
5151

5252
m_previousLineClamp = layoutState->lineClamp();
53-
if (blockContainer.isFieldset()) {
53+
if (blockContainer.isFieldset() || blockContainer.style().display() == DisplayType::InlineBlock) {
5454
layoutState->setLineClamp({ });
5555

5656
m_skippedLegacyLineClampToRestore = layoutState->legacyLineClamp();

0 commit comments

Comments
 (0)