Bug 951793 - Obey overscroll-behavior for any overscroll effect. r=kats
MozReview-Commit-ID: HyATx3aCmmm
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -2804,18 +2804,18 @@ void AsyncPanZoomController::OverscrollB
RecursiveMutexAutoLock lock(mRecursiveMutex);
// Do not go into overscroll in a direction in which we have no room to
// scroll to begin with.
bool xCanScroll = mX.CanScroll();
bool yCanScroll = mY.CanScroll();
bool xConsumed = FuzzyEqualsAdditive(aOverscroll.x, 0.0f, COORDINATE_EPSILON);
bool yConsumed = FuzzyEqualsAdditive(aOverscroll.y, 0.0f, COORDINATE_EPSILON);
- bool shouldOverscrollX = xCanScroll && !xConsumed;
- bool shouldOverscrollY = yCanScroll && !yConsumed;
+ bool shouldOverscrollX = xCanScroll && !xConsumed && mX.OverscrollBehaviorAllowsOverscrollEffect();
+ bool shouldOverscrollY = yCanScroll && !yConsumed && mY.OverscrollBehaviorAllowsOverscrollEffect();
mOverscrollEffect->ConsumeOverscroll(aOverscroll, shouldOverscrollX, shouldOverscrollY);
}
RefPtr<const OverscrollHandoffChain> AsyncPanZoomController::BuildOverscrollHandoffChain() {
if (APZCTreeManager* treeManagerLocal = GetApzcTreeManager()) {
return treeManagerLocal->BuildOverscrollHandoffChain(this);
}
@@ -2887,17 +2887,28 @@ void AsyncPanZoomController::HandleFling
APZCTreeManager* treeManagerLocal = GetApzcTreeManager();
if (treeManagerLocal) {
const FlingHandoffState handoffState{aVelocity,
aOverscrollHandoffChain,
true /* handoff */,
aScrolledApzc};
ParentLayerPoint residualVelocity = treeManagerLocal->DispatchFling(this, handoffState);
if (!IsZero(residualVelocity) && IsPannable() && gfxPrefs::APZOverscrollEnabled()) {
- mOverscrollEffect->HandleFlingOverscroll(residualVelocity);
+ // Obey overscroll-behavior.
+ RecursiveMutexAutoLock lock(mRecursiveMutex);
+ if (!mX.OverscrollBehaviorAllowsOverscrollEffect()) {
+ residualVelocity.x = 0;
+ }
+ if (!mY.OverscrollBehaviorAllowsOverscrollEffect()) {
+ residualVelocity.y = 0;
+ }
+
+ if (!IsZero(residualVelocity)) {
+ mOverscrollEffect->HandleFlingOverscroll(residualVelocity);
+ }
}
}
}
void AsyncPanZoomController::HandleSmoothScrollOverscroll(const ParentLayerPoint& aVelocity) {
// We must call BuildOverscrollHandoffChain from this deferred callback
// function in order to avoid a deadlock when acquiring the tree lock.
HandleFlingOverscroll(aVelocity, BuildOverscrollHandoffChain(), nullptr);