Skip to content

Commit

Permalink
Treat -webkit-line-clamp boxes as monolithic.
Browse files Browse the repository at this point in the history
It seems pointless to let them fragment, and our implementation didn't
behave when they fragmented anyway. Apart from counting lines
incorrectly in resumed fragments, we also had a stack overflow issue,
due to RelayoutIgnoringLineClamp() and RelayoutAndBreakEarlier()
invoking each other indefinitely.

RelayoutIgnoringLineClamp() would kick in if the number of lines was
equal to the -webkit-line-clamp value, regardless of whether there'd be
more lines to come in the next fragmentainer. When going back to
re-layout after having determined the orphans/widows requirements
(RelayoutAndBreakEarlier()) and set an early-break, this could trigger
RelayoutIgnoringLineClamp(), which would restart orphans/widows
calculation, since the early-break wasn't carried over (this could be
fixed, but it seems rather meaningless).

Making such boxes monolithic will disable fragmentation inside, so that
the two re-layout mechanisms never meet and therefore never get an
opportunity to start fighting each other. We used to crash when printing
youtube.com.

Bug: 1372637
Change-Id: I3c3a072d9d5025205e6d3600738329df8d3da0f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3948644
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1058563}
  • Loading branch information
mstensho authored and pull[bot] committed Jul 14, 2023
1 parent 2b20595 commit dc2709f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
8 changes: 8 additions & 0 deletions css/css-overflow/webkit-line-clamp-041-crash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1372637">
<div style="columns:2; column-fill:auto; line-height:20px; height:40px; orphans:2; widows:2;">
<div style="-webkit-line-clamp:2; display:-webkit-box; -webkit-box-orient:vertical;">
<br><br><br>
</div>
</div>
13 changes: 13 additions & 0 deletions css/css-overflow/webkit-line-clamp-042-crash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1372637">
<div style="columns:3; column-fill:auto; height:100px;">
<div style="display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:3; line-height:20px;">
Line 1<br>
Line 2<br>
Line 3<br>
Line 4<br>
Line 5<br>
</div>
<div style="break-before:avoid; break-inside:avoid; height:50px;"></div>
</div>
23 changes: 23 additions & 0 deletions css/css-overflow/webkit-line-clamp-043.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-overflow-3/#webkit-line-clamp">
<link rel="match" href="../reference/ref-filled-green-100px-square.xht">
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div style="columns:3; column-fill:auto; gap:0; width:300px; height:250px;">
<div style="display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:clip; line-height:50px; color:transparent; background:green;">
<br>
<br>
<span style="color:red;">
FAIL<br>
FAIL<br>
FAIL<br>
FAIL<br>
FAIL<br>
FAIL<br>
FAIL<br>
FAIL<br>
FAIL<br>
FAIL<br>
</span>
</div>
</div>

0 comments on commit dc2709f

Please sign in to comment.