mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Touch ups to gfxFontCache, for gfxFonts that are added twice and for those that are not accessed through AddNew() and Lookup(). b=401988, r+sr=roc
This commit is contained in:
parent
7d3543050f
commit
a662225a04
@ -356,6 +356,9 @@ class THEBES_API gfxFont {
|
||||
public:
|
||||
nsrefcnt AddRef(void) {
|
||||
NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");
|
||||
if (mExpirationState.IsTracked()) {
|
||||
gfxFontCache::GetCache()->RemoveObject(this);
|
||||
}
|
||||
++mRefCnt;
|
||||
NS_LOG_ADDREF(this, mRefCnt, "gfxFont", sizeof(*this));
|
||||
return mRefCnt;
|
||||
|
@ -118,9 +118,6 @@ gfxFontCache::Lookup(const nsAString &aName,
|
||||
|
||||
gfxFont *font = entry->mFont;
|
||||
NS_ADDREF(font);
|
||||
if (font->GetExpirationState()->IsTracked()) {
|
||||
RemoveObject(font);
|
||||
}
|
||||
return font;
|
||||
}
|
||||
|
||||
@ -131,15 +128,16 @@ gfxFontCache::AddNew(gfxFont *aFont)
|
||||
HashEntry *entry = mFonts.PutEntry(key);
|
||||
if (!entry)
|
||||
return;
|
||||
if (entry->mFont) {
|
||||
// This is weird. Someone's asking us to overwrite an existing font.
|
||||
// Oh well, make it happen ... just ensure that we're not tracking
|
||||
// the old font
|
||||
if (entry->mFont->GetExpirationState()->IsTracked()) {
|
||||
RemoveObject(entry->mFont);
|
||||
}
|
||||
}
|
||||
gfxFont *oldFont = entry->mFont;
|
||||
entry->mFont = aFont;
|
||||
// If someone's asked us to replace an existing font entry, then that's a
|
||||
// bit weird, but let it happen, and expire the old font if it's not used.
|
||||
if (oldFont && oldFont->GetExpirationState()->IsTracked()) {
|
||||
// if oldFont == aFont, recount should be > 0,
|
||||
// so we shouldn't be here.
|
||||
NS_ASSERTION(aFont != oldFont, "new font is tracked for expiry!");
|
||||
NotifyExpired(oldFont);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -168,7 +166,11 @@ void
|
||||
gfxFontCache::DestroyFont(gfxFont *aFont)
|
||||
{
|
||||
Key key(aFont->GetName(), aFont->GetStyle());
|
||||
mFonts.RemoveEntry(key);
|
||||
HashEntry *entry = mFonts.GetEntry(key);
|
||||
if (entry && entry->mFont == aFont)
|
||||
mFonts.RemoveEntry(key);
|
||||
NS_ASSERTION(aFont->GetRefCount() == 0,
|
||||
"Destroying with non-zero ref count!");
|
||||
delete aFont;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user