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
--- 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);