Bug 1229237 (part 1) - Make nsIWidget::{Create,CreateChildren}() take a LayoutDeviceIntRect. r=botond.

This commit is contained in:
Nicholas Nethercote 2015-11-16 00:35:18 -08:00
parent a610db35f4
commit 5b298e5d07
34 changed files with 154 additions and 142 deletions

View File

@ -757,7 +757,7 @@ TabChild::Init()
} }
mPuppetWidget->Create( mPuppetWidget->Create(
nullptr, 0, // no parents nullptr, 0, // no parents
gfx::IntRect(gfx::IntPoint(0, 0), gfx::IntSize(0, 0)), LayoutDeviceIntRect(0, 0, 0, 0),
nullptr // HandleWidgetEvent nullptr // HandleWidgetEvent
); );
@ -2838,8 +2838,9 @@ TabChild::CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut)
initData.mUnicode = false; initData.mUnicode = false;
initData.clipChildren = true; initData.clipChildren = true;
initData.clipSiblings = true; initData.clipSiblings = true;
nsresult rv = pluginWidget->Create(aParent, nullptr, gfx::IntRect(gfx::IntPoint(0, 0), nsresult rv = pluginWidget->Create(aParent, nullptr,
nsIntSize(0, 0)), &initData); LayoutDeviceIntRect(0, 0, 0, 0),
&initData);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_WARNING("Creating native plugin widget on the chrome side failed."); NS_WARNING("Creating native plugin widget on the chrome side failed.");
} }

View File

@ -2960,8 +2960,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
initData.mUnicode = false; initData.mUnicode = false;
initData.clipChildren = true; initData.clipChildren = true;
initData.clipSiblings = true; initData.clipSiblings = true;
rv = mWidget->Create(parentWidget.get(), nullptr, nsIntRect(0,0,0,0), rv = mWidget->Create(parentWidget.get(), nullptr,
&initData); LayoutDeviceIntRect(0, 0, 0, 0), &initData);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
mWidget->Destroy(); mWidget->Destroy();
mWidget = nullptr; mWidget = nullptr;

View File

