Bug 1421885 - Part 1: Don't let mNoActionRegion get complex when we've already added it to mDispatchToContentRegion. r?kats
MozReview-Commit-ID: 8oBbyseQsCV
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -654,16 +654,18 @@ public:
nsRegion mHorizontalPanRegion;
/**
* The region for this PaintedLayer that is sensitive to events and
* allows vertical panning but not zooming. This is an approximation
* and any deviation from the true region will be part of the
* mDispatchToContentHitRegion.
*/
nsRegion mVerticalPanRegion;
+
+ bool mCollapsedTouchActions = false;
/**
* Scaled versions of the bounds of mHitRegion and mMaybeHitRegion.
* We store these because FindPaintedLayerFor() needs to consume them
* in this form, and it's a hot code path so we don't want to scale
* them inside that function.
*/
nsIntRect mScaledHitRegionBounds;
nsIntRect mScaledMaybeHitRegionBounds;
@@ -3872,18 +3874,25 @@ PaintedLayerData::AccumulateHitTestInfo(
if (aItem->HitTestInfo() & CompositorHitTestInfo::eRequiresTargetConfirmation) {
mDTCRequiresTargetConfirmation = true;
}
}
auto touchFlags = hitTestInfo & CompositorHitTestInfo::eTouchActionMask;
if (touchFlags) {
- // something was disabled
- if (touchFlags == CompositorHitTestInfo::eTouchActionMask) {
+ // If there are multiple touch-action areas, there are multiple elements with
+ // touch-action properties. We don't know what the relationship is between
+ // those elements in terms of DOM ancestry, and so we don't know how to
+ // combine the regions properly. Instead, we just add all the areas to the
+ // dispatch-to-content region, so that the APZ knows to check with the
+ // main thread. See bug 1286957.
+ if (mCollapsedTouchActions) {
+ mDispatchToContentHitRegion.OrWith(area);
+ } else if (touchFlags == CompositorHitTestInfo::eTouchActionMask) {
// everything was disabled, so touch-action:none
mNoActionRegion.OrWith(area);
} else {
// The event regions code does not store enough information to actually
// represent all the different states. Prior to the introduction of
// CompositorHitTestInfo here in bug 1389149, the following two cases
// were effectively getting collapsed:
// (1) touch-action: auto
@@ -3909,28 +3918,34 @@ PaintedLayerData::AccumulateHitTestInfo(
} else {
// the touch-action: manipulation case described above. To preserve the
// existing behaviour, don't touch either mHorizontalPanRegion or
// mVerticalPanRegion
}
}
}
- // If there are multiple touch-action areas, there are multiple elements with
- // touch-action properties. We don't know what the relationship is between
- // those elements in terms of DOM ancestry, and so we don't know how to
- // combine the regions properly. Instead, we just add all the areas to the
- // dispatch-to-content region, so that the APZ knows to check with the
- // main thread. See bug 1286957.
- const int alreadyHadRegions = mNoActionRegion.GetNumRects() +
- mHorizontalPanRegion.GetNumRects() +
- mVerticalPanRegion.GetNumRects();
-
- if (alreadyHadRegions > 1) {
- mDispatchToContentHitRegion.OrWith(CombinedTouchActionRegion());
+ if (!mCollapsedTouchActions) {
+ // If there are multiple touch-action areas, there are multiple elements with
+ // touch-action properties. We don't know what the relationship is between
+ // those elements in terms of DOM ancestry, and so we don't know how to
+ // combine the regions properly. Instead, we just add all the areas to the
+ // dispatch-to-content region, so that the APZ knows to check with the
+ // main thread. See bug 1286957.
+ const int alreadyHadRegions = mNoActionRegion.GetNumRects() +
+ mHorizontalPanRegion.GetNumRects() +
+ mVerticalPanRegion.GetNumRects();
+
+ if (alreadyHadRegions > 1) {
+ mDispatchToContentHitRegion.OrWith(CombinedTouchActionRegion());
+ mNoActionRegion.SetEmpty();
+ mHorizontalPanRegion.SetEmpty();
+ mVerticalPanRegion.SetEmpty();
+ mCollapsedTouchActions = true;
+ }
}
// Avoid quadratic performance as a result of the region growing to include
// and arbitrarily large number of rects, which can happen on some pages.
mMaybeHitRegion.SimplifyOutward(8);
mDispatchToContentHitRegion.SimplifyOutward(8);
// Calculate scaled versions of the bounds of mHitRegion and mMaybeHitRegion