Bug 1224482 (part 3) - Replace GetClientOffsetUntyped() with GetClientOffset(). r=kats.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 13 Nov 2015 01:37:02 -0800
changeset 306868 e49cd993ae2a456bdb2ad126dfccb7aa09d3d9ff
parent 306867 d77e6ba0c79530b5ffb2211140fbf7cbb3d0614a
child 306869 af31b9ebda9bedbbef816053dc400bcbcd9b4f9f
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
bugs1224482
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 1224482 (part 3) - Replace GetClientOffsetUntyped() with GetClientOffset(). r=kats. The patch also changes nsMenuPopupFrame::mLastClientOffset to LayoutDeviceIntPoint.
layout/xul/nsMenuPopupFrame.cpp
layout/xul/nsMenuPopupFrame.h
layout/xul/nsXULPopupManager.cpp
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaWindow.h
widget/cocoa/nsCocoaWindow.mm
widget/gtk/nsWindow.cpp
widget/gtk/nsWindow.h
widget/nsBaseWidget.cpp
widget/nsBaseWidget.h
widget/nsIWidget.h
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -1496,17 +1496,17 @@ nsMenuPopupFrame::SetPopupPosition(nsIFr
   NS_ASSERTION(view, "popup with no view");
 
   // Offset the position by the width and height of the borders and titlebar.
   // Even though GetClientOffset should return (0, 0) when there is no
   // titlebar or borders, we skip these calculations anyway for non-panels
   // to save time since they will never have a titlebar.
   nsIWidget* widget = view->GetWidget();
   if (mPopupType == ePopupTypePanel && widget) {
-    mLastClientOffset = widget->GetClientOffsetUntyped();
+    mLastClientOffset = widget->GetClientOffset();
     viewPoint.x += presContext->DevPixelsToAppUnits(mLastClientOffset.x);
     viewPoint.y += presContext->DevPixelsToAppUnits(mLastClientOffset.y);
   }
 
   presContext->GetPresShell()->GetViewManager()->
     MoveViewTo(view, viewPoint.x, viewPoint.y);
 
   // Now that we've positioned the view, sync up the frame's origin.
@@ -2163,17 +2163,17 @@ nsMenuPopupFrame::DestroyFrom(nsIFrame* 
 }
 
 
 void
 nsMenuPopupFrame::MoveTo(const CSSIntPoint& aPos, bool aUpdateAttrs)
 {
   nsIWidget* widget = GetWidget();
   if ((mScreenRect.x == aPos.x && mScreenRect.y == aPos.y) &&
-      (!widget || widget->GetClientOffsetUntyped() == mLastClientOffset)) {
+      (!widget || widget->GetClientOffset() == mLastClientOffset)) {
     return;
   }
 
   // reposition the popup at the specified coordinates. Don't clear the anchor
   // and position, because the popup can be reset to its anchor position by
   // using (-1, -1) as coordinates. Subtract off the margin as it will be
   // added to the position when SetPopupPosition is called.
   nsMargin margin(0, 0, 0, 0);
--- a/layout/xul/nsMenuPopupFrame.h
+++ b/layout/xul/nsMenuPopupFrame.h
@@ -384,17 +384,20 @@ public:
 
   // Return the anchor if there is one.
   nsIContent* GetAnchor() const { return mAnchorContent; }
 
   // Return the screen coordinates in CSS pixels of the popup,
   // or (-1, -1, 0, 0) if anchored.
   nsIntRect GetScreenAnchorRect() const { return mScreenRect; }
 
-  nsIntPoint GetLastClientOffset() const { return mLastClientOffset; }
+  mozilla::LayoutDeviceIntPoint GetLastClientOffset() const
+  {
+    return mLastClientOffset;
+  }
 
   // Return the alignment of the popup
   int8_t GetAlignmentPosition() const;
 
   // Return the offset applied to the alignment of the popup
   nscoord GetAlignmentOffset() const { return mAlignmentOffset; }
 
   // Clear the mPopupShownDispatcher, remove the listener and return true if
@@ -521,17 +524,17 @@ protected:
   // If the panel prefers to "slide" rather than resize, then the arrow gets
   // positioned at this offset (along either the x or y axis, depending on
   // mPosition)
   nscoord mAlignmentOffset;
 
   // The value of the client offset of our widget the last time we positioned
   // ourselves. We store this so that we can detect when it changes but the
   // position of our widget didn't change.
-  nsIntPoint mLastClientOffset;
+  mozilla::LayoutDeviceIntPoint mLastClientOffset;
 
   nsPopupType mPopupType; // type of popup
   nsPopupState mPopupState; // open state of the popup
 
   // popup alignment relative to the anchor node
   int8_t mPopupAlignment;
   int8_t mPopupAnchor;
   int8_t mPosition;
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -468,17 +468,18 @@ nsXULPopupManager::PopupMoved(nsIFrame* 
   if (!view)
     return;
 
   // Don't do anything if the popup is already at the specified location. This
   // prevents recursive calls when a popup is positioned.
   nsIntRect curDevSize = view->CalcWidgetBounds(eWindowType_popup);
   nsIWidget* widget = menuPopupFrame->GetWidget();
   if (curDevSize.x == aPnt.x && curDevSize.y == aPnt.y &&
-      (!widget || widget->GetClientOffsetUntyped() == menuPopupFrame->GetLastClientOffset())) {
+      (!widget || widget->GetClientOffset() ==
+                  menuPopupFrame->GetLastClientOffset())) {
     return;
   }
 
   // Update the popup's position using SetPopupPosition if the popup is
   // anchored and at the parent level as these maintain their position
   // relative to the parent window. Otherwise, just update the popup to
   // the specified screen coordinates.
   if (menuPopupFrame->IsAnchored() &&
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -546,17 +546,17 @@ public:
   NS_IMETHOD StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
                             int32_t aPanelX, int32_t aPanelY,
                             nsString& aCommitted) override;
 
   NS_IMETHOD SetPluginFocused(bool& aFocused) override;
 
   bool IsPluginFocused() { return mPluginFocused; }
 
-  virtual nsIntPoint GetClientOffsetUntyped() override;
+  virtual mozilla::LayoutDeviceIntPoint GetClientOffset() override;
 
   void DispatchAPZWheelInputEvent(mozilla::InputData& aEvent, bool aCanTriggerSwipe);
 
   void SwipeFinished();
 
 protected:
   virtual ~nsChildView();
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1517,25 +1517,25 @@ void nsChildView::ReportMoveEvent()
 void nsChildView::ReportSizeEvent()
 {
   if (mWidgetListener)
     mWidgetListener->WindowResized(this, mBounds.width, mBounds.height);
 }
 
 #pragma mark -
 
-nsIntPoint nsChildView::GetClientOffsetUntyped()
+LayoutDeviceIntPoint nsChildView::GetClientOffset()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   NSPoint origin = [mView convertPoint:NSMakePoint(0, 0) toView:nil];
   origin.y = [[mView window] frame].size.height - origin.y;
-  return CocoaPointsToDevPixels(origin);
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(nsIntPoint(0, 0));
+  return LayoutDeviceIntPoint::FromUnknownPoint(CocoaPointsToDevPixels(origin));
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(LayoutDeviceIntPoint(0, 0));
 }
 
 //    Return the offset between this child view and the screen.
 //    @return       -- widget origin in device-pixel coords
 LayoutDeviceIntPoint nsChildView::WidgetToScreenOffset()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
--- a/widget/cocoa/nsCocoaWindow.h
+++ b/widget/cocoa/nsCocoaWindow.h
@@ -266,17 +266,17 @@ public:
     NS_IMETHOD              Show(bool aState) override;
     virtual nsIWidget*      GetSheetWindowParent(void) override;
     NS_IMETHOD              Enable(bool aState) override;
     virtual bool            IsEnabled() const override;
     NS_IMETHOD              SetModal(bool aState) override;
     virtual bool            IsVisible() const override;
     NS_IMETHOD              SetFocus(bool aState=false) override;
     virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() override;
-    virtual nsIntPoint GetClientOffsetUntyped() override;
+    virtual mozilla::LayoutDeviceIntPoint GetClientOffset() override;
     virtual mozilla::LayoutDeviceIntSize
     ClientToWindowSize(const mozilla::LayoutDeviceIntSize& aClientSize) override;
 
     virtual void* GetNativeData(uint32_t aDataType) override;
 
     NS_IMETHOD              ConstrainPosition(bool aAllowSlop,
                                               int32_t *aX, int32_t *aY) override;
     virtual void            SetSizeConstraints(const SizeConstraints& aConstraints) override;
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -1975,26 +1975,27 @@ LayoutDeviceIntPoint nsCocoaWindow::Widg
   }
   r = nsCocoaUtils::CocoaRectToGeckoRectDevPix(rect, BackingScaleFactor());
 
   return LayoutDeviceIntPoint::FromUnknownPoint(r.TopLeft());
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(LayoutDeviceIntPoint(0,0));
 }
 
