Bug 1224482 (part 1) - Tweak typed/untyped versions of Get{,Client,Screen}Bounds(). r=kats.

In nsIWidget, GetBoundsUntyped(), GetClientBoundsUntyped() and
GetScreenBoundsUntyped() are currently the primary implementations, and the
untyped versions are defined on top of them. This patch flips that around.

--HG--
extra : rebase_source : 15b2f08f90bf4d1e209c6cb885f6a6e3b8db6708
This commit is contained in:
Nicholas Nethercote 2015-11-12 16:04:52 -08:00
Родитель 8b78d5e498
Коммит 369f54f3a3
20 изменённых файлов: 88 добавлений и 83 удалений

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

@ -34,12 +34,12 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD GetClientBoundsUntyped(IntRect &aRect) override {
aRect = IntRect(0, 0, gCompWidth, gCompHeight);
NS_IMETHOD GetClientBounds(LayoutDeviceIntRect& aRect) override {
aRect = LayoutDeviceIntRect(0, 0, gCompWidth, gCompHeight);
return NS_OK;
}
NS_IMETHOD GetBoundsUntyped(IntRect &aRect) override {
return GetClientBoundsUntyped(aRect);
NS_IMETHOD GetBounds(LayoutDeviceIntRect& aRect) override {
return GetClientBounds(aRect);
}
void* GetNativeData(uint32_t aDataType) override {

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

@ -1171,9 +1171,9 @@ PuppetWidget::GetWindowPosition()
}
NS_METHOD
PuppetWidget::GetScreenBoundsUntyped(nsIntRect &aRect) {
aRect.MoveTo(WidgetToScreenOffset().ToUnknownPoint());
aRect.SizeTo(mBounds.Size());
PuppetWidget::GetScreenBounds(LayoutDeviceIntRect& aRect) {
aRect.MoveTo(WidgetToScreenOffset());
aRect.SizeTo(LayoutDeviceIntSize::FromUnknownSize(mBounds.Size()));
return NS_OK;
}

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

@ -212,7 +212,7 @@ public:
// Get the screen position of the application window.
nsIntPoint GetWindowPosition();
NS_IMETHOD GetScreenBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) override;
NS_IMETHOD StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
int32_t aPanelX, int32_t aPanelY,

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

@ -953,7 +953,7 @@ nsWindow::BringToFront()
}
NS_IMETHODIMP
nsWindow::GetScreenBoundsUntyped(nsIntRect &aRect)
nsWindow::GetScreenBounds(LayoutDeviceIntRect& aRect)
{
LayoutDeviceIntPoint p = WidgetToScreenOffset();

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

@ -105,7 +105,7 @@ public:
virtual bool IsEnabled() const override;
NS_IMETHOD Invalidate(const nsIntRect &aRect) override;
NS_IMETHOD SetFocus(bool aRaise = false) override;
NS_IMETHOD GetScreenBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) override;
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() override;
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
nsEventStatus& aStatus) override;

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

@ -378,9 +378,9 @@ public:
NS_IMETHOD Enable(bool aState) override;
virtual bool IsEnabled() const override;
NS_IMETHOD SetFocus(bool aRaise) override;
NS_IMETHOD GetBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetClientBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetScreenBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetBounds(mozilla::LayoutDeviceIntRect &aRect) override;
NS_IMETHOD GetClientBounds(mozilla::LayoutDeviceIntRect &aRect) override;
NS_IMETHOD GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) override;
// Returns the "backing scale factor" of the view's window, which is the
// ratio of pixels in the window's backing store to Cocoa points. Prior to

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

