Commit 9e38acbf authored by Kartikaya Gupta's avatar Kartikaya Gupta
Browse files

Bug 1525570 - Propagate preventDefault from first to subsequent touchstarts. r=botond

Other mobile browsers disallow browser-based pinch zooming when the
first touchstart is preventDefaulted, even if the second one is not. We
allowed pinch zooming in that scenario. This patch makes it so that if
the first touchstart is preventDefaulted, then subsequent touchstart
events are also preventDefaulted, which brings our behaviour in line
with that of other browsers.

Differential Revision:

extra : moz-landing-system : lando
parent b8f269fd
......@@ -104,6 +104,7 @@ APZEventState::APZEventState(nsIWidget* aWidget,
mLastTouchIdentifier(0) {
nsresult rv;
......@@ -337,6 +338,22 @@ void APZEventState::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
// for events that went through APZ (which should be all of them).
// If the first touchstart event was preventDefaulted, ensure that any
// subsequent additional touchstart events also get preventDefaulted. This
// ensures that e.g. pinch zooming is prevented even if just the first
// touchstart was prevented by content.
if (mTouchCounter.GetActiveTouchCount() == 0) {
mFirstTouchCancelled = isTouchPrevented;
} else {
if (mFirstTouchCancelled && !isTouchPrevented) {
"Propagating prevent-default from first-touch for block %" PRIu64
isTouchPrevented |= mFirstTouchCancelled;
if (isTouchPrevented) {
mContentReceivedInputBlockCallback(aGuid, aInputBlockId,
......@@ -373,6 +390,11 @@ void APZEventState::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
if (mTouchCounter.GetActiveTouchCount() == 0) {
mFirstTouchCancelled = false;
if (sentContentResponse && !isTouchPrevented &&
aApzResponse == nsEventStatus_eConsumeDoDefault &&
gfxPrefs::PointerEventsEnabled()) {
......@@ -13,6 +13,7 @@
#include "mozilla/EventForwards.h"
#include "mozilla/layers/GeckoContentController.h" // for APZStateChange
#include "mozilla/layers/ScrollableLayerGuid.h" // for ScrollableLayerGuid
#include "mozilla/layers/TouchCounter.h" // for TouchCounter
#include "mozilla/RefPtr.h"
#include "nsCOMPtr.h"
#include "nsISupportsImpl.h" // for NS_INLINE_DECL_REFCOUNTING
......@@ -94,10 +95,12 @@ class APZEventState {
nsWeakPtr mWidget;
RefPtr<ActiveElementManager> mActiveElementManager;
ContentReceivedInputBlockCallback mContentReceivedInputBlockCallback;
TouchCounter mTouchCounter;
bool mPendingTouchPreventedResponse;
ScrollableLayerGuid mPendingTouchPreventedGuid;
uint64_t mPendingTouchPreventedBlockId;
bool mEndTouchIsClick;
bool mFirstTouchCancelled;
bool mTouchEndCancelled;
int32_t mLastTouchIdentifier;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment