Title: [111589] trunk
Revision
111589
Author
[email protected]
Date
2012-03-21 12:04:30 -0700 (Wed, 21 Mar 2012)

Log Message

[chromium] Font fallback in cr-win is wrong for string contains zero-width-space.
https://bugs.webkit.org/show_bug.cgi?id=79961

Reviewed by Adam Barth.

Source/WebCore:

Treat zero-width-space (\u200B) as true for treatAsZeroWidthSpaceInComplexScipt().

* platform/graphics/Font.h:
(WebCore::Font::treatAsZeroWidthSpaceInComplexScript):
* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::adjustGlyphsAndAdvances):
* platform/graphics/win/UniscribeController.cpp:
(WebCore::UniscribeController::shapeAndPlaceItem):

LayoutTests:

* fast/text/zero-width-characters-complex-script.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (111588 => 111589)


--- trunk/LayoutTests/ChangeLog	2012-03-21 19:01:59 UTC (rev 111588)
+++ trunk/LayoutTests/ChangeLog	2012-03-21 19:04:30 UTC (rev 111589)
@@ -1,3 +1,12 @@
+2012-03-21  Xiaomei Ji  <[email protected]>
+
+        [chromium] Font fallback in cr-win is wrong for string contains zero-width-space.
+        https://bugs.webkit.org/show_bug.cgi?id=79961
+
+        Reviewed by Adam Barth.
+
+        * fast/text/zero-width-characters-complex-script.html:
+
 2012-03-21  Emil A Eklund  <[email protected]>
 
         Unreviewed test_expectations update for chromium.

Modified: trunk/LayoutTests/fast/text/zero-width-characters-complex-script.html (111588 => 111589)


--- trunk/LayoutTests/fast/text/zero-width-characters-complex-script.html	2012-03-21 19:01:59 UTC (rev 111588)
+++ trunk/LayoutTests/fast/text/zero-width-characters-complex-script.html	2012-03-21 19:04:30 UTC (rev 111589)
@@ -1,11 +1,9 @@
 <head>
 <script>
 
-function testChar(ch)
+function testChar(a, b, ch)
 {
     // Strings a and b selected here do not have any 'interaction' between them.
-    var a = "\u0915\u093E"
-    var b = "\u0916";
     var span = document.getElementById("characters");
     span.firstChild.data = a + b;
     var abWidth = span.offsetWidth;
@@ -21,39 +19,56 @@
     return 1;
 }
 
