Skip to content

Commit

Permalink
Bug 1196163 part 1 - Use nsSizeMode instead of int32_t for nsIWidget:…
Browse files Browse the repository at this point in the history
…:{SizeMode,SetSizeMode}. r=roc

--HG--
extra : source : cf438b9cb26ae512f792f075e4e22537ad6a38a7
  • Loading branch information
upsuper committed Aug 29, 2015
1 parent ef4e2e1 commit f46a938
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion widget/android/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
}

NS_IMETHODIMP
nsWindow::SetSizeMode(int32_t aMode)
nsWindow::SetSizeMode(nsSizeMode aMode)
{
switch (aMode) {
case nsSizeMode_Minimized:
Expand Down
2 changes: 1 addition & 1 deletion widget/android/nsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class nsWindow :
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;
Expand Down
2 changes: 1 addition & 1 deletion widget/cocoa/nsCocoaWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa
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);
Expand Down
2 changes: 1 addition & 1 deletion widget/cocoa/nsCocoaWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ static unsigned int WindowMaskForBorderStyle(nsBorderStyle aBorderStyle)
return NS_OK;
}

NS_METHOD nsCocoaWindow::SetSizeMode(int32_t aMode)
NS_METHOD nsCocoaWindow::SetSizeMode(nsSizeMode aMode)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;

Expand Down
2 changes: 1 addition & 1 deletion widget/gtk/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ nsWindow::SetZIndex(int32_t aZIndex)
}

NS_IMETHODIMP
nsWindow::SetSizeMode(int32_t aMode)
nsWindow::SetSizeMode(nsSizeMode aMode)
{
nsresult rv;

Expand Down
2 changes: 1 addition & 1 deletion widget/gtk/nsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class nsWindow : public nsBaseWidget
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;
Expand Down
18 changes: 8 additions & 10 deletions widget/nsBaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,17 +640,15 @@ NS_IMETHODIMP nsBaseWidget::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
// 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;
}

//-------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions widget/nsBaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference
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;
}
Expand Down
6 changes: 3 additions & 3 deletions widget/nsIWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "mozilla/widget/IMEData.h"
#include "nsDataHashtable.h"
#include "nsIObserver.h"
#include "nsIWidgetListener.h"
#include "FrameMetrics.h"
#include "Units.h"

Expand All @@ -35,7 +36,6 @@ class nsIRollupListener;
class imgIContainer;
class nsIContent;
class ViewWrapper;
class nsIWidgetListener;
class nsIntRegion;
class nsIScreen;
class nsIRunnable;
Expand Down Expand Up @@ -763,13 +763,13 @@ class nsIWidget : public nsISupports {
* 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
Expand Down
2 changes: 1 addition & 1 deletion widget/qt/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
}

NS_IMETHODIMP
nsWindow::SetSizeMode(int32_t aMode)
nsWindow::SetSizeMode(nsSizeMode aMode)
{
nsresult rv;

Expand Down
2 changes: 1 addition & 1 deletion widget/qt/nsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class nsWindow : public nsBaseWidget
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);
Expand Down
4 changes: 2 additions & 2 deletions widget/uikit/nsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ class nsWindow :
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();
Expand Down
4 changes: 2 additions & 2 deletions widget/uikit/nsWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ - (void)drawRect:(CGRect)aRect inContext:(CGContextRef)aContext
}

NS_IMETHODIMP
nsWindow::SetSizeMode(int32_t aMode)
nsWindow::SetSizeMode(nsSizeMode aMode)
{
if (aMode == static_cast<int32_t>(mSizeMode)) {
return NS_OK;
Expand Down Expand Up @@ -749,7 +749,7 @@ - (void)drawRect:(CGRect)aRect inContext:(CGContextRef)aContext
NotifyWindowMoved(mBounds.x, mBounds.y);
}

void nsWindow::ReportSizeModeEvent(int32_t aMode)
void nsWindow::ReportSizeModeEvent(nsSizeMode aMode)
{
if (mWidgetListener) {
// This is terrible.
Expand Down
3 changes: 2 additions & 1 deletion widget/windows/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,8 @@ NS_METHOD nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
}

// Maximize, minimize or restore the window.
NS_IMETHODIMP nsWindow::SetSizeMode(int32_t aMode) {
NS_IMETHODIMP
nsWindow::SetSizeMode(nsSizeMode aMode) {

nsresult rv;

Expand Down
2 changes: 1 addition & 1 deletion widget/windows/nsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class nsWindow : public nsWindowBase
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);
Expand Down
6 changes: 3 additions & 3 deletions xpfe/appshell/nsXULWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(uint32_t aLevel)
/* 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;
}
Expand Down Expand Up @@ -1195,7 +1195,7 @@ bool nsXULWindow::LoadMiscPersistentAttributesFromXUL()

// 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;
Expand Down Expand Up @@ -1511,7 +1511,7 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
}

if (mPersistentAttributesDirty & PAD_MISC) {
int32_t sizeMode = mWindow->SizeMode();
nsSizeMode sizeMode = mWindow->SizeMode();

if (sizeMode != nsSizeMode_Minimized) {
if (sizeMode == nsSizeMode_Maximized)
Expand Down

0 comments on commit f46a938

Please sign in to comment.