Bug 1453469 - Remove nsDisplayOwnLayer::mScrollTarget. r=botond
authorDaniel Zielas <zielas.daniel@gmail.com>
Sat, 14 Apr 2018 09:42:45 +0200
changeset 467601 6047ab9ac46a891c430f42dbeedc4555123172bb
parent 467600 34ebcf9dcd6e0bdc991d4b445321ae9d5f6acc16
child 467602 da8af21b243efa5c5810ee43d947f43865c238e5
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1453469
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1453469 - Remove nsDisplayOwnLayer::mScrollTarget. r=botond MozReview-Commit-ID: 1LAWH96mm5m
gfx/layers/LayerAttributes.h
gfx/layers/Layers.h
layout/generic/nsFrame.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
layout/xul/nsBoxFrame.cpp
layout/xul/nsSliderFrame.cpp
--- a/gfx/layers/LayerAttributes.h
+++ b/gfx/layers/LayerAttributes.h
@@ -28,25 +28,27 @@ struct ScrollbarData {
 
   ScrollbarData(ScrollDirection aDirection,
                 ScrollbarLayerType aScrollbarLayerType,
                 float aThumbRatio,
                 CSSCoord aThumbStart,
                 CSSCoord aThumbLength,
                 bool aThumbIsAsyncDraggable,
                 CSSCoord aScrollTrackStart,
-                CSSCoord aScrollTrackLength)
+                CSSCoord aScrollTrackLength,
+                uint64_t aTargetViewId)
     : mDirection(Some(aDirection))
     , mScrollbarLayerType(aScrollbarLayerType)
     , mThumbRatio(aThumbRatio)
     , mThumbStart(aThumbStart)
     , mThumbLength(aThumbLength)
     , mThumbIsAsyncDraggable(aThumbIsAsyncDraggable)
     , mScrollTrackStart(aScrollTrackStart)
     , mScrollTrackLength(aScrollTrackLength)
+    , mTargetViewId(aTargetViewId)
   {}
 
   /**
    * The mDirection contains a direction if mScrollbarLayerType is Thumb
    * or Container, otherwise it's empty.
    */
   Maybe<ScrollDirection> mDirection;
 
@@ -153,30 +155,16 @@ public:
     if (mScrollbarData == aScrollbarData)
     {
       return false;
     }
     mScrollbarData = aScrollbarData;
     return true;
   }
 
-  bool SetScrollbarContainer(FrameMetrics::ViewID aTargetViewId,
-                             ScrollDirection aDirection) {
-    if (mScrollbarData.mScrollbarLayerType == ScrollbarLayerType::Container &&
-        mScrollbarData.mDirection &&
-        *mScrollbarData.mDirection == aDirection &&
-        mScrollbarData.mTargetViewId == aTargetViewId) {
-      return false;
-    }
-    mScrollbarData.mDirection = Some(aDirection);
-    mScrollbarData.mTargetViewId = aTargetViewId;
-    mScrollbarData.mScrollbarLayerType = ScrollbarLayerType::Container;
-    return true;
-  }
-
   bool SetMixBlendMode(gfx::CompositionOp aMixBlendMode) {
     if (mMixBlendMode == aMixBlendMode) {
       return false;
     }
     mMixBlendMode = aMixBlendMode;
     return true;
   }
 
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -1254,39 +1254,28 @@ public:
     if (mSimpleAttrs.SetStickyPositionData(aScrollId, aOuter, aInner)) {
       MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) StickyPositionData", this));
       MutatedSimple();
     }
   }
 
   /**
    * CONSTRUCTION PHASE ONLY
-   * If a layer is a scroll thumb container layer, set the scroll identifier
-   * of the scroll frame scrolled by the thumb, and other data related to the
-   * thumb.
+   * If a layer is a scroll thumb container layer or a scrollbar container
+   * layer, set the scroll identifier of the scroll frame scrolled by
+   * the scrollbar, and other data related to the scrollbar.
    */
   void SetScrollbarData(const ScrollbarData& aThumbData)
   {
     if (mSimpleAttrs.SetScrollbarData(aThumbData)) {
       MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ScrollbarData", this));
       MutatedSimple();
     }
   }
 
