Bug 1296742 - Initialize gfxGDIFont's metrics at construction time, like other platform font subclasses, and remove its no-longer-needed support for init-on-first-use pattern. r=jrmuizel

This commit is contained in:
Jonathan Kew 2016-08-22 21:39:19 +01:00
parent ac04ca7f48
commit 993ba1a742
4 changed files with 3 additions and 26 deletions

View File

@ -41,10 +41,6 @@ public:
bool IsValid() const;
virtual gfxFloat GetAdjustedSize() const override {
return mAdjustedSize;
}
IDWriteFontFace *GetFontFace();
/* override Measure to add padding for antialiasing */

View File

@ -1433,7 +1433,7 @@ public:
return nullptr;
}
virtual gfxFloat GetAdjustedSize() const {
gfxFloat GetAdjustedSize() const {
return mAdjustedSize > 0.0
? mAdjustedSize
: (mStyle.sizeAdjust == 0.0 ? 0.0 : mStyle.size);

View File

@ -52,6 +52,7 @@ gfxGDIFont::gfxGDIFont(GDIFontEntry *aFontEntry,
mNeedsBold(aNeedsBold),
mScriptCache(nullptr)
{
Initialize();
}
gfxGDIFont::~gfxGDIFont()
@ -87,9 +88,6 @@ gfxGDIFont::ShapeText(DrawTarget *aDrawTarget,
bool aVertical,
gfxShapedText *aShapedText)
{
if (!mMetrics) {
Initialize();
}
if (!mIsValid) {
NS_WARNING("invalid font! expect incorrect text rendering");
return false;
@ -110,27 +108,18 @@ gfxGDIFont::ShapeText(DrawTarget *aDrawTarget,
const gfxFont::Metrics&
gfxGDIFont::GetHorizontalMetrics()
{
if (!mMetrics) {
Initialize();
}
return *mMetrics;
}
uint32_t
gfxGDIFont::GetSpaceGlyph()
{
if (!mMetrics) {
Initialize();
}
return mSpaceGlyph;
}
bool
gfxGDIFont::SetupCairoFont(DrawTarget* aDrawTarget)
{
if (!mMetrics) {
Initialize();
}
if (!mScaledFont ||
cairo_scaled_font_status(mScaledFont) != CAIRO_STATUS_SUCCESS) {
// Don't cairo_set_scaled_font as that would propagate the error to

View File

@ -26,15 +26,7 @@ public:
virtual ~gfxGDIFont();
HFONT GetHFONT() { if (!mMetrics) Initialize(); return mFont; }
virtual gfxFloat GetAdjustedSize()
{
if (!mMetrics) {
Initialize();
}
return mAdjustedSize;
}
HFONT GetHFONT() { return mFont; }
cairo_font_face_t *CairoFontFace() { return mFontFace; }
cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; }