Bug 1230047 (part 2) - Make several PaintWindow() functions use LayoutDevice coordinates. r=kats.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 02 Dec 2015 21:45:41 -0800
changeset 314538 605d74217b116eb40b211eb2545212ec15823cd1
parent 314537 06a87bae7c3151c41067c49cd35fcf6ce60a2553
child 314539 b73d6323bf42587b42fcf7f2de928397940c2053
push id8227
push userxquan@mozilla.com
push dateMon, 07 Dec 2015 17:23:23 +0000
reviewerskats
bugs1230047
milestone45.0a1
Bug 1230047 (part 2) - Make several PaintWindow() functions use LayoutDevice coordinates. r=kats. Specifically, the PaintWindow() functions in the following classes: - nsIWidgetListener, and its subclasses nsView and nsWebBrowser; - nsChildView; - nsWindow (the one in widget/uikit/); - nsViewManager.
embedding/browser/nsWebBrowser.cpp
embedding/browser/nsWebBrowser.h
gfx/src/nsRect.cpp
gfx/src/nsRect.h
view/nsView.cpp
view/nsView.h
view/nsViewManager.cpp
view/nsViewManager.h
widget/PuppetWidget.cpp
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
widget/gtk/nsWindow.cpp
widget/nsIWidgetListener.cpp
widget/nsIWidgetListener.h
widget/qt/nsWindow.cpp
widget/uikit/nsWindow.h
widget/uikit/nsWindow.mm
widget/windows/nsWindowGfx.cpp
--- a/embedding/browser/nsWebBrowser.cpp
+++ b/embedding/browser/nsWebBrowser.cpp
@@ -1724,25 +1724,25 @@ nsWebBrowser::WindowLowered(nsIWidget* a
   document->GetDocumentURI(documentURI);
   printf("nsWebBrowser::NS_DEACTIVATE %p %s\n", (void*)this,
          NS_ConvertUTF16toUTF8(documentURI).get());
 #endif
   Deactivate();
 }
 
 bool
-nsWebBrowser::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion)
+nsWebBrowser::PaintWindow(nsIWidget* aWidget, LayoutDeviceIntRegion aRegion)
 {
   LayerManager* layerManager = aWidget->GetLayerManager();
   NS_ASSERTION(layerManager, "Must be in paint event");
 
   layerManager->BeginTransaction();
   RefPtr<PaintedLayer> root = layerManager->CreatePaintedLayer();
   if (root) {
-    nsIntRect dirtyRect = aRegion.GetBounds();
+    nsIntRect dirtyRect = aRegion.GetBounds().ToUnknownRect();
     root->SetVisibleRegion(LayerIntRegion::FromUnknownRegion(dirtyRect));
     layerManager->SetRoot(root);
   }
 
   layerManager->EndTransaction(DrawPaintedLayer, &mBackgroundColor);
   return true;
 }
 
--- a/embedding/browser/nsWebBrowser.h
+++ b/embedding/browser/nsWebBrowser.h
@@ -117,17 +117,18 @@ protected:
   NS_IMETHOD GetPrimaryContentWindow(nsIDOMWindow** aDomWindow);
   NS_IMETHOD BindListener(nsISupports* aListener, const nsIID& aIID);
   NS_IMETHOD UnBindListener(nsISupports* aListener, const nsIID& aIID);
   NS_IMETHOD EnableGlobalHistory(bool aEnable);
 
   // nsIWidgetListener
   virtual void WindowRaised(nsIWidget* aWidget);
   virtual void WindowLowered(nsIWidget* aWidget);
-  virtual bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion) override;
+  virtual bool PaintWindow(nsIWidget* aWidget,
+                           mozilla::LayoutDeviceIntRegion aRegion) override;
 
 protected:
   RefPtr<nsDocShellTreeOwner> mDocShellTreeOwner;
   nsCOMPtr<nsIDocShell> mDocShell;
   nsCOMPtr<nsIInterfaceRequestor> mDocShellAsReq;
   nsCOMPtr<nsIBaseWindow> mDocShellAsWin;
   nsCOMPtr<nsIWebNavigation> mDocShellAsNav;
   nsCOMPtr<nsIScrollable> mDocShellAsScrollable;
