From 6e8a858e66434f4d776d4c46f1deaa774f04e999 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 5 Jan 2020 15:59:26 -0500 Subject: 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 --- dom/base/nsContentUtils.cpp | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) (limited to 'dom/base/nsContentUtils.cpp') 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 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 doc = aDoc->MasterDocument(); - - if (!doc->GetDocShell()) { - return; - } - - nsCOMPtr window(doc->GetInnerWindow()); - if (!window) { - return; - } - - RefPtr 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 -- cgit v1.2.3