diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index d47085f5da49..d1f6b65d875a 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -250,7 +250,7 @@ nsIBidiKeyboard *nsContentUtils::sBidiKeyboard = nullptr; uint32_t nsContentUtils::sScriptBlockerCount = 0; uint32_t nsContentUtils::sDOMNodeRemovedSuppressCount = 0; uint32_t nsContentUtils::sMicroTaskLevel = 0; -nsTArray< nsCOMPtr >* nsContentUtils::sBlockedScriptRunners = nullptr; +AutoTArray, 8>* nsContentUtils::sBlockedScriptRunners = nullptr; uint32_t nsContentUtils::sRunnersCountAtFirstBlocker = 0; nsIInterfaceRequestor* nsContentUtils::sSameOriginChecker = nullptr; @@ -534,7 +534,7 @@ nsContentUtils::Init() RegisterStrongMemoryReporter(new DOMEventListenerManagersHashReporter()); } - sBlockedScriptRunners = new nsTArray< nsCOMPtr >; + sBlockedScriptRunners = new AutoTArray, 8>; Preferences::AddBoolVarCache(&sAllowXULXBL_for_file, "dom.allow_XUL_XBL_for_file"); diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 214b2ed1f445..eae43320ed38 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -2658,7 +2658,7 @@ private: static uint32_t sDOMNodeRemovedSuppressCount; static uint32_t sMicroTaskLevel; // Not an nsCOMArray because removing elements from those is slower - static nsTArray< nsCOMPtr >* sBlockedScriptRunners; + static AutoTArray, 8>* sBlockedScriptRunners; static uint32_t sRunnersCountAtFirstBlocker; static uint32_t sScriptBlockerCountWhereRunnersPrevented; diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index ed0d4833496f..39c897568ccf 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -1809,6 +1809,13 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument) return NS_SUCCESS_INTERRUPTED_TRAVERSE; } + if (tmp->mMaybeEndOutermostXBLUpdateRunner) { + // The cached runnable keeps a reference to the document object.. + NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, + "mMaybeEndOutermostXBLUpdateRunner.mObj"); + cb.NoteXPCOMChild(ToSupports(tmp)); + } + for (auto iter = tmp->mIdentifierMap.ConstIter(); !iter.Done(); iter.Next()) { iter.Get()->Traverse(&cb); @@ -1959,6 +1966,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument) tmp->mCachedRootElement = nullptr; // Avoid a dangling pointer NS_IMPL_CYCLE_COLLECTION_UNLINK(mDisplayDocument) NS_IMPL_CYCLE_COLLECTION_UNLINK(mFirstBaseNodeWithHref) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mMaybeEndOutermostXBLUpdateRunner) NS_IMPL_CYCLE_COLLECTION_UNLINK(mDOMImplementation) NS_IMPL_CYCLE_COLLECTION_UNLINK(mImageMaps) NS_IMPL_CYCLE_COLLECTION_UNLINK(mCachedEncoder) @@ -4981,8 +4989,11 @@ nsDocument::MaybeEndOutermostXBLUpdate() mInXBLUpdate = false; BindingManager()->EndOutermostUpdate(); } else if (!mInDestructor) { - nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate)); + if (!mMaybeEndOutermostXBLUpdateRunner) { + mMaybeEndOutermostXBLUpdateRunner = + NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate); + } + nsContentUtils::AddScriptRunner(mMaybeEndOutermostXBLUpdateRunner); } } } diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h index 60f1237c6226..31c674693e94 100644 --- a/dom/base/nsDocument.h +++ b/dom/base/nsDocument.h @@ -1789,6 +1789,8 @@ private: nsTArray > mFrameLoaderFinalizers; RefPtr > mFrameLoaderRunner; + nsCOMPtr mMaybeEndOutermostXBLUpdateRunner; + nsRevocableEventPtr > mPendingTitleChangeEvent;