Bug 1217818 - Add support for the mHandledByAPZ flag on touch events as well. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 28 Oct 2015 12:53:34 -0400
changeset 270017 3e2f7db053c62fc44c65a35ae8b711637c5450a2
parent 270016 0370dcc7ca0fa1103066b07fd703821cf2f21104
child 270018 17a95e197925af9867b4474e848fde717df4ace0
push idunknown
push userunknown
push dateunknown
reviewersbotond
bugs1217818
milestone44.0a1
Bug 1217818 - Add support for the mHandledByAPZ flag on touch events as well. r=botond
gfx/layers/apz/src/APZCTreeManager.cpp
widget/BasicEvents.h
widget/InputData.cpp
widget/InputData.h
widget/TouchEvents.h
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -683,16 +683,17 @@ APZCTreeManager::ReceiveInputEvent(Input
   if (aOutInputBlockId) {
     *aOutInputBlockId = InputBlockState::NO_BLOCK_ID;
   }
   nsEventStatus result = nsEventStatus_eIgnore;
   HitTestResult hitResult = HitNothing;
   switch (aEvent.mInputType) {
     case MULTITOUCH_INPUT: {
       MultiTouchInput& touchInput = aEvent.AsMultiTouchInput();
+      touchInput.mHandledByAPZ = true;
       result = ProcessTouchInput(touchInput, aOutTargetGuid, aOutInputBlockId);
       break;
     } case MOUSE_INPUT: {
       MouseInput& mouseInput = aEvent.AsMouseInput();
 
       RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(mouseInput.mOrigin,
                                                             &hitResult);
       if (apzc) {
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -108,17 +108,17 @@ public:
   bool    mOnlyChromeDispatch : 1;
   // If mWantReplyFromContentProcess is true, the event will be redispatched
   // in the parent process after the content process has handled it. Useful
   // for when the parent process need the know first how the event was used
   // by content before handling it itself.
   bool mWantReplyFromContentProcess : 1;
   // The event's action will be handled by APZ. The main thread should not
   // perform its associated action. This is currently only relevant for
-  // wheel events.
+  // wheel and touch events.
   bool mHandledByAPZ : 1;
 
   // If the event is being handled in target phase, returns true.
   inline bool InTargetPhase() const
   {
     return (mInBubblingPhase && mInCapturePhase);
   }
 
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -81,16 +81,17 @@ MouseInput::TransformToLocal(const gfx::
   mLocalOrigin = *point;
 
   return true;
 }
 
 MultiTouchInput::MultiTouchInput(const WidgetTouchEvent& aTouchEvent)
   : InputData(MULTITOUCH_INPUT, aTouchEvent.time, aTouchEvent.timeStamp,
               aTouchEvent.modifiers)
+  , mHandledByAPZ(aTouchEvent.mFlags.mHandledByAPZ)
 {
   MOZ_ASSERT(NS_IsMainThread(),
              "Can only copy from WidgetTouchEvent on main thread");
 
   switch (aTouchEvent.mMessage) {
     case eTouchStart:
       mType = MULTITOUCH_START;
       break;
@@ -158,16 +159,17 @@ MultiTouchInput::ToWidgetTouchEvent(nsIW
   WidgetTouchEvent event(true, touchEventMessage, aWidget);
   if (touchEventMessage == eVoidEvent) {
     return event;
   }
 
   event.modifiers = this->modifiers;
   event.time = this->mTime;
   event.timeStamp = this->mTimeStamp;
+  event.mFlags.mHandledByAPZ = mHandledByAPZ;
 
   for (size_t i = 0; i < mTouches.Length(); i++) {
     *event.touches.AppendElement() = mTouches[i].ToNewDOMTouch();
   }
 
   return event;
 }
 
@@ -200,16 +202,17 @@ MultiTouchInput::ToWidgetMouseEvent(nsIW
   const SingleTouchData& firstTouch = mTouches[0];
   event.refPoint.x = firstTouch.mScreenPoint.x;
   event.refPoint.y = firstTouch.mScreenPoint.y;
 
   event.time = mTime;
   event.button = WidgetMouseEvent::eLeftButton;
   event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
   event.modifiers = modifiers;
+  event.mFlags.mHandledByAPZ = mHandledByAPZ;
 
   if (mouseEventMessage != eMouseMove) {
     event.clickCount = 1;
   }
 
   return event;
 }
 
@@ -228,16 +231,17 @@ MultiTouchInput::IndexOfTouch(int32_t aT
 // the B2G emulator we can only receive mouse events, but we need to be able
 // to pan correctly. To do this, we convert the events into a format that the
 // panning code can handle. This code is very limited and only supports
 // SingleTouchData. It also sends garbage for the identifier, radius, force
 // and rotation angle.
 MultiTouchInput::MultiTouchInput(const WidgetMouseEvent& aMouseEvent)
   : InputData(MULTITOUCH_INPUT, aMouseEvent.time, aMouseEvent.timeStamp,
               aMouseEvent.modifiers)
+  , mHandledByAPZ(aMouseEvent.mFlags.mHandledByAPZ)
 {
   MOZ_ASSERT(NS_IsMainThread(),
              "Can only copy from WidgetMouseEvent on main thread");
   switch (aMouseEvent.mMessage) {
   case eMouseDown:
     mType = MULTITOUCH_START;
     break;
   case eMouseMove:
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -203,30 +203,33 @@ public:
     MULTITOUCH_START,
     MULTITOUCH_MOVE,
     MULTITOUCH_END,
     MULTITOUCH_CANCEL
   };
 
   MultiTouchInput(MultiTouchType aType, uint32_t aTime, TimeStamp aTimeStamp,
                   Modifiers aModifiers)
-    : InputData(MULTITOUCH_INPUT, aTime, aTimeStamp, aModifiers),
-      mType(aType)
+    : InputData(MULTITOUCH_INPUT, aTime, aTimeStamp, aModifiers)
+    , mType(aType)
+    , mHandledByAPZ(false)
   {
   }
 
   MultiTouchInput()
     : InputData(MULTITOUCH_INPUT)
+    , mHandledByAPZ(false)
   {
   }
 
   MultiTouchInput(const MultiTouchInput& aOther)
     : InputData(MULTITOUCH_INPUT, aOther.mTime,
                 aOther.mTimeStamp, aOther.modifiers)
     , mType(aOther.mType)
+    , mHandledByAPZ(aOther.mHandledByAPZ)
   {
     mTouches.AppendElements(aOther.mTouches);
   }
 
   explicit MultiTouchInput(const WidgetTouchEvent& aTouchEvent);
   WidgetTouchEvent ToWidgetTouchEvent(nsIWidget* aWidget) const;
   WidgetMouseEvent ToWidgetMouseEvent(nsIWidget* aWidget) const;
 
@@ -241,16 +244,17 @@ public:
   // SingleTouchData. It also sends garbage for the identifier, radius, force
   // and rotation angle.
   explicit MultiTouchInput(const WidgetMouseEvent& aMouseEvent);
 
   bool TransformToLocal(const gfx::Matrix4x4& aTransform);
 
   MultiTouchType mType;
   nsTArray<SingleTouchData> mTouches;
+  bool mHandledByAPZ;
 };
 
 class MouseInput : public InputData
 {
 public:
   enum MouseType
   {
     MOUSE_MOVE,
--- a/widget/TouchEvents.h
+++ b/widget/TouchEvents.h
@@ -169,16 +169,17 @@ public:
     : WidgetInputEvent(aOther.mFlags.mIsTrusted, aOther.mMessage, aOther.widget,
                        eTouchEventClass)
   {
     modifiers = aOther.modifiers;
     time = aOther.time;
     timeStamp = aOther.timeStamp;
     touches.AppendElements(aOther.touches);
     mFlags.mCancelable = mMessage != eTouchCancel;
+    mFlags.mHandledByAPZ = aOther.mFlags.mHandledByAPZ;
     MOZ_COUNT_CTOR(WidgetTouchEvent);
   }
 
   WidgetTouchEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
     : WidgetInputEvent(aIsTrusted, aMessage, aWidget, eTouchEventClass)
   {
     MOZ_COUNT_CTOR(WidgetTouchEvent);
     mFlags.mCancelable = mMessage != eTouchCancel;