-nsIntPoint nsCocoaWindow::GetClientOffsetUntyped()
+LayoutDeviceIntPoint nsCocoaWindow::GetClientOffset()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
-  nsIntRect clientRect;
-  GetClientBoundsUntyped(clientRect);
-
-  return clientRect.TopLeft() - mBounds.TopLeft();
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(nsIntPoint(0, 0));
+  LayoutDeviceIntRect clientRect;
+  GetClientBounds(clientRect);
+
+  return clientRect.TopLeft() -
+         LayoutDeviceIntPoint::FromUnknownPoint(mBounds.TopLeft());
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(LayoutDeviceIntPoint(0, 0));
 }
 
 LayoutDeviceIntSize
 nsCocoaWindow::ClientToWindowSize(const LayoutDeviceIntSize& aClientSize)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   if (!mWindow)
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -1556,20 +1556,20 @@ nsWindow::UpdateClientOffset()
     int32_t left = int32_t(frame_extents[0]);
     int32_t top = int32_t(frame_extents[2]);
 
     g_free(frame_extents);
 
     mClientOffset = nsIntPoint(left, top);
 }
 
-nsIntPoint
-nsWindow::GetClientOffsetUntyped()
-{
-    return mClientOffset;
+LayoutDeviceIntPoint
+nsWindow::GetClientOffset()
+{
+    return LayoutDeviceIntPoint::FromUnknownPoint(mClientOffset);
 }
 
 gboolean
 nsWindow::OnPropertyNotifyEvent(GtkWidget* aWidget, GdkEventProperty* aEvent)
 
 {
   if (aEvent->atom == gdk_atom_intern("_NET_FRAME_EXTENTS", FALSE)) {
     UpdateClientOffset();
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -129,17 +129,17 @@ public:
                                    bool                        aActivate) override;
     void               SetZIndex(int32_t aZIndex) override;
     NS_IMETHOD         SetSizeMode(nsSizeMode aMode) override;
     NS_IMETHOD         Enable(bool aState) override;
     NS_IMETHOD         SetFocus(bool aRaise = false) override;
     NS_IMETHOD         GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) override;
     NS_IMETHOD         GetClientBounds(mozilla::LayoutDeviceIntRect &aRect) override;
     virtual mozilla::gfx::IntSize GetClientSize() override;
-    virtual nsIntPoint GetClientOffsetUntyped() override;
+    virtual mozilla::LayoutDeviceIntPoint GetClientOffset() override;
     NS_IMETHOD         SetCursor(nsCursor aCursor) override;
     NS_IMETHOD         SetCursor(imgIContainer* aCursor,
                                  uint32_t aHotspotX, uint32_t aHotspotY) override;
     NS_IMETHOD         Invalidate(const nsIntRect &aRect) override;
     virtual void*      GetNativeData(uint32_t aDataType) override;
     void               SetNativeData(uint32_t aDataType, uintptr_t aVal) override;
     NS_IMETHOD         SetTitle(const nsAString& aTitle) override;
     NS_IMETHOD         SetIcon(const nsAString& aIconSpec) override;
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -1338,20 +1338,20 @@ NS_METHOD nsBaseWidget::GetScreenBounds(
 NS_METHOD nsBaseWidget::GetRestoredBounds(LayoutDeviceIntRect& aRect)
 {
   if (SizeMode() != nsSizeMode_Normal) {
     return NS_ERROR_FAILURE;
   }
   return GetScreenBounds(aRect);
 }
 
-nsIntPoint
-nsBaseWidget::GetClientOffsetUntyped()
+LayoutDeviceIntPoint
+nsBaseWidget::GetClientOffset()
 {
-  return nsIntPoint(0, 0);
+  return LayoutDeviceIntPoint(0, 0);
 }
 
 NS_IMETHODIMP
 nsBaseWidget::GetNonClientMargins(LayoutDeviceIntMargin &margins)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -190,17 +190,17 @@ public:
   NS_IMETHOD              GetBounds(mozilla::LayoutDeviceIntRect &aRect) override;
   NS_IMETHOD              GetClientBounds(mozilla::LayoutDeviceIntRect &aRect) override;
   NS_IMETHOD              GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) override;
   NS_IMETHOD              GetRestoredBounds(mozilla::LayoutDeviceIntRect &aRect) override;
   NS_IMETHOD              GetNonClientMargins(
                             mozilla::LayoutDeviceIntMargin &margins) override;
   NS_IMETHOD              SetNonClientMargins(
                             mozilla::LayoutDeviceIntMargin &margins) override;
-  virtual nsIntPoint      GetClientOffsetUntyped() override;
+  virtual mozilla::LayoutDeviceIntPoint GetClientOffset() override;
   NS_IMETHOD              EnableDragDrop(bool aEnable) override;
   NS_IMETHOD              GetAttention(int32_t aCycleCount) override;
   virtual bool            HasPendingInputEvent() override;
   NS_IMETHOD              SetIcon(const nsAString &anIconSpec) override;
   NS_IMETHOD              SetWindowTitlebarColor(nscolor aColor, bool aActive) override;
   virtual void            SetDrawsInTitlebar(bool aState) override {}
   virtual bool            ShowsResizeIndicator(nsIntRect* aResizerRect) override;
   virtual void            FreeNativeData(void * data, uint32_t aDataType) override {}
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -885,27 +885,19 @@ class nsIWidget : public nsISupports {
      *  dimensions between zero and size < system default.
      *
      */
     NS_IMETHOD SetNonClientMargins(mozilla::LayoutDeviceIntMargin &margins) = 0;
 
     /**
      * Get the client offset from the window origin.
      *
-     * The untyped version exists temporarily to ease conversion to typed
-     * coordinates.
-     *
      * @return the x and y of the offset.
-     *
      */
-    virtual mozilla::LayoutDeviceIntPoint GetClientOffset() {
-      nsIntPoint tmp = GetClientOffsetUntyped();
-      return mozilla::LayoutDeviceIntPoint::FromUnknownPoint(tmp);
-    }
-    virtual nsIntPoint GetClientOffsetUntyped() = 0;
+    virtual mozilla::LayoutDeviceIntPoint GetClientOffset() = 0;
 
     /**
      * Equivalent to GetClientBounds but only returns the size.
      */
     virtual mozilla::gfx::IntSize GetClientSize() {
       // Dependeing on the backend, overloading this method may be useful if
       // if requesting the client offset is expensive.
       mozilla::LayoutDeviceIntRect rect;
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -1988,29 +1988,29 @@ NS_METHOD nsWindow::GetRestoredBounds(La
   VERIFY(::GetMonitorInfo(monitor, &mi));
 
   aRect.SetRect(r.left, r.top, r.right - r.left, r.bottom - r.top);
   aRect.MoveBy(mi.rcWork.left - mi.rcMonitor.left,
                mi.rcWork.top - mi.rcMonitor.top);
   return NS_OK;
 }
 
-// return the x,y offset of the client area from the origin
-// of the window. If the window is borderless returns (0,0).
-nsIntPoint
-nsWindow::GetClientOffsetUntyped()
+// Return the x,y offset of the client area from the origin of the window. If
+// the window is borderless returns (0,0).
+LayoutDeviceIntPoint
+nsWindow::GetClientOffset()
 {
   if (!mWnd) {
-    return nsIntPoint(0, 0);
+    return LayoutDeviceIntPoint(0, 0);
   }
 
   RECT r1;
   GetWindowRect(mWnd, &r1);
   LayoutDeviceIntPoint pt = WidgetToScreenOffset();
-  return nsIntPoint(pt.x - r1.left, pt.y - r1.top);
+  return LayoutDeviceIntPoint(pt.x - r1.left, pt.y - r1.top);
 }
 
 void
 nsWindow::SetDrawsInTitlebar(bool aState)
 {
   nsWindow * window = GetTopLevelWindow(true);
   if (window && window != this) {
     return window->SetDrawsInTitlebar(aState);
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -115,17 +115,17 @@ public:
   NS_IMETHOD              SetSizeMode(nsSizeMode aMode);
   NS_IMETHOD              Enable(bool aState);
   virtual bool            IsEnabled() const;
   NS_IMETHOD              SetFocus(bool aRaise);
   NS_IMETHOD              GetBounds(mozilla::LayoutDeviceIntRect &aRect) override;
   NS_IMETHOD              GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) override;
   NS_IMETHOD              GetRestoredBounds(mozilla::LayoutDeviceIntRect &aRect) override;
   NS_IMETHOD              GetClientBounds(mozilla::LayoutDeviceIntRect &aRect) override;
-  virtual nsIntPoint      GetClientOffsetUntyped() override;
+  virtual mozilla::LayoutDeviceIntPoint GetClientOffset() override;
   void                    SetBackgroundColor(const nscolor &aColor);
   NS_IMETHOD              SetCursor(imgIContainer* aCursor,
                                     uint32_t aHotspotX, uint32_t aHotspotY);
   NS_IMETHOD              SetCursor(nsCursor aCursor);
   virtual nsresult        ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
   virtual bool PrepareForFullscreenTransition(nsISupports** aData) override;
   virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
                                            uint16_t aDuration,