diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2020-01-05 15:59:26 -0500 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2020-01-26 15:50:29 -0500 |
commit | 3d4c4100912132141881f40e90ddbd3aba8b0737 (patch) | |
tree | 92a662145f0243654c42c8cf830cebf5df7aa30f /dom/base/CustomElementRegistry.cpp | |
parent | 186782301c03f4b27e4edae07b0280e92c4e01d1 (diff) | |
download | UXP-3d4c4100912132141881f40e90ddbd3aba8b0737.tar UXP-3d4c4100912132141881f40e90ddbd3aba8b0737.tar.gz UXP-3d4c4100912132141881f40e90ddbd3aba8b0737.tar.lz UXP-3d4c4100912132141881f40e90ddbd3aba8b0737.tar.xz UXP-3d4c4100912132141881f40e90ddbd3aba8b0737.zip |
Bug 1334043 - Part 2: Make nsContentUtils::EnqueueLifecycleCallback static.
We make nsContentUtils::EnqueueLifecycleCallback static so that it can be called without a window object. To achive this, we also make CustomElementReaction not taking a CustomElementRegistry in the constructor, as it can call Upgrade statically.
Tag UXP Issue #1344
Diffstat (limited to 'dom/base/CustomElementRegistry.cpp')
-rw-r--r-- | dom/base/CustomElementRegistry.cpp | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index efbad781f..67498a59b 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -47,7 +47,7 @@ CustomElementCallback::Call() ni->LocalName(), ni->NamespaceID(), extType.IsEmpty() ? nullptr : &extType); nsContentUtils::EnqueueLifecycleCallback( - document, nsIDocument::eConnected, mThisObject, nullptr, definition); + nsIDocument::eConnected, mThisObject, nullptr, definition); } static_cast<LifecycleCreatedCallback *>(mCallback.get())->Call(mThisObject, rv); @@ -329,7 +329,7 @@ CustomElementRegistry::SetupCustomElement(Element* aElement, // SyncInvokeReactions(nsIDocument::eCreated, aElement, definition); } -UniquePtr<CustomElementCallback> +/* static */ UniquePtr<CustomElementCallback> CustomElementRegistry::CreateCustomElementCallback( nsIDocument::ElementCallbackType aType, Element* aCustomElement, LifecycleCallbackArgs* aArgs, CustomElementDefinition* aDefinition) @@ -391,7 +391,7 @@ CustomElementRegistry::CreateCustomElementCallback( return Move(callback); } -void +/* static */ void CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType aType, Element* aCustomElement, LifecycleCallbackArgs* aArgs, @@ -412,7 +412,7 @@ CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType return; } - DocGroup* docGroup = mWindow->GetDocGroup(); + DocGroup* docGroup = aCustomElement->OwnerDoc()->GetDocGroup(); if (!docGroup) { return; } @@ -427,7 +427,7 @@ CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType CustomElementReactionsStack* reactionsStack = docGroup->CustomElementReactionsStack(); - reactionsStack->EnqueueCallbackReaction(this, aCustomElement, definition, + reactionsStack->EnqueueCallbackReaction(aCustomElement, definition, Move(callback)); } @@ -467,7 +467,7 @@ CustomElementRegistry::UpgradeCandidates(nsIAtom* aKey, continue; } - reactionsStack->EnqueueUpgradeReaction(this, elem, aDefinition); + reactionsStack->EnqueueUpgradeReaction(elem, aDefinition); } } } @@ -924,8 +924,7 @@ CustomElementRegistry::Upgrade(Element* aElement, (attrValue.IsEmpty() ? NullString() : attrValue), (namespaceURI.IsEmpty() ? NullString() : namespaceURI) }; - nsContentUtils::EnqueueLifecycleCallback(aElement->OwnerDoc(), - nsIDocument::eAttributeChanged, + nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eAttributeChanged, aElement, &args, aDefinition); } @@ -934,8 +933,7 @@ CustomElementRegistry::Upgrade(Element* aElement, // Step 4. if (aElement->IsInComposedDoc()) { - nsContentUtils::EnqueueLifecycleCallback(aElement->OwnerDoc(), - nsIDocument::eConnected, aElement, + nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eConnected, aElement, nullptr, aDefinition); } @@ -959,8 +957,7 @@ CustomElementRegistry::Upgrade(Element* aElement, aElement->SetCustomElementDefinition(aDefinition); // This is for old spec. - nsContentUtils::EnqueueLifecycleCallback(aElement->OwnerDoc(), - nsIDocument::eCreated, + nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eCreated, aElement, nullptr, aDefinition); } @@ -1004,20 +1001,18 @@ CustomElementReactionsStack::PopAndInvokeElementQueue() } void -CustomElementReactionsStack::EnqueueUpgradeReaction(CustomElementRegistry* aRegistry, - Element* aElement, +CustomElementReactionsStack::EnqueueUpgradeReaction(Element* aElement, CustomElementDefinition* aDefinition) { - Enqueue(aElement, new CustomElementUpgradeReaction(aRegistry, aDefinition)); + Enqueue(aElement, new CustomElementUpgradeReaction(aDefinition)); } void -CustomElementReactionsStack::EnqueueCallbackReaction(CustomElementRegistry* aRegistry, - Element* aElement, +CustomElementReactionsStack::EnqueueCallbackReaction(Element* aElement, CustomElementDefinition* aDefinition, UniquePtr<CustomElementCallback> aCustomElementCallback) { - Enqueue(aElement, new CustomElementCallbackReaction(aRegistry, aDefinition, + Enqueue(aElement, new CustomElementCallbackReaction(aDefinition, Move(aCustomElementCallback))); } @@ -1176,7 +1171,7 @@ CustomElementDefinition::CustomElementDefinition(nsIAtom* aType, /* virtual */ void CustomElementUpgradeReaction::Invoke(Element* aElement, ErrorResult& aRv) { - mRegistry->Upgrade(aElement, mDefinition, aRv); + CustomElementRegistry::Upgrade(aElement, mDefinition, aRv); } //----------------------------------------------------- |