Bug 900111 - Fix CSSIntPoints and LayoutDeviceIntPoint usage in APZC Metro implementation. r=kats
authorBrian R. Bondy <netzen@gmail.com>
Thu, 01 Aug 2013 13:44:41 -0400
changeset 153223 c4fcf8be2bd2ae240e6d0faaa2d5fa4a4e661cb4
parent 153222 03a9b0dead08d1a99a48286ec187ee4b259d6cb7
child 153224 2ba2c2534fdbb747c4718b7332876e68d9563aa9
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs900111
milestone25.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 900111 - Fix CSSIntPoints and LayoutDeviceIntPoint usage in APZC Metro implementation. r=kats
widget/windows/winrt/MetroInput.cpp
widget/windows/winrt/MetroInput.h
widget/windows/winrt/MetroWidget.cpp
widget/windows/winrt/MetroWidget.h
--- a/widget/windows/winrt/MetroInput.cpp
+++ b/widget/windows/winrt/MetroInput.cpp
@@ -966,17 +966,17 @@ MetroInput::OnTapped(UI::Input::IGesture
   if (deviceType != Devices::Input::PointerDeviceType::PointerDeviceType_Touch) {
     return S_OK;
   }
 
   Foundation::Point position;
   aArgs->get_Position(&position);
   nsIntPoint pt = MetroUtils::LogToPhys(position);
 
-  CSSIntPoint point(pt.x, pt.y);
+  LayoutDeviceIntPoint point(pt.x, pt.y);
   HandleSingleTap(point);
   return S_OK;
 }
 
 // This event is raised when a sequence of pointer events has been
 // interpreted by the GestureRecognizer as a right tap.
 // This could be a mouse right-click, a right-click on a pen, or
 // a tap-and-hold on a touch surface.
@@ -990,25 +990,25 @@ MetroInput::OnRightTapped(UI::Input::IGe
 
   Devices::Input::PointerDeviceType deviceType;
   aArgs->get_PointerDeviceType(&deviceType);
 
   Foundation::Point position;
   aArgs->get_Position(&position);
   nsIntPoint pt = MetroUtils::LogToPhys(position);
 
-  CSSIntPoint point(pt.x, pt.y);
+  LayoutDeviceIntPoint point(pt.x, pt.y);
   HandleLongTap(point);
 
   return S_OK;
 }
 
 // Used by MetroWidget GeckoContentController callbacks
 void
-MetroInput::HandleDoubleTap(const mozilla::CSSIntPoint& aPoint)
+MetroInput::HandleDoubleTap(const LayoutDeviceIntPoint& aPoint)
 {
 #ifdef DEBUG_INPUT
   LogFunction();
 #endif
   nsSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_TAP, mWidget.Get(), 0, 0.0);
   mModifierKeyState.Update();
   mModifierKeyState.InitInputEvent(geckoEvent);
   geckoEvent.time = ::GetMessageTime();
@@ -1016,17 +1016,17 @@ MetroInput::HandleDoubleTap(const mozill
   geckoEvent.refPoint.x = aPoint.x;
   geckoEvent.refPoint.y = aPoint.y;
   geckoEvent.clickCount = 2;
   geckoEvent.pressure = 1;
   DispatchEventIgnoreStatus(&geckoEvent);
 }
 
 void