--- a/gfx/src/nsRect.cpp
+++ b/gfx/src/nsRect.cpp
@@ -10,25 +10,16 @@
 #include "nsMargin.h"                   // for nsMargin
 
 static_assert((int(NS_SIDE_TOP) == 0) &&
               (int(NS_SIDE_RIGHT) == 1) &&
               (int(NS_SIDE_BOTTOM) == 2) &&
               (int(NS_SIDE_LEFT) == 3),
               "The mozilla::css::Side sequence must match the nsMargin nscoord sequence");
 
-nsRect
-ToAppUnits(const mozilla::gfx::IntRect& aRect, nscoord aAppUnitsPerPixel)
-{
-  return nsRect(NSIntPixelsToAppUnits(aRect.x, aAppUnitsPerPixel),
-                NSIntPixelsToAppUnits(aRect.y, aAppUnitsPerPixel),
-                NSIntPixelsToAppUnits(aRect.width, aAppUnitsPerPixel),
-                NSIntPixelsToAppUnits(aRect.height, aAppUnitsPerPixel));
-}
-
 const mozilla::gfx::IntRect& GetMaxSizedIntRect() {
   static const mozilla::gfx::IntRect r(0, 0, INT32_MAX, INT32_MAX);
   return r;
 }
 
 #ifdef DEBUG
 // Diagnostics
 
--- a/gfx/src/nsRect.h
+++ b/gfx/src/nsRect.h
@@ -298,17 +298,24 @@ nsRect::RemoveResolution(const float aRe
   }
 
   return rect;
 }
 
 const mozilla::gfx::IntRect& GetMaxSizedIntRect();
 
 // app units are integer multiples of pixels, so no rounding needed
+template<class units>
 nsRect