-  // Set during construction for the container layer of scrollbar components.
-  // |aScrollId| holds the scroll identifier of the scrollable content that
-  // the scrollbar is for.
-  void SetScrollbarContainer(FrameMetrics::ViewID aScrollId,
-                             ScrollDirection aDirection)
-  {
-    if (mSimpleAttrs.SetScrollbarContainer(aScrollId, aDirection)) {
-      MutatedSimple();
-    }
-  }
-
   // Used when forwarding transactions. Do not use at any other time.
   void SetSimpleAttributes(const SimpleLayerAttributes& aAttrs) {
     mSimpleAttrs = aAttrs;
   }
   const SimpleLayerAttributes& GetSimpleAttributes() const {
     return mSimpleAttrs;
   }
 
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -3377,17 +3377,16 @@ nsIFrame::BuildDisplayListForStackingCon
   }
 
   if (clipCapturedBy == ContainerItemType::eOwnLayerForTransformWithRoundedClip) {
     clipState.Restore();
     resultList.AppendToTop(
       MakeDisplayItem<nsDisplayOwnLayer>(aBuilder, this, &resultList,
                                        aBuilder->CurrentActiveScrolledRoot(),
                                        nsDisplayOwnLayerFlags::eNone,
-                                       mozilla::layers::FrameMetrics::NULL_SCROLL_ID,
                                        ScrollbarData{}, /* aForceActive = */ false));
     if (aCreatedContainerItem) {
       *aCreatedContainerItem = true;
     }
   }
 
   /* If we have sticky positioning, wrap it in a sticky position item.
    */
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -3037,31 +3037,31 @@ AppendToTop(nsDisplayListBuilder* aBuild
             nsDisplayList* aSource, nsIFrame* aSourceFrame, uint32_t aFlags)
 {
   if (aSource->IsEmpty())
     return;
 
   nsDisplayWrapList* newItem;
   const ActiveScrolledRoot* asr = aBuilder->CurrentActiveScrolledRoot();
   if (aFlags & APPEND_OWN_LAYER) {
-    FrameMetrics::ViewID scrollTarget = FrameMetrics::NULL_SCROLL_ID;
     nsDisplayOwnLayerFlags flags = aBuilder->GetCurrentScrollbarFlags();
     // The flags here should be at most one scrollbar direction and nothing else
     MOZ_ASSERT(flags == nsDisplayOwnLayerFlags::eNone ||
                flags == nsDisplayOwnLayerFlags::eVerticalScrollbar ||
                flags == nsDisplayOwnLayerFlags::eHorizontalScrollbar);
 
+    ScrollbarData scrollbarData;
     if (aFlags & APPEND_SCROLLBAR_CONTAINER) {
-      scrollTarget = aBuilder->GetCurrentScrollbarTarget();
+      scrollbarData.mTargetViewId = aBuilder->GetCurrentScrollbarTarget();
       // The flags here should be exactly one scrollbar direction
       MOZ_ASSERT(flags != nsDisplayOwnLayerFlags::eNone);
       flags |= nsDisplayOwnLayerFlags::eScrollbarContainer;
     }
 
-    newItem = MakeDisplayItem<nsDisplayOwnLayer>(aBuilder, aSourceFrame, aSource, asr, flags, scrollTarget);
+    newItem = MakeDisplayItem<nsDisplayOwnLayer>(aBuilder, aSourceFrame, aSource, asr, flags, scrollbarData);
   } else {
     newItem = MakeDisplayItem<nsDisplayWrapList>(aBuilder, aSourceFrame, aSource, asr);
   }
 
   if (aFlags & APPEND_POSITIONED) {
     // We want overlay scrollbars to always be on top of the scrolled content,
     // but we don't want them to unnecessarily cover overlapping elements from
     // outside our scroll frame.
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -6917,24 +6917,23 @@ nsDisplayTableBlendContainer::CreateForB
                                                            nsIFrame* aAncestorFrame)
 {
   return MakeDisplayItem<nsDisplayTableBlendContainer>(aBuilder, aFrame, aList, aActiveScrolledRoot, true, aAncestorFrame);
 }
 
 nsDisplayOwnLayer::nsDisplayOwnLayer(nsDisplayListBuilder* aBuilder,
                                      nsIFrame* aFrame, nsDisplayList* aList,
                                      const ActiveScrolledRoot* aActiveScrolledRoot,
-                                     nsDisplayOwnLayerFlags aFlags, ViewID aScrollTarget,
-                                     const ScrollbarData& aThumbData,
+                                     nsDisplayOwnLayerFlags aFlags,
+                                     const ScrollbarData& aScrollbarData,
                                      bool aForceActive,
                                      bool aClearClipChain)
     : nsDisplayWrapList(aBuilder, aFrame, aList, aActiveScrolledRoot, aClearClipChain)
     , mFlags(aFlags)
-    , mScrollTarget(aScrollTarget)
-    , mThumbData(aThumbData)
+    , mScrollbarData(aScrollbarData)
     , mForceActive(aForceActive)
     , mWrAnimationId(0)
 {
   MOZ_COUNT_CTOR(nsDisplayOwnLayer);
 
   // For scroll thumb layers, override the AGR to be the thumb's AGR rather
   // than the AGR for mFrame (which is the slider frame).
   if (IsScrollThumbLayer()) {
@@ -6960,17 +6959,17 @@ nsDisplayOwnLayer::GetLayerState(nsDispl
   }
 
   return RequiredLayerStateForChildren(aBuilder, aManager, aParameters, mList, mAnimatedGeometryRoot);
 }
 
 bool
 nsDisplayOwnLayer::IsScrollThumbLayer() const
 {
-  return mThumbData.mScrollbarLayerType == layers::ScrollbarLayerType::Thumb;
+  return mScrollbarData.mScrollbarLayerType == layers::ScrollbarLayerType::Thumb;
 }
 
 bool
 nsDisplayOwnLayer::ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBuilder) const
 {
   // Render scroll thumb layers even if they are invisible, because async
   // scrolling might bring them into view.
   return IsScrollThumbLayer();
@@ -6981,25 +6980,26 @@ already_AddRefed<Layer>
 nsDisplayOwnLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
                               LayerManager* aManager,
                               const ContainerLayerParameters& aContainerParameters)
 {
   RefPtr<ContainerLayer> layer = aManager->GetLayerBuilder()->
     BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList,
                            aContainerParameters, nullptr,
                            FrameLayerBuilder::CONTAINER_ALLOW_PULL_BACKGROUND_COLOR);
+
   if (IsScrollThumbLayer()) {
-    mThumbData.mTargetViewId = mScrollTarget;
-    layer->SetScrollbarData(mThumbData);
-  }
-  if (mFlags & nsDisplayOwnLayerFlags::eScrollbarContainer) {
-    ScrollDirection dir = (mFlags & nsDisplayOwnLayerFlags::eVerticalScrollbar)
-                        ? ScrollDirection::eVertical
-                        : ScrollDirection::eHorizontal;
-    layer->SetScrollbarContainer(mScrollTarget, dir);
+    layer->SetScrollbarData(mScrollbarData);
+  } else if (mFlags & nsDisplayOwnLayerFlags::eScrollbarContainer) {
+    mScrollbarData.mScrollbarLayerType = ScrollbarLayerType::Container;
+    mScrollbarData.mDirection = (mFlags & nsDisplayOwnLayerFlags::eVerticalScrollbar)
+                                ? Some(ScrollDirection::eVertical)
+                                : Some(ScrollDirection::eHorizontal);
+
+    layer->SetScrollbarData(mScrollbarData);
   }
 
   if (mFlags & nsDisplayOwnLayerFlags::eGenerateSubdocInvalidations) {
     mFrame->PresContext()->SetNotifySubDocInvalidationData(layer);
   }
   return layer.forget();
 }
 
