From 42331663e643b8366c4ec87a929161fa3fb8d775 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 5 Jan 2020 15:37:32 -0500 Subject: Bug 1392970 - Part 2: Get CustomElementDefinition from CustomElementData when possible. Tag UXP Issue #1344 --- dom/base/CustomElementRegistry.cpp | 65 +++++++++++++++----------------------- dom/base/nsContentUtils.cpp | 7 +--- 2 files changed, 26 insertions(+), 46 deletions(-) (limited to 'dom') diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index b752fdda7..1a4b5d45a 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -36,8 +36,19 @@ CustomElementCallback::Call() // enqueue attached callback for ELEMENT. nsIDocument* document = mThisObject->GetComposedDoc(); if (document && document->GetDocShell()) { + NodeInfo* ni = mThisObject->NodeInfo(); + nsDependentAtomString extType(mOwnerData->mType); + + // We need to do this because at this point, CustomElementDefinition is + // not set to CustomElementData yet, so EnqueueLifecycleCallback will + // fail to find the CE definition for this custom element. + // This will go away eventually since there is no created callback in v1. + CustomElementDefinition* definition = + nsContentUtils::LookupCustomElementDefinition(document, + ni->LocalName(), ni->NamespaceID(), + extType.IsEmpty() ? nullptr : &extType); nsContentUtils::EnqueueLifecycleCallback( - document, nsIDocument::eAttached, mThisObject); + document, nsIDocument::eAttached, mThisObject, nullptr, definition); } static_cast(mCallback.get())->Call(mThisObject, rv); @@ -324,51 +335,35 @@ CustomElementRegistry::CreateCustomElementCallback( nsIDocument::ElementCallbackType aType, Element* aCustomElement, LifecycleCallbackArgs* aArgs, CustomElementDefinition* aDefinition) { + MOZ_ASSERT(aDefinition, "CustomElementDefinition should not be null"); + RefPtr elementData = aCustomElement->GetCustomElementData(); MOZ_ASSERT(elementData, "CustomElementData should exist"); - // Let DEFINITION be ELEMENT's definition - CustomElementDefinition* definition = aDefinition; - if (!definition) { - mozilla::dom::NodeInfo* info = aCustomElement->NodeInfo(); - - // Make sure we get the correct definition in case the element - // is a extended custom element e.g.