Bug 1125040: Use LayoutDeviceIntPoint for nsLayoutUtils::GetEventCoordinatesRelativeTo and Touch::mRefPoint r=botond
authorDavid Zbarsky <dzbarsky@gmail.com>
Sun, 01 Feb 2015 17:27:31 -0500
changeset 254090 c36a026244de1d694ddf947c63e5ac08951180bc
parent 254089 05e2d12a1a0c7f23b3446c95fdb0bbf98338acfd
child 254091 9dbdaf7ab14d2de826f6195327e62dc9f0633a5d
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1125040
milestone38.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 1125040: Use LayoutDeviceIntPoint for nsLayoutUtils::GetEventCoordinatesRelativeTo and Touch::mRefPoint r=botond
accessible/base/nsCoreUtils.cpp
dom/base/nsDOMWindowUtils.cpp
dom/events/Event.cpp
dom/events/Touch.cpp
dom/events/Touch.h
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/TabParent.cpp
gfx/layers/apz/util/APZCCallbackHelper.cpp
gfx/layers/apz/util/APZCCallbackHelper.h
layout/base/SelectionCarets.cpp
layout/base/TouchCaret.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/base/nsPresShell.cpp
layout/base/nsPresShell.h
layout/forms/nsNumberControlFrame.cpp
layout/forms/nsRangeFrame.cpp
layout/xul/nsBoxFrame.cpp
widget/ContentHelper.cpp
widget/InputData.cpp
widget/android/AndroidJavaWrappers.cpp
widget/android/nsWindow.cpp
widget/android/nsWindow.h
widget/nsGUIEventIPC.h
widget/windows/nsWindow.cpp
--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -144,17 +144,17 @@ nsCoreUtils::DispatchTouchEvent(uint32_t
   if (!dom::TouchEvent::PrefEnabled())
     return;
 
   WidgetTouchEvent event(true, aEventType, aRootWidget);
 
   event.time = PR_IntervalNow();
 
   // XXX: Touch has an identifier of -1 to hint that it is synthesized.
-  nsRefPtr<dom::Touch> t = new dom::Touch(-1, nsIntPoint(aX, aY),
+  nsRefPtr<dom::Touch> t = new dom::Touch(-1, LayoutDeviceIntPoint(aX, aY),
                                           nsIntPoint(1, 1), 0.0f, 1.0f);
   t->SetTarget(aContent);
   event.touches.AppendElement(t);
   nsEventStatus status = nsEventStatus_eIgnore;
   aPresShell->HandleEventWithTarget(&event, aFrame, aContent, &status);
 }
 
 uint32_t
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1153,17 +1153,17 @@ nsDOMWindowUtils::SendTouchEventCommon(c
   if (!presContext) {
     return NS_ERROR_FAILURE;
   }
   event.touches.SetCapacity(aCount);
   for (uint32_t i = 0; i < aCount; ++i) {
     LayoutDeviceIntPoint pt =
       ToWidgetPoint(CSSPoint(aXs[i], aYs[i]), offset, presContext);
     nsRefPtr<Touch> t = new Touch(aIdentifiers[i],
-                                  LayoutDeviceIntPoint::ToUntyped(pt),
+                                  pt,
                                   nsIntPoint(aRxs[i], aRys[i]),
                                   aRotationAngles[i],
                                   aForces[i]);
     event.touches.AppendElement(t);
   }
 
   nsEventStatus status;
   if (aToWindow) {
@@ -3387,18 +3387,18 @@ nsDOMWindowUtils::SelectAtPoint(float aX
   nsIFrame* rootFrame = presShell->FrameManager()->GetRootFrame();
   if (!rootFrame) {
     return NS_ERROR_UNEXPECTED;
   }
 
   // Get the target frame at the client coordinates passed to us
   nsPoint offset;
   nsCOMPtr<nsIWidget> widget = GetWidget(&offset);
-  nsIntPoint pt = LayoutDeviceIntPoint::ToUntyped(
-    ToWidgetPoint(CSSPoint(aX, aY), offset, GetPresContext()));
+  LayoutDeviceIntPoint pt =
+    ToWidgetPoint(CSSPoint(aX, aY), offset, GetPresContext());
   nsPoint ptInRoot =
     nsLayoutUtils::GetEventCoordinatesRelativeTo(widget, pt, rootFrame);
   nsIFrame* targetFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, ptInRoot);
   // This can happen if the page hasn't loaded yet or if the point
   // is outside the frame.
   if (!targetFrame) {
     return NS_ERROR_INVALID_ARG;
   }
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -961,18 +961,17 @@ Event::GetClientCoords(nsPresContext* aP
     return CSSIntPoint(0, 0);
   }
 
   nsIFrame* rootFrame = shell->GetRootFrame();
   if (!rootFrame) {
     return CSSIntPoint(0, 0);
   }
   nsPoint pt =
-    nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
-      LayoutDeviceIntPoint::ToUntyped(aPoint), rootFrame);
+    nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, aPoint, rootFrame);
 
   return CSSIntPoint::FromAppUnitsRounded(pt);
 }
 
 // To be called ONLY by Event::GetType (which has the additional
 // logic for handling user-defined events).
 // static
 const char*
