mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 12:13:22 +00: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
5e520616e5
commit
64135bae96
@ -566,6 +566,16 @@ gfxFontEntry::ReleaseGrFace(gr_face *aFace)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxFontEntry::DisconnectSVG()
|
||||
{
|
||||
if (mSVGGlyphs) {
|
||||
delete mSVGGlyphs;
|
||||
mSVGGlyphs = nullptr;
|
||||
mSVGInitialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxFontEntry::CheckForGraphiteTables()
|
||||
{
|
||||
@ -1270,20 +1280,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)
|
||||
{
|
||||
@ -1292,6 +1292,8 @@ MemoryPressureObserver::Observe(nsISupports *aSubject,
|
||||
if (fontCache) {
|
||||
fontCache->FlushShapedWordCaches();
|
||||
}
|
||||
} else {
|
||||
NS_NOTREACHED("unexpected notification topic");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1334,7 +1336,7 @@ gfxFontCache::gfxFontCache()
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = GetObserverService();
|
||||
if (obs) {
|
||||
obs->AddObserver(new MemoryPressureObserver, "memory-pressure", false);
|
||||
obs->AddObserver(new Observer, "memory-pressure", false);
|
||||
}
|
||||
|
||||
#if 0 // disabled due to crashiness, see bug 717175
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "gfxPattern.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "gfxFontFeatures.h"
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
@ -409,7 +410,10 @@ public:
|
||||
// Caller must call gfxFontEntry::ReleaseGrFace when finished with it.
|
||||
gr_face* GetGrFace();
|
||||
virtual void ReleaseGrFace(gr_face* aFace);
|
||||
|
||||
|
||||
// Release any SVG-glyphs document this font may have loaded.
|
||||
void DisconnectSVG();
|
||||
|
||||
// For memory reporting
|
||||
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
@ -963,6 +967,15 @@ protected:
|
||||
NS_DECL_NSIMEMORYMULTIREPORTER
|
||||
};
|
||||
|
||||
// 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;
|
||||
|
@ -759,6 +759,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,
|
||||
@ -772,6 +780,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");
|
||||
}
|
||||
@ -824,6 +834,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,6 +342,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…
x
Reference in New Issue
Block a user