2009-07-13 Adam Langley <agl@google.com>
authoragl@chromium.org <agl@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Jul 2009 19:14:22 +0000 (19:14 +0000)
committeragl@chromium.org <agl@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Jul 2009 19:14:22 +0000 (19:14 +0000)
        Reviewed by Eric Seidel.

        Chromium Linux: fix assertion when rendering google.com.kh

        https://bugs.webkit.org/show_bug.cgi?id=26924

        Some shapers (i.e. Khmer) will produce cluster logs which report that
        /no/ code points contributed to certain glyphs. Because of this, we
        take any code point which contributed to the glyph in question, or any
        subsequent glyph.  If we run off the end, then we take the last code
        point.

        Added LayoutTests/fast/text/international/khmar-selection.html

        * platform/graphics/chromium/FontLinux.cpp:
        (WebCore::Font::offsetForPositionForComplexText):

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

LayoutTests/ChangeLog
LayoutTests/fast/text/international/khmer-selection.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/platform/graphics/chromium/FontLinux.cpp

index 1c8285869cf3f8ba2787706ccab0b11f7620b333..7cf8c60eead16e48a87483be80d7f28d8faf6acf 100644 (file)
@@ -1,3 +1,19 @@
+2009-07-13  Adam Langley  <agl@google.com>
+
+        Reviewed by Eric Seidel.
+
+        Chromium Linux: fix assertion when rendering google.com.kh
+
+        https://bugs.webkit.org/show_bug.cgi?id=26924
+
+        Some shapers (i.e. Khmer) will produce cluster logs which report that
+        /no/ code points contributed to certain glyphs. Because of this, we
+        take any code point which contributed to the glyph in question, or any
+        subsequent glyph.  If we run off the end, then we take the last code
+        point.
+
+        * fast/text/international/khmer-selection.html: Added.
+
 2009-07-13  Peter Kasting  <pkasting@google.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=19562
diff --git a/LayoutTests/fast/text/international/khmer-selection.html b/LayoutTests/fast/text/international/khmer-selection.html
new file mode 100644 (file)
index 0000000..74e0b08
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+  <title>Testing Khmer selection</title>
+  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+  <script>
+    function main() {
+      window.eventSender.mouseMoveTo(5, 8);
+      window.eventSender.mouseDown();
+
+      for (var x = 5; x < 600; x += 5) {
+        window.eventSender.mouseMoveTo(x, 8);
+      }
+
+      window.eventSender.mouseUp();
+    }
+  </script>
+</head>
+
+<body onload="main();">
+  <p>
+    <nobr><b class="gb1">វ៉ែប</b> <a href=
+    "http://images.google.com.kh/imghp?hl=km&amp;tab=wi" class=
+    "gb1">រូបភាព</a> <a href=
+    "http://groups.google.com.kh/grphp?hl=km&amp;tab=wg" class=
+    "gb1">ក្រុម</a> <a href=
+    "http://www.google.com.kh/dirhp?hl=km&amp;tab=wd" class=
+    "gb1">ថតឯកសារ</a></nobr>
+  </p>
+  <p>Some Harfbuzz shapers will output cluster logs which suggest that some glyphs had <i>no</i> contributing code points. This test contains such text and uses <tt>eventSender</tt> to select the text. You should see some of the above text selected and <tt>test_shell</tt> shouldn't trigger any assertions or crash.</p>
+</body>
+</html>
index bd4a7b5922cbdc27c1a62b62ca02fb2907a9b627..acf781f3e1d9b061712a286dccfc3a7a2213f2fb 100644 (file)
@@ -1,3 +1,22 @@
+2009-07-13  Adam Langley  <agl@google.com>
+
+        Reviewed by Eric Seidel.
+
+        Chromium Linux: fix assertion when rendering google.com.kh
+
+        https://bugs.webkit.org/show_bug.cgi?id=26924
+
+        Some shapers (i.e. Khmer) will produce cluster logs which report that
+        /no/ code points contributed to certain glyphs. Because of this, we
+        take any code point which contributed to the glyph in question, or any
+        subsequent glyph.  If we run off the end, then we take the last code
+        point.
+
+        Added LayoutTests/fast/text/international/khmar-selection.html
+
+        * platform/graphics/chromium/FontLinux.cpp:
+        (WebCore::Font::offsetForPositionForComplexText):
+
 2009-07-13  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Darin Adler.
index 2fc175504f1df58fd96d91b01e2d58ed0871b04b..e9884b6a515c98627a521f129e05b5c00543a381 100644 (file)
@@ -529,13 +529,19 @@ int Font::offsetForPositionForComplexText(const TextRun& run, int x,
             // code-point index. Because of ligatures, several code-points may
             // have gone into a single glyph. We iterate over the clusters log
             // and find the first code-point which contributed to the glyph.
+
+            // Some shapers (i.e. Khmer) will produce cluster logs which report
+            // that /no/ code points contributed to certain glyphs. Because of
+            // this, we take any code point which contributed to the glyph in
+            // question, or any subsequent glyph. If we run off the end, then
+            // we take the last code point.
             const unsigned short* log = walker.logClusters();
             for (unsigned j = 0; j < walker.numCodePoints(); ++j) {
-                if (log[j] == glyphIndex)
+                if (log[j] >= glyphIndex)
                     return basePosition + j;
             }
 
-            ASSERT_NOT_REACHED();
+            return basePosition + walker.numCodePoints() - 1;
         }
 
         x -= walker.width();