From dcdf651a033aea1c95b253e442a0d7b2f0206084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Fern=C3=A1ndez=20Garc=C3=ADa-Boente?= Date: Mon, 14 Sep 2020 16:23:17 -0700 Subject: [PATCH] New TextBreakIterator's default behavior breaks after space run Before this change, we were considering breaking opportunities before space runs. This approach allowed us to avoid re-shaping in many cases, which has an important advantage in terms of performance. However, the Unicode spec (UAX#14) state that breaking before a space character is not allowed [1], so we had to implement this logic after our TextBreakIterator had already determined the best breaking opportunity. This approach has been working fine so far for regular spaces (white-space, tabs, ...), but it doesn't work correctly for other BA [2] class characters; in the CSS Text specification, these are known as "other space separators" [3]. In order to implement the correct behavior for any kind of space, we would need to change our TextBreakIterator implementation so that matches the Unicode rules, considering breaking opportunity after space runs. This change should also consider the performance impact of the extra re-shaping operations required to deal with trailing spaces. In order to prevent performance regressions, we'll store the position of the 'end of non-hangable run', which will be used in case of items with styles dictating rules to collapse trailing spaces. [1] https://unicode-org.atlassian.net/browse/ICU-20843 [2] https://www.unicode.org/reports/tr14/tr14-39.html#BA [3] https://drafts.csswg.org/css-text-3/#other-space-separators Change-Id: Ie4a3890c75a3faff1a0155d4a40bcaa85bc6ac06 --- ...pace-pre-wrap-trailing-spaces-013-ref.html | 13 +++++++ ...white-space-wrap-after-nowrap-001-ref.html | 2 -- ...te-space-pre-wrap-trailing-spaces-012.html | 35 +++++++++++++++++++ ...te-space-pre-wrap-trailing-spaces-013.html | 24 +++++++++++++ ...te-space-pre-wrap-trailing-spaces-014.html | 35 +++++++++++++++++++ ...te-space-pre-wrap-trailing-spaces-015.html | 35 +++++++++++++++++++ .../white-space-wrap-after-nowrap-001.html | 2 -- 7 files changed, 142 insertions(+), 4 deletions(-) create mode 100644 css/css-text/white-space/reference/white-space-pre-wrap-trailing-spaces-013-ref.html create mode 100644 css/css-text/white-space/white-space-pre-wrap-trailing-spaces-012.html create mode 100644 css/css-text/white-space/white-space-pre-wrap-trailing-spaces-013.html create mode 100644 css/css-text/white-space/white-space-pre-wrap-trailing-spaces-014.html create mode 100644 css/css-text/white-space/white-space-pre-wrap-trailing-spaces-015.html diff --git a/css/css-text/white-space/reference/white-space-pre-wrap-trailing-spaces-013-ref.html b/css/css-text/white-space/reference/white-space-pre-wrap-trailing-spaces-013-ref.html new file mode 100644 index 000000000000000..af1f6bf268b7cd0 --- /dev/null +++ b/css/css-text/white-space/reference/white-space-pre-wrap-trailing-spaces-013-ref.html @@ -0,0 +1,13 @@ + + + +CSS test Reference + + + +

This test passes if the line is after the white space, which hangs (blue). + +

ああ
X
diff --git a/css/css-text/white-space/reference/white-space-wrap-after-nowrap-001-ref.html b/css/css-text/white-space/reference/white-space-wrap-after-nowrap-001-ref.html index 80b2260cbbe6122..71e1c82465cb835 100644 --- a/css/css-text/white-space/reference/white-space-wrap-after-nowrap-001-ref.html +++ b/css/css-text/white-space/reference/white-space-wrap-after-nowrap-001-ref.html @@ -24,7 +24,5 @@


-

-

diff --git a/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-012.html b/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-012.html new file mode 100644 index 000000000000000..7f7b7070e0e5ab8 --- /dev/null +++ b/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-012.html @@ -0,0 +1,35 @@ + + +CSS Text test: hanging trailing spaces with white-space:pre-wrap + + + + + + + + + + + +

This test passes if there is a green square and no red. +

XXXXX
XXXXX
XXXXX
XXXXX
XXXXX
+
XX X XXX XXXXX
XXXXX
XXXXX
+ diff --git a/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-013.html b/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-013.html new file mode 100644 index 000000000000000..40f1498701cfa21 --- /dev/null +++ b/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-013.html @@ -0,0 +1,24 @@ + + + +CSS Text test: hanging trailing spaces with white-space:pre-wrap + + + + + + + + + + +

This test passes if the line is after the white space, which hangs (blue). + +

ああ X
+ diff --git a/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-014.html b/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-014.html new file mode 100644 index 000000000000000..757e31e32063043 --- /dev/null +++ b/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-014.html @@ -0,0 +1,35 @@ + + +CSS Text test: hanging trailing spaces with white-space:pre-wrap + + + + + + + + + + + +

This test passes if there is a green square and no red. +

XXXXX
XXXXX
XXXXX
XXXXX
XXXXX
+
XX X XXX XXXXX
XXXXX
XXXXX
+ diff --git a/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-015.html b/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-015.html new file mode 100644 index 000000000000000..ea74160b3c38d79 --- /dev/null +++ b/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-015.html @@ -0,0 +1,35 @@ + + +CSS Text test: hanging trailing spaces with white-space:pre-wrap + + + + + + + + + + + +

This test passes if there is a green square and no red. +

XXXXX
XXXXX
XXXXX
XXXXX
XXXXX
+
XX XXX X
XXXXX
XXXXX
XXXXX
+ diff --git a/css/css-text/white-space/white-space-wrap-after-nowrap-001.html b/css/css-text/white-space/white-space-wrap-after-nowrap-001.html index a484f1cf9167e46..5947c289e8752c2 100644 --- a/css/css-text/white-space/white-space-wrap-after-nowrap-001.html +++ b/css/css-text/white-space/white-space-wrap-after-nowrap-001.html @@ -35,7 +35,5 @@
-
-