summaryrefslogtreecommitdiffstats
path: root/dom/base/CustomElementRegistry.cpp
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-04 19:47:42 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:17 -0500
commita2c7b5f1d971cd529e65179ad97d39750e956644 (patch)
treeb9f2a279ba276dd4700f86075815d921d3b68df9 /dom/base/CustomElementRegistry.cpp
parent9d51b9d06a16b4725e4540a6424c71f6a1ee94c3 (diff)
downloadUXP-a2c7b5f1d971cd529e65179ad97d39750e956644.tar
UXP-a2c7b5f1d971cd529e65179ad97d39750e956644.tar.gz
UXP-a2c7b5f1d971cd529e65179ad97d39750e956644.tar.lz
UXP-a2c7b5f1d971cd529e65179ad97d39750e956644.tar.xz
UXP-a2c7b5f1d971cd529e65179ad97d39750e956644.zip
Bug 1325279 - Put the reaction queue in CustomElementData structure instead of using a map;
Bug 1347446 makes accessing ElementReactionQueue becomes a bit non-trival (have to get it via DocGroup). Since bug 1359346 already refactors the creation time of CustomElementData, ReactionQueue can also be put into CustomElementData, then we can just get ReactionQueue from Element. Tag UXP Issue #1344
Diffstat (limited to 'dom/base/CustomElementRegistry.cpp')
-rw-r--r--dom/base/CustomElementRegistry.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp
index 6c643d861..bd48f3c07 100644
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -933,23 +933,20 @@ void
CustomElementReactionsStack::Enqueue(Element* aElement,
CustomElementReaction* aReaction)
{
+ RefPtr<CustomElementData> elementData = aElement->GetCustomElementData();
+ MOZ_ASSERT(elementData, "CustomElementData should exist");
+
// Add element to the current element queue.
if (!mReactionsStack.IsEmpty()) {
mReactionsStack.LastElement().AppendElement(do_GetWeakReference(aElement));
- ReactionQueue* reactionQueue =
- mElementReactionQueueMap.LookupOrAdd(aElement);
- reactionQueue->AppendElement(aReaction);
-
+ elementData->mReactionQueue.AppendElement(aReaction);
return;
}
// If the custom element reactions stack is empty, then:
// Add element to the backup element queue.
mBackupQueue.AppendElement(do_GetWeakReference(aElement));
-
- ReactionQueue* reactionQueue =
- mElementReactionQueueMap.LookupOrAdd(aElement);
- reactionQueue->AppendElement(aReaction);
+ elementData->mReactionQueue.AppendElement(aReaction);
if (mIsBackupQueueProcessing) {
return;
@@ -980,16 +977,15 @@ CustomElementReactionsStack::InvokeReactions(ElementQueue& aElementQueue)
continue;
}
- nsAutoPtr<ReactionQueue> reactions;
- mElementReactionQueueMap.RemoveAndForget(element, reactions);
-
- MOZ_ASSERT(reactions,
- "Associated ReactionQueue must be found in mElementReactionQueueMap");
+ RefPtr<CustomElementData> elementData = element->GetCustomElementData();
+ MOZ_ASSERT(elementData, "CustomElementData should exist");
- for (uint32_t j = 0; j < reactions->Length(); ++j) {
- nsAutoPtr<CustomElementReaction>& reaction = reactions->ElementAt(j);
- reaction->Invoke(element);
+ nsTArray<nsAutoPtr<CustomElementReaction>>& reactions =
+ elementData->mReactionQueue;
+ for (uint32_t j = 0; j < reactions.Length(); ++j) {
+ reactions.ElementAt(j)->Invoke(element);
}
+ reactions.Clear();
}
aElementQueue.Clear();
}
@@ -997,7 +993,6 @@ CustomElementReactionsStack::InvokeReactions(ElementQueue& aElementQueue)
//-----------------------------------------------------
// CustomElementDefinition
-
CustomElementDefinition::CustomElementDefinition(nsIAtom* aType,
nsIAtom* aLocalName,
JSObject* aConstructor,