Bug 1406119 - Ensure that we do all the necessary APZ prep before recursing. r?ethlin draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 05 Oct 2017 13:20:57 -0400
changeset 675685 7b53d3faa8dbe88c8fdf1bbd1a75a1a6c43aeb07
parent 675508 53bbdaaa2b8c1819061be26101b075c081b23260
child 734667 98c3ceadeafd3f9cc7f3c0ae1cc8ca06716d29b2
push id83197
push userkgupta@mozilla.com
push dateThu, 05 Oct 2017 17:21:13 +0000
reviewersethlin
bugs1406119, 1404782
milestone58.0a1
Bug 1406119 - Ensure that we do all the necessary APZ prep before recursing. r?ethlin Bug 1404782 added another codepath that allows the CreateWebRenderCommandsFromDisplayList function to recurse. However recursion is tricky when APZ is enabled because we need to do a bunch of setup and teardown to properly build event regions and track APZ state. This patch moves the new recursion codepath inside the setup and teardown, so that it works as intended. MozReview-Commit-ID: C2Pwld7DdCC
gfx/layers/wr/WebRenderCommandBuilder.cpp
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -121,24 +121,16 @@ WebRenderCommandBuilder::CreateWebRender
       i = peek;
     }
 
     if (mergedItems.Length() > 1) {
       item = aDisplayListBuilder->MergeItems(mergedItems);
       MOZ_ASSERT(item && itemType == item->GetType());
     }
 
-    nsDisplayList* childItems = item->GetSameCoordinateSystemChildren();
-    if (item->ShouldFlattenAway(aDisplayListBuilder)) {
-      MOZ_ASSERT(childItems);
-      CreateWebRenderCommandsFromDisplayList(childItems, aDisplayListBuilder, aSc,
-                                             aBuilder, aResources);
-      continue;
-    }
-
     bool forceNewLayerData = false;
     size_t layerCountBeforeRecursing = mLayerScrollData.size();
     if (apzEnabled) {
       // For some types of display items we want to force a new
       // WebRenderLayerScrollData object, to ensure we preserve the APZ-relevant
       // data that is in the display item.
       forceNewLayerData = item->UpdateScrollData(nullptr, nullptr);
 
@@ -193,17 +185,23 @@ WebRenderCommandBuilder::CreateWebRender
       // If we're going to create a new layer data for this item, stash the
       // ASR so that if we recurse into a sublist they will know where to stop
       // walking up their ASR chain when building scroll metadata.
       if (forceNewLayerData) {
         mAsrStack.push_back(asr);
       }
     }
 
-    { // scope the ScrollingLayersHelper
+    nsDisplayList* childItems = item->GetSameCoordinateSystemChildren();
+    if (item->ShouldFlattenAway(aDisplayListBuilder)) {
+      MOZ_ASSERT(childItems);
+      CreateWebRenderCommandsFromDisplayList(childItems, aDisplayListBuilder, aSc,
+                                             aBuilder, aResources);
+    } else {
+      // ensure the scope of ScrollingLayersHelper is maintained
       ScrollingLayersHelper clip(item, aBuilder, aSc, mClipIdCache, apzEnabled);
 
       // Note: this call to CreateWebRenderCommands can recurse back into
       // this function if the |item| is a wrapper for a sublist.
       if (!item->CreateWebRenderCommands(aBuilder, aResources, aSc, mManager,
                                          aDisplayListBuilder)) {
         PushItemAsImage(item, aBuilder, aResources, aSc, aDisplayListBuilder);
       }