Title: [224015] trunk
Revision
224015
Author
[email protected]
Date
2017-10-26 05:03:29 -0700 (Thu, 26 Oct 2017)

Log Message

REGRESSION(r222090): [HarfBuzz] Arabic shaping is broken except for first word in line
https://bugs.webkit.org/show_bug.cgi?id=178625

Reviewed by Michael Catanzaro.

Source/WebCore:

Once we find the first space, which has the COMMON script, we split the run, and the next ones keep using
COMMON instead of ARABIC because we don't update the current script on every loop iteration. This patch
simplifies the script handling by moving the code back to the loop and always breaking in case of different
scripts, correctly handling INHERITED and COMMON cases and updating the current script when needed.

Covered by existing tests. This improves several tests that have been rebaselined.

* platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp:
(WebCore::findNextRun):
(WebCore::scriptsAreCompatibleForCharacters): Deleted.

LayoutTests:

Rebaseline several tests that have been improved.

* platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-br-expected.png:
* platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-br-expected.txt:
* platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-p-expected.png:
* platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-p-expected.txt:
* platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-br-expected.png:
* platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-br-expected.txt:
* platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-p-expected.png:
* platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-p-expected.txt:
* platform/gtk/fast/text/atsui-negative-spacing-features-expected.png:
* platform/gtk/fast/text/atsui-negative-spacing-features-expected.txt:
* platform/gtk/fast/text/international/hebrew-vowels-expected.png:
* platform/gtk/fast/text/international/hebrew-vowels-expected.txt:
* platform/gtk/svg/W3C-SVG-1.1/fonts-glyph-02-t-expected.png:
* platform/gtk/svg/W3C-SVG-1.1/fonts-glyph-02-t-expected.txt:
* platform/gtk/svg/custom/glyph-selection-arabic-forms-expected.png:
* platform/gtk/svg/custom/glyph-selection-arabic-forms-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (224014 => 224015)


--- trunk/LayoutTests/ChangeLog	2017-10-26 10:58:17 UTC (rev 224014)
+++ trunk/LayoutTests/ChangeLog	2017-10-26 12:03:29 UTC (rev 224015)
@@ -1,3 +1,29 @@
+2017-10-26  Carlos Garcia Campos  <[email protected]>
+
+        REGRESSION(r222090): [HarfBuzz] Arabic shaping is broken except for first word in line
+        https://bugs.webkit.org/show_bug.cgi?id=178625
+
+        Reviewed by Michael Catanzaro.
+
+        Rebaseline several tests that have been improved.
+
+        * platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-br-expected.png:
+        * platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-br-expected.txt:
+        * platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-p-expected.png:
+        * platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-p-expected.txt:
+        * platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-br-expected.png:
+        * platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-br-expected.txt:
+        * platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-p-expected.png:
+        * platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-p-expected.txt:
+        * platform/gtk/fast/text/atsui-negative-spacing-features-expected.png:
+        * platform/gtk/fast/text/atsui-negative-spacing-features-expected.txt:
+        * platform/gtk/fast/text/international/hebrew-vowels-expected.png:
+        * platform/gtk/fast/text/international/hebrew-vowels-expected.txt:
+        * platform/gtk/svg/W3C-SVG-1.1/fonts-glyph-02-t-expected.png:
+        * platform/gtk/svg/W3C-SVG-1.1/fonts-glyph-02-t-expected.txt:
+        * platform/gtk/svg/custom/glyph-selection-arabic-forms-expected.png:
+        * platform/gtk/svg/custom/glyph-selection-arabic-forms-expected.txt:
+
 2017-10-26  Ryosuke Niwa  <[email protected]>
 
         LayoutTest http/tests/security/clipboard/copy-paste-html-cross-origin-iframe-across-origin.html is a flaky failure

Modified: trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-br-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-br-expected.txt (224014 => 224015)


--- trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-br-expected.txt	2017-10-26 10:58:17 UTC (rev 224014)
+++ trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-br-expected.txt	2017-10-26 12:03:29 UTC (rev 224015)
@@ -14,5 +14,5 @@
           RenderText {#text} at (23,45) size 23x120
             text run at (23,45) width 120 RTL: "\x{5D0}\x{5D9}\x{5DF} \x{5DC}\x{5D9} \x{5E9}\x{5DD}."
       RenderBlock {PRE} at (0,212) size 784x0
-selection start: position 0 of child 1 {BR} of child 1 {P} of child 3 {DIV} of body
+selection start: position 6 of child 0 {#text} of child 1 {P} of child 3 {DIV} of body
 selection end:   position 5 of child 2 {#text} of child 1 {P} of child 3 {DIV} of body

Modified: trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-p-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-p-expected.txt (224014 => 224015)


--- trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-p-expected.txt	2017-10-26 10:58:17 UTC (rev 224014)
+++ trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-backward-p-expected.txt	2017-10-26 12:03:29 UTC (rev 224015)
@@ -14,5 +14,5 @@
           RenderText {#text} at (0,45) size 23x120
             text run at (0,45) width 120 RTL: "\x{5D0}\x{5D9}\x{5DF} \x{5DC}\x{5D9} \x{5E9}\x{5DD}."
       RenderBlock {PRE} at (0,212) size 784x0
-selection start: position 9 of child 0 {#text} of child 1 {P} of child 3 {DIV} of body
+selection start: position 6 of child 0 {#text} of child 1 {P} of child 3 {DIV} of body
 selection end:   position 5 of child 0 {#text} of child 2 {P} of child 3 {DIV} of body

Modified: trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-br-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-br-expected.txt (224014 => 224015)


--- trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-br-expected.txt	2017-10-26 10:58:17 UTC (rev 224014)
+++ trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-br-expected.txt	2017-10-26 12:03:29 UTC (rev 224015)
@@ -15,4 +15,4 @@
             text run at (23,45) width 120 RTL: "\x{5D0}\x{5D9}\x{5DF} \x{5DC}\x{5D9} \x{5E9}\x{5DD}."
       RenderBlock {PRE} at (0,212) size 784x0
 selection start: position 5 of child 0 {#text} of child 1 {P} of child 3 {DIV} of body
-selection end:   position 9 of child 2 {#text} of child 1 {P} of child 3 {DIV} of body
+selection end:   position 6 of child 2 {#text} of child 1 {P} of child 3 {DIV} of body

Modified: trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-p-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-p-expected.txt (224014 => 224015)


--- trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-p-expected.txt	2017-10-26 10:58:17 UTC (rev 224014)
+++ trunk/LayoutTests/platform/gtk/editing/selection/vertical-rl-rtl-extend-line-forward-p-expected.txt	2017-10-26 12:03:29 UTC (rev 224015)
@@ -15,4 +15,4 @@
             text run at (0,45) width 120 RTL: "\x{5D0}\x{5D9}\x{5DF} \x{5DC}\x{5D9} \x{5E9}\x{5DD}."
       RenderBlock {PRE} at (0,212) size 784x0
 selection start: position 5 of child 0 {#text} of child 1 {P} of child 3 {DIV} of body
-selection end:   position 9 of child 0 {#text} of child 2 {P} of child 3 {DIV} of body
+selection end:   position 6 of child 0 {#text} of child 2 {P} of child 3 {DIV} of body

Modified: trunk/LayoutTests/platform/gtk/fast/text/atsui-negative-spacing-features-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/gtk/fast/text/atsui-negative-spacing-features-expected.txt (224014 => 224015)


--- trunk/LayoutTests/platform/gtk/fast/text/atsui-negative-spacing-features-expected.txt	2017-10-26 10:58:17 UTC (rev 224014)
+++ trunk/LayoutTests/platform/gtk/fast/text/atsui-negative-spacing-features-expected.txt	2017-10-26 12:03:29 UTC (rev 224015)
@@ -23,8 +23,8 @@
             RenderTableCell {TD} at (2,24) size 204x126 [r=1 c=0 rs=1 cs=1]
               RenderBlock {DIV} at (1,1) size 202x124
                 RenderBlock {DIV} at (0,0) size 202x38 [border: (1px solid #0000FF)]
-                  RenderText {#text} at (45,1) size 177x35
-                    text run at (45,1) width 156 RTL: "\x{5D9}\x{5B0}\x{5D4}\x{5B4}\x{5D9}, \x{5D0}\x{5B8}\x{5D7}\x{5B4}\x{5D9}, \x{5DC}\x{5B0}\x{5DA}\x{5B8} \x{5E1}\x{5B5}\x{5E4}\x{5B6}\x{5E8} \x{5E9}\x{5C1}\x{5B0}\x{5DC}\x{5B7}\x{5D7}\x{5B0}\x{5EA}\x{5BC}\x{5B4}\x{5D9}\x{5D5}"
+                  RenderText {#text} at (46,1) size 177x35
+                    text run at (46,1) width 155 RTL: "\x{5D9}\x{5B0}\x{5D4}\x{5B4}\x{5D9}, \x{5D0}\x{5B8}\x{5D7}\x{5B4}\x{5D9}, \x{5DC}\x{5B0}\x{5DA}\x{5B8} \x{5E1}\x{5B5}\x{5E4}\x{5B6}\x{5E8} \x{5E9}\x{5C1}\x{5B0}\x{5DC}\x{5B7}\x{5D7}\x{5B0}\x{5EA}\x{5BC}\x{5B4}\x{5D9}\x{5D5}"
                     text run at (24,19) width 122 RTL: "\x{5E6}\x{5B0}\x{5DE}\x{5B4}\x{5D9}\x{5EA}\x{5D5}\x{5BC}\x{5EA} \x{5DC}\x{5B8}\x{5DA}\x{5B0} \x{5DE}\x{5B0}\x{5DB}\x{5B7}\x{5E8}\x{5B0}\x{5EA}\x{5BC}\x{5B4}\x{5D9}\x{5D5}."
                     text run at (145,19) width 56 RTL: "\x{5D5}\x{5BC}\x{5DE}\x{5B4}\x{5DE}\x{5B0}\x{5DB}\x{5BC}\x{5B6}\x{5E8}\x{5B6}\x{5EA} "
                 RenderBlock {DIV} at (0,43) size 202x38 [border: (1px solid #0000FF)]
@@ -38,8 +38,8 @@
             RenderTableCell {TD} at (208,24) size 204x126 [r=1 c=1 rs=1 cs=1]
               RenderBlock {DIV} at (1,1) size 202x124
                 RenderBlock {DIV} at (0,0) size 202x38 [border: (1px solid #0000FF)]
-                  RenderText {#text} at (9,1) size 192x35
-                    text run at (9,1) width 192 RTL: "\x{5D9}\x{5B0}\x{5D4}\x{5B4}\x{5D9}, \x{5D0}\x{5B8}\x{5D7}\x{5B4}\x{5D9}, \x{5DC}\x{5B0}\x{5DA}\x{5B8} \x{5E1}\x{5B5}\x{5E4}\x{5B6}\x{5E8} \x{5E9}\x{5C1}\x{5B0}\x{5DC}\x{5B7}\x{5D7}\x{5B0}\x{5EA}\x{5BC}\x{5B4}\x{5D9}\x{5D5} \x{5D5}\x{5BC}\x{5DE}\x{5B4}\x{5DE}\x{5B0}\x{5DB}\x{5BC}\x{5B6}\x{5E8}\x{5B6}\x{5EA}"
+                  RenderText {#text} at (10,1) size 191x35
+                    text run at (10,1) width 191 RTL: "\x{5D9}\x{5B0}\x{5D4}\x{5B4}\x{5D9}, \x{5D0}\x{5B8}\x{5D7}\x{5B4}\x{5D9}, \x{5DC}\x{5B0}\x{5DA}\x{5B8} \x{5E1}\x{5B5}\x{5E4}\x{5B6}\x{5E8} \x{5E9}\x{5C1}\x{5B0}\x{5DC}\x{5B7}\x{5D7}\x{5B0}\x{5EA}\x{5BC}\x{5B4}\x{5D9}\x{5D5} \x{5D5}\x{5BC}\x{5DE}\x{5B4}\x{5DE}\x{5B0}\x{5DB}\x{5BC}\x{5B6}\x{5E8}\x{5B6}\x{5EA}"
                     text run at (93,19) width 108 RTL: "\x{5E6}\x{5B0}\x{5DE}\x{5B4}\x{5D9}\x{5EA}\x{5D5}\x{5BC}\x{5EA} \x{5DC}\x{5B8}\x{5DA}\x{5B0} \x{5DE}\x{5B0}\x{5DB}\x{5B7}\x{5E8}\x{5B0}\x{5EA}\x{5BC}\x{5B4}\x{5D9}\x{5D5}."
                 RenderBlock {DIV} at (0,43) size 202x38 [border: (1px solid #0000FF)]
                   RenderText {#text} at (1,1) size 150x35

Modified: trunk/LayoutTests/platform/gtk/fast/text/international/hebrew-vowels-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/gtk/fast/text/international/hebrew-vowels-expected.txt (224014 => 224015)


--- trunk/LayoutTests/platform/gtk/fast/text/international/hebrew-vowels-expected.txt	2017-10-26 10:58:17 UTC (rev 224014)
+++ trunk/LayoutTests/platform/gtk/fast/text/international/hebrew-vowels-expected.txt	2017-10-26 12:03:29 UTC (rev 224015)
@@ -11,8 +11,8 @@
         RenderText {#text} at (0,0) size 458x17
           text run at (0,0) width 458: "The vowel (two vertical dots) should be centered beneath the main letter."
       RenderBlock {DIV} at (0,86) size 784x91
-        RenderText {#text} at (33,1) size 44x88
-          text run at (33,1) width 44 RTL: "\x{5E1}\x{5B0} "
+        RenderText {#text} at (33,1) size 67x88
+          text run at (33,1) width 67 RTL: "\x{5E1}\x{5B0} "
         RenderText {#text} at (0,1) size 34x88
           text run at (0,1) width 34 RTL: "\x{5E9}\x{5B0}"
         RenderText {#text} at (0,0) size 0x0

Modified: trunk/LayoutTests/platform/gtk/svg/W3C-SVG-1.1/fonts-glyph-02-t-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/gtk/svg/W3C-SVG-1.1/fonts-glyph-02-t-expected.txt (224014 => 224015)


--- trunk/LayoutTests/platform/gtk/svg/W3C-SVG-1.1/fonts-glyph-02-t-expected.txt	2017-10-26 10:58:17 UTC (rev 224014)
+++ trunk/LayoutTests/platform/gtk/svg/W3C-SVG-1.1/fonts-glyph-02-t-expected.txt	2017-10-26 12:03:29 UTC (rev 224015)
@@ -2,16 +2,16 @@
   RenderView at (0,0) size 480x360
 layer at (0,0) size 480x360
   RenderSVGRoot {svg} at (0,0) size 480x360
-    RenderSVGContainer {g} at (100,36) size 210x196
+    RenderSVGContainer {g} at (100,36) size 224x196
       RenderSVGHiddenContainer {defs} at (0,0) size 0x0
       RenderSVGContainer {g} at (100,36) size 184x80
         RenderSVGText {text} at (100,36) size 184x80 contains 1 chunk(s)
           RenderSVGInlineText {#text} at (0,0) size 184x80
             chunk 1 text run 1 at (100.00,100.00) startOffset 0 endOffset 5 width 184.00 RTL: "\x{69A} \x{69A}\x{69A}\x{69A}"
-      RenderSVGContainer {g} at (100,118) size 210x114
-        RenderSVGText {text} at (100,118) size 210x114 contains 1 chunk(s)
-          RenderSVGInlineText {#text} at (0,0) size 210x114
-            chunk 1 text run 1 at (100.00,200.00) startOffset 0 endOffset 5 width 210.00 RTL: "\x{62E} \x{62E}\x{62E}\x{62E}"
+      RenderSVGContainer {g} at (100,118) size 224x114
+        RenderSVGText {text} at (100,118) size 224x114 contains 1 chunk(s)
+          RenderSVGInlineText {#text} at (0,0) size 224x114
+            chunk 1 text run 1 at (100.00,200.00) startOffset 0 endOffset 5 width 224.00 RTL: "\x{62E} \x{62E}\x{62E}\x{62E}"
     RenderSVGText {text} at (10,304) size 264x45 contains 1 chunk(s)
       RenderSVGInlineText {#text} at (0,0) size 264x45
         chunk 1 text run 1 at (10.00,340.00) startOffset 0 endOffset 16 width 264.00: "$Revision: 1.7 $"

Modified: trunk/LayoutTests/platform/gtk/svg/custom/glyph-selection-arabic-forms-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/gtk/svg/custom/glyph-selection-arabic-forms-expected.txt (224014 => 224015)


--- trunk/LayoutTests/platform/gtk/svg/custom/glyph-selection-arabic-forms-expected.txt	2017-10-26 10:58:17 UTC (rev 224014)
+++ trunk/LayoutTests/platform/gtk/svg/custom/glyph-selection-arabic-forms-expected.txt	2017-10-26 12:03:29 UTC (rev 224015)
@@ -1,10 +1,10 @@
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 400x50
-  RenderSVGRoot {svg} at (10,7) size 340x18
+  RenderSVGRoot {svg} at (10,7) size 347x18
     RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-    RenderSVGContainer {g} at (10,7) size 340x18
-      RenderSVGText {text} at (10,7) size 340x18 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 340x18
-          chunk 1 text run 1 at (10.00,20.00) startOffset 0 endOffset 56 width 333.00 RTL: "\x{62E}] [\x{62E}][\x{62E}][\x{62E}] | [\x{62E}] [\x{62E}\x{62E}][\x{62E}] | [\x{62E}] [\x{62E}\x{62E}\x{62E}] | [\x{62E} \x{62E}\x{62E}\x{62E}] | \x{62E} \x{62E}\x{62E}\x{62E}"
-          chunk 1 text run 1 at (343.00,20.00) startOffset 0 endOffset 1 width 7.00: "]"
+    RenderSVGContainer {g} at (10,7) size 347x18
+      RenderSVGText {text} at (10,7) size 347x18 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 347x18
+          chunk 1 text run 1 at (10.00,20.00) startOffset 0 endOffset 56 width 340.00 RTL: "\x{62E}] [\x{62E}][\x{62E}][\x{62E}] | [\x{62E}] [\x{62E}\x{62E}][\x{62E}] | [\x{62E}] [\x{62E}\x{62E}\x{62E}] | [\x{62E} \x{62E}\x{62E}\x{62E}] | \x{62E} \x{62E}\x{62E}\x{62E}"
+          chunk 1 text run 1 at (350.00,20.00) startOffset 0 endOffset 1 width 7.00: "]"

Modified: trunk/Source/WebCore/ChangeLog (224014 => 224015)


--- trunk/Source/WebCore/ChangeLog	2017-10-26 10:58:17 UTC (rev 224014)
+++ trunk/Source/WebCore/ChangeLog	2017-10-26 12:03:29 UTC (rev 224015)
@@ -1,3 +1,21 @@
+2017-10-26  Carlos Garcia Campos  <[email protected]>
+
+        REGRESSION(r222090): [HarfBuzz] Arabic shaping is broken except for first word in line
+        https://bugs.webkit.org/show_bug.cgi?id=178625
+
+        Reviewed by Michael Catanzaro.
+
+        Once we find the first space, which has the COMMON script, we split the run, and the next ones keep using
+        COMMON instead of ARABIC because we don't update the current script on every loop iteration. This patch
+        simplifies the script handling by moving the code back to the loop and always breaking in case of different
+        scripts, correctly handling INHERITED and COMMON cases and updating the current script when needed.
+
+        Covered by existing tests. This improves several tests that have been rebaselined.
+
+        * platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp:
+        (WebCore::findNextRun):
+        (WebCore::scriptsAreCompatibleForCharacters): Deleted.
+
 2017-10-26  Enrique Ocaña González  <[email protected]>
 
         [MSE][GStreamer] Fix hang on clearing/destroying AppendPipeline

Modified: trunk/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp (224014 => 224015)


--- trunk/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp	2017-10-26 10:58:17 UTC (rev 224014)
+++ trunk/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp	2017-10-26 12:03:29 UTC (rev 224015)
@@ -116,33 +116,6 @@
     return script;
 }
 
-static bool scriptsAreCompatibleForCharacters(UScriptCode script, UScriptCode previousScript, UChar32 character, UChar32 previousCharacter)
-{
-    if (script == previousScript)
-        return true;
-
-    if (script == USCRIPT_INHERITED || previousScript == USCRIPT_COMMON)
-        return true;
-
-    if (script == USCRIPT_COMMON) {
-        // §5.1 Handling Characters with the Common Script Property.
-        // Programs must resolve any of the special Script property values, such as Common,
-        // based on the context of the surrounding characters. A simple heuristic uses the
-        // script of the preceding character, which works well in many cases.
-        // http://www.unicode.org/reports/tr24/#Common.
-        //
-        // FIXME: cover all other cases mentioned in the spec (ie. brackets or quotation marks).
-        // https://bugs.webkit.org/show_bug.cgi?id=177003.
-        //
-        // We use a slightly more conservative heuristic than the one proposed in the spec,
-        // using the script of the previous character only if both are ASCII.
-        if (isASCII(character) && isASCII(previousCharacter))
-            return true;
-    }
-
-    return uscript_hasScript(character, previousScript);
-}
-
 struct HBRun {
     unsigned startIndex;
     unsigned endIndex;
@@ -162,8 +135,7 @@
         return std::nullopt;
 
     unsigned startIndex = offset;
-    UChar32 previousCharacter = character;
-    for (textIterator.advance(clusterLength); textIterator.consume(character, clusterLength); previousCharacter = character, textIterator.advance(clusterLength)) {
+    for (textIterator.advance(clusterLength); textIterator.consume(character, clusterLength); textIterator.advance(clusterLength)) {
         if (FontCascade::treatAsZeroWidthSpace(character))
             continue;
 
@@ -171,7 +143,25 @@
         if (!nextScript)
             return std::nullopt;
 
-        if (!scriptsAreCompatibleForCharacters(nextScript.value(), currentScript.value(), character, previousCharacter))
+        // §5.1 Handling Characters with the Common Script Property.
+        // Programs must resolve any of the special Script property values, such as Common,
+        // based on the context of the surrounding characters. A simple heuristic uses the
+        // script of the preceding character, which works well in many cases.
+        // http://www.unicode.org/reports/tr24/#Common.
+        //
+        // FIXME: cover all other cases mentioned in the spec (ie. brackets or quotation marks).
+        // https://bugs.webkit.org/show_bug.cgi?id=177003.
+        //
+        // If next script is inherited or common, keep using the current script.
+        if (nextScript == USCRIPT_INHERITED || nextScript == USCRIPT_COMMON)
+            continue;
+        // If current script is inherited or common, set the next script as current.
+        if (currentScript == USCRIPT_INHERITED || currentScript == USCRIPT_COMMON) {
+            currentScript = nextScript;
+            continue;
+        }
+
+        if (currentScript != nextScript && !uscript_hasScript(character, currentScript.value()))
             return std::optional<HBRun>({ startIndex, textIterator.currentIndex(), currentScript.value() });
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to