Bug 1451340 - Don't attempt to RegisterUnresolvedElement for native anonymous content;r=smaug draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Thu, 05 Apr 2018 12:01:18 -0700
changeset 778038 5226e5689195a047ebcb9903b4565df13b6b1aa0
parent 777437 c23c7481957f7b982cffc0ce1d25979c69ca2c2f
push id105375
push userbgrinstead@mozilla.com
push dateThu, 05 Apr 2018 19:01:39 +0000
reviewerssmaug
bugs1451340
milestone61.0a1
Bug 1451340 - Don't attempt to RegisterUnresolvedElement for native anonymous content;r=smaug The webconsole UI generates a large number of scrollbars, and considering their children as potential Custom Elements causes a slowdown when setting innerHTML="" when devtools closes. MozReview-Commit-ID: 2QCcXCnTHA2
dom/base/CustomElementRegistry.cpp
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -330,16 +330,22 @@ CustomElementRegistry::LookupCustomEleme
   MOZ_ASSERT(definition, "Definition must be found in mCustomDefinitions");
 
   return definition;
 }
 
 void
 CustomElementRegistry::RegisterUnresolvedElement(Element* aElement, nsAtom* aTypeName)
 {
+  // We don't have a use-case for a Custom Element inside NAC, and continuing
+  // here causes performance issues for NAC + XBL anonymous content.
+  if (aElement->IsInNativeAnonymousSubtree()) {
+    return;
+  }
+
   mozilla::dom::NodeInfo* info = aElement->NodeInfo();
 
   // Candidate may be a custom element through extension,
   // in which case the custom element type name will not
   // match the element tag name. e.g. <button is="x-button">.
   RefPtr<nsAtom> typeName = aTypeName;
   if (!typeName) {
     typeName = info->NameAtom();