From cd6be07458e0f1e5191323ff4b2d578638aafe1e Mon Sep 17 00:00:00 2001 From: wuggy Date: Fri, 7 Aug 2026 13:13:43 -0700 Subject: [PATCH] Revert "Optimise WebExtension implementaion pt.1" This reverts commit 3be08bc94bf666c81d7b30c0ba042517169e5e6f. --- dom/base/CustomElementRegistry.cpp | 3 --- dom/base/CustomElementRegistry.h | 7 +------ dom/base/ShadowRoot.cpp | 31 +++++++++++++++++------------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index bb10f3ca80..11ba39a67e 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -1278,9 +1278,6 @@ CustomElementDefinition::CustomElementDefinition(nsIAtom* aType, mCallbacks(aCallbacks), mDocOrder(aDocOrder) { - for (uint32_t i = 0; i < mObservedAttributes.Length(); ++i) { - mObservedAttributesSet.PutEntry(mObservedAttributes[i]); - } } //----------------------------------------------------- diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index 53f58b5a9f..06e5947dbc 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -16,8 +16,6 @@ #include "mozilla/dom/WebComponentsBinding.h" #include "nsCycleCollectionParticipant.h" #include "nsGenericHTMLElement.h" -#include "nsHashKeys.h" -#include "nsTHashtable.h" #include "nsWrapperCache.h" class nsDocument; @@ -168,9 +166,6 @@ struct CustomElementDefinition // The list of attributes that this custom element observes. nsCOMArray mObservedAttributes; - // Hash set for O(1) lookup of observed attributes. - nsTHashtable mObservedAttributesSet; - // The prototype to use for new custom elements of this type. JS::Heap mPrototype; @@ -194,7 +189,7 @@ struct CustomElementDefinition return false; } - return mObservedAttributesSet.Contains(aName); + return mObservedAttributes.Contains(aName); } private: diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp index d2da59edbb..f2ae953a0e 100644 --- a/dom/base/ShadowRoot.cpp +++ b/dom/base/ShadowRoot.cpp @@ -136,7 +136,7 @@ ShadowRoot::AddSlot(HTMLSlotElement* aSlot) MOZ_ASSERT(aSlot); // Note that if name attribute missing, the slot is a default slot. - nsAutoString name; + nsAutoString name; aSlot->GetName(name); nsTArray* currentSlots = mSlotMap.LookupOrAdd(name); @@ -162,14 +162,25 @@ ShadowRoot::AddSlot(HTMLSlotElement* aSlot) oldSlot->RemoveAssignedNode(assignedNode); currentSlot->AppendAssignedNode(assignedNode); + + Element* restyleElement; + if (assignedNode->IsElement()) { + restyleElement = assignedNode->AsElement(); + } else { + // This is likely a text node. Use the host instead. + restyleElement = GetHost(); + } + if (restyleElement) { + nsLayoutUtils::PostRestyleEvent( + restyleElement, eRestyle_Subtree, nsChangeHint(0)); + } + doEnqueueSlotChange = true; } if (doEnqueueSlotChange) { oldSlot->EnqueueSlotChangeEvent(); currentSlot->EnqueueSlotChangeEvent(); - nsLayoutUtils::PostRestyleEvent( - GetHost(), eRestyle_Subtree, nsChangeHint(0)); } } else { // Otherwise add appropriate nodes to this slot from the host. @@ -464,10 +475,7 @@ ShadowRoot::MaybeReassignElement(Element* aElement, void ShadowRoot::DistributionChanged() { - if (mSlotMap.IsEmpty()) { - return; - } - + // FIXME(emilio): We could be more granular in a bunch of cases. auto* host = GetHost(); if (!host || !host->IsInComposedDoc()) { return; @@ -543,11 +551,8 @@ ShadowRoot::AttributeChanged(nsIDocument* aDocument, return; } - if (aElement->GetPrimaryFrame()) { - shell->DestroyFramesForAndRestyle(aElement); - } else { - nsLayoutUtils::PostRestyleEvent(aElement, eRestyle_Subtree, nsChangeHint(0)); - } + //XXX optimize this! + shell->DestroyFramesForAndRestyle(aElement); } void @@ -559,7 +564,7 @@ ShadowRoot::ContentAppended(nsIDocument* aDocument, for (nsIContent* content = aFirstNewContent; content; content = content->GetNextSibling()) { - ContentInserted(aDocument, aContainer, content, aNewIndexInContainer); + ContentInserted(aDocument, aContainer, aFirstNewContent, aNewIndexInContainer); } }