Bug 282126 - Part 3: Don't compute ch to the average glyph width when there is no zero glyph. r=emilio draft
authorCameron McCormack <cam@mcc.id.au>
Wed, 20 Jun 2018 17:19:05 +1000
changeset 809794 39da73805b6f7821d19a07149bbecf61379a9b81
parent 809793 97c95948d8adb360217413b5d1d0374611918b9a
child 809795 65ac01ed3f628dd2d98f6ae1df0a1475b773ba74
push id113820
push userbmo:cam@mcc.id.au
push dateSat, 23 Jun 2018 03:01:03 +0000
reviewersemilio
bugs282126
milestone62.0a1
Bug 282126 - Part 3: Don't compute ch to the average glyph width when there is no zero glyph. r=emilio MozReview-Commit-ID: I5Sna6Af4HZ
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -2574,18 +2574,20 @@ Gecko_GetFontMetrics(RawGeckoPresContext
   nsPresContext* presContext = const_cast<nsPresContext*>(aPresContext);
   presContext->SetUsesExChUnits(true);
   RefPtr<nsFontMetrics> fm = nsLayoutUtils::GetMetricsFor(
       presContext, aIsVertical, aFont, aFontSize, aUseUserFontSet,
       nsLayoutUtils::FlushUserFontSet::No);
 
   ret.mXSize = fm->XHeight();
   gfxFloat zeroWidth = fm->GetThebesFontGroup()->GetFirstValidFont()->
-                           GetMetrics(fm->Orientation()).ZeroOrAveCharWidth();
-  ret.mChSize = ceil(aPresContext->AppUnitsPerDevPixel() * zeroWidth);
+                           GetMetrics(fm->Orientation()).zeroWidth;
+  ret.mChSize = zeroWidth >= 0.0
+    ? ceil(aPresContext->AppUnitsPerDevPixel() * zeroWidth)
+    : -1.0;
   return ret;
 }
 
 int32_t
 Gecko_GetAppUnitsPerPhysicalInch(RawGeckoPresContextBorrowed aPresContext)
 {
   nsPresContext* presContext = const_cast<nsPresContext*>(aPresContext);
   return presContext->DeviceContext()->AppUnitsPerPhysicalInch();
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -616,17 +616,17 @@ FontSizePrefs Gecko_GetBaseSize(nsAtom* 
 
 // XBL related functions.
 RawGeckoElementBorrowedOrNull Gecko_GetBindingParent(RawGeckoElementBorrowed aElement);
 RawServoAuthorStylesBorrowedOrNull Gecko_XBLBinding_GetRawServoStyles(RawGeckoXBLBindingBorrowed aXBLBinding);
 bool Gecko_XBLBinding_InheritsStyle(RawGeckoXBLBindingBorrowed aXBLBinding);
 
 struct GeckoFontMetrics
 {
-  nscoord mChSize;
+  nscoord mChSize;  // -1.0 indicates not found
   nscoord mXSize;
 };
 
 GeckoFontMetrics Gecko_GetFontMetrics(RawGeckoPresContextBorrowed pres_context,
                                       bool is_vertical,
                                       const nsStyleFont* font,
                                       nscoord font_size,
                                       bool use_user_font_set);