--- a/dom/events/Touch.cpp
+++ b/dom/events/Touch.cpp
@@ -28,30 +28,30 @@ Touch::Touch(EventTarget* aTarget,
              float aRotationAngle,
              float aForce)
 {
   mTarget = aTarget;
   mIdentifier = aIdentifier;
   mPagePoint = CSSIntPoint(aPageX, aPageY);
   mScreenPoint = nsIntPoint(aScreenX, aScreenY);
   mClientPoint = CSSIntPoint(aClientX, aClientY);
-  mRefPoint = nsIntPoint(0, 0);
+  mRefPoint = LayoutDeviceIntPoint(0, 0);
   mPointsInitialized = true;
   mRadius.x = aRadiusX;
   mRadius.y = aRadiusY;
   mRotationAngle = aRotationAngle;
   mForce = aForce;
 
   mChanged = false;
   mMessage = 0;
   nsJSContext::LikelyShortLivingObjectCreated();
 }
 
 Touch::Touch(int32_t aIdentifier,
-             nsIntPoint aPoint,
+             LayoutDeviceIntPoint aPoint,
              nsIntPoint aRadius,
              float aRotationAngle,
              float aForce)
 {
   mIdentifier = aIdentifier;
   mPagePoint = CSSIntPoint(0, 0);
   mScreenPoint = nsIntPoint(0, 0);
   mClientPoint = CSSIntPoint(0, 0);
@@ -101,23 +101,20 @@ Touch::GetTarget() const
 
 void
 Touch::InitializePoints(nsPresContext* aPresContext, WidgetEvent* aEvent)
 {
   if (mPointsInitialized) {
     return;
   }
   mClientPoint = Event::GetClientCoords(
-    aPresContext, aEvent, LayoutDeviceIntPoint::FromUntyped(mRefPoint),
-    mClientPoint);
+    aPresContext, aEvent, mRefPoint, mClientPoint);
   mPagePoint = Event::GetPageCoords(
-    aPresContext, aEvent, LayoutDeviceIntPoint::FromUntyped(mRefPoint),
-    mClientPoint);
-  mScreenPoint = Event::GetScreenCoords(aPresContext, aEvent,
-    LayoutDeviceIntPoint::FromUntyped(mRefPoint));
+    aPresContext, aEvent, mRefPoint, mClientPoint);
+  mScreenPoint = Event::GetScreenCoords(aPresContext, aEvent, mRefPoint);
   mPointsInitialized = true;
 }
 
 void
 Touch::SetTarget(EventTarget* aTarget)
 {
   mTarget = aTarget;
 }
--- a/dom/events/Touch.h
+++ b/dom/events/Touch.h
@@ -35,17 +35,17 @@ public:
         int32_t aScreenY,
         int32_t aClientX,
         int32_t aClientY,
         int32_t aRadiusX,
         int32_t aRadiusY,
         float aRotationAngle,
         float aForce);
   Touch(int32_t aIdentifier,
-        nsIntPoint aPoint,
+        LayoutDeviceIntPoint aPoint,
         nsIntPoint aRadius,
         float aRotationAngle,
         float aForce);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Touch)
 
   void InitializePoints(nsPresContext* aPresContext, WidgetEvent* aEvent);
@@ -68,17 +68,17 @@ public:
   int32_t PageX() const { return mPagePoint.x; }
   int32_t PageY() const { return mPagePoint.y; }
   int32_t RadiusX() const { return mRadius.x; }
   int32_t RadiusY() const { return mRadius.y; }
   float RotationAngle() const { return mRotationAngle; }
   float Force() const { return mForce; }
 
   nsCOMPtr<EventTarget> mTarget;
