Backout f430bb8a0049 (bug 736010) due to Windows reftest orange.
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 30 Mar 2012 23:45:43 -0400
changeset 90769 031949d40753cf8678ca9492c165a2ca885f330f
parent 90768 839c971b90223c70db47d2ed06023fa7217d9df9
child 90770 1bdb337e3136c877e5d93b9c3ebac548bd7e4fff
push id22382
push userbmo@edmorley.co.uk
push dateSat, 31 Mar 2012 21:44:34 +0000
treeherdermozilla-central@bbe5086163c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs736010
milestone14.0a1
backs outf430bb8a0049068fb0e70658c0c935d2de7c4e08
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
Backout f430bb8a0049 (bug 736010) due to Windows reftest orange.
layout/mathml/nsMathMLChar.cpp
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -1036,45 +1036,35 @@ insert:
                      p_name - p_begin);
   }
   else { // whitespace or empty
     aFontName = aFallbackFamilies;
   }
 }
 
 // Update the font and rendering context if there is a family change
-static bool
+static void
 SetFontFamily(nsStyleContext*      aStyleContext,
               nsRenderingContext&  aRenderingContext,
               nsFont&              aFont,
               const nsGlyphTable*  aGlyphTable,
               const nsGlyphCode&   aGlyphCode,
               const nsAString&     aDefaultFamily)
 {
   const nsAString& family =
     aGlyphCode.font ? aGlyphTable->FontNameFor(aGlyphCode) : aDefaultFamily;
   if (! family.Equals(aFont.name)) {
-    nsFont font = aFont;
-    font.name = family;
+    aFont.name = family;
     nsRefPtr<nsFontMetrics> fm;
-    aRenderingContext.DeviceContext()->GetMetricsFor(font,
+    aRenderingContext.DeviceContext()->GetMetricsFor(aFont,
       aStyleContext->GetStyleFont()->mLanguage,
       aStyleContext->PresContext()->GetUserFontSet(),
       *getter_AddRefs(fm));
-    // Set the font if it is an unicode table
-    // or if the same family name has been found
-    if (aGlyphTable == &gGlyphTableList->mUnicodeTable ||
-        fm->GetThebesFontGroup()->GetFontAt(0)->GetFontEntry()->
-        FamilyName() == family) {
-      aFont.name = family;
-      aRenderingContext.SetFont(fm);
-    } else
-        return false; // We did not set the font
+    aRenderingContext.SetFont(fm);
   }
-  return true;
 }
 
 class nsMathMLChar::StretchEnumContext {
 public:
   StretchEnumContext(nsMathMLChar*        aChar,
                      nsPresContext*       aPresContext,
                      nsRenderingContext& aRenderingContext,
                      nsStretchDirection   aStretchDirection,
@@ -1094,16 +1084,19 @@ public:
       mTryVariants(true),
       mTryParts(true),
       mGlyphFound(aGlyphFound) {}
 
   static bool
   EnumCallback(const nsString& aFamily, bool aGeneric, void *aData);
 
 private:
+  static bool
+  ResolverCallback (const nsAString& aFamily, void *aData);
+
   bool TryVariants(nsGlyphTable* aGlyphTable, const nsAString& aFamily);
   bool TryParts(nsGlyphTable* aGlyphTable, const nsAString& aFamily);
 
   nsMathMLChar* mChar;
   nsPresContext* mPresContext;
   nsRenderingContext& mRenderingContext;
   const nsStretchDirection mDirection;
   const nscoord mTargetSize;
@@ -1152,22 +1145,17 @@ nsMathMLChar::StretchEnumContext::TryVar
 #ifdef NOISY_SEARCH
   printf("  searching in %s ...\n",
            NS_LossyConvertUTF16toASCII(aFamily).get());
 #endif
 
   nsGlyphCode ch;
   while ((ch = aGlyphTable->BigOf(mPresContext, mChar, size)).Exists()) {
 
-    if(!SetFontFamily(sc, mRenderingContext, font, aGlyphTable, ch, aFamily)) {
-      // if largeopOnly is set, break now
-      if (largeopOnly) break;
-      ++size;
-      continue;
-    }
+    SetFontFamily(sc, mRenderingContext, font, aGlyphTable, ch, aFamily);
 
     NS_ASSERTION(maxWidth || ch.code[0] != mChar->mGlyph.code[0] ||
                  ch.code[1] != mChar->mGlyph.code[1] ||
                  !font.name.Equals(mChar->mFamily),
                  "glyph table incorrectly set -- duplicate found");
 
     nsBoundingMetrics bm = mRenderingContext.GetBoundingMetrics(ch.code,
                                                                 ch.Length());
@@ -1281,20 +1269,18 @@ nsMathMLChar::StretchEnumContext::TryPar
     if (!ch.Exists()) ch = glue;
     chdata[i] = ch;
     if (!ch.Exists()) {
       // Null glue indicates that a rule will be drawn, which can stretch to
       // fill any space.  Leave bounding metrics at 0.
       sizedata[i] = mTargetSize;
     }
     else {
-      if (!SetFontFamily(mChar->mStyleContext, mRenderingContext,
-                         font, aGlyphTable, ch, aFamily))
-        return false;
-
+      SetFontFamily(mChar->mStyleContext, mRenderingContext,
+                    font, aGlyphTable, ch, aFamily);
       nsBoundingMetrics bm = mRenderingContext.GetBoundingMetrics(ch.code,
                                                                   ch.Length());
 
       // TODO: For the generic Unicode table, ideally we should check that the
       // glyphs are actually found and that they each come from the same
       // font.
       bmdata[i] = bm;
       sizedata[i] = isVertical ? bm.ascent + bm.descent
@@ -1379,16 +1365,48 @@ nsMathMLChar::StretchEnumContext::TryPar
   // reset
   mChar->mGlyph = kNullGlyph; // this will tell paint to build by parts
   mChar->mGlyphTable = aGlyphTable;
   mChar->mFamily = aFamily;
 
   return IsSizeOK(mPresContext, computedSize, mTargetSize, mStretchHint);
 }
 
+// This is only called for glyph table corresponding to a family that exists.
+// See if the table has a glyph that matches the container
+bool
+nsMathMLChar::StretchEnumContext::ResolverCallback (const nsAString& aFamily,
+                                                    void *aData)
+{
+  StretchEnumContext* context = static_cast<StretchEnumContext*>(aData);
+  nsGlyphTable* glyphTable = context->mGlyphTable;
+
+  // Only try this table once.
+  context->mTablesTried.AppendElement(glyphTable);
+
+  // If the unicode table is being used, then search all font families.  If a
+  // special table is being used then the font in this family should have the
+  // specified glyphs.
+  const nsAString& family = glyphTable == &gGlyphTableList->mUnicodeTable ?
+    context->mFamilies : aFamily;
+
+  if(context->mTryVariants) {
+    bool isOK = context->TryVariants(glyphTable, family);
+    if (isOK)
+      return false; // no need to continue
+  }
+
+  if(context->mTryParts) {
+    bool isOK = context->TryParts(glyphTable, family);
+    if (isOK)
+      return false; // no need to continue
+  }
+  return true;
+}
+
 // This is called for each family, whether it exists or not
 bool
 nsMathMLChar::StretchEnumContext::EnumCallback(const nsString& aFamily,
                                                bool aGeneric, void *aData)
 {
   StretchEnumContext* context = static_cast<StretchEnumContext*>(aData);
 
   // See if there is a special table for the family, but always use the
@@ -1396,32 +1414,24 @@ nsMathMLChar::StretchEnumContext::EnumCa
   nsGlyphTable* glyphTable = aGeneric ?
     &gGlyphTableList->mUnicodeTable : gGlyphTableList->GetGlyphTableFor(aFamily);
 
   if (context->mTablesTried.Contains(glyphTable))
     return true; // already tried this one
 
   context->mGlyphTable = glyphTable;
 
-  // Now see if the table has a glyph that matches the container
-
-  // Only try this table once.
-  context->mTablesTried.AppendElement(glyphTable);
+  if (aGeneric)
+    return ResolverCallback(aFamily, aData);
 
-  // If the unicode table is being used, then search all font families.  If a
-  // special table is being used then the font in this family should have the
-  // specified glyphs.
-  const nsAString& family = glyphTable == &gGlyphTableList->mUnicodeTable ?
-    context->mFamilies : aFamily;
-
-  if((context->mTryVariants && context->TryVariants(glyphTable, family)) ||
-     (context->mTryParts && context->TryParts(glyphTable, family)))
-    return false; // no need to continue
-
-  return true; // true means continue
+  bool aborted;
+  gfxPlatform *pf = gfxPlatform::GetPlatform();
+  nsresult rv =
+    pf->ResolveFontName(aFamily, ResolverCallback, aData, aborted);
+  return NS_SUCCEEDED(rv) && !aborted; // true means continue
 }
 
 nsresult
 nsMathMLChar::StretchInternal(nsPresContext*           aPresContext,
                               nsRenderingContext&     aRenderingContext,
                               nsStretchDirection&      aStretchDirection,
                               const nsBoundingMetrics& aContainerSize,
                               nsBoundingMetrics&       aDesiredStretchSize,