From 5b298e5d070b52cafec5897ad641370788fc9604 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 16 Nov 2015 00:35:18 -0800 Subject: [PATCH] Bug 1229237 (part 1) - Make nsIWidget::{Create,CreateChildren}() take a LayoutDeviceIntRect. r=botond. --- dom/ipc/TabChild.cpp | 7 +++-- dom/plugins/base/nsPluginInstanceOwner.cpp | 4 +-- dom/plugins/ipc/PluginWidgetParent.cpp | 4 +-- embedding/browser/nsWebBrowser.cpp | 3 +- gfx/tests/gtest/TestCompositor.cpp | 6 ++-- layout/xul/nsXULPopupManager.cpp | 4 +-- view/nsView.cpp | 15 +++++----- view/nsView.h | 5 +++- widget/PluginWidgetProxy.cpp | 8 ++--- widget/PluginWidgetProxy.h | 2 +- widget/PuppetWidget.cpp | 16 +++++----- widget/PuppetWidget.h | 12 ++++---- widget/android/nsWindow.cpp | 11 +++---- widget/android/nsWindow.h | 6 ++-- widget/cocoa/nsChildView.h | 6 ++-- widget/cocoa/nsChildView.mm | 8 ++--- widget/cocoa/nsCocoaWindow.h | 9 +++--- widget/cocoa/nsCocoaWindow.mm | 35 +++++++++++++--------- widget/gonk/nsScreenManagerGonk.cpp | 2 +- widget/gonk/nsWindow.cpp | 10 +++---- widget/gonk/nsWindow.h | 8 ++--- widget/gtk/nsWindow.cpp | 10 +++---- widget/gtk/nsWindow.h | 8 ++--- widget/nsBaseWidget.cpp | 12 ++++---- widget/nsBaseWidget.h | 10 +++---- widget/nsIWidget.h | 14 ++++----- widget/qt/nsWindow.cpp | 10 +++---- widget/qt/nsWindow.h | 8 ++--- widget/uikit/nsWindow.h | 6 ++-- widget/uikit/nsWindow.mm | 18 +++++------ widget/windows/nsWindow.cpp | 8 ++--- widget/windows/nsWindow.h | 6 ++-- xpfe/appshell/nsAppShellService.cpp | 3 +- xpfe/appshell/nsWebShellWindow.cpp | 2 +- 34 files changed, 154 insertions(+), 142 deletions(-) diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 2aea815af54..1038e5c0878 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -757,7 +757,7 @@ TabChild::Init() } mPuppetWidget->Create( nullptr, 0, // no parents - gfx::IntRect(gfx::IntPoint(0, 0), gfx::IntSize(0, 0)), + LayoutDeviceIntRect(0, 0, 0, 0), nullptr // HandleWidgetEvent ); @@ -2838,8 +2838,9 @@ TabChild::CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut) initData.mUnicode = false; initData.clipChildren = true; initData.clipSiblings = true; - nsresult rv = pluginWidget->Create(aParent, nullptr, gfx::IntRect(gfx::IntPoint(0, 0), - nsIntSize(0, 0)), &initData); + nsresult rv = pluginWidget->Create(aParent, nullptr, + LayoutDeviceIntRect(0, 0, 0, 0), + &initData); if (NS_FAILED(rv)) { NS_WARNING("Creating native plugin widget on the chrome side failed."); } diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index a84d9e77f5d..af38c024abc 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -2960,8 +2960,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void) initData.mUnicode = false; initData.clipChildren = true; initData.clipSiblings = true; - rv = mWidget->Create(parentWidget.get(), nullptr, nsIntRect(0,0,0,0), - &initData); + rv = mWidget->Create(parentWidget.get(), nullptr, + LayoutDeviceIntRect(0, 0, 0, 0), &initData); if (NS_FAILED(rv)) { mWidget->Destroy(); mWidget = nullptr; diff --git a/dom/plugins/ipc/PluginWidgetParent.cpp b/dom/plugins/ipc/PluginWidgetParent.cpp index 6891324ab49..8ee6cb48fd8 100644 --- a/dom/plugins/ipc/PluginWidgetParent.cpp +++ b/dom/plugins/ipc/PluginWidgetParent.cpp @@ -118,8 +118,8 @@ PluginWidgetParent::RecvCreate(nsresult* aResult) initData.mUnicode = false; initData.clipChildren = true; initData.clipSiblings = true; - *aResult = mWidget->Create(parentWidget.get(), nullptr, nsIntRect(0,0,0,0), - &initData); + *aResult = mWidget->Create(parentWidget.get(), nullptr, + LayoutDeviceIntRect(0, 0, 0, 0), &initData); if (NS_FAILED(*aResult)) { KillWidget(); // This should never fail, abort. diff --git a/embedding/browser/nsWebBrowser.cpp b/embedding/browser/nsWebBrowser.cpp index ef7a29f9dca..b9dafeeed74 100644 --- a/embedding/browser/nsWebBrowser.cpp +++ b/embedding/browser/nsWebBrowser.cpp @@ -1176,7 +1176,8 @@ nsWebBrowser::Create() widgetInit.clipChildren = true; 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->Create(nullptr, mParentNativeWindow, bounds, &widgetInit); diff --git a/gfx/tests/gtest/TestCompositor.cpp b/gfx/tests/gtest/TestCompositor.cpp index d6b7442cbcb..7d1c4ae3086 100644 --- a/gfx/tests/gtest/TestCompositor.cpp +++ b/gfx/tests/gtest/TestCompositor.cpp @@ -55,10 +55,10 @@ public: return nullptr; } - NS_IMETHOD Create(nsIWidget *aParent, + NS_IMETHOD Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const IntRect &aRect, - nsWidgetInitData *aInitData = nullptr) override { return NS_OK; } + const LayoutDeviceIntRect& aRect, + 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, diff --git a/layout/xul/nsXULPopupManager.cpp b/layout/xul/nsXULPopupManager.cpp index dce837e6acc..d485c42a348 100644 --- a/layout/xul/nsXULPopupManager.cpp +++ b/layout/xul/nsXULPopupManager.cpp @@ -470,7 +470,7 @@ nsXULPopupManager::PopupMoved(nsIFrame* aFrame, nsIntPoint aPnt) // Don't do anything if the popup is already at the specified location. This // prevents recursive calls when a popup is positioned. - nsIntRect curDevSize = view->CalcWidgetBounds(eWindowType_popup); + LayoutDeviceIntRect curDevSize = view->CalcWidgetBounds(eWindowType_popup); nsIWidget* widget = menuPopupFrame->GetWidget(); if (curDevSize.x == aPnt.x && curDevSize.y == aPnt.y && (!widget || widget->GetClientOffset() == @@ -504,7 +504,7 @@ nsXULPopupManager::PopupResized(nsIFrame* aFrame, LayoutDeviceIntSize aSize) if (!view) 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 (curDevSize.width == aSize.width && curDevSize.height == aSize.height) return; diff --git a/view/nsView.cpp b/view/nsView.cpp index 4abaa485612..4c47125d31b 100644 --- a/view/nsView.cpp +++ b/view/nsView.cpp @@ -214,7 +214,7 @@ bool nsView::IsEffectivelyVisible() return true; } -nsIntRect nsView::CalcWidgetBounds(nsWindowType aType) +LayoutDeviceIntRect nsView::CalcWidgetBounds(nsWindowType aType) { int32_t p2a = mViewManager->AppUnitsPerDevPixel(); @@ -238,7 +238,8 @@ nsIntRect nsView::CalcWidgetBounds(nsWindowType aType) } // 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) // cocoa and GTK round widget coordinates to the nearest global "display @@ -248,7 +249,7 @@ nsIntRect nsView::CalcWidgetBounds(nsWindowType aType) uint32_t round; if (aType == eWindowType_popup && widget && ((round = widget->RoundsWidgetCoordinatesTo()) > 1)) { - nsIntSize pixelRoundedSize = newBounds.Size(); + LayoutDeviceIntSize pixelRoundedSize = newBounds.Size(); // round the top left and bottom right to the nearest round pixel newBounds.x = NSToIntRoundUp(NSAppUnitsToDoublePixels(viewBounds.x, p2a) / round) * round; newBounds.y = NSToIntRoundUp(NSAppUnitsToDoublePixels(viewBounds.y, p2a) / round) * round; @@ -312,7 +313,7 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly, if (invisiblePopup) { // We're going to hit the early exit below, avoid calling CalcWidgetBounds. } else { - newBounds = LayoutDeviceIntRect::FromUnknownRect(CalcWidgetBounds(type)); + newBounds = CalcWidgetBounds(type); } bool curVisibility = widget->IsVisible(); @@ -575,7 +576,7 @@ nsresult nsView::CreateWidget(nsWidgetInitData *aWidgetInitData, (!initDataPassedIn && GetParent() && GetParent()->GetViewManager() != mViewManager); - nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType); + LayoutDeviceIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType); nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(nullptr) : nullptr; @@ -610,7 +611,7 @@ nsresult nsView::CreateWidgetForParent(nsIWidget* aParentWidget, DefaultWidgetInitData defaultInitData; aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData; - nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType); + LayoutDeviceIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType); mWindow = aParentWidget->CreateChild(trect, aWidgetInitData); if (!mWindow) { @@ -632,7 +633,7 @@ nsresult nsView::CreateWidgetForPopup(nsWidgetInitData *aWidgetInitData, MOZ_ASSERT(aWidgetInitData->mWindowType == eWindowType_popup, "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 // ... unnecessary, but it's the way the old code did it. Please diff --git a/view/nsView.h b/view/nsView.h index 9b5dad5fdb4..bc6fd1698f4 100644 --- a/view/nsView.h +++ b/view/nsView.h @@ -14,6 +14,7 @@ #include "nsCOMPtr.h" #include "nsWidgetInitData.h" // for nsWindowType #include "nsIWidgetListener.h" +#include "Units.h" #include "mozilla/EventForwards.h" class nsViewManager; @@ -57,6 +58,8 @@ class nsView final : public nsIWidgetListener public: friend class nsViewManager; + typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect; + NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW /** @@ -326,7 +329,7 @@ public: */ bool IsRoot() const; - nsIntRect CalcWidgetBounds(nsWindowType aType); + LayoutDeviceIntRect CalcWidgetBounds(nsWindowType aType); // This is an app unit offset to add when converting view coordinates to // widget coordinates. It is the offset in view coordinates from widget diff --git a/widget/PluginWidgetProxy.cpp b/widget/PluginWidgetProxy.cpp index dd17eeda340..1626f7faabe 100644 --- a/widget/PluginWidgetProxy.cpp +++ b/widget/PluginWidgetProxy.cpp @@ -47,9 +47,9 @@ PluginWidgetProxy::~PluginWidgetProxy() } NS_IMETHODIMP -PluginWidgetProxy::Create(nsIWidget* aParent, - nsNativeWidget aNativeParent, - const nsIntRect& aRect, +PluginWidgetProxy::Create(nsIWidget* aParent, + nsNativeWidget aNativeParent, + const LayoutDeviceIntRect& aRect, nsWidgetInitData* aInitData) { ENSURE_CHANNEL; @@ -64,7 +64,7 @@ PluginWidgetProxy::Create(nsIWidget* aParent, BaseCreate(aParent, aRect, aInitData); - mBounds = aRect; + mBounds = aRect.ToUnknownRect(); mEnabled = true; mVisible = true; diff --git a/widget/PluginWidgetProxy.h b/widget/PluginWidgetProxy.h index 5935cce0dc4..398c1e31373 100644 --- a/widget/PluginWidgetProxy.h +++ b/widget/PluginWidgetProxy.h @@ -35,7 +35,7 @@ public: // nsIWidget NS_IMETHOD Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const nsIntRect& aRect, + const LayoutDeviceIntRect& aRect, nsWidgetInitData* aInitData = nullptr) override; NS_IMETHOD Destroy() override; NS_IMETHOD SetFocus(bool aRaise = false) override; diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 68643a45af1..749efef56d7 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -98,16 +98,16 @@ PuppetWidget::~PuppetWidget() } NS_IMETHODIMP -PuppetWidget::Create(nsIWidget *aParent, - nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) +PuppetWidget::Create(nsIWidget* aParent, + nsNativeWidget aNativeParent, + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData) { MOZ_ASSERT(!aNativeParent, "got a non-Puppet native parent"); BaseCreate(nullptr, aRect, aInitData); - mBounds = aRect; + mBounds = aRect.ToUnknownRect(); mEnabled = true; mVisible = true; @@ -146,9 +146,9 @@ PuppetWidget::InitIMEState() } already_AddRefed -PuppetWidget::CreateChild(const nsIntRect &aRect, - nsWidgetInitData *aInitData, - bool aForceUseIWidgetParent) +PuppetWidget::CreateChild(const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData, + bool aForceUseIWidgetParent) { bool isPopup = IsPopup(aInitData); nsCOMPtr widget = nsIWidget::CreatePuppetWidget(mTabChild); diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index 976d6e459ed..fed03cb62e9 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -53,17 +53,17 @@ protected: public: NS_DECL_ISUPPORTS_INHERITED - NS_IMETHOD Create(nsIWidget* aParent, - nsNativeWidget aNativeParent, - const nsIntRect& aRect, + NS_IMETHOD Create(nsIWidget* aParent, + nsNativeWidget aNativeParent, + const LayoutDeviceIntRect& aRect, nsWidgetInitData* aInitData = nullptr) override; void InitIMEState(); virtual already_AddRefed - CreateChild(const nsIntRect &aRect, - nsWidgetInitData *aInitData = nullptr, - bool aForceUseIWidgetParent = false) override; + CreateChild(const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData = nullptr, + bool aForceUseIWidgetParent = false) override; NS_IMETHOD Destroy() override; diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index f248b18e974..9094aa2df71 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -525,10 +525,10 @@ nsWindow::IsTopLevel() } NS_IMETHODIMP -nsWindow::Create(nsIWidget *aParent, +nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData) { 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; @@ -540,7 +540,7 @@ nsWindow::Create(nsIWidget *aParent, } } - mBounds = aRect; + mBounds = aRect.ToUnknownRect(); // for toplevel windows, bounds are fixed to full screen size if (!parent) { @@ -550,7 +550,8 @@ nsWindow::Create(nsIWidget *aParent, 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!"); diff --git a/widget/android/nsWindow.h b/widget/android/nsWindow.h index 2c9c3c2a44c..5324c42d54a 100644 --- a/widget/android/nsWindow.h +++ b/widget/android/nsWindow.h @@ -70,10 +70,10 @@ public: // nsIWidget // - NS_IMETHOD Create(nsIWidget *aParent, + NS_IMETHOD Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) override; + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData) override; NS_IMETHOD Destroy(void) override; NS_IMETHOD ConfigureChildren(const nsTArray&) override; NS_IMETHOD SetParent(nsIWidget* aNewParent) override; diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h index 9020c34bbf5..71e78580c57 100644 --- a/widget/cocoa/nsChildView.h +++ b/widget/cocoa/nsChildView.h @@ -354,10 +354,10 @@ public: nsChildView(); // nsIWidget interface - NS_IMETHOD Create(nsIWidget *aParent, + NS_IMETHOD Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData = nullptr) override; + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData = nullptr) override; NS_IMETHOD Destroy() override; diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 1643bc8a749..a4f7e98c1df 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -465,10 +465,10 @@ nsChildView::ReleaseTitlebarCGContext() } } -nsresult nsChildView::Create(nsIWidget *aParent, +nsresult nsChildView::Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; @@ -493,7 +493,7 @@ nsresult nsChildView::Create(nsIWidget *aParent, gChildViewMethodsSwizzled = true; } - mBounds = aRect; + mBounds = aRect.ToUnknownRect(); // Ensure that the toolkit is created. nsToolkit::GetToolkit(); diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h index acd0db0639c..798de7e936e 100644 --- a/widget/cocoa/nsCocoaWindow.h +++ b/widget/cocoa/nsCocoaWindow.h @@ -246,7 +246,6 @@ typedef struct _nsCocoaWindowList { class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa { private: - typedef nsBaseWidget Inherited; public: @@ -255,11 +254,11 @@ public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSPIWIDGETCOCOA - + NS_IMETHOD Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData = nullptr) override; + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData = nullptr) override; NS_IMETHOD Destroy() override; @@ -393,7 +392,7 @@ protected: nsresult CreateNativeWindow(const NSRect &aRect, nsBorderStyle aBorderStyle, bool aRectIsFrameRect); - nsresult CreatePopupContentView(const nsIntRect &aRect); + nsresult CreatePopupContentView(const LayoutDeviceIntRect &aRect); void DestroyNativeWindow(); void AdjustWindowShadow(); void SetWindowBackgroundBlur(); diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index 7964805a219..64b2915f0ff 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -182,13 +182,16 @@ nsCocoaWindow::~nsCocoaWindow() // Find the screen that overlaps aRect the most, // if none are found default to the mainScreen. -static NSScreen *FindTargetScreenForRect(const nsIntRect& aRect) +static NSScreen* +FindTargetScreenForRect(const LayoutDeviceIntRect& aRect) { NSScreen *targetScreen = [NSScreen mainScreen]; NSEnumerator *screenEnum = [[NSScreen screens] objectEnumerator]; int largestIntersectArea = 0; while (NSScreen *screen = [screenEnum nextObject]) { - nsIntRect screenRect(nsCocoaUtils::CocoaRectToGeckoRect([screen visibleFrame])); + LayoutDeviceIntRect screenRect = + LayoutDeviceIntRect::FromUnknownRect( + nsCocoaUtils::CocoaRectToGeckoRect([screen visibleFrame])); screenRect = screenRect.Intersect(aRect); int area = screenRect.width * screenRect.height; 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, // or to aScreen if a screen is passed in // 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) { aScreen = FindTargetScreenForRect(aRect); @@ -246,10 +250,10 @@ static bool UseNativePopupWindows() } // aRect here is specified in global display pixels -nsresult nsCocoaWindow::Create(nsIWidget *aParent, +nsresult nsCocoaWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData) { 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). nsAutoreleasePool localPool; - nsIntRect newBounds = aRect; + LayoutDeviceIntRect newBounds = aRect; FitRectToVisibleAreaForScreen(newBounds, nullptr); // Set defaults which can be overriden from aInitData in BaseCreate @@ -281,7 +285,7 @@ nsresult nsCocoaWindow::Create(nsIWidget *aParent, return NS_OK; nsresult rv = - CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(newBounds), + CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(newBounds.ToUnknownRect()), mBorderStyle, false); NS_ENSURE_SUCCESS(rv, rv); @@ -481,7 +485,8 @@ nsresult nsCocoaWindow::CreateNativeWindow(const NSRect &aRect, 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; @@ -1520,16 +1525,17 @@ nsresult nsCocoaWindow::DoResize(double aX, double aY, int32_t height = NSToIntRound(aHeight * scale); ConstrainSize(&width, &height); - nsIntRect newBounds(NSToIntRound(aX), NSToIntRound(aY), - NSToIntRound(width / scale), - NSToIntRound(height / scale)); + LayoutDeviceIntRect newBounds(NSToIntRound(aX), NSToIntRound(aY), + NSToIntRound(width / scale), + NSToIntRound(height / scale)); // constrain to the screen that contains the largest area of the new rect FitRectToVisibleAreaForScreen(newBounds, aConstrainToCurrentScreen ? [mWindow screen] : nullptr); // convert requested bounds into Cocoa coordinate system - NSRect newFrame = nsCocoaUtils::GeckoRectToCocoaRect(newBounds); + NSRect newFrame = + nsCocoaUtils::GeckoRectToCocoaRect(newBounds.ToUnknownRect()); NSRect frame = [mWindow frame]; 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. NSScreen *screen = - FindTargetScreenForRect(nsCocoaUtils::CocoaRectToGeckoRect(frame)); + FindTargetScreenForRect( + LayoutDeviceIntRect::FromUnknownRect(nsCocoaUtils::CocoaRectToGeckoRect(frame))); return nsCocoaUtils::GetBackingScaleFactor(screen); } diff --git a/widget/gonk/nsScreenManagerGonk.cpp b/widget/gonk/nsScreenManagerGonk.cpp index e772f6e982b..e95610d4dfb 100644 --- a/widget/gonk/nsScreenManagerGonk.cpp +++ b/widget/gonk/nsScreenManagerGonk.cpp @@ -481,7 +481,7 @@ nsScreenGonk::EnableMirroring() nsWidgetInitData initData; initData.mScreenId = mId; RefPtr window = new nsWindow(); - window->Create(nullptr, nullptr, mNaturalBounds.ToUnknownRect(), &initData); + window->Create(nullptr, nullptr, mNaturalBounds, &initData); MOZ_ASSERT(static_cast(window)->GetScreen() == this); // Update mMirroringWidget on compositor thread diff --git a/widget/gonk/nsWindow.cpp b/widget/gonk/nsWindow.cpp index c0bdb990b41..45df1538914 100644 --- a/widget/gonk/nsWindow.cpp +++ b/widget/gonk/nsWindow.cpp @@ -330,10 +330,10 @@ nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId, } NS_IMETHODIMP -nsWindow::Create(nsIWidget *aParent, - void *aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) +nsWindow::Create(nsIWidget* aParent, + void* aNativeParent, + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData) { BaseCreate(aParent, aRect, aInitData); @@ -347,7 +347,7 @@ nsWindow::Create(nsIWidget *aParent, mScreen = static_cast(screen.get()); - mBounds = aRect; + mBounds = aRect.ToUnknownRect(); mParent = (nsWindow *)aParent; mVisible = false; diff --git a/widget/gonk/nsWindow.h b/widget/gonk/nsWindow.h index beaeb34e50e..afd5a4b7878 100644 --- a/widget/gonk/nsWindow.h +++ b/widget/gonk/nsWindow.h @@ -46,10 +46,10 @@ public: static nsEventStatus DispatchKeyInput(mozilla::WidgetKeyboardEvent& aEvent); static void DispatchTouchInput(mozilla::MultiTouchInput& aInput); - NS_IMETHOD Create(nsIWidget *aParent, - void *aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData); + NS_IMETHOD Create(nsIWidget* aParent, + void* aNativeParent, + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData); NS_IMETHOD Destroy(void); NS_IMETHOD Show(bool aState); diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index f3bbabdb6b5..9f05b4aded5 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -3498,10 +3498,10 @@ CreateGdkWindow(GdkWindow *parent, GtkWidget *widget) } nsresult -nsWindow::Create(nsIWidget *aParent, - nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) +nsWindow::Create(nsIWidget* aParent, + nsNativeWidget aNativeParent, + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData) { // only set the base parent if we're going to be a dialog or a // toplevel @@ -3531,7 +3531,7 @@ nsWindow::Create(nsIWidget *aParent, CommonCreate(aParent, listenForResizes); // save our bounds - mBounds = aRect; + mBounds = aRect.ToUnknownRect(); ConstrainSize(&mBounds.width, &mBounds.height); // figure out our parent window diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h index e53a9c17d44..7359d10a0ff 100644 --- a/widget/gtk/nsWindow.h +++ b/widget/gtk/nsWindow.h @@ -95,10 +95,10 @@ public: bool AreBoundsSane(void); // nsIWidget - NS_IMETHOD Create(nsIWidget *aParent, - nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) override; + NS_IMETHOD Create(nsIWidget* aParent, + nsNativeWidget aNativeParent, + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData) override; NS_IMETHOD Destroy(void) override; virtual nsIWidget *GetParent() override; virtual float GetDPI() override; diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 033269fce4d..10b91606163 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -308,9 +308,9 @@ nsBaseWidget::~nsBaseWidget() // Basic create. // //------------------------------------------------------------------------- -void nsBaseWidget::BaseCreate(nsIWidget *aParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) +void nsBaseWidget::BaseCreate(nsIWidget* aParent, + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData) { static bool gDisableNativeThemeCached = false; if (!gDisableNativeThemeCached) { @@ -355,9 +355,9 @@ void nsBaseWidget::SetWidgetListener(nsIWidgetListener* aWidgetListener) } already_AddRefed -nsBaseWidget::CreateChild(const nsIntRect &aRect, - nsWidgetInitData *aInitData, - bool aForceUseIWidgetParent) +nsBaseWidget::CreateChild(const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData, + bool aForceUseIWidgetParent) { nsIWidget* parent = this; nsNativeWidget nativeParent = nullptr; diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index 51673e3382f..0b33b83a948 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -231,9 +231,9 @@ public: double& aOverriddenDeltaX, double& aOverriddenDeltaY) override; virtual already_AddRefed - CreateChild(const nsIntRect &aRect, - nsWidgetInitData *aInitData = nullptr, - bool aForceUseIWidgetParent = false) override; + CreateChild(const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData = nullptr, + bool aForceUseIWidgetParent = false) override; NS_IMETHOD AttachViewToTopLevel(bool aUseAttachedEvents) override; virtual nsIWidgetListener* GetAttachedWidgetListener() override; virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) override; @@ -350,8 +350,8 @@ protected: nsIFile **aResult); virtual void OnDestroy(); void BaseCreate(nsIWidget *aParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData); + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData); virtual void ConfigureAPZCTreeManager(); virtual void ConfigureAPZControllerThread(); diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 5eeec5d52f7..f5a938166e6 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -395,10 +395,10 @@ class nsIWidget : public nsISupports { * @param aInitData data that is used for widget initialization * */ - NS_IMETHOD Create(nsIWidget *aParent, - nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData = nullptr) = 0; + NS_IMETHOD Create(nsIWidget* aParent, + nsNativeWidget aNativeParent, + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData = nullptr) = 0; /** * 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. */ virtual already_AddRefed - CreateChild(const nsIntRect &aRect, - nsWidgetInitData *aInitData = nullptr, - bool aForceUseIWidgetParent = false) = 0; + CreateChild(const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData = nullptr, + bool aForceUseIWidgetParent = false) = 0; /** * Attach to a top level widget. diff --git a/widget/qt/nsWindow.cpp b/widget/qt/nsWindow.cpp index 835cde2cd72..5ff4bd86ef4 100644 --- a/widget/qt/nsWindow.cpp +++ b/widget/qt/nsWindow.cpp @@ -133,10 +133,10 @@ nsWindow::~nsWindow() } nsresult -nsWindow::Create(nsIWidget *aParent, - nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) +nsWindow::Create(nsIWidget* aParent, + nsNativeWidget aNativeParent, + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData) { // only set the base parent if we're not going to be a dialog or a // toplevel @@ -151,7 +151,7 @@ nsWindow::Create(nsIWidget *aParent, mParent = (nsWindow *)aParent; // save our bounds - mBounds = aRect; + mBounds = aRect.ToUnknownRect(); // find native parent MozQWidget *parent = nullptr; diff --git a/widget/qt/nsWindow.h b/widget/qt/nsWindow.h index 7b6dc75ef29..871af067b31 100644 --- a/widget/qt/nsWindow.h +++ b/widget/qt/nsWindow.h @@ -84,10 +84,10 @@ public: // // nsIWidget // - NS_IMETHOD Create(nsIWidget *aParent, - nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData); + NS_IMETHOD Create(nsIWidget* aParent, + nsNativeWidget aNativeParent, + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData); NS_IMETHOD Destroy(void); NS_IMETHOD Show(bool aState); diff --git a/widget/uikit/nsWindow.h b/widget/uikit/nsWindow.h index e4ffad64adc..e7e8fd8ec84 100644 --- a/widget/uikit/nsWindow.h +++ b/widget/uikit/nsWindow.h @@ -30,10 +30,10 @@ public: // nsIWidget // - NS_IMETHOD Create(nsIWidget *aParent, + NS_IMETHOD Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData = nullptr) override; + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData = nullptr) override; NS_IMETHOD Destroy() override; NS_IMETHOD Show(bool aState) override; NS_IMETHOD Enable(bool aState) override { diff --git a/widget/uikit/nsWindow.mm b/widget/uikit/nsWindow.mm index f5fe867b1dc..6f2009d210e 100644 --- a/widget/uikit/nsWindow.mm +++ b/widget/uikit/nsWindow.mm @@ -466,10 +466,10 @@ nsWindow::IsTopLevel() // NS_IMETHODIMP -nsWindow::Create(nsIWidget *aParent, +nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) + const LayoutDeviceIntRect& aRect, + 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); nsWindow* parent = (nsWindow*) aParent; @@ -484,17 +484,15 @@ nsWindow::Create(nsIWidget *aParent, if (parent == nullptr) { if (nsAppShell::gWindow == nil) { mBounds = UIKitScreenManager::GetBounds(); - } - else { + } else { CGRect cgRect = [nsAppShell::gWindow bounds]; mBounds.x = cgRect.origin.x; mBounds.y = cgRect.origin.y; mBounds.width = cgRect.size.width; mBounds.height = cgRect.size.height; } - } - else { - mBounds = aRect; + } else { + mBounds = aRect.ToUnknownRect(); } ALOG("nsWindow[%p]::Create bounds: %d %d %d %d", (void*)this, @@ -504,7 +502,9 @@ nsWindow::Create(nsIWidget *aParent, mWindowType = eWindowType_toplevel; 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!"); diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 404d0d4cff7..64851903492 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -490,10 +490,10 @@ ShouldCacheTitleBarInfo(nsWindowType aWindowType, nsBorderStyle aBorderStyle) // Create the proper widget nsresult -nsWindow::Create(nsIWidget *aParent, +nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData) { nsWidgetInitData defaultInitData; if (!aInitData) @@ -507,7 +507,7 @@ nsWindow::Create(nsIWidget *aParent, nullptr : aParent; mIsTopWidgetWindow = (nullptr == baseParent); - mBounds = aRect; + mBounds = aRect.ToUnknownRect(); // Ensure that the toolkit is created. nsToolkit::GetToolkit(); diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index ffcac65a313..9ae0aee68c9 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -92,10 +92,10 @@ public: using nsWindowBase::DispatchPluginEvent; // nsIWidget interface - NS_IMETHOD Create(nsIWidget *aParent, + NS_IMETHOD Create(nsIWidget* aParent, nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData = nullptr); + const LayoutDeviceIntRect& aRect, + nsWidgetInitData* aInitData = nullptr); NS_IMETHOD Destroy(); NS_IMETHOD SetParent(nsIWidget *aNewParent); virtual nsIWidget* GetParent(void); diff --git a/xpfe/appshell/nsAppShellService.cpp b/xpfe/appshell/nsAppShellService.cpp index 0ee2dc167af..5632ae8b2ad 100644 --- a/xpfe/appshell/nsAppShellService.cpp +++ b/xpfe/appshell/nsAppShellService.cpp @@ -474,8 +474,7 @@ nsAppShellService::CreateWindowlessBrowser(bool aIsChrome, nsIWebNavigation **aR NS_ERROR("Couldn't create instance of PuppetWidget"); return NS_ERROR_FAILURE; } - widget->Create(nullptr, 0, gfx::IntRect(gfx::IntPoint(0, 0), gfx::IntSize(0, 0)), - nullptr); + widget->Create(nullptr, 0, LayoutDeviceIntRect(0, 0, 0, 0), nullptr); nsCOMPtr window = do_QueryInterface(navigation); window->InitWindow(0, widget, 0, 0, 0, 0); window->Create(); diff --git a/xpfe/appshell/nsWebShellWindow.cpp b/xpfe/appshell/nsWebShellWindow.cpp index 9c20b47fd79..424e5c9dd43 100644 --- a/xpfe/appshell/nsWebShellWindow.cpp +++ b/xpfe/appshell/nsWebShellWindow.cpp @@ -173,7 +173,7 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent, mWindow->SetWidgetListener(this); mWindow->Create((nsIWidget *)parentWidget, // Parent nsIWidget nullptr, // Native parent widget - r.ToUnknownRect(), // Widget dimensions + r, // Widget dimensions &widgetInitData); // Widget initialization data mWindow->GetClientBounds(r); // Match the default background color of content. Important on windows