-ToAppUnits(const mozilla::gfx::IntRect& aRect, nscoord aAppUnitsPerPixel);
+ToAppUnits(const mozilla::gfx::IntRectTyped<units>& aRect, nscoord aAppUnitsPerPixel)
+{
+  return nsRect(NSIntPixelsToAppUnits(aRect.x, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(aRect.y, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(aRect.width, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(aRect.height, aAppUnitsPerPixel));
+}
 
 #ifdef DEBUG
 // Diagnostics
 extern FILE* operator<<(FILE* out, const nsRect& rect);
 #endif // DEBUG
 
 #endif /* NSRECT_H */
--- a/view/nsView.cpp
+++ b/view/nsView.cpp
@@ -1057,17 +1057,17 @@ nsView::RequestWindowClose(nsIWidget* aW
 void
 nsView::WillPaintWindow(nsIWidget* aWidget)
 {
   RefPtr<nsViewManager> vm = mViewManager;
   vm->WillPaintWindow(aWidget);
 }
 
 bool
-nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion)
+nsView::PaintWindow(nsIWidget* aWidget, LayoutDeviceIntRegion aRegion)
 {
   NS_ASSERTION(this == nsView::GetViewFor(aWidget), "wrong view for widget?");
 
   RefPtr<nsViewManager> vm = mViewManager;
   bool result = vm->PaintWindow(aWidget, aRegion);
   return result;
 }
 
--- a/view/nsView.h
+++ b/view/nsView.h
@@ -54,16 +54,17 @@ enum nsViewVisibility {
  */
 
 class nsView final : public nsIWidgetListener
 {
 public:
   friend class nsViewManager;
 
   typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
+  typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
 
   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
 
   /**
    * Get the view manager which "owns" the view.
    * This method might require some expensive traversal work in the future. If you can get the
    * view manager from somewhere else, do that instead.
    * @result the view manager
@@ -377,17 +378,18 @@ public:
 
   // nsIWidgetListener
   virtual nsIPresShell* GetPresShell() override;
   virtual nsView* GetView() override { return this; }
   virtual bool WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y) override;
   virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight) override;
   virtual bool RequestWindowClose(nsIWidget* aWidget) override;
   virtual void WillPaintWindow(nsIWidget* aWidget) override;
-  virtual bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion) override;
+  virtual bool PaintWindow(nsIWidget* aWidget,
+                           LayoutDeviceIntRegion aRegion) override;
   virtual void DidPaintWindow() override;
   virtual void DidCompositeWindow(const mozilla::TimeStamp& aCompositeStart,
                                   const mozilla::TimeStamp& aCompositeEnd) override;
   virtual void RequestRepaint() override;
   virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent,
                                     bool aUseAttachedEvents) override;
 
   virtual ~nsView();
--- a/view/nsViewManager.cpp
+++ b/view/nsViewManager.cpp
@@ -276,26 +276,27 @@ nsView* nsViewManager::GetDisplayRootFor
   }
 }
 
 /**
    aRegion is given in device coordinates!!
    aContext may be null, in which case layers should be used for
    rendering.
 */
-void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion)
+void nsViewManager::Refresh(nsView* aView, const LayoutDeviceIntRegion& aRegion)
 {
   NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
 
   if (mPresShell && mPresShell->IsNeverPainting()) {
     return;
   }
 
   // damageRegion is the damaged area, in twips, relative to the view origin
   nsRegion damageRegion = aRegion.ToAppUnits(AppUnitsPerDevPixel());
+
   // move region from widget coordinates into view coordinates
   damageRegion.MoveBy(-aView->ViewToWidgetOffset());
 
   if (damageRegion.IsEmpty()) {
 #ifdef DEBUG_roc
     nsRect viewRect = aView->GetDimensions();
     nsRect damageRect = damageRegion.GetBounds();
     printf_stderr("XXX Damage rectangle (%d,%d,%d,%d) does not intersect the widget's view (%d,%d,%d,%d)!\n",
@@ -709,17 +710,18 @@ void nsViewManager::WillPaintWindow(nsIW
   }
 
   nsCOMPtr<nsIPresShell> shell = mPresShell;
   if (shell) {
     shell->WillPaintWindow();
   }
 }
 
-bool nsViewManager::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion)
+bool nsViewManager::PaintWindow(nsIWidget* aWidget,
+                                LayoutDeviceIntRegion aRegion)
 {
   if (!aWidget || !mContext)
     return false;
 
   NS_ASSERTION(IsPaintingAllowed(),
                "shouldn't be receiving paint events while painting is disallowed!");
 
   // Get the view pointer here since NS_WILL_PAINT might have
--- a/view/nsViewManager.h
+++ b/view/nsViewManager.h
@@ -23,16 +23,17 @@ class nsIPresShell;
 
 class nsViewManager final
 {
   ~nsViewManager();
 public:
   friend class nsView;
 
   typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
+  typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
 
   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
 
   NS_INLINE_DECL_REFCOUNTING(nsViewManager)
 
   nsViewManager();
 
   /**
@@ -341,17 +342,17 @@ private:
   void CallWillPaintOnObservers();
   void ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget);
   void ReparentWidgets(nsView* aView, nsView *aParent);
   void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion);
 
   void InvalidateViews(nsView *aView);
 
   // aView is the view for aWidget and aRegion is relative to aWidget.
-  void Refresh(nsView *aView, const nsIntRegion& aRegion);
+  void Refresh(nsView* aView, const LayoutDeviceIntRegion& aRegion);
 
   // Utilities
 
   bool IsViewInserted(nsView *aView);
 
   /**
    * Intersects aRect with aView's bounds and then transforms it from aView's
    * coordinate system to the coordinate system of the widget attached to
@@ -375,17 +376,17 @@ private:
   bool IsRootVM() const { return this == RootViewManager(); }
 
   // Whether synchronous painting is allowed at the moment. For example,
   // widget geometry changes can cause synchronous painting, so they need to
   // be deferred while refresh is disabled.
   bool IsPaintingAllowed() { return RootViewManager()->mRefreshDisableCount == 0; }
 
   void WillPaintWindow(nsIWidget* aWidget);
-  bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion);
+  bool PaintWindow(nsIWidget* aWidget, LayoutDeviceIntRegion aRegion);
   void DidPaintWindow();
 
   // Call this when you need to let the viewmanager know that it now has
   // pending updates.
   void PostPendingUpdate();
 
   RefPtr<nsDeviceContext> mContext;
   nsIPresShell   *mPresShell;
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -994,17 +994,17 @@ PuppetWidget::Paint()
         mTabChild->NotifyPainted();
       }
     } else {
       RefPtr<gfxContext> ctx = new gfxContext(mDrawTarget);
       ctx->Rectangle(gfxRect(0,0,0,0));
       ctx->Clip();
       AutoLayerManagerSetup setupLayerManager(this, ctx,
                                               BufferMode::BUFFER_NONE);
-      GetCurrentWidgetListener()->PaintWindow(this, region.ToUnknownRegion());
+      GetCurrentWidgetListener()->PaintWindow(this, region);
       if (mTabChild) {
         mTabChild->NotifyPainted();
       }
     }
   }
 
   if (GetCurrentWidgetListener()) {
     GetCurrentWidgetListener()->DidPaintWindow();
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -471,17 +471,17 @@ public:
                                                     uint32_t aAdditionalFlags,
                                                     nsIObserver* aObserver) override;
 
   // Mac specific methods
   
   virtual bool      DispatchWindowEvent(mozilla::WidgetGUIEvent& event);
 
   void WillPaintWindow();
-  bool PaintWindow(nsIntRegion aRegion);
+  bool PaintWindow(LayoutDeviceIntRegion aRegion);
 
 #ifdef ACCESSIBILITY
   already_AddRefed<mozilla::a11y::Accessible> GetDocumentAccessible();
 #endif
 
   virtual void CreateCompositor() override;
   virtual void PrepareWindowEffects() override;
   virtual void CleanupWindowEffects() override;
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1483,17 +1483,17 @@ void nsChildView::WillPaintWindow()
   nsCOMPtr<nsIWidget> widget = GetWidgetForListenerEvents();
 
   nsIWidgetListener* listener = widget->GetWidgetListener();
   if (listener) {
     listener->WillPaintWindow(widget);
   }
 }
 
-bool nsChildView::PaintWindow(nsIntRegion aRegion)
+bool nsChildView::PaintWindow(LayoutDeviceIntRegion aRegion)
 {
   nsCOMPtr<nsIWidget> widget = GetWidgetForListenerEvents();
 
   nsIWidgetListener* listener = widget->GetWidgetListener();
   if (!listener)
     return false;
 
   bool returnValue = false;
@@ -3751,20 +3751,20 @@ NSEvent* gLastDragMouseDownEvent = nil;
   }
   targetContext->Clip();
 
   nsAutoRetainCocoaObject kungFuDeathGrip(self);
   bool painted = false;
   if (mGeckoChild->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_BASIC) {
     nsBaseWidget::AutoLayerManagerSetup
       setupLayerManager(mGeckoChild, targetContext, BufferMode::BUFFER_NONE);
-    painted = mGeckoChild->PaintWindow(region.ToUnknownRegion());
+    painted = mGeckoChild->PaintWindow(region);
   } else if (mGeckoChild->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
     // We only need this so that we actually get DidPaintWindow fired
-    painted = mGeckoChild->PaintWindow(region.ToUnknownRegion());
+    painted = mGeckoChild->PaintWindow(region);
   }
 
   targetContext = nullptr;
   targetSurface = nullptr;
 
   CGContextRestoreGState(aContext);
 
   // Undo the scale transform so that from now on the context is in
@@ -3825,17 +3825,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
     return;
 
   mWaitingForPaint = NO;
 
   LayoutDeviceIntRect geckoBounds;
   mGeckoChild->GetBounds(geckoBounds);
   LayoutDeviceIntRegion region(geckoBounds);
 
-  mGeckoChild->PaintWindow(region.ToUnknownRegion());
+  mGeckoChild->PaintWindow(region);
 
   // Force OpenGL to refresh the very first time we draw. This works around a
   // Mac OS X bug that stops windows updating on OS X when we use OpenGL.
   if (!mDidForceRefreshOpenGL) {
     [self performSelector:@selector(forceRefreshOpenGL) withObject:nil afterDelay:0];
     mDidForceRefreshOpenGL = YES;
   }
 }
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2208,17 +2208,17 @@ nsWindow::OnExposeEvent(cairo_t *cr)
     }
 
     if (region.IsEmpty()) {
         return TRUE;
     }
 
     // If this widget uses OMTC...
     if (GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
-        listener->PaintWindow(this, region.ToUnknownRegion());
+        listener->PaintWindow(this, region);
         listener->DidPaintWindow();
         return TRUE;
     }
 
     RefPtr<DrawTarget> dt = GetDrawTarget(region.ToUnknownRegion());
     if (!dt) {
         return FALSE;
     }
@@ -2272,17 +2272,17 @@ nsWindow::OnExposeEvent(cairo_t *cr)
 #endif
 
 #endif // MOZ_X11
 
     bool painted = false;
     {
       if (GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_BASIC) {
         AutoLayerManagerSetup setupLayerManager(this, ctx, layerBuffering);
-        painted = listener->PaintWindow(this, region.ToUnknownRegion());
+        painted = listener->PaintWindow(this, region);
       }
     }
 
 #ifdef MOZ_X11
     // PaintWindow can Destroy us (bug 378273), avoid doing any paint
     // operations below if that happened - it will lead to XError and exit().
     if (shaped) {
         if (MOZ_LIKELY(!mIsDestroyed)) {
--- a/widget/nsIWidgetListener.cpp
+++ b/widget/nsIWidgetListener.cpp
@@ -91,17 +91,17 @@ nsIWidgetListener::RequestWindowClose(ns
 
 void
 nsIWidgetListener::WillPaintWindow(nsIWidget* aWidget)
 {
 }
 
 bool
 nsIWidgetListener::PaintWindow(nsIWidget* aWidget,
-                               nsIntRegion aRegion)
+                               LayoutDeviceIntRegion aRegion)
 {
   return false;
 }
 
 void
 nsIWidgetListener::DidPaintWindow()
 {
 }
--- a/widget/nsIWidgetListener.h
+++ b/widget/nsIWidgetListener.h
@@ -6,16 +6,17 @@
 #define nsIWidgetListener_h__
 
 #include <stdint.h>
 
 #include "mozilla/EventForwards.h"
 #include "mozilla/TimeStamp.h"
 
 #include "nsRegionFwd.h"
+#include "Units.h"
 
 class nsView;
 class nsIPresShell;
 class nsIWidget;
 class nsIXULWindow;
 
 /**
  * sizemode is an adjunct to widget size
@@ -123,17 +124,18 @@ public:
   virtual void WillPaintWindow(nsIWidget* aWidget);
 
   /**
    * Paint the specified region of the window. Returns true if the
    * notification was handled.
    * This is called at a time when it is not OK to change the geometry of
    * this widget or of other widgets.
    */
-  virtual bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion);
+  virtual bool PaintWindow(nsIWidget* aWidget,
+                           mozilla::LayoutDeviceIntRegion aRegion);
 
   /**
    * Indicates that a paint occurred.
    * This is called at a time when it is OK to change the geometry of
    * this widget or of other widgets.
    * Must be called after every call to PaintWindow.
    */
   virtual void DidPaintWindow();
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -870,17 +870,18 @@ nsWindow::OnPaint()
     if (!listener) {
         return;
     }
 
     listener->WillPaintWindow(this);
 
     switch (GetLayerManager()->GetBackendType()) {
         case mozilla::layers::LayersBackend::LAYERS_CLIENT: {
-            nsIntRegion region(nsIntRect(0, 0, mWidget->width(), mWidget->height()));
+            LayoutDeviceIntRegion region(
+              LayoutDeviceIntRect(0, 0, mWidget->width(), mWidget->height()));
             listener->PaintWindow(this, region);
             break;
         }
         default:
             NS_ERROR("Invalid layer manager");
     }
 
     listener->DidPaintWindow();
--- a/widget/uikit/nsWindow.h
+++ b/widget/uikit/nsWindow.h
@@ -86,17 +86,17 @@ public:
     NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
                              nsEventStatus& aStatus) override;
     NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener,
                                    bool aDoCapture) override {
         return NS_ERROR_NOT_IMPLEMENTED;
     }
 
     void WillPaintWindow();
-    bool PaintWindow(nsIntRegion aRegion);
+    bool PaintWindow(LayoutDeviceIntRegion aRegion);
 
     bool HasModalDescendents() { return false; }
 
     //NS_IMETHOD NotifyIME(const IMENotification& aIMENotification) override;
     NS_IMETHOD_(void) SetInputContext(
                         const InputContext& aContext,
                         const InputContextAction& aAction);
     NS_IMETHOD_(InputContext) GetInputContext();
--- a/widget/uikit/nsWindow.mm
+++ b/widget/uikit/nsWindow.mm
@@ -277,17 +277,17 @@ private:
     return;
 
   mWaitingForPaint = NO;
 
   LayoutDeviceIntRect geckoBounds;
   mGeckoChild->GetBounds(geckoBounds);
   LayoutDeviceIntRegion region(geckoBounds);
 
-  mGeckoChild->PaintWindow(region.ToUnknownRegion());
+  mGeckoChild->PaintWindow(region);
 }
 
 // Called asynchronously after setNeedsDisplay in order to avoid entering the
 // normal drawing machinery.
 - (void)drawUsingOpenGLCallback
 {
   if (mWaitingForPaint) {
     [self drawUsingOpenGL];
@@ -339,20 +339,21 @@ private:
   CGContextSaveGState(aContext);
   CGContextScaleCTM(aContext, 1.0 / scale, 1.0 / scale);
 
   CGSize viewSize = [self bounds].size;
   nsIntSize backingSize(viewSize.width * scale, viewSize.height * scale);
 
   CGContextSaveGState(aContext);
 
-  nsIntRegion region = nsIntRect(NSToIntRound(aRect.origin.x * scale),
-                                 NSToIntRound(aRect.origin.y * scale),
-                                 NSToIntRound(aRect.size.width * scale),
-                                 NSToIntRound(aRect.size.height * scale));
+  LayoutDeviceIntRegion region =
+    LayoutDeviceIntRect(NSToIntRound(aRect.origin.x * scale),
+                        NSToIntRound(aRect.origin.y * scale),
+                        NSToIntRound(aRect.size.width * scale),
+                        NSToIntRound(aRect.size.height * scale));
 
   // Create Cairo objects.
   RefPtr<gfxQuartzSurface> targetSurface;
 
   RefPtr<gfxContext> targetContext;
   if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BackendType::COREGRAPHICS)) {
     RefPtr<gfx::DrawTarget> dt =
       gfx::Factory::CreateDrawTargetForCairoCGContext(aContext,
@@ -371,20 +372,20 @@ private:
                                                                           backingSize.height));
     dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
     targetContext = new gfxContext(dt);
   } else {
     MOZ_ASSERT_UNREACHABLE("COREGRAPHICS is the only supported backed");
   }
 
   // Set up the clip region.
-  nsIntRegionRectIterator iter(region);
+  LayoutDeviceIntRegion::RectIterator iter(region);
   targetContext->NewPath();
   for (;;) {
-    const nsIntRect* r = iter.Next();
+    const LayoutDeviceIntRect* r = iter.Next();
     if (!r)
       break;
     targetContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height));
   }
   targetContext->Clip();
 
   //nsAutoRetainCocoaObject kungFuDeathGrip(self);
   bool painted = false;
