summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-04 22:05:07 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:21 -0500
commite6733c9278d0e9687be83de5b5f409a43653fbee (patch)
treed65748f7a2825defe21ccf20b5db8aa7422623c9
parent6ff1c0c52fdf5f25e26ca65631e1b081f67ce1c2 (diff)
downloadUXP-e6733c9278d0e9687be83de5b5f409a43653fbee.tar
UXP-e6733c9278d0e9687be83de5b5f409a43653fbee.tar.gz
UXP-e6733c9278d0e9687be83de5b5f409a43653fbee.tar.lz
UXP-e6733c9278d0e9687be83de5b5f409a43653fbee.tar.xz
UXP-e6733c9278d0e9687be83de5b5f409a43653fbee.zip
Bug 1315885 - Part 3: Transfer the ownership of ReactionQueue's entry due to re-enter CustomElementReactionsStack::InvokeReactions.
Tag UXP Issue #1344
-rw-r--r--dom/base/CustomElementRegistry.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp
index 249162c38..6419c1425 100644
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -974,6 +974,7 @@ CustomElementReactionsStack::InvokeBackupQueue()
void
CustomElementReactionsStack::InvokeReactions(ElementQueue& aElementQueue)
{
+ // Note: It's possible to re-enter this method.
for (uint32_t i = 0; i < aElementQueue.Length(); ++i) {
nsCOMPtr<Element> element = do_QueryReferent(aElementQueue[i]);
@@ -984,10 +985,14 @@ CustomElementReactionsStack::InvokeReactions(ElementQueue& aElementQueue)
RefPtr<CustomElementData> elementData = element->GetCustomElementData();
MOZ_ASSERT(elementData, "CustomElementData should exist");
- nsTArray<nsAutoPtr<CustomElementReaction>>& reactions =
- elementData->mReactionQueue;
+ auto& reactions = elementData->mReactionQueue;
for (uint32_t j = 0; j < reactions.Length(); ++j) {
- reactions.ElementAt(j)->Invoke(element);
+ // Transfer the ownership of the entry due to reentrant invocation of
+ // this funciton. The entry will be removed when bug 1379573 is landed.
+ auto reaction(Move(reactions.ElementAt(j)));
+ if (reaction) {
+ reaction->Invoke(element);
+ }
}
reactions.Clear();
}