@ -906,31 +906,33 @@ NS_IMETHODIMP nsChildView::SetCursor(imgIContainer* aCursor,
#pragma mark -
// Get this component dimension
NS_IMETHODIMP nsChildView::GetBoundsUntyped(nsIntRect &aRect)
NS_IMETHODIMP nsChildView::GetBounds(LayoutDeviceIntRect& aRect)
{
nsIntRect tmp;
if (!mView) {
aRect = mBounds;
tmp = mBounds;
} else {
aRect = CocoaPointsToDevPixels([mView frame]);
tmp = CocoaPointsToDevPixels([mView frame]);
}
aRect = LayoutDeviceIntRect::FromUnknownRect(tmp);
return NS_OK;
}
NS_IMETHODIMP nsChildView::GetClientBoundsUntyped(nsIntRect &aRect)
NS_IMETHODIMP nsChildView::GetClientBounds(mozilla::LayoutDeviceIntRect& aRect)
{
GetBoundsUntyped(aRect);
GetBounds(aRect);
if (!mParentWidget) {
// For top level widgets we want the position on screen, not the position
// of this view inside the window.
aRect.MoveTo(WidgetToScreenOffset().ToUnknownPoint());
aRect.MoveTo(WidgetToScreenOffset());
}
return NS_OK;
}
NS_IMETHODIMP nsChildView::GetScreenBoundsUntyped(nsIntRect &aRect)
NS_IMETHODIMP nsChildView::GetScreenBounds(LayoutDeviceIntRect& aRect)
{
GetBoundsUntyped(aRect);
aRect.MoveTo(WidgetToScreenOffset().ToUnknownPoint());
GetBounds(aRect);
aRect.MoveTo(WidgetToScreenOffset());
return NS_OK;
}

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

@ -307,8 +307,8 @@ public:
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 GetClientBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetScreenBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetClientBounds(mozilla::LayoutDeviceIntRect &aRect) override;
NS_IMETHOD GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) override;
void ReportMoveEvent();
void ReportSizeEvent();
NS_IMETHOD SetCursor(nsCursor aCursor) override;

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

@ -1550,13 +1550,14 @@ NS_IMETHODIMP nsCocoaWindow::Resize(double aWidth, double aHeight, bool aRepaint
aWidth, aHeight, aRepaint, true);
}
NS_IMETHODIMP nsCocoaWindow::GetClientBoundsUntyped(nsIntRect &aRect)
NS_IMETHODIMP nsCocoaWindow::GetClientBounds(mozilla::LayoutDeviceIntRect& aRect)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
CGFloat scaleFactor = BackingScaleFactor();
if (!mWindow) {
aRect = nsCocoaUtils::CocoaRectToGeckoRectDevPix(NSZeroRect, scaleFactor);
aRect = LayoutDeviceIntRect::FromUnknownRect(
nsCocoaUtils::CocoaRectToGeckoRectDevPix(NSZeroRect, scaleFactor));
return NS_OK;
}
@ -1568,7 +1569,8 @@ NS_IMETHODIMP nsCocoaWindow::GetClientBoundsUntyped(nsIntRect &aRect)
r = [mWindow contentRectForFrameRect:[mWindow frame]];
}
aRect = nsCocoaUtils::CocoaRectToGeckoRectDevPix(r, scaleFactor);
aRect = LayoutDeviceIntRect::FromUnknownRect(
nsCocoaUtils::CocoaRectToGeckoRectDevPix(r, scaleFactor));
return NS_OK;
@ -1585,7 +1587,7 @@ nsCocoaWindow::UpdateBounds()
mBounds = nsCocoaUtils::CocoaRectToGeckoRectDevPix(frame, BackingScaleFactor());
}
NS_IMETHODIMP nsCocoaWindow::GetScreenBoundsUntyped(nsIntRect &aRect)
NS_IMETHODIMP nsCocoaWindow::GetScreenBounds(LayoutDeviceIntRect &aRect)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -1594,7 +1596,7 @@ NS_IMETHODIMP nsCocoaWindow::GetScreenBoundsUntyped(nsIntRect &aRect)
NS_ASSERTION(mWindow && mBounds == r, "mBounds out of sync!");
#endif
aRect = mBounds;
aRect = LayoutDeviceIntRect::FromUnknownRect(mBounds);
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;

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

