commit 1267c6b0ead221af0536ce633fba538ab265e784 parent 4ac7d1d31ca99ce850eb4af548864a3997a5371d Author: Jonathan Kew <jkew@mozilla.com> Date: Wed, 3 Dec 2025 19:47:26 +0000 Bug 2003765 - Use C++20's 'default' to implement simple comparison operators in /layout/. r=layout-reviewers,firefox-style-system-reviewers,emilio Just cleans up the code a bit; should not change any behavior. Differential Revision: https://phabricator.services.mozilla.com/D274907 Diffstat:
28 files changed, 77 insertions(+), 225 deletions(-)
diff --git a/layout/base/AnchorPositioningUtils.h b/layout/base/AnchorPositioningUtils.h @@ -33,16 +33,14 @@ struct AnchorPosInfo { class DistanceToNearestScrollContainer { public: - DistanceToNearestScrollContainer() : mDistance{kInvalid} {} + DistanceToNearestScrollContainer() = default; explicit DistanceToNearestScrollContainer(uint32_t aDistance) : mDistance{aDistance} {} + bool Valid() const { return mDistance != kInvalid; } - bool operator==(const DistanceToNearestScrollContainer& aOther) const { - return mDistance == aOther.mDistance; - } - bool operator!=(const DistanceToNearestScrollContainer& aOther) const { - return !(*this == aOther); - } + + bool operator==(const DistanceToNearestScrollContainer&) const = default; + bool operator!=(const DistanceToNearestScrollContainer&) const = default; private: // 0 is invalid - a frame itself cannot be its own nearest scroll container. @@ -51,7 +49,7 @@ class DistanceToNearestScrollContainer { // between abspos/fixedpos frames and their containing blocks are irrelevant, // so the distance should be measured from the out-of-flow frame, not the // placeholder frame. - uint32_t mDistance; + uint32_t mDistance = kInvalid; }; struct AnchorPosOffsetData { diff --git a/layout/base/RelativeTo.h b/layout/base/RelativeTo.h @@ -38,9 +38,7 @@ struct RelativeTo { // Choose ViewportType::Layout as the default as this is what the vast // majority of layout code deals with. ViewportType mViewportType = ViewportType::Layout; - bool operator==(const RelativeTo& aOther) const { - return mFrame == aOther.mFrame && mViewportType == aOther.mViewportType; - } + bool operator==(const RelativeTo&) const = default; friend std::ostream& operator<<(std::ostream& aOs, const RelativeTo& aR) { return aOs << "{" << aR.mFrame << ", " << (aR.mViewportType == ViewportType::Visual ? "visual" diff --git a/layout/base/ScrollStyles.h b/layout/base/ScrollStyles.h @@ -30,12 +30,9 @@ struct ScrollStyles { enum MapOverflowToValidScrollStyleTag { MapOverflowToValidScrollStyle }; ScrollStyles(const nsStyleDisplay&, MapOverflowToValidScrollStyleTag); - bool operator==(const ScrollStyles& aStyles) const { - return aStyles.mHorizontal == mHorizontal && aStyles.mVertical == mVertical; - } - bool operator!=(const ScrollStyles& aStyles) const { - return !(*this == aStyles); - } + bool operator==(const ScrollStyles&) const = default; + bool operator!=(const ScrollStyles&) const = default; + bool IsHiddenInBothDirections() const; }; diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h @@ -644,7 +644,7 @@ class nsCSSFrameConstructor final : public nsFrameManager { will set as the frame on the content. Guaranteed non-null. */ using FrameFullConstructor = - nsIFrame* (nsCSSFrameConstructor::*)(nsFrameConstructorState& aState, + nsIFrame* (nsCSSFrameConstructor::*)(nsFrameConstructorState & aState, FrameConstructionItem& aItem, nsContainerFrame* aParentFrame, const nsStyleDisplay* aStyleDisplay, @@ -928,9 +928,8 @@ class nsCSSFrameConstructor final : public nsFrameManager { MOZ_ASSERT(&mList == &aOther.mList, "Iterators for different lists?"); return mCurrent == aOther.mCurrent; } - bool operator!=(const Iterator& aOther) const { - return !(*this == aOther); - } + bool operator!=(const Iterator& aOther) const = default; + Iterator& operator=(const Iterator& aOther) { MOZ_ASSERT(&mList == &aOther.mList, "Iterators for different lists?"); mCurrent = aOther.mCurrent; diff --git a/layout/base/nsCaret.h b/layout/base/nsCaret.h @@ -145,10 +145,8 @@ class nsCaret final : public nsISelectionListener { CaretAssociationHint mHint{0}; mozilla::intl::BidiEmbeddingLevel mBidiLevel; - bool operator==(const CaretPosition& aOther) const { - return mContent == aOther.mContent && mOffset == aOther.mOffset && - mHint == aOther.mHint && mBidiLevel == aOther.mBidiLevel; - } + bool operator==(const CaretPosition& aOther) const = default; + explicit operator bool() const { return !!mContent; } }; diff --git a/layout/generic/AspectRatio.h b/layout/generic/AspectRatio.h @@ -121,13 +121,8 @@ struct AspectRatio { nscoord aRatioDeterminingSize, const LogicalSize& aContentBoxSizeToBoxSizingAdjust) const; - bool operator==(const AspectRatio& aOther) const { - return mRatio == aOther.mRatio && mUseBoxSizing == aOther.mUseBoxSizing; - } - - bool operator!=(const AspectRatio& aOther) const { - return !(*this == aOther); - } + bool operator==(const AspectRatio&) const = default; + bool operator!=(const AspectRatio&) const = default; bool operator<(const AspectRatio& aOther) const { MOZ_ASSERT( diff --git a/layout/generic/ReflowOutput.h b/layout/generic/ReflowOutput.h @@ -52,9 +52,7 @@ struct OverflowAreas { ScrollableOverflow().IsEqualEdges(aOther.ScrollableOverflow()); } - bool operator!=(const OverflowAreas& aOther) const { - return !(*this == aOther); - } + bool operator!=(const OverflowAreas&) const = default; OverflowAreas operator+(const nsPoint& aPoint) const { OverflowAreas result(*this); @@ -119,13 +117,8 @@ struct OverflowAreas { */ class CollapsingMargin final { public: - bool operator==(const CollapsingMargin& aOther) const { - return mMostPos == aOther.mMostPos && mMostNeg == aOther.mMostNeg; - } - - bool operator!=(const CollapsingMargin& aOther) const { - return !(*this == aOther); - } + bool operator==(const CollapsingMargin&) const = default; + bool operator!=(const CollapsingMargin&) const = default; void Include(nscoord aCoord) { if (aCoord > mMostPos) { diff --git a/layout/generic/RubyUtils.h b/layout/generic/RubyUtils.h @@ -143,14 +143,12 @@ struct MOZ_STACK_CLASS RubyColumn { return ret; } - friend bool operator==(const Iterator& aIter1, const Iterator& aIter2) { - MOZ_ASSERT(&aIter1.mColumn == &aIter2.mColumn, + bool operator==(const Iterator& aIter2) const { + MOZ_ASSERT(&mColumn == &aIter2.mColumn, "Should only compare iterators of the same ruby column"); - return aIter1.mIndex == aIter2.mIndex; - } - friend bool operator!=(const Iterator& aIter1, const Iterator& aIter2) { - return !(aIter1 == aIter2); + return mIndex == aIter2.mIndex; } + bool operator!=(const Iterator& aIter2) const = default; private: Iterator(const RubyColumn& aColumn, int32_t aIndex) diff --git a/layout/generic/ScrollSnapInfo.h b/layout/generic/ScrollSnapInfo.h @@ -32,9 +32,7 @@ struct SnapPoint { SnapPoint(Maybe<nscoord>&& aX, Maybe<nscoord>&& aY) : mX(std::move(aX)), mY(std::move(aY)) {} - bool operator==(const SnapPoint& aOther) const { - return mX == aOther.mX && mY == aOther.mY; - } + bool operator==(const SnapPoint&) const = default; Maybe<nscoord> mX; Maybe<nscoord> mY; @@ -44,14 +42,7 @@ struct ScrollSnapInfo { using ScrollDirection = layers::ScrollDirection; ScrollSnapInfo(); - bool operator==(const ScrollSnapInfo& aOther) const { - return mScrollSnapStrictnessX == aOther.mScrollSnapStrictnessX && - mScrollSnapStrictnessY == aOther.mScrollSnapStrictnessY && - mSnapTargets == aOther.mSnapTargets && - mXRangeWiderThanSnapport == aOther.mXRangeWiderThanSnapport && - mYRangeWiderThanSnapport == aOther.mYRangeWiderThanSnapport && - mSnapportSize == aOther.mSnapportSize; - } + bool operator==(const ScrollSnapInfo&) const = default; bool HasScrollSnapping() const; bool HasSnapPositions() const; @@ -86,11 +77,7 @@ struct ScrollSnapInfo { mScrollSnapStop(aScrollSnapStop), mTargetId(aTargetId) {} - bool operator==(const SnapTarget& aOther) const { - return mSnapPoint == aOther.mSnapPoint && mSnapArea == aOther.mSnapArea && - mScrollSnapStop == aOther.mScrollSnapStop && - mTargetId == aOther.mTargetId; - } + bool operator==(const SnapTarget& aOther) const = default; }; CopyableTArray<SnapTarget> mSnapTargets; @@ -112,10 +99,7 @@ struct ScrollSnapInfo { ScrollDirection mDirection; ScrollSnapTargetId mTargetId; - bool operator==(const ScrollSnapRange& aOther) const { - return mDirection == aOther.mDirection && mSnapArea == aOther.mSnapArea && - mTargetId == aOther.mTargetId; - } + bool operator==(const ScrollSnapRange& aOther) const = default; nscoord Start() const { return mDirection == ScrollDirection::eHorizontal ? mSnapArea.X() diff --git a/layout/generic/ScrollSnapTargetId.h b/layout/generic/ScrollSnapTargetId.h @@ -23,9 +23,7 @@ inline constexpr bool IsEnumCase(ScrollSnapTargetId) { return true; } struct ScrollSnapTargetIds { CopyableTArray<ScrollSnapTargetId> mIdsOnX; CopyableTArray<ScrollSnapTargetId> mIdsOnY; - bool operator==(const ScrollSnapTargetIds& aOther) const { - return mIdsOnX == aOther.mIdsOnX && mIdsOnY == aOther.mIdsOnY; - } + bool operator==(const ScrollSnapTargetIds&) const = default; }; struct SnapDestination { diff --git a/layout/generic/WritingModes.h b/layout/generic/WritingModes.h @@ -499,13 +499,8 @@ class WritingMode { /** * Compare two WritingModes for equality. */ - bool operator==(const WritingMode& aOther) const { - return mWritingMode == aOther.mWritingMode; - } - - bool operator!=(const WritingMode& aOther) const { - return mWritingMode != aOther.mWritingMode; - } + bool operator==(const WritingMode&) const = default; + bool operator!=(const WritingMode&) const = default; /** * Check whether two modes are orthogonal to each other. @@ -858,11 +853,7 @@ class LogicalPoint { CHECK_WRITING_MODE(aOther.GetWritingMode()); return mPoint == aOther.mPoint; } - - bool operator!=(const LogicalPoint& aOther) const { - CHECK_WRITING_MODE(aOther.GetWritingMode()); - return mPoint != aOther.mPoint; - } + bool operator!=(const LogicalPoint&) const = default; LogicalPoint operator+(const LogicalPoint& aOther) const { CHECK_WRITING_MODE(aOther.GetWritingMode()); @@ -1085,11 +1076,7 @@ class LogicalSize { CHECK_WRITING_MODE(aOther.GetWritingMode()); return mSize == aOther.mSize; } - - bool operator!=(const LogicalSize& aOther) const { - CHECK_WRITING_MODE(aOther.GetWritingMode()); - return mSize != aOther.mSize; - } + bool operator!=(const LogicalSize&) const = default; LogicalSize operator+(const LogicalSize& aOther) const { CHECK_WRITING_MODE(aOther.GetWritingMode()); @@ -1201,14 +1188,11 @@ struct LogicalSides final { mSides += aOther; return *this; } - bool operator==(LogicalSides aOther) const { + bool operator==(const LogicalSides& aOther) const { CHECK_WRITING_MODE(aOther.GetWritingMode()); return mSides == aOther.mSides; } - bool operator!=(LogicalSides aOther) const { - CHECK_WRITING_MODE(aOther.GetWritingMode()); - return !(*this == aOther); - } + bool operator!=(const LogicalSides&) const = default; #ifdef DEBUG WritingMode GetWritingMode() const { return mWritingMode; } @@ -1514,11 +1498,7 @@ class LogicalMargin { CHECK_WRITING_MODE(aMargin.GetWritingMode()); return mMargin == aMargin.mMargin; } - - bool operator!=(const LogicalMargin& aMargin) const { - CHECK_WRITING_MODE(aMargin.GetWritingMode()); - return mMargin != aMargin.mMargin; - } + bool operator!=(const LogicalMargin&) const = default; LogicalMargin operator+(const LogicalMargin& aMargin) const { CHECK_WRITING_MODE(aMargin.GetWritingMode()); diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp @@ -1416,13 +1416,8 @@ void nsBlockFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics, int32_t mOffset = -1; nscoord mBlockCoord = 0; - bool operator==(const BalanceTarget& aOther) const { - return mContent == aOther.mContent && mOffset == aOther.mOffset && - mBlockCoord == aOther.mBlockCoord; - } - bool operator!=(const BalanceTarget& aOther) const { - return !(*this == aOther); - } + bool operator==(const BalanceTarget& aOther) const = default; + bool operator!=(const BalanceTarget& aOther) const = default; }; BalanceTarget balanceTarget; diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp @@ -1870,12 +1870,7 @@ class nsFlexContainerFrame::CachedBAxisMeasurement { mComputedMaxBSize(aRI.ComputedMaxBSize()), mAvailableBSize(aRI.AvailableBSize()) {} - bool operator==(const Key& aOther) const { - return mComputedSize == aOther.mComputedSize && - mComputedMinBSize == aOther.mComputedMinBSize && - mComputedMaxBSize == aOther.mComputedMaxBSize && - mAvailableBSize == aOther.mAvailableBSize; - } + bool operator==(const Key& aOther) const = default; }; const Key mKey; diff --git a/layout/generic/nsFrameList.h b/layout/generic/nsFrameList.h @@ -401,13 +401,8 @@ class nsFrameList { return ret; } - bool operator==(const Iterator<FrameTraversal>& aOther) const { - return mCurrent == aOther.mCurrent; - } - - bool operator!=(const Iterator<FrameTraversal>& aOther) const { - return !(*this == aOther); - } + bool operator==(const Iterator<FrameTraversal>& aOther) const = default; + bool operator!=(const Iterator<FrameTraversal>& aOther) const = default; private: nsIFrame* mCurrent; diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp @@ -315,11 +315,7 @@ class nsGridContainerFrame::CachedBAxisMeasurement final { aFrame->GetProperty(nsIFrame::BBaselinePadProperty()); } - bool operator==(const Key& aOther) const { - return mCBSizeInItemInlineAxis == aOther.mCBSizeInItemInlineAxis && - mBaselinePaddingInItemBlockAxis == - aOther.mBaselinePaddingInItemBlockAxis; - } + bool operator==(const Key& aOther) const = default; }; Key mKey; diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h @@ -423,10 +423,8 @@ struct IntrinsicSize { } } - bool operator==(const IntrinsicSize& rhs) const { - return width == rhs.width && height == rhs.height; - } - bool operator!=(const IntrinsicSize& rhs) const { return !(*this == rhs); } + bool operator==(const IntrinsicSize&) const = default; + bool operator!=(const IntrinsicSize&) const = default; }; // Pseudo bidi embedding level indicating nonexistence. @@ -5250,13 +5248,8 @@ class nsIFrame : public nsQueryFrame { uint8_t mTop; uint8_t mRight; uint8_t mBottom; - bool operator==(const InkOverflowDeltas& aOther) const { - return mLeft == aOther.mLeft && mTop == aOther.mTop && - mRight == aOther.mRight && mBottom == aOther.mBottom; - } - bool operator!=(const InkOverflowDeltas& aOther) const { - return !(*this == aOther); - } + bool operator==(const InkOverflowDeltas& aOther) const = default; + bool operator!=(const InkOverflowDeltas& aOther) const = default; }; enum class OverflowStorageType : uint32_t { // No overflow area; code relies on this being an all-zero value. diff --git a/layout/generic/nsLineBox.h b/layout/generic/nsLineBox.h @@ -703,12 +703,7 @@ class GenericLineListIterator { "comparing iterators over different lists"); return mCurrent == aOther.mCurrent; } - bool operator!=(const self_type& aOther) const { - MOZ_ASSERT(mListLink); - MOZ_ASSERT(mListLink == aOther.mListLink, - "comparing iterators over different lists"); - return mCurrent != aOther.mCurrent; - } + bool operator!=(const self_type&) const = default; #ifdef DEBUG bool IsInSameList(const self_type& aOther) const { diff --git a/layout/generic/nsTextFrame.h b/layout/generic/nsTextFrame.h @@ -982,19 +982,8 @@ class nsTextFrame : public nsIFrame { LineDecoration(const LineDecoration& aOther) = default; - bool operator==(const LineDecoration& aOther) const { - return mFrame == aOther.mFrame && mStyle == aOther.mStyle && - mColor == aOther.mColor && - mBaselineOffset == aOther.mBaselineOffset && - mTextUnderlinePosition == aOther.mTextUnderlinePosition && - mTextUnderlineOffset == aOther.mTextUnderlineOffset && - mTextDecorationThickness == aOther.mTextDecorationThickness && - mAllowInkSkipping == aOther.mAllowInkSkipping; - } - - bool operator!=(const LineDecoration& aOther) const { - return !(*this == aOther); - } + bool operator==(const LineDecoration& aOther) const = default; + bool operator!=(const LineDecoration& aOther) const = default; }; struct TextDecorations { AutoTArray<LineDecoration, 1> mOverlines, mUnderlines, mStrikes; @@ -1007,13 +996,8 @@ class nsTextFrame : public nsIFrame { bool HasUnderline() const { return !mUnderlines.IsEmpty(); } bool HasOverline() const { return !mOverlines.IsEmpty(); } bool HasStrikeout() const { return !mStrikes.IsEmpty(); } - bool operator==(const TextDecorations& aOther) const { - return mOverlines == aOther.mOverlines && - mUnderlines == aOther.mUnderlines && mStrikes == aOther.mStrikes; - } - bool operator!=(const TextDecorations& aOther) const { - return !(*this == aOther); - } + bool operator==(const TextDecorations& aOther) const = default; + bool operator!=(const TextDecorations& aOther) const = default; }; enum TextDecorationColorResolution { eResolvedColors, eUnresolvedColors }; void GetTextDecorations(nsPresContext* aPresContext, diff --git a/layout/mathml/nsMathMLChar.h b/layout/mathml/nsMathMLChar.h @@ -71,7 +71,7 @@ struct nsGlyphCode { (!IsGlyphID() && other.code[0] == code[0] && other.code[1] == code[1]))); } - bool operator!=(const nsGlyphCode& other) const { return !operator==(other); } + bool operator!=(const nsGlyphCode&) const = default; }; // Class used to handle stretchy symbols (accent, delimiter and boundary diff --git a/layout/painting/BorderCache.h b/layout/painting/BorderCache.h @@ -33,10 +33,7 @@ struct FourFloats { n[3] = d; } - bool operator==(const FourFloats& aOther) const { - return n[0] == aOther.n[0] && n[1] == aOther.n[1] && n[2] == aOther.n[2] && - n[3] == aOther.n[3]; - } + bool operator==(const FourFloats&) const = default; }; class FourFloatsHashKey : public PLDHashEntryHdr { diff --git a/layout/painting/RetainedDisplayListHelpers.h b/layout/painting/RetainedDisplayListHelpers.h @@ -15,9 +15,7 @@ class nsIFrame; namespace mozilla { struct DisplayItemKey { - bool operator==(const DisplayItemKey& aOther) const { - return mFrame == aOther.mFrame && mPerFrameKey == aOther.mPerFrameKey; - } + bool operator==(const DisplayItemKey&) const = default; nsIFrame* mFrame; uint32_t mPerFrameKey; @@ -64,17 +62,15 @@ class MergedListUnits {}; template <typename Units> struct Index { - Index() : val(0) {} + Index() = default; explicit Index(size_t aVal) : val(aVal) { MOZ_RELEASE_ASSERT(aVal < std::numeric_limits<uint32_t>::max(), "List index overflowed"); } - bool operator==(const Index<Units>& aOther) const { - return val == aOther.val; - } + bool operator==(const Index<Units>&) const = default; - uint32_t val; + uint32_t val = 0; }; typedef Index<OldListUnits> OldListIndex; typedef Index<MergedListUnits> MergedListIndex; diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h @@ -3162,13 +3162,8 @@ struct LinkedListIterator { return *this; } - bool operator==(const LinkedListIterator<T>& aOther) const { - return mNode == aOther.mNode; - } - - bool operator!=(const LinkedListIterator<T>& aOther) const { - return mNode != aOther.mNode; - } + bool operator==(const LinkedListIterator<T>&) const = default; + bool operator!=(const LinkedListIterator<T>&) const = default; const T operator*() const { MOZ_ASSERT(mNode); diff --git a/layout/style/CSSPropertyId.h b/layout/style/CSSPropertyId.h @@ -63,12 +63,9 @@ struct CSSPropertyId { RefPtr<nsAtom> mCustomName; bool IsCustom() const { return mId == eCSSPropertyExtra_variable; } - bool operator==(const CSSPropertyId& aOther) const { - return mId == aOther.mId && mCustomName == aOther.mCustomName; - } - bool operator!=(const CSSPropertyId& aOther) const { - return !(*this == aOther); - } + + bool operator==(const CSSPropertyId&) const = default; + bool operator!=(const CSSPropertyId&) const = default; bool IsValid() const { if (mId == eCSSProperty_UNKNOWN) { diff --git a/layout/style/PseudoStyleType.h b/layout/style/PseudoStyleType.h @@ -148,9 +148,7 @@ struct PseudoStyleRequest { PseudoStyleRequest(PseudoStyleType aType, nsAtom* aIdentifier) : mType(aType), mIdentifier(aIdentifier) {} - bool operator==(const PseudoStyleRequest& aOther) const { - return mType == aOther.mType && mIdentifier == aOther.mIdentifier; - } + bool operator==(const PseudoStyleRequest&) const = default; bool IsNotPseudo() const { return mType == PseudoStyleType::NotPseudo; } bool IsPseudoElementOrNotPseudo() const { diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h @@ -86,9 +86,9 @@ class nsCSSValue { nsCSSValue& operator=(const nsCSSValue& aCopy); nsCSSValue& operator=(nsCSSValue&& aCopy); - bool operator==(const nsCSSValue& aOther) const; - bool operator!=(const nsCSSValue& aOther) const { return !(*this == aOther); } + bool operator==(const nsCSSValue& aOther) const; + bool operator!=(const nsCSSValue&) const = default; nsCSSUnit GetUnit() const { return mUnit; } bool IsLengthUnit() const { diff --git a/layout/style/nsStyleAutoArray.h b/layout/style/nsStyleAutoArray.h @@ -44,9 +44,7 @@ class nsStyleAutoArray { mFirstElement == aOther.mFirstElement && mOtherElements == aOther.mOtherElements; } - bool operator!=(const nsStyleAutoArray& aOther) const { - return !(*this == aOther); - } + bool operator!=(const nsStyleAutoArray&) const = default; size_t Length() const { return mOtherElements.Length() + 1; } const T& operator[](size_t aIndex) const { diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h @@ -86,10 +86,7 @@ struct ContainSizeAxes { bool IsBoth() const { return mIContained && mBContained; } bool IsAny() const { return mIContained || mBContained; } - bool operator==(const ContainSizeAxes& aOther) const { - return mIContained == aOther.mIContained && - mBContained == aOther.mBContained; - } + bool operator==(const ContainSizeAxes&) const = default; /** * Return a contained size from an uncontained size. @@ -214,10 +211,8 @@ struct nsStyleImageLayers { mYRepeat == mozilla::StyleImageLayerRepeat::Space; } - bool operator==(const Repeat& aOther) const { - return mXRepeat == aOther.mXRepeat && mYRepeat == aOther.mYRepeat; - } - bool operator!=(const Repeat& aOther) const { return !(*this == aOther); } + bool operator==(const Repeat& aOther) const = default; + bool operator!=(const Repeat& aOther) const = default; }; struct Layer { @@ -279,7 +274,7 @@ struct nsStyleImageLayers { // An equality operator that compares the images using URL-equality // rather than pointer-equality. bool operator==(const Layer& aOther) const; - bool operator!=(const Layer& aOther) const { return !(*this == aOther); } + bool operator!=(const Layer& aOther) const = default; }; // The (positive) number of computed values of each property, since @@ -1477,9 +1472,7 @@ struct StyleTransition { StyleTransitionBehavior GetBehavior() const { return mBehavior; } bool operator==(const StyleTransition& aOther) const; - bool operator!=(const StyleTransition& aOther) const { - return !(*this == aOther); - } + bool operator!=(const StyleTransition&) const = default; private: StyleComputedTimingFunction mTimingFunction{ @@ -1509,9 +1502,7 @@ struct StyleAnimation { const StyleAnimationTimeline& GetTimeline() const { return mTimeline; } bool operator==(const StyleAnimation& aOther) const; - bool operator!=(const StyleAnimation& aOther) const { - return !(*this == aOther); - } + bool operator!=(const StyleAnimation&) const = default; private: StyleComputedTimingFunction mTimingFunction{ @@ -1534,12 +1525,8 @@ struct StyleScrollTimeline { nsAtom* GetName() const { return mName.AsAtom(); } StyleScrollAxis GetAxis() const { return mAxis; } - bool operator==(const StyleScrollTimeline& aOther) const { - return mName == aOther.mName && mAxis == aOther.mAxis; - } - bool operator!=(const StyleScrollTimeline& aOther) const { - return !(*this == aOther); - } + bool operator==(const StyleScrollTimeline&) const = default; + bool operator!=(const StyleScrollTimeline&) const = default; private: StyleTimelineName mName; @@ -1554,13 +1541,8 @@ struct StyleViewTimeline { StyleScrollAxis GetAxis() const { return mAxis; } const StyleViewTimelineInset& GetInset() const { return mInset; } - bool operator==(const StyleViewTimeline& aOther) const { - return mName == aOther.mName && mAxis == aOther.mAxis && - mInset == aOther.mInset; - } - bool operator!=(const StyleViewTimeline& aOther) const { - return !(*this == aOther); - } + bool operator==(const StyleViewTimeline&) const = default; + bool operator!=(const StyleViewTimeline&) const = default; private: StyleTimelineName mName; diff --git a/layout/svg/SVGImageContext.h b/layout/svg/SVGImageContext.h @@ -112,9 +112,7 @@ class SVGImageContext { mColorScheme == aOther.mColorScheme; } - bool operator!=(const SVGImageContext& aOther) const { - return !(*this == aOther); - } + bool operator!=(const SVGImageContext&) const = default; PLDHashNumber Hash() const { PLDHashNumber hash = 0;