2010-04-21 David Yonge-Mallo <davinci@chromium.org>
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Apr 2010 02:48:20 +0000 (02:48 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Apr 2010 02:48:20 +0000 (02:48 +0000)
        Reviewed by Dan Bernstein.

        ZWNJ - Display non-printing, invisible character
        https://bugs.webkit.org/show_bug.cgi?id=16131

        Fix the (non)display of glyphs for ZWJ and ZWNJ in simple font code path.

        Tests: fast/text/format-control.html
               fast/text/zero-width-characters.html

        * platform/graphics/Font.h:
        (WebCore::Font::operator!=):
        (WebCore::Font::treatAsZeroWidthSpace): treat ZWNJ and ZWJ as ZWSP.
        * platform/graphics/GlyphPageTreeNode.cpp:
        (WebCore::GlyphPageTreeNode::initializePage): added ZWNJ and ZWJ.
        * platform/text/CharacterNames.h: added ZWNJ and ZWJ.

2010-04-21  David Yonge-Mallo  <davinci@chromium.org>

        Reviewed by Dan Bernstein.

        ZWNJ - Display non-printing, invisible character
        https://bugs.webkit.org/show_bug.cgi?id=16131

        Added tests for the handling of ZWJ and ZWNJ characters in simple font
        path.  These characters have zero width but may change the widths of text
        around them.  Furthermore, their glyphs should not be displayed in
        simple static text.

        * fast/text/format-control.html: Added.
        * fast/text/zero-width-characters.html: modified to test ZWSP, ZWJ, and ZWNJ.
        * platform/mac/fast/text/format-control-expected.checksum: Added.
        * platform/mac/fast/text/format-control-expected.png: Added.
        * platform/mac/fast/text/format-control-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@58042 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/text/format-control.html [new file with mode: 0644]
LayoutTests/fast/text/zero-width-characters.html
LayoutTests/platform/mac/fast/text/format-control-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/format-control-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/format-control-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/platform/graphics/Font.h
WebCore/platform/graphics/GlyphPageTreeNode.cpp
WebCore/platform/text/CharacterNames.h

index c490578..6f444c3 100644 (file)
@@ -1,3 +1,21 @@
+2010-04-21  David Yonge-Mallo  <davinci@chromium.org>
+
+        Reviewed by Dan Bernstein.
+
+        ZWNJ - Display non-printing, invisible character
+        https://bugs.webkit.org/show_bug.cgi?id=16131
+
+        Added tests for the handling of ZWJ and ZWNJ characters in simple font
+        path.  These characters have zero width but may change the widths of text 
+        around them.  Furthermore, their glyphs should not be displayed in
+        simple static text.
+
+        * fast/text/format-control.html: Added.
+        * fast/text/zero-width-characters.html: modified to test ZWSP, ZWJ, and ZWNJ.
+        * platform/mac/fast/text/format-control-expected.checksum: Added.
+        * platform/mac/fast/text/format-control-expected.png: Added.
+        * platform/mac/fast/text/format-control-expected.txt: Added.
+
 2010-04-21  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
 
         Unreviewed.
diff --git a/LayoutTests/fast/text/format-control.html b/LayoutTests/fast/text/format-control.html
new file mode 100644 (file)
index 0000000..1e6c11d
--- /dev/null
@@ -0,0 +1,23 @@
+<html><head>
+<meta charset="utf-8">
+<style>
+div { font-size: 30pt; }
+</style>
+</head>
+<body>
+This tests the ZWJ and ZWNJ format control characters on basic Latin text.
+
+<div>
+<p>fi fl ff ffi ffl fl f&nbsp;&nbsp;&nbsp;i</p>
+<p>f‌i f‌l f‌f f‌f‌i f‌f‌l f‌‌‌‌‌‌‌l f‌‌‌‌‌‌‌ ‌‌‌‌‌‌‌ ‌‌‌‌‌‌‌ ‌‌‌‌‌‌‌i</p>
+<p>f‍i f‍l f‍f f‍f‍i f‍f‍l f‍‍‍‍‍‍‍l f‍‍‍‍‍‍‍ ‍‍‍‍‍‍‍ ‍‍‍‍‍‍‍ ‍‍‍‍‍‍‍i</p>
+</div>
+
+<div style="font-family: Times New Roman">
+<p>fi fl ff ffi ffl fl f&nbsp;&nbsp;&nbsp;i</p>
+<p>f‌i f‌l f‌f f‌f‌i f‌f‌l f‌‌‌‌‌‌‌l f‌‌‌‌‌‌‌ ‌‌‌‌‌‌‌ ‌‌‌‌‌‌‌ ‌‌‌‌‌‌‌i</p>
+<p>f‍i f‍l f‍f f‍f‍i f‍f‍l f‍‍‍‍‍‍‍l f‍‍‍‍‍‍‍ ‍‍‍‍‍‍‍ ‍‍‍‍‍‍‍ ‍‍‍‍‍‍‍i</p>
+</div>
+
+</body>
+</html>
index d88bc3f..d8ec6f2 100644 (file)
@@ -8,6 +8,9 @@ function test()
     for (var i = 0; i < 32; ++i) // >
         if (i != 9 && i != 10 && i != 13) // ;
             testString += String.fromCharCode(i);
+    testString += String.fromCharCode(0x200B);
+    testString += String.fromCharCode(0x200C);
+    testString += String.fromCharCode(0x200D);
     testString += String.fromCharCode(0x200E);
     testString += String.fromCharCode(0x200F);
     testString += String.fromCharCode(0xFFFC);
diff --git a/LayoutTests/platform/mac/fast/text/format-control-expected.checksum b/LayoutTests/platform/mac/fast/text/format-control-expected.checksum
new file mode 100644 (file)
index 0000000..2b934a9
--- /dev/null
@@ -0,0 +1 @@
+9a8e0218297be2fa94660b86601724ff
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/text/format-control-expected.png b/LayoutTests/platform/mac/fast/text/format-control-expected.png
new file mode 100644 (file)
index 0000000..355c48f
Binary files /dev/null and b/LayoutTests/platform/mac/fast/text/format-control-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/text/format-control-expected.txt b/LayoutTests/platform/mac/fast/text/format-control-expected.txt
new file mode 100644 (file)
index 0000000..8de988d
--- /dev/null
@@ -0,0 +1,28 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x552
+      RenderBlock (anonymous) at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 475x18
+          text run at (0,0) width 475: "This tests the ZWJ and ZWNJ format control characters on basic Latin text."
+      RenderBlock {DIV} at (0,58) size 784x218
+        RenderBlock {P} at (0,0) size 784x46
+          RenderText {#text} at (0,0) size 286x46
+            text run at (0,0) width 286: "fi fl ff ffi ffl fl f   i"
+        RenderBlock {P} at (0,86) size 784x46
+          RenderText {#text} at (0,0) size 286x46
+            text run at (0,0) width 286: "f\x{200C}i f\x{200C}l f\x{200C}f f\x{200C}f\x{200C}i f\x{200C}f\x{200C}l f\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}l f\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C} \x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C} \x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C} \x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}i"
+        RenderBlock {P} at (0,172) size 784x46
+          RenderText {#text} at (0,0) size 286x46
+            text run at (0,0) width 286: "f\x{200D}i f\x{200D}l f\x{200D}f f\x{200D}f\x{200D}i f\x{200D}f\x{200D}l f\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}l f\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D} \x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D} \x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D} \x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}i"
+      RenderBlock {DIV} at (0,316) size 784x221
+        RenderBlock {P} at (0,0) size 784x47
+          RenderText {#text} at (0,1) size 286x45
+            text run at (0,1) width 286: "fi fl ff ffi ffl fl f   i"
+        RenderBlock {P} at (0,87) size 784x47
+          RenderText {#text} at (0,1) size 286x45
+            text run at (0,1) width 286: "f\x{200C}i f\x{200C}l f\x{200C}f f\x{200C}f\x{200C}i f\x{200C}f\x{200C}l f\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}l f\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C} \x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C} \x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C} \x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}\x{200C}i"
+        RenderBlock {P} at (0,174) size 784x47
+          RenderText {#text} at (0,1) size 286x45
+            text run at (0,1) width 286: "f\x{200D}i f\x{200D}l f\x{200D}f f\x{200D}f\x{200D}i f\x{200D}f\x{200D}l f\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}l f\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D} \x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D} \x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D} \x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}\x{200D}i"
index 1370f1e..ce973f4 100644 (file)
@@ -1,3 +1,22 @@
+2010-04-21  David Yonge-Mallo  <davinci@chromium.org>
+
+        Reviewed by Dan Bernstein.
+
+        ZWNJ - Display non-printing, invisible character
+        https://bugs.webkit.org/show_bug.cgi?id=16131
+
+        Fix the (non)display of glyphs for ZWJ and ZWNJ in simple font code path.
+
+        Tests: fast/text/format-control.html
+               fast/text/zero-width-characters.html
+
+        * platform/graphics/Font.h:
+        (WebCore::Font::operator!=):
+        (WebCore::Font::treatAsZeroWidthSpace): treat ZWNJ and ZWJ as ZWSP.
+        * platform/graphics/GlyphPageTreeNode.cpp:
+        (WebCore::GlyphPageTreeNode::initializePage): added ZWNJ and ZWJ.
+        * platform/text/CharacterNames.h: added ZWNJ and ZWJ.
+
 2010-04-21  Charles Wei  <charles.wei@torchmobile.com.cn>
 
         Reviewed by George Staikos.
index 62525b0..54c3c0d 100644 (file)
@@ -26,9 +26,9 @@
 #define Font_h
 
 #include "CharacterNames.h"
-#include "TextRun.h"
 #include "FontDescription.h"
 #include "SimpleFontData.h"
+#include "TextRun.h"
 #include "TypesettingFeatures.h"
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
@@ -83,9 +83,7 @@ public:
     Font& operator=(const Font&);
 
     bool operator==(const Font& other) const;
-    bool operator!=(const Font& other) const {
-        return !(*this == other);
-    }
+    bool operator!=(const Font& other) const { return !(*this == other); }
 
     const FontDescription& fontDescription() const { return m_fontDescription; }
 
@@ -197,7 +195,7 @@ public:
 
     FontSelector* fontSelector() const;
     static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == 0x00A0; }
-    static bool treatAsZeroWidthSpace(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == 0x200e || c == 0x200f || (c >= 0x202a && c <= 0x202e) || c == 0xFFFC; }
+    static bool treatAsZeroWidthSpace(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || (c >= 0x200c && c <= 0x200f) || (c >= 0x202a && c <= 0x202e) || c == 0xFFFC; }
 
     static inline UChar normalizeSpaces(UChar character)
     {
index 59a5efb..9e846ec 100644 (file)
@@ -165,13 +165,15 @@ void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNu
                     buffer[(int)'\t'] = ' ';
                     buffer[noBreakSpace] = ' ';
                 } else if (start == (leftToRightMark & ~(GlyphPage::size - 1))) {
-                    // LRM, RLM, LRE, RLE and PDF must not render at all.
+                    // LRM, RLM, LRE, RLE, ZWNJ, ZWJ, and PDF must not render at all.
                     buffer[leftToRightMark - start] = zeroWidthSpace;
                     buffer[rightToLeftMark - start] = zeroWidthSpace;
                     buffer[leftToRightEmbed - start] = zeroWidthSpace;
                     buffer[rightToLeftEmbed - start] = zeroWidthSpace;
                     buffer[leftToRightOverride - start] = zeroWidthSpace;
                     buffer[rightToLeftOverride - start] = zeroWidthSpace;
+                    buffer[zeroWidthNonJoiner - start] = zeroWidthSpace;
+                    buffer[zeroWidthJoiner - start] = zeroWidthSpace;
                     buffer[popDirectionalFormatting - start] = zeroWidthSpace;
                 } else if (start == (objectReplacementCharacter & ~(GlyphPage::size - 1))) {
                     // Object replacement character must not render at all.
index c0b1750..fbb9466 100644 (file)
 
 namespace WebCore {
 
-    // Names here are taken from the Unicode standard.
+// Names here are taken from the Unicode standard.
 
-    // Note, these are UChar constants, not UChar32, which makes them
-    // more convenient for WebCore code that mostly uses UTF-16.
+// Note, these are UChar constants, not UChar32, which makes them
+// more convenient for WebCore code that mostly uses UTF-16.
 
-    const UChar blackSquare = 0x25A0;
-    const UChar bullet = 0x2022;
-    const UChar ethiopicPrefaceColon = 0x1366;
-    const UChar hebrewPunctuationGeresh = 0x05F3;
-    const UChar hebrewPunctuationGershayim = 0x05F4;
-    const UChar horizontalEllipsis = 0x2026;
-    const UChar hyphenMinus = 0x002D;
-    const UChar ideographicComma = 0x3001;
-    const UChar ideographicFullStop = 0x3002;
-    const UChar ideographicSpace = 0x3000;
-    const UChar leftDoubleQuotationMark = 0x201C;
-    const UChar leftSingleQuotationMark = 0x2018;
-    const UChar leftToRightEmbed = 0x202A;
-    const UChar leftToRightMark = 0x200E;
-    const UChar leftToRightOverride = 0x202D;
-    const UChar newlineCharacter = 0x000A;
-    const UChar noBreakSpace = 0x00A0;
-    const UChar objectReplacementCharacter = 0xFFFC;
-    const UChar popDirectionalFormatting = 0x202C;
-    const UChar replacementCharacter = 0xFFFD;
-    const UChar rightDoubleQuotationMark = 0x201D;
-    const UChar rightSingleQuotationMark = 0x2019;
-    const UChar rightToLeftEmbed = 0x202B;
-    const UChar rightToLeftMark = 0x200F;
-    const UChar rightToLeftOverride = 0x202E;
-    const UChar softHyphen = 0x00AD;
-    const UChar space = 0x0020;
-    const UChar whiteBullet = 0x25E6;
-    const UChar zeroWidthSpace = 0x200B;
+const UChar blackSquare = 0x25A0;
+const UChar bullet = 0x2022;
+const UChar ethiopicPrefaceColon = 0x1366;
+const UChar hebrewPunctuationGeresh = 0x05F3;
+const UChar hebrewPunctuationGershayim = 0x05F4;
+const UChar horizontalEllipsis = 0x2026;
+const UChar hyphenMinus = 0x002D;
+const UChar ideographicComma = 0x3001;
+const UChar ideographicFullStop = 0x3002;
+const UChar ideographicSpace = 0x3000;
+const UChar leftDoubleQuotationMark = 0x201C;
+const UChar leftSingleQuotationMark = 0x2018;
+const UChar leftToRightEmbed = 0x202A;
+const UChar leftToRightMark = 0x200E;
+const UChar leftToRightOverride = 0x202D;
+const UChar newlineCharacter = 0x000A;
+const UChar noBreakSpace = 0x00A0;
+const UChar objectReplacementCharacter = 0xFFFC;
+const UChar popDirectionalFormatting = 0x202C;
+const UChar replacementCharacter = 0xFFFD;
+const UChar rightDoubleQuotationMark = 0x201D;
+const UChar rightSingleQuotationMark = 0x2019;
+const UChar rightToLeftEmbed = 0x202B;
+const UChar rightToLeftMark = 0x200F;
+const UChar rightToLeftOverride = 0x202E;
+const UChar softHyphen = 0x00AD;
+const UChar space = 0x0020;
+const UChar whiteBullet = 0x25E6;
+const UChar zeroWidthJoiner = 0x200D;
+const UChar zeroWidthNonJoiner = 0x200C;
+const UChar zeroWidthSpace = 0x200B;
 
 }