Bug 1223310 (part 1) - Pass a LayoutDeviceIntPoint instead of an nsIntPoint to InitEvent(). r=kats.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 09 Nov 2015 21:37:32 -0800
changeset 306187 31531f850dec8eb0131fd05c8b9a926cf9163b02
parent 306186 4d6d9c1e52e452ec3139c89e3a0165d654f4cf83
child 306188 49a5f1fe2128ff16b17eccdd77017f751c8efb11
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1223310
milestone45.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 1223310 (part 1) - Pass a LayoutDeviceIntPoint instead of an nsIntPoint to InitEvent(). r=kats. Also use direct assignment for some LayoutDeviceIntPoint assignments, rather than doing it field-by-field.
layout/base/nsPresShell.cpp
widget/PuppetWidget.cpp
widget/PuppetWidget.h
widget/android/nsWindow.cpp
widget/android/nsWindow.h
widget/nsBaseDragService.cpp
widget/windows/IMMHandler.cpp
widget/windows/KeyboardLayout.cpp
widget/windows/TSFTextStore.cpp
widget/windows/WinMouseScrollHandler.cpp
widget/windows/WinMouseScrollHandler.h
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
widget/windows/nsWindowBase.cpp
widget/windows/nsWindowBase.h
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -6674,18 +6674,17 @@ DispatchPointerFromMouseOrTouch(PresShel
       mozilla::dom::Touch* touch = touchEvent->touches[i];
       if (!touch || !touch->convertToPointer) {
         continue;
       }
 
       WidgetPointerEvent event(touchEvent->mFlags.mIsTrusted, pointerMessage, touchEvent->widget);
       event.isPrimary = i == 0;
       event.pointerId = touch->Identifier();
-      event.refPoint.x = touch->mRefPoint.x;
-      event.refPoint.y = touch->mRefPoint.y;
+      event.refPoint = touch->mRefPoint;
       event.modifiers = touchEvent->modifiers;
       event.width = touch->RadiusX();
       event.height = touch->RadiusY();
       event.tiltX = touch->tiltX;
       event.tiltY = touch->tiltY;
       event.time = touchEvent->time;
       event.timeStamp = touchEvent->timeStamp;
       event.mFlags = touchEvent->mFlags;
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -282,26 +282,24 @@ PuppetWidget::Invalidate(const nsIntRect
     mPaintTask = new PaintTask(this);
     return NS_DispatchToCurrentThread(mPaintTask.get());
   }
 
   return NS_OK;
 }
 
 void
