bug 745261 - check calls to SetupCairoFont for failure. r=jdaggett
authorJonathan Kew <jkew@mozilla.com>
Tue, 17 Apr 2012 09:50:26 +0100
changeset 95154 e5cd53eb0cf9d5af4bf620886fd198b6370848a9
parent 95153 eb4d4fc1f84f8f44f581f1628c5d4c85e07755c1
child 95155 993d0e9edd3f30122fad0bd27ffb280b02cca4b2
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs745261
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 745261 - check calls to SetupCairoFont for failure. r=jdaggett
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxGraphiteShaper.cpp
gfx/thebes/gfxHarfBuzzShaper.cpp
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2781,22 +2781,23 @@ gfxGlyphExtents::GetTightGlyphExtentsApp
 {
     HashEntry *entry = mTightGlyphExtents.GetEntry(aGlyphID);
     if (!entry) {
         if (!aContext) {
             NS_WARNING("Could not get glyph extents (no aContext)");
             return false;
         }
 
-        aFont->SetupCairoFont(aContext);
+        if (aFont->SetupCairoFont(aContext)) {
 #ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
-        ++gGlyphExtentsSetupLazyTight;
+            ++gGlyphExtentsSetupLazyTight;
 #endif
-        aFont->SetupGlyphExtents(aContext, aGlyphID, true, this);
-        entry = mTightGlyphExtents.GetEntry(aGlyphID);
+            aFont->SetupGlyphExtents(aContext, aGlyphID, true, this);
+            entry = mTightGlyphExtents.GetEntry(aGlyphID);
+        }
         if (!entry) {
             NS_WARNING("Could not get glyph extents");
             return false;
         }
     }
 
     *aExtents = gfxRect(entry->x, entry->y, entry->width, entry->height);
     return true;
@@ -5448,18 +5449,21 @@ gfxTextRun::FetchGlyphExtents(gfxContext
             const gfxTextRun::CompressedGlyph *glyphData = &charGlyphs[j];
             if (glyphData->IsSimpleGlyph()) {
                 // If we're in speed mode, don't set up glyph extents here; we'll
                 // just return "optimistic" glyph bounds later
                 if (needsGlyphExtents) {
                     PRUint32 glyphIndex = glyphData->GetSimpleGlyph();
                     if (!extents->IsGlyphKnown(glyphIndex)) {
                         if (!fontIsSetup) {
-                            font->SetupCairoFont(aRefContext);
-                             fontIsSetup = true;
+                            if (!font->SetupCairoFont(aRefContext)) {
+                                NS_WARNING("failed to set up font for glyph extents");
+                                break;
+                            }
+                            fontIsSetup = true;
                         }
 #ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
                         ++gGlyphExtentsSetupEagerSimple;
 #endif
                         font->SetupGlyphExtents(aRefContext, glyphIndex, false, extents);
                     }
                 }
             } else if (!glyphData->IsMissing()) {
@@ -5470,17 +5474,20 @@ gfxTextRun::FetchGlyphExtents(gfxContext
                 const gfxTextRun::DetailedGlyph *details = GetDetailedGlyphs(j);
                 if (!details) {
                     continue;
                 }
                 for (PRUint32 k = 0; k < glyphCount; ++k, ++details) {
                     PRUint32 glyphIndex = details->mGlyphID;
                     if (!extents->IsGlyphKnownWithTightExtents(glyphIndex)) {
                         if (!fontIsSetup) {
-                            font->SetupCairoFont(aRefContext);
+                            if (!font->SetupCairoFont(aRefContext)) {
+                                NS_WARNING("failed to set up font for glyph extents");
+                                break;
+                            }
                             fontIsSetup = true;
                         }
 #ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
                         ++gGlyphExtentsSetupEagerTight;
 #endif
                         font->SetupGlyphExtents(aRefContext, glyphIndex, true, extents);
                     }
                 }
--- a/gfx/thebes/gfxGraphiteShaper.cpp
+++ b/gfx/thebes/gfxGraphiteShaper.cpp
@@ -155,17 +155,19 @@ MakeGraphiteLangTag(PRUint32 aTag)
 }
 
 bool
 gfxGraphiteShaper::ShapeWord(gfxContext      *aContext,
                              gfxShapedWord   *aShapedWord,
                              const PRUnichar *aText)
 {
     // some font back-ends require this in order to get proper hinted metrics
-    mFont->SetupCairoFont(aContext);
+    if (!mFont->SetupCairoFont(aContext)) {
+        return false;
+    }
 
     mCallbackData.mContext = aContext;
 
     if (!mGrFont) {
         mGrFace = gr_make_face(&mCallbackData, GrGetTable, gr_face_default);
         if (!mGrFace) {
             return false;
         }
--- a/gfx/thebes/gfxHarfBuzzShaper.cpp
+++ b/gfx/thebes/gfxHarfBuzzShaper.cpp
@@ -850,17 +850,19 @@ static hb_font_funcs_t * sHBFontFuncs = 
 static hb_unicode_funcs_t * sHBUnicodeFuncs = nsnull;
 
 bool
 gfxHarfBuzzShaper::ShapeWord(gfxContext      *aContext,
                              gfxShapedWord   *aShapedWord,
                              const PRUnichar *aText)
 {
     // some font back-ends require this in order to get proper hinted metrics
-    mFont->SetupCairoFont(aContext);
+    if (!mFont->SetupCairoFont(aContext)) {
+        return false;
+    }
 
     if (!mHBFace) {
 
         mUseFontGlyphWidths = mFont->ProvidesGlyphWidths();
 
         // set up the harfbuzz face etc the first time we use the font
 
         if (!sHBFontFuncs) {