Source/WebCore: Added the regional indicator symbols to the set of codepoints that...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Jul 2011 20:20:52 +0000 (20:20 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Jul 2011 20:20:52 +0000 (20:20 +0000)
Fixes <rdar://problem/9864578> Regional indicator symbols do not combine into national flags
https://bugs.webkit.org/show_bug.cgi?id=65380

Reviewed by Anders Carlsson.

Test: fast/text/regional-indicator-symobls.html

* platform/graphics/Font.cpp:
(WebCore::Font::codePath): Added handling of surrogate pairs, which returns Complex for characters in
the range U+1F1E6..U+1F1FF.

LayoutTests: Test for <rdar://problem/9864578> Regional indicator symbols do not combine into national flags
https://bugs.webkit.org/show_bug.cgi?id=65380

Reviewed by Anders Carlsson.

* fast/text/regional-indicator-symobls-expected.txt: Added.
* fast/text/regional-indicator-symobls.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/regional-indicator-symobls-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/regional-indicator-symobls.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Font.cpp

index 2447e37..f729313 100644 (file)
@@ -1,3 +1,13 @@
+2011-07-29  Dan Bernstein  <mitz@apple.com>
+
+        Test for <rdar://problem/9864578> Regional indicator symbols do not combine into national flags
+        https://bugs.webkit.org/show_bug.cgi?id=65380
+
+        Reviewed by Anders Carlsson.
+
+        * fast/text/regional-indicator-symobls-expected.txt: Added.
+        * fast/text/regional-indicator-symobls.html: Added.
+
 2011-07-29  Anna Cavender  <annacc@chromium.org>
 
         Tests for validating a new WebVTT parser for <track>
diff --git a/LayoutTests/fast/text/regional-indicator-symobls-expected.txt b/LayoutTests/fast/text/regional-indicator-symobls-expected.txt
new file mode 100644 (file)
index 0000000..89cb4cd
--- /dev/null
@@ -0,0 +1,7 @@
+Test that regional indicator symobol letters can combine into national flags.
+
+The two boxes below should look the same.
+
+PASS
+
+πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ
diff --git a/LayoutTests/fast/text/regional-indicator-symobls.html b/LayoutTests/fast/text/regional-indicator-symobls.html
new file mode 100644 (file)
index 0000000..3d2baac
--- /dev/null
@@ -0,0 +1,25 @@
+<style>
+    span { border: solid; }
+    span#reference { text-rendering: optimizelegibility; }
+</style>
+<p>
+    Test that regional indicator symobol letters can combine into national flags.
+</p>
+<p>
+    The two boxes below should look the same.
+</p>
+<p id="result">
+    FAIL: Test did not finish.
+</p>
+<p style="font-size: 48px;">
+    <span id="test">&#x1f1ec;&#x1f1e7; &#x1f1fa;&#x1f1f8;</span>
+    <span id="reference">&#x1f1ec;&#x1f1e7; &#x1f1fa;&#x1f1f8;</span>
+</p>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    var test = document.getElementById("test");
+    var reference = document.getElementById("reference");
+    document.getElementById("result").innerText = test.offsetWidth === reference.offsetWidth ? "PASS" : "FAIL";
+</script>
index 35dd6a1..6b2ef95 100644 (file)
@@ -1,3 +1,18 @@
+2011-07-29  Dan Bernstein  <mitz@apple.com>
+
+        Added the regional indicator symbols to the set of codepoints that force use of the complex text code path.
+
+        Fixes <rdar://problem/9864578> Regional indicator symbols do not combine into national flags
+        https://bugs.webkit.org/show_bug.cgi?id=65380
+
+        Reviewed by Anders Carlsson.
+
+        Test: fast/text/regional-indicator-symobls.html
+
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::codePath): Added handling of surrogate pairs, which returns Complex for characters in
+        the range U+1F1E6..U+1F1FF.
+
 2011-07-28  David Hyatt  <hyatt@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=65342
index 4b47cfd..0bb606c 100644 (file)
@@ -382,13 +382,33 @@ Font::CodePath Font::codePath(const TextRun& run) const
         if (c <= 0xD7FF)
             return Complex;
 
+        if (c <= 0xDBFF) {
+            // High surrogate
+
+            if (i == run.length() - 1)
+                continue;
+
+            UChar next = run[++i];
+            if (!U16_IS_TRAIL(next))
+                continue;
+
+            UChar32 supplementaryCharacter = U16_GET_SUPPLEMENTARY(c, next);
+
+            if (supplementaryCharacter < 0x1F1E6) // U+1F1E6 through U+1F1FF Regional Indicator Symbols
+                continue;
+            if (supplementaryCharacter <= 0x1F1FF)
+                return Complex;
+
+            // FIXME: Check for Brahmi (U+11000 block), Kaithi (U+11080 block) and other complex scripts
+            // in plane 1 or higher.
+
+            continue;
+        }
+
         if (c < 0xFE20) // U+FE20 through U+FE2F Combining half marks
             continue;
         if (c <= 0xFE2F)
             return Complex;
-
-        // FIXME: Make this loop UTF-16-aware and check for Brahmi (U+11000 block)
-        // Kaithi (U+11080 block) and other complex scripts in plane 1 or higher.
     }
 
     if (typesettingFeatures())