Bug 1090530 - Ensure that we unregister preference observers in nsPresContext unlink. r=roc

This commit is contained in:
John Schoenick 2014-10-29 13:24:02 -07:00
Родитель c33d0bc4e2
Коммит 1218c93b60
2 изменённых файлов: 26 добавлений и 26 удалений

Просмотреть файл

@ -252,24 +252,14 @@ nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
PR_INIT_CLIST(&mDOMMediaQueryLists);
}
nsPresContext::~nsPresContext()
void
nsPresContext::Destroy()
{
NS_PRECONDITION(!mShell, "Presshell forgot to clear our mShell pointer");
SetShell(nullptr);
NS_ABORT_IF_FALSE(PR_CLIST_IS_EMPTY(&mDOMMediaQueryLists),
"must not have media query lists left");
// Disconnect the refresh driver *after* the transition manager, which
// needs it.
if (mRefreshDriver && mRefreshDriver->PresContext() == this) {
mRefreshDriver->Disconnect();
}
if (mEventManager) {
// unclear if these are needed, but can't hurt
mEventManager->NotifyDestroyPresContext(this);
mEventManager->SetPresContext(nullptr);
mEventManager = nullptr;
}
if (mPrefChangedTimer)
@ -321,6 +311,24 @@ nsPresContext::~nsPresContext()
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
"nglayout.debug.paint_flashing_chrome",
this);
// Disconnect the refresh driver *after* the transition manager, which
// needs it.
if (mRefreshDriver && mRefreshDriver->PresContext() == this) {
mRefreshDriver->Disconnect();
mRefreshDriver = nullptr;
}
}
nsPresContext::~nsPresContext()
{
NS_PRECONDITION(!mShell, "Presshell forgot to clear our mShell pointer");
SetShell(nullptr);
NS_ABORT_IF_FALSE(PR_CLIST_IS_EMPTY(&mDOMMediaQueryLists),
"must not have media query lists left");
Destroy();
}
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPresContext)
@ -368,13 +376,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPresContext)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument);
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDeviceContext); // worth bothering?
if (tmp->mEventManager) {
// unclear if these are needed, but can't hurt
tmp->mEventManager->NotifyDestroyPresContext(tmp);
tmp->mEventManager->SetPresContext(nullptr);
tmp->mEventManager = nullptr;
}
// We own only the items in mDOMMediaQueryLists that have listeners;
// this reference is managed by their AddListener and RemoveListener
// methods.
@ -387,15 +388,11 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPresContext)
}
// NS_RELEASE(tmp->mLanguage); // an atom
// NS_IMPL_CYCLE_COLLECTION_UNLINK(mTheme); // a service
// NS_IMPL_CYCLE_COLLECTION_UNLINK(mLangService); // a service
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPrintSettings);
if (tmp->mPrefChangedTimer)
{
tmp->mPrefChangedTimer->Cancel();
tmp->mPrefChangedTimer = nullptr;
}
tmp->Destroy();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END

Просмотреть файл

@ -1172,6 +1172,9 @@ public:
#endif
protected:
// May be called multiple times (unlink, destructor)
void Destroy();
void InvalidatePaintedLayers();
void AppUnitsPerDevPixelChanged();