-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fully implement bidi for a line's trailing spaces (UAX#9 L1)
Per UAX#9 L1, any spaces that after line breaking would fall logically at the end of a line must be reset to the paragraph's initial embedding level, regardless of the embedding level of those spaces in the paragraph. Until now, Blink only had partial support for this. The reason this was hard to implement in Blink is because the direction of text is computed in a per-paragraph level, splitting the text into items with a given direction and embedding level. Those items are then split into item results when line breaking, but item results must have the same direction as the item. As part of line breaking, some item results are produced which only have trailing spaces. The partial support, implemented in crrev.com/c/2505486, consisted of marking these results with the `has_only_trailing_spaces` flag, and using this flag to distinguish them when reordering the item results. This patch builds on top of that partial fix by adding a final processing step to line breaking, which splits item results so that trailing spaces (with a different embedding level as the paragraph) are split into its own item result, and by marking all trailing spaces item results as `has_only_trailing_spaces`. This also fixes bug 1514753, where having a item result with non-base direction which had logically trailing spaces was causing the text (rather than the spaces) to hang, because `LineInfo::ComputeTrailingSpaceWidth` assumed that UAX#9 L1 held. This patch also modifies some existing WPT tests to make them use a monospace Arabic webfont (since it's not guaranteed that all OS's have one), and by changing the widths slightly to work around bug 1409445. Bug: 316409, 1514753 Change-Id: I1eb751b457d413b5099dad8f95badba9a1b3e5fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5199988 Reviewed-by: Koji Ishii <[email protected]> Commit-Queue: Andreu Botella <[email protected]> Cr-Commit-Position: refs/heads/main@{#1257309}
- Loading branch information
1 parent
aee2a77
commit c635cb4
Showing
10 changed files
with
217 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>CSS Text 3 test: trailing collapsible spaces and bidi</title> | ||
<link rel="author" title="Andreu Botella" href="mailto:[email protected]"> | ||
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-pre-wrap"> | ||
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2"> | ||
<link rel="match" href="reference/eol-spaces-bidi-004-ref.html"> | ||
<link rel="match" href="reference/eol-spaces-bidi-alt-004-ref.html"> | ||
<meta name="assert" content="Hanging space should take paragraph direction and show at the end of the line (blue box to the left)"> | ||
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> | ||
|
||
<style> | ||
div#test { | ||
direction: rtl; | ||
text-align: left; | ||
|
||
font: 20px/1 Ahem; | ||
margin-left: 20px; | ||
background: green; | ||
color: red; | ||
|
||
width: 4ch; | ||
white-space: pre-wrap; | ||
} | ||
span { | ||
background: blue; | ||
} | ||
#green-cover { | ||
position: absolute; | ||
margin-left: 20px; | ||
width: 60px; | ||
height: 40px; | ||
background: | ||
linear-gradient(green, green) 0 0 / 60px 20px no-repeat, | ||
linear-gradient(green, green) 0 20px / 20px 20px no-repeat; | ||
z-index: 1; | ||
} | ||
</style> | ||
<p>Test passes if a blue box (the white space) is visible at the left start in first line and <strong>no red</strong> is shown.</p> | ||
<div id="green-cover"></div> | ||
<div id="test"><span>XXX </span>X</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
css/css-text/white-space/reference/eol-spaces-bidi-004-ref.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>CSS Text 3 test reference</title> | ||
<link rel="author" title="Andreu Botella" href="mailto:[email protected]"> | ||
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> | ||
|
||
<style> | ||
div#test { | ||
text-align: right; | ||
|
||
font: 20px/1 Ahem; | ||
background: linear-gradient(green, green) 1ch 0 / cover no-repeat; | ||
|
||
width: 5ch; | ||
white-space: pre; | ||
|
||
color: blue; | ||
} | ||
</style> | ||
<p>Test passes if a blue box (the white space) is visible at the left start in first line and <strong>no red</strong> is shown.</p> | ||
<div id="test">X <br> </div> |
18 changes: 18 additions & 0 deletions
18
css/css-text/white-space/reference/eol-spaces-bidi-alt-004-ref.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>CSS Text 3 test reference</title> | ||
<link rel="author" title="Andreu Botella" href="mailto:[email protected]"> | ||
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> | ||
|
||
<style> | ||
div#test { | ||
font: 20px/1 Ahem; | ||
margin-left: 20px; | ||
background: green; | ||
|
||
width: 4ch; | ||
white-space: pre; | ||
} | ||
</style> | ||
<p>Test passes if a blue box (the white space) is visible at the left start in first line and <strong>no red</strong> is shown.</p> | ||
<div id="test"> <br> </div> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
This Font Software is licensed under the SIL Open Font License, | ||
Version 1.1. | ||
|
||
This license is copied below, and is also available with a FAQ at: | ||
http://scripts.sil.org/OFL | ||
|
||
----------------------------------------------------------- | ||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 | ||
----------------------------------------------------------- | ||
|
||
PREAMBLE | ||
The goals of the Open Font License (OFL) are to stimulate worldwide | ||
development of collaborative font projects, to support the font | ||
creation efforts of academic and linguistic communities, and to | ||
provide a free and open framework in which fonts may be shared and | ||
improved in partnership with others. | ||
|
||
The OFL allows the licensed fonts to be used, studied, modified and | ||
redistributed freely as long as they are not sold by themselves. The | ||
fonts, including any derivative works, can be bundled, embedded, | ||
redistributed and/or sold with any software provided that any reserved | ||
names are not used by derivative works. The fonts and derivatives, | ||
however, cannot be released under any other type of license. The | ||
requirement for fonts to remain under this license does not apply to | ||
any document created using the fonts or their derivatives. | ||
|
||
DEFINITIONS | ||
"Font Software" refers to the set of files released by the Copyright | ||
Holder(s) under this license and clearly marked as such. This may | ||
include source files, build scripts and documentation. | ||
|
||
"Reserved Font Name" refers to any names specified as such after the | ||
copyright statement(s). | ||
|
||
"Original Version" refers to the collection of Font Software | ||
components as distributed by the Copyright Holder(s). | ||
|
||
"Modified Version" refers to any derivative made by adding to, | ||
deleting, or substituting -- in part or in whole -- any of the | ||
components of the Original Version, by changing formats or by porting | ||
the Font Software to a new environment. | ||
|
||
"Author" refers to any designer, engineer, programmer, technical | ||
writer or other person who contributed to the Font Software. | ||
|
||
PERMISSION & CONDITIONS | ||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of the Font Software, to use, study, copy, merge, embed, | ||
modify, redistribute, and sell modified and unmodified copies of the | ||
Font Software, subject to the following conditions: | ||
|
||
1) Neither the Font Software nor any of its individual components, in | ||
Original or Modified Versions, may be sold by itself. | ||
|
||
2) Original or Modified Versions of the Font Software may be bundled, | ||
redistributed and/or sold with any software, provided that each copy | ||
contains the above copyright notice and this license. These can be | ||
included either as stand-alone text files, human-readable headers or | ||
in the appropriate machine-readable metadata fields within text or | ||
binary files as long as those fields can be easily viewed by the user. | ||
|
||
3) No Modified Version of the Font Software may use the Reserved Font | ||
Name(s) unless explicit written permission is granted by the | ||
corresponding Copyright Holder. This restriction only applies to the | ||
primary font name as presented to the users. | ||
|
||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font | ||
Software shall not be used to promote, endorse or advertise any | ||
Modified Version, except to acknowledge the contribution(s) of the | ||
Copyright Holder(s) and the Author(s) or with their explicit written | ||
permission. | ||
|
||
5) The Font Software, modified or unmodified, in part or in whole, | ||
must be distributed entirely under this license, and must not be | ||
distributed under any other license. The requirement for fonts to | ||
remain under this license does not apply to any document created using | ||
the Font Software. | ||
|
||
TERMINATION | ||
This license becomes null and void if any of the above conditions are | ||
not met. | ||
|
||
DISCLAIMER | ||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT | ||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE | ||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL | ||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM | ||
OTHER DEALINGS IN THE FONT SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This font is a monospace Arabic font, which helps test the interaction of bidi | ||
with line breaking, among other features. | ||
|
||
Some operating systems already ship with a monospace Arabic font by default, but | ||
not all do, so it is better to use a webfont. | ||
|
||
This font was obtained from https://github.com/eliheuer/hasubi-mono. |