Bug 1196163 part 1 - Use nsSizeMode instead of int32_t for nsIWidget::{SizeMode,SetSizeMode}. r=roc
authorXidorn Quan <quanxunzhen@gmail.com>
Sat, 29 Aug 2015 11:12:41 +1000
changeset 259955 b8d3872064c7f369787c5097db9956ca99a5253c
parent 259954 312566100da60a845adeb0f0b96826822afc542c
child 259956 7e1086bf601817c1c2213e7baa0115debd3515a7
push id29296
push userryanvm@gmail.com
push dateSun, 30 Aug 2015 19:45:10 +0000
treeherdermozilla-central@2ad5077d86ba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1196163
milestone43.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 1196163 part 1 - Use nsSizeMode instead of int32_t for nsIWidget::{SizeMode,SetSizeMode}. r=roc
widget/android/nsWindow.cpp
widget/android/nsWindow.h
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/qt/nsWindow.cpp
widget/qt/nsWindow.h
widget/uikit/nsWindow.h
widget/uikit/nsWindow.mm
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
xpfe/appshell/nsXULWindow.cpp
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -515,17 +515,17 @@ NS_IMETHODIMP
 nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
                       nsIWidget *aWidget,
                       bool aActivate)
 {
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsWindow::SetSizeMode(int32_t aMode)
+nsWindow::SetSizeMode(nsSizeMode aMode)
 {
     switch (aMode) {
         case nsSizeMode_Minimized:
             GeckoAppShell::MoveTaskToBack();
             break;
         case nsSizeMode_Fullscreen:
             MakeFullScreen(true);
             break;
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -88,17 +88,17 @@ public:
                       double aY,
                       double aWidth,
                       double aHeight,
                       bool aRepaint) override;
     void SetZIndex(int32_t aZIndex) override;
     NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
                            nsIWidget *aWidget,
                            bool aActivate) override;
-    NS_IMETHOD SetSizeMode(int32_t aMode) override;
+    NS_IMETHOD SetSizeMode(nsSizeMode aMode) override;
     NS_IMETHOD Enable(bool aState) override;
     virtual bool IsEnabled() const override;
     NS_IMETHOD Invalidate(const nsIntRect &aRect) override;
     NS_IMETHOD SetFocus(bool aRaise = false) override;
     NS_IMETHOD GetScreenBounds(nsIntRect &aRect) override;
     virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() override;
     NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
                              nsEventStatus& aStatus) override;
--- a/widget/cocoa/nsCocoaWindow.h
+++ b/widget/cocoa/nsCocoaWindow.h
@@ -278,17 +278,17 @@ public:
     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;
     NS_IMETHOD              Move(double aX, double aY) override;
     NS_IMETHOD              PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
                                         nsIWidget *aWidget, bool aActivate) override;
-    NS_IMETHOD              SetSizeMode(int32_t aMode) override;
+    NS_IMETHOD              SetSizeMode(nsSizeMode aMode) override;
     NS_IMETHOD              HideWindowChrome(bool aShouldHide) override;
 
     void EnteredFullScreen(bool aFullScreen, bool aNativeMode = true);
     virtual bool PrepareForFullscreenTransition(nsISupports** aData) override;
     virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
                                              uint16_t aDuration,
                                              nsISupports* aData,
                                              nsIRunnable* aCallback) override;
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -1172,17 +1172,17 @@ NS_IMETHODIMP nsCocoaWindow::Move(double
 
 // Position the window behind the given window
 NS_METHOD nsCocoaWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
                                      nsIWidget *aWidget, bool aActivate)
 {
   return NS_OK;
 }
 
-NS_METHOD nsCocoaWindow::SetSizeMode(int32_t aMode)
+NS_METHOD nsCocoaWindow::SetSizeMode(nsSizeMode aMode)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   if (!mWindow)
     return NS_OK;
 
   // mSizeMode will be updated in DispatchSizeModeEvent, which will be called
   // from a delegate method that handles the state change during one of the
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -1231,17 +1231,17 @@ nsWindow::SetZIndex(int32_t aZIndex)
              w = static_cast<nsWindow*>(w->GetPrevSibling())) {
             if (w->mGdkWindow)
                 gdk_window_lower(w->mGdkWindow);
         }
     }
 }
 
 NS_IMETHODIMP
-nsWindow::SetSizeMode(int32_t aMode)
+nsWindow::SetSizeMode(nsSizeMode aMode)
 {
     nsresult rv;
 
     LOG(("nsWindow::SetSizeMode [%p] %d\n", (void *)this, aMode));
 
     // Save the requested state.
     rv = nsBaseWidget::SetSizeMode(aMode);
 
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -121,17 +121,17 @@ public:
                                          bool   aRepaint) override;
     virtual bool       IsEnabled() const override;
 
 
     NS_IMETHOD         PlaceBehind(nsTopLevelWidgetZPlacement  aPlacement,
                                    nsIWidget                  *aWidget,
                                    bool                        aActivate) override;
     void               SetZIndex(int32_t aZIndex) override;
