Bug 1239589 - Change nsBaseWidget::mBounds to a LayoutDeviceIntRect. r=kats.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 22 Nov 2015 20:32:29 -0800
changeset 302569 88a086706e1e5cdaad5d7fdb7f7e8c799cc276c0
parent 302568 52291e2e62258973fa362c0829969bc1e727ac03
child 302570 075d8bd8b9a50a712e2ab0400eea762238164a6f
push id8978
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 14:05:32 +0000
treeherdermozilla-aurora@b9a803752a2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1239589
milestone46.0a1
Bug 1239589 - Change nsBaseWidget::mBounds to a LayoutDeviceIntRect. r=kats. This patch removes dozens of ToUnknown/FromUnknown conversions and doesn't add any new ones, which is nice. It also removes UntypedDevPixelsToCocoaPoints(), which is no longer needed.
widget/PluginWidgetProxy.cpp
widget/PuppetWidget.cpp
widget/android/nsWindow.cpp
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaUtils.h
widget/cocoa/nsCocoaWindow.mm
widget/gonk/nsWindow.cpp
widget/gtk/nsWindow.cpp
widget/gtk/nsWindow.h
widget/nsBaseWidget.cpp
widget/nsBaseWidget.h
widget/qt/nsWindow.cpp
widget/uikit/nsScreenManager.h
widget/uikit/nsScreenManager.mm
widget/uikit/nsWindow.mm
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/widget/PluginWidgetProxy.cpp
+++ b/widget/PluginWidgetProxy.cpp
@@ -59,17 +59,17 @@ PluginWidgetProxy::Create(nsIWidget* aPa
   mActor->SendCreate(&rv);
   if (NS_FAILED(rv)) {
     NS_WARNING("failed to create chrome widget, plugins won't paint.");
     return rv;
   }
 
   BaseCreate(aParent, aInitData);
 
-  mBounds = aRect.ToUnknownRect();
+  mBounds = aRect;
   mEnabled = true;
   mVisible = true;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PluginWidgetProxy::SetParent(nsIWidget* aNewParent)
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -25,21 +25,21 @@
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::hal;
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 using namespace mozilla::widget;
 
 static void
-InvalidateRegion(nsIWidget* aWidget, const nsIntRegion& aRegion)
+InvalidateRegion(nsIWidget* aWidget, const LayoutDeviceIntRegion& aRegion)
 {
-  nsIntRegionRectIterator it(aRegion);
-  while(const nsIntRect* r = it.Next()) {
-    aWidget->Invalidate(LayoutDeviceIntRect::FromUnknownRect(*r));
+  LayoutDeviceIntRegion::RectIterator it(aRegion);
+  while(const LayoutDeviceIntRect* r = it.Next()) {
+    aWidget->Invalidate(*r);
   }
 }
 
 /*static*/ already_AddRefed<nsIWidget>
 nsIWidget::CreatePuppetWidget(TabChild* aTabChild)
 {
   MOZ_ASSERT(!aTabChild || nsIWidget::UsePuppetWidgets(),
              "PuppetWidgets not allowed in this configuration");
@@ -102,17 +102,17 @@ PuppetWidget::Create(nsIWidget* aParent,
                      nsNativeWidget aNativeParent,
                      const LayoutDeviceIntRect& aRect,
                      nsWidgetInitData* aInitData)
 {
   MOZ_ASSERT(!aNativeParent, "got a non-Puppet native parent");
 
   BaseCreate(nullptr, aInitData);
 
-  mBounds = aRect.ToUnknownRect();
+  mBounds = aRect;
   mEnabled = true;
   mVisible = true;
 
   mDrawTarget = gfxPlatform::GetPlatform()->
     CreateOffscreenContentDrawTarget(IntSize(1, 1), SurfaceFormat::B8G8R8A8);
 
   mNeedIMEStateInit = MightNeedIMEFocus(aInitData);
 
@@ -192,39 +192,40 @@ PuppetWidget::Show(bool aState)
   mVisible = aState;
 
   if (mChild) {
     mChild->mVisible = aState;
   }
 
   if (!wasVisible && mVisible) {
     Resize(mBounds.width, mBounds.height, false);
-    Invalidate(LayoutDeviceIntRect::FromUnknownRect(mBounds));
+    Invalidate(mBounds);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PuppetWidget::Resize(double aWidth,
                      double aHeight,
                      bool   aRepaint)
 {
-  nsIntRect oldBounds = mBounds;
-  mBounds.SizeTo(nsIntSize(NSToIntRound(aWidth), NSToIntRound(aHeight)));
+  LayoutDeviceIntRect oldBounds = mBounds;
+  mBounds.SizeTo(LayoutDeviceIntSize(NSToIntRound(aWidth),
+                                     NSToIntRound(aHeight)));
 
   if (mChild) {
     return mChild->Resize(aWidth, aHeight, aRepaint);
   }
 
   // XXX: roc says that |aRepaint| dictates whether or not to
   // invalidate the expanded area
   if (oldBounds.Size() < mBounds.Size() && aRepaint) {
-    nsIntRegion dirty(mBounds);
-    dirty.Sub(dirty,  oldBounds);
+    LayoutDeviceIntRegion dirty(mBounds);
+    dirty.Sub(dirty, oldBounds);
     InvalidateRegion(this, dirty);
   }
 
   // call WindowResized() on both the current listener, and possibly
   // also the previous one if we're in a state where we're drawing that one
   // because the current one is paint suppressed
   if (!oldBounds.IsEqualEdges(mBounds) && mAttachedWidgetListener) {
     if (GetCurrentWidgetListener() &&
@@ -1235,17 +1236,17 @@ PuppetWidget::GetWindowPosition()
   int32_t winX, winY, winW, winH;
   NS_ENSURE_SUCCESS(GetOwningTabChild()->GetDimensions(0, &winX, &winY, &winW, &winH), nsIntPoint());
   return nsIntPoint(winX, winY);
 }
 
 NS_METHOD
 PuppetWidget::GetScreenBounds(LayoutDeviceIntRect& aRect) {
   aRect.MoveTo(WidgetToScreenOffset());
-  aRect.SizeTo(LayoutDeviceIntSize::FromUnknownSize(mBounds.Size()));
+  aRect.SizeTo(mBounds.Size());
   return NS_OK;
 }
 
 uint32_t PuppetWidget::GetMaxTouchPoints() const
 {
   static uint32_t sTouchPoints = 0;
   static bool sIsInitialized = false;
   if (sIsInitialized) {
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1070,17 +1070,17 @@ nsWindow::Create(nsIWidget* aParent,
     if (aNativeParent) {
         if (parent) {
             ALOG("Ignoring native parent on Android window [%p], since parent was specified (%p %p)", (void*)this, (void*)aNativeParent, (void*)aParent);
         } else {
             parent = (nsWindow*) aNativeParent;
         }
     }
 
-    mBounds = aRect.ToUnknownRect();
+    mBounds = aRect;
 
     // for toplevel windows, bounds are fixed to full screen size
     if (!parent) {
         mBounds.x = 0;
         mBounds.y = 0;
         mBounds.width = gAndroidBounds.width;
         mBounds.height = gAndroidBounds.height;
     }
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -530,21 +530,16 @@ public:
     return nsCocoaUtils::CocoaPointsToDevPixels(aPt, BackingScaleFactor());
   }
   LayoutDeviceIntRect CocoaPointsToDevPixels(const NSRect& aRect) const {
     return nsCocoaUtils::CocoaPointsToDevPixels(aRect, BackingScaleFactor());
   }
   CGFloat           DevPixelsToCocoaPoints(int32_t aPixels) const {
     return nsCocoaUtils::DevPixelsToCocoaPoints(aPixels, BackingScaleFactor());
   }
-  // XXX: all calls to this function should eventually be replaced with calls
-  // to DevPixelsToCocoaPoints().
-  NSRect            UntypedDevPixelsToCocoaPoints(const nsIntRect& aRect) const {
-    return nsCocoaUtils::UntypedDevPixelsToCocoaPoints(aRect, BackingScaleFactor());
-  }
   NSRect            DevPixelsToCocoaPoints(const LayoutDeviceIntRect& aRect) const {
     return nsCocoaUtils::DevPixelsToCocoaPoints(aRect, BackingScaleFactor());
   }
 
   already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion) override;
   void EndRemoteDrawing() override;
   void CleanupRemoteDrawing() override;
   bool InitCompositor(mozilla::layers::Compositor* aCompositor) override;
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -491,17 +491,17 @@ nsresult nsChildView::Create(nsIWidget* 
                                 true);
       nsToolkit::SwizzleMethods([NSEvent class], @selector(removeMonitor:),
                                 @selector(nsChildView_NSEvent_removeMonitor:), true);
     }
 #endif
     gChildViewMethodsSwizzled = true;
   }
 
-  mBounds = aRect.ToUnknownRect();
+  mBounds = aRect;
 
   // Ensure that the toolkit is created.
   nsToolkit::GetToolkit();
 
   BaseCreate(aParent, aInitData);
 
   // inherit things from the parent view and create our parallel
   // NSView in the Cocoa display system
@@ -517,18 +517,17 @@ nsresult nsChildView::Create(nsIWidget* 
     // aNativeParent will be the contentView of our window, since that's what
     // nsCocoaWindow returns when asked for an NS_NATIVE_VIEW.
     mParentView = reinterpret_cast<NSView<mozView>*>(aNativeParent);
   }
 
   // create our parallel NSView and hook it up to our parent. Recall
   // that NS_NATIVE_WIDGET is the NSView.
   CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(mParentView);
-  NSRect r = nsCocoaUtils::DevPixelsToCocoaPoints(
-    LayoutDeviceIntRect::FromUnknownRect(mBounds), scaleFactor);
+  NSRect r = nsCocoaUtils::DevPixelsToCocoaPoints(mBounds, scaleFactor);
   mView = [(NSView<mozView>*)CreateCocoaView(r) retain];
   if (!mView) {
     return NS_ERROR_FAILURE;
   }
 
   // If this view was created in a Gecko view hierarchy, the initial state
   // is hidden.  If the view is attached only to a native NSView but has
   // no Gecko parent (as in embedding), the initial state is visible.
@@ -924,19 +923,17 @@ NS_IMETHODIMP nsChildView::SetCursor(img
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 #pragma mark -
 
 // Get this component dimension
 NS_IMETHODIMP nsChildView::GetBounds(LayoutDeviceIntRect& aRect)
 {
-  aRect = !mView
-        ? LayoutDeviceIntRect::FromUnknownRect(mBounds)
-        : CocoaPointsToDevPixels([mView frame]);
+  aRect = !mView ? mBounds : CocoaPointsToDevPixels([mView frame]);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsChildView::GetClientBounds(mozilla::LayoutDeviceIntRect& aRect)
 {
   GetBounds(aRect);
   if (!mParentWidget) {
     // For top level widgets we want the position on screen, not the position
@@ -1018,17 +1015,17 @@ NS_IMETHODIMP nsChildView::Move(double a
 
   if (!mView || (mBounds.x == x && mBounds.y == y))
     return NS_OK;
 
   mBounds.x = x;
   mBounds.y = y;
 
   ManipulateViewWithoutNeedingDisplay(mView, ^{
-    [mView setFrame:UntypedDevPixelsToCocoaPoints(mBounds)];
+    [mView setFrame:DevPixelsToCocoaPoints(mBounds)];
   });
 
   NotifyRollupGeometryChange();
   ReportMoveEvent();
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
@@ -1043,17 +1040,17 @@ NS_IMETHODIMP nsChildView::Resize(double
 
   if (!mView || (mBounds.width == width && mBounds.height == height))
     return NS_OK;
 
   mBounds.width  = width;
   mBounds.height = height;
 
   ManipulateViewWithoutNeedingDisplay(mView, ^{
-    [mView setFrame:UntypedDevPixelsToCocoaPoints(mBounds)];
+    [mView setFrame:DevPixelsToCocoaPoints(mBounds)];
   });
 
   if (mVisible && aRepaint)
     [mView setNeedsDisplay:YES];
 
   NotifyRollupGeometryChange();
   ReportSizeEvent();
 
@@ -1082,17 +1079,17 @@ NS_IMETHODIMP nsChildView::Resize(double
     mBounds.y = y;
   }
   if (isResizing) {
     mBounds.width  = width;
     mBounds.height = height;
   }
 
   ManipulateViewWithoutNeedingDisplay(mView, ^{
-    [mView setFrame:UntypedDevPixelsToCocoaPoints(mBounds)];
+    [mView setFrame:DevPixelsToCocoaPoints(mBounds)];
   });
 
   if (mVisible && aRepaint)
     [mView setNeedsDisplay:YES];
 
   NotifyRollupGeometryChange();
   if (isMoving) {
     ReportMoveEvent();
@@ -2645,42 +2642,41 @@ nsChildView::StartRemoteDrawingInRegion(
     mGLPresenter = GLPresenter::CreateForWindow(this);
 
     if (!mGLPresenter) {
       return nullptr;
     }
   }
 
   LayoutDeviceIntRegion dirtyRegion(aInvalidRegion);
-  LayoutDeviceIntSize renderSize =
-    LayoutDeviceIntSize::FromUnknownSize(mBounds.Size());
+  LayoutDeviceIntSize renderSize = mBounds.Size();
 
   if (!mBasicCompositorImage) {
     mBasicCompositorImage = new RectTextureImage(mGLPresenter->gl());
   }
 
   RefPtr<gfx::DrawTarget> drawTarget =
     mBasicCompositorImage->BeginUpdate(renderSize, dirtyRegion);
 
   if (!drawTarget) {
     // Composite unchanged textures.
-    DoRemoteComposition(LayoutDeviceIntRect::FromUnknownRect(mBounds));
+    DoRemoteComposition(mBounds);
     return nullptr;
   }
 
   aInvalidRegion = mBasicCompositorImage->GetUpdateRegion();
 
   return drawTarget.forget();
 }
 
 void
 nsChildView::EndRemoteDrawing()
 {
   mBasicCompositorImage->EndUpdate(true);
-  DoRemoteComposition(LayoutDeviceIntRect::FromUnknownRect(mBounds));
+  DoRemoteComposition(mBounds);
 }
 
 void
 nsChildView::CleanupRemoteDrawing()
 {
   mBasicCompositorImage = nullptr;
   mCornerMaskImage = nullptr;
   mResizerImage = nullptr;
--- a/widget/cocoa/nsCocoaUtils.h
+++ b/widget/cocoa/nsCocoaUtils.h
@@ -179,27 +179,16 @@ public:
   static NSPoint
   DevPixelsToCocoaPoints(const mozilla::LayoutDeviceIntPoint& aPt,
                          CGFloat aBackingScale)
   {
     return NSMakePoint((CGFloat)aPt.x / aBackingScale,
                        (CGFloat)aPt.y / aBackingScale);
   }
 
-  // XXX: all calls to this function should eventually be replaced with calls
-  // to DevPixelsToCocoaPoints().
-  static NSRect
-  UntypedDevPixelsToCocoaPoints(const nsIntRect& aRect, CGFloat aBackingScale)
-  {
-    return NSMakeRect((CGFloat)aRect.x / aBackingScale,
-                      (CGFloat)aRect.y / aBackingScale,
-                      (CGFloat)aRect.width / aBackingScale,
-                      (CGFloat)aRect.height / aBackingScale);
-  }
-
   static NSRect
   DevPixelsToCocoaPoints(const LayoutDeviceIntRect& aRect,
                          CGFloat aBackingScale)
   {
     return NSMakeRect((CGFloat)aRect.x / aBackingScale,
                       (CGFloat)aRect.y / aBackingScale,
                       (CGFloat)aRect.width / aBackingScale,
                       (CGFloat)aRect.height / aBackingScale);
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -1616,30 +1616,30 @@ NS_IMETHODIMP nsCocoaWindow::GetClientBo
 
 void
 nsCocoaWindow::UpdateBounds()
 {
   NSRect frame = NSZeroRect;
   if (mWindow) {
     frame = [mWindow frame];
   }
-  mBounds = nsCocoaUtils::CocoaRectToGeckoRectDevPix(
-    frame, BackingScaleFactor()).ToUnknownRect();
+  mBounds =
+    nsCocoaUtils::CocoaRectToGeckoRectDevPix(frame, BackingScaleFactor());
 }
 
 NS_IMETHODIMP nsCocoaWindow::GetScreenBounds(LayoutDeviceIntRect &aRect)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
 #ifdef DEBUG
   LayoutDeviceIntRect r = nsCocoaUtils::CocoaRectToGeckoRectDevPix([mWindow frame], BackingScaleFactor());
-  NS_ASSERTION(mWindow && mBounds == r.ToUnknownRect(), "mBounds out of sync!");
+  NS_ASSERTION(mWindow && mBounds == r, "mBounds out of sync!");
 #endif
 
-  aRect = LayoutDeviceIntRect::FromUnknownRect(mBounds);
+  aRect = mBounds;
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 double
 nsCocoaWindow::GetDefaultScaleInternal()
 {
@@ -2020,18 +2020,17 @@ LayoutDeviceIntPoint nsCocoaWindow::Widg
 
 LayoutDeviceIntPoint nsCocoaWindow::GetClientOffset()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   LayoutDeviceIntRect clientRect;
   GetClientBounds(clientRect);
 
-  return clientRect.TopLeft() -
-         LayoutDeviceIntPoint::FromUnknownPoint(mBounds.TopLeft());
+  return clientRect.TopLeft() - mBounds.TopLeft();
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(LayoutDeviceIntPoint(0, 0));
 }
 
 LayoutDeviceIntSize
 nsCocoaWindow::ClientToWindowSize(const LayoutDeviceIntSize& aClientSize)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -339,23 +339,23 @@ nsWindow::Create(nsIWidget* aParent,
     uint32_t screenId = aParent ? ((nsWindow*)aParent)->mScreen->GetId() :
                                   aInitData->mScreenId;
 
     RefPtr<nsScreenManagerGonk> screenManager = nsScreenManagerGonk::GetInstance();
     screenManager->ScreenForId(screenId, getter_AddRefs(screen));
 
     mScreen = static_cast<nsScreenGonk*>(screen.get());
 
-    mBounds = aRect.ToUnknownRect();
+    mBounds = aRect;
 
     mParent = (nsWindow *)aParent;
     mVisible = false;
 
     if (!aParent) {
-        mBounds = mScreen->GetRect().ToUnknownRect();
+        mBounds = mScreen->GetRect();
     }
 
     mComposer2D = HwcComposer2D::GetInstance();
 
     if (!IS_TOPLEVEL()) {
         return NS_OK;
     }
 
@@ -443,24 +443,24 @@ nsWindow::Resize(double aWidth,
 
 NS_IMETHODIMP
 nsWindow::Resize(double aX,
                  double aY,
                  double aWidth,
                  double aHeight,
                  bool   aRepaint)
 {
-    mBounds = nsIntRect(NSToIntRound(aX), NSToIntRound(aY),
-                        NSToIntRound(aWidth), NSToIntRound(aHeight));
+    mBounds = LayoutDeviceIntRect(NSToIntRound(aX), NSToIntRound(aY),
+                                  NSToIntRound(aWidth), NSToIntRound(aHeight));
     if (mWidgetListener) {
         mWidgetListener->WindowResized(this, mBounds.width, mBounds.height);
     }
 
     if (aRepaint) {
-        Invalidate(LayoutDeviceIntRect::FromUnknownRect(mBounds));
+        Invalidate(mBounds);
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWindow::Enable(bool aState)
 {
@@ -721,17 +721,17 @@ nsWindow::BringToTop()
     }
 
     mScreen->BringToTop(this);
 
     if (mWidgetListener) {
         mWidgetListener->WindowActivated();
     }
 
-    Invalidate(LayoutDeviceIntRect::FromUnknownRect(mBounds));
+    Invalidate(mBounds);
 }
 
 void
 nsWindow::UserActivity()
 {
     if (!mIdleService) {
         mIdleService = do_GetService("@mozilla.org/widget/idleservice;1");
     }
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -1492,17 +1492,17 @@ nsWindow::GetScreenBounds(LayoutDeviceIn
         aRect.MoveTo(GdkPointToDevicePixels({ x, y }));
     } else {
         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(LayoutDeviceIntSize::FromUnknownSize(mBounds.Size()));
+    aRect.SizeTo(mBounds.Size());
     LOG(("GetScreenBounds %d,%d | %dx%d\n",
          aRect.x, aRect.y, aRect.width, aRect.height));
     return NS_OK;
 }
 
 LayoutDeviceIntSize
 nsWindow::GetClientSize()
 {
@@ -2414,17 +2414,17 @@ nsWindow::OnConfigureEvent(GtkWidget *aW
         //
         // Skipping the WindowMoved call saves context menus from an infinite
         // loop when nsXULPopupManager::PopupMoved moves the window to the new
         // position and nsMenuPopupFrame::SetPopupPosition adds
         // offsetForContextMenu on each iteration.
         return FALSE;
     }
 
-    mBounds.MoveTo(screenBounds.TopLeft().ToUnknownPoint());
+    mBounds.MoveTo(screenBounds.TopLeft());
 
     // XXX mozilla will invalidate the entire window after this move
     // complete.  wtf?
     NotifyWindowMoved(mBounds.x, mBounds.y);
 
     return FALSE;
 }
 
@@ -2445,17 +2445,17 @@ nsWindow::OnContainerUnrealize()
 
 void
 nsWindow::OnSizeAllocate(GtkAllocation *aAllocation)
 {
     LOG(("size_allocate [%p] %d %d %d %d\n",
          (void *)this, aAllocation->x, aAllocation->y,
          aAllocation->width, aAllocation->height));
 
-    nsIntSize size = GdkRectToDevicePixels(*aAllocation).Size();
+    LayoutDeviceIntSize size = GdkRectToDevicePixels(*aAllocation).Size();
 
     if (mBounds.Size() == size)
         return;
 
     // Invalidate the new part of the window now for the pending paint to
     // minimize background flashes (GDK does not do this for external resizes
     // of toplevels.)
     if (mBounds.width < size.width) {
@@ -3537,17 +3537,17 @@ nsWindow::Create(nsIWidget* aParent,
     bool listenForResizes = false;;
     if (aNativeParent || (aInitData && aInitData->mListenForResizes))
         listenForResizes = true;
 
     // and do our common creation
     CommonCreate(aParent, listenForResizes);
 
     // save our bounds
-    mBounds = aRect.ToUnknownRect();
+    mBounds = aRect;
     ConstrainSize(&mBounds.width, &mBounds.height);
 
     // figure out our parent window
     GtkWidget      *parentMozContainer = nullptr;
     GtkContainer   *parentGtkContainer = nullptr;
     GdkWindow      *parentGdkWindow = nullptr;
     GtkWindow      *topLevelParent = nullptr;
     nsWindow       *parentnsWindow = nullptr;
@@ -4030,17 +4030,17 @@ nsWindow::NativeResize()
         if (!mNeedsShow && mIsShown) {
             mNeedsShow = true;
             NativeShow(false);
         }
         return;
     }
 
     GdkRectangle size = DevicePixelsToGdkSizeRoundUp(mBounds.Size());
-    
+
     LOG(("nsWindow::NativeResize [%p] %d %d\n", (void *)this,
          size.width, size.height));
 
     if (mIsTopLevel) {
         gtk_window_resize(GTK_WINDOW(mShell), size.width, size.height);
     }
     else if (mContainer) {
         GtkWidget *widget = GTK_WIDGET(mContainer);
@@ -4296,24 +4296,22 @@ nsWindow::ConfigureChildren(const nsTArr
       return NS_OK;
     }
 
     for (uint32_t i = 0; i < aConfigurations.Length(); ++i) {
         const Configuration& configuration = aConfigurations[i];
         nsWindow* w = static_cast<nsWindow*>(configuration.mChild.get());
         NS_ASSERTION(w->GetParent() == this,
                      "Configured widget is not a child");
-        LayoutDeviceIntRect wBounds =
-            LayoutDeviceIntRect::FromUnknownRect(w->mBounds);
         w->SetWindowClipRegion(configuration.mClipRegion, true);
-        if (wBounds.Size() != configuration.mBounds.Size()) {
+        if (w->mBounds.Size() != configuration.mBounds.Size()) {
             w->Resize(configuration.mBounds.x, configuration.mBounds.y,
                       configuration.mBounds.width, configuration.mBounds.height,
                       true);
-        } else if (wBounds.TopLeft() != configuration.mBounds.TopLeft()) {
+        } else if (w->mBounds.TopLeft() != configuration.mBounds.TopLeft()) {
             w->Move(configuration.mBounds.x, configuration.mBounds.y);
         }
         w->SetWindowClipRegion(configuration.mClipRegion, false);
     }
     return NS_OK;
 }
 
 nsresult
@@ -6697,33 +6695,33 @@ nsWindow::DevicePixelsToGdkCoordRoundUp(
 
 gint
 nsWindow::DevicePixelsToGdkCoordRoundDown(int pixels) {
     gint scale = GdkScaleFactor();
     return pixels / scale;
 }
 
 GdkPoint
-nsWindow::DevicePixelsToGdkPointRoundDown(nsIntPoint point) {
+nsWindow::DevicePixelsToGdkPointRoundDown(LayoutDeviceIntPoint point) {
     gint scale = GdkScaleFactor();
     return { point.x / scale, point.y / scale };
 }
 
 GdkRectangle
 nsWindow::DevicePixelsToGdkRectRoundOut(LayoutDeviceIntRect rect) {
     gint scale = GdkScaleFactor();
     int x = rect.x / scale;
     int y = rect.y / scale;
     int right = (rect.x + rect.width + scale - 1) / scale;
     int bottom = (rect.y + rect.height + scale - 1) / scale;
     return { x, y, right - x, bottom - y };
 }
 
 GdkRectangle
-nsWindow::DevicePixelsToGdkSizeRoundUp(nsIntSize pixelSize) {
+nsWindow::DevicePixelsToGdkSizeRoundUp(LayoutDeviceIntSize pixelSize) {
     gint scale = GdkScaleFactor();
     gint width = (pixelSize.width + scale - 1) / scale;
     gint height = (pixelSize.height + scale - 1) / scale;
     return { 0, 0, width, height };
 }
 
 int
 nsWindow::GdkCoordToDevicePixels(gint coord) {
@@ -6739,23 +6737,23 @@ nsWindow::GdkEventCoordsToDevicePixels(g
 
 LayoutDeviceIntPoint
 nsWindow::GdkPointToDevicePixels(GdkPoint point) {
     gint scale = GdkScaleFactor();
     return LayoutDeviceIntPoint(point.x * scale,
                                 point.y * scale);
 }
 
-nsIntRect
+LayoutDeviceIntRect
 nsWindow::GdkRectToDevicePixels(GdkRectangle rect) {
     gint scale = GdkScaleFactor();
-    return nsIntRect(rect.x * scale,
-                     rect.y * scale,
-                     rect.width * scale,
-                     rect.height * scale);
+    return LayoutDeviceIntRect(rect.x * scale,
+                               rect.y * scale,
+                               rect.width * scale,
+                               rect.height * scale);
 }
 
 nsresult
 nsWindow::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
                                      uint32_t aNativeMessage,
                                      uint32_t aModifierFlags,
                                      nsIObserver* aObserver)
 {
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -335,24 +335,24 @@ public:
                                                       nsIObserver* aObserver) override;
 
     // HiDPI scale conversion
     gint GdkScaleFactor();
 
     // To GDK
     gint DevicePixelsToGdkCoordRoundUp(int pixels);
     gint DevicePixelsToGdkCoordRoundDown(int pixels);
-    GdkPoint DevicePixelsToGdkPointRoundDown(nsIntPoint point);
-    GdkRectangle DevicePixelsToGdkSizeRoundUp(nsIntSize pixelSize);
+    GdkPoint DevicePixelsToGdkPointRoundDown(LayoutDeviceIntPoint point);
+    GdkRectangle DevicePixelsToGdkSizeRoundUp(LayoutDeviceIntSize pixelSize);
 
     // From GDK
     int GdkCoordToDevicePixels(gint coord);
     LayoutDeviceIntPoint GdkPointToDevicePixels(GdkPoint point);
     LayoutDeviceIntPoint GdkEventCoordsToDevicePixels(gdouble x, gdouble y);
-    nsIntRect GdkRectToDevicePixels(GdkRectangle rect);
+    LayoutDeviceIntRect GdkRectToDevicePixels(GdkRectangle rect);
 
 protected:
     virtual ~nsWindow();
 
     // event handling code
     void DispatchActivateEvent(void);
     void DispatchDeactivateEvent(void);
     void DispatchResized();
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -1438,17 +1438,17 @@ NS_METHOD nsBaseWidget::GetClientBounds(
 }
 
 /**
 * If the implementation of nsWindow supports borders this method MUST be overridden
 *
 **/
 NS_METHOD nsBaseWidget::GetBounds(LayoutDeviceIntRect &aRect)
 {
-  aRect = LayoutDeviceIntRect::FromUnknownRect(mBounds);
+  aRect = mBounds;
   return NS_OK;
 }
 
 /**
 * If the implementation of nsWindow uses a local coordinate system within the window,
 * this method must be overridden
 *
 **/
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -510,17 +510,17 @@ protected:
   RefPtr<mozilla::CompositorVsyncDispatcher> mCompositorVsyncDispatcher;
   RefPtr<APZCTreeManager> mAPZC;
   RefPtr<APZEventState> mAPZEventState;
   SetAllowedTouchBehaviorCallback mSetAllowedTouchBehaviorCallback;
   RefPtr<WidgetShutdownObserver> mShutdownObserver;
   RefPtr<TextEventDispatcher> mTextEventDispatcher;
   nsCursor          mCursor;
   nsBorderStyle     mBorderStyle;
-  nsIntRect         mBounds;
+  LayoutDeviceIntRect mBounds;
   LayoutDeviceIntRect* mOriginalBounds;
   // When this pointer is null, the widget is not clipped
   mozilla::UniquePtr<LayoutDeviceIntRect[]> mClipRects;
   uint32_t          mClipRectCount;
   nsSizeMode        mSizeMode;
   nsPopupLevel      mPopupLevel;
   nsPopupType       mPopupType;
   SizeConstraints   mSizeConstraints;
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -146,17 +146,17 @@ nsWindow::Create(nsIWidget* aParent,
     BaseCreate(baseParent, aInitData);
 
     mVisible = true;
 
     // and do our common creation
     mParent = (nsWindow *)aParent;
 
     // save our bounds
-    mBounds = aRect.ToUnknownRect();
+    mBounds = aRect;
 
     // find native parent
     MozQWidget *parent = nullptr;
 
     if (aParent != nullptr) {
         parent = static_cast<MozQWidget*>(aParent->GetNativeData(NS_NATIVE_WIDGET));
     } else if (aNativeParent != nullptr) {
         parent = static_cast<MozQWidget*>(aNativeParent);
@@ -461,18 +461,17 @@ nsWindow::Resize(double aWidth, double a
     }
     else {
         mNeedsResize = true;
     }
 
     // synthesize a resize event if this isn't a toplevel
     if (mIsTopLevel || mListenForResizes) {
         nsEventStatus status;
-        DispatchResizeEvent(LayoutDeviceIntRect::FromUnknownRect(mBounds),
-                            status);
+        DispatchResizeEvent(mBounds, status);
     }
 
     NotifyRollupGeometryChange();
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWindow::Resize(double aX, double aY, double aWidth, double aHeight,
@@ -525,18 +524,17 @@ nsWindow::Resize(double aX, double aY, d
     else {
         mNeedsResize = true;
         mNeedsMove = true;
     }
 
     if (mIsTopLevel || mListenForResizes) {
         // synthesize a resize event
         nsEventStatus status;
-        DispatchResizeEvent(LayoutDeviceIntRect::FromUnknownRect(mBounds),
-                            status);
+        DispatchResizeEvent(mBounds, status);
     }
 
     if (aRepaint) {
         mWidget->renderLater();
     }
 
     NotifyRollupGeometryChange();
     return NS_OK;
@@ -598,23 +596,21 @@ nsWindow::ConfigureChildren(const nsTArr
 {
     for (uint32_t i = 0; i < aConfigurations.Length(); ++i) {
         const Configuration& configuration = aConfigurations[i];
 
         nsWindow* w = static_cast<nsWindow*>(configuration.mChild.get());
         NS_ASSERTION(w->GetParent() == this,
                      "Configured widget is not a child");
 
-        LayoutDeviceIntRect wBounds =
-            LayoutDeviceIntRect::FromUnknownRect(w->mBounds);
-        if (wBounds.Size() != configuration.mBounds.Size()) {
+        if (w->mBounds.Size() != configuration.mBounds.Size()) {
             w->Resize(configuration.mBounds.x, configuration.mBounds.y,
                       configuration.mBounds.width, configuration.mBounds.height,
                       true);
-        } else if (wBounds.TopLeft() != configuration.mBounds.TopLeft()) {
+        } else if (w->mBounds.TopLeft() != configuration.mBounds.TopLeft()) {
             w->Move(configuration.mBounds.x, configuration.mBounds.y);
         }
     }
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWindow::Invalidate(const LayoutDeviceIntRect& aRect)
@@ -1498,18 +1494,17 @@ void find_first_visible_parent(QWindow* 
             }
         }
     }
 }
 
 NS_IMETHODIMP
 nsWindow::GetScreenBounds(LayoutDeviceIntRect& aRect)
 {
-    aRect = LayoutDeviceIntRect(LayoutDeviceIntPoint(0, 0),
-                                LayoutDeviceIntSize::FromUnknownSize(mBounds.Size()));
+    aRect = LayoutDeviceIntRect(LayoutDeviceIntPoint(0, 0), mBounds.Size());
     if (mIsTopLevel) {
         QPoint pos = mWidget->position();
         aRect.MoveTo(pos.x(), pos.y());
     } else {
         aRect.MoveTo(WidgetToScreenOffset());
     }
     LOG(("GetScreenBounds %d %d | %d %d | %d %d\n",
          aRect.x, aRect.y,
--- a/widget/uikit/nsScreenManager.h
+++ b/widget/uikit/nsScreenManager.h
@@ -40,17 +40,17 @@ class UIKitScreenManager : public nsIScr
 {
 public:
     UIKitScreenManager ();
 
     NS_DECL_ISUPPORTS
 
     NS_DECL_NSISCREENMANAGER
 
-    static nsIntRect GetBounds();
+    static LayoutDeviceIntRect GetBounds();
 
 private:
     virtual ~UIKitScreenManager () {}
     //TODO: support >1 screen, iPad supports external displays
     nsCOMPtr<nsIScreen> mScreen;
 };
 
 #endif // nsScreenManager_h_
--- a/widget/uikit/nsScreenManager.mm
+++ b/widget/uikit/nsScreenManager.mm
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #import <UIKit/UIScreen.h>
 
 #include "gfxPoint.h"
 #include "nsScreenManager.h"
 #include "nsAppShell.h"
 
-static nsIntRect gScreenBounds;
+static LayoutDeviceIntRect gScreenBounds;
 static bool gScreenBoundsSet = false;
 
 UIKitScreen::UIKitScreen(UIScreen* aScreen)
 {
     mScreen = [aScreen retain];
 }
 
 NS_IMETHODIMP
@@ -78,17 +78,17 @@ UIKitScreen::GetContentsScaleFactor(doub
 
 NS_IMPL_ISUPPORTS(UIKitScreenManager, nsIScreenManager)
 
 UIKitScreenManager::UIKitScreenManager()
 : mScreen(new UIKitScreen([UIScreen mainScreen]))
 {
 }
 
-nsIntRect
+LayoutDeviceIntRect
 UIKitScreenManager::GetBounds()
 {
     if (!gScreenBoundsSet) {
         CGRect rect = [[UIScreen mainScreen] bounds];
         CGFloat scale = [[UIScreen mainScreen] scale];
         gScreenBounds.x = rect.origin.x * scale;
         gScreenBounds.y = rect.origin.y * scale;
         gScreenBounds.width = rect.size.width * scale;
--- a/widget/uikit/nsWindow.mm
+++ b/widget/uikit/nsWindow.mm
@@ -46,17 +46,17 @@ using namespace mozilla::layers;
 static LayoutDeviceIntPoint
 UIKitPointsToDevPixels(CGPoint aPoint, CGFloat aBackingScale)
 {
     return LayoutDeviceIntPoint(NSToIntRound(aPoint.x * aBackingScale),
                                 NSToIntRound(aPoint.y * aBackingScale));
 }
 
 static CGRect
-DevPixelsToUIKitPoints(const nsIntRect& aRect, CGFloat aBackingScale)
+DevPixelsToUIKitPoints(const LayoutDeviceIntRect& aRect, CGFloat aBackingScale)
 {
     return CGRectMake((CGFloat)aRect.x / aBackingScale,
                       (CGFloat)aRect.y / aBackingScale,
                       (CGFloat)aRect.width / aBackingScale,
                       (CGFloat)aRect.height / aBackingScale);
 }
 
 // Used to retain a Cocoa object for the remainder of a method's execution.
@@ -488,17 +488,17 @@ nsWindow::Create(nsIWidget* aParent,
         } 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.ToUnknownRect();
+        mBounds = aRect;
     }
 
     ALOG("nsWindow[%p]::Create bounds: %d %d %d %d", (void*)this,
          mBounds.x, mBounds.y, mBounds.width, mBounds.height);
 
     // Set defaults which can be overriden from aInitData in BaseCreate
     mWindowType = eWindowType_toplevel;
     mBorderStyle = eBorderStyle_default;
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -543,17 +543,17 @@ nsWindow::Create(nsIWidget* aParent,
   mUnicodeWidget = aInitData->mUnicode;
 
   nsIWidget *baseParent = aInitData->mWindowType == eWindowType_dialog ||
                           aInitData->mWindowType == eWindowType_toplevel ||
                           aInitData->mWindowType == eWindowType_invisible ?
                           nullptr : aParent;
 
   mIsTopWidgetWindow = (nullptr == baseParent);
-  mBounds = aRect.ToUnknownRect();
+  mBounds = aRect;
 
   // Ensure that the toolkit is created.
   nsToolkit::GetToolkit();
 
   BaseCreate(baseParent, aInitData);
 
   HWND parent;
   if (aParent) { // has a nsIWidget parent
@@ -2025,17 +2025,17 @@ NS_METHOD nsWindow::GetBounds(LayoutDevi
         LayoutDeviceIntPoint clientOffset = pWidget->GetClientOffset();
         r.left -= clientOffset.x;
         r.top  -= clientOffset.y;
       }
     }
     aRect.x = r.left;
     aRect.y = r.top;
   } else {
-    aRect = LayoutDeviceIntRect::FromUnknownRect(mBounds);
+    aRect = mBounds;
   }
   return NS_OK;
 }
 
 // Get this component dimension
 NS_METHOD nsWindow::GetClientBounds(LayoutDeviceIntRect& aRect)
 {
   if (mWnd) {
@@ -2061,17 +2061,17 @@ NS_METHOD nsWindow::GetScreenBounds(Layo
     RECT r;
     VERIFY(::GetWindowRect(mWnd, &r));
 
     aRect.width  = r.right - r.left;
     aRect.height = r.bottom - r.top;
     aRect.x = r.left;
     aRect.y = r.top;
   } else {
-    aRect = LayoutDeviceIntRect::FromUnknownRect(mBounds);
+    aRect = mBounds;
   }
   return NS_OK;
 }
 
 NS_METHOD nsWindow::GetRestoredBounds(LayoutDeviceIntRect &aRect)
 {
   if (SizeMode() == nsSizeMode_Normal) {
     return GetScreenBounds(aRect);
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -580,17 +580,17 @@ protected:
   static LONG           sLastMouseDownTime;
   static LONG           sLastClickCount;
   static BYTE           sLastMouseButton;
 
   // Graphics
   HDC                   mPaintDC; // only set during painting
   HDC                   mCompositeDC; // only set during StartRemoteDrawing
 
-  nsIntRect             mLastPaintBounds;
+  LayoutDeviceIntRect   mLastPaintBounds;
 
   // Used for displayport suppression during window resize
   enum ResizeState {
     NOT_RESIZING,
     IN_SIZEMOVE,
     RESIZING,
   };
   ResizeState mResizeState;