Bug 1536405 - Cycle-collect through ChromeEventHandler, r=bzbarsky

Differential Revision: https://phabricator.services.mozilla.com/D24422

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-03-22 23:35:15 +00:00
Родитель edf28c4d07
Коммит a39708b997
2 изменённых файлов: 8 добавлений и 7 удалений

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

@ -316,7 +316,6 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext)
mForcedCharset(nullptr),
mParentCharset(nullptr),
mTreeOwner(nullptr),
mChromeEventHandler(nullptr),
mDefaultScrollbarPref(Scrollbar_Auto, Scrollbar_Auto),
mCharsetReloadState(eCharsetReloadInit),
mOrientationLock(hal::eScreenOrientation_None),
@ -541,7 +540,7 @@ void nsDocShell::DestroyChildren() {
NS_IMPL_CYCLE_COLLECTION_INHERITED(nsDocShell, nsDocLoader,
mSessionStorageManager, mScriptGlobal,
mInitialClientSource, mSessionHistory,
mBrowsingContext)
mBrowsingContext, mChromeEventHandler)
NS_IMPL_ADDREF_INHERITED(nsDocShell, nsDocLoader)
NS_IMPL_RELEASE_INHERITED(nsDocShell, nsDocLoader)
@ -1141,7 +1140,6 @@ nsDocShell::GetOuterWindowID(uint64_t* aWindowID) {
NS_IMETHODIMP
nsDocShell::SetChromeEventHandler(EventTarget* aChromeEventHandler) {
// Weak reference. Don't addref.
mChromeEventHandler = aChromeEventHandler;
if (mScriptGlobal) {
@ -1154,7 +1152,7 @@ nsDocShell::SetChromeEventHandler(EventTarget* aChromeEventHandler) {
NS_IMETHODIMP
nsDocShell::GetChromeEventHandler(EventTarget** aChromeEventHandler) {
NS_ENSURE_ARG_POINTER(aChromeEventHandler);
nsCOMPtr<EventTarget> handler = mChromeEventHandler;
RefPtr<EventTarget> handler = mChromeEventHandler;
handler.forget(aChromeEventHandler);
return NS_OK;
}
@ -4199,7 +4197,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
errorPage.AssignLiteral("tabcrashed");
error = "tabcrashed";
nsCOMPtr<EventTarget> handler = mChromeEventHandler;
RefPtr<EventTarget> handler = mChromeEventHandler;
if (handler) {
nsCOMPtr<Element> element = do_QueryInterface(handler);
element->GetAttribute(NS_LITERAL_STRING("crashedPageTitle"), messageStr);
@ -4993,6 +4991,8 @@ nsDocShell::Destroy() {
mTabChild = nullptr;
mChromeEventHandler = nullptr;
mOnePermittedSandboxedNavigator = nullptr;
// required to break ref cycle

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

@ -1036,8 +1036,9 @@ class nsDocShell final : public nsDocLoader,
// Note these are intentionally not addrefd. Doing so will create a cycle.
// For that reasons don't use nsCOMPtr.
nsIDocShellTreeOwner* mTreeOwner; // Weak Reference
mozilla::dom::EventTarget* mChromeEventHandler; // Weak Reference
nsIDocShellTreeOwner* mTreeOwner; // Weak Reference
RefPtr<mozilla::dom::EventTarget> mChromeEventHandler;
nsIntPoint mDefaultScrollbarPref; // persistent across doc loads