-    NS_IMETHOD         SetSizeMode(int32_t aMode) override;
+    NS_IMETHOD         SetSizeMode(nsSizeMode aMode) override;
     NS_IMETHOD         Enable(bool aState) override;
     NS_IMETHOD         SetFocus(bool aRaise = false) override;
     NS_IMETHOD         GetScreenBounds(nsIntRect &aRect) override;
     NS_IMETHOD         GetClientBounds(nsIntRect &aRect) override;
     virtual mozilla::gfx::IntSize GetClientSize() override;
     virtual nsIntPoint GetClientOffset() override;
     NS_IMETHOD         SetCursor(nsCursor aCursor) override;
     NS_IMETHOD         SetCursor(imgIContainer* aCursor,
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -635,27 +635,25 @@ NS_IMETHODIMP nsBaseWidget::PlaceBehind(
 }
 
 //-------------------------------------------------------------------------
 //
 // Maximize, minimize or restore the window. The BaseWidget implementation
 // merely stores the state.
 //
 //-------------------------------------------------------------------------
-NS_IMETHODIMP nsBaseWidget::SetSizeMode(int32_t aMode)
+NS_IMETHODIMP
+nsBaseWidget::SetSizeMode(nsSizeMode aMode)
 {
-  if (aMode == nsSizeMode_Normal ||
-      aMode == nsSizeMode_Minimized ||
-      aMode == nsSizeMode_Maximized ||
-      aMode == nsSizeMode_Fullscreen) {
-
-    mSizeMode = (nsSizeMode) aMode;
-    return NS_OK;
-  }
-  return NS_ERROR_ILLEGAL_VALUE;
+  MOZ_ASSERT(aMode == nsSizeMode_Normal ||
+             aMode == nsSizeMode_Minimized ||
+             aMode == nsSizeMode_Maximized ||
+             aMode == nsSizeMode_Fullscreen);
+  mSizeMode = aMode;
+  return NS_OK;
 }
 
 //-------------------------------------------------------------------------
 //
 // Get this component cursor
 //
 //-------------------------------------------------------------------------
 nsCursor nsBaseWidget::GetCursor()
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -119,18 +119,18 @@ public:
   virtual float           GetDPI() override;
   virtual void            AddChild(nsIWidget* aChild) override;
   virtual void            RemoveChild(nsIWidget* aChild) override;
 
   void                    SetZIndex(int32_t aZIndex) override;
   NS_IMETHOD              PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
                                       nsIWidget *aWidget, bool aActivate) override;
 
-  NS_IMETHOD              SetSizeMode(int32_t aMode) override;
-  virtual int32_t         SizeMode() override
+  NS_IMETHOD              SetSizeMode(nsSizeMode aMode) override;
+  virtual nsSizeMode      SizeMode() override
   {
     return mSizeMode;
   }
 
   virtual nsCursor        GetCursor() override;
   NS_IMETHOD              SetCursor(nsCursor aCursor) override;
   NS_IMETHOD              SetCursor(imgIContainer* aCursor,
                                     uint32_t aHotspotX, uint32_t aHotspotY) override;
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -22,25 +22,25 @@
 #include "mozilla/EventForwards.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/gfx/Point.h"
 #include "mozilla/widget/IMEData.h"
 #include "nsDataHashtable.h"
 #include "nsIObserver.h"
+#include "nsIWidgetListener.h"
 #include "FrameMetrics.h"
 #include "Units.h"
 
 // forward declarations
 class   nsIRollupListener;
 class   imgIContainer;
 class   nsIContent;
 class   ViewWrapper;
