зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1502010 - Extract helper methods to be more reusable. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D12823 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
7ca67a1530
Коммит
43ba79bb22
|
@ -40,6 +40,18 @@ CalculatePendingDisplayPort(const FrameMetrics& aFrameMetrics,
|
||||||
aFrameMetrics, aVelocity);
|
aFrameMetrics, aVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*static*/ bool
|
||||||
|
IsCloseToHorizontal(float aAngle, float aThreshold)
|
||||||
|
{
|
||||||
|
return (aAngle < aThreshold || aAngle > (M_PI - aThreshold));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ bool
|
||||||
|
IsCloseToVertical(float aAngle, float aThreshold)
|
||||||
|
{
|
||||||
|
return (fabs(aAngle - (M_PI / 2)) < aThreshold);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace apz
|
} // namespace apz
|
||||||
} // namespace layers
|
} // namespace layers
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -131,6 +131,16 @@ void InitializeGlobalState();
|
||||||
const ScreenMargin CalculatePendingDisplayPort(const FrameMetrics& aFrameMetrics,
|
const ScreenMargin CalculatePendingDisplayPort(const FrameMetrics& aFrameMetrics,
|
||||||
const ParentLayerPoint& aVelocity);
|
const ParentLayerPoint& aVelocity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is aAngle within the given threshold of the horizontal axis?
|
||||||
|
* @param aAngle an angle in radians in the range [0, pi]
|
||||||
|
* @param aThreshold an angle in radians in the range [0, pi/2]
|
||||||
|
*/
|
||||||
|
bool IsCloseToHorizontal(float aAngle, float aThreshold);
|
||||||
|
|
||||||
|
// As above, but for the vertical axis.
|
||||||
|
bool IsCloseToVertical(float aAngle, float aThreshold);
|
||||||
|
|
||||||
} // namespace apz
|
} // namespace apz
|
||||||
|
|
||||||
} // namespace layers
|
} // namespace layers
|
||||||
|
|
|
@ -524,22 +524,6 @@ static bool IsHighMemSystem()
|
||||||
return gIsHighMemSystem;
|
return gIsHighMemSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Is aAngle within the given threshold of the horizontal axis?
|
|
||||||
* @param aAngle an angle in radians in the range [0, pi]
|
|
||||||
* @param aThreshold an angle in radians in the range [0, pi/2]
|
|
||||||
*/
|
|
||||||
static bool IsCloseToHorizontal(float aAngle, float aThreshold)
|
|
||||||
{
|
|
||||||
return (aAngle < aThreshold || aAngle > (M_PI - aThreshold));
|
|
||||||
}
|
|
||||||
|
|
||||||
// As above, but for the vertical axis.
|
|
||||||
static bool IsCloseToVertical(float aAngle, float aThreshold)
|
|
||||||
{
|
|
||||||
return (fabs(aAngle - (M_PI / 2)) < aThreshold);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Counter used to give each APZC a unique id
|
// Counter used to give each APZC a unique id
|
||||||
static uint32_t sAsyncPanZoomControllerCount = 0;
|
static uint32_t sAsyncPanZoomControllerCount = 0;
|
||||||
|
|
||||||
|
@ -2765,10 +2749,10 @@ void AsyncPanZoomController::HandlePanningWithTouchAction(double aAngle) {
|
||||||
overscrollHandoffChain->CanScrollInDirection(this, ScrollDirection::eVertical);
|
overscrollHandoffChain->CanScrollInDirection(this, ScrollDirection::eVertical);
|
||||||
if (GetCurrentTouchBlock()->TouchActionAllowsPanningXY()) {
|
if (GetCurrentTouchBlock()->TouchActionAllowsPanningXY()) {
|
||||||
if (canScrollHorizontal && canScrollVertical) {
|
if (canScrollHorizontal && canScrollVertical) {
|
||||||
if (IsCloseToHorizontal(aAngle, gfxPrefs::APZAxisLockAngle())) {
|
if (apz::IsCloseToHorizontal(aAngle, gfxPrefs::APZAxisLockAngle())) {
|
||||||
mY.SetAxisLocked(true);
|
mY.SetAxisLocked(true);
|
||||||
SetState(PANNING_LOCKED_X);
|
SetState(PANNING_LOCKED_X);
|
||||||
} else if (IsCloseToVertical(aAngle, gfxPrefs::APZAxisLockAngle())) {
|
} else if (apz::IsCloseToVertical(aAngle, gfxPrefs::APZAxisLockAngle())) {
|
||||||
mX.SetAxisLocked(true);
|
mX.SetAxisLocked(true);
|
||||||
SetState(PANNING_LOCKED_Y);
|
SetState(PANNING_LOCKED_Y);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2782,7 +2766,7 @@ void AsyncPanZoomController::HandlePanningWithTouchAction(double aAngle) {
|
||||||
} else if (GetCurrentTouchBlock()->TouchActionAllowsPanningX()) {
|
} else if (GetCurrentTouchBlock()->TouchActionAllowsPanningX()) {
|
||||||
// Using bigger angle for panning to keep behavior consistent
|
// Using bigger angle for panning to keep behavior consistent
|
||||||
// with IE.
|
// with IE.
|
||||||
if (IsCloseToHorizontal(aAngle, gfxPrefs::APZAllowedDirectPanAngle())) {
|
if (apz::IsCloseToHorizontal(aAngle, gfxPrefs::APZAllowedDirectPanAngle())) {
|
||||||
mY.SetAxisLocked(true);
|
mY.SetAxisLocked(true);
|
||||||
SetState(PANNING_LOCKED_X);
|
SetState(PANNING_LOCKED_X);
|
||||||
mPanDirRestricted = true;
|
mPanDirRestricted = true;
|
||||||
|
@ -2792,7 +2776,7 @@ void AsyncPanZoomController::HandlePanningWithTouchAction(double aAngle) {
|
||||||
SetState(NOTHING);
|
SetState(NOTHING);
|
||||||
}
|
}
|
||||||
} else if (GetCurrentTouchBlock()->TouchActionAllowsPanningY()) {
|
} else if (GetCurrentTouchBlock()->TouchActionAllowsPanningY()) {
|
||||||
if (IsCloseToVertical(aAngle, gfxPrefs::APZAllowedDirectPanAngle())) {
|
if (apz::IsCloseToVertical(aAngle, gfxPrefs::APZAllowedDirectPanAngle())) {
|
||||||
mX.SetAxisLocked(true);
|
mX.SetAxisLocked(true);
|
||||||
SetState(PANNING_LOCKED_Y);
|
SetState(PANNING_LOCKED_Y);
|
||||||
mPanDirRestricted = true;
|
mPanDirRestricted = true;
|
||||||
|
@ -2823,12 +2807,12 @@ void AsyncPanZoomController::HandlePanning(double aAngle) {
|
||||||
|
|
||||||
if (!canScrollHorizontal || !canScrollVertical) {
|
if (!canScrollHorizontal || !canScrollVertical) {
|
||||||
SetState(PANNING);
|
SetState(PANNING);
|
||||||
} else if (IsCloseToHorizontal(aAngle, gfxPrefs::APZAxisLockAngle())) {
|
} else if (apz::IsCloseToHorizontal(aAngle, gfxPrefs::APZAxisLockAngle())) {
|
||||||
mY.SetAxisLocked(true);
|
mY.SetAxisLocked(true);
|
||||||
if (canScrollHorizontal) {
|
if (canScrollHorizontal) {
|
||||||
SetState(PANNING_LOCKED_X);
|
SetState(PANNING_LOCKED_X);
|
||||||
}
|
}
|
||||||
} else if (IsCloseToVertical(aAngle, gfxPrefs::APZAxisLockAngle())) {
|
} else if (apz::IsCloseToVertical(aAngle, gfxPrefs::APZAxisLockAngle())) {
|
||||||
mX.SetAxisLocked(true);
|
mX.SetAxisLocked(true);
|
||||||
if (canScrollVertical) {
|
if (canScrollVertical) {
|
||||||
SetState(PANNING_LOCKED_Y);
|
SetState(PANNING_LOCKED_Y);
|
||||||
|
@ -2849,12 +2833,12 @@ void AsyncPanZoomController::HandlePanningUpdate(const ScreenPoint& aPanDistance
|
||||||
|
|
||||||
if (fabs(aPanDistance.x) > breakThreshold || fabs(aPanDistance.y) > breakThreshold) {
|
if (fabs(aPanDistance.x) > breakThreshold || fabs(aPanDistance.y) > breakThreshold) {
|
||||||
if (mState == PANNING_LOCKED_X) {
|
if (mState == PANNING_LOCKED_X) {
|
||||||
if (!IsCloseToHorizontal(angle, gfxPrefs::APZAxisBreakoutAngle())) {
|
if (!apz::IsCloseToHorizontal(angle, gfxPrefs::APZAxisBreakoutAngle())) {
|
||||||
mY.SetAxisLocked(false);
|
mY.SetAxisLocked(false);
|
||||||
SetState(PANNING);
|
SetState(PANNING);
|
||||||
}
|
}
|
||||||
} else if (mState == PANNING_LOCKED_Y) {
|
} else if (mState == PANNING_LOCKED_Y) {
|
||||||
if (!IsCloseToVertical(angle, gfxPrefs::APZAxisBreakoutAngle())) {
|
if (!apz::IsCloseToVertical(angle, gfxPrefs::APZAxisBreakoutAngle())) {
|
||||||
mX.SetAxisLocked(false);
|
mX.SetAxisLocked(false);
|
||||||
SetState(PANNING);
|
SetState(PANNING);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче