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 | 6e8a858e66434f4d776d4c46f1deaa774f04e999 (patch) | |
tree | 92a662145f0243654c42c8cf830cebf5df7aa30f /dom/base/nsContentUtils.cpp | |
parent | 8d579e8d4365c7182916c2474a5f0d144d63d571 (diff) | |
download | uxp-6e8a858e66434f4d776d4c46f1deaa774f04e999.tar.gz |
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 mcp-graveyard/UXP#1344
Diffstat (limited to 'dom/base/nsContentUtils.cpp')
-rw-r--r-- | dom/base/nsContentUtils.cpp | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index b029f97938..76171dda02 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -9661,48 +9661,30 @@ nsContentUtils::EnqueueUpgradeReaction(Element* aElement, MOZ_ASSERT(aElement); nsIDocument* doc = aElement->OwnerDoc(); - nsPIDOMWindowInner* window(doc->GetInnerWindow()); - if (!window) { - return; - } - RefPtr<CustomElementRegistry> registry(window->CustomElements()); - if (!registry) { + // No DocGroup means no custom element reactions stack. + if (!doc->GetDocGroup()) { return; } CustomElementReactionsStack* stack = doc->GetDocGroup()->CustomElementReactionsStack(); - stack->EnqueueUpgradeReaction(registry, aElement, aDefinition); + stack->EnqueueUpgradeReaction(aElement, aDefinition); } /* static */ void -nsContentUtils::EnqueueLifecycleCallback(nsIDocument* aDoc, - nsIDocument::ElementCallbackType aType, +nsContentUtils::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType aType, Element* aCustomElement, LifecycleCallbackArgs* aArgs, CustomElementDefinition* aDefinition) { - MOZ_ASSERT(aDoc); - - // To support imported document. - nsCOMPtr<nsIDocument> doc = aDoc->MasterDocument(); - - if (!doc->GetDocShell()) { - return; - } - - nsCOMPtr<nsPIDOMWindowInner> window(doc->GetInnerWindow()); - if (!window) { - return; - } - - RefPtr<CustomElementRegistry> registry(window->CustomElements()); - if (!registry) { + // No DocGroup means no custom element reactions stack. + if (!aCustomElement->OwnerDoc()->GetDocGroup()) { return; } - registry->EnqueueLifecycleCallback(aType, aCustomElement, aArgs, aDefinition); + CustomElementRegistry::EnqueueLifecycleCallback(aType, aCustomElement, aArgs, + aDefinition); } /* static */ void |