Bug 795567 - Part 5: Add zoom prevention based on the touch-action value. r=kats

This commit is contained in:
Nick Lebedev 2014-01-15 10:03:16 -05:00
parent d4749b9941
commit fdd089b63d
2 changed files with 26 additions and 0 deletions

View File

@ -758,6 +758,11 @@ nsEventStatus AsyncPanZoomController::OnTouchCancel(const MultiTouchInput& aEven
nsEventStatus AsyncPanZoomController::OnScaleBegin(const PinchGestureInput& aEvent) {
APZC_LOG("%p got a scale-begin in state %d\n", this, mState);
if (!TouchActionAllowZoom()) {
return nsEventStatus_eIgnore;
}
if (!mZoomConstraints.mAllowZoom) {
return nsEventStatus_eConsumeNoDefault;
}
@ -1726,6 +1731,22 @@ void AsyncPanZoomController::CheckContentResponse() {
}
}
bool AsyncPanZoomController::TouchActionAllowZoom() {
if (!mTouchActionPropertyEnabled) {
return true;
}
// Pointer events specification implies all touch points to allow zoom
// to perform it.
for (size_t i = 0; i < mAllowedTouchBehaviors.Length(); i++) {
if (!(mAllowedTouchBehaviors[i] & AllowedTouchBehavior::ZOOM)) {
return false;
}
}
return true;
}
AsyncPanZoomController::TouchBehaviorFlags
AsyncPanZoomController::GetTouchBehavior(uint32_t touchIndex) {
if (touchIndex < mAllowedTouchBehaviors.Length()) {

View File

@ -538,6 +538,11 @@ private:
was not set yet. we still need to abort animations. */
};
/*
* Returns whether current touch behavior values allow zooming.
*/
bool TouchActionAllowZoom();
/*
* Returns allowed touch behavior from the mAllowedTouchBehavior array.
* In case apzc didn't receive touch behavior values within the timeout