Bug 1406008 - Try to better handle an edge case in APZ hit-testing with layers-free WR. r?jrmuizel
MozReview-Commit-ID: DNAHx2e6uRF
--- 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()) {