-class   nsIWidgetListener;
 class   nsIntRegion;
 class   nsIScreen;
 class   nsIRunnable;
 
 namespace mozilla {
 class CompositorVsyncDispatcher;
 namespace dom {
 class TabChild;
@@ -758,23 +758,23 @@ class nsIWidget : public nsISupports {
      */
     NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
                            nsIWidget *aWidget, bool aActivate) = 0;
 
     /**
      * Minimize, maximize or normalize the window size.
      * Takes a value from nsSizeMode (see nsIWidgetListener.h)
      */
-    NS_IMETHOD SetSizeMode(int32_t aMode) = 0;
+    NS_IMETHOD SetSizeMode(nsSizeMode aMode) = 0;
 
     /**
      * Return size mode (minimized, maximized, normalized).
      * Returns a value from nsSizeMode (see nsIWidgetListener.h)
      */
-    virtual int32_t SizeMode() = 0;
+    virtual nsSizeMode SizeMode() = 0;
 
     /**
      * Enable or disable this Widget
      *
      * @param aState true to enable the Widget, false to disable it.
      *
      */
     NS_IMETHOD Enable(bool aState) = 0;
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -1422,17 +1422,17 @@ NS_IMETHODIMP
 nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement  aPlacement,
                       nsIWidget                  *aWidget,
                       bool                        aActivate)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsWindow::SetSizeMode(int32_t aMode)
+nsWindow::SetSizeMode(nsSizeMode aMode)
 {
     nsresult rv;
 
     LOG(("nsWindow::SetSizeMode [%p] %d\n", (void *)this, aMode));
     if (aMode != nsSizeMode_Minimized) {
         mWidget->requestActivate();
     }
 
--- a/widget/qt/nsWindow.h
+++ b/widget/qt/nsWindow.h
@@ -196,17 +196,17 @@ public:
     // Old QtWidget only
     NS_IMETHOD         SetParent(nsIWidget* aNewParent);
     virtual nsIWidget *GetParent(void);
     virtual float      GetDPI();
     NS_IMETHOD         SetModal(bool aModal);
     NS_IMETHOD         PlaceBehind(nsTopLevelWidgetZPlacement  aPlacement,
                                    nsIWidget                  *aWidget,
                                    bool                        aActivate);
-    NS_IMETHOD         SetSizeMode(int32_t aMode);
+    NS_IMETHOD         SetSizeMode(nsSizeMode aMode);
     NS_IMETHOD         GetScreenBounds(nsIntRect &aRect);
     NS_IMETHOD         SetHasTransparentBackground(bool aTransparent);
     NS_IMETHOD         GetHasTransparentBackground(bool& aTransparent);
     NS_IMETHOD         HideWindowChrome(bool aShouldHide);
     NS_IMETHOD         SetIcon(const nsAString& aIconSpec);
     NS_IMETHOD         CaptureMouse(bool aCapture);
     NS_IMETHOD         SetWindowClass(const nsAString& xulWinType);
     NS_IMETHOD         GetAttention(int32_t aCycleCount);
--- a/widget/uikit/nsWindow.h
+++ b/widget/uikit/nsWindow.h
@@ -52,24 +52,24 @@ public:
     virtual void SetBackgroundColor(const nscolor &aColor) override;
     virtual void* GetNativeData(uint32_t aDataType) override;
 
     NS_IMETHOD              ConstrainPosition(bool aAllowSlop,
                                               int32_t *aX, int32_t *aY) override;
     NS_IMETHOD              Move(double aX, double aY) override;
     NS_IMETHOD              PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
                                         nsIWidget *aWidget, bool aActivate) override;
-    NS_IMETHOD              SetSizeMode(int32_t aMode) override;
+    NS_IMETHOD              SetSizeMode(nsSizeMode aMode) override;
     void                    EnteredFullScreen(bool aFullScreen);
     NS_IMETHOD              Resize(double aWidth, double aHeight, bool aRepaint) override;
     NS_IMETHOD              Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint) override;
     NS_IMETHOD              GetScreenBounds(nsIntRect &aRect) override;
     void                    ReportMoveEvent();
     void                    ReportSizeEvent();
-    void                    ReportSizeModeEvent(int32_t aMode);
+    void                    ReportSizeModeEvent(nsSizeMode aMode);
 
     CGFloat                 BackingScaleFactor();
     void                    BackingScaleFactorChanged();
     virtual float           GetDPI() override {
         //XXX: terrible
         return 326.0f;
     }
     virtual double          GetDefaultScaleInternal() override {
--- a/widget/uikit/nsWindow.mm
+++ b/widget/uikit/nsWindow.mm
@@ -677,17 +677,17 @@ NS_IMETHODIMP
 nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
                       nsIWidget *aWidget,
                       bool aActivate)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsWindow::SetSizeMode(int32_t aMode)
