tor-browser

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

commit d90acdc399be472b62455d74cfe369b20963d700
parent 954449162966ffb0853b159c8bf5f1b5410b3344
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Mon,  5 Jan 2026 17:35:48 +0000

Bug 2008531 - Make nsIFrame::RemoveProperty return whether the property was removed. r=layout-reviewers,longsonr,dholbert

I was planning to use this for bug 1910616 but didn't need it in the
end. Still seems useful, so submitting it for review independently.

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

Diffstat:
Mlayout/base/FrameProperties.h | 19+++++++++++--------
Mlayout/generic/nsIFrame.h | 4++--
2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/layout/base/FrameProperties.h b/layout/base/FrameProperties.h @@ -220,11 +220,11 @@ class FrameProperties { /** * Remove and destroy a property value. This requires a linear search through * the properties of the frame. If the frame has no such property, nothing - * happens. + * happens and false is returned. */ template <typename T> - void Remove(Descriptor<T> aProperty, const nsIFrame* aFrame) { - RemoveInternal(aProperty, aFrame); + bool Remove(Descriptor<T> aProperty, const nsIFrame* aFrame) { + return RemoveInternal(aProperty, aFrame); } /** @@ -281,7 +281,8 @@ class FrameProperties { inline uint64_t TakeInternal(UntypedDescriptor aProperty, bool* aFoundResult); - inline void RemoveInternal(UntypedDescriptor aProperty, + // Returns whether the property was removed. + inline bool RemoveInternal(UntypedDescriptor aProperty, const nsIFrame* aFrame); template <typename T> @@ -416,16 +417,18 @@ inline uint64_t FrameProperties::TakeInternal(UntypedDescriptor aProperty, return result; } -inline void FrameProperties::RemoveInternal(UntypedDescriptor aProperty, +inline bool FrameProperties::RemoveInternal(UntypedDescriptor aProperty, const nsIFrame* aFrame) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aProperty, "Null property?"); auto index = mProperties.IndexOf(aProperty, 0, PropertyComparator()); - if (index != nsTArray<PropertyValue>::NoIndex) { - mProperties.Elements()[index].DestroyValueFor(aFrame); - mProperties.RemoveElementAtUnsafe(index); + if (index == nsTArray<PropertyValue>::NoIndex) { + return false; } + mProperties.Elements()[index].DestroyValueFor(aFrame); + mProperties.RemoveElementAtUnsafe(index); + return true; } } // namespace mozilla diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h @@ -4506,8 +4506,8 @@ class nsIFrame : public nsQueryFrame { } template <typename T> - void RemoveProperty(FrameProperties::Descriptor<T> aProperty) { - mProperties.Remove(aProperty, this); + bool RemoveProperty(FrameProperties::Descriptor<T> aProperty) { + return mProperties.Remove(aProperty, this); } /**