Skip to content

Commit

Permalink
[line-clamp] [RubyLB] Make sure ruby isn't visible in clamped lines
Browse files Browse the repository at this point in the history
With RubyLB, in some cases ruby annotations would not be hidden even
though the line containing them would be. This is because when a line
is after the clamp point, the line box and its logical line items
would be marked as hidden for paint, but in RubyLB the line's ruby
annotations and their line items are stored in the logical ruby
columns.

This patch fixes this in `FragmentItemsBuilder::AddLine`, when
`FragmentItem`s are created for a line's multiple annotations, by
marking every item in the annotations as hidden for paint if the
line's fragment is marked as such.

Aside from adding a test for this issue, this patch also adds a test
that the sizing of a clamped block box properly takes into account any
ruby annotations that add leading to a line. This already worked as
expected, presumably due to https://crrev.com/c/5683304 storing the
`PreviousInflowPosition` at the clamp point, but the effect on ruby
had not been tested in that CL.

Bug: 40336192
Change-Id: I95fe796bb887d1d205dd43c2644095b6c6f225e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5695646
Reviewed-by: Kent Tamura <tkent@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Andreu Botella <abotella@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1326551}
  • Loading branch information
andreubotella authored and chromium-wpt-export-bot committed Jul 12, 2024
1 parent ce8be75 commit 56eea69
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
24 changes: 24 additions & 0 deletions css/css-overflow/line-clamp/line-clamp-026.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Overflow: ruby annotations after the clamp point are not rendered</title>
<link rel="author" title="Andreu Botella" href="mailto:abotella@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-overflow-4/#line-clamp">
<link rel="match" href="reference/line-clamp-026-ref.html">
<meta name="assert" content="Ruby annotations are part of a line box's content, and therefore must not be rendered if the line box wouldn't be">
<style>
.clamp {
line-clamp: 3;

font: 16px / 32px serif;
white-space: pre-wrap;
}
.ruby-under ruby {
ruby-position: under;
}
</style>
<div class="clamp"><ruby><rt>いち</ruby><ruby><rt>ぎょう</ruby><ruby><rt></ruby>
<span class="ruby-under"><ruby><rt></ruby><ruby><rt>ぎょう</ruby><ruby><rt></ruby></span>
<ruby><rt><ruby>さん<rt>san</ruby></ruby><ruby><rt><ruby>ぎょう<rt>gyou</ruby></ruby><ruby><rt><ruby><rt>me</ruby></ruby>
<ruby><rt>よん</ruby><ruby><rt>ぎょう</ruby><ruby><rt></ruby>
<span class="ruby-under"><ruby><rt></ruby><ruby><rt>ぎょう</ruby><ruby><rt></ruby></span>
<ruby><rt><ruby>ろく<rt>roku</ruby></ruby><ruby><rt><ruby>ぎょう<rt>gyou</ruby></ruby><ruby><rt><ruby><rt>me</ruby></ruby></div>
27 changes: 27 additions & 0 deletions css/css-overflow/line-clamp/line-clamp-027.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Overflow: sizing of line-clamp elements with ruby annotations</title>
<link rel="author" title="Andreu Botella" href="mailto:abotella@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-overflow-4/#line-clamp">
<link rel="match" href="reference/line-clamp-027-ref.html">
<meta name="assert" content="The sizing of a line-clamp element should be exactly as if it had no content after clamp, even if there are ruby annotations involved.">
<style>
.clamp {
line-clamp: 3;
font-size: 16px / 16px serif;
white-space: pre-wrap;
background-color: yellow;
}
ruby.under {
ruby-position: under;
}
.large {
font-size: 3em;
}
</style>
<div class="clamp">Line 1
Line 2
<ruby class="under">Line 3<rt>ruby</ruby>
<ruby>Line 4<rt class="large">ruby</ruby>
Line 5
<ruby class="under">Line 6<rt class="large">ruby</ruby></div>
15 changes: 15 additions & 0 deletions css/css-overflow/line-clamp/reference/line-clamp-026-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Reference</title>
<style>
.clamp {
font: 16px / 32px serif;
white-space: pre-wrap;
}
.ruby-under ruby {
ruby-position: under;
}
</style>
<div class="clamp"><ruby><rt>いち</ruby><ruby><rt>ぎょう</ruby><ruby><rt></ruby>
<span class="ruby-under"><ruby><rt></ruby><ruby><rt>ぎょう</ruby><ruby><rt></ruby></span>
<ruby><rt><ruby>さん<rt>san</ruby></ruby><ruby><rt><ruby>ぎょう<rt>gyou</ruby></ruby><ruby><rt><ruby><rt>me</ruby></ruby></div>
16 changes: 16 additions & 0 deletions css/css-overflow/line-clamp/reference/line-clamp-027-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Reference</title>
<style>
.clamp {
font-size: 16px / 16px serif;
white-space: pre-wrap;
background-color: yellow;
}
ruby.under {
ruby-position: under;
}
</style>
<div class="clamp">Line 1
Line 2
<ruby class="under">Line 3<rt>ruby</ruby></div>

0 comments on commit 56eea69

Please sign in to comment.