@@ -725,17 +726,17 @@ nsWindow::SetFocus(bool aRaise)
 
 void nsWindow::WillPaintWindow()
 {
   if (mWidgetListener) {
     mWidgetListener->WillPaintWindow(this);
   }
 }
 
-bool nsWindow::PaintWindow(nsIntRegion aRegion)
+bool nsWindow::PaintWindow(LayoutDeviceIntRegion aRegion)
 {
   if (!mWidgetListener)
     return false;
 
   bool returnValue = false;
   returnValue = mWidgetListener->PaintWindow(this, aRegion);
 
   if (mWidgetListener) {
--- a/widget/windows/nsWindowGfx.cpp
+++ b/widget/windows/nsWindowGfx.cpp
@@ -401,18 +401,19 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t
             doubleBuffering = mozilla::layers::BufferMode::BUFFERED;
 #endif
           }
 
           RefPtr<gfxContext> thebesContext = new gfxContext(dt);
 
           {
             AutoLayerManagerSetup
-                setupLayerManager(this, thebesContext, doubleBuffering);
-            result = listener->PaintWindow(this, region);
+              setupLayerManager(this, thebesContext, doubleBuffering);
+            result = listener->PaintWindow(
+              this, LayoutDeviceIntRegion::FromUnknownRegion(region));
           }
 
 #ifdef MOZ_XUL
           if ((IsRenderMode(gfxWindowsPlatform::RENDER_GDI) ||
                IsRenderMode(gfxWindowsPlatform::RENDER_DIRECT2D))&&
               eTransparencyTransparent == mTransparencyMode) {
             // Data from offscreen drawing surface was copied to memory bitmap of transparent
             // bitmap. Now it can be read from memory bitmap to apply alpha channel and after
@@ -509,17 +510,18 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t
                             (BITMAPINFO*) &bi,
                             DIB_RGB_COLORS,
                             SRCCOPY);
             }
           }
         }
         break;
       case LayersBackend::LAYERS_CLIENT:
-        result = listener->PaintWindow(this, region);
+        result = listener->PaintWindow(
+          this, LayoutDeviceIntRegion::FromUnknownRegion(region));
         break;
       default:
         NS_ERROR("Unknown layers backend used!");
         break;
     }
   }
 
   if (!aDC) {