Bug 1406008 - Try to better handle an edge case in APZ hit-testing with layers-free WR. r?jrmuizel draft
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 06 Oct 2017 09:29:46 -0400
changeset 676026 c92a6882e96ae3a4a1806bf80b56884b7f288252
parent 676025 78a2ba5000b12bf57f71f95b874000ac4ac69714
child 734825 57357b02921bbb82dfbcb25fd6ba91400d596275
push id83367
push userkgupta@mozilla.com
push dateFri, 06 Oct 2017 13:30:14 +0000
reviewersjrmuizel
bugs1406008
milestone58.0a1
Bug 1406008 - Try to better handle an edge case in APZ hit-testing with layers-free WR. r?jrmuizel MozReview-Commit-ID: DNAHx2e6uRF
gfx/layers/wr/WebRenderCommandBuilder.cpp
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -202,27 +202,40 @@ WebRenderCommandBuilder::CreateWebRender
       // 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);
       }
     }
 
-    if (apzEnabled && forceNewLayerData) {
-      // Pop the thing we pushed before the recursion, so the topmost item on
-      // the stack is enclosing display item's ASR (or the stack is empty)
-      mAsrStack.pop_back();
-      const ActiveScrolledRoot* stopAtAsr =
-          mAsrStack.empty() ? nullptr : mAsrStack.back();
+    if (apzEnabled) {
+      if (forceNewLayerData) {
+        // Pop the thing we pushed before the recursion, so the topmost item on
+        // the stack is enclosing display item's ASR (or the stack is empty)
+        mAsrStack.pop_back();
+        const ActiveScrolledRoot* stopAtAsr =
+            mAsrStack.empty() ? nullptr : mAsrStack.back();
+
+        int32_t descendants = mLayerScrollData.size() - layerCountBeforeRecursing;
 
-      int32_t descendants = mLayerScrollData.size() - layerCountBeforeRecursing;
-
-      mLayerScrollData.emplace_back();
-      mLayerScrollData.back().Initialize(mManager->GetScrollData(), item, descendants, stopAtAsr);
+        mLayerScrollData.emplace_back();
+        mLayerScrollData.back().Initialize(mManager->GetScrollData(), item, descendants, stopAtAsr);
+      } else if (mLayerScrollData.size() != layerCountBeforeRecursing &&
+                 !eventRegions.IsEmpty()) {
+        // We are not forcing a new layer for |item|, but we did create some
+        // layers while recursing. In this case, we need to make sure any
+        // event regions that we were carrying end up on the right layer. So we
+        // do an event region "flush" but retroactively; i.e. the event regions
+        // end up on the layer that was mLayerScrollData.back() prior to the
+        // recursion.
+        MOZ_ASSERT(layerCountBeforeRecursing > 0);
+        mLayerScrollData[layerCountBeforeRecursing - 1].AddEventRegions(eventRegions);
+        eventRegions.SetEmpty();
+      }
     }
   }
 
   // If we have any event region info left over we need to flush it before we
   // return. Again, at this point the layer data list must be non-empty, and
   // the most recently created layer data will have been created by an item
   // with matching ASRs.
   if (!eventRegions.IsEmpty()) {