b=455647 garbage Indic characters on parts of some English webpages. r=pavlov
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 29 Oct 2008 10:24:06 -0700
changeset 21055 8feeaada71ebae163b664c2ae7729619c13afe1a
parent 21054 d0bfac57c9edd5973adf453b9c7638420df273b4
child 21056 091abd0f3e24095b96c726f8b55ca5c75f25a592
push id3274
push userktomlinson@mozilla.com
push dateWed, 29 Oct 2008 17:24:14 +0000
treeherdermozilla-central@8feeaada71eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspavlov
bugs455647
milestone1.9.1b2pre
b=455647 garbage Indic characters on parts of some English webpages. r=pavlov
gfx/thebes/src/gfxFont.cpp
gfx/thebes/src/gfxPangoFonts.cpp
--- a/gfx/thebes/src/gfxFont.cpp
+++ b/gfx/thebes/src/gfxFont.cpp
@@ -2218,16 +2218,22 @@ gfxTextRun::SortGlyphRuns()
     // Now copy back, coalescing adjacent glyph runs that have the same font
     mGlyphRuns.Clear();
     PRUint32 i;
     for (i = 0; i < runs.Length(); ++i) {
         // a GlyphRun with the same font as the previous GlyphRun can just
         // be skipped; the last GlyphRun will cover its character range.
         if (i == 0 || runs[i].mFont != runs[i - 1].mFont) {
             mGlyphRuns.AppendElement(runs[i]);
+            // If two fonts have the same character offset, Sort() will have
+            // randomized the order.
+            NS_ASSERTION(i == 0 ||
+                         runs[i].mCharacterOffset !=
+                         runs[i - 1].mCharacterOffset,
+                         "Two fonts for the same run, glyph indices may not match the font");
         }
     }
 }
 
 PRUint32
 gfxTextRun::CountMissingGlyphs()
 {
     PRUint32 i;
--- a/gfx/thebes/src/gfxPangoFonts.cpp
+++ b/gfx/thebes/src/gfxPangoFonts.cpp
@@ -2216,17 +2216,17 @@ gfxPangoFontGroup::CreateGlyphRunsItemiz
 
             length -= aUTF8HeaderLen - offset;
             offset = aUTF8HeaderLen;
         }
 
         gfxFcFont *font =
             gfxPangoFcFont::GfxFont(GFX_PANGO_FC_FONT(item->analysis.font));
 
-        nsresult rv = aTextRun->AddGlyphRun(font, utf16Offset, PR_TRUE);
+        nsresult rv = aTextRun->AddGlyphRun(font, utf16Offset);
         if (NS_FAILED(rv)) {
             NS_ERROR("AddGlyphRun Failed");
             goto out;
         }
 
         PRUint32 spaceWidth =
             moz_pango_units_from_double(font->GetMetrics().spaceWidth);
 
@@ -2249,18 +2249,16 @@ gfxPangoFontGroup::CreateGlyphRunsItemiz
             gint len = p - text;
 
             pango_shape(text, len, &item->analysis, glyphString);
             SetupClusterBoundaries(aTextRun, text, len, utf16Offset, &item->analysis);
             SetGlyphs(aTextRun, text, len, &utf16Offset, glyphString, spaceWidth, PR_FALSE);
         }
     }
 
-    aTextRun->SortGlyphRuns();
-
 out:
     if (glyphString)
         pango_glyph_string_free(glyphString);
 
     for (pos = items; pos; pos = pos->next)
         pango_item_free((PangoItem *)pos->data);
 
     if (items)