Bug 1113386 - Don't send long-press events if they begin on a fast-motion block. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 23 Dec 2014 11:05:46 -0500
changeset 221193 2f392da0634f51edd5b9ddf04e3b38bfdd7e9381
parent 221192 23fc520af341e69b71c23111f3205ee054a3b52e
child 221194 a23075b6065e4604b048dd27a475377ed1d85e98
push id53294
push userkwierso@gmail.com
push dateWed, 24 Dec 2014 00:54:16 +0000
treeherdermozilla-inbound@c5d1be9b095a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1113386
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1113386 - Don't send long-press events if they begin on a fast-motion block. r=botond
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/InputQueue.cpp
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1657,16 +1657,20 @@ nsEventStatus AsyncPanZoomController::On
 
 nsEventStatus AsyncPanZoomController::OnLongPress(const TapGestureInput& aEvent) {
   APZC_LOG("%p got a long-press in state %d\n", this, mState);
   nsRefPtr<GeckoContentController> controller = GetGeckoContentController();
   if (controller) {
     int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers);
     CSSPoint geckoScreenPoint;
     if (ConvertToGecko(aEvent.mLocalPoint, &geckoScreenPoint)) {
+      if (CurrentTouchBlock()->IsDuringFastMotion()) {
+        APZC_LOG("%p dropping long-press because of fast motion\n", this);
+        return nsEventStatus_eIgnore;
+      }
       uint64_t blockId = GetInputQueue()->InjectNewTouchBlock(this);
       controller->HandleLongTap(geckoScreenPoint, modifiers, GetGuid(), blockId);
       return nsEventStatus_eConsumeNoDefault;
     }
   }
   return nsEventStatus_eIgnore;
 }
 
--- a/gfx/layers/apz/src/InputQueue.cpp
+++ b/gfx/layers/apz/src/InputQueue.cpp
@@ -105,16 +105,17 @@ InputQueue::ReceiveTouchInput(const nsRe
   nsRefPtr<AsyncPanZoomController> target = block->GetTargetApzc();
 
   nsEventStatus result = nsEventStatus_eIgnore;
 
   // XXX calling ArePointerEventsConsumable on |target| may be wrong here if
   // the target isn't confirmed and the real target turns out to be something
   // else. For now assume this is rare enough that it's not an issue.
   if (block->IsDuringFastMotion()) {
+    INPQ_LOG("dropping event due to block %p being in fast motion\n", block);
     result = nsEventStatus_eConsumeNoDefault;
   } else if (target && target->ArePointerEventsConsumable(block, aEvent.AsMultiTouchInput().mTouches.Length())) {
     result = nsEventStatus_eConsumeDoDefault;
   }
   if (!MaybeHandleCurrentBlock(target, block, aEvent)) {
     block->AddEvent(aEvent.AsMultiTouchInput());
   }
   return result;
@@ -219,18 +220,18 @@ InputQueue::MaybeRequestContentResponse(
 }
 
 uint64_t
 InputQueue::InjectNewTouchBlock(AsyncPanZoomController* aTarget)
 {
   TouchBlockState* block = StartNewTouchBlock(aTarget,
     /* aTargetConfirmed = */ true,
     /* aCopyAllowedTouchBehaviorFromCurrent = */ true);
-  INPQ_LOG("%p injecting new touch block with id %" PRIu64 " and target %p\n",
-    this, block->GetBlockId(), aTarget);
+  INPQ_LOG("injecting new touch block %p with id %" PRIu64 " and target %p\n",
+    block, block->GetBlockId(), aTarget);
   ScheduleMainThreadTimeout(aTarget, block->GetBlockId());
   return block->GetBlockId();
 }
 
 void
 InputQueue::SweepDepletedBlocks()
 {
   // We're going to start a new block, so clear out any depleted blocks at the head of the queue.