@@ -7039,38 +7039,38 @@ nsDisplayOwnLayer::CreateWebRenderComman
 bool
 nsDisplayOwnLayer::UpdateScrollData(mozilla::layers::WebRenderScrollData* aData,
                                     mozilla::layers::WebRenderLayerScrollData* aLayerData)
 {
   bool ret = false;
   if (IsScrollThumbLayer()) {
     ret = true;
     if (aLayerData) {
-      aLayerData->SetScrollbarData(mThumbData);
+      aLayerData->SetScrollbarData(mScrollbarData);
       aLayerData->SetScrollbarAnimationId(mWrAnimationId);
-      aLayerData->SetScrollbarTargetContainerId(mScrollTarget);
+      aLayerData->SetScrollbarTargetContainerId(mScrollbarData.mTargetViewId);
     }
   }
   if (mFlags & nsDisplayOwnLayerFlags::eScrollbarContainer) {
     ret = true;
     if (aLayerData) {
       ScrollDirection dir = (mFlags & nsDisplayOwnLayerFlags::eVerticalScrollbar)
                           ? ScrollDirection::eVertical
                           : ScrollDirection::eHorizontal;
       aLayerData->SetScrollbarContainerDirection(dir);
-      aLayerData->SetScrollbarTargetContainerId(mScrollTarget);
+      aLayerData->SetScrollbarTargetContainerId(mScrollbarData.mTargetViewId);
     }
   }
   return ret;
 }
 
 void
 nsDisplayOwnLayer::WriteDebugInfo(std::stringstream& aStream)
 {
-  aStream << nsPrintfCString(" (flags 0x%x) (scrolltarget %" PRIu64 ")", (int)mFlags, mScrollTarget).get();
+  aStream << nsPrintfCString(" (flags 0x%x) (scrolltarget %" PRIu64 ")", (int)mFlags, mScrollbarData.mTargetViewId).get();
 }
 
 nsDisplaySubDocument::nsDisplaySubDocument(nsDisplayListBuilder* aBuilder,
                                            nsIFrame* aFrame,
                                            nsSubDocumentFrame* aSubDocFrame,
                                            nsDisplayList* aList,
                                            nsDisplayOwnLayerFlags aFlags)
     : nsDisplayOwnLayer(aBuilder, aFrame, aList, aBuilder->CurrentActiveScrolledRoot(), aFlags)
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -5595,28 +5595,28 @@ public:
    * @param aScrollTarget when eVerticalScrollbar or eHorizontalScrollbar
    * is set in the flags, this parameter should be the ViewID of the
    * scrollable content this scrollbar is for.
    */
   nsDisplayOwnLayer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
                     nsDisplayList* aList,
                     const ActiveScrolledRoot* aActiveScrolledRoot,
                     nsDisplayOwnLayerFlags aFlags = nsDisplayOwnLayerFlags::eNone,
