tor-browser

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

commit 3031f3f7d434094f11a6bd61b1d7ceae18ba9958
parent 5f70dfd492a6ad71a774670170356565f300433a
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Sat,  1 Nov 2025 09:48:19 +0000

Bug 1997630 - Make frame constructor removal kind an enum class. r=layout-reviewers,dshin

No behavior change.

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

Diffstat:
Mlayout/base/PresShell.cpp | 2+-
Mlayout/base/nsCSSFrameConstructor.cpp | 19++++++++++---------
Mlayout/base/nsCSSFrameConstructor.h | 25++++++++++---------------
3 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp @@ -4713,7 +4713,7 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY void PresShell::ContentWillBeRemoved( } mFrameConstructor->ContentWillBeRemoved( - aChild, nsCSSFrameConstructor::REMOVE_CONTENT); + aChild, nsCSSFrameConstructor::RemovalKind::Dom); // NOTE(emilio): It's important that this goes after the frame constructor // stuff, otherwise the frame constructor can't see elements which are diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp @@ -7264,7 +7264,7 @@ static bool CanRemoveWrapperPseudoForChildRemoval(nsIFrame* aFrame, } bool nsCSSFrameConstructor::ContentWillBeRemoved(nsIContent* aChild, - RemoveFlags aFlags) { + RemovalKind aKind) { MOZ_ASSERT(aChild); MOZ_ASSERT( !aChild->IsRootOfNativeAnonymousSubtree() || !aChild->GetNextSibling(), @@ -7304,7 +7304,7 @@ bool nsCSSFrameConstructor::ContentWillBeRemoved(nsIContent* aChild, // We don't handle the fullscreen case here, because it doesn't change the // scrollbar styles override element stored on the prescontext.) const Element* removingElement = - aFlags == REMOVE_CONTENT ? aChild->AsElement() : nullptr; + aKind == RemovalKind::Dom ? aChild->AsElement() : nullptr; Element* newOverrideElement = presContext->UpdateViewportScrollStylesOverride(removingElement); @@ -7385,8 +7385,9 @@ bool nsCSSFrameConstructor::ContentWillBeRemoved(nsIContent* aChild, // FIXME(emilio, bug 1450366): We can make this faster without adding much // complexity for the display: none -> other case, which right now // unnecessarily walks the content tree down. - auto CouldHaveBeenDisplayContents = [aFlags](nsIContent* aContent) -> bool { - return aFlags == REMOVE_FOR_RECONSTRUCTION || IsDisplayContents(aContent); + auto CouldHaveBeenDisplayContents = [aKind](nsIContent* aContent) -> bool { + return aKind == RemovalKind::ForReconstruction || + IsDisplayContents(aContent); }; if (!childFrame && CouldHaveBeenDisplayContents(aChild)) { @@ -7408,7 +7409,7 @@ bool nsCSSFrameConstructor::ContentWillBeRemoved(nsIContent* aChild, } if (childFrame) { - if (aFlags == REMOVE_FOR_RECONSTRUCTION) { + if (aKind == RemovalKind::ForReconstruction) { // Before removing the frames associated with the content object, // ask them to save their state onto our state object. CaptureStateForFramesOf(aChild, mFrameTreeState); @@ -7451,7 +7452,7 @@ bool nsCSSFrameConstructor::ContentWillBeRemoved(nsIContent* aChild, } #ifdef ACCESSIBILITY - if (aFlags != REMOVE_FOR_RECONSTRUCTION) { + if (aKind != RemovalKind::ForReconstruction) { if (nsAccessibilityService* accService = GetAccService()) { accService->ContentRemoved(mPresShell, aChild); } @@ -7553,7 +7554,7 @@ bool nsCSSFrameConstructor::ContentWillBeRemoved(nsIContent* aChild, // If we're just reconstructing frames for the element, then the // following ContentInserted notification on the element will // take care of fixing up any adjacent text nodes. - if (aFlags == REMOVE_CONTENT) { + if (aKind == RemovalKind::Dom) { MOZ_ASSERT(aChild->GetParentNode(), "How did we have a sibling without a parent?"); // Adjacent whitespace-only text nodes might have been suppressed if @@ -8455,7 +8456,7 @@ void nsCSSFrameConstructor::RecreateFramesForContent( MOZ_ASSERT(aContent->GetParentNode()); const bool didReconstruct = - ContentWillBeRemoved(aContent, REMOVE_FOR_RECONSTRUCTION); + ContentWillBeRemoved(aContent, RemovalKind::ForReconstruction); if (!didReconstruct) { if (aInsertionKind == InsertionKind::Async && aContent->IsElement()) { @@ -8480,7 +8481,7 @@ void nsCSSFrameConstructor::RecreateFramesForContent( bool nsCSSFrameConstructor::DestroyFramesFor(nsIContent* aContent) { MOZ_ASSERT(aContent && aContent->GetParentNode()); - return ContentWillBeRemoved(aContent, REMOVE_FOR_RECONSTRUCTION); + return ContentWillBeRemoved(aContent, RemovalKind::ForReconstruction); } ////////////////////////////////////////////////////////////////////// diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h @@ -231,28 +231,26 @@ class nsCSSFrameConstructor final : public nsFrameManager { void ContentRangeInserted(nsIContent* aStartChild, nsIContent* aEndChild, InsertionKind aInsertionKind); - enum RemoveFlags { - REMOVE_CONTENT, - REMOVE_FOR_RECONSTRUCTION, + // The kind of removal we're dealing with. + enum class RemovalKind : uint8_t { + // The DOM node is getting removed from the document. + Dom, + // We're about to remove this frame, but we will insert it later. + ForReconstruction, }; /** * Recreate or destroy frames for aChild. * - * aFlags == REMOVE_CONTENT means aChild has been removed from the document. - * aFlags == REMOVE_FOR_RECONSTRUCTION means the caller will reconstruct the - * frames later. - * - * In both the above cases, this method will in some cases try to reconstruct - * frames on some ancestor of aChild. This can happen regardless of the value - * of aFlags. + * Regardless of the removal kind, this method will in some cases try to + * reconstruct frames on some ancestor of aChild. * * The return value indicates whether this "reconstruct an ancestor" action * took place. If true is returned, that means that the frame subtree rooted * at some ancestor of aChild's frame was destroyed and will be reconstructed * async. */ - bool ContentWillBeRemoved(nsIContent* aChild, RemoveFlags aFlags); + bool ContentWillBeRemoved(nsIContent* aChild, RemovalKind); void CharacterDataChanged(nsIContent* aContent, const CharacterDataChangeInfo& aInfo); @@ -1703,11 +1701,8 @@ class nsCSSFrameConstructor final : public nsFrameManager { /** * Recreate frames for aContent. - * @param aContent the content to recreate frames for - * @param aFlags normally you want to pass REMOVE_FOR_RECONSTRUCTION here */ - void RecreateFramesForContent(nsIContent* aContent, - InsertionKind aInsertionKind); + void RecreateFramesForContent(nsIContent* aContent, InsertionKind); /** * Handles change of rowspan and colspan attributes on table cells.