@ -118,8 +118,8 @@ PluginWidgetParent::RecvCreate(nsresult* aResult)
initData.mUnicode = false; initData.mUnicode = false;
initData.clipChildren = true; initData.clipChildren = true;
initData.clipSiblings = true; initData.clipSiblings = true;
*aResult = mWidget->Create(parentWidget.get(), nullptr, nsIntRect(0,0,0,0), *aResult = mWidget->Create(parentWidget.get(), nullptr,
&initData); LayoutDeviceIntRect(0, 0, 0, 0), &initData);
if (NS_FAILED(*aResult)) { if (NS_FAILED(*aResult)) {
KillWidget(); KillWidget();
// This should never fail, abort. // This should never fail, abort.

View File

@ -1176,7 +1176,8 @@ nsWebBrowser::Create()
widgetInit.clipChildren = true; widgetInit.clipChildren = true;
widgetInit.mWindowType = eWindowType_child; widgetInit.mWindowType = eWindowType_child;
nsIntRect bounds(mInitInfo->x, mInitInfo->y, mInitInfo->cx, mInitInfo->cy); LayoutDeviceIntRect bounds(mInitInfo->x, mInitInfo->y,
mInitInfo->cx, mInitInfo->cy);
mInternalWidget->SetWidgetListener(this); mInternalWidget->SetWidgetListener(this);
mInternalWidget->Create(nullptr, mParentNativeWindow, bounds, &widgetInit); mInternalWidget->Create(nullptr, mParentNativeWindow, bounds, &widgetInit);

View File

@ -55,10 +55,10 @@ public:
return nullptr; return nullptr;
} }
NS_IMETHOD Create(nsIWidget *aParent, NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const IntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData = nullptr) override { return NS_OK; } nsWidgetInitData* aInitData = nullptr) override { return NS_OK; }
NS_IMETHOD Show(bool aState) override { return NS_OK; } NS_IMETHOD Show(bool aState) override { return NS_OK; }
virtual bool IsVisible() const override { return true; } virtual bool IsVisible() const override { return true; }
NS_IMETHOD ConstrainPosition(bool aAllowSlop, NS_IMETHOD ConstrainPosition(bool aAllowSlop,

View File

@ -470,7 +470,7 @@ nsXULPopupManager::PopupMoved(nsIFrame* aFrame, nsIntPoint aPnt)
// Don't do anything if the popup is already at the specified location. This // Don't do anything if the popup is already at the specified location. This
// prevents recursive calls when a popup is positioned. // prevents recursive calls when a popup is positioned.
nsIntRect curDevSize = view->CalcWidgetBounds(eWindowType_popup); LayoutDeviceIntRect curDevSize = view->CalcWidgetBounds(eWindowType_popup);
nsIWidget* widget = menuPopupFrame->GetWidget(); nsIWidget* widget = menuPopupFrame->GetWidget();
if (curDevSize.x == aPnt.x && curDevSize.y == aPnt.y && if (curDevSize.x == aPnt.x && curDevSize.y == aPnt.y &&
(!widget || widget->GetClientOffset() == (!widget || widget->GetClientOffset() ==
@ -504,7 +504,7 @@ nsXULPopupManager::PopupResized(nsIFrame* aFrame, LayoutDeviceIntSize aSize)
if (!view) if (!view)
return; return;
nsIntRect curDevSize = view->CalcWidgetBounds(eWindowType_popup); LayoutDeviceIntRect curDevSize = view->CalcWidgetBounds(eWindowType_popup);
// If the size is what we think it is, we have nothing to do. // If the size is what we think it is, we have nothing to do.
if (curDevSize.width == aSize.width && curDevSize.height == aSize.height) if (curDevSize.width == aSize.width && curDevSize.height == aSize.height)
return; return;

View File

@ -214,7 +214,7 @@ bool nsView::IsEffectivelyVisible()
return true; return true;
} }
nsIntRect nsView::CalcWidgetBounds(nsWindowType aType) LayoutDeviceIntRect nsView::CalcWidgetBounds(nsWindowType aType)
{ {
int32_t p2a = mViewManager->AppUnitsPerDevPixel(); int32_t p2a = mViewManager->AppUnitsPerDevPixel();
@ -238,7 +238,8 @@ nsIntRect nsView::CalcWidgetBounds(nsWindowType aType)
} }
// Compute widget bounds in device pixels // Compute widget bounds in device pixels
nsIntRect newBounds = viewBounds.ToNearestPixels(p2a); LayoutDeviceIntRect newBounds =
LayoutDeviceIntRect::FromUnknownRect(viewBounds.ToNearestPixels(p2a));
#if defined(XP_MACOSX) || (MOZ_WIDGET_GTK == 3) #if defined(XP_MACOSX) || (MOZ_WIDGET_GTK == 3)
// cocoa and GTK round widget coordinates to the nearest global "display // cocoa and GTK round widget coordinates to the nearest global "display
@ -248,7 +249,7 @@ nsIntRect nsView::CalcWidgetBounds(nsWindowType aType)
uint32_t round; uint32_t round;
if (aType == eWindowType_popup && widget && if (aType == eWindowType_popup && widget &&
((round = widget->RoundsWidgetCoordinatesTo()) > 1)) { ((round = widget->RoundsWidgetCoordinatesTo()) > 1)) {
nsIntSize pixelRoundedSize = newBounds.Size(); LayoutDeviceIntSize pixelRoundedSize = newBounds.Size();
// round the top left and bottom right to the nearest round pixel // round the top left and bottom right to the nearest round pixel
newBounds.x = NSToIntRoundUp(NSAppUnitsToDoublePixels(viewBounds.x, p2a) / round) * round; newBounds.x = NSToIntRoundUp(NSAppUnitsToDoublePixels(viewBounds.x, p2a) / round) * round;
newBounds.y = NSToIntRoundUp(NSAppUnitsToDoublePixels(viewBounds.y, p2a) / round) * round; newBounds.y = NSToIntRoundUp(NSAppUnitsToDoublePixels(viewBounds.y, p2a) / round) * round;
@ -312,7 +313,7 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly,
if (invisiblePopup) { if (invisiblePopup) {
// We're going to hit the early exit below, avoid calling CalcWidgetBounds. // We're going to hit the early exit below, avoid calling CalcWidgetBounds.
} else { } else {
newBounds = LayoutDeviceIntRect::FromUnknownRect(CalcWidgetBounds(type)); newBounds = CalcWidgetBounds(type);
} }
bool curVisibility = widget->IsVisible(); bool curVisibility = widget->IsVisible();
@ -575,7 +576,7 @@ nsresult nsView::CreateWidget(nsWidgetInitData *aWidgetInitData,
(!initDataPassedIn && GetParent() && (!initDataPassedIn && GetParent() &&
GetParent()->GetViewManager() != mViewManager); GetParent()->GetViewManager() != mViewManager);
nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType); LayoutDeviceIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
nsIWidget* parentWidget = nsIWidget* parentWidget =
GetParent() ? GetParent()->GetNearestWidget(nullptr) : nullptr; GetParent() ? GetParent()->GetNearestWidget(nullptr) : nullptr;
@ -610,7 +611,7 @@ nsresult nsView::CreateWidgetForParent(nsIWidget* aParentWidget,
DefaultWidgetInitData defaultInitData; DefaultWidgetInitData defaultInitData;
aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData; aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData;
nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType); LayoutDeviceIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
mWindow = aParentWidget->CreateChild(trect, aWidgetInitData); mWindow = aParentWidget->CreateChild(trect, aWidgetInitData);
if (!mWindow) { if (!mWindow) {
@ -632,7 +633,7 @@ nsresult nsView::CreateWidgetForPopup(nsWidgetInitData *aWidgetInitData,
MOZ_ASSERT(aWidgetInitData->mWindowType == eWindowType_popup, MOZ_ASSERT(aWidgetInitData->mWindowType == eWindowType_popup,
"Use one of the other CreateWidget methods"); "Use one of the other CreateWidget methods");
nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType); LayoutDeviceIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
// XXX/cjones: having these two separate creation cases seems ... um // XXX/cjones: having these two separate creation cases seems ... um
// ... unnecessary, but it's the way the old code did it. Please // ... unnecessary, but it's the way the old code did it. Please

View File

@ -14,6 +14,7 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsWidgetInitData.h" // for nsWindowType #include "nsWidgetInitData.h" // for nsWindowType
#include "nsIWidgetListener.h" #include "nsIWidgetListener.h"
#include "Units.h"
#include "mozilla/EventForwards.h" #include "mozilla/EventForwards.h"
class nsViewManager; class nsViewManager;
@ -57,6 +58,8 @@ class nsView final : public nsIWidgetListener
public: public:
friend class nsViewManager; friend class nsViewManager;
typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
/** /**
@ -326,7 +329,7 @@ public:
*/ */
bool IsRoot() const; bool IsRoot() const;
nsIntRect CalcWidgetBounds(nsWindowType aType); LayoutDeviceIntRect CalcWidgetBounds(nsWindowType aType);
// This is an app unit offset to add when converting view coordinates to // This is an app unit offset to add when converting view coordinates to
// widget coordinates. It is the offset in view coordinates from widget // widget coordinates. It is the offset in view coordinates from widget

View File

@ -47,9 +47,9 @@ PluginWidgetProxy::~PluginWidgetProxy()
} }
NS_IMETHODIMP NS_IMETHODIMP
PluginWidgetProxy::Create(nsIWidget* aParent, PluginWidgetProxy::Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect& aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData* aInitData) nsWidgetInitData* aInitData)
{ {
ENSURE_CHANNEL; ENSURE_CHANNEL;
@ -64,7 +64,7 @@ PluginWidgetProxy::Create(nsIWidget* aParent,
BaseCreate(aParent, aRect, aInitData); BaseCreate(aParent, aRect, aInitData);
mBounds = aRect; mBounds = aRect.ToUnknownRect();
mEnabled = true; mEnabled = true;
mVisible = true; mVisible = true;

View File

@ -35,7 +35,7 @@ public:
// nsIWidget // nsIWidget
NS_IMETHOD Create(nsIWidget* aParent, nsNativeWidget aNativeParent, NS_IMETHOD Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
const nsIntRect& aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData* aInitData = nullptr) override; nsWidgetInitData* aInitData = nullptr) override;
NS_IMETHOD Destroy() override; NS_IMETHOD Destroy() override;
NS_IMETHOD SetFocus(bool aRaise = false) override; NS_IMETHOD SetFocus(bool aRaise = false) override;

View File

@ -98,16 +98,16 @@ PuppetWidget::~PuppetWidget()
} }
NS_IMETHODIMP NS_IMETHODIMP
PuppetWidget::Create(nsIWidget *aParent, PuppetWidget::Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) nsWidgetInitData* aInitData)
{ {
MOZ_ASSERT(!aNativeParent, "got a non-Puppet native parent"); MOZ_ASSERT(!aNativeParent, "got a non-Puppet native parent");
BaseCreate(nullptr, aRect, aInitData); BaseCreate(nullptr, aRect, aInitData);
mBounds = aRect; mBounds = aRect.ToUnknownRect();
mEnabled = true; mEnabled = true;
mVisible = true; mVisible = true;
@ -146,9 +146,9 @@ PuppetWidget::InitIMEState()
} }
already_AddRefed<nsIWidget> already_AddRefed<nsIWidget>
PuppetWidget::CreateChild(const nsIntRect &aRect, PuppetWidget::CreateChild(const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData, nsWidgetInitData* aInitData,
bool aForceUseIWidgetParent) bool aForceUseIWidgetParent)
{ {
bool isPopup = IsPopup(aInitData); bool isPopup = IsPopup(aInitData);
nsCOMPtr<nsIWidget> widget = nsIWidget::CreatePuppetWidget(mTabChild); nsCOMPtr<nsIWidget> widget = nsIWidget::CreatePuppetWidget(mTabChild);

View File

@ -53,17 +53,17 @@ protected:
public: public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD Create(nsIWidget* aParent, NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect& aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData* aInitData = nullptr) override; nsWidgetInitData* aInitData = nullptr) override;
void InitIMEState(); void InitIMEState();
virtual already_AddRefed<nsIWidget> virtual already_AddRefed<nsIWidget>
CreateChild(const nsIntRect &aRect, CreateChild(const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData = nullptr, nsWidgetInitData* aInitData = nullptr,
bool aForceUseIWidgetParent = false) override; bool aForceUseIWidgetParent = false) override;
NS_IMETHOD Destroy() override; NS_IMETHOD Destroy() override;

View File

@ -525,10 +525,10 @@ nsWindow::IsTopLevel()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::Create(nsIWidget *aParent, nsWindow::Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) nsWidgetInitData* aInitData)
{ {
ALOG("nsWindow[%p]::Create %p [%d %d %d %d]", (void*)this, (void*)aParent, aRect.x, aRect.y, aRect.width, aRect.height); ALOG("nsWindow[%p]::Create %p [%d %d %d %d]", (void*)this, (void*)aParent, aRect.x, aRect.y, aRect.width, aRect.height);
nsWindow *parent = (nsWindow*) aParent; nsWindow *parent = (nsWindow*) aParent;
@ -540,7 +540,7 @@ nsWindow::Create(nsIWidget *aParent,
} }
} }
mBounds = aRect; mBounds = aRect.ToUnknownRect();
// for toplevel windows, bounds are fixed to full screen size // for toplevel windows, bounds are fixed to full screen size
if (!parent) { if (!parent) {
@ -550,7 +550,8 @@ nsWindow::Create(nsIWidget *aParent,
mBounds.height = gAndroidBounds.height; mBounds.height = gAndroidBounds.height;
} }
BaseCreate(nullptr, mBounds, aInitData); BaseCreate(nullptr, LayoutDeviceIntRect::FromUnknownRect(mBounds),
aInitData);
NS_ASSERTION(IsTopLevel() || parent, "non top level windowdoesn't have a parent!"); NS_ASSERTION(IsTopLevel() || parent, "non top level windowdoesn't have a parent!");

View File

@ -70,10 +70,10 @@ public:
// nsIWidget // nsIWidget
// //
NS_IMETHOD Create(nsIWidget *aParent, NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) override; nsWidgetInitData* aInitData) override;
NS_IMETHOD Destroy(void) override; NS_IMETHOD Destroy(void) override;
NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&) override; NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&) override;
NS_IMETHOD SetParent(nsIWidget* aNewParent) override; NS_IMETHOD SetParent(nsIWidget* aNewParent) override;

View File

@ -354,10 +354,10 @@ public:
nsChildView(); nsChildView();
// nsIWidget interface // nsIWidget interface
NS_IMETHOD Create(nsIWidget *aParent, NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData = nullptr) override; nsWidgetInitData* aInitData = nullptr) override;
NS_IMETHOD Destroy() override; NS_IMETHOD Destroy() override;

