From 8d01c7e4288c903bb4972609a8f353763c311c2f Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sun, 15 Feb 2015 13:52:28 -0500 Subject: [PATCH] Bug 1125040: Use LayoutDeviceIntPoint for GetScreenCoords r=botond --- dom/events/Event.cpp | 12 ++++++------ dom/events/Event.h | 6 +++--- dom/events/EventStateManager.cpp | 2 +- dom/events/EventStateManager.h | 2 +- dom/events/Touch.cpp | 4 ++-- dom/events/Touch.h | 2 +- dom/events/UIEvent.cpp | 4 ++-- dom/events/UIEvent.h | 12 ++++++------ 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index 04dbbf56b062..5458987ebe8c 100644 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -877,7 +877,7 @@ Event::Shutdown() } } -nsIntPoint +LayoutDeviceIntPoint Event::GetScreenCoords(nsPresContext* aPresContext, WidgetEvent* aEvent, LayoutDeviceIntPoint aPoint) @@ -886,7 +886,7 @@ Event::GetScreenCoords(nsPresContext* aPresContext, return EventStateManager::sLastScreenPoint; } - if (!aEvent || + if (!aEvent || (aEvent->mClass != eMouseEventClass && aEvent->mClass != eMouseScrollEventClass && aEvent->mClass != eWheelEventClass && @@ -894,19 +894,19 @@ Event::GetScreenCoords(nsPresContext* aPresContext, 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 diff --git a/dom/events/Event.h b/dom/events/Event.h index fbcbd5b249a3..eb2a177bb125 100644 --- a/dom/events/Event.h +++ b/dom/events/Event.h @@ -146,9 +146,9 @@ public: 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 Constructor(const GlobalObject& aGlobal, const nsAString& aType, diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 76fd0807c603..36e831be86d6 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -265,7 +265,7 @@ 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; diff --git a/dom/events/EventStateManager.h b/dom/events/EventStateManager.h index 8afbfeef9261..dd5fac775ecc 100644 --- a/dom/events/EventStateManager.h +++ b/dom/events/EventStateManager.h @@ -233,7 +233,7 @@ public: // 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 diff --git a/dom/events/Touch.cpp b/dom/events/Touch.cpp index 25f5fde37498..efbb15abb755 100644 --- a/dom/events/Touch.cpp +++ b/dom/events/Touch.cpp @@ -31,7 +31,7 @@ Touch::Touch(EventTarget* aTarget, 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; @@ -53,7 +53,7 @@ Touch::Touch(int32_t aIdentifier, { mIdentifier = aIdentifier; mPagePoint = CSSIntPoint(0, 0); - mScreenPoint = nsIntPoint(0, 0); + mScreenPoint = LayoutDeviceIntPoint(0, 0); mClientPoint = CSSIntPoint(0, 0); mRefPoint = aPoint; mPointsInitialized = false; diff --git a/dom/events/Touch.h b/dom/events/Touch.h index 1077a7432eaa..e019209269a8 100644 --- a/dom/events/Touch.h +++ b/dom/events/Touch.h @@ -79,7 +79,7 @@ public: int32_t mIdentifier; CSSIntPoint mPagePoint; CSSIntPoint mClientPoint; - nsIntPoint mScreenPoint; + LayoutDeviceIntPoint mScreenPoint; nsIntPoint mRadius; float mRotationAngle; float mForce; diff --git a/dom/events/UIEvent.cpp b/dom/events/UIEvent.cpp index a0637afa5777..c423f5dfa523 100644 --- a/dom/events/UIEvent.cpp +++ b/dom/events/UIEvent.cpp @@ -358,11 +358,11 @@ UIEvent::DuplicatePrivateData() 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; } diff --git a/dom/events/UIEvent.h b/dom/events/UIEvent.h index 81b6097286b8..a7bb53ae38b1 100644 --- a/dom/events/UIEvent.h +++ b/dom/events/UIEvent.h @@ -39,8 +39,8 @@ public: 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 && @@ -49,19 +49,19 @@ public: 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,