-  nsIntPoint mRefPoint;
+  LayoutDeviceIntPoint mRefPoint;
   bool mChanged;
   uint32_t mMessage;
   int32_t mIdentifier;
   CSSIntPoint mPagePoint;
   CSSIntPoint mClientPoint;
   nsIntPoint mScreenPoint;
   nsIntPoint mRadius;
   float mRotationAngle;
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -2297,19 +2297,18 @@ TabChild::RecvMouseWheelEvent(const Widg
                               const ScrollableLayerGuid& aGuid,
                               const uint64_t& aInputBlockId)
 {
   if (IsAsyncPanZoomEnabled()) {
     nsCOMPtr<nsIDocument> document(GetDocument());
     if (nsIPresShell* shell = document->GetShell()) {
       if (nsIFrame* rootFrame = shell->GetRootFrame()) {
         nsTArray<ScrollableLayerGuid> targets;
-        nsIntPoint refPoint(aEvent.refPoint.x, aEvent.refPoint.y);
         bool waitForRefresh =
-          PrepareForSetTargetAPZCNotification(aGuid, aInputBlockId, rootFrame, refPoint, &targets);
+          PrepareForSetTargetAPZCNotification(aGuid, aInputBlockId, rootFrame, aEvent.refPoint, &targets);
 
         SendSetTargetAPZCNotification(shell, aInputBlockId, targets, waitForRefresh);
       }
     }
   }
 
   WidgetWheelEvent event(aEvent);
   event.widget = mWidget;
@@ -2536,17 +2535,17 @@ private:
   uint64_t mInputBlockId;
   nsTArray<ScrollableLayerGuid> mTargets;
 };
 
 bool
 TabChild::PrepareForSetTargetAPZCNotification(const ScrollableLayerGuid& aGuid,
                                               const uint64_t& aInputBlockId,
                                               nsIFrame* aRootFrame,
-                                              const nsIntPoint& aRefPoint,
+                                              const LayoutDeviceIntPoint& aRefPoint,
                                               nsTArray<ScrollableLayerGuid>* aTargets)
 {
   ScrollableLayerGuid guid(aGuid.mLayersId, 0, FrameMetrics::NULL_SCROLL_ID);
   nsPoint point =
     nsLayoutUtils::GetEventCoordinatesRelativeTo(WebWidget(), aRefPoint, aRootFrame);
   nsIFrame* target =
     nsLayoutUtils::GetFrameForPoint(aRootFrame, point, nsLayoutUtils::IGNORE_ROOT_SCROLL_FRAME);
   nsIScrollableFrame* scrollAncestor = GetScrollableAncestorFrame(target);
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -587,17 +587,17 @@ private:
                                            const ScrollableLayerGuid& aGuid);
 
     // Adds the scrollable layer target to the target list, and returns whether
     // or not the caller should wait for a refresh to send a target
     // notification.
     bool PrepareForSetTargetAPZCNotification(const ScrollableLayerGuid& aGuid,
                                              const uint64_t& aInputBlockId,
                                              nsIFrame* aRootFrame,
-                                             const nsIntPoint& aRefPoint,
+                                             const LayoutDeviceIntPoint& aRefPoint,
                                              nsTArray<ScrollableLayerGuid>* aTargets);
 
     // Sends a SetTarget notification for APZC, given one or more previous
     // calls to PrepareForAPZCSetTargetNotification().
     void SendSetTargetAPZCNotification(nsIPresShell* aShell,
                                        const uint64_t& aInputBlockId,
                                        const nsTArray<ScrollableLayerGuid>& aTargets,
                                        bool aWaitForRefresh);
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1080,17 +1080,17 @@ TabParent::MapEventCoordinatesForChildPr
     aEvent->refPoint = LayoutDeviceIntPoint();
     // Then offset all the touch points by that distance, to put them
     // in the space where top-left is 0,0.
     const WidgetTouchEvent::TouchArray& touches =
       aEvent->AsTouchEvent()->touches;
     for (uint32_t i = 0; i < touches.Length(); ++i) {
       Touch* touch = touches[i];
       if (touch) {
-        touch->mRefPoint += LayoutDeviceIntPoint::ToUntyped(aOffset);
+        touch->mRefPoint += aOffset;
       }
     }
   }
 }
 
 bool TabParent::SendRealMouseEvent(WidgetMouseEvent& event)
 {
   if (mIsDestroyed) {
@@ -1726,17 +1726,17 @@ TabParent::GetChildProcessOffset()
   }
 
   // Find out how far we're offset from the nearest widget.
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return offset;
   }
   nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(widget,
-                                                            nsIntPoint(0, 0),
+                                                            LayoutDeviceIntPoint(0, 0),
                                                             targetFrame);
 
   return LayoutDeviceIntPoint::ToUntyped(LayoutDeviceIntPoint::FromAppUnitsToNearest(
            pt, targetFrame->PresContext()->AppUnitsPerDevPixel()));
 }
 
 bool
 TabParent::RecvReplyKeyEvent(const WidgetKeyboardEvent& event)
@@ -2480,17 +2480,17 @@ TabParent::InjectTouchEvent(const nsAStr
   event.touches.SetCapacity(aCount);
   for (uint32_t i = 0; i < aCount; ++i) {
     LayoutDeviceIntPoint pt =
       LayoutDeviceIntPoint::FromAppUnitsRounded(
         CSSPoint::ToAppUnits(CSSPoint(aXs[i], aYs[i])),
         presContext->AppUnitsPerDevPixel());
 
     nsRefPtr<Touch> t = new Touch(aIdentifiers[i],
-                                  LayoutDeviceIntPoint::ToUntyped(pt),
+                                  pt,
                                   nsIntPoint(aRxs[i], aRys[i]),
                                   aRotationAngles[i],
                                   aForces[i]);
 
     // Consider all injected touch events as changedTouches. For more details
     // about the meaning of changedTouches for each event, see
     // https://developer.mozilla.org/docs/Web/API/TouchEvent.changedTouches
     t->mChanged = true;
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -350,26 +350,25 @@ APZCCallbackHelper::ApplyCallbackTransfo
                 CSSPoint delta = (*static_cast<CSSPoint*>(property));
                 return input + delta;
             }
         }
     }
     return input;
 }
 
-nsIntPoint
-APZCCallbackHelper::ApplyCallbackTransform(const nsIntPoint& aPoint,
+LayoutDeviceIntPoint
+APZCCallbackHelper::ApplyCallbackTransform(const LayoutDeviceIntPoint& aPoint,
                                            const ScrollableLayerGuid& aGuid,
                                            const CSSToLayoutDeviceScale& aScale,
                                            float aPresShellResolution)
 {
     LayoutDevicePoint point = LayoutDevicePoint(aPoint.x, aPoint.y);
     point = ApplyCallbackTransform(point / aScale, aGuid, aPresShellResolution) * aScale;
-    LayoutDeviceIntPoint ret = gfx::RoundedToInt(point);
-    return nsIntPoint(ret.x, ret.y);
+    return gfx::RoundedToInt(point);
 }
 
 nsEventStatus
 APZCCallbackHelper::DispatchWidgetEvent(WidgetGUIEvent& aEvent)
 {
   if (!aEvent.widget)
     return nsEventStatus_eConsumeNoDefault;
 
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -94,23 +94,24 @@ public:
        method's documentations for details.
        This method additionally adjusts |aInput| by inversely scaling by the provided
        pres shell resolution, to cancel out a compositor-side transform (added in
        bug 1076241) that APZ doesn't unapply. */
     static CSSPoint ApplyCallbackTransform(const CSSPoint& aInput,
                                            const ScrollableLayerGuid& aGuid,
                                            float aPresShellResolution);
 
-    /* Same as above, but operates on nsIntPoint that are assumed to be in LayoutDevice
-       pixel space. Requires an additonal |aScale| parameter to convert between CSS and
+    /* Same as above, but operates on LayoutDeviceIntPoint.
+       Requires an additonal |aScale| parameter to convert between CSS and
        LayoutDevice space. */
-    static nsIntPoint ApplyCallbackTransform(const nsIntPoint& aPoint,
-                                             const ScrollableLayerGuid& aGuid,
-                                             const CSSToLayoutDeviceScale& aScale,
-                                             float aPresShellResolution);
+    static mozilla::LayoutDeviceIntPoint
+    ApplyCallbackTransform(const LayoutDeviceIntPoint& aPoint,
+                           const ScrollableLayerGuid& aGuid,
+                           const CSSToLayoutDeviceScale& aScale,
+                           float aPresShellResolution);
 
     /* Dispatch a widget event via the widget stored in the event, if any.
      * In a child process, allows the TabParent event-capture mechanism to
      * intercept the event. */
     static nsEventStatus DispatchWidgetEvent(WidgetGUIEvent& aEvent);
 
     /* Synthesize a mouse event with the given parameters, and dispatch it
      * via the given widget. */
--- a/layout/base/SelectionCarets.cpp
+++ b/layout/base/SelectionCarets.cpp
@@ -156,17 +156,17 @@ nsEventStatus
 SelectionCarets::HandleEvent(WidgetEvent* aEvent)
 {
   WidgetMouseEvent *mouseEvent = aEvent->AsMouseEvent();
   if (mouseEvent && mouseEvent->reason == WidgetMouseEvent::eSynthesized) {
     return nsEventStatus_eIgnore;
   }
 
   WidgetTouchEvent *touchEvent = aEvent->AsTouchEvent();
-  nsIntPoint movePoint;
+  LayoutDeviceIntPoint movePoint;
   int32_t nowTouchId = -1;
   if (touchEvent && !touchEvent->touches.IsEmpty()) {
     // If touch happened, just grab event with same identifier
     if (mActiveTouchId >= 0) {
       for (uint32_t i = 0; i < touchEvent->touches.Length(); ++i) {
         if (touchEvent->touches[i]->Identifier() == mActiveTouchId) {
           movePoint = touchEvent->touches[i]->mRefPoint;
           nowTouchId = touchEvent->touches[i]->Identifier();
@@ -178,17 +178,17 @@ SelectionCarets::HandleEvent(WidgetEvent
       if (nowTouchId == -1) {
         return nsEventStatus_eConsumeNoDefault;
       }
     } else {
       movePoint = touchEvent->touches[0]->mRefPoint;
       nowTouchId = touchEvent->touches[0]->Identifier();
     }
   } else if (mouseEvent) {
-    movePoint = LayoutDeviceIntPoint::ToUntyped(mouseEvent->AsGUIEvent()->refPoint);
+    movePoint = mouseEvent->AsGUIEvent()->refPoint;
   }
 
   // Get event coordinate relative to root frame
   nsIFrame* rootFrame = mPresShell->GetRootFrame();
   if (!rootFrame) {
     return nsEventStatus_eIgnore;
   }
   nsPoint ptInRoot =
--- a/layout/base/TouchCaret.cpp
+++ b/layout/base/TouchCaret.cpp
@@ -624,32 +624,31 @@ TouchCaret::HandleEvent(WidgetEvent* aEv
 
 nsPoint
 TouchCaret::GetEventPosition(WidgetTouchEvent* aEvent, int32_t aIdentifier)
 {
   for (size_t i = 0; i < aEvent->touches.Length(); i++) {
     if (aEvent->touches[i]->mIdentifier == aIdentifier) {
       // Get event coordinate relative to canvas frame.
       nsIFrame* canvasFrame = GetCanvasFrame();
-      nsIntPoint touchIntPoint = aEvent->touches[i]->mRefPoint;
+      LayoutDeviceIntPoint touchIntPoint = aEvent->touches[i]->mRefPoint;
       return nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
                                                           touchIntPoint,
                                                           canvasFrame);
     }
   }
   return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
 }
 
 nsPoint
 TouchCaret::GetEventPosition(WidgetMouseEvent* aEvent)
 {
   // Get event coordinate relative to canvas frame.
   nsIFrame* canvasFrame = GetCanvasFrame();
-  nsIntPoint mouseIntPoint =
-    LayoutDeviceIntPoint::ToUntyped(aEvent->AsGUIEvent()->refPoint);
+  LayoutDeviceIntPoint mouseIntPoint = aEvent->AsGUIEvent()->refPoint;
   return nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
                                                       mouseIntPoint,
                                                       canvasFrame);
 }
 
 nsEventStatus
 TouchCaret::HandleMouseMoveEvent(WidgetMouseEvent* aEvent)
 {
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1907,40 +1907,40 @@ nsLayoutUtils::GetEventCoordinatesRelati
                   aEvent->mClass != eSimpleGestureEventClass &&
                   aEvent->mClass != ePointerEventClass &&
                   aEvent->mClass != eGestureNotifyEventClass &&
                   aEvent->mClass != eTouchEventClass &&
                   aEvent->mClass != eQueryContentEventClass))
     return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
 
   return GetEventCoordinatesRelativeTo(aEvent,
-           LayoutDeviceIntPoint::ToUntyped(aEvent->AsGUIEvent()->refPoint),
+           aEvent->AsGUIEvent()->refPoint,
            aFrame);
 }
 
 nsPoint
 nsLayoutUtils::GetEventCoordinatesRelativeTo(const WidgetEvent* aEvent,
-                                             const nsIntPoint aPoint,
+                                             const LayoutDeviceIntPoint& aPoint,
                                              nsIFrame* aFrame)
 {
   if (!aFrame) {
     return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
   }
 
   nsIWidget* widget = aEvent->AsGUIEvent()->widget;
   if (!widget) {
     return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
   }
 
   return GetEventCoordinatesRelativeTo(widget, aPoint, aFrame);
 }
 
 nsPoint
 nsLayoutUtils::GetEventCoordinatesRelativeTo(nsIWidget* aWidget,
-                                             const nsIntPoint aPoint,
+                                             const LayoutDeviceIntPoint& aPoint,
                                              nsIFrame* aFrame)
 {
   if (!aFrame || !aWidget) {
     return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
   }
 
   nsView* view = aFrame->GetView();
   if (view) {
@@ -2653,26 +2653,27 @@ static nsIntPoint WidgetToWidgetOffset(n
   if (fromRoot == toRoot) {
     return fromOffset - toOffset;
   }
   return aFrom->WidgetToScreenOffset() - aTo->WidgetToScreenOffset();
 }
 
 nsPoint
 nsLayoutUtils::TranslateWidgetToView(nsPresContext* aPresContext,
-                                     nsIWidget* aWidget, nsIntPoint aPt,
+                                     nsIWidget* aWidget, const LayoutDeviceIntPoint& aPt,
                                      nsView* aView)
 {
   nsPoint viewOffset;
   nsIWidget* viewWidget = aView->GetNearestWidget(&viewOffset);
   if (!viewWidget) {
     return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
   }
 
-  nsIntPoint widgetPoint = aPt + WidgetToWidgetOffset(aWidget, viewWidget);
+  LayoutDeviceIntPoint widgetPoint = aPt +
+    LayoutDeviceIntPoint::FromUntyped(WidgetToWidgetOffset(aWidget, viewWidget));
   nsPoint widgetAppUnits(aPresContext->DevPixelsToAppUnits(widgetPoint.x),
                          aPresContext->DevPixelsToAppUnits(widgetPoint.y));
   return widgetAppUnits - viewOffset;
 }
 
 nsIntPoint
 nsLayoutUtils::TranslateViewToWidget(nsPresContext* aPresContext,
                                      nsView* aView, nsPoint aPt,
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -674,31 +674,31 @@ public:
    * @param aPoint the point to get the coordinates relative to
    * @param aFrame the frame to make coordinates relative to
    * @return the point, or (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if
    * for some reason the coordinates for the mouse are not known (e.g.,
    * the event is not a GUI event).
    */
   static nsPoint GetEventCoordinatesRelativeTo(
                    const mozilla::WidgetEvent* aEvent,
-                   const nsIntPoint aPoint,
+                   const mozilla::LayoutDeviceIntPoint& aPoint,
                    nsIFrame* aFrame);
 
   /**
    * Get the coordinates of a given point relative to a widget and a
    * given frame.
    * @param aWidget the event src widget
    * @param aPoint the point to get the coordinates relative to
    * @param aFrame the frame to make coordinates relative to
    * @return the point, or (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if
    * for some reason the coordinates for the mouse are not known (e.g.,
    * the event is not a GUI event).
    */
   static nsPoint GetEventCoordinatesRelativeTo(nsIWidget* aWidget,
-                                               const nsIntPoint aPoint,
+                                               const mozilla::LayoutDeviceIntPoint& aPoint,
                                                nsIFrame* aFrame);
 
   /**
    * Get the popup frame of a given native mouse event.
    * @param aPresContext only check popups within aPresContext or a descendant
    * @param aEvent  the event.
    * @return        Null, if there is no popup frame at the point, otherwise,
    *                returns top-most popup frame at the point.
@@ -711,17 +711,18 @@ public:
    * Translate from widget coordinates to the view's coordinates
    * @param aPresContext the PresContext for the view
    * @param aWidget the widget
    * @param aPt the point relative to the widget
    * @param aView  view to which returned coordinates are relative
    * @return the point in the view's coordinates
    */
   static nsPoint TranslateWidgetToView(nsPresContext* aPresContext,
-                                       nsIWidget* aWidget, nsIntPoint aPt,
+                                       nsIWidget* aWidget,
+                                       const mozilla::LayoutDeviceIntPoint& aPt,
                                        nsView* aView);
 
   /**
    * Translate from view coordinates to the widget's coordinates.
    * @param aPresContext the PresContext for the view
    * @param aView the view
    * @param aPt the point relative to the view
    * @param aWidget the widget to which returned coordinates are relative
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -6748,18 +6748,17 @@ PresShell::RecordMouseLocation(WidgetGUI
        aEvent->AsMouseEvent()->reason == WidgetMouseEvent::eReal) ||
       aEvent->message == NS_MOUSE_ENTER ||
       aEvent->message == NS_MOUSE_BUTTON_DOWN ||
       aEvent->message == NS_MOUSE_BUTTON_UP) {
     nsIFrame* rootFrame = GetRootFrame();
     if (!rootFrame) {
       nsView* rootView = mViewManager->GetRootView();
       mMouseLocation = nsLayoutUtils::TranslateWidgetToView(mPresContext,
-        aEvent->widget, LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint),
-        rootView);
+        aEvent->widget, aEvent->refPoint, rootView);
     } else {
       mMouseLocation =
         nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, rootFrame);
     }
 #ifdef DEBUG_MOUSE_LOCATION
     if (aEvent->message == NS_MOUSE_ENTER)
       printf("[ps=%p]got mouse enter for %p\n",
              this, aEvent->widget);
@@ -8513,22 +8512,22 @@ PresShell::AdjustContextMenuKeyEvent(Wid
           LayoutDeviceIntPoint::FromAppUnitsToNearest(offset, mPresContext->AppUnitsPerDevPixel());
       }
     }
   } else {
     aEvent->widget = nullptr;
   }
 
   // see if we should use the caret position for the popup
-  nsIntPoint caretPoint;
+  LayoutDeviceIntPoint caretPoint;
   // Beware! This may flush notifications via synchronous
   // ScrollSelectionIntoView.
   if (PrepareToUseCaretPosition(aEvent->widget, caretPoint)) {
     // caret position is good
-    aEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(caretPoint);
+    aEvent->refPoint = caretPoint;
     return true;
   }
 
   // If we're here because of the key-equiv for showing context menus, we
   // have to reset the event target to the currently focused element. Get it
   // from the focus controller.
   nsCOMPtr<nsIDOMElement> currentFocus;
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
@@ -8559,17 +8558,18 @@ PresShell::AdjustContextMenuKeyEvent(Wid
 //    coordinates of that position is returned in aTargetPt. This function
 //    will also scroll the window as needed to make the caret visible.
 //
 //    The event widget should be the widget that generated the event, and
 //    whose coordinate system the resulting event's refPoint should be
 //    relative to.  The returned point is in device pixels realtive to the
 //    widget passed in.
 bool
-PresShell::PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsIntPoint& aTargetPt)
+PresShell::PrepareToUseCaretPosition(nsIWidget* aEventWidget,
+                                     LayoutDeviceIntPoint& aTargetPt)
 {
   nsresult rv;
 
   // check caret visibility
   nsRefPtr<nsCaret> caret = GetCaret();
   NS_ENSURE_TRUE(caret, false);
 
   bool caretVisible = caret->IsVisible();
--- a/layout/base/nsPresShell.h
+++ b/layout/base/nsPresShell.h
@@ -685,17 +685,18 @@ protected:
    * view.
    *
    * Returns true if the context menu event should fire and false if it should
    * not.
    */
   bool AdjustContextMenuKeyEvent(mozilla::WidgetMouseEvent* aEvent);
 
   //
-  bool PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsIntPoint& aTargetPt);
+  bool PrepareToUseCaretPosition(nsIWidget* aEventWidget,
+                                 mozilla::LayoutDeviceIntPoint& aTargetPt);
 
   // Get the selected item and coordinates in device pixels relative to root
   // document's root view for element, first ensuring the element is onscreen
   void GetCurrentItemAndPositionForElement(nsIDOMElement *aCurrentEl,
                                            nsIContent **aTargetToUse,
                                            mozilla::LayoutDeviceIntPoint& aTargetPt,
                                            nsIWidget *aRootWidget);
 
--- a/layout/forms/nsNumberControlFrame.cpp
+++ b/layout/forms/nsNumberControlFrame.cpp
@@ -580,18 +580,17 @@ nsNumberControlFrame::GetSpinButtonForPo
     // In the case that the up/down buttons are hidden (display:none) we use
     // just the spin box element, spinning up if the pointer is over the top
     // half of the element, or down if it's over the bottom half. This is
     // important to handle since this is the state things are in for the
     // default UA style sheet. See the comment in forms.css for why.
     LayoutDeviceIntPoint absPoint = aEvent->refPoint;
     nsPoint point =
       nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
-                       LayoutDeviceIntPoint::ToUntyped(absPoint),
-                       mSpinBox->GetPrimaryFrame());
+                       absPoint, mSpinBox->GetPrimaryFrame());
     if (point != nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE)) {
       if (point.y < mSpinBox->GetPrimaryFrame()->GetSize().height / 2) {
         return eSpinButtonUp;
       }
       return eSpinButtonDown;
     }
   }
   return eSpinButtonNone;
--- a/layout/forms/nsRangeFrame.cpp
+++ b/layout/forms/nsRangeFrame.cpp
@@ -487,24 +487,22 @@ nsRangeFrame::GetValueAtEventPoint(Widge
     return minimum;
   }
   Decimal range = maximum - minimum;
 
   LayoutDeviceIntPoint absPoint;
   if (aEvent->mClass == eTouchEventClass) {
     MOZ_ASSERT(aEvent->AsTouchEvent()->touches.Length() == 1,
                "Unexpected number of touches");
-    absPoint = LayoutDeviceIntPoint::FromUntyped(
-      aEvent->AsTouchEvent()->touches[0]->mRefPoint);
+    absPoint = aEvent->AsTouchEvent()->touches[0]->mRefPoint;
   } else {
     absPoint = aEvent->refPoint;
   }
   nsPoint point =
-    nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, 
-      LayoutDeviceIntPoint::ToUntyped(absPoint), this);
+    nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, absPoint, this);
 
   if (point == nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE)) {
     // We don't want to change the current value for this error state.
     return static_cast<dom::HTMLInputElement*>(mContent)->GetValueAsDecimal();
   }
 
   nsRect rangeContentRect = GetContentRectRelativeToSelf();
   nsSize thumbSize;
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -2092,17 +2092,18 @@ nsBoxFrame::WrapListsInRedirector(nsDisp
   nsXULEventRedirectorWrapper wrapper(this);
   wrapper.WrapLists(aBuilder, this, aIn, aOut);
 }
 
 bool
 nsBoxFrame::GetEventPoint(WidgetGUIEvent* aEvent, nsPoint &aPoint) {
   nsIntPoint refPoint;
   bool res = GetEventPoint(aEvent, refPoint);
-  aPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, refPoint, this);
+  aPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(
+    aEvent, LayoutDeviceIntPoint::FromUntyped(refPoint), this);
   return res;
 }
 
 bool
 nsBoxFrame::GetEventPoint(WidgetGUIEvent* aEvent, nsIntPoint &aPoint) {
   NS_ENSURE_TRUE(aEvent, false);
 
   WidgetTouchEvent* touchEvent = aEvent->AsTouchEvent();
@@ -2112,14 +2113,14 @@ nsBoxFrame::GetEventPoint(WidgetGUIEvent
     if (touchEvent->touches.Length() != 1) {
       return false;
     }
 
     dom::Touch* touch = touchEvent->touches.SafeElementAt(0);
     if (!touch) {
       return false;
     }
-    aPoint = touch->mRefPoint;
+    aPoint = LayoutDeviceIntPoint::ToUntyped(touch->mRefPoint);
   } else {
     aPoint = LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
   }
   return true;
 }