-function test()
-{
-    if (window.layoutTestController)
-        layoutTestController.dumpAsText();
+function testWithZeroWidthSpace(a, b) {
     var failedCount = 0;
+
     for (var i = 1; i < 32; ++i)
         if (i != 9 && i != 10 && i != 13)
-            failedCount += testChar(i);
+            failedCount += testChar(a, b, i);
 
     for (var i = 0x7F; i < 0xA0; ++i)
-        failedCount += testChar(i);
-    failedCount += testChar(0xAD);
+        failedCount += testChar(a, b, i);
+    failedCount += testChar(a, b, 0xAD);
+
     // ZWJ (U+200C) and ZWNJ (U+200D) are excluded because they
     // can affect the rendering in complex script text.
-    failedCount += testChar(0x200B);
-    failedCount += testChar(0x200E);
-    failedCount += testChar(0x200F);
-    failedCount += testChar(0x202A);
-    failedCount += testChar(0x202B);
-    failedCount += testChar(0x202C);
-    failedCount += testChar(0x202D);
-    failedCount += testChar(0x202E);
-    failedCount += testChar(0xFEFF);
-    failedCount += testChar(0xFFFC);
+    failedCount += testChar(a, b, 0x200B);
+    failedCount += testChar(a, b, 0x200E);
+    failedCount += testChar(a, b, 0x200F);
+    failedCount += testChar(a, b, 0x202A);
+    failedCount += testChar(a, b, 0x202B);
+    failedCount += testChar(a, b, 0x202C);
+    failedCount += testChar(a, b, 0x202D);
+    failedCount += testChar(a, b, 0x202E);
+    failedCount += testChar(a, b, 0xFEFF);
+    failedCount += testChar(a, b, 0xFFFC);
 
+    return failedCount;
+}
+
+function test()
+{
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    var failedDevanagariCount = testWithZeroWidthSpace("\u0915\u093E", "\u0916");
+
+    var failedArabicCount = testWithZeroWidthSpace("\u0627\u0644\u0645\u062A\u0648\u0633\u0637\u0020\u200B\u200B\u0647\u0648\u0020\u0020", "\u0647\u0648\u0020");
+
     var testArea = document.getElementById("testArea");
     testArea.parentNode.removeChild(testArea);
 
-    if (failedCount > 0) 
-        result = "FAIL: " + failedCount + " characters had non-zero width" +
-                 " or failed to get measured.";
-    else
+    var result = "";
+    if (failedDevanagariCount == 0 && failedArabicCount == 0)
         result = "PASS: All characters had zero-width.";
+    else {
+        if (failedDevanagariCount > 0)
+            result = "FAIL: " + failedDevanagariCount + " characters had non-zero width" +
+                 " or failed to get measured when test with Devanagari";
+        if (failedArabicCount > 0)
+            result += "\nFAIL: " + failedArabicCount + " characters had non-zero width" +
+                 " or failed to get measured when test with Arabic";
+    }
     document.getElementById("result").firstChild.data = ""
 }
 </script>

Modified: trunk/Source/WebCore/ChangeLog (111588 => 111589)


--- trunk/Source/WebCore/ChangeLog	2012-03-21 19:01:59 UTC (rev 111588)
+++ trunk/Source/WebCore/ChangeLog	2012-03-21 19:04:30 UTC (rev 111589)
@@ -1,3 +1,19 @@
+2012-03-21  Xiaomei Ji  <[email protected]>
+
+        [chromium] Font fallback in cr-win is wrong for string contains zero-width-space.
+        https://bugs.webkit.org/show_bug.cgi?id=79961
+
+        Reviewed by Adam Barth.
+
+        Treat zero-width-space (\u200B) as true for treatAsZeroWidthSpaceInComplexScipt().
+
+        * platform/graphics/Font.h:
+        (WebCore::Font::treatAsZeroWidthSpaceInComplexScript):
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
+        * platform/graphics/win/UniscribeController.cpp:
+        (WebCore::UniscribeController::shapeAndPlaceItem):
+
 2012-03-21  Patrick Gansterer  <[email protected]>
 
         Build fix for !ENABLE(INSPECTOR) after r111005.

Modified: trunk/Source/WebCore/platform/graphics/Font.h (111588 => 111589)


--- trunk/Source/WebCore/platform/graphics/Font.h	2012-03-21 19:01:59 UTC (rev 111588)
+++ trunk/Source/WebCore/platform/graphics/Font.h	2012-03-21 19:04:30 UTC (rev 111589)
@@ -229,7 +229,7 @@
     FontSelector* fontSelector() const;
     static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == noBreakSpace; }
     static bool treatAsZeroWidthSpace(UChar c) { return treatAsZeroWidthSpaceInComplexScript(c) || c == 0x200c || c == 0x200d; }
-    static bool treatAsZeroWidthSpaceInComplexScript(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == softHyphen || (c >= 0x200e && c <= 0x200f) || (c >= 0x202a && c <= 0x202e) || c == zeroWidthNoBreakSpace || c == objectReplacementCharacter; }
+    static bool treatAsZeroWidthSpaceInComplexScript(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == softHyphen || c == zeroWidthSpace || (c >= 0x200e && c <= 0x200f) || (c >= 0x202a && c <= 0x202e) || c == zeroWidthNoBreakSpace || c == objectReplacementCharacter; }
     static bool canReceiveTextEmphasis(UChar32 c);
 
     static inline UChar normalizeSpaces(UChar character)

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp (111588 => 111589)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2012-03-21 19:01:59 UTC (rev 111588)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2012-03-21 19:04:30 UTC (rev 111589)
@@ -519,7 +519,7 @@
             if (ch == '\t' && m_run.allowTabs()) {
                 float tabWidth = m_font.tabWidth(*fontData);
                 advance.width = tabWidth - fmodf(m_run.xPos() + m_totalWidth + widthSinceLastCommit, tabWidth);
-            } else if (ch == zeroWidthSpace || (Font::treatAsZeroWidthSpace(ch) && !treatAsSpace)) {
+            } else if (Font::treatAsZeroWidthSpace(ch) && !treatAsSpace) {
                 advance.width = 0;
                 glyph = fontData->spaceGlyph();
             }

Modified: trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp (111588 => 111589)


--- trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp	2012-03-21 19:01:59 UTC (rev 111588)
+++ trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp	2012-03-21 19:04:30 UTC (rev 111589)
@@ -272,7 +272,7 @@
     for (int k = 0; k < len; k++) {
         UChar ch = *(str + k);
         bool treatAsSpace = Font::treatAsSpace(ch);
-        bool treatAsZeroWidthSpace = ch == zeroWidthSpace || Font::treatAsZeroWidthSpace(ch);
+        bool treatAsZeroWidthSpace = Font::treatAsZeroWidthSpace(ch);
         if (treatAsSpace || treatAsZeroWidthSpace) {
             // Substitute in the space glyph at the appropriate place in the glyphs
             // array.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to