Bug 1292064 - [Pointer Event] Add digitizer/pen tangential (barrel) pressure and twist. r=smaug
authorStone Shih <sshih@mozilla.com>
Thu, 09 Feb 2017 10:49:00 +0800
changeset 391755 2fd6a5c4759f0d83ac771f24117687eb406a0a76
parent 391754 6b1f71852f5f7493bbb2220bacdc1ad05453e07f
child 391756 17853e6961133ff988dbce520c611a95583f503a
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1292064
milestone54.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 1292064 - [Pointer Event] Add digitizer/pen tangential (barrel) pressure and twist. r=smaug
dom/events/PointerEvent.cpp
dom/events/PointerEvent.h
dom/webidl/PointerEvent.webidl
widget/MouseEvents.h
widget/nsGUIEventIPC.h
--- a/dom/events/PointerEvent.cpp
+++ b/dom/events/PointerEvent.cpp
@@ -88,18 +88,20 @@ PointerEvent::Constructor(EventTarget* a
                     aParam.mRelatedTarget);
   e->InitializeExtraMouseEventDictionaryMembers(aParam);
 
   WidgetPointerEvent* widgetEvent = e->mEvent->AsPointerEvent();
   widgetEvent->pointerId = aParam.mPointerId;
   widgetEvent->mWidth = aParam.mWidth;
   widgetEvent->mHeight = aParam.mHeight;
   widgetEvent->pressure = aParam.mPressure;
+  widgetEvent->tangentialPressure = aParam.mTangentialPressure;
   widgetEvent->tiltX = aParam.mTiltX;
   widgetEvent->tiltY = aParam.mTiltY;
+  widgetEvent->twist = aParam.mTwist;
   widgetEvent->inputSource = ConvertStringToPointerType(aParam.mPointerType);
   widgetEvent->mIsPrimary = aParam.mIsPrimary;
   widgetEvent->buttons = aParam.mButtons;
 
   e->SetTrusted(trusted);
   e->SetComposed(aParam.mComposed);
   return e.forget();
 }
@@ -140,28 +142,40 @@ PointerEvent::Height()
 }
 
 float
 PointerEvent::Pressure()
 {
   return mEvent->AsPointerEvent()->pressure;
 }
 
+float
+PointerEvent::TangentialPressure()
+{
+  return mEvent->AsPointerEvent()->tangentialPressure;
+}
+
 int32_t
 PointerEvent::TiltX()
 {
   return mEvent->AsPointerEvent()->tiltX;
 }
 
 int32_t
 PointerEvent::TiltY()
 {
   return mEvent->AsPointerEvent()->tiltY;
 }
 
+int32_t
+PointerEvent::Twist()
+{
+  return mEvent->AsPointerEvent()->twist;
+}
+
 bool
 PointerEvent::IsPrimary()
 {
   return mEvent->AsPointerEvent()->mIsPrimary;
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/events/PointerEvent.h
+++ b/dom/events/PointerEvent.h
@@ -39,18 +39,20 @@ public:
   Constructor(EventTarget* aOwner,
               const nsAString& aType,
               const PointerEventInit& aParam);
 
   int32_t PointerId();
   int32_t Width();
   int32_t Height();
   float Pressure();
+  float TangentialPressure();
   int32_t TiltX();
   int32_t TiltY();
+  int32_t Twist();
   bool IsPrimary();
   void GetPointerType(nsAString& aPointerType);
 };
 
 void ConvertPointerTypeToString(uint16_t aPointerTypeSrc, nsAString& aPointerTypeDest);
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/webidl/PointerEvent.webidl
+++ b/dom/webidl/PointerEvent.webidl
@@ -12,26 +12,30 @@ interface WindowProxy;
 [Pref="dom.w3c_pointer_events.enabled",
  Constructor(DOMString type, optional PointerEventInit eventInitDict)]
 interface PointerEvent : MouseEvent
 {
   readonly attribute long pointerId;
   readonly attribute long width;
   readonly attribute long height;
   readonly attribute float pressure;
+  readonly attribute float tangentialPressure;
   readonly attribute long tiltX;
   readonly attribute long tiltY;
+  readonly attribute long twist;
   readonly attribute DOMString pointerType;
   readonly attribute boolean isPrimary;
 };
 
 dictionary PointerEventInit : MouseEventInit
 {
   long pointerId = 0;
   long width = 1;
   long height = 1;
   float pressure = 0;
+  float tangentialPressure = 0;
   long tiltX = 0;
   long tiltY = 0;
+  long twist = 0;
   DOMString pointerType = "";
   boolean isPrimary = false;
 };
 
--- a/widget/MouseEvents.h
+++ b/widget/MouseEvents.h
@@ -41,42 +41,51 @@ namespace dom {
  ******************************************************************************/
 
 class WidgetPointerHelper
 {
 public:
   uint32_t pointerId;
   uint32_t tiltX;
   uint32_t tiltY;
+  uint32_t twist;
+  float tangentialPressure;
   bool convertToPointer;
   bool retargetedByPointerCapture;
 
   WidgetPointerHelper()
     : pointerId(0)
     , tiltX(0)
     , tiltY(0)
+    , twist(0)
+    , tangentialPressure(0)
     , convertToPointer(true)
     , retargetedByPointerCapture(false)
   {
   }
 
-  WidgetPointerHelper(uint32_t aPointerId, uint32_t aTiltX, uint32_t aTiltY)
+  WidgetPointerHelper(uint32_t aPointerId, uint32_t aTiltX, uint32_t aTiltY,
+                      uint32_t aTwist = 0, float aTangentialPressure = 0)
     : pointerId(aPointerId)
     , tiltX(aTiltX)
     , tiltY(aTiltY)
+    , twist(aTwist)
+    , tangentialPressure(aTangentialPressure)
     , convertToPointer(true)
     , retargetedByPointerCapture(false)
   {
   }
 
   void AssignPointerHelperData(const WidgetPointerHelper& aEvent)
   {
     pointerId = aEvent.pointerId;
     tiltX = aEvent.tiltX;
     tiltY = aEvent.tiltY;
+    twist = aEvent.twist;
+    tangentialPressure = aEvent.tangentialPressure;
     convertToPointer = aEvent.convertToPointer;
     retargetedByPointerCapture = aEvent.retargetedByPointerCapture;
   }
 };
 
 /******************************************************************************
  * mozilla::WidgetMouseEventBase
  ******************************************************************************/
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -223,26 +223,30 @@ struct ParamTraits<mozilla::WidgetPointe
 {
   typedef mozilla::WidgetPointerHelper paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, aParam.pointerId);
     WriteParam(aMsg, aParam.tiltX);
     WriteParam(aMsg, aParam.tiltY);
+    WriteParam(aMsg, aParam.twist);
+    WriteParam(aMsg, aParam.tangentialPressure);
     // We don't serialize convertToPointer and retargetedByPointerCapture since
     // they are temporarily variable and should be reset to default.
   }
 
   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
   {
     bool rv;
     rv = ReadParam(aMsg, aIter, &aResult->pointerId) &&
          ReadParam(aMsg, aIter, &aResult->tiltX) &&
-         ReadParam(aMsg, aIter, &aResult->tiltY);
+         ReadParam(aMsg, aIter, &aResult->tiltY) &&
+         ReadParam(aMsg, aIter, &aResult->twist) &&
+         ReadParam(aMsg, aIter, &aResult->tangentialPressure);
     return rv;
   }
 };
 
 template<>
 struct ParamTraits<mozilla::WidgetMouseEvent>
 {
   typedef mozilla::WidgetMouseEvent paramType;