зеркало из https://github.com/mozilla/gecko-dev.git
Bug 951793 - Obey overscroll-behavior for fling handoff. r=kats
MozReview-Commit-ID: 9i2AgmW3Inm --HG-- extra : rebase_source : 429438b26c2ab0b75690f87bd6b9b0b9187a4567
This commit is contained in:
Родитель
2f514da8d8
Коммит
15d10c1b0d
|
@ -2082,10 +2082,14 @@ APZCTreeManager::DispatchFling(AsyncPanZoomController* aPrev,
|
|||
|
||||
endPoint = startPoint + currentVelocity;
|
||||
|
||||
RefPtr<AsyncPanZoomController> prevApzc = (startIndex > 0)
|
||||
? chain->GetApzcAtIndex(startIndex - 1)
|
||||
: nullptr;
|
||||
|
||||
// Only transform when current apzc can be transformed with previous
|
||||
if (startIndex > 0) {
|
||||
if (prevApzc) {
|
||||
if (!TransformDisplacement(this,
|
||||
chain->GetApzcAtIndex(startIndex - 1),
|
||||
prevApzc,
|
||||
current,
|
||||
startPoint,
|
||||
endPoint)) {
|
||||
|
@ -2093,10 +2097,18 @@ APZCTreeManager::DispatchFling(AsyncPanZoomController* aPrev,
|
|||
}
|
||||
}
|
||||
|
||||
FlingHandoffState transformedHandoffState = aHandoffState;
|
||||
transformedHandoffState.mVelocity = (endPoint - startPoint);
|
||||
ParentLayerPoint availableVelocity = (endPoint - startPoint);
|
||||
ParentLayerPoint residualVelocity;
|
||||
|
||||
ParentLayerPoint residualVelocity = current->AttemptFling(transformedHandoffState);
|
||||
FlingHandoffState transformedHandoffState = aHandoffState;
|
||||
transformedHandoffState.mVelocity = availableVelocity;
|
||||
|
||||
// Obey overscroll-behavior.
|
||||
if (prevApzc) {
|
||||
residualVelocity += prevApzc->AdjustHandoffVelocityForOverscrollBehavior(transformedHandoffState.mVelocity);
|
||||
}
|
||||
|
||||
residualVelocity += current->AttemptFling(transformedHandoffState);
|
||||
|
||||
// If there's no residual velocity, there's nothing more to hand off.
|
||||
if (IsZero(residualVelocity)) {
|
||||
|
@ -2105,13 +2117,16 @@ APZCTreeManager::DispatchFling(AsyncPanZoomController* aPrev,
|
|||
|
||||
// If any of the velocity available to be handed off was consumed,
|
||||
// subtract the proportion of consumed velocity from finalResidualVelocity.
|
||||
if (!FuzzyEqualsAdditive(transformedHandoffState.mVelocity.x,
|
||||
// Note: it's important to compare |residualVelocity| to |availableVelocity|
|
||||
// here and not to |transformedHandoffState.mVelocity|, since the latter
|
||||
// may have been modified by AdjustHandoffVelocityForOverscrollBehavior().
|
||||
if (!FuzzyEqualsAdditive(availableVelocity.x,
|
||||
residualVelocity.x, COORDINATE_EPSILON)) {
|
||||
finalResidualVelocity.x *= (residualVelocity.x / transformedHandoffState.mVelocity.x);
|
||||
finalResidualVelocity.x *= (residualVelocity.x / availableVelocity.x);
|
||||
}
|
||||
if (!FuzzyEqualsAdditive(transformedHandoffState.mVelocity.y,
|
||||
if (!FuzzyEqualsAdditive(availableVelocity.y,
|
||||
residualVelocity.y, COORDINATE_EPSILON)) {
|
||||
finalResidualVelocity.y *= (residualVelocity.y / transformedHandoffState.mVelocity.y);
|
||||
finalResidualVelocity.y *= (residualVelocity.y / availableVelocity.y);
|
||||
}
|
||||
|
||||
currentVelocity = residualVelocity;
|
||||
|
|
|
@ -2825,6 +2825,22 @@ ParentLayerPoint AsyncPanZoomController::AttemptFling(const FlingHandoffState& a
|
|||
return residualVelocity;
|
||||
}
|
||||
|
||||
ParentLayerPoint AsyncPanZoomController::AdjustHandoffVelocityForOverscrollBehavior(ParentLayerPoint& aHandoffVelocity) const
|
||||
{
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
ParentLayerPoint residualVelocity;
|
||||
if (!mX.OverscrollBehaviorAllowsHandoff()) {
|
||||
residualVelocity.x = aHandoffVelocity.x;
|
||||
aHandoffVelocity.x = 0;
|
||||
}
|
||||
if (!mY.OverscrollBehaviorAllowsHandoff()) {
|
||||
residualVelocity.y = aHandoffVelocity.y;
|
||||
aHandoffVelocity.y = 0;
|
||||
}
|
||||
return residualVelocity;
|
||||
}
|
||||
|
||||
|
||||
void AsyncPanZoomController::HandleFlingOverscroll(const ParentLayerPoint& aVelocity,
|
||||
const RefPtr<const OverscrollHandoffChain>& aOverscrollHandoffChain,
|
||||
const RefPtr<const AsyncPanZoomController>& aScrolledApzc) {
|
||||
|
|
|
@ -1011,6 +1011,8 @@ public:
|
|||
*/
|
||||
ParentLayerPoint AttemptFling(const FlingHandoffState& aHandoffState);
|
||||
|
||||
ParentLayerPoint AdjustHandoffVelocityForOverscrollBehavior(ParentLayerPoint& aHandoffVelocity) const;
|
||||
|
||||
private:
|
||||
friend class AndroidFlingAnimation;
|
||||
friend class AutoscrollAnimation;
|
||||
|
|
Загрузка…
Ссылка в новой задаче