-MetroInput::HandleSingleTap(const mozilla::CSSIntPoint& aPoint)
+MetroInput::HandleSingleTap(const LayoutDeviceIntPoint& aPoint)
 {
 #ifdef DEBUG_INPUT
   LogFunction();
 #endif
 
   // Set up the mouse event that we'll reuse for mousemove, mousedown, and
   // mouseup
   nsMouseEvent mouseEvent(true,
@@ -1070,17 +1070,17 @@ MetroInput::HandleSingleTap(const mozill
     mouseEvent.button = 0;
 
     DispatchEventIgnoreStatus(&mouseEvent);
   }
 
 }
 
 void
-MetroInput::HandleLongTap(const mozilla::CSSIntPoint& aPoint)
+MetroInput::HandleLongTap(const LayoutDeviceIntPoint& aPoint)
 {
 #ifdef DEBUG_INPUT
   LogFunction();
 #endif
 
   nsMouseEvent contextMenu(true,
                            NS_CONTEXTMENU,
                            mWidget.Get(),
--- a/widget/windows/winrt/MetroInput.h
+++ b/widget/windows/winrt/MetroInput.h
@@ -147,19 +147,19 @@ public:
                                 IManipulationUpdatedEventArgs* aArgs);
   HRESULT OnManipulationCompleted(IGestureRecognizer* aSender,
                                   IManipulationCompletedEventArgs* aArgs);
   HRESULT OnTapped(IGestureRecognizer* aSender, ITappedEventArgs* aArgs);
   HRESULT OnRightTapped(IGestureRecognizer* aSender,
                         IRightTappedEventArgs* aArgs);
 
   // Used by MetroWidget GeckoContentController callbacks
-  void HandleDoubleTap(const mozilla::CSSIntPoint& aPoint);
-  void HandleSingleTap(const mozilla::CSSIntPoint& aPoint);
-  void HandleLongTap(const mozilla::CSSIntPoint& aPoint);
+  void HandleDoubleTap(const mozilla::LayoutDeviceIntPoint& aPoint);
+  void HandleSingleTap(const mozilla::LayoutDeviceIntPoint& aPoint);
+  void HandleLongTap(const mozilla::LayoutDeviceIntPoint& aPoint);
 
 private:
   Microsoft::WRL::ComPtr<ICoreWindow> mWindow;
   Microsoft::WRL::ComPtr<MetroWidget> mWidget;
   Microsoft::WRL::ComPtr<ICoreDispatcher> mDispatcher;
   Microsoft::WRL::ComPtr<IGestureRecognizer> mGestureRecognizer;
 
   ModifierKeyState mModifierKeyState;
--- a/widget/windows/winrt/MetroWidget.cpp
+++ b/widget/windows/winrt/MetroWidget.cpp
@@ -1018,20 +1018,20 @@ void MetroWidget::UserActivity()
 }
 
 void
 MetroWidget::InitEvent(nsGUIEvent& event, nsIntPoint* aPoint)
 {
   if (!aPoint) {
     event.refPoint.x = event.refPoint.y = 0;
   } else {
-    // convert CSS pixels to device pixels for event.refPoint
-    double scale = GetDefaultScale(); 
-    event.refPoint.x = int32_t(NS_round(aPoint->x * scale));
-    event.refPoint.y = int32_t(NS_round(aPoint->y * scale));
+    CSSIntPoint cssPoint(aPoint->x, aPoint->y);
+    LayoutDeviceIntPoint layoutDeviceIntPoint = CSSIntPointToLayoutDeviceIntPoint(cssPoint);
+    event.refPoint.x = layoutDeviceIntPoint.x;
+    event.refPoint.y = layoutDeviceIntPoint.y;
   }
   event.time = ::GetMessageTime();
 }
 
 bool
 MetroWidget::DispatchWindowEvent(nsGUIEvent* aEvent)
 {
   MOZ_ASSERT(aEvent);
@@ -1108,16 +1108,25 @@ double MetroWidget::GetDefaultScaleInter
     ResolutionScale scale;
     if (SUCCEEDED(dispProps->get_ResolutionScale(&scale))) {
       return (double)scale / 100.0;
     }
   }
   return 1.0;
 }
 
+LayoutDeviceIntPoint
+MetroWidget::CSSIntPointToLayoutDeviceIntPoint(const CSSIntPoint &aCSSPoint)
+{
+  double scale = GetDefaultScale();
+  LayoutDeviceIntPoint devPx(int32_t(NS_round(scale * aCSSPoint.x)),
+                             int32_t(NS_round(scale * aCSSPoint.y)));
+  return devPx;
+}
+
 float MetroWidget::GetDPI()
 {
   LogFunction();
   if (!mView) {
     return 96.0;
   }
   return mView->GetDPI();
 }
@@ -1404,41 +1413,41 @@ void
 MetroWidget::HandleDoubleTap(const CSSIntPoint& aPoint)
 {
   LogFunction();
 
   if (!mMetroInput) {
     return;
   }
 
-  mMetroInput->HandleDoubleTap(aPoint);
+  mMetroInput->HandleDoubleTap(CSSIntPointToLayoutDeviceIntPoint(aPoint));
 }
 
 void
 MetroWidget::HandleSingleTap(const CSSIntPoint& aPoint)
 {
   LogFunction();
 
   if (!mMetroInput) {
     return;
   }
 
-  mMetroInput->HandleSingleTap(aPoint);
+  mMetroInput->HandleSingleTap(CSSIntPointToLayoutDeviceIntPoint(aPoint));
 }
 
 void
 MetroWidget::HandleLongTap(const CSSIntPoint& aPoint)
 {
   LogFunction();
 
   if (!mMetroInput) {
     return;
   }
 
-  mMetroInput->HandleLongTap(aPoint);
+  mMetroInput->HandleLongTap(CSSIntPointToLayoutDeviceIntPoint(aPoint));
 }
 
 void
 MetroWidget::SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const CSSRect &aContentRect, const CSSSize &aScrollableSize)
 {
   LogFunction();
 }
 
--- a/widget/windows/winrt/MetroWidget.h
+++ b/widget/windows/winrt/MetroWidget.h
@@ -116,16 +116,17 @@ public:
                                                     double aDeltaX,
                                                     double aDeltaY,
                                                     double aDeltaZ,
                                                     uint32_t aModifierFlags,
                                                     uint32_t aAdditionalFlags);
   virtual bool  HasPendingInputEvent();
   virtual double GetDefaultScaleInternal();
   float         GetDPI();
+  mozilla::LayoutDeviceIntPoint CSSIntPointToLayoutDeviceIntPoint(const mozilla::CSSIntPoint &aCSSPoint);
   void          ChangedDPI();
   virtual bool  IsVisible() const;
   virtual bool  IsEnabled() const;
   // ShouldUseOffMainThreadCompositing is defined in base widget
   virtual bool  ShouldUseOffMainThreadCompositing();
   bool          ShouldUseMainThreadD3D10Manager();
   bool          ShouldUseBasicManager();
   bool          ShouldUseAPZC();