-                    ViewID aScrollTarget = mozilla::layers::FrameMetrics::NULL_SCROLL_ID,
-                    const ScrollbarData& aThumbData = ScrollbarData{},
+                    const ScrollbarData& aScrollbarData = ScrollbarData{},
                     bool aForceActive = true,
                     bool aClearClipChain = false);
+
 #ifdef NS_BUILD_REFCNT_LOGGING
   virtual ~nsDisplayOwnLayer();
 #endif
+
   nsDisplayOwnLayer(nsDisplayListBuilder* aBuilder, const nsDisplayOwnLayer& aOther)
     : nsDisplayWrapList(aBuilder, aOther)
     , mFlags(aOther.mFlags)
-    , mScrollTarget(aOther.mScrollTarget)
-    , mThumbData(aOther.mThumbData)
+    , mScrollbarData(aOther.mScrollbarData)
     , mForceActive(aOther.mForceActive)
     , mWrAnimationId(aOther.mWrAnimationId)
   {
     MOZ_COUNT_CTOR(nsDisplayOwnLayer);
   }
 
   virtual bool ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBuilder) const override;
   virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
@@ -5646,22 +5646,25 @@ public:
 
   void WriteDebugInfo(std::stringstream& aStream) override;
 
   nsDisplayOwnLayerFlags GetFlags() { return mFlags; }
   bool IsScrollThumbLayer() const;
   NS_DISPLAY_DECL_NAME("OwnLayer", TYPE_OWN_LAYER)
 protected:
   nsDisplayOwnLayerFlags mFlags;
