Bug 1563178 - Properly manage the renderRoot variable during the APZ tree walk. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 10 Jul 2019 19:54:08 +0000
changeset 482269 dc058b3425f758eadb09e6c18d872d8635b4a23d
parent 482268 278205a39cd87fae34b84827c4188147d8ee2b1e
child 482270 1edf0457ac230fdbdb31fd621bb49c4188daa9fc
push id89664
push userkgupta@mozilla.com
push dateWed, 10 Jul 2019 20:02:54 +0000
treeherderautoland@dc058b3425f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1563178
milestone70.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 1563178 - Properly manage the renderRoot variable during the APZ tree walk. r=botond The APZ tree walk is recursive but the render root was not being updated when walking up out of a subtree with a different render root. This changes the code to use a stack and push/pop the render root for subtrees as we enter and exit the subtrees as part of the tree walk. Differential Revision: https://phabricator.services.mozilla.com/D37614
gfx/layers/apz/src/APZCTreeManager.cpp
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -406,17 +406,18 @@ APZCTreeManager::UpdateHitTestingTreeImp
   bool haveRootContentOutsideAsyncZoomContainer = false;
 
   if (aRoot) {
     std::stack<gfx::TreeAutoIndent<LOG_DEFAULT>> indents;
     std::stack<AncestorTransform> ancestorTransforms;
     HitTestingTreeNode* parent = nullptr;
     HitTestingTreeNode* next = nullptr;
     LayersId layersId = mRootLayersId;
-    wr::RenderRoot renderRoot = wr::RenderRoot::Default;
+    std::stack<wr::RenderRoot> renderRoots;
+    renderRoots.push(wr::RenderRoot::Default);
     ancestorTransforms.push(AncestorTransform());
     state.mParentHasPerspective.push(false);
 
     mApzcTreeLog << "[start]\n";
     mTreeLock.AssertCurrentThreadIn();
 
     ForEachNode<ReverseIterator>(
         aRoot,
@@ -436,17 +437,17 @@ APZCTreeManager::UpdateHitTestingTreeImp
           // metadata to be on the same node as the async zoom container.
           if (aLayerMetrics.Metrics().IsRootContent() &&
               asyncZoomContainerNestingDepth == 0) {
             haveRootContentOutsideAsyncZoomContainer = true;
           }
 
           HitTestingTreeNode* node = PrepareNodeForLayer(
               lock, aLayerMetrics, aLayerMetrics.Metrics(), layersId,
-              ancestorTransforms.top(), parent, next, state, renderRoot);
+              ancestorTransforms.top(), parent, next, state, renderRoots.top());
           MOZ_ASSERT(node);
           AsyncPanZoomController* apzc = node->GetApzc();
           aLayerMetrics.SetApzc(apzc);
 
           // GetScrollbarAnimationId is only set when webrender is enabled,
           // which limits the extra thumb mapping work to the webrender-enabled
           // case where it is needed.
           // Note also that when webrender is enabled, a "valid" animation id
@@ -485,17 +486,17 @@ APZCTreeManager::UpdateHitTestingTreeImp
           next = nullptr;
 
           // Update the layersId or renderroot if we have a new one
           if (Maybe<LayersId> newLayersId = aLayerMetrics.GetReferentId()) {
             layersId = *newLayersId;
           }
           if (Maybe<wr::RenderRoot> newRenderRoot =
                   aLayerMetrics.GetReferentRenderRoot()) {
-            renderRoot = *newRenderRoot;
+            renderRoots.push(*newRenderRoot);
           }
 
           indents.push(gfx::TreeAutoIndent<LOG_DEFAULT>(mApzcTreeLog));
           state.mParentHasPerspective.push(
               aLayerMetrics.TransformIsPerspective());
         },
         [&](ScrollNode aLayerMetrics) {
           if (aLayerMetrics.IsAsyncZoomContainer()) {
@@ -503,16 +504,19 @@ APZCTreeManager::UpdateHitTestingTreeImp
           }
 
           next = parent;
           parent = parent->GetParent();
           layersId = next->GetLayersId();
           ancestorTransforms.pop();
           indents.pop();
           state.mParentHasPerspective.pop();
+          if (aLayerMetrics.GetReferentRenderRoot()) {
+            renderRoots.pop();
+          }
         });
 
     mApzcTreeLog << "[end]\n";
 
     MOZ_ASSERT(
         !mUsingAsyncZoomContainer || !haveRootContentOutsideAsyncZoomContainer,
         "If there is an async zoom container, all scroll nodes with root "
         "content scroll metadata should be inside it");