mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 871961 pt 4 - on xpcom-shutdown notification, release any SVG-glyphs documents held by fonts. r=roc
This commit is contained in:
parent
01306365fd
commit
ed174bb5d0
@ -688,6 +688,15 @@ gfxFontEntry::ReleaseGrFace(gr_face *aFace)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxFontEntry::DisconnectSVG()
|
||||
{
|
||||
if (mSVGInitialized && mSVGGlyphs) {
|
||||
mSVGGlyphs = nullptr;
|
||||
mSVGInitialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxFontEntry::CheckForGraphiteTables()
|
||||
{
|
||||
@ -1393,20 +1402,10 @@ gfxFontCache::MemoryReporter::CollectReports
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Observer for the memory-pressure notification, to trigger
|
||||
// flushing of the shaped-word caches
|
||||
class MemoryPressureObserver MOZ_FINAL : public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS2(MemoryPressureObserver, nsIObserver, nsISupportsWeakReference)
|
||||
NS_IMPL_ISUPPORTS1(gfxFontCache::Observer, nsIObserver)
|
||||
|
||||
NS_IMETHODIMP
|
||||
MemoryPressureObserver::Observe(nsISupports *aSubject,
|
||||
gfxFontCache::Observer::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const PRUnichar *someData)
|
||||
{
|
||||
@ -1415,6 +1414,8 @@ MemoryPressureObserver::Observe(nsISupports *aSubject,
|
||||
if (fontCache) {
|
||||
fontCache->FlushShapedWordCaches();
|
||||
}
|
||||
} else {
|
||||
NS_NOTREACHED("unexpected notification topic");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1455,7 +1456,7 @@ gfxFontCache::gfxFontCache()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obs = GetObserverService();
|
||||
if (obs) {
|
||||
obs->AddObserver(new MemoryPressureObserver, "memory-pressure", false);
|
||||
obs->AddObserver(new Observer, "memory-pressure", false);
|
||||
}
|
||||
|
||||
mWordCacheExpirationTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "gfxPattern.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "gfxFontFeatures.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/gfx/Types.h"
|
||||
@ -400,6 +401,9 @@ public:
|
||||
gr_face* GetGrFace();
|
||||
virtual void ReleaseGrFace(gr_face* aFace);
|
||||
|
||||
// Release any SVG-glyphs document this font may have loaded.
|
||||
void DisconnectSVG();
|
||||
|
||||
// Called to notify that aFont is being destroyed. Needed when we're tracking
|
||||
// the fonts belonging to this font entry.
|
||||
void NotifyFontDestroyed(gfxFont* aFont);
|
||||
@ -951,6 +955,15 @@ protected:
|
||||
NS_DECL_NSIMEMORYREPORTER
|
||||
};
|
||||
|
||||
// Observer for notifications that the font cache cares about
|
||||
class Observer MOZ_FINAL
|
||||
: public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
};
|
||||
|
||||
void DestroyFont(gfxFont *aFont);
|
||||
|
||||
static gfxFontCache *gGlobalCache;
|
||||
|
@ -810,6 +810,14 @@ gfxUserFontSet::UserFontCache::Entry::RemoveIfPrivate(Entry* aEntry,
|
||||
return aEntry->mPrivate ? PL_DHASH_REMOVE : PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
PLDHashOperator
|
||||
gfxUserFontSet::UserFontCache::Entry::DisconnectSVG(Entry* aEntry,
|
||||
void* aUserData)
|
||||
{
|
||||
aEntry->GetFontEntry()->DisconnectSVG();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
gfxUserFontSet::UserFontCache::Flusher::Observe(nsISupports* aSubject,
|
||||
const char* aTopic,
|
||||
@ -823,6 +831,8 @@ gfxUserFontSet::UserFontCache::Flusher::Observe(nsISupports* aSubject,
|
||||
sUserFonts->Clear();
|
||||
} else if (!strcmp(aTopic, "last-pb-context-exited")) {
|
||||
sUserFonts->EnumerateEntries(Entry::RemoveIfPrivate, nullptr);
|
||||
} else if (!strcmp(aTopic, "xpcom-shutdown")) {
|
||||
sUserFonts->EnumerateEntries(Entry::DisconnectSVG, nullptr);
|
||||
} else {
|
||||
NS_NOTREACHED("unexpected topic");
|
||||
}
|
||||
@ -874,6 +884,7 @@ gfxUserFontSet::UserFontCache::CacheFont(gfxFontEntry *aFontEntry)
|
||||
obs->AddObserver(flusher, NS_CACHESERVICE_EMPTYCACHE_TOPIC_ID,
|
||||
false);
|
||||
obs->AddObserver(flusher, "last-pb-context-exited", false);
|
||||
obs->AddObserver(flusher, "xpcom-shutdown", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -346,6 +346,7 @@ public:
|
||||
gfxFontEntry* GetFontEntry() const { return mFontEntry; }
|
||||
|
||||
static PLDHashOperator RemoveIfPrivate(Entry* aEntry, void* aUserData);
|
||||
static PLDHashOperator DisconnectSVG(Entry* aEntry, void* aUserData);
|
||||
|
||||
private:
|
||||
static uint32_t
|
||||
|
Loading…
Reference in New Issue
Block a user