--- a/widget/ContentHelper.cpp
+++ b/widget/ContentHelper.cpp
@@ -70,17 +70,19 @@ ContentHelper::UpdateAllowedBehavior(uin
 }
 
 ContentHelper::TouchBehaviorFlags
 ContentHelper::GetAllowedTouchBehavior(nsIWidget* aWidget, const nsIntPoint& aPoint)
 {
   nsView *view = nsView::GetViewFor(aWidget);
   nsIFrame *viewFrame = view->GetFrame();
 
-  nsPoint relativePoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aWidget, aPoint, viewFrame);
+  nsPoint relativePoint =
+    nsLayoutUtils::GetEventCoordinatesRelativeTo(
+      aWidget, LayoutDeviceIntPoint::FromUntyped(aPoint), viewFrame);
 
   nsIFrame *target = nsLayoutUtils::GetFrameForPoint(viewFrame, relativePoint, nsLayoutUtils::IGNORE_ROOT_SCROLL_FRAME);
   nsIScrollableFrame *nearestScrollableParent = nsLayoutUtils::GetNearestScrollableFrame(target, 0);
   nsIFrame* nearestScrollableFrame = do_QueryFrame(nearestScrollableParent);
 
   // We're walking up the DOM tree until we meet the element with touch behavior and accumulating
   // touch-action restrictions of all elements in this chain.
   // The exact quote from the spec, that clarifies more:
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -16,17 +16,17 @@ namespace mozilla {
 
 using namespace dom;
 
 already_AddRefed<Touch> SingleTouchData::ToNewDOMTouch() const
 {
   NS_ABORT_IF_FALSE(NS_IsMainThread(),
                     "Can only create dom::Touch instances on main thread");
   nsRefPtr<Touch> touch = new Touch(mIdentifier,
-                                    nsIntPoint(mScreenPoint.x, mScreenPoint.y),
+                                    LayoutDeviceIntPoint(mScreenPoint.x, mScreenPoint.y),
                                     nsIntPoint(mRadius.width, mRadius.height),
                                     mRotationAngle,
                                     mForce);
   return touch.forget();
 }
 
 MultiTouchInput::MultiTouchInput(const WidgetTouchEvent& aTouchEvent)
   : InputData(MULTITOUCH_INPUT, aTouchEvent.time, aTouchEvent.timeStamp,
--- a/widget/android/AndroidJavaWrappers.cpp
+++ b/widget/android/AndroidJavaWrappers.cpp
@@ -733,17 +733,17 @@ AndroidGeckoEvent::MakeTouchEvent(nsIWid
     const nsIntPoint& offset = widget->WidgetToScreenOffset();
     event.touches.SetCapacity(endIndex - startIndex);
     for (int i = startIndex; i < endIndex; i++) {
         // In this code branch, we are dispatching this event directly
         // into Gecko (as opposed to going through the AsyncPanZoomController),
         // and the Points() array has points in CSS pixels, which we need
         // to convert.
         CSSToLayoutDeviceScale scale = widget->GetDefaultScale();
-        nsIntPoint pt(
+        LayoutDeviceIntPoint pt(
             (Points()[i].x * scale.scale) - offset.x,
             (Points()[i].y * scale.scale) - offset.y);
         nsIntPoint radii(
             PointRadii()[i].x * scale.scale,
             PointRadii()[i].y * scale.scale);
         nsRefPtr<Touch> t = new Touch(PointIndicies()[i],
                                       pt,
                                       radii,
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1090,17 +1090,17 @@ bool nsWindow::OnMultitouchEvent(Android
     }
 
     if (isDownEvent && event.touches.Length() == 1) {
         // Since touch events don't get retargeted by PositionedEventTargeting.cpp
         // code on Fennec, we dispatch a dummy mouse event that *does* get
         // retargeted. The Fennec browser.js code can use this to activate the
         // highlight element in case the this touchstart is the start of a tap.
         WidgetMouseEvent hittest(true, NS_MOUSE_MOZHITTEST, this, WidgetMouseEvent::eReal);
-        hittest.refPoint = LayoutDeviceIntPoint::FromUntyped(event.touches[0]->mRefPoint);
+        hittest.refPoint = event.touches[0]->mRefPoint;
         hittest.ignoreRootScrollFrame = true;
         hittest.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
         nsEventStatus status;
         DispatchEvent(&hittest, status);
     }
 
     // if the last event we got was a down event, then by now we know for sure whether
     // this block has been default-prevented or not. if we haven't already sent the
@@ -1135,18 +1135,18 @@ bool nsWindow::OnMultitouchEvent(Android
     sLastWasDownEvent = isDownEvent;
 
     return preventDefaultActions;
 }
 
 void
 nsWindow::OnNativeGestureEvent(AndroidGeckoEvent *ae)
 {
-  nsIntPoint pt(ae->Points()[0].x,
-                ae->Points()[0].y);
+  LayoutDeviceIntPoint pt(ae->Points()[0].x,
+                          ae->Points()[0].y);
   double delta = ae->X();
   int msg = 0;
 
   switch (ae->Action()) {
       case AndroidMotionEvent::ACTION_MAGNIFY_START:
           msg = NS_SIMPLE_GESTURE_MAGNIFY_START;
           mStartDist = delta;
           mLastDist = delta;
@@ -1165,25 +1165,25 @@ nsWindow::OnNativeGestureEvent(AndroidGe
   }
 
   nsRefPtr<nsWindow> kungFuDeathGrip(this);
   DispatchGestureEvent(msg, 0, delta, pt, ae->Time());
 }
 
 void
 nsWindow::DispatchGestureEvent(uint32_t msg, uint32_t direction, double delta,
-                               const nsIntPoint &refPoint, uint64_t time)
+                               const LayoutDeviceIntPoint &refPoint, uint64_t time)
 {
     WidgetSimpleGestureEvent event(true, msg, this);
 
     event.direction = direction;
     event.delta = delta;
     event.modifiers = 0;
     event.time = time;
-    event.refPoint = LayoutDeviceIntPoint::FromUntyped(refPoint);
+    event.refPoint = refPoint;
 
     DispatchEvent(&event);
 }
 
 
 static unsigned int ConvertAndroidKeyCodeToDOMKeyCode(int androidKeyCode)
 {
     // Special-case alphanumeric keycodes because they are most common.
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -234,17 +234,17 @@ protected:
     static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0);
     static void LogWindow(nsWindow *win, int index, int indent);
 
 private:
     void InitKeyEvent(mozilla::WidgetKeyboardEvent& event,
                       mozilla::AndroidGeckoEvent& key,
                       ANPEvent* pluginEvent);
     void DispatchGestureEvent(uint32_t msg, uint32_t direction, double delta,
-                              const nsIntPoint &refPoint, uint64_t time);
+                              const mozilla::LayoutDeviceIntPoint &refPoint, uint64_t time);
     void HandleSpecialKey(mozilla::AndroidGeckoEvent *ae);
     void CreateLayerManager(int aCompositorWidth, int aCompositorHeight);
     void RedrawAll();
 
     mozilla::AndroidLayerRendererFrame mLayerRendererFrame;
 
     static mozilla::StaticRefPtr<mozilla::layers::APZCTreeManager> sApzcTreeManager;
     static mozilla::StaticRefPtr<mozilla::layers::LayerManager> sLayerManager;
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -281,18 +281,17 @@ struct ParamTraits<mozilla::WidgetTouchE
             !ReadParam(aMsg, aIter, &refPoint) ||
             !ReadParam(aMsg, aIter, &radius) ||
             !ReadParam(aMsg, aIter, &rotationAngle) ||
             !ReadParam(aMsg, aIter, &force)) {
           return false;
         }
         aResult->touches.AppendElement(
           new mozilla::dom::Touch(
-            identifier, mozilla::LayoutDeviceIntPoint::ToUntyped(refPoint),
-            radius, rotationAngle, force));
+            identifier, refPoint, radius, rotationAngle, force));
     }
     return true;
   }
 };
 
 template<>
 struct ParamTraits<mozilla::AlternativeCharCode>
 {
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6199,17 +6199,17 @@ bool nsWindow::OnTouch(WPARAM wParam, LP
 
       // Setup the touch point we'll append to the touch event array
       nsPointWin touchPoint;
       touchPoint.x = TOUCH_COORD_TO_PIXEL(pInputs[i].x);
       touchPoint.y = TOUCH_COORD_TO_PIXEL(pInputs[i].y);
       touchPoint.ScreenToClient(mWnd);
       nsRefPtr<Touch> touch =
         new Touch(pInputs[i].dwID,
-                  touchPoint,
+                  LayoutDeviceIntPoint::FromUntyped(touchPoint),
                   /* radius, if known */
                   pInputs[i].dwFlags & TOUCHINPUTMASKF_CONTACTAREA ?
                     nsIntPoint(
                       TOUCH_COORD_TO_PIXEL(pInputs[i].cxContact) / 2,
                       TOUCH_COORD_TO_PIXEL(pInputs[i].cyContact) / 2) :
                     nsIntPoint(1,1),
                   /* rotation angle and force */
                   0.0f, 0.0f);