Bug 541277: correct boundary handling in character/glyph clump processing. r=roc
authorJonathan Kew <jfkthame@gmail.com>
Wed, 27 Jan 2010 07:46:31 +0000
changeset 37533 263b6541c83fead708070cf98df0ee49bf4c79c4
parent 37532 764e41012ee811bbbe7485d5fd68c07180b0c09c
child 37534 f155f30508750f0856eabf2bc0934b6c4c8e2b2b
push id11362
push userjkew@mozilla.com
push dateWed, 27 Jan 2010 07:52:20 +0000
treeherdermozilla-central@263b6541c83f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs541277
milestone1.9.3a1pre
Bug 541277: correct boundary handling in character/glyph clump processing. r=roc
gfx/thebes/src/gfxCoreTextFonts.cpp
layout/generic/crashtests/541277-1.html
layout/generic/crashtests/541277-2.html
layout/generic/crashtests/crashtests.list
--- a/gfx/thebes/src/gfxCoreTextFonts.cpp
+++ b/gfx/thebes/src/gfxCoreTextFonts.cpp
@@ -444,19 +444,19 @@ gfxCoreTextFont::InitTextRun(gfxTextRun 
                 bidiWrap = PR_TRUE;
                 break;
             }
         }
     }
 
     // If there's a possibility of any bidi, we wrap the text with direction overrides
     // to ensure neutrals or characters that were bidi-overridden in HTML behave properly.
-    const UniChar beginLTR[]    = { 0x202d };
-    const UniChar beginRTL[]    = { 0x202e };
-    const UniChar endBidiWrap[] = { 0x202c };
+    const UniChar beginLTR[]    = { 0x202d, 0x20 };
+    const UniChar beginRTL[]    = { 0x202e, 0x20 };
+    const UniChar endBidiWrap[] = { 0x20, 0x202c };
 
     PRUint32 startOffset;
     CFStringRef stringObj;
     if (bidiWrap) {
         startOffset = isRTL ?
             sizeof(beginRTL) / sizeof(beginRTL[0]) : sizeof(beginLTR) / sizeof(beginLTR[0]);
         CFMutableStringRef mutableString =
             ::CFStringCreateMutable(kCFAllocatorDefault,
@@ -633,18 +633,16 @@ gfxCoreTextFont::SetGlyphsFromRun(gfxTex
     nsAutoTArray<PRInt32,SMALL_GLYPH_RUN> charToGlyphArray;
     if (!charToGlyphArray.SetLength(stringRange.length))
         return NS_ERROR_OUT_OF_MEMORY;
     PRInt32 *charToGlyph = charToGlyphArray.Elements();
     for (PRInt32 offset = 0; offset < stringRange.length; ++offset)
         charToGlyph[offset] = NO_GLYPH;
     for (PRInt32 g = 0; g < numGlyphs; ++g) {
         PRInt32 loc = glyphToChar[g] - stringRange.location;
-        if (loc == 0 && !isLTR)
-            ++loc; // avoid seeing initial surrogate char as "ligated" with direction override
         if (loc >= 0 && loc < stringRange.length) {
             charToGlyph[loc] = g;
         }
     }
 
     // Find character and glyph clumps that correspond, allowing for ligatures,
     // indic reordering, split glyphs, etc.
     //
new file mode 100644
--- /dev/null
+++ b/layout/generic/crashtests/541277-1.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+<span>&#xFBE4;</span><span>&#xFB4B;</span><span>&#xFBE6;</span>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/generic/crashtests/541277-2.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+&#x202E;X&#x200D; &#x5D60;
+</body>
+</html>
--- a/layout/generic/crashtests/crashtests.list
+++ b/layout/generic/crashtests/crashtests.list
@@ -280,8 +280,10 @@ load 505912-1.html
 load 509749-1.html
 load 511482.html
 load 513394-1.html
 load 514800-1.html
 load 517968.html
 load 520340.html
 load 533379-1.html
 load 533379-2.html
+load 541277-1.html
+load 541277-2.html