@ -1481,22 +1481,22 @@ nsWindow::SetFocus(bool aRaise)
}
NS_IMETHODIMP
nsWindow::GetScreenBoundsUntyped(nsIntRect &aRect)
nsWindow::GetScreenBounds(LayoutDeviceIntRect& aRect)
{
if (mIsTopLevel && mContainer) {
// use the point including window decorations
gint x, y;
gdk_window_get_root_origin(gtk_widget_get_window(GTK_WIDGET(mContainer)), &x, &y);
aRect.MoveTo(GdkPointToDevicePixels({ x, y }).ToUnknownPoint());
aRect.MoveTo(GdkPointToDevicePixels({ x, y }));
} else {
aRect.MoveTo(WidgetToScreenOffset().ToUnknownPoint());
aRect.MoveTo(WidgetToScreenOffset());
}
// mBounds.Size() is the window bounds, not the window-manager frame
// bounds (bug 581863). gdk_window_get_frame_extents would give the
// frame bounds, but mBounds.Size() is returned here for consistency
// with Resize.
aRect.SizeTo(mBounds.Size());
LOG(("GetScreenBoundsUntyped %d,%d | %dx%d\n",
aRect.SizeTo(LayoutDeviceIntSize::FromUnknownSize(mBounds.Size()));
LOG(("GetScreenBounds %d,%d | %dx%d\n",
aRect.x, aRect.y, aRect.width, aRect.height));
return NS_OK;
}
@ -1508,13 +1508,13 @@ nsWindow::GetClientSize()
}
NS_IMETHODIMP
nsWindow::GetClientBoundsUntyped(nsIntRect &aRect)
nsWindow::GetClientBounds(LayoutDeviceIntRect& aRect)
{
// GetBounds returns a rect whose top left represents the top left of the
// outer bounds, but whose width/height represent the size of the inner
// bounds (which is messed up).
GetBoundsUntyped(aRect);
aRect.MoveBy(GetClientOffsetUntyped());
GetBounds(aRect);
aRect.MoveBy(GetClientOffset());
return NS_OK;
}

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

@ -131,8 +131,8 @@ public:
NS_IMETHOD SetSizeMode(nsSizeMode aMode) override;
NS_IMETHOD Enable(bool aState) override;
NS_IMETHOD SetFocus(bool aRaise = false) override;
NS_IMETHOD GetScreenBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetClientBoundsUntyped(nsIntRect &aRect) 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;
NS_IMETHOD SetCursor(nsCursor aCursor) override;

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

@ -1310,18 +1310,18 @@ NS_METHOD nsBaseWidget::ResizeClient(double aX,
* If the implementation of nsWindow supports borders this method MUST be overridden
*
**/
NS_METHOD nsBaseWidget::GetClientBoundsUntyped(nsIntRect &aRect)
NS_METHOD nsBaseWidget::GetClientBounds(LayoutDeviceIntRect &aRect)
{
return GetBoundsUntyped(aRect);
return GetBounds(aRect);
}
/**
* If the implementation of nsWindow supports borders this method MUST be overridden
*
**/
NS_METHOD nsBaseWidget::GetBoundsUntyped(nsIntRect &aRect)
NS_METHOD nsBaseWidget::GetBounds(LayoutDeviceIntRect &aRect)
{
aRect = mBounds;
aRect = LayoutDeviceIntRect::FromUnknownRect(mBounds);
return NS_OK;
}
@ -1330,12 +1330,12 @@ NS_METHOD nsBaseWidget::GetBoundsUntyped(nsIntRect &aRect)
* this method must be overridden
*
**/
NS_METHOD nsBaseWidget::GetScreenBoundsUntyped(nsIntRect &aRect)
NS_METHOD nsBaseWidget::GetScreenBounds(LayoutDeviceIntRect& aRect)
{
return GetBoundsUntyped(aRect);
return GetBounds(aRect);
}
NS_METHOD nsBaseWidget::GetRestoredBounds(LayoutDeviceIntRect &aRect)
NS_METHOD nsBaseWidget::GetRestoredBounds(LayoutDeviceIntRect& aRect)
{
if (SizeMode() != nsSizeMode_Normal) {
return NS_ERROR_FAILURE;

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

@ -187,9 +187,9 @@ public:
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;
NS_IMETHOD GetBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetClientBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetScreenBoundsUntyped(nsIntRect &aRect) override;
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;

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

@ -808,13 +808,13 @@ class nsIWidget : public nsISupports {
* @param aRect On return it holds the x, y, width and height of
* this widget.
*/
NS_IMETHOD GetBounds(mozilla::LayoutDeviceIntRect &aRect) {
nsIntRect tmp;
nsresult rv = GetBoundsUntyped(tmp);
aRect = mozilla::LayoutDeviceIntRect::FromUnknownRect(tmp);
NS_IMETHOD GetBounds(mozilla::LayoutDeviceIntRect &aRect) = 0;
NS_IMETHOD GetBoundsUntyped(nsIntRect &aRect) {
mozilla::LayoutDeviceIntRect tmp;
nsresult rv = GetBounds(tmp);
aRect = tmp.ToUnknownRect();
return rv;
}
NS_IMETHOD GetBoundsUntyped(nsIntRect &aRect) = 0;
/**
* Get this widget's outside dimensions in global coordinates. This
@ -826,13 +826,13 @@ class nsIWidget : public nsISupports {
* @param aRect On return it holds the x, y, width and height of
* this widget.
*/
NS_IMETHOD GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) {
nsIntRect tmp;
nsresult rv = GetScreenBoundsUntyped(tmp);
aRect = mozilla::LayoutDeviceIntRect::FromUnknownRect(tmp);
NS_IMETHOD GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) = 0;
NS_IMETHOD GetScreenBoundsUntyped(nsIntRect &aRect) {
mozilla::LayoutDeviceIntRect tmp;
nsresult rv = GetScreenBounds(tmp);
aRect = tmp.ToUnknownRect();
return rv;
}
NS_IMETHOD GetScreenBoundsUntyped(nsIntRect &aRect) = 0;
/**
* Similar to GetScreenBounds except that this function will always
@ -860,13 +860,13 @@ class nsIWidget : public nsISupports {
* @param aRect On return it holds the x. y, width and height of
* the client area of this widget.
*/
NS_IMETHOD GetClientBounds(mozilla::LayoutDeviceIntRect &aRect) {
nsIntRect tmp;
nsresult rv = GetClientBoundsUntyped(tmp);
aRect = mozilla::LayoutDeviceIntRect::FromUnknownRect(tmp);
NS_IMETHOD GetClientBounds(mozilla::LayoutDeviceIntRect &aRect) = 0;
NS_IMETHOD GetClientBoundsUntyped(nsIntRect &aRect) {
mozilla::LayoutDeviceIntRect tmp;
nsresult rv = GetClientBounds(tmp);
aRect = tmp.ToUnknownRect();
return rv;
}
NS_IMETHOD GetClientBoundsUntyped(nsIntRect &aRect) = 0;
/**
* Get the non-client area dimensions of the window.

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

@ -1500,14 +1500,15 @@ void find_first_visible_parent(QWindow* aItem, QWindow*& aVisibleItem)
}
NS_IMETHODIMP
nsWindow::GetScreenBoundsUntyped(nsIntRect &aRect)
nsWindow::GetScreenBounds(LayoutDeviceIntRect& aRect)
{
aRect = gfx::IntRect(gfx::IntPoint(0, 0), mBounds.Size());
aRect = LayoutDeviceIntRect(LayoutDeviceIntPoint(0, 0),
LayoutDeviceIntSize::FromUnknownSize(mBounds.Size()));
if (mIsTopLevel) {
QPoint pos = mWidget->position();
aRect.MoveTo(pos.x(), pos.y());
} else {
aRect.MoveTo(WidgetToScreenOffset().ToUnknownPoint());
aRect.MoveTo(WidgetToScreenOffset());
}
LOG(("GetScreenBounds %d %d | %d %d | %d %d\n",
aRect.x, aRect.y,

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

@ -203,7 +203,7 @@ public:
nsIWidget *aWidget,
bool aActivate);
NS_IMETHOD SetSizeMode(nsSizeMode aMode);
NS_IMETHOD GetScreenBoundsUntyped(nsIntRect &aRect);
NS_IMETHOD GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) override;
NS_IMETHOD SetHasTransparentBackground(bool aTransparent);
NS_IMETHOD GetHasTransparentBackground(bool& aTransparent);
NS_IMETHOD HideWindowChrome(bool aShouldHide);

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

@ -61,7 +61,7 @@ public:
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 GetScreenBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) override;
void ReportMoveEvent();
void ReportSizeEvent();
void ReportSizeModeEvent(nsSizeMode aMode);

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

@ -779,7 +779,7 @@ void nsWindow::ReportSizeEvent()
}
NS_IMETHODIMP
nsWindow::GetScreenBoundsUntyped(nsIntRect &aRect)
nsWindow::GetScreenBounds(LayoutDeviceIntRect& aRect)
{
LayoutDeviceIntPoint p = WidgetToScreenOffset();

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

@ -1864,7 +1864,7 @@ NS_METHOD nsWindow::SetFocus(bool aRaise)
// Return the window's full dimensions in screen coordinates.
// If the window has a parent, converts the origin to an offset
// of the parent's screen origin.
NS_METHOD nsWindow::GetBoundsUntyped(nsIntRect &aRect)
NS_METHOD nsWindow::GetBounds(LayoutDeviceIntRect& aRect)
{
if (mWnd) {
RECT r;
@ -1926,21 +1926,21 @@ NS_METHOD nsWindow::GetBoundsUntyped(nsIntRect &aRect)
aRect.x = r.left;
aRect.y = r.top;
} else {
aRect = mBounds;
aRect = LayoutDeviceIntRect::FromUnknownRect(mBounds);
}
return NS_OK;
}
// Get this component dimension
NS_METHOD nsWindow::GetClientBoundsUntyped(nsIntRect &aRect)
NS_METHOD nsWindow::GetClientBounds(LayoutDeviceIntRect& aRect)
{
if (mWnd) {
RECT r;
VERIFY(::GetClientRect(mWnd, &r));
nsIntRect bounds;
GetBoundsUntyped(bounds);
aRect.MoveTo(bounds.TopLeft() + GetClientOffsetUntyped());
LayoutDeviceIntRect bounds;
GetBounds(bounds);
aRect.MoveTo(bounds.TopLeft() + GetClientOffset());
aRect.width = r.right - r.left;
aRect.height = r.bottom - r.top;
@ -1951,7 +1951,7 @@ NS_METHOD nsWindow::GetClientBoundsUntyped(nsIntRect &aRect)
}
// Like GetBounds, but don't offset by the parent
NS_METHOD nsWindow::GetScreenBoundsUntyped(nsIntRect &aRect)
NS_METHOD nsWindow::GetScreenBounds(LayoutDeviceIntRect& aRect)
{
if (mWnd) {
RECT r;
@ -1961,9 +1961,9 @@ NS_METHOD nsWindow::GetScreenBoundsUntyped(nsIntRect &aRect)
aRect.height = r.bottom - r.top;
aRect.x = r.left;
aRect.y = r.top;
} else
aRect = mBounds;
} else {
aRect = LayoutDeviceIntRect::FromUnknownRect(mBounds);
}
return NS_OK;
}

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

@ -116,10 +116,10 @@ public:
NS_IMETHOD Enable(bool aState);
virtual bool IsEnabled() const;
NS_IMETHOD SetFocus(bool aRaise);
NS_IMETHOD GetBoundsUntyped(nsIntRect &aRect);
NS_IMETHOD GetScreenBoundsUntyped(nsIntRect &aRect);
NS_IMETHOD GetBounds(mozilla::LayoutDeviceIntRect &aRect) override;
NS_IMETHOD GetScreenBounds(mozilla::LayoutDeviceIntRect &aRect) override;
NS_IMETHOD GetRestoredBounds(mozilla::LayoutDeviceIntRect &aRect) override;
NS_IMETHOD GetClientBoundsUntyped(nsIntRect &aRect);
NS_IMETHOD GetClientBounds(mozilla::LayoutDeviceIntRect &aRect) override;
virtual nsIntPoint GetClientOffsetUntyped() override;
void SetBackgroundColor(const nscolor &aColor);
NS_IMETHOD SetCursor(imgIContainer* aCursor,