Bug 838105 - don't rely on key lookup to remove items from the user font cache, as the principal could have changed. r=jdaggett

This commit is contained in:
Jonathan Kew 2013-09-18 11:48:38 +01:00
parent 1069bab4a7
commit bdfea7f41f
2 changed files with 14 additions and 5 deletions

View File

@ -810,6 +810,14 @@ gfxUserFontSet::UserFontCache::Entry::RemoveIfPrivate(Entry* aEntry,
return aEntry->mPrivate ? PL_DHASH_REMOVE : PL_DHASH_NEXT;
}
PLDHashOperator
gfxUserFontSet::UserFontCache::Entry::RemoveIfMatches(Entry* aEntry,
void* aUserData)
{
return aEntry->GetFontEntry() == static_cast<gfxFontEntry*>(aUserData) ?
PL_DHASH_REMOVE : PL_DHASH_NEXT;
}
PLDHashOperator
gfxUserFontSet::UserFontCache::Entry::DisconnectSVG(Entry* aEntry,
void* aUserData)
@ -902,11 +910,11 @@ gfxUserFontSet::UserFontCache::ForgetFont(gfxFontEntry *aFontEntry)
return;
}
gfxUserFontData *data = aFontEntry->mUserFontData;
if (data) {
sUserFonts->RemoveEntry(Key(data->mURI, data->mPrincipal, aFontEntry,
data->mPrivate));
}
// We can't simply use RemoveEntry here because it's possible the principal
// may have changed since the font was cached, in which case the lookup
// would no longer find the entry (bug 838105).
sUserFonts->EnumerateEntries(
gfxUserFontSet::UserFontCache::Entry::RemoveIfMatches, aFontEntry);
}
gfxFontEntry*

View File

@ -346,6 +346,7 @@ public:
gfxFontEntry* GetFontEntry() const { return mFontEntry; }
static PLDHashOperator RemoveIfPrivate(Entry* aEntry, void* aUserData);
static PLDHashOperator RemoveIfMatches(Entry* aEntry, void* aUserData);
static PLDHashOperator DisconnectSVG(Entry* aEntry, void* aUserData);
private: