Bug 377976 - Check for null mDetailedGlyphs before referencing its members for missing CompressedGlyphs.p=Karl Tomlinson <mozbugz@karlt.net>r+sr=roc
authorasqueella@gmail.com
Fri, 04 May 2007 00:00:09 -0700
changeset 1079 bcfdee40fcb5e0f3e89892db235888de01226ddf
parent 1078 79d997bcdd0e228f7a0b774837b9101d28aafb77
child 1080 db8bad3308b0ffb118e323debbbc22d1ba764275
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs377976
milestone1.9a5pre
Bug 377976 - Check for null mDetailedGlyphs before referencing its members for missing CompressedGlyphs.p=Karl Tomlinson <mozbugz@karlt.net>r+sr=roc
gfx/thebes/src/gfxFont.cpp
--- a/gfx/thebes/src/gfxFont.cpp
+++ b/gfx/thebes/src/gfxFont.cpp
@@ -673,22 +673,23 @@ gfxTextRun::SetPotentialLineBreaks(PRUin
 }
 
 PRInt32
 gfxTextRun::ComputeClusterAdvance(PRUint32 aClusterOffset)
 {
     CompressedGlyph *glyphData = &mCharacterGlyphs[aClusterOffset];
     if (glyphData->IsSimpleGlyph())
         return glyphData->GetSimpleAdvance();
-    NS_ASSERTION(glyphData->IsComplexCluster(), "Unknown character type!");
-    NS_ASSERTION(mDetailedGlyphs, "Complex cluster but no details array!");
+
+    const DetailedGlyph *details = GetDetailedGlyphs(aClusterOffset);
+    if (!details)
+        return 0;
+
     PRInt32 advance = 0;
-    DetailedGlyph *details = mDetailedGlyphs[aClusterOffset];
-    NS_ASSERTION(details, "Complex cluster but no details!");
-    for (;;) {
+    while (1) {
         advance += details->mAdvance;
         if (details->mIsLastGlyph)
             return advance;
         ++details;
     }
 }
 
 gfxTextRun::LigatureData
@@ -765,27 +766,28 @@ gfxTextRun::GetAdjustedSpacing(PRUint32 
             CompressedGlyph *glyphData = &charGlyphs[i];
             
             if (glyphData->IsSimpleGlyph()) {
                 if (i > aStart) {
                     aSpacing[i - 1 - aStart].mAfter -= clusterWidth;
                 }
                 clusterWidth = glyphData->GetSimpleAdvance();
             } else if (glyphData->IsComplexOrMissing()) {
-                NS_ASSERTION(mDetailedGlyphs, "No details but we have a complex cluster...");
                 if (i > aStart) {
                     aSpacing[i - 1 - aStart].mAfter -= clusterWidth;
                 }
-                DetailedGlyph *details = mDetailedGlyphs[i];
                 clusterWidth = 0;
-                while (details) {
-                    clusterWidth += details->mAdvance;
-                    if (details->mIsLastGlyph)
-                        break;
-                    ++details;
+                const DetailedGlyph *details = GetDetailedGlyphs(i);
+                if (details) {
+                    while (1) {
+                        clusterWidth += details->mAdvance;
+                        if (details->mIsLastGlyph)
+                            break;
+                        ++details;
+                    }
                 }
             }
         }
         aSpacing[aEnd - 1 - aStart].mAfter -= clusterWidth;
     }
 
     // Move spacing inside a ligature to after the ligature.
     // Do this after adjusting for ABSOLUTE_SPACING above.
@@ -1247,23 +1249,24 @@ gfxTextRun::BreakAndMeasureText(PRUint32
             }
         }
         
         if (i >= ligatureRunStart && i < ligatureRunEnd) {
             CompressedGlyph *glyphData = &charGlyphs[i];
             if (glyphData->IsSimpleGlyph()) {
                 advance += glyphData->GetSimpleAdvance();
             } else if (glyphData->IsComplexOrMissing()) {
-                NS_ASSERTION(mDetailedGlyphs, "No details but we have a complex cluster...");
-                DetailedGlyph *details = mDetailedGlyphs[i];
-                while (details) {
-                    advance += details->mAdvance;
-                    if (details->mIsLastGlyph)
-                        break;
-                    ++details;
+                const DetailedGlyph *details = GetDetailedGlyphs(i);
+                if (details) {
+                    while (1) {
+                        advance += details->mAdvance;
+                        if (details->mIsLastGlyph)
+                            break;
+                        ++details;
+                    }
                 }
             }
             if (haveSpacing) {
                 PropertyProvider::Spacing *space = &spacingBuffer[i - bufferStart];
                 advance += space->mBefore + space->mAfter;
             }
         } else {
             advance += GetPartialLigatureWidth(i, i + 1, aProvider);
@@ -1342,22 +1345,24 @@ gfxTextRun::GetAdvanceWidth(PRUint32 aSt
               GetPartialLigatureWidth(ligatureRunEnd, aStart + aLength, aProvider);
 
     PRUint32 i;
     for (i = ligatureRunStart; i < ligatureRunEnd; ++i) {
         CompressedGlyph *glyphData = &charGlyphs[i];
         if (glyphData->IsSimpleGlyph()) {
             result += glyphData->GetSimpleAdvance();
         } else if (glyphData->IsComplexOrMissing()) {
-            DetailedGlyph *details = mDetailedGlyphs[i];
-            while (details) {
-                result += details->mAdvance;
-                if (details->mIsLastGlyph)
-                    break;
-                ++details;
+            const DetailedGlyph *details = GetDetailedGlyphs(i);
+            if (details) {
+                while (1) {
+                    result += details->mAdvance;
+                    if (details->mIsLastGlyph)
+                        break;
+                    ++details;
+                }
             }
         }
     }
 
     return result;
 }
 
 PRBool