Bug 1296993 (part 3) - Streamline nsIWidget::ConstrainPosition. r=mstange.

This patch does the following.

- Removes the return value, because none of the call sites check it.

- Puts an empty implementation into nsBaseWidget.

- Removes the empty implementations from several nsIWidget instances, because
  they can use the nsBaseWidget one.

--HG--
extra : rebase_source : ccf64aaa9364d096e1f060ef77be7e8455b11e1f
This commit is contained in:
Nicholas Nethercote 2016-08-25 13:43:27 +10:00
Родитель 672f94a22d
Коммит d8684f0659
18 изменённых файлов: 32 добавлений и 65 удалений

Просмотреть файл

@ -68,8 +68,6 @@ public:
nsWidgetInitData* aInitData = nullptr) override { return NS_OK; }
NS_IMETHOD Show(bool aState) override { return NS_OK; }
virtual bool IsVisible() const override { return true; }
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
int32_t *aX, int32_t *aY) override { return NS_OK; }
NS_IMETHOD Move(double aX, double aY) override { return NS_OK; }
NS_IMETHOD Resize(double aWidth, double aHeight, bool aRepaint) override { return NS_OK; }
NS_IMETHOD Resize(double aX, double aY,

Просмотреть файл

@ -83,10 +83,10 @@ public:
virtual bool IsVisible() const override
{ return mVisible; }
NS_IMETHOD ConstrainPosition(bool /*ignored aAllowSlop*/,
int32_t* aX,
int32_t* aY) override
{ *aX = kMaxDimension; *aY = kMaxDimension; return NS_OK; }
virtual void ConstrainPosition(bool /*ignored aAllowSlop*/,
int32_t* aX,
int32_t* aY) override
{ *aX = kMaxDimension; *aY = kMaxDimension; }
// Widget position is controlled by the parent process via TabChild.
NS_IMETHOD Move(double aX, double aY) override

Просмотреть файл

@ -1742,7 +1742,7 @@ nsWindow::IsVisible() const
return mIsVisible;
}
NS_IMETHODIMP
void
nsWindow::ConstrainPosition(bool aAllowSlop,
int32_t *aX,
int32_t *aY)
@ -1754,8 +1754,6 @@ nsWindow::ConstrainPosition(bool aAllowSlop,
*aX = 0;
*aY = 0;
}
return NS_OK;
}
NS_IMETHODIMP

Просмотреть файл

@ -141,9 +141,9 @@ public:
virtual double GetDefaultScaleInternal() override;
NS_IMETHOD Show(bool aState) override;
virtual bool IsVisible() const override;
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
int32_t *aX,
int32_t *aY) override;
virtual void ConstrainPosition(bool aAllowSlop,
int32_t *aX,
int32_t *aY) override;
NS_IMETHOD Move(double aX,
double aY) override;
NS_IMETHOD Resize(double aWidth,

Просмотреть файл

@ -312,8 +312,6 @@ public:
virtual nsIWidget* GetParent(void) override;
virtual float GetDPI() override;
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
int32_t *aX, int32_t *aY) override;
NS_IMETHOD Move(double aX, double aY) override;
NS_IMETHOD Resize(double aWidth, double aHeight, bool aRepaint) override;
NS_IMETHOD Resize(double aX, double aY,

Просмотреть файл

@ -948,12 +948,6 @@ nsChildView::RoundsWidgetCoordinatesTo()
return 1;
}
NS_IMETHODIMP nsChildView::ConstrainPosition(bool aAllowSlop,
int32_t *aX, int32_t *aY)
{
return NS_OK;
}
// Move this component, aX and aY are in the parent widget coordinate system
NS_IMETHODIMP nsChildView::Move(double aX, double aY)
{

Просмотреть файл

@ -252,7 +252,7 @@ public:
virtual void* GetNativeData(uint32_t aDataType) override;
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
virtual void 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;

Просмотреть файл

@ -1112,11 +1112,13 @@ bool nsCocoaWindow::IsEnabled() const
#define kWindowPositionSlop 20
NS_IMETHODIMP nsCocoaWindow::ConstrainPosition(bool aAllowSlop,
int32_t *aX, int32_t *aY)
void
nsCocoaWindow::ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
if (!mWindow || ![mWindow screen]) {
return NS_OK;
return;
}
nsIntRect screenBounds;
@ -1166,7 +1168,7 @@ NS_IMETHODIMP nsCocoaWindow::ConstrainPosition(bool aAllowSlop,
}
}
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK;
}
void nsCocoaWindow::SetSizeConstraints(const SizeConstraints& aConstraints)

Просмотреть файл

@ -385,14 +385,6 @@ nsWindow::IsVisible() const
return mVisible;
}
NS_IMETHODIMP
nsWindow::ConstrainPosition(bool aAllowSlop,
int32_t *aX,
int32_t *aY)
{
return NS_OK;
}
NS_IMETHODIMP
nsWindow::Move(double aX,
double aY)

Просмотреть файл

