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
--- 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();