Bug 1384181 - Ensure that the WebRenderScrollData has a single root layer node. r? draft
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 26 Jul 2017 14:47:48 -0400
changeset 616162 4865a295a312ed83cb2ff92a22bfc277680d0ec3
parent 616161 e5e66645b6b77e8f3fb5f2e5772b640ffc0ff29f
child 616163 fc3f4457f3b38e2a8d1f40394e024d0e5b1532da
push id70614
push userkgupta@mozilla.com
push dateWed, 26 Jul 2017 20:00:48 +0000
bugs1384181
milestone56.0a1
Bug 1384181 - Ensure that the WebRenderScrollData has a single root layer node. r? The semantics of the WebRenderScrollData structure is that the per-layer structures form a tree with a single root node. When we build the data structure from the display list, we are generating (for now) a flat list. Therefore we need to synthesize a root node in order to make stuff work as intended. MozReview-Commit-ID: IDXyziBO7pk
gfx/layers/wr/WebRenderLayerManager.cpp
gfx/layers/wr/WebRenderScrollData.cpp
gfx/layers/wr/WebRenderScrollData.h
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -529,16 +529,19 @@ WebRenderLayerManager::EndTransactionInt
       mParentCommands.Clear();
       mScrollData = WebRenderScrollData();
       MOZ_ASSERT(mLayerScrollData.empty());
 
       CreateWebRenderCommandsFromDisplayList(aDisplayList, aDisplayListBuilder, sc, builder);
 
       builder.Finalize(contentSize, mBuiltDisplayList);
 
+      // Make a "root" layer data that has everything else as descendants
+      mLayerScrollData.emplace_back();
+      mLayerScrollData.back().InitializeRoot(mLayerScrollData.size() - 1);
       // Append the WebRenderLayerScrollData items into WebRenderScrollData
       // in reverse order, from topmost to bottommost. This is in keeping with
       // the semantics of WebRenderScrollData.
       for (auto i = mLayerScrollData.crbegin(); i != mLayerScrollData.crend(); i++) {
         mScrollData.AddLayerData(*i);
       }
       mLayerScrollData.clear();
     }
--- a/gfx/layers/wr/WebRenderScrollData.cpp
+++ b/gfx/layers/wr/WebRenderScrollData.cpp
@@ -56,16 +56,22 @@ WebRenderLayerScrollData::Initialize(Web
   mScrollThumbData = aLayer->GetScrollThumbData();
   mScrollbarAnimationId = aLayer->GetCompositorAnimationsId();
   mScrollbarTargetContainerId = aLayer->GetScrollbarTargetContainerId();
   mIsScrollbarContainer = aLayer->IsScrollbarContainer();
   mFixedPosScrollContainerId = aLayer->GetFixedPositionScrollContainerId();
 }
 
 void
+WebRenderLayerScrollData::InitializeRoot(int32_t aDescendantCount)
+{
+  mDescendantCount = aDescendantCount;
+}
+
+void
 WebRenderLayerScrollData::Initialize(WebRenderScrollData& aOwner,
                                      nsDisplayItem* aItem)
 {
   mDescendantCount = 0;
 
   MOZ_ASSERT(aItem);
   if (aItem->GetType() == nsDisplayItem::TYPE_SCROLL_INFO_LAYER) {
     nsDisplayScrollInfoLayer* info = static_cast<nsDisplayScrollInfoLayer*>(aItem);
--- a/gfx/layers/wr/WebRenderScrollData.h
+++ b/gfx/layers/wr/WebRenderScrollData.h
@@ -36,16 +36,17 @@ public:
   ~WebRenderLayerScrollData();
 
   // Actually initialize the object. This is not done during the constructor
   // for optimization purposes (the call site is hard to write efficiently
   // if we do this in the constructor).
   void Initialize(WebRenderScrollData& aOwner,
                   Layer* aLayer,
                   int32_t aDescendantCount);
+  void InitializeRoot(int32_t aDescendantCount);
   void Initialize(WebRenderScrollData& aOwner,
                   nsDisplayItem* aItem);
 
   int32_t GetDescendantCount() const;
   size_t GetScrollMetadataCount() const;
 
   // Return the ScrollMetadata object that used to be on the original Layer
   // at the given index. Since we deduplicate the ScrollMetadata objects into