From 84624b4a4289271f35f42a6e7d15c5f2f7e77f68 Mon Sep 17 00:00:00 2001 From: Miko Mynttinen Date: Mon, 22 Apr 2019 19:58:01 +0000 Subject: [PATCH] Bug 1540785 - Part 2: Devirtualize nsDisplayItemBase::GetPerFrameKey() r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D27580 --HG-- extra : moz-landing-system : lando --- layout/generic/TextOverflow.cpp | 9 +- layout/mathml/nsMathMLChar.cpp | 8 +- layout/mathml/nsMathMLFrame.cpp | 8 +- layout/mathml/nsMathMLmencloseFrame.cpp | 4 +- layout/painting/nsDisplayList.cpp | 35 +++---- layout/painting/nsDisplayList.h | 133 ++++++++++++------------ 6 files changed, 95 insertions(+), 102 deletions(-) diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index c123e3044a7c..19f052db2bb5 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -153,7 +153,7 @@ class nsDisplayTextOverflowMarker final : public nsDisplayItem { nsDisplayTextOverflowMarker(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, const nsRect& aRect, nscoord aAscent, const nsStyleTextOverflowSide* aStyle, - uint32_t aLineNumber, uint32_t aIndex) + uint32_t aLineNumber, uint16_t aIndex) : nsDisplayItem(aBuilder, aFrame), mRect(aRect), mStyle(*aStyle), @@ -189,9 +189,8 @@ class nsDisplayTextOverflowMarker final : public nsDisplayItem { virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; - virtual uint32_t GetPerFrameKey() const override { - return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); - } + virtual uint16_t CalculatePerFrameKey() const override { return mIndex; } + void PaintTextToContext(gfxContext* aCtx, nsPoint aOffsetFromRect); virtual bool CreateWebRenderCommands( @@ -206,7 +205,7 @@ class nsDisplayTextOverflowMarker final : public nsDisplayItem { nsRect mRect; // in reference frame coordinates const nsStyleTextOverflowSide mStyle; nscoord mAscent; // baseline for the marker text in mRect - uint32_t mIndex; + uint16_t mIndex; }; static void PaintTextShadowCallback(gfxContext* aCtx, nsPoint aShadowOffset, diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp index c2475b187706..f929ea34f656 100644 --- a/layout/mathml/nsMathMLChar.cpp +++ b/layout/mathml/nsMathMLChar.cpp @@ -1717,7 +1717,7 @@ class nsDisplayMathMLCharForeground final : public nsDisplayItem { public: nsDisplayMathMLCharForeground(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsMathMLChar* aChar, - uint32_t aIndex, bool aIsSelected) + uint16_t aIndex, bool aIsSelected) : nsDisplayItem(aBuilder, aFrame), mChar(aChar), mIndex(aIndex), @@ -1758,13 +1758,11 @@ class nsDisplayMathMLCharForeground final : public nsDisplayItem { return GetBounds(aBuilder, &snap); } - virtual uint32_t GetPerFrameKey() const override { - return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); - } + virtual uint16_t CalculatePerFrameKey() const override { return mIndex; } private: nsMathMLChar* mChar; - uint32_t mIndex; + uint16_t mIndex; bool mIsSelected; }; diff --git a/layout/mathml/nsMathMLFrame.cpp b/layout/mathml/nsMathMLFrame.cpp index 31f72dd57c51..45b3ddf4c6e1 100644 --- a/layout/mathml/nsMathMLFrame.cpp +++ b/layout/mathml/nsMathMLFrame.cpp @@ -303,7 +303,7 @@ void nsMathMLFrame::DisplayBoundingMetrics(nsDisplayListBuilder* aBuilder, class nsDisplayMathMLBar final : public nsDisplayItem { public: nsDisplayMathMLBar(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, - const nsRect& aRect, uint32_t aIndex) + const nsRect& aRect, uint16_t aIndex) : nsDisplayItem(aBuilder, aFrame), mRect(aRect), mIndex(aIndex) { MOZ_COUNT_CTOR(nsDisplayMathMLBar); } @@ -311,15 +311,13 @@ class nsDisplayMathMLBar final : public nsDisplayItem { virtual ~nsDisplayMathMLBar() { MOZ_COUNT_DTOR(nsDisplayMathMLBar); } #endif - virtual uint32_t GetPerFrameKey() const override { - return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); - } + virtual uint16_t CalculatePerFrameKey() const override { return mIndex; } virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; NS_DISPLAY_DECL_NAME("MathMLBar", TYPE_MATHML_BAR) private: nsRect mRect; - uint32_t mIndex; + uint16_t mIndex; }; void nsDisplayMathMLBar::Paint(nsDisplayListBuilder* aBuilder, diff --git a/layout/mathml/nsMathMLmencloseFrame.cpp b/layout/mathml/nsMathMLmencloseFrame.cpp index b420e4b3bd71..49e0c5cc504f 100644 --- a/layout/mathml/nsMathMLmencloseFrame.cpp +++ b/layout/mathml/nsMathMLmencloseFrame.cpp @@ -716,9 +716,7 @@ class nsDisplayNotation final : public nsDisplayItem { virtual ~nsDisplayNotation() { MOZ_COUNT_DTOR(nsDisplayNotation); } #endif - virtual uint32_t GetPerFrameKey() const override { - return (mType << TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); - } + virtual uint16_t CalculatePerFrameKey() const override { return mType; } virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; NS_DISPLAY_DECL_NAME("MathMLMencloseNotation", TYPE_MATHML_MENCLOSE_NOTATION) diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index b96a799ee684..269ae50b0968 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -3533,7 +3533,7 @@ static Maybe GetViewportRectRelativeToReferenceFrame( /* static */ nsDisplayBackgroundImage::InitData nsDisplayBackgroundImage::GetInitData(nsDisplayListBuilder* aBuilder, - nsIFrame* aFrame, uint32_t aLayer, + nsIFrame* aFrame, uint16_t aLayer, const nsRect& aBackgroundRect, ComputedStyle* aBackgroundStyle) { nsPresContext* presContext = aFrame->PresContext(); @@ -5029,7 +5029,7 @@ bool nsDisplayEventReceiver::CreateWebRenderCommands( nsDisplayCompositorHitTestInfo::nsDisplayCompositorHitTestInfo( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, - const mozilla::gfx::CompositorHitTestInfo& aHitTestFlags, uint32_t aIndex, + const mozilla::gfx::CompositorHitTestInfo& aHitTestFlags, uint16_t aIndex, const mozilla::Maybe& aArea) : nsDisplayHitTestInfoItem(aBuilder, aFrame), mIndex(aIndex), @@ -5114,8 +5114,8 @@ bool nsDisplayCompositorHitTestInfo::CreateWebRenderCommands( return true; } -uint32_t nsDisplayCompositorHitTestInfo::GetPerFrameKey() const { - return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); +uint16_t nsDisplayCompositorHitTestInfo::CalculatePerFrameKey() const { + return mIndex; } int32_t nsDisplayCompositorHitTestInfo::ZIndex() const { @@ -5643,7 +5643,7 @@ nsDisplayWrapList::nsDisplayWrapList(nsDisplayListBuilder* aBuilder, nsDisplayWrapList::nsDisplayWrapList( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, const ActiveScrolledRoot* aActiveScrolledRoot, bool aClearClipChain, - uint32_t aIndex) + uint16_t aIndex) : nsDisplayHitTestInfoItem(aBuilder, aFrame, aActiveScrolledRoot), mFrameActiveScrolledRoot(aBuilder->CurrentActiveScrolledRoot()), mOverrideZIndex(0), @@ -6260,7 +6260,7 @@ bool nsDisplayOpacity::CreateWebRenderCommands( nsDisplayBlendMode::nsDisplayBlendMode( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, uint8_t aBlendMode, const ActiveScrolledRoot* aActiveScrolledRoot, - uint32_t aIndex) + uint16_t aIndex) : nsDisplayWrapList(aBuilder, aFrame, aList, aActiveScrolledRoot, true), mBlendMode(aBlendMode), mIndex(aIndex) { @@ -6885,9 +6885,9 @@ nsDisplayFixedPosition::nsDisplayFixedPosition( const ActiveScrolledRoot* aActiveScrolledRoot, const ActiveScrolledRoot* aContainerASR) : nsDisplayOwnLayer(aBuilder, aFrame, aList, aActiveScrolledRoot), + mContainerASR(aContainerASR), mIndex(0), - mIsFixedBackground(false), - mContainerASR(aContainerASR) { + mIsFixedBackground(false) { MOZ_COUNT_CTOR(nsDisplayFixedPosition); Init(aBuilder); } @@ -6895,13 +6895,12 @@ nsDisplayFixedPosition::nsDisplayFixedPosition( nsDisplayFixedPosition::nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, - uint32_t aIndex) + uint16_t aIndex) : nsDisplayOwnLayer(aBuilder, aFrame, aList, aBuilder->CurrentActiveScrolledRoot()), + mContainerASR(nullptr), // XXX maybe this should be something? mIndex(aIndex), - mIsFixedBackground(true), - mContainerASR(nullptr) // XXX maybe this should be something? -{ + mIsFixedBackground(true) { MOZ_COUNT_CTOR(nsDisplayFixedPosition); Init(aBuilder); } @@ -6916,7 +6915,7 @@ void nsDisplayFixedPosition::Init(nsDisplayListBuilder* aBuilder) { /* static */ nsDisplayFixedPosition* nsDisplayFixedPosition::CreateForFixedBackground( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, - nsDisplayBackgroundImage* aImage, uint32_t aIndex) { + nsDisplayBackgroundImage* aImage, uint16_t aIndex) { nsDisplayList temp; temp.AppendToTop(aImage); @@ -7041,7 +7040,7 @@ TableType GetTableTypeFromFrame(nsIFrame* aFrame) { nsDisplayTableFixedPosition::nsDisplayTableFixedPosition( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, - uint32_t aIndex, nsIFrame* aAncestorFrame) + uint16_t aIndex, nsIFrame* aAncestorFrame) : nsDisplayFixedPosition(aBuilder, aFrame, aList, aIndex), mAncestorFrame(aAncestorFrame), mTableType(GetTableTypeFromFrame(aAncestorFrame)) { @@ -7054,7 +7053,7 @@ nsDisplayTableFixedPosition::nsDisplayTableFixedPosition( nsDisplayTableFixedPosition* nsDisplayTableFixedPosition::CreateForFixedBackground( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, - nsDisplayBackgroundImage* aImage, uint32_t aIndex, + nsDisplayBackgroundImage* aImage, uint16_t aIndex, nsIFrame* aAncestorFrame) { nsDisplayList temp; temp.AppendToTop(aImage); @@ -7508,7 +7507,7 @@ static_assert(sizeof(nsDisplayTransform) < 512, "nsDisplayTransform has grown"); nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, const nsRect& aChildrenBuildingRect, - uint32_t aIndex) + uint16_t aIndex) : nsDisplayHitTestInfoItem(aBuilder, aFrame), mTransform(Some(Matrix4x4())), mTransformGetter(nullptr), @@ -7526,7 +7525,7 @@ nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, const nsRect& aChildrenBuildingRect, - uint32_t aIndex, + uint16_t aIndex, bool aAllowAsyncAnimation) : nsDisplayHitTestInfoItem(aBuilder, aFrame), mTransformGetter(nullptr), @@ -7544,7 +7543,7 @@ nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsDisplayTransform::nsDisplayTransform( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, - const nsRect& aChildrenBuildingRect, uint32_t aIndex, + const nsRect& aChildrenBuildingRect, uint16_t aIndex, ComputeTransformFunction aTransformGetter) : nsDisplayHitTestInfoItem(aBuilder, aFrame), mTransformGetter(aTransformGetter), diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index c8f373b5ecab..37fb5dc8c45e 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -2027,6 +2027,8 @@ MOZ_ALWAYS_INLINE T* MakeDisplayItem(nsDisplayListBuilder* aBuilder, item->SetType(T::ItemType()); } + item->SetPerFrameKey(item->CalculatePerFrameKey()); + // TODO: Ideally we'd determine this before constructing the item, // but we'd need a template specialization for every type that has // children, or make all callers pass the type. @@ -2166,8 +2168,19 @@ class nsDisplayItemBase : public nsDisplayItemLink { * Pairing this with the Frame() pointer gives a key that * uniquely identifies this display item in the display item tree. */ - virtual uint32_t GetPerFrameKey() const { return uint32_t(GetType()); } - void SetPerFrameKey(const uint32_t aKey) { mKey = aKey; } + uint32_t GetPerFrameKey() const { + // The top 8 bits are currently unused. + // The middle 16 bits of the per frame key uniquely identify the display + // item when there are more than one item of the same type for a frame. + // The low 8 bits are the display item type. + return (static_cast(mKey) << TYPE_BITS) | + static_cast(mType); + } + + /** + * Returns the initial per frame key for this display item. + */ + virtual uint16_t CalculatePerFrameKey() const { return 0; } /** * Returns true if this item was reused during display list merging. @@ -2278,6 +2291,8 @@ class nsDisplayItemBase : public nsDisplayItemLink { } } + void SetPerFrameKey(const uint16_t aKey) { mKey = aKey; } + void SetDeletedFrame(); nsIFrame* mFrame; // 8 @@ -4384,7 +4399,7 @@ class nsDisplayBackgroundImage : public nsDisplayImageContainer { * aBackgroundRect is relative to aFrame. */ static InitData GetInitData(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, - uint32_t aLayer, const nsRect& aBackgroundRect, + uint16_t aLayer, const nsRect& aBackgroundRect, mozilla::ComputedStyle* aBackgroundStyle); explicit nsDisplayBackgroundImage(nsDisplayListBuilder* aBuilder, @@ -4435,9 +4450,7 @@ class nsDisplayBackgroundImage : public nsDisplayImageContainer { void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; - uint32_t GetPerFrameKey() const override { - return (mLayer << TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); - } + uint16_t CalculatePerFrameKey() const override { return mLayer; } /** * Return the background positioning area. @@ -4532,7 +4545,7 @@ class nsDisplayBackgroundImage : public nsDisplayImageContainer { nsRect mDestRect; /* Bounds of this display item */ nsRect mBounds; - uint32_t mLayer; + uint16_t mLayer; bool mIsRasterImage; /* Whether the image should be treated as fixed to the viewport. */ bool mShouldFixToViewport; @@ -4557,6 +4570,14 @@ static_assert(static_cast(TableType::TABLE_TYPE_MAX) < "TableType cannot fit with TableTypeBits::COUNT"); TableType GetTableTypeFromFrame(nsIFrame* aFrame); +static uint16_t CalculateTablePerFrameKey(const uint16_t aIndex, + const TableType aType) { + const uint32_t key = (aIndex << static_cast(TableTypeBits::COUNT)) | + static_cast(aType); + + return static_cast(key); +} + /** * A display item to paint background image for table. For table parts, such * as row, row group, col, col group, when drawing its background, we'll @@ -4579,11 +4600,8 @@ class nsDisplayTableBackgroundImage : public nsDisplayBackgroundImage { NS_DISPLAY_DECL_NAME("TableBackgroundImage", TYPE_TABLE_BACKGROUND_IMAGE) - uint32_t GetPerFrameKey() const override { - return (mLayer << (TYPE_BITS + - static_cast(TableTypeBits::COUNT))) | - (static_cast(mTableType) << TYPE_BITS) | - nsDisplayItem::GetPerFrameKey(); + uint16_t CalculatePerFrameKey() const override { + return CalculateTablePerFrameKey(mLayer, mTableType); } bool IsInvalid(nsRect& aRect) const override; @@ -4711,9 +4729,8 @@ class nsDisplayTableThemedBackground : public nsDisplayThemedBackground { NS_DISPLAY_DECL_NAME("TableThemedBackground", TYPE_TABLE_THEMED_BACKGROUND_IMAGE) - uint32_t GetPerFrameKey() const override { - return (static_cast(mTableType) << TYPE_BITS) | - nsDisplayItem::GetPerFrameKey(); + uint16_t CalculatePerFrameKey() const override { + return static_cast(mTableType); } nsIFrame* FrameForInvalidation() const override { return mAncestorFrame; } @@ -4903,9 +4920,8 @@ class nsDisplayTableBackgroundColor : public nsDisplayBackgroundColor { nsDisplayBackgroundColor::RemoveFrame(aFrame); } - uint32_t GetPerFrameKey() const override { - return (static_cast(mTableType) << TYPE_BITS) | - nsDisplayItem::GetPerFrameKey(); + uint16_t CalculatePerFrameKey() const override { + return static_cast(mTableType); } bool CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) override { @@ -5151,7 +5167,7 @@ class nsDisplayCompositorHitTestInfo : public nsDisplayHitTestInfoItem { nsDisplayCompositorHitTestInfo( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, const mozilla::gfx::CompositorHitTestInfo& aHitTestFlags, - uint32_t aIndex = 0, + uint16_t aIndex = 0, const mozilla::Maybe& aArea = mozilla::Nothing()); nsDisplayCompositorHitTestInfo( @@ -5174,7 +5190,7 @@ class nsDisplayCompositorHitTestInfo : public nsDisplayHitTestInfoItem { const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; - uint32_t GetPerFrameKey() const override; + uint16_t CalculatePerFrameKey() const override; int32_t ZIndex() const override; void SetOverrideZIndex(int32_t aZIndex); @@ -5196,7 +5212,7 @@ class nsDisplayCompositorHitTestInfo : public nsDisplayHitTestInfoItem { private: mozilla::Maybe mScrollTarget; - uint32_t mIndex; + uint16_t mIndex; mozilla::Maybe mOverrideZIndex; int32_t mAppUnitsPerDevPixel; }; @@ -5229,7 +5245,7 @@ class nsDisplayWrapList : public nsDisplayHitTestInfoItem { nsDisplayWrapList(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, const ActiveScrolledRoot* aActiveScrolledRoot, - bool aClearClipChain = false, uint32_t aIndex = 0); + bool aClearClipChain = false, uint16_t aIndex = 0); nsDisplayWrapList(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) : nsDisplayHitTestInfoItem(aBuilder, aFrame), @@ -5333,9 +5349,7 @@ class nsDisplayWrapList : public nsDisplayHitTestInfoItem { bool ComputeVisibility(nsDisplayListBuilder* aBuilder, nsRegion* aVisibleRegion) override; - uint32_t GetPerFrameKey() const override { - return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); - } + uint16_t CalculatePerFrameKey() const override { return mIndex; } bool CanMerge(const nsDisplayItem* aItem) const override { return false; } @@ -5441,7 +5455,7 @@ class nsDisplayWrapList : public nsDisplayHitTestInfoItem { // Our mBuildingRect may include the visible areas of children. nsRect mBaseBuildingRect; int32_t mOverrideZIndex; - uint32_t mIndex; + uint16_t mIndex; bool mHasZIndexOverride; bool mClearingClipChain = false; }; @@ -5616,7 +5630,7 @@ class nsDisplayBlendMode : public nsDisplayWrapList { nsDisplayBlendMode(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, uint8_t aBlendMode, const ActiveScrolledRoot* aActiveScrolledRoot, - uint32_t aIndex = 0); + uint16_t aIndex = 0); nsDisplayBlendMode(nsDisplayListBuilder* aBuilder, const nsDisplayBlendMode& aOther) : nsDisplayWrapList(aBuilder, aOther), @@ -5646,9 +5660,7 @@ class nsDisplayBlendMode : public nsDisplayWrapList { // LayerTreeInvalidation } - uint32_t GetPerFrameKey() const override { - return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); - } + uint16_t CalculatePerFrameKey() const override { return mIndex; } LayerState GetLayerState( nsDisplayListBuilder* aBuilder, LayerManager* aManager, @@ -5672,7 +5684,7 @@ class nsDisplayBlendMode : public nsDisplayWrapList { protected: uint8_t mBlendMode; - uint32_t mIndex; + uint16_t mIndex; }; class nsDisplayTableBlendMode : public nsDisplayBlendMode { @@ -5680,7 +5692,7 @@ class nsDisplayTableBlendMode : public nsDisplayBlendMode { nsDisplayTableBlendMode(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, uint8_t aBlendMode, const ActiveScrolledRoot* aActiveScrolledRoot, - uint32_t aIndex, nsIFrame* aAncestorFrame) + uint16_t aIndex, nsIFrame* aAncestorFrame) : nsDisplayBlendMode(aBuilder, aFrame, aList, aBlendMode, aActiveScrolledRoot, aIndex), mAncestorFrame(aAncestorFrame), @@ -5722,11 +5734,8 @@ class nsDisplayTableBlendMode : public nsDisplayBlendMode { nsDisplayBlendMode::RemoveFrame(aFrame); } - uint32_t GetPerFrameKey() const override { - return (mIndex << (TYPE_BITS + - static_cast(TableTypeBits::COUNT))) | - (static_cast(mTableType) << TYPE_BITS) | - nsDisplayItem::GetPerFrameKey(); + uint16_t CalculatePerFrameKey() const override { + return CalculateTablePerFrameKey(mIndex, mTableType); } protected: @@ -5784,9 +5793,8 @@ class nsDisplayBlendContainer : public nsDisplayWrapList { return false; } - uint32_t GetPerFrameKey() const override { - return (mIsForBackground ? 1 << TYPE_BITS : 0) | - nsDisplayItem::GetPerFrameKey(); + uint16_t CalculatePerFrameKey() const override { + return mIsForBackground ? 1 : 0; } protected: @@ -5826,9 +5834,8 @@ class nsDisplayTableBlendContainer : public nsDisplayBlendContainer { nsDisplayBlendContainer::RemoveFrame(aFrame); } - uint32_t GetPerFrameKey() const override { - return (static_cast(mTableType) << TYPE_BITS) | - nsDisplayItem::GetPerFrameKey(); + uint16_t CalculatePerFrameKey() const override { + return static_cast(mTableType); } protected: @@ -6148,15 +6155,15 @@ class nsDisplayFixedPosition : public nsDisplayOwnLayer { : nsDisplayOwnLayer(aBuilder, aOther), mAnimatedGeometryRootForScrollMetadata( aOther.mAnimatedGeometryRootForScrollMetadata), + mContainerASR(aOther.mContainerASR), mIndex(aOther.mIndex), - mIsFixedBackground(aOther.mIsFixedBackground), - mContainerASR(aOther.mContainerASR) { + mIsFixedBackground(aOther.mIsFixedBackground) { MOZ_COUNT_CTOR(nsDisplayFixedPosition); } static nsDisplayFixedPosition* CreateForFixedBackground( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, - nsDisplayBackgroundImage* aImage, uint32_t aIndex); + nsDisplayBackgroundImage* aImage, uint16_t aIndex); #ifdef NS_BUILD_REFCNT_LOGGING ~nsDisplayFixedPosition() override { MOZ_COUNT_DTOR(nsDisplayFixedPosition); } @@ -6182,9 +6189,7 @@ class nsDisplayFixedPosition : public nsDisplayOwnLayer { return mIsFixedBackground; } - uint32_t GetPerFrameKey() const override { - return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); - } + uint16_t CalculatePerFrameKey() const override { return mIndex; } AnimatedGeometryRoot* AnimatedGeometryRootForScrollMetadata() const override { return mAnimatedGeometryRootForScrollMetadata; @@ -6204,21 +6209,21 @@ class nsDisplayFixedPosition : public nsDisplayOwnLayer { protected: // For background-attachment:fixed nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, - nsDisplayList* aList, uint32_t aIndex); + nsDisplayList* aList, uint16_t aIndex); void Init(nsDisplayListBuilder* aBuilder); ViewID GetScrollTargetId(); RefPtr mAnimatedGeometryRootForScrollMetadata; - uint32_t mIndex; - bool mIsFixedBackground; RefPtr mContainerASR; + uint16_t mIndex; + bool mIsFixedBackground; }; class nsDisplayTableFixedPosition : public nsDisplayFixedPosition { public: static nsDisplayTableFixedPosition* CreateForFixedBackground( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, - nsDisplayBackgroundImage* aImage, uint32_t aIndex, + nsDisplayBackgroundImage* aImage, uint16_t aIndex, nsIFrame* aAncestorFrame); NS_DISPLAY_DECL_NAME("TableFixedPosition", TYPE_TABLE_FIXED_POSITION) @@ -6237,16 +6242,13 @@ class nsDisplayTableFixedPosition : public nsDisplayFixedPosition { nsDisplayFixedPosition::RemoveFrame(aFrame); } - uint32_t GetPerFrameKey() const override { - return (mIndex << (TYPE_BITS + - static_cast(TableTypeBits::COUNT))) | - (static_cast(mTableType) << TYPE_BITS) | - nsDisplayItem::GetPerFrameKey(); + uint16_t CalculatePerFrameKey() const override { + return CalculateTablePerFrameKey(mIndex, mTableType); } protected: nsDisplayTableFixedPosition(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, - nsDisplayList* aList, uint32_t aIndex, + nsDisplayList* aList, uint16_t aIndex, nsIFrame* aAncestorFrame); nsDisplayTableFixedPosition(nsDisplayListBuilder* aBuilder, @@ -6687,15 +6689,15 @@ class nsDisplayTransform : public nsDisplayHitTestInfoItem { */ nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, const nsRect& aChildrenBuildingRect, - uint32_t aIndex); + uint16_t aIndex); nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, const nsRect& aChildrenBuildingRect, - uint32_t aIndex, bool aAllowAsyncAnimation); + uint16_t aIndex, bool aAllowAsyncAnimation); nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, const nsRect& aChildrenBuildingRect, - uint32_t aIndex, + uint16_t aIndex, ComputeTransformFunction aTransformGetter); #ifdef NS_BUILD_REFCNT_LOGGING @@ -6762,9 +6764,7 @@ class nsDisplayTransform : public nsDisplayHitTestInfoItem { bool CanMerge(const nsDisplayItem* aItem) const override { return false; } - uint32_t GetPerFrameKey() const override { - return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); - } + uint16_t CalculatePerFrameKey() const override { return mIndex; } nsDisplayItemGeometry* AllocateGeometry( nsDisplayListBuilder* aBuilder) override { @@ -7010,8 +7010,9 @@ class nsDisplayTransform : public nsDisplayHitTestInfoItem { RefPtr mAnimatedGeometryRootForChildren; RefPtr mAnimatedGeometryRootForScrollMetadata; nsRect mChildrenBuildingRect; - uint32_t mIndex; mutable RetainedDisplayList mChildren; + uint16_t mIndex; + // The untransformed bounds of |mChildren|. nsRect mChildBounds; // The transformed bounds of this display item.