-PuppetWidget::InitEvent(WidgetGUIEvent& event, nsIntPoint* aPoint)
+PuppetWidget::InitEvent(WidgetGUIEvent& event, LayoutDeviceIntPoint* aPoint)
 {
   if (nullptr == aPoint) {
     event.refPoint.x = 0;
     event.refPoint.y = 0;
-  }
-  else {
+  } else {
     // use the point override if provided
-    event.refPoint.x = aPoint->x;
-    event.refPoint.y = aPoint->y;
+    event.refPoint = *aPoint;
   }
   event.time = PR_Now() / 1000;
 }
 
 NS_IMETHODIMP
 PuppetWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
 {
 #ifdef DEBUG
--- a/widget/PuppetWidget.h
+++ b/widget/PuppetWidget.h
@@ -127,17 +127,18 @@ public:
 
   // PuppetWidgets don't have any concept of titles.
   NS_IMETHOD SetTitle(const nsAString& aTitle) override
   { return NS_ERROR_UNEXPECTED; }
 
   virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() override
   { return LayoutDeviceIntPoint::FromUntyped(GetWindowPosition() + GetChromeDimensions()); }
 
-  void InitEvent(WidgetGUIEvent& aEvent, nsIntPoint* aPoint = nullptr);
+  void InitEvent(WidgetGUIEvent& aEvent,
+                 mozilla::LayoutDeviceIntPoint* aPoint = nullptr);
 
   NS_IMETHOD DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override;
   nsEventStatus DispatchAPZAwareEvent(WidgetInputEvent* aEvent) override;
   nsEventStatus DispatchInputEvent(WidgetInputEvent* aEvent) override;
   void SetConfirmedTargetAPZC(uint64_t aInputBlockId,
                               const nsTArray<ScrollableLayerGuid>& aTargets) const override;
   void UpdateZoomConstraints(const uint32_t& aPresShellId,
                              const FrameMetrics::ViewID& aViewId,
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1223,21 +1223,20 @@ nsWindow::OnSizeChanged(const gfx::IntSi
     mBounds.height = aSize.height;
 
     if (mWidgetListener) {
         mWidgetListener->WindowResized(this, aSize.width, aSize.height);
     }
 }
 
 void
-nsWindow::InitEvent(WidgetGUIEvent& event, nsIntPoint* aPoint)
+nsWindow::InitEvent(WidgetGUIEvent& event, LayoutDeviceIntPoint* aPoint)
 {
     if (aPoint) {
-        event.refPoint.x = aPoint->x;
-        event.refPoint.y = aPoint->y;
+        event.refPoint = *aPoint;
     } else {
         event.refPoint.x = 0;
         event.refPoint.y = 0;
     }
 
     event.time = PR_Now() / 1000;
 }
 
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -57,17 +57,18 @@ public:
     bool OnContextmenuEvent(mozilla::AndroidGeckoEvent *ae);
     void OnLongTapEvent(mozilla::AndroidGeckoEvent *ae);
     bool OnMultitouchEvent(mozilla::AndroidGeckoEvent *ae);
     void OnNativeGestureEvent(mozilla::AndroidGeckoEvent *ae);
     void OnMouseEvent(mozilla::AndroidGeckoEvent *ae);
 
     void OnSizeChanged(const mozilla::gfx::IntSize& aSize);
 
-    void InitEvent(mozilla::WidgetGUIEvent& event, nsIntPoint* aPoint = 0);
+    void InitEvent(mozilla::WidgetGUIEvent& event,
+                   mozilla::LayoutDeviceIntPoint* aPoint = 0);
 
     //
     // nsIWidget
     //
 
     NS_IMETHOD Create(nsIWidget *aParent,
                       nsNativeWidget aNativeParent,
                       const nsIntRect &aRect,
--- a/widget/nsBaseDragService.cpp
+++ b/widget/nsBaseDragService.cpp
@@ -426,18 +426,17 @@ nsBaseDragService::FireDragEventAtSource
     nsCOMPtr<nsIDocument> doc = do_QueryInterface(mSourceDocument);
     if (doc) {
       nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
       if (presShell) {
         nsEventStatus status = nsEventStatus_eIgnore;
         WidgetDragEvent event(true, aEventMessage, nullptr);
         event.inputSource = mInputSource;
         if (aEventMessage == eDragEnd) {
-          event.refPoint.x = mEndDragPoint.x;
-          event.refPoint.y = mEndDragPoint.y;
+          event.refPoint = mEndDragPoint;
           event.userCancelled = mUserCancelled;
         }
 
         nsCOMPtr<nsIContent> content = do_QueryInterface(mSourceNode);
         return presShell->HandleDOMEventWithTarget(content, &event, &status);
       }
     }
   }
--- a/widget/windows/IMMHandler.cpp
+++ b/widget/windows/IMMHandler.cpp
@@ -1246,17 +1246,17 @@ IMMHandler::HandleStartComposition(nsWin
   }
 
   AdjustCompositionFont(aContext, selection.mWritingMode);
 
   mCompositionStart = selection.mOffset;
   mCursorPosition = NO_IME_CARET;
 
   WidgetCompositionEvent event(true, eCompositionStart, aWindow);
-  nsIntPoint point(0, 0);
+  LayoutDeviceIntPoint point(0, 0);
   aWindow->InitEvent(event, &point);
   aWindow->DispatchWindowEvent(&event);
 
   mIsComposing = true;
   mComposingWindow = aWindow;
 
   MOZ_LOG(gIMMLog, LogLevel::Info,
     ("IMM: HandleStartComposition, START composition, mCompositionStart=%ld",
@@ -1522,17 +1522,17 @@ IMMHandler::HandleEndComposition(nsWindo
   if (mNativeCaretIsCreated) {
     ::DestroyCaret();
     mNativeCaretIsCreated = false;
   }
 
   EventMessage message =
     aCommitString ? eCompositionCommit : eCompositionCommitAsIs;
   WidgetCompositionEvent compositionCommitEvent(true, message, aWindow);
-  nsIntPoint point(0, 0);
+  LayoutDeviceIntPoint point(0, 0);
   aWindow->InitEvent(compositionCommitEvent, &point);
   if (aCommitString) {
     compositionCommitEvent.mData = *aCommitString;
   }
   aWindow->DispatchWindowEvent(&compositionCommitEvent);
   mIsComposing = false;
   mComposingWindow = nullptr;
 }
@@ -1688,17 +1688,17 @@ IMMHandler::HandleQueryCharPosition(nsWi
 bool
 IMMHandler::HandleDocumentFeed(nsWindow* aWindow,
                                LPARAM lParam,
                                LRESULT* oResult)
 {
   *oResult = 0;
   RECONVERTSTRING* pReconv = reinterpret_cast<RECONVERTSTRING*>(lParam);
 
-  nsIntPoint point(0, 0);
+  LayoutDeviceIntPoint point(0, 0);
 
   bool hasCompositionString =
     mIsComposing && ShouldDrawCompositionStringOurselves();
 
   int32_t targetOffset, targetLength;
   if (!hasCompositionString) {
     Selection& selection = GetSelection();
     if (!selection.EnsureValidSelection(aWindow)) {
@@ -1890,17 +1890,17 @@ IMMHandler::DispatchCompositionChangeEve
   if (!ShouldDrawCompositionStringOurselves()) {
     // But we need to adjust composition window pos and native caret pos, here.
     SetIMERelatedWindowsPos(aWindow, aContext);
     return;
   }
 
   RefPtr<nsWindow> kungFuDeathGrip(aWindow);
 
-  nsIntPoint point(0, 0);
+  LayoutDeviceIntPoint point(0, 0);
 
   WidgetCompositionEvent event(true, eCompositionChange, aWindow);
 
   aWindow->InitEvent(event, &point);
 
   event.mRanges = CreateTextRangeArray();
   event.mData = mCompositionString;
 
@@ -2093,17 +2093,17 @@ IMMHandler::ConvertToANSIString(const ns
 }
 
 bool
 IMMHandler::GetCharacterRectOfSelectedTextAt(nsWindow* aWindow,
                                              uint32_t aOffset,
                                              nsIntRect& aCharRect,
                                              WritingMode* aWritingMode)
 {
-  nsIntPoint point(0, 0);
+  LayoutDeviceIntPoint point(0, 0);
 
   Selection& selection = GetSelection();
   if (!selection.EnsureValidSelection(aWindow)) {
     MOZ_LOG(gIMMLog, LogLevel::Error,
       ("IMM: GetCharacterRectOfSelectedTextAt, FAILED, due to "
        "Selection::EnsureValidSelection() failure"));
     return false;
   }
@@ -2187,17 +2187,17 @@ IMMHandler::GetCharacterRectOfSelectedTe
   return GetCaretRect(aWindow, aCharRect, aWritingMode);
 }
 
 bool
 IMMHandler::GetCaretRect(nsWindow* aWindow,
                          nsIntRect& aCaretRect,
                          WritingMode* aWritingMode)
 {
-  nsIntPoint point(0, 0);
+  LayoutDeviceIntPoint point(0, 0);
 
   Selection& selection = GetSelection();
   if (!selection.EnsureValidSelection(aWindow)) {
     MOZ_LOG(gIMMLog, LogLevel::Error,
       ("IMM: GetCaretRect, FAILED, due to "
        "Selection::EnsureValidSelection() failure"));
     return false;
   }
@@ -2748,17 +2748,17 @@ IMMHandler::Selection::Update(const IMEN
 }
 
 bool
 IMMHandler::Selection::Init(nsWindow* aWindow)
 {
   Clear();
 
   WidgetQueryContentEvent selection(true, eQuerySelectedText, aWindow);
-  nsIntPoint point(0, 0);
+  LayoutDeviceIntPoint point(0, 0);
   aWindow->InitEvent(selection, &point);
   aWindow->DispatchWindowEvent(&selection);
   if (NS_WARN_IF(!selection.mSucceeded)) {
     MOZ_LOG(gIMMLog, LogLevel::Error,
       ("IMM: Selection::Init, FAILED, due to eQuerySelectedText failure"));
     return false;
   }
   // If the window is destroyed during querying selected text, we shouldn't
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -1135,17 +1135,17 @@ NativeKey::InitKeyEvent(WidgetKeyboardEv
 {
   InitKeyEvent(aKeyEvent, mModKeyState);
 }
 
 void
 NativeKey::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
                         const ModifierKeyState& aModKeyState) const
 {
-  nsIntPoint point(0, 0);
+  LayoutDeviceIntPoint point(0, 0);
   mWidget->InitEvent(aKeyEvent, &point);
 
   switch (aKeyEvent.mMessage) {
     case eKeyDown:
       aKeyEvent.keyCode = mDOMKeyCode;
       // Unique id for this keydown event and its associated keypress.
       sUniqueKeyEventId++;
       aKeyEvent.mUniqueId = sUniqueKeyEventId;
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -3375,19 +3375,19 @@ TSFTextStore::GetACPFromPoint(TsViewCook
   if (mLockedContent.IsLayoutChanged()) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::GetACPFromPoint() FAILED due to "
             "layout not recomputed", this));
     mPendingOnLayoutChange = true;
     return TS_E_NOLAYOUT;
   }
 
-  nsIntPoint ourPt(pt->x, pt->y);
+  LayoutDeviceIntPoint ourPt(pt->x, pt->y);
   // Convert to widget relative coordinates from screen's.
-  ourPt -= mWidget->WidgetToScreenOffsetUntyped();
+  ourPt -= mWidget->WidgetToScreenOffset();
 
   // NOTE: Don't check if the point is in the widget since the point can be
   //       outside of the widget if focused editor is in a XUL <panel>.
 
   WidgetQueryContentEvent charAtPt(true, eQueryCharacterAtPoint, mWidget);
   mWidget->InitEvent(charAtPt, &ourPt);
 
   // FYI: WidgetQueryContentEvent may cause flushing pending layout and it
--- a/widget/windows/WinMouseScrollHandler.cpp
+++ b/widget/windows/WinMouseScrollHandler.cpp
@@ -314,20 +314,20 @@ MouseScrollHandler::SynthesizeNativeMous
   return sInstance->mSynthesizingEvent->
            Synthesize(pts, target, aNativeMessage, wParam, lParam, kbdState);
 }
 
 /* static */
 void
 MouseScrollHandler::InitEvent(nsWindowBase* aWidget,
                               WidgetGUIEvent& aEvent,
-                              nsIntPoint* aPoint)
+                              LayoutDeviceIntPoint* aPoint)
 {
   NS_ENSURE_TRUE_VOID(aWidget);
-  nsIntPoint point;
+  LayoutDeviceIntPoint point;
   if (aPoint) {
     point = *aPoint;
   } else {
     POINTS pts = GetCurrentMessagePos();
     POINT pt;
     pt.x = pts.x;
     pt.y = pts.y;
     ::ScreenToClient(aWidget->GetWindowHandle(), &pt);
--- a/widget/windows/WinMouseScrollHandler.h
+++ b/widget/windows/WinMouseScrollHandler.h
@@ -69,17 +69,17 @@ private:
   static MouseScrollHandler* sInstance;
 
   /**
    * InitEvent() initializes the aEvent.  If aPoint is null, the result of
    * GetCurrentMessagePos() will be used.
    */
   static void InitEvent(nsWindowBase* aWidget,
                         WidgetGUIEvent& aEvent,
-                        nsIntPoint* aPoint = nullptr);
+                        LayoutDeviceIntPoint* aPoint = nullptr);
 
   /**
    * GetModifierKeyState() returns current modifier key state.
    * Note that some devices need some hack for the modifier key state.
    * This method does it automatically.
    *
    * @param aMessage    Handling message.
    */
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -3793,41 +3793,38 @@ nsWindow::GetMaxTouchPoints() const
 /**************************************************************
  *
  * SECTION: Mozilla event initialization
  *
  * Helpers for initializing moz events.
  *
  **************************************************************/
 
-// Event intialization
-void nsWindow::InitEvent(WidgetGUIEvent& event, nsIntPoint* aPoint)
+// Event initialization
+void nsWindow::InitEvent(WidgetGUIEvent& event, LayoutDeviceIntPoint* aPoint)
 {
   if (nullptr == aPoint) {     // use the point from the event
     // get the message position in client coordinates
     if (mWnd != nullptr) {
-
       DWORD pos = ::GetMessagePos();
       POINT cpos;
-      
+
       cpos.x = GET_X_LPARAM(pos);
       cpos.y = GET_Y_LPARAM(pos);
 
       ::ScreenToClient(mWnd, &cpos);
       event.refPoint.x = cpos.x;
       event.refPoint.y = cpos.y;
     } else {
       event.refPoint.x = 0;
       event.refPoint.y = 0;
     }
-  }
-  else {  
+  } else {
     // use the point override if provided
-    event.refPoint.x = aPoint->x;
-    event.refPoint.y = aPoint->y;
+    event.refPoint = *aPoint;
   }
 
   event.time = ::GetMessageTime();
   event.timeStamp = GetMessageTimeStamp(event.time);
 }
 
 /**************************************************************
  *
@@ -4033,39 +4030,37 @@ nsWindow::DispatchMouseEvent(EventMessag
         CaptureMouse(false);
       break;
 
     default:
       break;
 
   } // switch
 
-  nsIntPoint eventPoint;
-  eventPoint.x = GET_X_LPARAM(lParam);
-  eventPoint.y = GET_Y_LPARAM(lParam);
+  LayoutDeviceIntPoint eventPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
 
   WidgetMouseEvent event(true, aEventMessage, this, WidgetMouseEvent::eReal,
                          aIsContextMenuKey ? WidgetMouseEvent::eContextMenuKey :
                                              WidgetMouseEvent::eNormal);
   if (aEventMessage == eContextMenu && aIsContextMenuKey) {
-    nsIntPoint zero(0, 0);
+    LayoutDeviceIntPoint zero(0, 0);
     InitEvent(event, &zero);
   } else {
     InitEvent(event, &eventPoint);
   }
 
   ModifierKeyState modifierKeyState;
   modifierKeyState.InitInputEvent(event);
   event.button    = aButton;
   event.inputSource = aInputSource;
   // If we get here the mouse events must be from non-touch sources, so
   // convert it to pointer events as well
   event.convertToPointer = true;
 
-  nsIntPoint mpScreen = eventPoint + WidgetToScreenOffsetUntyped();
+  LayoutDeviceIntPoint mpScreen = eventPoint + WidgetToScreenOffset();
 
   // Suppress mouse moves caused by widget creation
   if (aEventMessage == eMouseMove) {
     if ((sLastMouseMovePoint.x == mpScreen.x) && (sLastMouseMovePoint.y == mpScreen.y))
       return result;
     sLastMouseMovePoint.x = mpScreen.x;
     sLastMouseMovePoint.y = mpScreen.y;
   }
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -76,17 +76,17 @@ public:
   nsWindow();
 
   NS_DECL_ISUPPORTS_INHERITED
 
   friend class nsWindowGfx;
 
   // nsWindowBase
   virtual void InitEvent(mozilla::WidgetGUIEvent& aEvent,
-                         nsIntPoint* aPoint = nullptr) override;
+                         mozilla::LayoutDeviceIntPoint* aPoint = nullptr) override;
   virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent) override;
   virtual bool DispatchKeyboardEvent(mozilla::WidgetKeyboardEvent* aEvent) override;
   virtual bool DispatchWheelEvent(mozilla::WidgetWheelEvent* aEvent) override;
   virtual bool DispatchContentCommandEvent(mozilla::WidgetContentCommandEvent* aEvent) override;
   virtual nsWindowBase* GetParentWindowBase(bool aIncludeOwner) override;
   virtual bool IsTopLevelWidget() override { return mIsTopWidgetWindow; }
 
   using nsWindowBase::DispatchPluginEvent;
--- a/widget/windows/nsWindowBase.cpp
+++ b/widget/windows/nsWindowBase.cpp
@@ -19,17 +19,17 @@ InjectTouchInputPtr nsWindowBase::sInjec
 
 bool
 nsWindowBase::DispatchPluginEvent(const MSG& aMsg)
 {
   if (!PluginHasFocus()) {
     return false;
   }
   WidgetPluginEvent pluginEvent(true, ePluginInputEvent, this);
-  nsIntPoint point(0, 0);
+  LayoutDeviceIntPoint point(0, 0);
   InitEvent(pluginEvent, &point);
   NPEvent npEvent;
   npEvent.event = aMsg.message;
   npEvent.wParam = aMsg.wParam;
   npEvent.lParam = aMsg.lParam;
   pluginEvent.mPluginEvent.Copy(npEvent);
   pluginEvent.retargetToFocusedDocument = true;
   return DispatchWindowEvent(&pluginEvent);
--- a/widget/windows/nsWindowBase.h
+++ b/widget/windows/nsWindowBase.h
@@ -38,17 +38,17 @@ public:
   virtual bool IsTopLevelWidget() = 0;
 
   /*
    * Init a standard gecko event for this widget.
    * @param aEvent the event to initialize.
    * @param aPoint message position in physical coordinates.
    */
   virtual void InitEvent(mozilla::WidgetGUIEvent& aEvent,
-                         nsIntPoint* aPoint = nullptr) = 0;
+                         mozilla::LayoutDeviceIntPoint* aPoint = nullptr) = 0;
 
   /*
    * Dispatch a gecko event for this widget.
    * Returns true if it's consumed.  Otherwise, false.
    */
   virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent) = 0;
 
   /*