@ -56,9 +56,6 @@ public:
NS_IMETHOD Show(bool aState);
virtual bool IsVisible() const;
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
int32_t *aX,
int32_t *aY);
NS_IMETHOD Move(double aX,
double aY);
NS_IMETHOD Resize(double aWidth,

Просмотреть файл

@ -968,11 +968,11 @@ nsWindow::RegisterTouchWindow()
#endif
}
NS_IMETHODIMP
void
nsWindow::ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY)
{
if (!mIsTopLevel || !mShell)
return NS_OK;
return;
double dpiScale = GetDefaultScale().scale;
@ -991,7 +991,7 @@ nsWindow::ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY)
// We don't have any screen so leave the coordinates as is
if (!screen)
return NS_OK;
return;
nsIntRect screenRect;
if (mSizeMode != nsSizeMode_Fullscreen) {
@ -1025,8 +1025,6 @@ nsWindow::ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY)
else if (*aY >= screenRect.YMost() - logHeight)
*aY = screenRect.YMost() - logHeight;
}
return NS_OK;
}
void nsWindow::SetSizeConstraints(const SizeConstraints& aConstraints)

Просмотреть файл

@ -109,7 +109,7 @@ public:
virtual nsresult SetParent(nsIWidget* aNewParent) override;
virtual void SetModal(bool aModal) override;
virtual bool IsVisible() const override;
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
virtual void ConstrainPosition(bool aAllowSlop,
int32_t *aX,
int32_t *aY) override;
virtual void SetSizeConstraints(const SizeConstraints& aConstraints) override;

Просмотреть файл

@ -214,6 +214,9 @@ public:
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() override {
return mozilla::DesktopToLayoutDeviceScale(1.0);
}
virtual void ConstrainPosition(bool aAllowSlop,
int32_t *aX,
int32_t *aY) override {}
NS_IMETHOD MoveClient(double aX, double aY) override;
NS_IMETHOD ResizeClient(double aWidth, double aHeight, bool aRepaint) override;
NS_IMETHOD ResizeClient(double aX, double aY, double aWidth, double aHeight, bool aRepaint) override;

Просмотреть файл

@ -678,12 +678,11 @@ class nsIWidget : public nsISupports
* out: the x position constrained to fit on the screen(s).
* @param aY in: an y position expressed in screen coordinates.
* out: the y position constrained to fit on the screen(s).
* @return vapid success indication. but see also the parameters.
*
**/
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
int32_t *aX,
int32_t *aY) = 0;
virtual void ConstrainPosition(bool aAllowSlop,
int32_t *aX,
int32_t *aY) = 0;
/**
* NOTE:

Просмотреть файл

@ -51,8 +51,6 @@ 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;

Просмотреть файл

@ -582,14 +582,6 @@ nsWindow::Show(bool aState)
return NS_OK;
}
NS_IMETHODIMP
nsWindow::ConstrainPosition(bool aAllowSlop,
int32_t *aX,
int32_t *aY)
{
return NS_OK;
}
NS_IMETHODIMP
nsWindow::Move(double aX, double aY)
{

Просмотреть файл

@ -1908,11 +1908,11 @@ nsWindow::SetSizeMode(nsSizeMode aMode)
// Constrain a potential move to fit onscreen
// Position (aX, aY) is specified in Windows screen (logical) pixels,
// except when using per-monitor DPI, in which case it's device pixels.
NS_IMETHODIMP nsWindow::ConstrainPosition(bool aAllowSlop,
int32_t *aX, int32_t *aY)
void
nsWindow::ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY)
{
if (!mIsTopWidgetWindow) // only a problem for top-level windows
return NS_OK;
return;
double dpiScale = GetDesktopToDeviceScale().scale;
@ -1927,7 +1927,7 @@ NS_IMETHODIMP nsWindow::ConstrainPosition(bool aAllowSlop,
nsCOMPtr<nsIScreenManager> screenmgr = do_GetService(sScreenManagerContractID);
if (!screenmgr) {
return NS_ERROR_NOT_AVAILABLE;
return;
}
nsCOMPtr<nsIScreen> screen;
int32_t left, top, width, height;
@ -1938,13 +1938,13 @@ NS_IMETHODIMP nsWindow::ConstrainPosition(bool aAllowSlop,
// For normalized windows, use the desktop work area.
nsresult rv = screen->GetAvailRectDisplayPix(&left, &top, &width, &height);
if (NS_FAILED(rv)) {
return rv;
return;
}
} else {
// For full screen windows, use the desktop.
nsresult rv = screen->GetRectDisplayPix(&left, &top, &width, &height);
if (NS_FAILED(rv)) {
return rv;
return;
}
}
screenRect.left = left;
@ -1975,8 +1975,6 @@ NS_IMETHODIMP nsWindow::ConstrainPosition(bool aAllowSlop,
else if (*aY >= screenRect.bottom - logHeight)
*aY = screenRect.bottom - logHeight;
}
return NS_OK;
}
/**************************************************************

Просмотреть файл

@ -120,7 +120,7 @@ public:
NS_IMETHOD Show(bool bState) override;
virtual bool IsVisible() const override;
NS_IMETHOD ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY) override;
virtual void ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY) override;
virtual void SetSizeConstraints(const SizeConstraints& aConstraints) override;
virtual const SizeConstraints GetSizeConstraints() override;
NS_IMETHOD Move(double aX, double aY) override;