-  ViewID mScrollTarget;
-  // If this nsDisplayOwnLayer represents a scroll thumb layer, mThumbData
-  // stores information about the scroll thumb. Otherwise, mThumbData will be
-  // default-constructed (in particular with mDirection == Nothing())
-  // and can be ignored.
-  ScrollbarData mThumbData;
+
+  /**
+   * If this nsDisplayOwnLayer represents a scroll thumb layer or a
+   * scrollbar container layer, mScrollbarData stores information
+   * about the scrollbar. Otherwise, mScrollbarData will be
+   * default-constructed (in particular with mDirection == Nothing())
+   * and can be ignored.
+   */
+  ScrollbarData mScrollbarData;
   bool mForceActive;
   uint64_t mWrAnimationId;
 };
 
 /**
  * A display item for subdocuments. This is more or less the same as nsDisplayOwnLayer,
  * except that it always populates the FrameMetrics instance on the ContainerLayer it
  * builds.
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -1385,17 +1385,16 @@ nsBoxFrame::BuildDisplayList(nsDisplayLi
     const ActiveScrolledRoot* ownLayerASR = contASRTracker->GetContainerASR();
 
     DisplayListClipState::AutoSaveRestore ownLayerClipState(aBuilder);
 
     // Wrap the list to make it its own layer
     aLists.Content()->AppendToTop(
       MakeDisplayItem<nsDisplayOwnLayer>(aBuilder, this, &masterList, ownLayerASR,
                                          nsDisplayOwnLayerFlags::eNone,
-                                         mozilla::layers::FrameMetrics::NULL_SCROLL_ID,
                                          mozilla::layers::ScrollbarData{}, true, true));
   }
 }
 
 void
 nsBoxFrame::BuildDisplayListForChildren(nsDisplayListBuilder*   aBuilder,
                                         const nsDisplayListSet& aLists)
 {
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -454,25 +454,26 @@ nsSliderFrame::BuildDisplayListForChildr
 
       // Restore the saved clip so it applies to the thumb container layer.
       thumbContentsClipState.Restore();
 
       // Wrap the list to make it its own layer.
       const ActiveScrolledRoot* ownLayerASR = contASRTracker.GetContainerASR();
       aLists.Content()->AppendToTop(
         MakeDisplayItem<nsDisplayOwnLayer>(aBuilder, this, &masterList, ownLayerASR,
-                                           flags, scrollTargetId,
+                                           flags,
                                            ScrollbarData{scrollDirection,
                                                          layers::ScrollbarLayerType::Thumb,
                                                          GetThumbRatio(),
                                                          thumbStart,
                                                          thumbLength,
                                                          isAsyncDraggable,
                                                          sliderTrackStart,
-                                                         sliderTrackLength}));
+                                                         sliderTrackLength,
+                                                         scrollTargetId}));
 
       return;
     }
   }
 
   nsBoxFrame::BuildDisplayListForChildren(aBuilder, aLists);
 }