Bug 1125040: Use LayoutDeviceIntPoint for GetScreenCoords r=botond
authorDavid Zbarsky <dzbarsky@gmail.com>
Sun, 15 Feb 2015 13:52:28 -0500
changeset 256369 b736b6fb4d1be1085f2a9a8a4839411b04d78a5f
parent 256368 157e840119deda4031383cf59c2bcd83510ea854
child 256370 e0060a3e4ed8270f5c28084996594144e191188d
push idunknown
push userunknown
push dateunknown
reviewersbotond
bugs1125040
milestone38.0a1
Bug 1125040: Use LayoutDeviceIntPoint for GetScreenCoords r=botond
dom/events/Event.cpp
dom/events/Event.h
dom/events/EventStateManager.cpp
dom/events/EventStateManager.h
dom/events/Touch.cpp
dom/events/Touch.h
dom/events/UIEvent.cpp
dom/events/UIEvent.h
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -872,46 +872,46 @@ Event::PopupAllowedEventsChanged()
 void
 Event::Shutdown()
 {
   if (sPopupAllowedEvents) {
     nsMemory::Free(sPopupAllowedEvents);
   }
 }
 
-nsIntPoint
+LayoutDeviceIntPoint
 Event::GetScreenCoords(nsPresContext* aPresContext,
                        WidgetEvent* aEvent,
                        LayoutDeviceIntPoint aPoint)
 {
   if (EventStateManager::sIsPointerLocked) {
     return EventStateManager::sLastScreenPoint;
   }
 
-  if (!aEvent || 
+  if (!aEvent ||
        (aEvent->mClass != eMouseEventClass &&
         aEvent->mClass != eMouseScrollEventClass &&
         aEvent->mClass != eWheelEventClass &&
         aEvent->mClass != ePointerEventClass &&
         aEvent->mClass != eTouchEventClass &&
         aEvent->mClass != eDragEventClass &&
         aEvent->mClass != eSimpleGestureEventClass)) {
-    return nsIntPoint(0, 0);
+    return LayoutDeviceIntPoint(0, 0);
   }
 
   WidgetGUIEvent* guiEvent = aEvent->AsGUIEvent();
   if (!guiEvent->widget) {
-    return LayoutDeviceIntPoint::ToUntyped(aPoint);
+    return aPoint;
   }
 
   LayoutDeviceIntPoint offset = aPoint + guiEvent->widget->WidgetToScreenOffset();
   nscoord factor =
     aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
-  return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
-                    nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
+  return LayoutDeviceIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
+                              nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
 }
 
 // static
 CSSIntPoint
 Event::GetPageCoords(nsPresContext* aPresContext,
                      WidgetEvent* aEvent,
                      LayoutDeviceIntPoint aPoint,
                      CSSIntPoint aDefaultPoint)
--- a/dom/events/Event.h
+++ b/dom/events/Event.h
@@ -141,19 +141,19 @@ public:
   static CSSIntPoint GetClientCoords(nsPresContext* aPresContext,
                                      WidgetEvent* aEvent,
                                      LayoutDeviceIntPoint aPoint,
                                      CSSIntPoint aDefaultPoint);
   static CSSIntPoint GetPageCoords(nsPresContext* aPresContext,
                                    WidgetEvent* aEvent,
                                    LayoutDeviceIntPoint aPoint,
                                    CSSIntPoint aDefaultPoint);
-  static nsIntPoint GetScreenCoords(nsPresContext* aPresContext,
-                                    WidgetEvent* aEvent,
-                                    LayoutDeviceIntPoint aPoint);
+  static LayoutDeviceIntPoint GetScreenCoords(nsPresContext* aPresContext,
+                                              WidgetEvent* aEvent,
+                                              LayoutDeviceIntPoint aPoint);
 
   static already_AddRefed<Event> Constructor(const GlobalObject& aGlobal,
                                              const nsAString& aType,
                                              const EventInit& aParam,
                                              ErrorResult& aRv);
 
   // Implemented as xpidl method
   // void GetType(nsString& aRetval) {}
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -260,17 +260,17 @@ static uint32_t sESMInstanceCount = 0;
 static bool sPointerEventEnabled = false;
 
 int32_t EventStateManager::sUserInputEventDepth = 0;
 bool EventStateManager::sNormalLMouseEventInProcess = false;
 EventStateManager* EventStateManager::sActiveESM = nullptr;
 nsIDocument* EventStateManager::sMouseOverDocument = nullptr;
 nsWeakFrame EventStateManager::sLastDragOverFrame = nullptr;
 LayoutDeviceIntPoint EventStateManager::sLastRefPoint = kInvalidRefPoint;
-nsIntPoint EventStateManager::sLastScreenPoint = nsIntPoint(0, 0);
+LayoutDeviceIntPoint EventStateManager::sLastScreenPoint = LayoutDeviceIntPoint(0, 0);
 LayoutDeviceIntPoint EventStateManager::sSynthCenteringPoint = kInvalidRefPoint;
 CSSIntPoint EventStateManager::sLastClientPoint = CSSIntPoint(0, 0);
 bool EventStateManager::sIsPointerLocked = false;
 // Reference to the pointer locked element.
 nsWeakPtr EventStateManager::sPointerLockedElement;
 // Reference to the document which requested pointer lock.
 nsWeakPtr EventStateManager::sPointerLockedDoc;
 nsCOMPtr<nsIContent> EventStateManager::sDragOverContent = nullptr;
--- a/dom/events/EventStateManager.h
+++ b/dom/events/EventStateManager.h
@@ -228,17 +228,17 @@ public:
   static bool WheelEventIsScrollAction(WidgetWheelEvent* aEvent);
 
   // Holds the point in screen coords that a mouse event was dispatched to,
   // before we went into pointer lock mode. This is constantly updated while
   // the pointer is not locked, but we don't update it while the pointer is
   // locked. This is used by dom::Event::GetScreenCoords() to make mouse
   // events' screen coord appear frozen at the last mouse position while
   // the pointer is locked.
-  static nsIntPoint sLastScreenPoint;
+  static LayoutDeviceIntPoint sLastScreenPoint;
 
   // Holds the point in client coords of the last mouse event. Used by
   // dom::Event::GetClientCoords() to make mouse events' client coords appear
   // frozen at the last mouse position while the pointer is locked.
   static CSSIntPoint sLastClientPoint;
 
   static bool sIsPointerLocked;
   static nsWeakPtr sPointerLockedElement;
--- a/dom/events/Touch.cpp
+++ b/dom/events/Touch.cpp
@@ -26,17 +26,17 @@ Touch::Touch(EventTarget* aTarget,
              int32_t aRadiusX,
              int32_t aRadiusY,
              float aRotationAngle,
              float aForce)
 {
   mTarget = aTarget;
   mIdentifier = aIdentifier;
   mPagePoint = CSSIntPoint(aPageX, aPageY);
-  mScreenPoint = nsIntPoint(aScreenX, aScreenY);
+  mScreenPoint = LayoutDeviceIntPoint(aScreenX, aScreenY);
   mClientPoint = CSSIntPoint(aClientX, aClientY);
   mRefPoint = LayoutDeviceIntPoint(0, 0);
   mPointsInitialized = true;
   mRadius.x = aRadiusX;
   mRadius.y = aRadiusY;
   mRotationAngle = aRotationAngle;
   mForce = aForce;
 
@@ -48,17 +48,17 @@ Touch::Touch(EventTarget* aTarget,
 Touch::Touch(int32_t aIdentifier,
              LayoutDeviceIntPoint aPoint,
              nsIntPoint aRadius,
              float aRotationAngle,
              float aForce)
 {
   mIdentifier = aIdentifier;
   mPagePoint = CSSIntPoint(0, 0);
-  mScreenPoint = nsIntPoint(0, 0);
+  mScreenPoint = LayoutDeviceIntPoint(0, 0);
   mClientPoint = CSSIntPoint(0, 0);
   mRefPoint = aPoint;
   mPointsInitialized = false;
   mRadius = aRadius;
   mRotationAngle = aRotationAngle;
   mForce = aForce;
 
   mChanged = false;
--- a/dom/events/Touch.h
+++ b/dom/events/Touch.h
@@ -74,17 +74,17 @@ public:
 
   nsCOMPtr<EventTarget> mTarget;
   LayoutDeviceIntPoint mRefPoint;
   bool mChanged;
   uint32_t mMessage;
   int32_t mIdentifier;
   CSSIntPoint mPagePoint;
   CSSIntPoint mClientPoint;
-  nsIntPoint mScreenPoint;
+  LayoutDeviceIntPoint mScreenPoint;
   nsIntPoint mRadius;
   float mRotationAngle;
   float mForce;
 protected:
   ~Touch();
 
   bool mPointsInitialized;
 };
--- a/dom/events/UIEvent.cpp
+++ b/dom/events/UIEvent.cpp
@@ -353,21 +353,21 @@ UIEvent::DuplicatePrivateData()
   mClientPoint =
     Event::GetClientCoords(mPresContext, mEvent, mEvent->refPoint,
                            mClientPoint);
   mMovementPoint = GetMovementPoint();
   mLayerPoint = GetLayerPoint();
   mPagePoint =
     Event::GetPageCoords(mPresContext, mEvent, mEvent->refPoint, mClientPoint);
   // GetScreenPoint converts mEvent->refPoint to right coordinates.
-  nsIntPoint screenPoint =
+  LayoutDeviceIntPoint screenPoint =
     Event::GetScreenCoords(mPresContext, mEvent, mEvent->refPoint);
   nsresult rv = Event::DuplicatePrivateData();
   if (NS_SUCCEEDED(rv)) {
-    mEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(screenPoint);
+    mEvent->refPoint = screenPoint;
   }
   return rv;
 }
 
 NS_IMETHODIMP_(void)
 UIEvent::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType)
 {
   if (aSerializeInterfaceType) {
--- a/dom/events/UIEvent.h
+++ b/dom/events/UIEvent.h
@@ -34,39 +34,39 @@ public:
   NS_DECL_NSIDOMUIEVENT
 
   // Forward to Event
   NS_FORWARD_TO_EVENT_NO_SERIALIZATION_NO_DUPLICATION
   NS_IMETHOD DuplicatePrivateData() MOZ_OVERRIDE;
   NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) MOZ_OVERRIDE;
   NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter) MOZ_OVERRIDE;
 
-  static nsIntPoint CalculateScreenPoint(nsPresContext* aPresContext,
-                                         WidgetEvent* aEvent)
+  static LayoutDeviceIntPoint CalculateScreenPoint(nsPresContext* aPresContext,
+                                                   WidgetEvent* aEvent)
   {
     if (!aEvent ||
         (aEvent->mClass != eMouseEventClass &&
          aEvent->mClass != eMouseScrollEventClass &&
          aEvent->mClass != eWheelEventClass &&
          aEvent->mClass != eDragEventClass &&
          aEvent->mClass != ePointerEventClass &&
          aEvent->mClass != eSimpleGestureEventClass)) {
-      return nsIntPoint(0, 0);
+      return LayoutDeviceIntPoint(0, 0);
     }
 
     WidgetGUIEvent* event = aEvent->AsGUIEvent();
     if (!event->widget) {
-      return LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
+      return aEvent->refPoint;
     }
 
     LayoutDeviceIntPoint offset = aEvent->refPoint + event->widget->WidgetToScreenOffset();
     nscoord factor =
       aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
-    return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
-                      nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
+    return LayoutDeviceIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
+                                nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
   }
 
   static CSSIntPoint CalculateClientPoint(nsPresContext* aPresContext,
                                           WidgetEvent* aEvent,
                                           CSSIntPoint* aDefaultClientPoint)
   {
     if (!aEvent ||
         (aEvent->mClass != eMouseEventClass &&