diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index 47601aabb0..99452df650 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -243,12 +243,11 @@ CustomElementRegistry::~CustomElementRegistry() } CustomElementDefinition* -CustomElementRegistry::LookupCustomElementDefinition(const nsAString& aLocalName, +CustomElementRegistry::LookupCustomElementDefinition(nsIAtom* aNameAtom, nsIAtom* aTypeAtom) const { - nsCOMPtr localNameAtom = NS_Atomize(aLocalName); CustomElementDefinition* data = mCustomDefinitions.GetWeak(aTypeAtom); - if (data && data->mLocalName == localNameAtom) { + if (data && data->mLocalName == aNameAtom) { return data; } diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index 01c32a5958..c416e50439 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -412,7 +412,7 @@ public: * https://html.spec.whatwg.org/#look-up-a-custom-element-definition */ CustomElementDefinition* LookupCustomElementDefinition( - const nsAString& aLocalName, nsIAtom* aTypeAtom) const; + nsIAtom* aNameAtom, nsIAtom* aTypeAtom) const; CustomElementDefinition* LookupCustomElementDefinition( JSContext* aCx, JSObject *aConstructor) const; diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 402dfd1c5b..b6cbbbacef 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -9536,9 +9536,11 @@ nsContentUtils::TryToUpgradeElement(Element* aElement) NodeInfo* nodeInfo = aElement->NodeInfo(); RefPtr typeAtom = aElement->GetCustomElementData()->GetCustomElementType(); + + MOZ_ASSERT(nodeInfo->NameAtom()->Equals(nodeInfo->LocalName())); CustomElementDefinition* definition = nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(), - nodeInfo->LocalName(), + nodeInfo->NameAtom(), nodeInfo->NamespaceID(), typeAtom); if (definition) { @@ -9553,7 +9555,7 @@ nsContentUtils::TryToUpgradeElement(Element* aElement) /* static */ CustomElementDefinition* nsContentUtils::LookupCustomElementDefinition(nsIDocument* aDoc, - const nsAString& aLocalName, + nsIAtom* aNameAtom, uint32_t aNameSpaceID, nsIAtom* aTypeAtom) { @@ -9577,7 +9579,7 @@ nsContentUtils::LookupCustomElementDefinition(nsIDocument* aDoc, return nullptr; } - return registry->LookupCustomElementDefinition(aLocalName, aTypeAtom); + return registry->LookupCustomElementDefinition(aNameAtom, aTypeAtom); } /* static */ void diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 4200a06213..bf6a59dcd9 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -2712,7 +2712,7 @@ public: */ static mozilla::dom::CustomElementDefinition* LookupCustomElementDefinition(nsIDocument* aDoc, - const nsAString& aLocalName, + nsIAtom* aNameAtom, uint32_t aNameSpaceID, nsIAtom* aTypeAtom); diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index f79da66523..384e56cde6 100644 --- a/dom/base/nsNodeUtils.cpp +++ b/dom/base/nsNodeUtils.cpp @@ -497,9 +497,11 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep, if (data || !extension.IsEmpty()) { RefPtr typeAtom = extension.IsEmpty() ? tagAtom : NS_Atomize(extension); cloneElem->SetCustomElementData(new CustomElementData(typeAtom)); + + MOZ_ASSERT(nodeInfo->NameAtom()->Equals(nodeInfo->LocalName())); CustomElementDefinition* definition = nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(), - nodeInfo->LocalName(), + nodeInfo->NameAtom(), nodeInfo->NamespaceID(), typeAtom); if (definition) { diff --git a/dom/html/nsHTMLContentSink.cpp b/dom/html/nsHTMLContentSink.cpp index 920ded728d..1fe5d2a865 100644 --- a/dom/html/nsHTMLContentSink.cpp +++ b/dom/html/nsHTMLContentSink.cpp @@ -287,9 +287,10 @@ NS_NewHTMLElement(Element** aResult, already_AddRefed&& CustomElementDefinition* definition = aDefinition; if (CustomElementRegistry::IsCustomElementEnabled() && isCustomElement && !definition) { + MOZ_ASSERT(nodeInfo->NameAtom()->Equals(nodeInfo->LocalName())); definition = nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(), - nodeInfo->LocalName(), + nodeInfo->NameAtom(), nodeInfo->NamespaceID(), typeAtom); } diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index d747f80a8a..22c8058595 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -433,8 +433,9 @@ nsHtml5TreeOperation::CreateHTMLElement( RefPtr typeAtom = isValue.IsEmpty() ? tagAtom : NS_Atomize(isValue); + MOZ_ASSERT(nodeInfo->NameAtom()->Equals(nodeInfo->LocalName())); definition = nsContentUtils::LookupCustomElementDefinition(document, - nodeInfo->LocalName(), nodeInfo->NamespaceID(), typeAtom); + nodeInfo->NameAtom(), nodeInfo->NamespaceID(), typeAtom); if (definition) { willExecuteScript = true;