Bug 1458063 - Support constructing a PinchGestureInput with a focus point in Screen coordinates. r=kats
authorBotond Ballo <botond@mozilla.com>
Wed, 02 May 2018 16:41:47 -0400
changeset 472852 201d209f079641567f83f87681da2bd14e9a340f
parent 472851 b0921ba1cfa757b2c46b4efd3cda3079be57fe71
child 472853 34a5f8bd932c7a907c25ba01fd292416a6a186ff
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1458063
milestone61.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 1458063 - Support constructing a PinchGestureInput with a focus point in Screen coordinates. r=kats MozReview-Commit-ID: 9umkUEEWyBQ
widget/InputData.cpp
widget/InputData.h
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -591,31 +591,50 @@ PanGestureInput::UserMultipliedLocalPanD
 
 PinchGestureInput::PinchGestureInput()
   : InputData(PINCHGESTURE_INPUT)
 {
 }
 
 PinchGestureInput::PinchGestureInput(PinchGestureType aType, uint32_t aTime,
                                      TimeStamp aTimeStamp,
+                                     const ScreenPoint& aFocusPoint,
+                                     ParentLayerCoord aCurrentSpan,
+                                     ParentLayerCoord aPreviousSpan,
+                                     Modifiers aModifiers)
+  : InputData(PINCHGESTURE_INPUT, aTime, aTimeStamp, aModifiers)
+  , mType(aType)
+  , mFocusPoint(aFocusPoint)
+  , mCurrentSpan(aCurrentSpan)
+  , mPreviousSpan(aPreviousSpan)
+{
+}
+
+PinchGestureInput::PinchGestureInput(PinchGestureType aType, uint32_t aTime,
+                                     TimeStamp aTimeStamp,
                                      const ParentLayerPoint& aLocalFocusPoint,
                                      ParentLayerCoord aCurrentSpan,
                                      ParentLayerCoord aPreviousSpan,
                                      Modifiers aModifiers)
   : InputData(PINCHGESTURE_INPUT, aTime, aTimeStamp, aModifiers)
   , mType(aType)
   , mLocalFocusPoint(aLocalFocusPoint)
   , mCurrentSpan(aCurrentSpan)
   , mPreviousSpan(aPreviousSpan)
 {
 }
 
 bool
 PinchGestureInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
-{ 
+{
+  if (mFocusPoint == BothFingersLifted<ScreenPixel>()) {
+    // Special value, no transform required.
+    mLocalFocusPoint = BothFingersLifted();
+    return true;
+  }
   Maybe<ParentLayerPoint> point = UntransformBy(aTransform, mFocusPoint);
   if (!point) {
     return false;
   }
   mLocalFocusPoint = *point;
   return true;
 }
 
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -413,16 +413,28 @@ protected:
 public:
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
     PinchGestureType, (
       PINCHGESTURE_START,
       PINCHGESTURE_SCALE,
       PINCHGESTURE_END
   ));
 
+  // Construct a pinch gesture from a Screen point.
+  // (Technically, we should take the span values in Screen pixels as well,
+  // but that would require also storing them in Screen pixels and then
+  // converting them in TransformToLocal() like the focus point. Since pinch
+  // gesture events are processed by the root content APZC, the only transform
+  // between Screen and ParentLayer pixels should be a translation, which is
+  // irrelevant to span values, so we don't bother.)
+  PinchGestureInput(PinchGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
+                    const ScreenPoint& aFocusPoint,
+                    ParentLayerCoord aCurrentSpan,
+                    ParentLayerCoord aPreviousSpan, Modifiers aModifiers);
+
   // Construct a pinch gesture from a ParentLayer point.
   // mFocusPoint remains (0,0) unless it's set later.
   PinchGestureInput(PinchGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
                     const ParentLayerPoint& aLocalFocusPoint,
                     ParentLayerCoord aCurrentSpan,
                     ParentLayerCoord aPreviousSpan, Modifiers aModifiers);
 
   bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);