From e63a6defd2740480a052f5ab03be2597d8916380 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 synthesizing native events on widgets r=botond --- dom/base/nsDOMWindowUtils.cpp | 6 +++--- dom/events/EventStateManager.cpp | 9 +++------ widget/cocoa/nsChildView.h | 4 ++-- widget/cocoa/nsChildView.mm | 2 +- widget/cocoa/nsCocoaUtils.h | 4 +++- widget/cocoa/nsCocoaWindow.h | 2 +- widget/cocoa/nsCocoaWindow.mm | 2 +- widget/cocoa/nsDragService.mm | 2 +- widget/gtk/nsWindow.cpp | 2 +- widget/gtk/nsWindow.h | 4 ++-- widget/nsBaseWidget.h | 6 +++--- widget/nsIWidget.h | 6 +++--- widget/windows/WinMouseScrollHandler.cpp | 2 +- widget/windows/WinMouseScrollHandler.h | 3 ++- widget/windows/nsWindow.cpp | 4 ++-- widget/windows/nsWindow.h | 6 +++--- widget/windows/winrt/MetroWidget.cpp | 4 ++-- widget/windows/winrt/MetroWidget.h | 4 ++-- 18 files changed, 36 insertions(+), 36 deletions(-) diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index b512a009ed54..7b8f0a8dd763 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -1322,7 +1322,7 @@ nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX, if (!widget) return NS_ERROR_FAILURE; - return widget->SynthesizeNativeMouseEvent(nsIntPoint(aScreenX, aScreenY), + return widget->SynthesizeNativeMouseEvent(LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aModifierFlags); } @@ -1345,8 +1345,8 @@ nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX, return NS_ERROR_FAILURE; } - return widget->SynthesizeNativeMouseScrollEvent(nsIntPoint(aScreenX, - aScreenY), + return widget->SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint(aScreenX, + aScreenY), aNativeMessage, aDeltaX, aDeltaY, aDeltaZ, aModifierFlags, diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index a5c6871fca02..76fd0807c603 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -4031,8 +4031,7 @@ EventStateManager::GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent) // in the other branch here. sSynthCenteringPoint = center; aMouseEvent->widget->SynthesizeNativeMouseMove( - LayoutDeviceIntPoint::ToUntyped(center + - aMouseEvent->widget->WidgetToScreenOffset())); + center + aMouseEvent->widget->WidgetToScreenOffset()); } else if (aMouseEvent->refPoint == sSynthCenteringPoint) { // This is the "synthetic native" event we dispatched to re-center the // pointer. Cancel it so we don't expose the centering move to content. @@ -4167,8 +4166,7 @@ EventStateManager::SetPointerLock(nsIWidget* aWidget, sLastRefPoint = GetWindowInnerRectCenter(aElement->OwnerDoc()->GetWindow(), aWidget, mPresContext); - aWidget->SynthesizeNativeMouseMove( - LayoutDeviceIntPoint::ToUntyped(sLastRefPoint + aWidget->WidgetToScreenOffset())); + aWidget->SynthesizeNativeMouseMove(sLastRefPoint + aWidget->WidgetToScreenOffset()); // Retarget all events to this element via capture. nsIPresShell::SetCapturingContent(aElement, CAPTURE_POINTERLOCK); @@ -4183,8 +4181,7 @@ EventStateManager::SetPointerLock(nsIWidget* aWidget, // pre-pointerlock position, so that the synthetic mouse event reports // no movement. sLastRefPoint = mPreLockPoint; - aWidget->SynthesizeNativeMouseMove( - LayoutDeviceIntPoint::ToUntyped(mPreLockPoint + aWidget->WidgetToScreenOffset())); + aWidget->SynthesizeNativeMouseMove(mPreLockPoint + aWidget->WidgetToScreenOffset()); // Don't retarget events to this element any more. nsIPresShell::SetCapturingContent(nullptr, CAPTURE_POINTERLOCK); diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h index e13186e3770b..b7c233b2eabd 100644 --- a/widget/cocoa/nsChildView.h +++ b/widget/cocoa/nsChildView.h @@ -453,11 +453,11 @@ public: const nsAString& aCharacters, const nsAString& aUnmodifiedCharacters) MOZ_OVERRIDE; - virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint, + virtual nsresult SynthesizeNativeMouseEvent(mozilla::LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags) MOZ_OVERRIDE; - virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) MOZ_OVERRIDE + virtual nsresult SynthesizeNativeMouseMove(mozilla::LayoutDeviceIntPoint aPoint) MOZ_OVERRIDE { return SynthesizeNativeMouseEvent(aPoint, NSMouseMoved, 0); } // Mac specific methods diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 60833bfd63eb..173b006efcb6 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -1125,7 +1125,7 @@ nsresult nsChildView::SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout, aUnmodifiedCharacters); } -nsresult nsChildView::SynthesizeNativeMouseEvent(nsIntPoint aPoint, +nsresult nsChildView::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags) { diff --git a/widget/cocoa/nsCocoaUtils.h b/widget/cocoa/nsCocoaUtils.h index 99c235da5035..50d6e8ec984c 100644 --- a/widget/cocoa/nsCocoaUtils.h +++ b/widget/cocoa/nsCocoaUtils.h @@ -12,6 +12,7 @@ #include "imgIContainer.h" #include "npapi.h" #include "nsTArray.h" +#include "Units.h" // This must be the last include: #include "nsObjCExceptions.h" @@ -174,7 +175,8 @@ public: } static NSPoint - DevPixelsToCocoaPoints(const nsIntPoint& aPt, CGFloat aBackingScale) + DevPixelsToCocoaPoints(const mozilla::LayoutDeviceIntPoint& aPt, + CGFloat aBackingScale) { return NSMakePoint((CGFloat)aPt.x / aBackingScale, (CGFloat)aPt.y / aBackingScale); diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h index 891df6f4be8f..e32080ed0fd1 100644 --- a/widget/cocoa/nsCocoaWindow.h +++ b/widget/cocoa/nsCocoaWindow.h @@ -324,7 +324,7 @@ public: NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive) MOZ_OVERRIDE; virtual void SetDrawsInTitlebar(bool aState) MOZ_OVERRIDE; virtual void UpdateThemeGeometries(const nsTArray& aThemeGeometries) MOZ_OVERRIDE; - virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint, + virtual nsresult SynthesizeNativeMouseEvent(mozilla::LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags) MOZ_OVERRIDE; diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index a0353f9028bc..52572e123bc7 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -2068,7 +2068,7 @@ void nsCocoaWindow::SetDrawsInTitlebar(bool aState) NS_OBJC_END_TRY_ABORT_BLOCK; } -NS_IMETHODIMP nsCocoaWindow::SynthesizeNativeMouseEvent(nsIntPoint aPoint, +NS_IMETHODIMP nsCocoaWindow::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags) { diff --git a/widget/cocoa/nsDragService.mm b/widget/cocoa/nsDragService.mm index c3bef08e5d99..61d1b98b71e4 100644 --- a/widget/cocoa/nsDragService.mm +++ b/widget/cocoa/nsDragService.mm @@ -274,7 +274,7 @@ nsDragService::InvokeDragSession(nsIDOMNode* aDOMNode, nsISupportsArray* aTransf [image unlockFocus]; } - nsIntPoint pt(dragRect.x, dragRect.YMost()); + LayoutDeviceIntPoint pt(dragRect.x, dragRect.YMost()); CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(gLastDragView); NSPoint point = nsCocoaUtils::DevPixelsToCocoaPoints(pt, scaleFactor); point.y = nsCocoaUtils::FlippedScreenY(point.y); diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 19ff7efd4679..fefad779f669 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -6566,7 +6566,7 @@ nsWindow::GdkRectToDevicePixels(GdkRectangle rect) { } nsresult -nsWindow::SynthesizeNativeMouseEvent(nsIntPoint aPoint, +nsWindow::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags) { diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h index a5af3930defd..955b66fc9f35 100644 --- a/widget/gtk/nsWindow.h +++ b/widget/gtk/nsWindow.h @@ -298,11 +298,11 @@ public: #endif NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) MOZ_OVERRIDE; - virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint, + virtual nsresult SynthesizeNativeMouseEvent(mozilla::LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags) MOZ_OVERRIDE; - virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) MOZ_OVERRIDE + virtual nsresult SynthesizeNativeMouseMove(mozilla::LayoutDeviceIntPoint aPoint) MOZ_OVERRIDE { return SynthesizeNativeMouseEvent(aPoint, GDK_MOTION_NOTIFY, 0); } protected: diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index d7affa3df07e..840ff1f9d6d6 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -341,15 +341,15 @@ protected: const nsAString& aUnmodifiedCharacters) MOZ_OVERRIDE { return NS_ERROR_UNEXPECTED; } - virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint, + virtual nsresult SynthesizeNativeMouseEvent(mozilla::LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags) MOZ_OVERRIDE { return NS_ERROR_UNEXPECTED; } - virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) MOZ_OVERRIDE + virtual nsresult SynthesizeNativeMouseMove(mozilla::LayoutDeviceIntPoint aPoint) MOZ_OVERRIDE { return NS_ERROR_UNEXPECTED; } - virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint, + virtual nsresult SynthesizeNativeMouseScrollEvent(mozilla::LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX, double aDeltaY, diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 975498a697b2..22b1439cc244 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -1863,7 +1863,7 @@ class nsIWidget : public nsISupports { * @param aModifierFlags *platform-specific* modifier flags (ignored * on Windows) */ - virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint, + virtual nsresult SynthesizeNativeMouseEvent(mozilla::LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags) = 0; @@ -1871,7 +1871,7 @@ class nsIWidget : public nsISupports { * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native message. * aPoint is location in device pixels to which the mouse pointer moves to. */ - virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) = 0; + virtual nsresult SynthesizeNativeMouseMove(mozilla::LayoutDeviceIntPoint aPoint) = 0; /** * Utility method intended for testing. Dispatching native mouse scroll @@ -1894,7 +1894,7 @@ class nsIWidget : public nsISupports { * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their * document. */ - virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint, + virtual nsresult SynthesizeNativeMouseScrollEvent(mozilla::LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX, double aDeltaY, diff --git a/widget/windows/WinMouseScrollHandler.cpp b/widget/windows/WinMouseScrollHandler.cpp index b1e123706fa6..dc722801b843 100644 --- a/widget/windows/WinMouseScrollHandler.cpp +++ b/widget/windows/WinMouseScrollHandler.cpp @@ -249,7 +249,7 @@ MouseScrollHandler::ProcessMessage(nsWindowBase* aWidget, UINT msg, /* static */ nsresult MouseScrollHandler::SynthesizeNativeMouseScrollEvent(nsWindowBase* aWidget, - const nsIntPoint& aPoint, + const LayoutDeviceIntPoint& aPoint, uint32_t aNativeMessage, int32_t aDelta, uint32_t aModifierFlags, diff --git a/widget/windows/WinMouseScrollHandler.h b/widget/windows/WinMouseScrollHandler.h index d828f115b2f1..7689c915a99c 100644 --- a/widget/windows/WinMouseScrollHandler.h +++ b/widget/windows/WinMouseScrollHandler.h @@ -12,6 +12,7 @@ #include "mozilla/Assertions.h" #include "mozilla/EventForwards.h" #include "mozilla/TimeStamp.h" +#include "Units.h" #include class nsWindowBase; @@ -43,7 +44,7 @@ public: * this method. */ static nsresult SynthesizeNativeMouseScrollEvent(nsWindowBase* aWidget, - const nsIntPoint& aPoint, + const LayoutDeviceIntPoint& aPoint, uint32_t aNativeMessage, int32_t aDelta, uint32_t aModifierFlags, diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 3c7b28b95415..17a78776118e 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -5818,7 +5818,7 @@ nsWindow::SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout, } nsresult -nsWindow::SynthesizeNativeMouseEvent(nsIntPoint aPoint, +nsWindow::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags) { @@ -5835,7 +5835,7 @@ nsWindow::SynthesizeNativeMouseEvent(nsIntPoint aPoint, } nsresult -nsWindow::SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint, +nsWindow::SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX, double aDeltaY, diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index 52defeb46074..0b41686f763e 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -160,14 +160,14 @@ public: uint32_t aModifierFlags, const nsAString& aCharacters, const nsAString& aUnmodifiedCharacters); - virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint, + virtual nsresult SynthesizeNativeMouseEvent(mozilla::LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags); - virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) + virtual nsresult SynthesizeNativeMouseMove(mozilla::LayoutDeviceIntPoint aPoint) { return SynthesizeNativeMouseEvent(aPoint, MOUSEEVENTF_MOVE, 0); } - virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint, + virtual nsresult SynthesizeNativeMouseScrollEvent(mozilla::LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX, double aDeltaY, diff --git a/widget/windows/winrt/MetroWidget.cpp b/widget/windows/winrt/MetroWidget.cpp index 4d8d1cd87cc1..66d1b9416b49 100644 --- a/widget/windows/winrt/MetroWidget.cpp +++ b/widget/windows/winrt/MetroWidget.cpp @@ -592,7 +592,7 @@ MetroWidget::SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout, } nsresult -MetroWidget::SynthesizeNativeMouseEvent(nsIntPoint aPoint, +MetroWidget::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags) { @@ -616,7 +616,7 @@ MetroWidget::SynthesizeNativeMouseEvent(nsIntPoint aPoint, } nsresult -MetroWidget::SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint, +MetroWidget::SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX, double aDeltaY, diff --git a/widget/windows/winrt/MetroWidget.h b/widget/windows/winrt/MetroWidget.h index 5796a4cb5411..35281af38567 100644 --- a/widget/windows/winrt/MetroWidget.h +++ b/widget/windows/winrt/MetroWidget.h @@ -127,10 +127,10 @@ public: uint32_t aModifierFlags, const nsAString& aCharacters, const nsAString& aUnmodifiedCharacters); - virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint, + virtual nsresult SynthesizeNativeMouseEvent(mozilla::LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags); - virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint, + virtual nsresult SynthesizeNativeMouseScrollEvent(mozilla::LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX, double aDeltaY,