tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit a1993f4ba4da86b261dc2f9a883fb9b4ae655dee
parent 9f85cbd0235de94e712beeae9d6f56a0970cb785
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Sun, 21 Dec 2025 17:06:53 +0000

Bug 2007270 - Partially back out the regressing patch.

Differential Revision: https://phabricator.services.mozilla.com/D277296

Diffstat:
Mdom/base/CharacterData.cpp | 3+--
Mdom/base/Element.cpp | 3+--
Mdom/base/ShadowRoot.cpp | 15+++++----------
Mdom/base/ShadowRoot.h | 4+---
Mdom/base/nsIContent.h | 3+--
Mdom/base/nsIContentInlines.h | 5++---
6 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/dom/base/CharacterData.cpp b/dom/base/CharacterData.cpp @@ -457,8 +457,7 @@ void CharacterData::UnbindFromTree(UnbindContext& aContext) { UnsetFlags(NS_CREATE_FRAME_IF_NON_WHITESPACE | NS_REFRAME_IF_WHITESPACE); const bool nullParent = aContext.IsUnbindRoot(this); - HandleShadowDOMRelatedRemovalSteps(nullParent, - !!aContext.GetBatchRemovalState()); + HandleShadowDOMRelatedRemovalSteps(nullParent); if (nullParent) { if (GetParent()) { diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp @@ -2500,8 +2500,7 @@ static bool WillDetachFromShadowOnUnbind(const Element& aElement, void Element::UnbindFromTree(UnbindContext& aContext) { const bool nullParent = aContext.IsUnbindRoot(this); - HandleShadowDOMRelatedRemovalSteps(nullParent, - !!aContext.GetBatchRemovalState()); + HandleShadowDOMRelatedRemovalSteps(nullParent); if (HasFlag(ELEMENT_IN_CONTENT_IDENTIFIER_FOR_LCP)) { OwnerDoc()->ContentIdentifiersForLCP().Remove(this); diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp @@ -824,7 +824,7 @@ nsINode* ShadowRoot::CreateElementAndAppendChildAt(nsINode& aParentNode, return aParentNode.AppendChild(*node, rv); } -void ShadowRoot::MaybeUnslotHostChild(nsIContent& aChild, bool aInBatch) { +void ShadowRoot::MaybeUnslotHostChild(nsIContent& aChild) { // Need to null-check the host because we may be unlinked already. MOZ_ASSERT(!GetHost() || aChild.GetParent() == GetHost()); @@ -837,19 +837,14 @@ void ShadowRoot::MaybeUnslotHostChild(nsIContent& aChild, bool aInBatch) { "How did aChild end up assigned to a slot?"); // If the slot is going to start showing fallback content, we need to tell // layout about it. - if ((aInBatch || slot->AssignedNodes().Length() == 1) && - slot->HasChildren()) { + if (slot->AssignedNodes().Length() == 1 && slot->HasChildren()) { InvalidateStyleAndLayoutOnSubtree(slot); } slot->EnqueueSlotChangeEvent(); - if (aInBatch) { - slot->ClearAssignedNodes(); - } else { - slot->RemoveAssignedNode(aChild); - if (mIsDetailsShadowTree && aChild.IsHTMLElement(nsGkAtoms::summary)) { - MaybeReassignMainSummary(SummaryChangeReason::Deletion); - } + slot->RemoveAssignedNode(aChild); + if (mIsDetailsShadowTree && aChild.IsHTMLElement(nsGkAtoms::summary)) { + MaybeReassignMainSummary(SummaryChangeReason::Deletion); } } diff --git a/dom/base/ShadowRoot.h b/dom/base/ShadowRoot.h @@ -76,9 +76,7 @@ class ShadowRoot final : public DocumentFragment, public DocumentOrShadowRoot { void MaybeSlotHostChild(nsIContent&); // Called when a direct child of our host is removed. Tries to un-slot the // child from the currently-assigned slot, if any. - // If aInBatch is true, we know all the host kids are getting removed (and - // thus we can just unassign all the kids at once). - void MaybeUnslotHostChild(nsIContent&, bool aInBatch); + void MaybeUnslotHostChild(nsIContent&); // Shadow DOM v1 Element* Host() const { diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h @@ -388,8 +388,7 @@ class nsIContent : public nsINode { // Handles Shadow-DOM related state tracking. Meant to be called near the // beginning of UnbindFromTree(), before the node has lost the reference to // its parent. - inline void HandleShadowDOMRelatedRemovalSteps(bool aNullParent, - bool aInBatch); + inline void HandleShadowDOMRelatedRemovalSteps(bool aNullParent); public: /** diff --git a/dom/base/nsIContentInlines.h b/dom/base/nsIContentInlines.h @@ -251,8 +251,7 @@ inline void nsIContent::HandleShadowDOMRelatedInsertionSteps(bool aHadParent) { } } -inline void nsIContent::HandleShadowDOMRelatedRemovalSteps(bool aNullParent, - bool aInBatch) { +inline void nsIContent::HandleShadowDOMRelatedRemovalSteps(bool aNullParent) { using mozilla::dom::Element; using mozilla::dom::ShadowRoot; @@ -262,7 +261,7 @@ inline void nsIContent::HandleShadowDOMRelatedRemovalSteps(bool aNullParent, // (with already disconnected anonymous content subtrees). if (Element* parentElement = Element::FromNodeOrNull(mParent)) { if (ShadowRoot* shadow = parentElement->GetShadowRoot()) { - shadow->MaybeUnslotHostChild(*this, aInBatch); + shadow->MaybeUnslotHostChild(*this); } HandleInsertionToOrRemovalFromSlot(); }