View File

@ -465,10 +465,10 @@ nsChildView::ReleaseTitlebarCGContext()
} }
} }
nsresult nsChildView::Create(nsIWidget *aParent, nsresult nsChildView::Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) nsWidgetInitData* aInitData)
{ {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -493,7 +493,7 @@ nsresult nsChildView::Create(nsIWidget *aParent,
gChildViewMethodsSwizzled = true; gChildViewMethodsSwizzled = true;
} }
mBounds = aRect; mBounds = aRect.ToUnknownRect();
// Ensure that the toolkit is created. // Ensure that the toolkit is created.
nsToolkit::GetToolkit(); nsToolkit::GetToolkit();

View File

@ -246,7 +246,6 @@ typedef struct _nsCocoaWindowList {
class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa
{ {
private: private:
typedef nsBaseWidget Inherited; typedef nsBaseWidget Inherited;
public: public:
@ -255,11 +254,11 @@ public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSPIWIDGETCOCOA NS_DECL_NSPIWIDGETCOCOA
NS_IMETHOD Create(nsIWidget* aParent, NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData = nullptr) override; nsWidgetInitData* aInitData = nullptr) override;
NS_IMETHOD Destroy() override; NS_IMETHOD Destroy() override;
@ -393,7 +392,7 @@ protected:
nsresult CreateNativeWindow(const NSRect &aRect, nsresult CreateNativeWindow(const NSRect &aRect,
nsBorderStyle aBorderStyle, nsBorderStyle aBorderStyle,
bool aRectIsFrameRect); bool aRectIsFrameRect);
nsresult CreatePopupContentView(const nsIntRect &aRect); nsresult CreatePopupContentView(const LayoutDeviceIntRect &aRect);
void DestroyNativeWindow(); void DestroyNativeWindow();
void AdjustWindowShadow(); void AdjustWindowShadow();
void SetWindowBackgroundBlur(); void SetWindowBackgroundBlur();

View File

@ -182,13 +182,16 @@ nsCocoaWindow::~nsCocoaWindow()
// Find the screen that overlaps aRect the most, // Find the screen that overlaps aRect the most,
// if none are found default to the mainScreen. // if none are found default to the mainScreen.
static NSScreen *FindTargetScreenForRect(const nsIntRect& aRect) static NSScreen*
FindTargetScreenForRect(const LayoutDeviceIntRect& aRect)
{ {
NSScreen *targetScreen = [NSScreen mainScreen]; NSScreen *targetScreen = [NSScreen mainScreen];
NSEnumerator *screenEnum = [[NSScreen screens] objectEnumerator]; NSEnumerator *screenEnum = [[NSScreen screens] objectEnumerator];
int largestIntersectArea = 0; int largestIntersectArea = 0;
while (NSScreen *screen = [screenEnum nextObject]) { while (NSScreen *screen = [screenEnum nextObject]) {
nsIntRect screenRect(nsCocoaUtils::CocoaRectToGeckoRect([screen visibleFrame])); LayoutDeviceIntRect screenRect =
LayoutDeviceIntRect::FromUnknownRect(
nsCocoaUtils::CocoaRectToGeckoRect([screen visibleFrame]));
screenRect = screenRect.Intersect(aRect); screenRect = screenRect.Intersect(aRect);
int area = screenRect.width * screenRect.height; int area = screenRect.width * screenRect.height;
if (area > largestIntersectArea) { if (area > largestIntersectArea) {
@ -202,7 +205,8 @@ static NSScreen *FindTargetScreenForRect(const nsIntRect& aRect)
// fits the rect to the screen that contains the largest area of it, // fits the rect to the screen that contains the largest area of it,
// or to aScreen if a screen is passed in // or to aScreen if a screen is passed in
// NB: this operates with aRect in global display pixels // NB: this operates with aRect in global display pixels
static void FitRectToVisibleAreaForScreen(nsIntRect &aRect, NSScreen *aScreen) static void
FitRectToVisibleAreaForScreen(LayoutDeviceIntRect& aRect, NSScreen* aScreen)
{ {
if (!aScreen) { if (!aScreen) {
aScreen = FindTargetScreenForRect(aRect); aScreen = FindTargetScreenForRect(aRect);
@ -246,10 +250,10 @@ static bool UseNativePopupWindows()
} }
// aRect here is specified in global display pixels // aRect here is specified in global display pixels
nsresult nsCocoaWindow::Create(nsIWidget *aParent, nsresult nsCocoaWindow::Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) nsWidgetInitData* aInitData)
{ {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -257,7 +261,7 @@ nsresult nsCocoaWindow::Create(nsIWidget *aParent,
// we have to provide an autorelease pool (see bug 559075). // we have to provide an autorelease pool (see bug 559075).
nsAutoreleasePool localPool; nsAutoreleasePool localPool;
nsIntRect newBounds = aRect; LayoutDeviceIntRect newBounds = aRect;
FitRectToVisibleAreaForScreen(newBounds, nullptr); FitRectToVisibleAreaForScreen(newBounds, nullptr);
// Set defaults which can be overriden from aInitData in BaseCreate // Set defaults which can be overriden from aInitData in BaseCreate
@ -281,7 +285,7 @@ nsresult nsCocoaWindow::Create(nsIWidget *aParent,
return NS_OK; return NS_OK;
nsresult rv = nsresult rv =
CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(newBounds), CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(newBounds.ToUnknownRect()),
mBorderStyle, false); mBorderStyle, false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -481,7 +485,8 @@ nsresult nsCocoaWindow::CreateNativeWindow(const NSRect &aRect,
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
} }
NS_IMETHODIMP nsCocoaWindow::CreatePopupContentView(const nsIntRect &aRect) NS_IMETHODIMP
nsCocoaWindow::CreatePopupContentView(const LayoutDeviceIntRect &aRect)
{ {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -1520,16 +1525,17 @@ nsresult nsCocoaWindow::DoResize(double aX, double aY,
int32_t height = NSToIntRound(aHeight * scale); int32_t height = NSToIntRound(aHeight * scale);
ConstrainSize(&width, &height); ConstrainSize(&width, &height);
nsIntRect newBounds(NSToIntRound(aX), NSToIntRound(aY), LayoutDeviceIntRect newBounds(NSToIntRound(aX), NSToIntRound(aY),
NSToIntRound(width / scale), NSToIntRound(width / scale),
NSToIntRound(height / scale)); NSToIntRound(height / scale));
// constrain to the screen that contains the largest area of the new rect // constrain to the screen that contains the largest area of the new rect
FitRectToVisibleAreaForScreen(newBounds, aConstrainToCurrentScreen ? FitRectToVisibleAreaForScreen(newBounds, aConstrainToCurrentScreen ?
[mWindow screen] : nullptr); [mWindow screen] : nullptr);
// convert requested bounds into Cocoa coordinate system // convert requested bounds into Cocoa coordinate system
NSRect newFrame = nsCocoaUtils::GeckoRectToCocoaRect(newBounds); NSRect newFrame =
nsCocoaUtils::GeckoRectToCocoaRect(newBounds.ToUnknownRect());
NSRect frame = [mWindow frame]; NSRect frame = [mWindow frame];
BOOL isMoving = newFrame.origin.x != frame.origin.x || BOOL isMoving = newFrame.origin.x != frame.origin.x ||
@ -1665,7 +1671,8 @@ GetBackingScaleFactor(NSWindow* aWindow)
// Then identify the screen it belongs to, and return its scale factor. // Then identify the screen it belongs to, and return its scale factor.
NSScreen *screen = NSScreen *screen =
FindTargetScreenForRect(nsCocoaUtils::CocoaRectToGeckoRect(frame)); FindTargetScreenForRect(
LayoutDeviceIntRect::FromUnknownRect(nsCocoaUtils::CocoaRectToGeckoRect(frame)));
return nsCocoaUtils::GetBackingScaleFactor(screen); return nsCocoaUtils::GetBackingScaleFactor(screen);
} }

View File

@ -481,7 +481,7 @@ nsScreenGonk::EnableMirroring()
nsWidgetInitData initData; nsWidgetInitData initData;
initData.mScreenId = mId; initData.mScreenId = mId;
RefPtr<nsWindow> window = new nsWindow(); RefPtr<nsWindow> window = new nsWindow();
window->Create(nullptr, nullptr, mNaturalBounds.ToUnknownRect(), &initData); window->Create(nullptr, nullptr, mNaturalBounds, &initData);
MOZ_ASSERT(static_cast<nsWindow*>(window)->GetScreen() == this); MOZ_ASSERT(static_cast<nsWindow*>(window)->GetScreen() == this);
// Update mMirroringWidget on compositor thread // Update mMirroringWidget on compositor thread

View File

@ -330,10 +330,10 @@ nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::Create(nsIWidget *aParent, nsWindow::Create(nsIWidget* aParent,
void *aNativeParent, void* aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) nsWidgetInitData* aInitData)
{ {
BaseCreate(aParent, aRect, aInitData); BaseCreate(aParent, aRect, aInitData);
@ -347,7 +347,7 @@ nsWindow::Create(nsIWidget *aParent,
mScreen = static_cast<nsScreenGonk*>(screen.get()); mScreen = static_cast<nsScreenGonk*>(screen.get());
mBounds = aRect; mBounds = aRect.ToUnknownRect();
mParent = (nsWindow *)aParent; mParent = (nsWindow *)aParent;
mVisible = false; mVisible = false;

View File

@ -46,10 +46,10 @@ public:
static nsEventStatus DispatchKeyInput(mozilla::WidgetKeyboardEvent& aEvent); static nsEventStatus DispatchKeyInput(mozilla::WidgetKeyboardEvent& aEvent);
static void DispatchTouchInput(mozilla::MultiTouchInput& aInput); static void DispatchTouchInput(mozilla::MultiTouchInput& aInput);
NS_IMETHOD Create(nsIWidget *aParent, NS_IMETHOD Create(nsIWidget* aParent,
void *aNativeParent, void* aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData); nsWidgetInitData* aInitData);
NS_IMETHOD Destroy(void); NS_IMETHOD Destroy(void);
NS_IMETHOD Show(bool aState); NS_IMETHOD Show(bool aState);

View File

@ -3498,10 +3498,10 @@ CreateGdkWindow(GdkWindow *parent, GtkWidget *widget)
} }
nsresult nsresult
nsWindow::Create(nsIWidget *aParent, nsWindow::Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) nsWidgetInitData* aInitData)
{ {
// only set the base parent if we're going to be a dialog or a // only set the base parent if we're going to be a dialog or a
// toplevel // toplevel
@ -3531,7 +3531,7 @@ nsWindow::Create(nsIWidget *aParent,
CommonCreate(aParent, listenForResizes); CommonCreate(aParent, listenForResizes);
// save our bounds // save our bounds
mBounds = aRect; mBounds = aRect.ToUnknownRect();
ConstrainSize(&mBounds.width, &mBounds.height); ConstrainSize(&mBounds.width, &mBounds.height);
// figure out our parent window // figure out our parent window

View File

@ -95,10 +95,10 @@ public:
bool AreBoundsSane(void); bool AreBoundsSane(void);
// nsIWidget // nsIWidget
NS_IMETHOD Create(nsIWidget *aParent, NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) override; nsWidgetInitData* aInitData) override;
NS_IMETHOD Destroy(void) override; NS_IMETHOD Destroy(void) override;
virtual nsIWidget *GetParent() override; virtual nsIWidget *GetParent() override;
virtual float GetDPI() override; virtual float GetDPI() override;

View File

@ -308,9 +308,9 @@ nsBaseWidget::~nsBaseWidget()
// Basic create. // Basic create.
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
void nsBaseWidget::BaseCreate(nsIWidget *aParent, void nsBaseWidget::BaseCreate(nsIWidget* aParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) nsWidgetInitData* aInitData)
{ {
static bool gDisableNativeThemeCached = false; static bool gDisableNativeThemeCached = false;
if (!gDisableNativeThemeCached) { if (!gDisableNativeThemeCached) {
@ -355,9 +355,9 @@ void nsBaseWidget::SetWidgetListener(nsIWidgetListener* aWidgetListener)
} }
already_AddRefed<nsIWidget> already_AddRefed<nsIWidget>
nsBaseWidget::CreateChild(const nsIntRect &aRect, nsBaseWidget::CreateChild(const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData, nsWidgetInitData* aInitData,
bool aForceUseIWidgetParent) bool aForceUseIWidgetParent)
{ {
nsIWidget* parent = this; nsIWidget* parent = this;
nsNativeWidget nativeParent = nullptr; nsNativeWidget nativeParent = nullptr;

View File

@ -231,9 +231,9 @@ public:
double& aOverriddenDeltaX, double& aOverriddenDeltaX,
double& aOverriddenDeltaY) override; double& aOverriddenDeltaY) override;
virtual already_AddRefed<nsIWidget> virtual already_AddRefed<nsIWidget>
CreateChild(const nsIntRect &aRect, CreateChild(const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData = nullptr, nsWidgetInitData* aInitData = nullptr,
bool aForceUseIWidgetParent = false) override; bool aForceUseIWidgetParent = false) override;
NS_IMETHOD AttachViewToTopLevel(bool aUseAttachedEvents) override; NS_IMETHOD AttachViewToTopLevel(bool aUseAttachedEvents) override;
virtual nsIWidgetListener* GetAttachedWidgetListener() override; virtual nsIWidgetListener* GetAttachedWidgetListener() override;
virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) override; virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) override;
@ -350,8 +350,8 @@ protected:
nsIFile **aResult); nsIFile **aResult);
virtual void OnDestroy(); virtual void OnDestroy();
void BaseCreate(nsIWidget *aParent, void BaseCreate(nsIWidget *aParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData); nsWidgetInitData* aInitData);
virtual void ConfigureAPZCTreeManager(); virtual void ConfigureAPZCTreeManager();
virtual void ConfigureAPZControllerThread(); virtual void ConfigureAPZControllerThread();

View File

@ -395,10 +395,10 @@ class nsIWidget : public nsISupports {
* @param aInitData data that is used for widget initialization * @param aInitData data that is used for widget initialization
* *
*/ */
NS_IMETHOD Create(nsIWidget *aParent, NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData = nullptr) = 0; nsWidgetInitData* aInitData = nullptr) = 0;
/** /**
* Allocate, initialize, and return a widget that is a child of * Allocate, initialize, and return a widget that is a child of
@ -417,9 +417,9 @@ class nsIWidget : public nsISupports {
* understood code, and shouldn't be used in new code. * understood code, and shouldn't be used in new code.
*/ */
virtual already_AddRefed<nsIWidget> virtual already_AddRefed<nsIWidget>
CreateChild(const nsIntRect &aRect, CreateChild(const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData = nullptr, nsWidgetInitData* aInitData = nullptr,
bool aForceUseIWidgetParent = false) = 0; bool aForceUseIWidgetParent = false) = 0;
/** /**
* Attach to a top level widget. * Attach to a top level widget.

View File

@ -133,10 +133,10 @@ nsWindow::~nsWindow()
} }
nsresult nsresult
nsWindow::Create(nsIWidget *aParent, nsWindow::Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) nsWidgetInitData* aInitData)
{ {
// only set the base parent if we're not going to be a dialog or a // only set the base parent if we're not going to be a dialog or a
// toplevel // toplevel
@ -151,7 +151,7 @@ nsWindow::Create(nsIWidget *aParent,
mParent = (nsWindow *)aParent; mParent = (nsWindow *)aParent;
// save our bounds // save our bounds
mBounds = aRect; mBounds = aRect.ToUnknownRect();
// find native parent // find native parent
MozQWidget *parent = nullptr; MozQWidget *parent = nullptr;

View File

@ -84,10 +84,10 @@ public:
// //
// nsIWidget // nsIWidget
// //
NS_IMETHOD Create(nsIWidget *aParent, NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData); nsWidgetInitData* aInitData);
NS_IMETHOD Destroy(void); NS_IMETHOD Destroy(void);
NS_IMETHOD Show(bool aState); NS_IMETHOD Show(bool aState);

View File

@ -30,10 +30,10 @@ public:
// nsIWidget // nsIWidget
// //
NS_IMETHOD Create(nsIWidget *aParent, NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData = nullptr) override; nsWidgetInitData* aInitData = nullptr) override;
NS_IMETHOD Destroy() override; NS_IMETHOD Destroy() override;
NS_IMETHOD Show(bool aState) override; NS_IMETHOD Show(bool aState) override;
NS_IMETHOD Enable(bool aState) override { NS_IMETHOD Enable(bool aState) override {

View File

@ -466,10 +466,10 @@ nsWindow::IsTopLevel()
// //
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::Create(nsIWidget *aParent, nsWindow::Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) nsWidgetInitData* aInitData)
{ {
ALOG("nsWindow[%p]::Create %p/%p [%d %d %d %d]", (void*)this, (void*)aParent, (void*)aNativeParent, aRect.x, aRect.y, aRect.width, aRect.height); ALOG("nsWindow[%p]::Create %p/%p [%d %d %d %d]", (void*)this, (void*)aParent, (void*)aNativeParent, aRect.x, aRect.y, aRect.width, aRect.height);
nsWindow* parent = (nsWindow*) aParent; nsWindow* parent = (nsWindow*) aParent;
@ -484,17 +484,15 @@ nsWindow::Create(nsIWidget *aParent,
if (parent == nullptr) { if (parent == nullptr) {
if (nsAppShell::gWindow == nil) { if (nsAppShell::gWindow == nil) {
mBounds = UIKitScreenManager::GetBounds(); mBounds = UIKitScreenManager::GetBounds();
} } else {
else {
CGRect cgRect = [nsAppShell::gWindow bounds]; CGRect cgRect = [nsAppShell::gWindow bounds];
mBounds.x = cgRect.origin.x; mBounds.x = cgRect.origin.x;
mBounds.y = cgRect.origin.y; mBounds.y = cgRect.origin.y;
mBounds.width = cgRect.size.width; mBounds.width = cgRect.size.width;
mBounds.height = cgRect.size.height; mBounds.height = cgRect.size.height;
} }
} } else {
else { mBounds = aRect.ToUnknownRect();
mBounds = aRect;
} }
ALOG("nsWindow[%p]::Create bounds: %d %d %d %d", (void*)this, ALOG("nsWindow[%p]::Create bounds: %d %d %d %d", (void*)this,
@ -504,7 +502,9 @@ nsWindow::Create(nsIWidget *aParent,
mWindowType = eWindowType_toplevel; mWindowType = eWindowType_toplevel;
mBorderStyle = eBorderStyle_default; mBorderStyle = eBorderStyle_default;
Inherited::BaseCreate(aParent, mBounds, aInitData); Inherited::BaseCreate(aParent,
LayoutDeviceIntRect::FromUnknownRect(mBounds),
aInitData);
NS_ASSERTION(IsTopLevel() || parent, "non top level window doesn't have a parent!"); NS_ASSERTION(IsTopLevel() || parent, "non top level window doesn't have a parent!");

View File

@ -490,10 +490,10 @@ ShouldCacheTitleBarInfo(nsWindowType aWindowType, nsBorderStyle aBorderStyle)
// Create the proper widget // Create the proper widget
nsresult nsresult
nsWindow::Create(nsIWidget *aParent, nsWindow::Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData) nsWidgetInitData* aInitData)
{ {
nsWidgetInitData defaultInitData; nsWidgetInitData defaultInitData;
if (!aInitData) if (!aInitData)
@ -507,7 +507,7 @@ nsWindow::Create(nsIWidget *aParent,
nullptr : aParent; nullptr : aParent;
mIsTopWidgetWindow = (nullptr == baseParent); mIsTopWidgetWindow = (nullptr == baseParent);
mBounds = aRect; mBounds = aRect.ToUnknownRect();
// Ensure that the toolkit is created. // Ensure that the toolkit is created.
nsToolkit::GetToolkit(); nsToolkit::GetToolkit();

View File

@ -92,10 +92,10 @@ public:
using nsWindowBase::DispatchPluginEvent; using nsWindowBase::DispatchPluginEvent;
// nsIWidget interface // nsIWidget interface
NS_IMETHOD Create(nsIWidget *aParent, NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
const nsIntRect &aRect, const LayoutDeviceIntRect& aRect,
nsWidgetInitData *aInitData = nullptr); nsWidgetInitData* aInitData = nullptr);
NS_IMETHOD Destroy(); NS_IMETHOD Destroy();
NS_IMETHOD SetParent(nsIWidget *aNewParent); NS_IMETHOD SetParent(nsIWidget *aNewParent);
virtual nsIWidget* GetParent(void); virtual nsIWidget* GetParent(void);

View File

@ -474,8 +474,7 @@ nsAppShellService::CreateWindowlessBrowser(bool aIsChrome, nsIWebNavigation **aR
NS_ERROR("Couldn't create instance of PuppetWidget"); NS_ERROR("Couldn't create instance of PuppetWidget");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
widget->Create(nullptr, 0, gfx::IntRect(gfx::IntPoint(0, 0), gfx::IntSize(0, 0)), widget->Create(nullptr, 0, LayoutDeviceIntRect(0, 0, 0, 0), nullptr);
nullptr);
nsCOMPtr<nsIBaseWindow> window = do_QueryInterface(navigation); nsCOMPtr<nsIBaseWindow> window = do_QueryInterface(navigation);
window->InitWindow(0, widget, 0, 0, 0, 0); window->InitWindow(0, widget, 0, 0, 0, 0);
window->Create(); window->Create();

View File

@ -173,7 +173,7 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
mWindow->SetWidgetListener(this); mWindow->SetWidgetListener(this);
mWindow->Create((nsIWidget *)parentWidget, // Parent nsIWidget mWindow->Create((nsIWidget *)parentWidget, // Parent nsIWidget
nullptr, // Native parent widget nullptr, // Native parent widget
r.ToUnknownRect(), // Widget dimensions r, // Widget dimensions
&widgetInitData); // Widget initialization data &widgetInitData); // Widget initialization data
mWindow->GetClientBounds(r); mWindow->GetClientBounds(r);
// Match the default background color of content. Important on windows // Match the default background color of content. Important on windows