Bug 1149785 - Make nsIWidget::ClientToWindowSize use LayoutDeviceIntSize instead of the unit-less nsIntSize. r=roc

This commit is contained in:
Mats Palmgren 2015-03-31 22:09:03 +00:00
parent a0a4fe694d
commit b9fae4bb36
7 changed files with 18 additions and 12 deletions

View File

@ -687,7 +687,8 @@ void nsContainerFrame::SetSizeConstraints(nsPresContext* aPresContext,
// The sizes are in inner window sizes, so convert them into outer window sizes.
// Use a size of (200, 200) as only the difference between the inner and outer
// size is needed.
nsIntSize windowSize = aWidget->ClientToWindowSize(nsIntSize(200, 200));
LayoutDeviceIntSize windowSize =
aWidget->ClientToWindowSize(LayoutDeviceIntSize(200, 200));
if (constraints.mMinSize.width)
constraints.mMinSize.width += windowSize.width - 200;
if (constraints.mMinSize.height)

View File

@ -272,7 +272,8 @@ public:
NS_IMETHOD SetFocus(bool aState=false) override;
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() override;
virtual nsIntPoint GetClientOffset() override;
virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize) override;
virtual mozilla::LayoutDeviceIntSize
ClientToWindowSize(const mozilla::LayoutDeviceIntSize& aClientSize) override;
virtual void* GetNativeData(uint32_t aDataType) override;

View File

@ -1838,21 +1838,23 @@ nsIntPoint nsCocoaWindow::GetClientOffset()
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(nsIntPoint(0, 0));
}
nsIntSize nsCocoaWindow::ClientToWindowSize(const nsIntSize& aClientSize)
LayoutDeviceIntSize
nsCocoaWindow::ClientToWindowSize(const LayoutDeviceIntSize& aClientSize)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
if (!mWindow)
return nsIntSize(0, 0);
return LayoutDeviceIntSize(0, 0);
CGFloat backingScale = BackingScaleFactor();
nsIntRect r(0, 0, aClientSize.width, aClientSize.height);
NSRect rect = nsCocoaUtils::DevPixelsToCocoaPoints(r, backingScale);
NSRect inflatedRect = [mWindow frameRectForContentRect:rect];
return nsCocoaUtils::CocoaRectToGeckoRectDevPix(inflatedRect, backingScale).Size();
r = nsCocoaUtils::CocoaRectToGeckoRectDevPix(inflatedRect, backingScale);
return LayoutDeviceIntSize(r.width, r.height);
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(nsIntSize(0,0));
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(LayoutDeviceIntSize(0,0));
}
nsMenuBarX* nsCocoaWindow::GetMenuBar()

View File

@ -262,7 +262,8 @@ public:
nsPopupLevel PopupLevel() { return mPopupLevel; }
virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize) override
virtual mozilla::LayoutDeviceIntSize
ClientToWindowSize(const mozilla::LayoutDeviceIntSize& aClientSize) override
{
return aClientSize;
}

View File

@ -22,7 +22,6 @@
#include "mozilla/layers/LayersTypes.h"
#include "mozilla/RefPtr.h"
#include "mozilla/TimeStamp.h"
#include "Units.h"
#include "mozilla/gfx/Point.h"
#include "Units.h"
@ -1689,7 +1688,8 @@ class nsIWidget : public nsISupports {
* which includes the area for the borders and titlebar. This method
* should work even when the window is not yet visible.
*/
virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize) = 0;
virtual mozilla::LayoutDeviceIntSize ClientToWindowSize(
const mozilla::LayoutDeviceIntSize& aClientSize) = 0;
/**
* Dispatches an event to the widget

View File

@ -3069,7 +3069,8 @@ LayoutDeviceIntPoint nsWindow::WidgetToScreenOffset()
return LayoutDeviceIntPoint(point.x, point.y);
}
nsIntSize nsWindow::ClientToWindowSize(const nsIntSize& aClientSize)
LayoutDeviceIntSize
nsWindow::ClientToWindowSize(const LayoutDeviceIntSize& aClientSize)
{
if (mWindowType == eWindowType_popup && !IsPopupWithTitleBar())
return aClientSize;
@ -3082,7 +3083,7 @@ nsIntSize nsWindow::ClientToWindowSize(const nsIntSize& aClientSize)
r.bottom = 200 + aClientSize.height;
::AdjustWindowRectEx(&r, WindowStyle(), false, WindowExStyle());
return nsIntSize(r.right - r.left, r.bottom - r.top);
return LayoutDeviceIntSize(r.right - r.left, r.bottom - r.top);
}
/**************************************************************

View File

@ -139,7 +139,7 @@ public:
NS_IMETHOD SetTitle(const nsAString& aTitle);
NS_IMETHOD SetIcon(const nsAString& aIconSpec);
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset();
virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize);
virtual mozilla::LayoutDeviceIntSize ClientToWindowSize(const mozilla::LayoutDeviceIntSize& aClientSize) override;
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
nsEventStatus& aStatus);
NS_IMETHOD EnableDragDrop(bool aEnable);