+nsWindow::SetSizeMode(nsSizeMode aMode)
 {
     if (aMode == static_cast<int32_t>(mSizeMode)) {
         return NS_OK;
     }
 
     nsresult rv = NS_OK;
     mSizeMode = static_cast<nsSizeMode>(aMode);
     if (aMode == nsSizeMode_Maximized || aMode == nsSizeMode_Fullscreen) {
@@ -744,17 +744,17 @@ bool nsWindow::PaintWindow(nsIntRegion a
   return returnValue;
 }
 
 void nsWindow::ReportMoveEvent()
 {
     NotifyWindowMoved(mBounds.x, mBounds.y);
 }
 
-void nsWindow::ReportSizeModeEvent(int32_t aMode)
+void nsWindow::ReportSizeModeEvent(nsSizeMode aMode)
 {
     if (mWidgetListener) {
         // This is terrible.
         nsSizeMode theMode;
         switch (aMode) {
         case nsSizeMode_Maximized:
             theMode = nsSizeMode_Maximized;
             break;
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -1660,17 +1660,18 @@ NS_METHOD nsWindow::PlaceBehind(nsTopLev
     flags |= SWP_NOACTIVATE;
   }
 
   ::SetWindowPos(mWnd, behind, 0, 0, 0, 0, flags);
   return NS_OK;
 }
 
 // Maximize, minimize or restore the window.
-NS_IMETHODIMP nsWindow::SetSizeMode(int32_t aMode) {
+NS_IMETHODIMP
+nsWindow::SetSizeMode(nsSizeMode aMode) {
 
   nsresult rv;
 
   // Let's not try and do anything if we're already in that state.
   // (This is needed to prevent problems when calling window.minimize(), which
   // calls us directly, and then the OS triggers another call to us.)
   if (aMode == mSizeMode)
     return NS_OK;
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -107,17 +107,17 @@ public:
   virtual void            SetSizeConstraints(const SizeConstraints& aConstraints);
   NS_IMETHOD              Move(double aX, double aY);
   NS_IMETHOD              Resize(double aWidth, double aHeight, bool aRepaint);
   NS_IMETHOD              Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint);
   NS_IMETHOD              BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
                                           int32_t aHorizontal,
                                           int32_t aVertical);
   NS_IMETHOD              PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget *aWidget, bool aActivate);
-  NS_IMETHOD              SetSizeMode(int32_t aMode);
+  NS_IMETHOD              SetSizeMode(nsSizeMode aMode);
   NS_IMETHOD              Enable(bool aState);
   virtual bool            IsEnabled() const;
   NS_IMETHOD              SetFocus(bool aRaise);
   NS_IMETHOD              GetBounds(nsIntRect &aRect);
   NS_IMETHOD              GetScreenBounds(nsIntRect &aRect);
   NS_IMETHOD              GetRestoredBounds(nsIntRect &aRect) override;
   NS_IMETHOD              GetClientBounds(nsIntRect &aRect);
   virtual nsIntPoint      GetClientOffset();
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -209,17 +209,17 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(uin
   uint32_t zLevel;
   mediator->GetZLevel(this, &zLevel);
   if (zLevel == aLevel)
     return NS_OK;
 
   /* refuse to raise a maximized window above the normal browser level,
      for fear it could hide newly opened browser windows */
   if (aLevel > nsIXULWindow::normalZ && mWindow) {
-    int32_t sizeMode = mWindow->SizeMode();
+    nsSizeMode sizeMode = mWindow->SizeMode();
     if (sizeMode == nsSizeMode_Maximized || sizeMode == nsSizeMode_Fullscreen) {
       return NS_ERROR_FAILURE;
     }
   }
 
   // do it
   mediator->SetZLevel(this, aLevel);
   PersistentAttributesDirty(PAD_MISC);
@@ -1190,17 +1190,17 @@ bool nsXULWindow::LoadMiscPersistentAttr
 
   nsCOMPtr<dom::Element> windowElement = GetWindowDOMElement();
   NS_ENSURE_TRUE(windowElement, false);
 
   nsAutoString stateString;
 
   // sizemode
   windowElement->GetAttribute(MODE_ATTRIBUTE, stateString);
-  int32_t sizeMode = nsSizeMode_Normal;
+  nsSizeMode sizeMode = nsSizeMode_Normal;
   /* ignore request to minimize, to not confuse novices
   if (stateString.Equals(SIZEMODE_MINIMIZED))
     sizeMode = nsSizeMode_Minimized;
   */
   if (!mIgnoreXULSizeMode &&
       (stateString.Equals(SIZEMODE_MAXIMIZED) || stateString.Equals(SIZEMODE_FULLSCREEN))) {
     /* Honor request to maximize only if the window is sizable.
        An unsizable, unmaximizable, yet maximized window confuses
@@ -1506,17 +1506,17 @@ NS_IMETHODIMP nsXULWindow::SavePersisten
       sizeString.AssignWithConversion(sizeBuf);
       docShellElement->SetAttribute(HEIGHT_ATTRIBUTE, sizeString, rv);
       if (ownerXULDoc)
         ownerXULDoc->Persist(windowElementId, HEIGHT_ATTRIBUTE);
     }
   }
 
   if (mPersistentAttributesDirty & PAD_MISC) {
-    int32_t sizeMode = mWindow->SizeMode();
+    nsSizeMode sizeMode = mWindow->SizeMode();
 
     if (sizeMode != nsSizeMode_Minimized) {
       if (sizeMode == nsSizeMode_Maximized)
         sizeString.Assign(SIZEMODE_MAXIMIZED);
       else if (sizeMode == nsSizeMode_Fullscreen)
         sizeString.Assign(SIZEMODE_FULLSCREEN);
       else
         sizeString.Assign(SIZEMODE_NORMAL);