Bug 1155621 - Make nsIntRect and nsIntPoint typedefs of mozilla::gfx::IntRect and mozilla::gfx::IntPoint. r=Bas
authorNicolas Silva <nsilva@mozilla.com>
Tue, 21 Apr 2015 17:04:57 +0200
changeset 240295 7f2cb4c27f48b2afcdf78c711eb11eae36bf0db3
parent 240294 295890a566bdc852904f71755e4a0d1282df6500
child 240296 daea8a10009a34ec67789a3fc4db020a01afcc12
push id12503
push userkwierso@gmail.com
push dateTue, 21 Apr 2015 22:39:56 +0000
treeherderfx-team@376a1624b727 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1155621
milestone40.0a1
Bug 1155621 - Make nsIntRect and nsIntPoint typedefs of mozilla::gfx::IntRect and mozilla::gfx::IntPoint. r=Bas
accessible/base/nsCoreUtils.cpp
accessible/generic/Accessible.h
accessible/generic/HyperTextAccessible.cpp
accessible/ipc/PDocAccessible.ipdl
docshell/base/nsIContentViewer.idl
docshell/shistory/public/nsISHEntry.idl
dom/events/WheelHandlingHelper.h
dom/ipc/PBrowser.ipdl
dom/ipc/PPluginWidget.ipdl
dom/ipc/PScreenManager.ipdl
dom/ipc/TabChild.cpp
dom/media/VideoUtils.h
dom/media/wmf/DXVA2Manager.h
dom/plugins/base/nsPluginInstanceOwner.h
dom/plugins/ipc/PPluginInstance.ipdl
dom/plugins/ipc/PluginLibrary.h
dom/plugins/ipc/PluginUtilsOSX.h
gfx/2d/Rect.h
gfx/gl/GLTextureImage.cpp
gfx/gl/GLUploadHelpers.cpp
gfx/gl/GLUploadHelpers.h
gfx/gl/TextureImageEGL.cpp
gfx/ipc/GfxMessageUtils.h
gfx/layers/LayerTreeInvalidation.cpp
gfx/layers/LayerTreeInvalidation.h
gfx/layers/LayersLogging.h
gfx/layers/ReadbackLayer.h
gfx/layers/RotatedBuffer.cpp
gfx/layers/RotatedBuffer.h
gfx/layers/basic/BasicContainerLayer.cpp
gfx/layers/basic/BasicContainerLayer.h
gfx/layers/client/ClientTiledPaintedLayer.cpp
gfx/layers/composite/CanvasLayerComposite.cpp
gfx/layers/composite/CanvasLayerComposite.h
gfx/layers/composite/ColorLayerComposite.cpp
gfx/layers/composite/ColorLayerComposite.h
gfx/layers/composite/CompositableHost.h
gfx/layers/composite/ContainerLayerComposite.cpp
gfx/layers/composite/ContainerLayerComposite.h
gfx/layers/composite/ContentHost.cpp
gfx/layers/composite/ImageLayerComposite.cpp
gfx/layers/composite/ImageLayerComposite.h
gfx/layers/composite/PaintedLayerComposite.cpp
gfx/layers/composite/PaintedLayerComposite.h
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/composite/TiledContentHost.cpp
gfx/layers/composite/TiledContentHost.h
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d9/DeviceManagerD3D9.cpp
gfx/layers/d3d9/DeviceManagerD3D9.h
gfx/layers/ipc/CompositableForwarder.h
gfx/layers/ipc/CompositorParent.cpp
gfx/layers/ipc/CompositorParent.h
gfx/layers/ipc/ImageBridgeChild.cpp
gfx/layers/ipc/ImageBridgeChild.h
gfx/layers/ipc/LayersMessages.ipdlh
gfx/layers/ipc/LayersSurfaces.ipdlh
gfx/layers/ipc/PCompositor.ipdl
gfx/layers/ipc/ShadowLayers.cpp
gfx/layers/ipc/ShadowLayers.h
gfx/layers/opengl/GLBlitTextureImageHelper.cpp
gfx/layers/opengl/GLBlitTextureImageHelper.h
gfx/layers/opengl/OGLShaderProgram.h
gfx/layers/opengl/TextureHostOGL.cpp
gfx/layers/opengl/TextureHostOGL.h
gfx/src/nsPoint.h
gfx/src/nsRect.cpp
gfx/src/nsRect.h
gfx/src/nsRegion.h
gfx/thebes/gfx2DGlue.h
gfx/thebes/gfxASurface.h
gfx/thebes/gfxAlphaRecovery.h
gfx/thebes/gfxAlphaRecoverySSE2.cpp
gfx/thebes/gfxD2DSurface.cpp
gfx/thebes/gfxD2DSurface.h
gfx/thebes/gfxQtNativeRenderer.h
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
gfx/thebes/gfxXlibNativeRenderer.cpp
gfx/thebes/gfxXlibNativeRenderer.h
hal/sandbox/PHal.ipdl
image/src/Decoder.cpp
image/src/ImageOps.h
image/src/MultipartImage.cpp
image/src/ProgressTracker.cpp
image/src/RasterImage.cpp
image/src/SVGDocumentWrapper.cpp
image/src/VectorImage.cpp
image/src/imgFrame.cpp
image/src/imgRequestProxy.cpp
image/src/imgRequestProxy.h
layout/base/FrameLayerBuilder.cpp
layout/base/nsIPresShell.h
layout/base/nsPresShell.cpp
layout/generic/nsFrame.cpp
layout/generic/nsImageFrame.cpp
layout/svg/nsFilterInstance.cpp
layout/svg/nsISVGChildFrame.h
layout/svg/nsSVGContainerFrame.h
layout/svg/nsSVGFilterPaintCallback.h
layout/svg/nsSVGImageFrame.cpp
layout/svg/nsSVGIntegrationUtils.h
layout/svg/nsSVGPathGeometryFrame.h
layout/svg/nsSVGUtils.h
layout/tables/nsCellMap.h
layout/xul/BoxObject.h
layout/xul/PopupBoxObject.cpp
layout/xul/nsMenuPopupFrame.cpp
layout/xul/nsResizerFrame.cpp
layout/xul/nsSliderFrame.cpp
view/nsView.cpp
view/nsViewManager.cpp
widget/PuppetWidget.cpp
widget/android/AndroidDirectTexture.h
widget/android/AndroidGraphicBuffer.h
widget/cocoa/nsChildView.mm
widget/gonk/HwcComposer2D.cpp
widget/gonk/nsWindow.cpp
widget/gtk/nsNativeThemeGTK.cpp
widget/nsBaseDragService.cpp
widget/nsIPluginWidget.h
widget/nsIRollupListener.h
widget/qt/nsWindow.cpp
widget/windows/WinMouseScrollHandler.h
widget/windows/WinUtils.h
widget/windows/nsIMM32Handler.h
widget/windows/winrt/MetroInput.cpp
widget/windows/winrt/MetroInput.h
widget/windows/winrt/MetroUtils.h
xpfe/appshell/nsAppShellService.cpp
--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -295,17 +295,17 @@ nsCoreUtils::ScrollFrameToPoint(nsIFrame
                                 nsIFrame *aFrame,
                                 const nsIntPoint& aPoint)
 {
   nsIScrollableFrame* scrollableFrame = do_QueryFrame(aScrollableFrame);
   if (!scrollableFrame)
     return;
 
   nsPoint point =
-    aPoint.ToAppUnits(aFrame->PresContext()->AppUnitsPerDevPixel());
+    ToAppUnits(aPoint, aFrame->PresContext()->AppUnitsPerDevPixel());
   nsRect frameRect = aFrame->GetScreenRectInAppUnits();
   nsPoint deltaPoint(point.x - frameRect.x, point.y - frameRect.y);
 
   nsPoint scrollPoint = scrollableFrame->GetScrollPosition();
   scrollPoint -= deltaPoint;
 
   scrollableFrame->ScrollTo(scrollPoint, nsIScrollableFrame::INSTANT);
 }
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -10,23 +10,23 @@
 #include "mozilla/a11y/RelationType.h"
 #include "mozilla/a11y/Role.h"
 #include "mozilla/a11y/States.h"
 
 #include "nsIContent.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsRefPtrHashtable.h"
+#include "nsRect.h"
 
 struct nsRoleMapEntry;
 
 struct nsRect;
 class nsIFrame;
 class nsIAtom;
-struct nsIntRect;
 class nsIPersistentProperties;
 class nsView;
 
 namespace mozilla {
 namespace a11y {
 
 class Accessible;
 class AccEvent;
--- a/accessible/generic/HyperTextAccessible.cpp
+++ b/accessible/generic/HyperTextAccessible.cpp
@@ -1035,17 +1035,17 @@ HyperTextAccessible::OffsetAtPoint(int32
   if (!hyperFrame)
     return -1;
 
   nsIntPoint coords = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordType,
                                                         this);
 
   nsPresContext* presContext = mDoc->PresContext();
   nsPoint coordsInAppUnits =
-    coords.ToAppUnits(presContext->AppUnitsPerDevPixel());
+    ToAppUnits(coords, presContext->AppUnitsPerDevPixel());
 
   nsRect frameScreenRect = hyperFrame->GetScreenRectInAppUnits();
   if (!frameScreenRect.Contains(coordsInAppUnits.x, coordsInAppUnits.y))
     return -1; // Not found
 
   nsPoint pointInHyperText(coordsInAppUnits.x - frameScreenRect.x,
                            coordsInAppUnits.y - frameScreenRect.y);
 
@@ -1563,17 +1563,17 @@ HyperTextAccessible::ScrollSubstringToPo
                                                         this);
 
   nsRefPtr<nsRange> range = new nsRange(mContent);
   if (!OffsetsToDOMRange(aStartOffset, aEndOffset, range))
     return;
 
   nsPresContext* presContext = frame->PresContext();
   nsPoint coordsInAppUnits =
-    coords.ToAppUnits(presContext->AppUnitsPerDevPixel());
+    ToAppUnits(coords, presContext->AppUnitsPerDevPixel());
 
   bool initialScrolled = false;
   nsIFrame *parentFrame = frame;
   while ((parentFrame = parentFrame->GetParent())) {
     nsIScrollableFrame *scrollableFrame = do_QueryFrame(parentFrame);
     if (scrollableFrame) {
       if (!initialScrolled) {
         // Scroll substring to the given point. Turn the point into percents
--- a/accessible/ipc/PDocAccessible.ipdl
+++ b/accessible/ipc/PDocAccessible.ipdl
@@ -3,19 +3,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PContent;
 
 include "mozilla/GfxMessageUtils.h";
 
-using struct nsIntPoint from "nsRect.h";
-using struct nsIntRect from "nsRect.h";
+using nsIntRect from "nsRect.h";
 using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
+using mozilla::gfx::IntPoint from "mozilla/gfx/Point.h";
 
 namespace mozilla {
 namespace a11y {
 
 struct AccessibleData
 {
   uint64_t ID;
   uint32_t Role;
@@ -130,17 +130,17 @@ child:
     returns(bool aValid);
   prio(high) sync CutText(uint64_t aID, int32_t aStartPos, int32_t aEndPos)
     returns(bool aValid);
   prio(high) sync DeleteText(uint64_t aID, int32_t aStartPos, int32_t aEndPos)
     returns(bool aValid);
   prio(high) sync PasteText(uint64_t aID, int32_t aPosition)
     returns(bool aValid);
 
-  prio(high) sync ImagePosition(uint64_t aID, uint32_t aCoordType) returns(nsIntPoint aRetVal);
+  prio(high) sync ImagePosition(uint64_t aID, uint32_t aCoordType) returns(IntPoint aRetVal);
   prio(high) sync ImageSize(uint64_t aID) returns(IntSize aRetVal);
 
   prio(high) sync StartOffset(uint64_t aID) returns(uint32_t aRetVal, bool aOk);
   prio(high) sync EndOffset(uint64_t aID) returns(uint32_t aRetVal, bool aOk);
   prio(high) sync IsLinkValid(uint64_t aID) returns(bool aRetVal);
   prio(high) sync AnchorCount(uint64_t aID) returns(uint32_t aRetVal, bool aOk);
   prio(high) sync AnchorURIAt(uint64_t aID, uint32_t aIndex) returns(nsCString aURI, bool aOk);
   prio(high) sync AnchorAt(uint64_t aID, uint32_t aIndex) returns(uint64_t aIDOfAnchor, bool aOk);
--- a/docshell/base/nsIContentViewer.idl
+++ b/docshell/base/nsIContentViewer.idl
@@ -9,19 +9,19 @@ interface nsIDocument;
 interface nsIDOMDocument;
 interface nsIDOMNode;
 interface nsISHEntry;
 interface nsIPrintSettings;
 
 
 %{ C++
 #include "nsTArray.h"
+#include "nsRect.h"
 
 class nsIWidget;
-struct nsIntRect;
 class nsIPresShell;
 class nsPresContext;
 class nsView;
 class nsDOMNavigationTiming;
 %}
 
 [ptr] native nsIWidgetPtr(nsIWidget);
 [ref] native nsIntRectRef(nsIntRect);
--- a/docshell/shistory/public/nsISHEntry.idl
+++ b/docshell/shistory/public/nsISHEntry.idl
@@ -17,17 +17,17 @@ interface nsIContentViewer;
 interface nsIURI;
 interface nsIInputStream;
 interface nsIDocShellTreeItem;
 interface nsISupportsArray;
 interface nsIStructuredCloneContainer;
 interface nsIBFCacheEntry;
 
 %{C++
-struct nsIntRect;
+#include "nsRect.h"
 class nsDocShellEditorData;
 class nsSHEntryShared;
 %}
 [ref] native nsIntRect(nsIntRect);
 [ptr] native nsDocShellEditorDataPtr(nsDocShellEditorData);
 [ptr] native nsSHEntryShared(nsSHEntryShared);
 
 [scriptable, uuid(d5fbeb10-f373-4677-b69a-2694aa706cac)]
--- a/dom/events/WheelHandlingHelper.h
+++ b/dom/events/WheelHandlingHelper.h
@@ -6,22 +6,21 @@
 
 #ifndef mozilla_WheelHandlingHelper_h_
 #define mozilla_WheelHandlingHelper_h_
 
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
 #include "nsCoord.h"
 #include "nsIFrame.h"
+#include "nsPoint.h"
 
 class nsIScrollableFrame;
 class nsITimer;
 
-struct nsIntPoint;
-
 namespace mozilla {
 
 class EventStateManager;
 
 /**
  * DeltaValues stores two delta values which are along X and Y axis.  This is
  * useful for arguments and results of some methods.
  */
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -32,19 +32,19 @@ using struct mozilla::layers::Scrollable
 using struct mozilla::layers::ZoomConstraints from "FrameMetrics.h";
 using FrameMetrics::ViewID from "FrameMetrics.h";
 using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
 using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
 using nscolor from "nsColor.h";
 using class mozilla::WidgetCompositionEvent from "ipc/nsGUIEventIPC.h";
 using struct mozilla::widget::IMENotification from "nsIWidget.h";
 using struct nsIMEUpdatePreference from "nsIWidget.h";
-using struct nsIntPoint from "nsPoint.h";
-using struct nsIntRect from "nsRect.h";
 using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
+using mozilla::gfx::IntPoint from "mozilla/gfx/Point.h";
+using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
 using class mozilla::WidgetKeyboardEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetMouseEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetWheelEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetDragEvent from "ipc/nsGUIEventIPC.h";
 using struct nsRect from "nsRect.h";
 using class mozilla::WidgetSelectionEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetTouchEvent from "ipc/nsGUIEventIPC.h";
 using struct mozilla::dom::RemoteDOMEvent from "mozilla/dom/TabMessageUtils.h";
@@ -483,21 +483,21 @@ parent:
                                      double aDeltaX,
                                      double aDeltaY,
                                      double aDeltaZ,
                                      uint32_t aModifierFlags,
                                      uint32_t aAdditionalFlags,
                                      uint64_t aObserverId);
     SynthesizeNativeTouchPoint(uint32_t aPointerId,
                                TouchPointerState aPointerState,
-                               nsIntPoint aPointerScreenPoint,
+                               IntPoint aPointerScreenPoint,
                                double aPointerPressure,
                                uint32_t aPointerOrientation,
                                uint64_t aObserverId);
-    SynthesizeNativeTouchTap(nsIntPoint aPointerScreenPoint,
+    SynthesizeNativeTouchTap(IntPoint aPointerScreenPoint,
                              bool aLongTap,
                              uint64_t aObserverId);
     ClearNativeTouchSequence(uint64_t aObserverId);
 child:
     NativeSynthesisResponse(uint64_t aObserverId, nsCString aResponse);
 
 parent:
 
@@ -543,17 +543,17 @@ child:
          uint64_t layersId,
          nullable PRenderFrame renderFrame,
          bool parentIsActive);
 
     LoadURL(nsCString uri, BrowserConfiguration config);
 
     CacheFileDescriptor(nsString path, FileDescriptor fd);
 
-    UpdateDimensions(nsIntRect rect, ScreenIntSize size, ScreenOrientation orientation,
+    UpdateDimensions(IntRect rect, ScreenIntSize size, ScreenOrientation orientation,
                      LayoutDeviceIntPoint chromeDisp) compress;
 
     UpdateFrame(FrameMetrics frame);
 
     // The following methods correspond to functions on the GeckoContentController
     // interface in gfx/layers/apz/public/GeckoContentController.h. Refer to documentation
     // in that file for these functions.
     RequestFlingSnap(ViewID aScrollID, CSSPoint aDestination);
--- a/dom/ipc/PPluginWidget.ipdl
+++ b/dom/ipc/PPluginWidget.ipdl
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PBrowser;
 
 include "mozilla/GfxMessageUtils.h";
 
-using struct nsIntRect from "nsRect.h";
+using nsIntRect from "nsRect.h";
 
 namespace mozilla {
 namespace plugins {
 
 /**
  * PPluginWidget - a nsIWidget'ish protocol for windowed plugins in e10s.
  * On windows and linux we create native widgets in chrome which we then manage
  * from content.  On the content side there's PluginWidgetProxy which
--- a/dom/ipc/PScreenManager.ipdl
+++ b/dom/ipc/PScreenManager.ipdl
@@ -3,17 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PBrowser;
 include protocol PContent;
 
 include "mozilla/GfxMessageUtils.h";
 
-using struct nsIntRect from "nsRect.h";
+using nsIntRect from "nsRect.h";
 using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
 
 namespace mozilla {
 namespace dom {
 
 struct ScreenDetails {
   uint32_t id;
   nsIntRect rect;
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1080,17 +1080,17 @@ TabChild::Init()
 
   mWidget = nsIWidget::CreatePuppetWidget(this);
   if (!mWidget) {
     NS_ERROR("couldn't create fake widget");
     return NS_ERROR_FAILURE;
   }
   mWidget->Create(
     nullptr, 0,              // no parents
-    nsIntRect(nsIntPoint(0, 0), nsIntSize(0, 0)),
+    gfx::IntRect(gfx::IntPoint(0, 0), gfx::IntSize(0, 0)),
     nullptr                  // HandleWidgetEvent
   );
 
   baseWindow->InitWindow(0, mWidget, 0, 0, 0, 0);
   baseWindow->Create();
 
   NotifyTabContextUpdated();
 
@@ -3174,17 +3174,17 @@ TabChild::CreatePluginWidget(nsIWidget* 
     return NS_ERROR_UNEXPECTED;
   }
 
   nsWidgetInitData initData;
   initData.mWindowType = eWindowType_plugin_ipc_content;
   initData.mUnicode = false;
   initData.clipChildren = true;
   initData.clipSiblings = true;
-  nsresult rv = pluginWidget->Create(aParent, nullptr, nsIntRect(nsIntPoint(0, 0),
+  nsresult rv = pluginWidget->Create(aParent, nullptr, gfx::IntRect(gfx::IntPoint(0, 0),
                                      nsIntSize(0, 0)), &initData);
   if (NS_FAILED(rv)) {
     NS_WARNING("Creating native plugin widget on the chrome side failed.");
   }
   pluginWidget.forget(aOut);
   return rv;
 }
 
--- a/dom/media/VideoUtils.h
+++ b/dom/media/VideoUtils.h
@@ -7,34 +7,33 @@
 #ifndef VideoUtils_h
 #define VideoUtils_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "mozilla/CheckedInt.h"
 #include "nsIThread.h"
 #include "nsSize.h"
+#include "nsRect.h"
 
 #if !(defined(XP_WIN) || defined(XP_MACOSX) || defined(LINUX)) || \
     defined(MOZ_ASAN)
 // For MEDIA_THREAD_STACK_SIZE
 #include "nsIThreadManager.h"
 #endif
 #include "nsThreadUtils.h"
 #include "prtime.h"
 #include "AudioSampleFormat.h"
 #include "mozilla/RefPtr.h"
 
 using mozilla::CheckedInt64;
 using mozilla::CheckedUint64;
 using mozilla::CheckedInt32;
 using mozilla::CheckedUint32;
 
-struct nsIntRect;
-
 // This file contains stuff we'd rather put elsewhere, but which is
 // dependent on other changes which we don't want to wait for. We plan to
 // remove this file in the near future.
 
 
 // This belongs in xpcom/monitor/Monitor.h, once we've made
 // mozilla::Monitor non-reentrant.
 namespace mozilla {
--- a/dom/media/wmf/DXVA2Manager.h
+++ b/dom/media/wmf/DXVA2Manager.h
@@ -4,18 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #if !defined(DXVA2Manager_h_)
 #define DXVA2Manager_h_
 
 #include "WMF.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Mutex.h"
-
-struct nsIntRect;
+#include "nsRect.h"
 
 namespace mozilla {
 
 namespace layers {
 class Image;
 class ImageContainer;
 }
 
--- a/dom/plugins/base/nsPluginInstanceOwner.h
+++ b/dom/plugins/base/nsPluginInstanceOwner.h
@@ -19,17 +19,16 @@
 #include "gfxRect.h"
 
 #ifdef XP_MACOSX
 #include "mozilla/gfx/QuartzSupport.h"
 #include <ApplicationServices/ApplicationServices.h>
 #endif
 
 class nsIInputStream;
-struct nsIntRect;
 class nsPluginDOMContextMenuListener;
 class nsPluginFrame;
 class nsDisplayListBuilder;
 
 namespace mozilla {
 namespace dom {
 struct MozPluginParameter;
 }
--- a/dom/plugins/ipc/PPluginInstance.ipdl
+++ b/dom/plugins/ipc/PPluginInstance.ipdl
@@ -21,17 +21,17 @@ using NPNURLVariable from "npapi.h";
 using NPCoordinateSpace from "npapi.h";
 using NPNVariable from "npapi.h";
 using mozilla::plugins::NativeWindowHandle from "mozilla/plugins/PluginMessageUtils.h";
 using gfxSurfaceType from "gfxTypes.h";
 using gfxIntSize from "nsSize.h";
 using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
 using mozilla::plugins::WindowsSharedMemoryHandle from "mozilla/plugins/PluginMessageUtils.h";
 using mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h";
-using struct nsIntRect from "nsRect.h";
+using nsIntRect from "nsRect.h";
 
 namespace mozilla {
 namespace plugins {
 
 struct IOSurfaceDescriptor {
   uint32_t surfaceId;
   double contentsScaleFactor;
 };
--- a/dom/plugins/ipc/PluginLibrary.h
+++ b/dom/plugins/ipc/PluginLibrary.h
@@ -10,20 +10,20 @@
 #include "prlink.h"
 #include "npapi.h"
 #include "npfunctions.h"
 #include "nscore.h"
 #include "nsTArray.h"
 #include "nsError.h"
 #include "mozilla/EventForwards.h"
 #include "nsSize.h"
+#include "nsRect.h"
 
 class gfxContext;
 class nsCString;
-struct nsIntRect;
 class nsNPAPIPlugin;
 
 namespace mozilla {
 namespace layers {
 class Image;
 class ImageContainer;
 }
 }
--- a/dom/plugins/ipc/PluginUtilsOSX.h
+++ b/dom/plugins/ipc/PluginUtilsOSX.h
@@ -4,18 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef dom_plugins_PluginUtilsOSX_h
 #define dom_plugins_PluginUtilsOSX_h 1
 
 #include "npapi.h"
 #include "mozilla/gfx/QuartzSupport.h"
-
-struct nsIntRect;
+#include "nsRect.h"
 
 namespace mozilla {
 namespace plugins {
 namespace PluginUtilsOSX {
 
 // Need to call back into the browser's message loop to process event.
 typedef void (*RemoteProcessEvents) (void*);
 
--- a/gfx/2d/Rect.h
+++ b/gfx/2d/Rect.h
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_GFX_RECT_H_
 #define MOZILLA_GFX_RECT_H_
 
 #include "BaseRect.h"
 #include "BaseMargin.h"
+#include "NumericTools.h"
 #include "Point.h"
 #include "Tools.h"
 
 #include <cmath>
 
 namespace mozilla {
 
 template <typename> struct IsPixel;
@@ -100,16 +101,31 @@ struct IntRectTyped :
       return !xMost.isValid() || !yMost.isValid();
     }
 
     // This is here only to keep IPDL-generated code happy. DO NOT USE.
     bool operator==(const IntRectTyped<units>& aRect) const
     {
       return IntRectTyped<units>::IsEqualEdges(aRect);
     }
+
+    void InflateToMultiple(const IntSizeTyped<units>& aTileSize)
+    {
+      int32_t yMost = this->YMost();
+      int32_t xMost = this->XMost();
+
+      this->x = RoundDownToMultiple(this->x, aTileSize.width);
+      this->y = RoundDownToMultiple(this->y, aTileSize.height);
+      xMost = RoundUpToMultiple(xMost, aTileSize.width);
+      yMost = RoundUpToMultiple(yMost, aTileSize.height);
+
+      this->width = xMost - this->x;
+      this->height = yMost - this->y;
+    }
+
 };
 typedef IntRectTyped<UnknownUnits> IntRect;
 
 template<class units>
 struct RectTyped :
     public BaseRect<Float, RectTyped<units>, PointTyped<units>, SizeTyped<units>, MarginTyped<units> >,
     public units {
     static_assert(IsPixel<units>::value,
--- a/gfx/gl/GLTextureImage.cpp
+++ b/gfx/gl/GLTextureImage.cpp
@@ -74,17 +74,17 @@ TextureImage::Create(GLContext* gl,
 }
 
 bool
 TextureImage::UpdateFromDataSource(gfx::DataSourceSurface *aSurface,
                                    const nsIntRegion* aDestRegion,
                                    const gfx::IntPoint* aSrcPoint)
 {
     nsIntRegion destRegion = aDestRegion ? *aDestRegion
-                                         : nsIntRect(0, 0,
+                                         : IntRect(0, 0,
                                                      aSurface->GetSize().width,
                                                      aSurface->GetSize().height);
     gfx::IntPoint srcPoint = aSrcPoint ? *aSrcPoint
                                        : gfx::IntPoint(0, 0);
     return DirectUpdate(aSurface, destRegion, srcPoint);
 }
 
 gfx::IntRect TextureImage::GetTileRect() {
@@ -115,23 +115,23 @@ gfx::DrawTarget*
 BasicTextureImage::BeginUpdate(nsIntRegion& aRegion)
 {
     NS_ASSERTION(!mUpdateDrawTarget, "BeginUpdate() without EndUpdate()?");
 
     // determine the region the client will need to repaint
     if (CanUploadSubTextures(mGLContext)) {
         GetUpdateRegion(aRegion);
     } else {
-        aRegion = nsIntRect(nsIntPoint(0, 0), mSize);
+        aRegion = IntRect(IntPoint(0, 0), mSize);
     }
 
     mUpdateRegion = aRegion;
 
-    nsIntRect rgnSize = mUpdateRegion.GetBounds();
-    if (!nsIntRect(nsIntPoint(0, 0), mSize).Contains(rgnSize)) {
+    IntRect rgnSize = mUpdateRegion.GetBounds();
+    if (!IntRect(IntPoint(0, 0), mSize).Contains(rgnSize)) {
         NS_ERROR("update outside of image");
         return nullptr;
     }
 
     gfx::SurfaceFormat format =
         (GetContentType() == gfxContentType::COLOR) ?
         gfx::SurfaceFormat::B8G8R8X8 : gfx::SurfaceFormat::B8G8R8A8;
     mUpdateDrawTarget =
@@ -142,17 +142,17 @@ BasicTextureImage::BeginUpdate(nsIntRegi
 
 void
 BasicTextureImage::GetUpdateRegion(nsIntRegion& aForRegion)
 {
   // if the texture hasn't been initialized yet, or something important
   // changed, we need to recreate our backing surface and force the
   // client to paint everything
   if (mTextureState != Valid) {
-      aForRegion = nsIntRect(nsIntPoint(0, 0), mSize);
+      aForRegion = IntRect(IntPoint(0, 0), mSize);
   }
 }
 
 void
 BasicTextureImage::EndUpdate()
 {
     NS_ASSERTION(!!mUpdateDrawTarget, "EndUpdate() without BeginUpdate()?");
 
@@ -164,17 +164,17 @@ BasicTextureImage::EndUpdate()
     bool relative = FinishedSurfaceUpdate();
 
     mTextureFormat =
         UploadSurfaceToTexture(mGLContext,
                                updateData,
                                mUpdateRegion,
                                mTexture,
                                mTextureState == Created,
-                               mUpdateOffset,
+                               ToIntPoint(mUpdateOffset),
                                relative);
     FinishedSurfaceUpload();
 
     mUpdateDrawTarget = nullptr;
     mTextureState = Valid;
 }
 
 void
@@ -200,32 +200,32 @@ BasicTextureImage::FinishedSurfaceUpdate
 void
 BasicTextureImage::FinishedSurfaceUpload()
 {
 }
 
 bool
 BasicTextureImage::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom /* = gfx::IntPoint(0, 0) */)
 {
-    nsIntRect bounds = aRegion.GetBounds();
+    IntRect bounds = aRegion.GetBounds();
     nsIntRegion region;
     if (mTextureState != Valid) {
-        bounds = nsIntRect(0, 0, mSize.width, mSize.height);
+        bounds = IntRect(0, 0, mSize.width, mSize.height);
         region = nsIntRegion(bounds);
     } else {
         region = aRegion;
     }
 
     mTextureFormat =
         UploadSurfaceToTexture(mGLContext,
                                aSurf,
                                region,
                                mTexture,
                                mTextureState == Created,
-                               bounds.TopLeft() + nsIntPoint(aFrom.x, aFrom.y),
+                               bounds.TopLeft() + IntPoint(aFrom.x, aFrom.y),
                                false);
     mTextureState = Valid;
     return true;
 }
 
 void
 BasicTextureImage::Resize(const gfx::IntSize& aSize)
 {
@@ -340,27 +340,27 @@ TiledTextureImage::DirectUpdate(gfx::Dat
 {
     if (mSize.width == 0 || mSize.height == 0) {
         return true;
     }
 
     nsIntRegion region;
 
     if (mTextureState != Valid) {
-        nsIntRect bounds = nsIntRect(0, 0, mSize.width, mSize.height);
+        IntRect bounds = IntRect(0, 0, mSize.width, mSize.height);
         region = nsIntRegion(bounds);
     } else {
         region = aRegion;
     }
 
     bool result = true;
     int oldCurrentImage = mCurrentImage;
     BeginBigImageIteration();
     do {
-        nsIntRect tileRect = ThebesIntRect(GetSrcTileRect());
+        IntRect tileRect = ThebesIntRect(GetSrcTileRect());
         int xPos = tileRect.x;
         int yPos = tileRect.y;
 
         nsIntRegion tileRegion;
         tileRegion.And(region, tileRect); // intersect with tile
 
         if (tileRegion.IsEmpty())
             continue;
@@ -395,28 +395,28 @@ TiledTextureImage::DirectUpdate(gfx::Dat
 
 void
 TiledTextureImage::GetUpdateRegion(nsIntRegion& aForRegion)
 {
     if (mTextureState != Valid) {
         // if the texture hasn't been initialized yet, or something important
         // changed, we need to recreate our backing surface and force the
         // client to paint everything
-        aForRegion = nsIntRect(nsIntPoint(0, 0), mSize);
+        aForRegion = IntRect(IntPoint(0, 0), mSize);
         return;
     }
 
     nsIntRegion newRegion;
 
     // We need to query each texture with the region it will be drawing and
     // set aForRegion to be the combination of all of these regions
     for (unsigned i = 0; i < mImages.Length(); i++) {
         int xPos = (i % mColumns) * mTileSize;
         int yPos = (i / mColumns) * mTileSize;
-        nsIntRect imageRect = nsIntRect(nsIntPoint(xPos,yPos),
+        IntRect imageRect = IntRect(IntPoint(xPos,yPos),
                                         mImages[i]->GetSize());
 
         if (aForRegion.Intersects(imageRect)) {
             // Make a copy of the region
             nsIntRegion subRegion;
             subRegion.And(aForRegion, imageRect);
             // Translate it into tile-space
             subRegion.MoveBy(-xPos, -yPos);
@@ -441,26 +441,26 @@ TiledTextureImage::BeginUpdate(nsIntRegi
     // Note, we don't call GetUpdateRegion here as if the updated region is
     // fully contained in a single tile, we get to avoid iterating through
     // the tiles again (and a little copying).
     if (mTextureState != Valid)
     {
         // if the texture hasn't been initialized yet, or something important
         // changed, we need to recreate our backing surface and force the
         // client to paint everything
-        aRegion = nsIntRect(nsIntPoint(0, 0), mSize);
+        aRegion = IntRect(IntPoint(0, 0), mSize);
     }
 
-    nsIntRect bounds = aRegion.GetBounds();
+    IntRect bounds = aRegion.GetBounds();
 
     for (unsigned i = 0; i < mImages.Length(); i++) {
         int xPos = (i % mColumns) * mTileSize;
         int yPos = (i / mColumns) * mTileSize;
         nsIntRegion imageRegion =
-          nsIntRegion(nsIntRect(nsIntPoint(xPos,yPos),
+          nsIntRegion(IntRect(IntPoint(xPos,yPos),
                                 mImages[i]->GetSize()));
 
         // a single Image can handle this update request
         if (imageRegion.Contains(aRegion)) {
             // adjust for tile offset
             aRegion.MoveBy(-xPos, -yPos);
             // forward the actual call
             RefPtr<gfx::DrawTarget> drawTarget = mImages[i]->BeginUpdate(aRegion);
@@ -505,18 +505,17 @@ TiledTextureImage::EndUpdate()
 
     RefPtr<gfx::SourceSurface> updateSnapshot = mUpdateDrawTarget->Snapshot();
     RefPtr<gfx::DataSourceSurface> updateData = updateSnapshot->GetDataSurface();
 
     // upload tiles from temp surface
     for (unsigned i = 0; i < mImages.Length(); i++) {
         int xPos = (i % mColumns) * mTileSize;
         int yPos = (i / mColumns) * mTileSize;
-        nsIntRect imageRect = nsIntRect(nsIntPoint(xPos,yPos),
-                                        mImages[i]->GetSize());
+        IntRect imageRect = IntRect(IntPoint(xPos,yPos), mImages[i]->GetSize());
 
         nsIntRegion subregion;
         subregion.And(mUpdateRegion, imageRect);
         if (subregion.IsEmpty())
             continue;
         subregion.MoveBy(-xPos, -yPos); // Tile-local space
         // copy tile from temp target
         gfx::DrawTarget* drawTarget = mImages[i]->BeginUpdate(subregion);
--- a/gfx/gl/GLUploadHelpers.cpp
+++ b/gfx/gl/GLUploadHelpers.cpp
@@ -45,17 +45,17 @@ NextPowerOfTwo(int aNumber)
     aNumber |= aNumber >> 4;
     aNumber |= aNumber >> 8;
     aNumber |= aNumber >> 16;
     return ++aNumber;
 #endif
 }
 
 static unsigned int
-DataOffset(const nsIntPoint &aPoint, int32_t aStride, SurfaceFormat aFormat)
+DataOffset(const IntPoint &aPoint, int32_t aStride, SurfaceFormat aFormat)
 {
   unsigned int data = aPoint.y * aStride;
   data += aPoint.x * BytesPerPixel(aFormat);
   return data;
 }
 
 static GLint GetAddressAlignment(ptrdiff_t aAddress)
 {
@@ -497,20 +497,20 @@ UploadImageDataToTexture(GLContext* gl,
             // We don't have a specific luminance shader
             surfaceFormat = SurfaceFormat::A8;
             break;
         default:
             NS_ASSERTION(false, "Unhandled image surface format!");
     }
 
     nsIntRegionRectIterator iter(paintRegion);
-    const nsIntRect *iterRect;
+    const IntRect *iterRect;
 
     // Top left point of the region's bounding rectangle.
-    nsIntPoint topLeft = paintRegion.GetBounds().TopLeft();
+    IntPoint topLeft = paintRegion.GetBounds().TopLeft();
 
     while ((iterRect = iter.Next())) {
         // The inital data pointer is at the top left point of the region's
         // bounding rectangle. We need to find the offset of this rect
         // within the region and adjust the data pointer accordingly.
         unsigned char *rectData =
             aData + DataOffset(iterRect->TopLeft() - topLeft, aStride, aFormat);
 
@@ -551,17 +551,17 @@ UploadImageDataToTexture(GLContext* gl,
 }
 
 SurfaceFormat
 UploadSurfaceToTexture(GLContext* gl,
                        DataSourceSurface *aSurface,
                        const nsIntRegion& aDstRegion,
                        GLuint& aTexture,
                        bool aOverwrite,
-                       const nsIntPoint& aSrcPoint,
+                       const gfx::IntPoint& aSrcPoint,
                        bool aPixelBuffer,
                        GLenum aTextureUnit,
                        GLenum aTextureTarget)
 {
     unsigned char* data = aPixelBuffer ? nullptr : aSurface->GetData();
     int32_t stride = aSurface->Stride();
     SurfaceFormat format = aSurface->GetFormat();
     data += DataOffset(aSrcPoint, stride, format);
--- a/gfx/gl/GLUploadHelpers.h
+++ b/gfx/gl/GLUploadHelpers.h
@@ -69,17 +69,17 @@ UploadImageDataToTexture(GLContext* gl,
   * Convenience wrapper around UploadImageDataToTexture for gfx::DataSourceSurface's.
   */
 gfx::SurfaceFormat
 UploadSurfaceToTexture(GLContext* gl,
                        gfx::DataSourceSurface *aSurface,
                        const nsIntRegion& aDstRegion,
                        GLuint& aTexture,
                        bool aOverwrite = false,
-                       const nsIntPoint& aSrcPoint = nsIntPoint(0, 0),
+                       const gfx::IntPoint& aSrcPoint = gfx::IntPoint(0, 0),
                        bool aPixelBuffer = false,
                        GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
                        GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
 
 bool CanUploadSubTextures(GLContext* gl);
 bool CanUploadNonPowerOfTwo(GLContext* gl);
 
 }
--- a/gfx/gl/TextureImageEGL.cpp
+++ b/gfx/gl/TextureImageEGL.cpp
@@ -97,17 +97,17 @@ TextureImageEGL::~TextureImageEGL()
 }
 
 void
 TextureImageEGL::GetUpdateRegion(nsIntRegion& aForRegion)
 {
     if (mTextureState != Valid) {
         // if the texture hasn't been initialized yet, force the
         // client to paint everything
-        aForRegion = nsIntRect(nsIntPoint(0, 0), mSize);
+        aForRegion = gfx::IntRect(gfx::IntPoint(0, 0), mSize);
     }
 
     // We can only draw a rectangle, not subregions due to
     // the way that our texture upload functions work.  If
     // needed, we /could/ do multiple texture uploads if we have
     // non-overlapping rects, but that's a tradeoff.
     aForRegion = nsIntRegion(aForRegion.GetBounds());
 }
@@ -117,17 +117,17 @@ TextureImageEGL::BeginUpdate(nsIntRegion
 {
     NS_ASSERTION(!mUpdateDrawTarget, "BeginUpdate() without EndUpdate()?");
 
     // determine the region the client will need to repaint
     GetUpdateRegion(aRegion);
     mUpdateRect = aRegion.GetBounds();
 
     //printf_stderr("BeginUpdate with updateRect [%d %d %d %d]\n", mUpdateRect.x, mUpdateRect.y, mUpdateRect.width, mUpdateRect.height);
-    if (!nsIntRect(nsIntPoint(0, 0), mSize).Contains(mUpdateRect)) {
+    if (!gfx::IntRect(gfx::IntPoint(0, 0), mSize).Contains(mUpdateRect)) {
         NS_ERROR("update outside of image");
         return nullptr;
     }
 
     //printf_stderr("creating image surface %dx%d format %d\n", mUpdateRect.width, mUpdateRect.height, mUpdateFormat);
 
     mUpdateDrawTarget = gfx::Factory::CreateDrawTarget(gfx::BackendType::CAIRO,
                                                        gfx::IntSize(mUpdateRect.width, mUpdateRect.height),
@@ -193,33 +193,33 @@ TextureImageEGL::EndUpdate()
     mUpdateDrawTarget = nullptr;
     mTextureState = Valid;
     return;         // mTexture is bound
 }
 
 bool
 TextureImageEGL::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom /* = gfx::IntPoint(0,0) */)
 {
-    nsIntRect bounds = aRegion.GetBounds();
+    gfx::IntRect bounds = aRegion.GetBounds();
 
     nsIntRegion region;
     if (mTextureState != Valid) {
-        bounds = nsIntRect(0, 0, mSize.width, mSize.height);
+        bounds = gfx::IntRect(0, 0, mSize.width, mSize.height);
         region = nsIntRegion(bounds);
     } else {
         region = aRegion;
     }
 
     mTextureFormat =
       UploadSurfaceToTexture(mGLContext,
                              aSurf,
                              region,
                              mTexture,
                              mTextureState == Created,
-                             bounds.TopLeft() + nsIntPoint(aFrom.x, aFrom.y),
+                             bounds.TopLeft() + gfx::IntPoint(aFrom.x, aFrom.y),
                              false);
 
     mTextureState = Valid;
     return true;
 }
 
 void
 TextureImageEGL::BindTexture(GLenum aTextureUnit)
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -386,38 +386,16 @@ struct ParamTraits<mozilla::gfx::IntSize
 
   static bool Read(const Message* msg, void** iter, paramType* result)
   {
     return (ReadParam(msg, iter, &result->width) &&
             ReadParam(msg, iter, &result->height));
   }
 };
 
-template<>
-struct ParamTraits<nsIntRect>
-{
-  typedef nsIntRect paramType;
-
-  static void Write(Message* msg, const paramType& param)
-  {
-    WriteParam(msg, param.x);
-    WriteParam(msg, param.y);
-    WriteParam(msg, param.width);
-    WriteParam(msg, param.height);
-  }
-
-  static bool Read(const Message* msg, void** iter, paramType* result)
-  {
-    return (ReadParam(msg, iter, &result->x) &&
-            ReadParam(msg, iter, &result->y) &&
-            ReadParam(msg, iter, &result->width) &&
-            ReadParam(msg, iter, &result->height));
-  }
-};
-
 template<typename Region, typename Rect, typename Iter>
 struct RegionParamTraits
 {
   typedef Region paramType;
 
   static void Write(Message* msg, const paramType& param)
   {
     Iter it(param);
--- a/gfx/layers/LayerTreeInvalidation.cpp
+++ b/gfx/layers/LayerTreeInvalidation.cpp
@@ -16,52 +16,51 @@
 #include "mozilla/gfx/BaseSize.h"       // for BaseSize
 #include "mozilla/gfx/Point.h"          // for IntSize
 #include "mozilla/mozalloc.h"           // for operator new, etc
 #include "nsAutoPtr.h"                  // for nsRefPtr, nsAutoPtr, etc
 #include "nsDataHashtable.h"            // for nsDataHashtable
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsHashKeys.h"                 // for nsPtrHashKey
 #include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
+#include "nsRect.h"                     // for IntRect
 #include "nsTArray.h"                   // for nsAutoTArray, nsTArray_Impl
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 struct LayerPropertiesBase;
 UniquePtr<LayerPropertiesBase> CloneLayerTreePropertiesInternal(Layer* aRoot, bool aIsMask = false);
 
-static nsIntRect
-TransformRect(const nsIntRect& aRect, const Matrix4x4& aTransform)
+static IntRect
+TransformRect(const IntRect& aRect, const Matrix4x4& aTransform)
 {
   if (aRect.IsEmpty()) {
-    return nsIntRect();
+    return IntRect();
   }
 
   Rect rect(aRect.x, aRect.y, aRect.width, aRect.height);
   rect = aTransform.TransformBounds(rect);
   rect.RoundOut();
 
-  nsIntRect intRect;
+  IntRect intRect;
   if (!gfxUtils::GfxRectToIntRect(ThebesRect(rect), &intRect)) {
-    return nsIntRect();
+    return IntRect();
   }
 
   return intRect;
 }
 
 static void
 AddTransformedRegion(nsIntRegion& aDest, const nsIntRegion& aSource, const Matrix4x4& aTransform)
 {
   nsIntRegionRectIterator iter(aSource);
-  const nsIntRect *r;
+  const IntRect *r;
   while ((r = iter.Next())) {
     aDest.Or(aDest, TransformRect(*r, aTransform));
   }
   aDest.SimplifyOutward(20);
 }
 
 static void
 AddRegion(nsIntRegion& aDest, const nsIntRegion& aSource)
@@ -122,22 +121,22 @@ struct LayerPropertiesBase : public Laye
     , mMaskLayer(nullptr)
   {
     MOZ_COUNT_CTOR(LayerPropertiesBase);
   }
   ~LayerPropertiesBase()
   {
     MOZ_COUNT_DTOR(LayerPropertiesBase);
   }
-  
-  virtual nsIntRegion ComputeDifferences(Layer* aRoot, 
+
+  virtual nsIntRegion ComputeDifferences(Layer* aRoot,
                                          NotifySubDocInvalidationFunc aCallback,
                                          bool* aGeometryChanged);
 
-  virtual void MoveBy(const nsIntPoint& aOffset);
+  virtual void MoveBy(const IntPoint& aOffset);
 
   nsIntRegion ComputeChange(NotifySubDocInvalidationFunc aCallback,
                             bool& aGeometryChanged)
   {
     bool transformChanged = !mTransform.FuzzyEqual(mLayer->GetLocalTransform()) ||
                             mLayer->GetPostXScale() != mPostXScale ||
                             mLayer->GetPostYScale() != mPostYScale;
     Layer* otherMask = mLayer->GetMaskLayer();
@@ -171,30 +170,30 @@ struct LayerPropertiesBase : public Laye
         AddRegion(result, tmp);
       }
     }
 
     mLayer->ClearInvalidRect();
     return result;
   }
 
-  nsIntRect NewTransformedBounds()
+  IntRect NewTransformedBounds()
   {
     return TransformRect(mLayer->GetVisibleRegion().GetBounds(), mLayer->GetLocalTransform());
   }
 
-  nsIntRect OldTransformedBounds()
+  IntRect OldTransformedBounds()
   {
     return TransformRect(mVisibleRegion.GetBounds(), mTransform);
   }
 
   virtual nsIntRegion ComputeChangeInternal(NotifySubDocInvalidationFunc aCallback,
                                             bool& aGeometryChanged)
   {
-    return nsIntRect();
+    return IntRect();
   }
 
   nsRefPtr<Layer> mLayer;
   UniquePtr<LayerPropertiesBase> mMaskLayer;
   nsIntRegion mVisibleRegion;
   nsIntRegion mInvalidRegion;
   Matrix4x4 mTransform;
   float mPostXScale;
@@ -346,17 +345,17 @@ struct ColorLayerProperties : public Lay
 
     nsIntRegion result;
     AddTransformedRegion(result, boundsDiff, mTransform);
 
     return result;
   }
 
   gfxRGBA mColor;
-  nsIntRect mBounds;
+  IntRect mBounds;
 };
 
 struct ImageLayerProperties : public LayerPropertiesBase
 {
   explicit ImageLayerProperties(ImageLayer* aImage, bool aIsMask)
     : LayerPropertiesBase(aImage)
     , mContainer(aImage->GetContainer())
     , mFilter(aImage->GetFilter())
@@ -368,41 +367,41 @@ struct ImageLayerProperties : public Lay
 
   virtual nsIntRegion ComputeChangeInternal(NotifySubDocInvalidationFunc aCallback,
                                             bool& aGeometryChanged)
   {
     ImageLayer* imageLayer = static_cast<ImageLayer*>(mLayer.get());
     
     if (!imageLayer->GetVisibleRegion().IsEqual(mVisibleRegion)) {
       aGeometryChanged = true;
-      nsIntRect result = NewTransformedBounds();
+      IntRect result = NewTransformedBounds();
       result = result.Union(OldTransformedBounds());
       return result;
     }
 
     ImageContainer* container = imageLayer->GetContainer();
     if (mContainer != container ||
         mFilter != imageLayer->GetFilter() ||
         mScaleToSize != imageLayer->GetScaleToSize() ||
         mScaleMode != imageLayer->GetScaleMode()) {
       aGeometryChanged = true;
 
       if (mIsMask) {
         // Mask layers have an empty visible region, so we have to
         // use the image size instead.
         IntSize size = container->GetCurrentSize();
-        nsIntRect rect(0, 0, size.width, size.height);
+        IntRect rect(0, 0, size.width, size.height);
         return TransformRect(rect, mLayer->GetLocalTransform());
 
       } else {
         return NewTransformedBounds();
       }
     }
 
-    return nsIntRect();
+    return IntRect();
   }
 
   nsRefPtr<ImageContainer> mContainer;
   GraphicsFilter mFilter;
   gfx::IntSize mScaleToSize;
   ScaleMode mScaleMode;
   bool mIsMask;
 };
@@ -461,17 +460,17 @@ LayerPropertiesBase::ComputeDifferences(
 {
   NS_ASSERTION(aRoot, "Must have a layer tree to compare against!");
   if (mLayer != aRoot) {
     if (aCallback) {
       NotifySubdocumentInvalidationRecursive(aRoot, aCallback);
     } else {
       ClearInvalidations(aRoot);
     }
-    nsIntRect result = TransformRect(aRoot->GetVisibleRegion().GetBounds(),
+    IntRect result = TransformRect(aRoot->GetVisibleRegion().GetBounds(),
                                      aRoot->GetLocalTransform());
     result = result.Union(OldTransformedBounds());
     if (aGeometryChanged != nullptr) {
       *aGeometryChanged = true;
     }
     return result;
   } else {
     bool geometryChanged = (aGeometryChanged != nullptr) ? *aGeometryChanged : false;
@@ -479,15 +478,15 @@ LayerPropertiesBase::ComputeDifferences(
     if (aGeometryChanged != nullptr) {
       *aGeometryChanged = geometryChanged;
     }
     return invalid;
   }
 }
 
 void
-LayerPropertiesBase::MoveBy(const nsIntPoint& aOffset)
+LayerPropertiesBase::MoveBy(const IntPoint& aOffset)
 {
   mTransform.PostTranslate(aOffset.x, aOffset.y, 0);
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/LayerTreeInvalidation.h
+++ b/gfx/layers/LayerTreeInvalidation.h
@@ -3,19 +3,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_LAYER_TREE_INVALIDATION_H
 #define GFX_LAYER_TREE_INVALIDATION_H
 
 #include "nsRegion.h"                   // for nsIntRegion
 #include "mozilla/UniquePtr.h"          // for UniquePtr
+#include "mozilla/gfx/Point.h"
 
 class nsPresContext;
-struct nsIntPoint;
 
 namespace mozilla {
 namespace layers {
 
 class Layer;
 class ContainerLayer;
 
 /**
@@ -54,20 +54,19 @@ struct LayerProperties
    * Compares a set of existing layer tree properties to the current layer
    * tree and generates the changed rectangle.
    *
    * @param aRoot Root layer of the layer tree to compare against.
    * @param aCallback If specified, callback to call when ContainerLayers
    * are invalidated.
    * @return Painted area changed by the layer tree changes.
    */
-  virtual nsIntRegion ComputeDifferences(Layer* aRoot, 
+  virtual nsIntRegion ComputeDifferences(Layer* aRoot,
                                          NotifySubDocInvalidationFunc aCallback,
                                          bool* aGeometryChanged = nullptr) = 0;
-  
-  
-  virtual void MoveBy(const nsIntPoint& aOffset) = 0;
+
+  virtual void MoveBy(const gfx::IntPoint& aOffset) = 0;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif /* GFX_LAYER_TREE_INVALIDATON_H */
--- a/gfx/layers/LayersLogging.h
+++ b/gfx/layers/LayersLogging.h
@@ -12,18 +12,16 @@
 #include "mozilla/gfx/Types.h"          // for Filter, SurfaceFormat
 #include "mozilla/layers/CompositorTypes.h"  // for TextureFlags
 #include "nsAString.h"
 #include "nsPrintfCString.h"            // for nsPrintfCString
 #include "nsRegion.h"                   // for nsRegion, nsIntRegion
 #include "nscore.h"                     // for nsACString, etc
 
 struct gfxRGBA;
-struct nsIntPoint;
-struct nsIntRect;
 
 namespace mozilla {
 namespace gfx {
 class Matrix4x4;
 template <class units> struct RectTyped;
 }
 
 namespace layers {
@@ -47,40 +45,32 @@ AppendToString(std::stringstream& aStrea
 void
 AppendToString(std::stringstream& aStream, const nsPoint& p,
                const char* pfx="", const char* sfx="");
 
 void
 AppendToString(std::stringstream& aStream, const nsRect& r,
                const char* pfx="", const char* sfx="");
 
-void
-AppendToString(std::stringstream& aStream, const nsIntPoint& p,
-               const char* pfx="", const char* sfx="");
-
 template<class T>
 void
 AppendToString(std::stringstream& aStream, const mozilla::gfx::PointTyped<T>& p,
                const char* pfx="", const char* sfx="")
 {
   aStream << pfx << p << sfx;
 }
 
 template<class T>
 void
 AppendToString(std::stringstream& aStream, const mozilla::gfx::IntPointTyped<T>& p,
                const char* pfx="", const char* sfx="")
 {
   aStream << pfx << p << sfx;
 }
 
-void
-AppendToString(std::stringstream& aStream, const nsIntRect& r,
-               const char* pfx="", const char* sfx="");
-
 template<class T>
 void
 AppendToString(std::stringstream& aStream, const mozilla::gfx::RectTyped<T>& r,
                const char* pfx="", const char* sfx="")
 {
   aStream << pfx;
   aStream << nsPrintfCString(
     "(x=%f, y=%f, w=%f, h=%f)",
--- a/gfx/layers/ReadbackLayer.h
+++ b/gfx/layers/ReadbackLayer.h
@@ -4,24 +4,23 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_READBACKLAYER_H
 #define GFX_READBACKLAYER_H
 
 #include <stdint.h>                     // for uint64_t
 #include "Layers.h"                     // for Layer, etc
 #include "gfxColor.h"                   // for gfxRGBA
-#include "gfxRect.h"                    // for gfxRect
+#include "mozilla/gfx/Rect.h"                    // for gfxRect
+#include "mozilla/gfx/Point.h"                    // for gfxRect
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAutoPtr.h"                  // for nsAutoPtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
 #include "nscore.h"                     // for nsACString
 
 class gfxContext;
 
 namespace mozilla {
 namespace layers {
 
 class ReadbackProcessor;
@@ -56,24 +55,24 @@ public:
    * set up to clip to aRect. Zero should never be passed as a sequence number.
    * If this returns null, EndUpdate should NOT be called. If it returns
    * non-null, EndUpdate must be called.
    *
    * We don't support partially unknown backgrounds. Therefore, the
    * first BeginUpdate after a SetUnknown will have the complete background.
    */
   virtual already_AddRefed<gfxContext>
-      BeginUpdate(const nsIntRect& aRect, uint64_t aSequenceNumber) = 0;
+      BeginUpdate(const gfx::IntRect& aRect, uint64_t aSequenceNumber) = 0;
   /**
    * EndUpdate must be called immediately after BeginUpdate, without returning
    * to the event loop.
    * @param aContext the context returned by BeginUpdate
    * Implicitly Restore()s the state of aContext.
    */
-  virtual void EndUpdate(gfxContext* aContext, const nsIntRect& aRect) = 0;
+  virtual void EndUpdate(gfxContext* aContext, const gfx::IntRect& aRect) = 0;
 };
 
 /**
  * A ReadbackLayer never renders anything. It enables clients to extract
  * the rendered contents of the layer tree below the ReadbackLayer.
  * The rendered contents are delivered asynchronously via calls to a
  * ReadbackSink object supplied by the client.
  *
@@ -117,23 +116,23 @@ public:
   ReadbackSink* GetSink() { return mSink; }
 
   /**
    * CONSTRUCTION PHASE ONLY
    * Set the size of content that should be read back. The readback area
    * has its top-left at 0,0 and has size aSize.
    * Can only be called while the sink is null!
    */
-  void SetSize(const nsIntSize& aSize)
+  void SetSize(const gfx::IntSize& aSize)
   {
     NS_ASSERTION(!mSink, "Should have no sink while changing size!");
     mSize = aSize;
   }
-  const nsIntSize& GetSize() { return mSize; }
-  nsIntRect GetRect() { return nsIntRect(nsIntPoint(0, 0), mSize); }
+  const gfx::IntSize& GetSize() { return mSize; }
+  gfx::IntRect GetRect() { return gfx::IntRect(gfx::IntPoint(0, 0), mSize); }
 
   bool IsBackgroundKnown()
   {
     return mBackgroundLayer || mBackgroundColor.a == 1.0;
   }
 
   void NotifyRemoved() {
     SetUnknown();
@@ -175,17 +174,17 @@ protected:
   {}
 
   virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
 
   virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
 
   uint64_t mSequenceCounter;
   nsAutoPtr<ReadbackSink> mSink;
-  nsIntSize mSize;
+  gfx::IntSize mSize;
 
   // This can refer to any (earlier) sibling PaintedLayer. That PaintedLayer
   // must have mUsedForReadback set on it. If the PaintedLayer is removed
   // for the container, this will be set to null by NotifyPaintedLayerRemoved.
   // This PaintedLayer contains the contents which have previously been reported
   // to mSink. The PaintedLayer had only an integer translation transform,
   // and it covered the entire readback area. This layer also had only an
   // integer translation transform.
--- a/gfx/layers/RotatedBuffer.cpp
+++ b/gfx/layers/RotatedBuffer.cpp
@@ -29,22 +29,22 @@
 #include "nsLayoutUtils.h"              // for invalidation debugging
 
 namespace mozilla {
 
 using namespace gfx;
 
 namespace layers {
 
-nsIntRect
+IntRect
 RotatedBuffer::GetQuadrantRectangle(XSide aXSide, YSide aYSide) const
 {
   // quadrantTranslation is the amount we translate the top-left
   // of the quadrant by to get coordinates relative to the layer
-  nsIntPoint quadrantTranslation = -mBufferRotation;
+  IntPoint quadrantTranslation = -mBufferRotation;
   quadrantTranslation.x += aXSide == LEFT ? mBufferRect.width : 0;
   quadrantTranslation.y += aYSide == TOP ? mBufferRect.height : 0;
   return mBufferRect + quadrantTranslation;
 }
 
 Rect
 RotatedBuffer::GetSourceRectangle(XSide aXSide, YSide aYSide) const
 {
@@ -84,18 +84,18 @@ RotatedBuffer::DrawBufferQuadrant(gfx::D
                                   gfx::CompositionOp aOperator,
                                   gfx::SourceSurface* aMask,
                                   const gfx::Matrix* aMaskTransform) const
 {
   // The rectangle that we're going to fill. Basically we're going to
   // render the buffer at mBufferRect + quadrantTranslation to get the
   // pixels in the right place, but we're only going to paint within
   // mBufferRect
-  nsIntRect quadrantRect = GetQuadrantRectangle(aXSide, aYSide);
-  nsIntRect fillRect;
+  IntRect quadrantRect = GetQuadrantRectangle(aXSide, aYSide);
+  IntRect fillRect;
   if (!fillRect.IntersectRect(mBufferRect, quadrantRect))
     return;
 
   gfx::Point quadrantTranslation(quadrantRect.x, quadrantRect.y);
 
   MOZ_ASSERT(aSource != BUFFER_BOTH);
   RefPtr<SourceSurface> snapshot = GetSourceSurface(aSource);
 
@@ -236,30 +236,30 @@ RotatedContentBuffer::DrawTo(PaintedLaye
 
   DrawBufferWithRotation(aTarget, BUFFER_BLACK, aOpacity, aOp, aMask, aMaskTransform);
   if (clipped) {
     aTarget->PopClip();
   }
 }
 
 DrawTarget*
-RotatedContentBuffer::BorrowDrawTargetForQuadrantUpdate(const nsIntRect& aBounds,
+RotatedContentBuffer::BorrowDrawTargetForQuadrantUpdate(const IntRect& aBounds,
                                                         ContextSource aSource,
                                                         DrawIterator* aIter)
 {
-  nsIntRect bounds = aBounds;
+  IntRect bounds = aBounds;
   if (aIter) {
     // If an iterator was provided, then BeginPaint must have been run with
     // PAINT_CAN_DRAW_ROTATED, and the draw region might cover multiple quadrants.
     // Iterate over each of them, and return an appropriate buffer each time we find
     // one that intersects the draw region. The iterator mCount value tracks which
     // quadrants we have considered across multiple calls to this function.
     aIter->mDrawRegion.SetEmpty();
     while (aIter->mCount < 4) {
-      nsIntRect quadrant = GetQuadrantRectangle((aIter->mCount & 1) ? LEFT : RIGHT,
+      IntRect quadrant = GetQuadrantRectangle((aIter->mCount & 1) ? LEFT : RIGHT,
         (aIter->mCount & 2) ? TOP : BOTTOM);
       aIter->mDrawRegion.And(aBounds, quadrant);
       aIter->mCount++;
       if (!aIter->mDrawRegion.IsEmpty()) {
         break;
       }
     }
     if (aIter->mDrawRegion.IsEmpty()) {
@@ -289,17 +289,17 @@ RotatedContentBuffer::BorrowDrawTargetFo
     mLoanedDrawTarget = mDTBuffer;
   }
 
   // Figure out which quadrant to draw in
   int32_t xBoundary = mBufferRect.XMost() - mBufferRotation.x;
   int32_t yBoundary = mBufferRect.YMost() - mBufferRotation.y;
   XSide sideX = bounds.XMost() <= xBoundary ? RIGHT : LEFT;
   YSide sideY = bounds.YMost() <= yBoundary ? BOTTOM : TOP;
-  nsIntRect quadrantRect = GetQuadrantRectangle(sideX, sideY);
+  IntRect quadrantRect = GetQuadrantRectangle(sideX, sideY);
   NS_ASSERTION(quadrantRect.Contains(bounds), "Messed up quadrants");
 
   mLoanedTransform = mLoanedDrawTarget->GetTransform();
   mLoanedDrawTarget->SetTransform(Matrix(mLoanedTransform).
                                     PreTranslate(-quadrantRect.x,
                                                  -quadrantRect.y));
 
   return mLoanedDrawTarget;
@@ -385,20 +385,20 @@ WrapRotationAxis(int32_t* aRotationPoint
 {
   if (*aRotationPoint < 0) {
     *aRotationPoint += aSize;
   } else if (*aRotationPoint >= aSize) {
     *aRotationPoint -= aSize;
   }
 }
 
-static nsIntRect
-ComputeBufferRect(const nsIntRect& aRequestedRect)
+static IntRect
+ComputeBufferRect(const IntRect& aRequestedRect)
 {
-  nsIntRect rect(aRequestedRect);
+  IntRect rect(aRequestedRect);
   // Set a minimum width to guarantee a minimum size of buffers we
   // allocate (and work around problems on some platforms with smaller
   // dimensions).  64 is the magic number needed to work around the
   // rendering glitch, and guarantees image rows can be SIMD'd for
   // even r5g6b5 surfaces pretty much everywhere.
   rect.width = std::max(aRequestedRect.width, 64);
 #ifdef MOZ_WIDGET_GONK
   // Set a minumum height to guarantee a minumum height of buffers we
@@ -442,34 +442,34 @@ RotatedContentBuffer::BeginPaint(Painted
 
   bool canUseOpaqueSurface = aLayer->CanUseOpaqueSurface();
   ContentType layerContentType =
     canUseOpaqueSurface ? gfxContentType::COLOR :
                           gfxContentType::COLOR_ALPHA;
 
   SurfaceMode mode;
   nsIntRegion neededRegion;
-  nsIntRect destBufferRect;
+  IntRect destBufferRect;
 
   bool canReuseBuffer = HaveBuffer();
 
   while (true) {
     mode = aLayer->GetSurfaceMode();
     neededRegion = aLayer->GetVisibleRegion();
     canReuseBuffer &= BufferSizeOkFor(neededRegion.GetBounds().Size());
     result.mContentType = layerContentType;
 
     if (canReuseBuffer) {
       if (mBufferRect.Contains(neededRegion.GetBounds())) {
         // We don't need to adjust mBufferRect.
         destBufferRect = mBufferRect;
       } else if (neededRegion.GetBounds().Size() <= mBufferRect.Size()) {
         // The buffer's big enough but doesn't contain everything that's
         // going to be visible. We'll move it.
-        destBufferRect = nsIntRect(neededRegion.GetBounds().TopLeft(), mBufferRect.Size());
+        destBufferRect = IntRect(neededRegion.GetBounds().TopLeft(), mBufferRect.Size());
       } else {
         destBufferRect = neededRegion.GetBounds();
       }
     } else {
       // We won't be reusing the buffer.  Compute a new rect.
       destBufferRect = ComputeBufferRect(neededRegion.GetBounds());
     }
 
@@ -550,61 +550,59 @@ RotatedContentBuffer::BeginPaint(Painted
 
   if (HaveBuffer()) {
     // Do not modify result.mRegionToDraw or result.mContentType after this call.
     // Do not modify mBufferRect, mBufferRotation, or mDidSelfCopy,
     // or call CreateBuffer before this call.
     FinalizeFrame(result.mRegionToDraw);
   }
 
-  nsIntRect drawBounds = result.mRegionToDraw.GetBounds();
+  IntRect drawBounds = result.mRegionToDraw.GetBounds();
   RefPtr<DrawTarget> destDTBuffer;
   RefPtr<DrawTarget> destDTBufferOnWhite;
   uint32_t bufferFlags = 0;
   if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
     bufferFlags |= BUFFER_COMPONENT_ALPHA;
   }
   if (canReuseBuffer) {
     if (!EnsureBuffer()) {
       return result;
     }
-    nsIntRect keepArea;
+    IntRect keepArea;
     if (keepArea.IntersectRect(destBufferRect, mBufferRect)) {
       // Set mBufferRotation so that the pixels currently in mDTBuffer
       // will still be rendered in the right place when mBufferRect
       // changes to destBufferRect.
-      nsIntPoint newRotation = mBufferRotation +
+      IntPoint newRotation = mBufferRotation +
         (destBufferRect.TopLeft() - mBufferRect.TopLeft());
       WrapRotationAxis(&newRotation.x, mBufferRect.width);
       WrapRotationAxis(&newRotation.y, mBufferRect.height);
-      NS_ASSERTION(nsIntRect(nsIntPoint(0,0), mBufferRect.Size()).Contains(newRotation),
+      NS_ASSERTION(gfx::IntRect(gfx::IntPoint(0,0), mBufferRect.Size()).Contains(newRotation),
                    "newRotation out of bounds");
       int32_t xBoundary = destBufferRect.XMost() - newRotation.x;
       int32_t yBoundary = destBufferRect.YMost() - newRotation.y;
       bool drawWrapsBuffer = (drawBounds.x < xBoundary && xBoundary < drawBounds.XMost()) ||
                              (drawBounds.y < yBoundary && yBoundary < drawBounds.YMost());
       if ((drawWrapsBuffer && !(aFlags & PAINT_CAN_DRAW_ROTATED)) ||
-          (newRotation != nsIntPoint(0,0) && !canHaveRotation)) {
+          (newRotation != IntPoint(0,0) && !canHaveRotation)) {
         // The stuff we need to redraw will wrap around an edge of the
         // buffer (and the caller doesn't know how to support that), so
         // move the pixels we can keep into a position that lets us
         // redraw in just one quadrant.
-        if (mBufferRotation == nsIntPoint(0,0)) {
-          nsIntRect srcRect(nsIntPoint(0, 0), mBufferRect.Size());
-          nsIntPoint dest = mBufferRect.TopLeft() - destBufferRect.TopLeft();
+        if (mBufferRotation == IntPoint(0,0)) {
+          IntRect srcRect(IntPoint(0, 0), mBufferRect.Size());
+          IntPoint dest = mBufferRect.TopLeft() - destBufferRect.TopLeft();
           MOZ_ASSERT(mDTBuffer);
-          mDTBuffer->CopyRect(IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height),
-                              IntPoint(dest.x, dest.y));
+          mDTBuffer->CopyRect(srcRect, dest);
           if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
             if (!EnsureBufferOnWhite()) {
               return result;
             }
             MOZ_ASSERT(mDTBufferOnWhite);
-            mDTBufferOnWhite->CopyRect(IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height),
-                                       IntPoint(dest.x, dest.y));
+            mDTBufferOnWhite->CopyRect(srcRect, dest);
           }
           result.mDidSelfCopy = true;
           mDidSelfCopy = true;
           // Don't set destBuffer; we special-case self-copies, and
           // just did the necessary work above.
           mBufferRect = destBufferRect;
         } else {
           // With azure and a data surface perform an buffer unrotate
@@ -636,17 +634,17 @@ RotatedContentBuffer::BeginPaint(Painted
               mDTBufferOnWhite->ReleaseBits(data);
             }
 
             // Buffer unrotate moves all the pixels, note that
             // we self copied for SyncBackToFrontBuffer
             result.mDidSelfCopy = true;
             mDidSelfCopy = true;
             mBufferRect = destBufferRect;
-            mBufferRotation = nsIntPoint(0, 0);
+            mBufferRotation = IntPoint(0, 0);
           }
 
           if (!result.mDidSelfCopy) {
             destBufferRect = ComputeBufferRect(neededRegion.GetBounds());
             CreateBuffer(result.mContentType, destBufferRect, bufferFlags,
                          &destDTBuffer, &destDTBufferOnWhite);
             if (!destDTBuffer ||
                 (!destDTBufferOnWhite && (bufferFlags & BUFFER_COMPONENT_ALPHA))) {
@@ -659,17 +657,17 @@ RotatedContentBuffer::BeginPaint(Painted
         mBufferRect = destBufferRect;
         mBufferRotation = newRotation;
       }
     } else {
       // No pixels are going to be kept. The whole visible region
       // will be redrawn, so we don't need to copy anything, so we don't
       // set destBuffer.
       mBufferRect = destBufferRect;
-      mBufferRotation = nsIntPoint(0,0);
+      mBufferRotation = IntPoint(0,0);
     }
   } else {
     // The buffer's not big enough, so allocate a new one
     CreateBuffer(result.mContentType, destBufferRect, bufferFlags,
                  &destDTBuffer, &destDTBufferOnWhite);
     if (!destDTBuffer ||
         (!destDTBufferOnWhite && (bufferFlags & BUFFER_COMPONENT_ALPHA))) {
       gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(IntSize(destBufferRect.width, destBufferRect.height)))) << "Failed 2 buffer db=" << hexa(destDTBuffer.get()) << " dw=" << hexa(destDTBufferOnWhite.get()) << " for " << destBufferRect.x << ", " << destBufferRect.y << ", " << destBufferRect.width << ", " << destBufferRect.height;
@@ -682,17 +680,17 @@ RotatedContentBuffer::BeginPaint(Painted
 
   // If we have no buffered data already, then destBuffer will be a fresh buffer
   // and we do not need to clear it below.
   bool isClear = !HaveBuffer();
 
   if (destDTBuffer) {
     if (!isClear && (mode != SurfaceMode::SURFACE_COMPONENT_ALPHA || HaveBufferOnWhite())) {
       // Copy the bits
-      nsIntPoint offset = -destBufferRect.TopLeft();
+      IntPoint offset = -destBufferRect.TopLeft();
       Matrix mat = Matrix::Translation(offset.x, offset.y);
       destDTBuffer->SetTransform(mat);
       if (!EnsureBuffer()) {
         return result;
       }
        MOZ_ASSERT(mDTBuffer, "Have we got a Thebes buffer for some reason?");
       DrawBufferWithRotation(destDTBuffer, BUFFER_BLACK, 1.0, CompositionOp::OP_SOURCE);
       destDTBuffer->SetTransform(Matrix());
@@ -706,19 +704,19 @@ RotatedContentBuffer::BeginPaint(Painted
         DrawBufferWithRotation(destDTBufferOnWhite, BUFFER_WHITE, 1.0, CompositionOp::OP_SOURCE);
         destDTBufferOnWhite->SetTransform(Matrix());
       }
     }
 
     mDTBuffer = destDTBuffer.forget();
     mDTBufferOnWhite = destDTBufferOnWhite.forget();
     mBufferRect = destBufferRect;
-    mBufferRotation = nsIntPoint(0,0);
+    mBufferRotation = IntPoint(0,0);
   }
-  NS_ASSERTION(canHaveRotation || mBufferRotation == nsIntPoint(0,0),
+  NS_ASSERTION(canHaveRotation || mBufferRotation == IntPoint(0,0),
                "Rotation disabled, but we have nonzero rotation?");
 
   nsIntRegion invalidate;
   invalidate.Sub(aLayer->GetValidRegion(), destBufferRect);
   result.mRegionToInvalidate.Or(result.mRegionToInvalidate, invalidate);
   result.mClip = DrawRegionClip::DRAW;
   result.mMode = mode;
 
@@ -753,27 +751,27 @@ RotatedContentBuffer::BorrowDrawTargetFo
   if (aPaintState.mMode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
     if (!mDTBuffer || !mDTBufferOnWhite) {
       // This can happen in release builds if allocating one of the two buffers
       // failed. This in turn can happen if unreasonably large textures are
       // requested.
       return nullptr;
     }
     nsIntRegionRectIterator iter(*drawPtr);
-    const nsIntRect *iterRect;
+    const IntRect *iterRect;
     while ((iterRect = iter.Next())) {
       mDTBuffer->FillRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height),
                           ColorPattern(Color(0.0, 0.0, 0.0, 1.0)));
       mDTBufferOnWhite->FillRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height),
                                  ColorPattern(Color(1.0, 1.0, 1.0, 1.0)));
     }
   } else if (aPaintState.mContentType == gfxContentType::COLOR_ALPHA && HaveBuffer()) {
     // HaveBuffer() => we have an existing buffer that we must clear
     nsIntRegionRectIterator iter(*drawPtr);
-    const nsIntRect *iterRect;
+    const IntRect *iterRect;
     while ((iterRect = iter.Next())) {
       result->ClearRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height));
     }
   }
 
   return result;
 }
 
--- a/gfx/layers/RotatedBuffer.h
+++ b/gfx/layers/RotatedBuffer.h
@@ -11,18 +11,16 @@
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef
 #include "mozilla/gfx/2D.h"             // for DrawTarget, etc
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
 #include "nsRegion.h"                   // for nsIntRegion
 #include "LayersTypes.h"
 
 namespace mozilla {
 namespace gfx {
 class Matrix;
 }
 
@@ -45,18 +43,18 @@ class PaintedLayer;
  * at row 0 on the screen, and then painting rows 0 to N-1 of the buffer
  * at row H-N on the screen.
  * mBufferRotation.y would be N in this example.
  */
 class RotatedBuffer {
 public:
   typedef gfxContentType ContentType;
 
-  RotatedBuffer(const nsIntRect& aBufferRect,
-                const nsIntPoint& aBufferRotation)
+  RotatedBuffer(const gfx::IntRect& aBufferRect,
+                const gfx::IntPoint& aBufferRotation)
     : mBufferRect(aBufferRect)
     , mBufferRotation(aBufferRotation)
     , mDidSelfCopy(false)
   { }
   RotatedBuffer()
     : mDidSelfCopy(false)
   { }
 
@@ -76,72 +74,72 @@ public:
                               gfx::SourceSurface* aMask = nullptr,
                               const gfx::Matrix* aMaskTransform = nullptr) const;
 
   /**
    * |BufferRect()| is the rect of device pixels that this
    * RotatedBuffer covers.  That is what DrawBufferWithRotation()
    * will paint when it's called.
    */
-  const nsIntRect& BufferRect() const { return mBufferRect; }
-  const nsIntPoint& BufferRotation() const { return mBufferRotation; }
+  const gfx::IntRect& BufferRect() const { return mBufferRect; }
+  const gfx::IntPoint& BufferRotation() const { return mBufferRotation; }
 
   virtual bool HaveBuffer() const = 0;
   virtual bool HaveBufferOnWhite() const = 0;
 
   virtual TemporaryRef<gfx::SourceSurface> GetSourceSurface(ContextSource aSource) const = 0;
 
 protected:
 
   enum XSide {
     LEFT, RIGHT
   };
   enum YSide {
     TOP, BOTTOM
   };
-  nsIntRect GetQuadrantRectangle(XSide aXSide, YSide aYSide) const;
+  gfx::IntRect GetQuadrantRectangle(XSide aXSide, YSide aYSide) const;
 
   gfx::Rect GetSourceRectangle(XSide aXSide, YSide aYSide) const;
 
   /*
    * If aMask is non-null, then it is used as an alpha mask for rendering this
    * buffer. aMaskTransform must be non-null if aMask is non-null, and is used
    * to adjust the coordinate space of the mask.
    */
   void DrawBufferQuadrant(gfx::DrawTarget* aTarget, XSide aXSide, YSide aYSide,
                           ContextSource aSource,
                           float aOpacity,
                           gfx::CompositionOp aOperator,
                           gfx::SourceSurface* aMask,
                           const gfx::Matrix* aMaskTransform) const;
 
   /** The area of the PaintedLayer that is covered by the buffer as a whole */
-  nsIntRect             mBufferRect;
+  gfx::IntRect             mBufferRect;
   /**
    * The x and y rotation of the buffer. Conceptually the buffer
    * has its origin translated to mBufferRect.TopLeft() - mBufferRotation,
    * is tiled to fill the plane, and the result is clipped to mBufferRect.
    * So the pixel at mBufferRotation within the buffer is what gets painted at
    * mBufferRect.TopLeft().
    * This is "rotation" in the sense of rotating items in a linear buffer,
    * where items falling off the end of the buffer are returned to the
    * buffer at the other end, not 2D rotation!
    */
-  nsIntPoint            mBufferRotation;
+  gfx::IntPoint            mBufferRotation;
   // When this is true it means that all pixels have moved inside the buffer.
   // It's not possible to sync with another buffer without a full copy.
   bool                  mDidSelfCopy;
 };
 
 class SourceRotatedBuffer : public RotatedBuffer
 {
 public:
   SourceRotatedBuffer(gfx::SourceSurface* aSource, gfx::SourceSurface* aSourceOnWhite,
-                      const nsIntRect& aBufferRect,
-                      const nsIntPoint& aBufferRotation)
+                      const gfx::IntRect& aBufferRect,
+                      const gfx::IntPoint& aBufferRotation)
     : RotatedBuffer(aBufferRect, aBufferRotation)
     , mSource(aSource)
     , mSourceOnWhite(aSourceOnWhite)
   { }
 
   virtual TemporaryRef<gfx::SourceSurface> GetSourceSurface(ContextSource aSource) const;
 
   virtual bool HaveBuffer() const { return !!mSource; }
@@ -305,17 +303,17 @@ public:
   /**
    * Return a new surface of |aSize| and |aType|.
    *
    * If the created buffer supports azure content, then the result(s) will
    * be returned in aBlackDT/aWhiteDT, otherwise aBlackSurface/aWhiteSurface
    * will be used.
    */
   virtual void
-  CreateBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags,
+  CreateBuffer(ContentType aType, const gfx::IntRect& aRect, uint32_t aFlags,
                RefPtr<gfx::DrawTarget>* aBlackDT, RefPtr<gfx::DrawTarget>* aWhiteDT) = 0;
 
   /**
    * Get the underlying buffer, if any. This is useful because we can pass
    * in the buffer as the default "reference surface" if there is one.
    * Don't use it for anything else!
    */
   gfx::DrawTarget* GetDTBuffer() { return mDTBuffer; }
@@ -370,17 +368,17 @@ protected:
    * BorrowDrawTargetForQuadrantUpdate may not be called more than once without
    * first calling ReturnDrawTarget.
    *
    * ReturnDrawTarget will restore the transform on the draw target. But it is
    * the callers responsibility to restore the clip. The caller should flush the
    * draw target, if necessary.
    */
   gfx::DrawTarget*
-  BorrowDrawTargetForQuadrantUpdate(const nsIntRect& aBounds,
+  BorrowDrawTargetForQuadrantUpdate(const gfx::IntRect& aBounds,
                                     ContextSource aSource,
                                     DrawIterator* aIter);
 
   static bool IsClippingCheap(gfx::DrawTarget* aTarget, const nsIntRegion& aRegion);
 
 protected:
   /**
    * Return the buffer's content type.  Requires a valid buffer or
--- a/gfx/layers/basic/BasicContainerLayer.cpp
+++ b/gfx/layers/basic/BasicContainerLayer.cpp
@@ -9,17 +9,16 @@
 #include "basic/BasicImplData.h"        // for BasicImplData
 #include "basic/BasicLayers.h"          // for BasicLayerManager
 #include "mozilla/gfx/BaseRect.h"       // for BaseRect
 #include "mozilla/mozalloc.h"           // for operator new
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsISupportsImpl.h"            // for Layer::AddRef, etc
 #include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
 #include "nsRegion.h"                   // for nsIntRegion
 #include "ReadbackProcessor.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
@@ -73,25 +72,25 @@ BasicContainerLayer::ComputeEffectiveTra
   mUseIntermediateSurface =
     GetMaskLayer() ||
     GetForceIsolatedGroup() ||
     (GetMixBlendMode() != CompositionOp::OP_OVER && HasMultipleChildren()) ||
     (GetEffectiveOpacity() != 1.0 && (HasMultipleChildren() || hasSingleBlendingChild));
 }
 
 bool
-BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect)
+BasicContainerLayer::ChildrenPartitionVisibleRegion(const gfx::IntRect& aInRect)
 {
   Matrix transform;
   if (!GetEffectiveTransform().CanDraw2D(&transform) ||
       ThebesMatrix(transform).HasNonIntegerTranslation())
     return false;
 
   nsIntPoint offset(int32_t(transform._31), int32_t(transform._32));
-  nsIntRect rect = aInRect.Intersect(GetEffectiveVisibleRegion().GetBounds() + offset);
+  gfx::IntRect rect = aInRect.Intersect(GetEffectiveVisibleRegion().GetBounds() + offset);
   nsIntRegion covered;
 
   for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) {
     if (ToData(l)->IsHidden())
       continue;
 
     Matrix childTransform;
     if (!l->GetEffectiveTransform().CanDraw2D(&childTransform) ||
--- a/gfx/layers/basic/BasicContainerLayer.h
+++ b/gfx/layers/basic/BasicContainerLayer.h
@@ -7,17 +7,17 @@
 #define GFX_BASICCONTAINERLAYER_H
 
 #include "BasicImplData.h"              // for BasicImplData
 #include "BasicLayers.h"                // for BasicLayerManager
 #include "Layers.h"                     // for Layer, ContainerLayer
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR
 #include "nsISupportsUtils.h"           // for NS_ADDREF, NS_RELEASE
-struct nsIntRect;
+#include "mozilla/gfx/Rect.h"
 
 namespace mozilla {
 namespace layers {
 
 class BasicContainerLayer : public ContainerLayer, public BasicImplData {
 public:
   explicit BasicContainerLayer(BasicLayerManager* aManager) :
     ContainerLayer(aManager, static_cast<BasicImplData*>(this))
@@ -72,17 +72,17 @@ public:
    * (aInRect intersected with this layer's visible region).
    * c) this layer and all (non-hidden) children have transforms that are translations
    * by integers.
    * aInRect is in the root coordinate system.
    * Child layers with opacity do not contribute to the covered area in check b).
    * This method can be conservative; it's OK to return false under any
    * circumstances.
    */
-  bool ChildrenPartitionVisibleRegion(const nsIntRect& aInRect);
+  bool ChildrenPartitionVisibleRegion(const gfx::IntRect& aInRect);
 
   void ForceIntermediateSurface() { mUseIntermediateSurface = true; }
 
   void SetSupportsComponentAlphaChildren(bool aSupports) { mSupportsComponentAlphaChildren = aSupports; }
 
   virtual void Validate(LayerManager::DrawPaintedLayerCallback aCallback,
                         void* aCallbackData,
                         ReadbackProcessor* aReadback) override;
--- a/gfx/layers/client/ClientTiledPaintedLayer.cpp
+++ b/gfx/layers/client/ClientTiledPaintedLayer.cpp
@@ -13,17 +13,16 @@
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/gfx/BaseSize.h"       // for BaseSize
 #include "mozilla/gfx/Rect.h"           // for Rect, RectTyped
 #include "mozilla/layers/CompositorChild.h"
 #include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
 #include "mozilla/layers/LayersMessages.h"
 #include "mozilla/mozalloc.h"           // for operator delete, etc
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
-#include "nsRect.h"                     // for nsIntRect
 #include "LayersLogging.h"
 
 namespace mozilla {
 namespace layers {
 
 ClientTiledPaintedLayer::ClientTiledPaintedLayer(ClientLayerManager* const aManager,
                                                ClientLayerManager::PaintedLayerCreationHint aCreationHint)
   : PaintedLayer(aManager, static_cast<ClientLayer*>(this), aCreationHint)
@@ -419,22 +418,22 @@ ClientTiledPaintedLayer::RenderLayer()
   nsIntRegion neededRegion = mVisibleRegion;
 #ifndef MOZ_IGNORE_PAINT_WILL_RESAMPLE
   // This is handled by PadDrawTargetOutFromRegion in TiledContentClient for mobile
   if (MayResample()) {
     // If we're resampling then bilinear filtering can read up to 1 pixel
     // outside of our texture coords. Make the visible region a single rect,
     // and pad it out by 1 pixel (restricted to tile boundaries) so that
     // we always have valid content or transparent pixels to sample from.
-    nsIntRect bounds = neededRegion.GetBounds();
-    nsIntRect wholeTiles = bounds;
-    wholeTiles.InflateToMultiple(nsIntSize(
+    IntRect bounds = neededRegion.GetBounds();
+    IntRect wholeTiles = bounds;
+    wholeTiles.InflateToMultiple(IntSize(
       gfxPlatform::GetPlatform()->GetTileWidth(),
       gfxPlatform::GetPlatform()->GetTileHeight()));
-    nsIntRect padded = bounds;
+    IntRect padded = bounds;
     padded.Inflate(1);
     padded.IntersectRect(padded, wholeTiles);
     neededRegion = padded;
   }
 #endif
 
   nsIntRegion invalidRegion;
   invalidRegion.Sub(neededRegion, mValidRegion);
--- a/gfx/layers/composite/CanvasLayerComposite.cpp
+++ b/gfx/layers/composite/CanvasLayerComposite.cpp
@@ -12,17 +12,16 @@
 #include "mozilla/gfx/Point.h"          // for Point
 #include "mozilla/gfx/Rect.h"           // for Rect
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/Effects.h"     // for EffectChain
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAString.h"
 #include "nsRefPtr.h"                   // for nsRefPtr
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
-#include "nsPoint.h"                    // for nsIntPoint
 #include "nsString.h"                   // for nsAutoCString
 #include "gfxVR.h"
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 
--- a/gfx/layers/composite/CanvasLayerComposite.h
+++ b/gfx/layers/composite/CanvasLayerComposite.h
@@ -9,17 +9,16 @@
 #include "Layers.h"                     // for CanvasLayer, etc
 #include "mozilla/Attributes.h"         // for override
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "mozilla/layers/LayerManagerComposite.h"  // for LayerComposite, etc
 #include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT
 #include "nsRect.h"                     // for nsIntRect
 #include "nscore.h"                     // for nsACString
-struct nsIntPoint;
 
 namespace mozilla {
 namespace layers {
 
 class CompositableHost;
 // Canvas layers use ImageHosts (but CanvasClients) because compositing a
 // canvas is identical to compositing an image.
 class ImageHost;
--- a/gfx/layers/composite/ColorLayerComposite.cpp
+++ b/gfx/layers/composite/ColorLayerComposite.cpp
@@ -9,30 +9,28 @@
 #include "mozilla/gfx/Matrix.h"         // for Matrix4x4
 #include "mozilla/gfx/Point.h"          // for Point
 #include "mozilla/gfx/Rect.h"           // for Rect
 #include "mozilla/gfx/Types.h"          // for Color
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/CompositorTypes.h"  // for DiagnosticFlags::COLOR
 #include "mozilla/layers/Effects.h"     // for Effect, EffectChain, etc
 #include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
 
 namespace mozilla {
 namespace layers {
 
 void
-ColorLayerComposite::RenderLayer(const nsIntRect& aClipRect)
+ColorLayerComposite::RenderLayer(const gfx::IntRect& aClipRect)
 {
   EffectChain effects(this);
 
   GenEffectChain(effects);
 
-  nsIntRect boundRect = GetBounds();
+  gfx::IntRect boundRect = GetBounds();
 
   LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(GetMaskLayer(),
                                                           effects);
 
   gfx::Rect rect(boundRect.x, boundRect.y,
                  boundRect.width, boundRect.height);
   gfx::Rect clipRect(aClipRect.x, aClipRect.y,
                      aClipRect.width, aClipRect.height);
--- a/gfx/layers/composite/ColorLayerComposite.h
+++ b/gfx/layers/composite/ColorLayerComposite.h
@@ -6,19 +6,16 @@
 #ifndef GFX_ColorLayerComposite_H
 #define GFX_ColorLayerComposite_H
 
 #include "Layers.h"                     // for ColorLayer, etc
 #include "mozilla/Attributes.h"         // for override
 #include "mozilla/layers/LayerManagerComposite.h"  // for LayerComposite, etc
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 
-struct nsIntPoint;
-struct nsIntRect;
-
 namespace mozilla {
 namespace layers {
 
 class CompositableHost;
 
 class ColorLayerComposite : public ColorLayer,
                             public LayerComposite
 {
@@ -45,17 +42,17 @@ public:
   virtual void SetLayerManager(LayerManagerComposite* aManager) override
   {
     LayerComposite::SetLayerManager(aManager);
     mManager = aManager;
   }
 
   virtual void Destroy() override { mDestroyed = true; }
 
-  virtual void RenderLayer(const nsIntRect& aClipRect) override;
+  virtual void RenderLayer(const gfx::IntRect& aClipRect) override;
   virtual void CleanupResources() override {};
 
   virtual void GenEffectChain(EffectChain& aEffect) override;
 
   CompositableHost* GetCompositableHost() override { return nullptr; }
 
   virtual LayerComposite* AsLayerComposite() override { return this; }
 
--- a/gfx/layers/composite/CompositableHost.h
+++ b/gfx/layers/composite/CompositableHost.h
@@ -23,19 +23,16 @@
 #include "mozilla/layers/LayersMessages.h"
 #include "mozilla/layers/TextureHost.h" // for TextureHost
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nscore.h"                     // for nsACString
 #include "Units.h"                      // for CSSToScreenScale
 
-struct nsIntPoint;
-struct nsIntRect;
-
 namespace mozilla {
 namespace gfx {
 class Matrix4x4;
 class DataSourceSurface;
 }
 
 namespace layers {
 
@@ -103,17 +100,17 @@ public:
 
   /**
    * Returns the front buffer.
    */
   virtual TextureHost* GetAsTextureHost() { return nullptr; }
 
   virtual LayerRenderState GetRenderState() = 0;
 
-  virtual void SetPictureRect(const nsIntRect& aPictureRect)
+  virtual void SetPictureRect(const gfx::IntRect& aPictureRect)
   {
     MOZ_ASSERT(false, "Should have been overridden");
   }
 
   virtual gfx::IntSize GetImageSize() const
   {
     MOZ_ASSERT(false, "Should have been overridden");
     return gfx::IntSize();
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -24,18 +24,16 @@
 #include "mozilla/layers/TextureHost.h"  // for CompositingRenderTarget
 #include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
 #include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
 #include "mozilla/mozalloc.h"           // for operator delete, etc
 #include "nsRefPtr.h"                   // for nsRefPtr
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsISupportsUtils.h"           // for NS_ADDREF, NS_RELEASE
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nsTArray.h"                   // for nsAutoTArray
 #include "TextRenderer.h"               // for TextRenderer
 #include <vector>
 #include "GeckoProfiler.h"              // for GeckoProfiler
 #ifdef MOZ_ENABLE_PROFILER_SPS
 #include "ProfilerMarkers.h"            // for ProfilerMarkers
 #endif
@@ -80,28 +78,26 @@ static void DrawLayerInfo(const RenderTa
 
   std::stringstream ss;
   aLayer->PrintInfo(ss, "");
 
   nsIntRegion visibleRegion = aLayer->GetVisibleRegion();
 
   uint32_t maxWidth = std::min<uint32_t>(visibleRegion.GetBounds().width, 500);
 
-  nsIntPoint topLeft = visibleRegion.GetBounds().TopLeft();
-  aManager->GetTextRenderer()->RenderText(ss.str().c_str(), gfx::IntPoint(topLeft.x, topLeft.y),
+  IntPoint topLeft = visibleRegion.GetBounds().TopLeft();
+  aManager->GetTextRenderer()->RenderText(ss.str().c_str(), topLeft,
                                           aLayer->GetEffectiveTransform(), 16,
                                           maxWidth);
 }
 
 template<class ContainerT>
 static gfx::IntRect ContainerVisibleRect(ContainerT* aContainer)
 {
-  nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
-  gfx::IntRect surfaceRect = gfx::IntRect(visibleRect.x, visibleRect.y,
-                                          visibleRect.width, visibleRect.height);
+  gfx::IntRect surfaceRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
   return surfaceRect;
 }
 
 static void PrintUniformityInfo(Layer* aLayer)
 {
 #ifdef MOZ_ENABLE_PROFILER_SPS
   if (!profiler_is_active()) {
     return;
@@ -132,26 +128,26 @@ struct PreparedLayer
   LayerComposite* mLayer;
   RenderTargetIntRect mClipRect;
 };
 
 
 template<class ContainerT> void
 ContainerRenderVR(ContainerT* aContainer,
                   LayerManagerComposite* aManager,
-                  const nsIntRect& aClipRect,
+                  const gfx::IntRect& aClipRect,
                   gfx::VRHMDInfo* aHMD)
 {
   RefPtr<CompositingRenderTarget> surface;
 
   Compositor* compositor = aManager->GetCompositor();
 
   RefPtr<CompositingRenderTarget> previousTarget = compositor->GetCurrentRenderTarget();
 
-  nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
+  gfx::IntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
 
   float opacity = aContainer->GetEffectiveOpacity();
 
   gfx::IntRect surfaceRect = gfx::IntRect(visibleRect.x, visibleRect.y,
                                           visibleRect.width, visibleRect.height);
   // we're about to create a framebuffer backed by textures to use as an intermediate
   // surface. What to do if its size (as given by framebufferRect) would exceed the
   // maximum texture size supported by the GL? The present code chooses the compromise
@@ -171,17 +167,17 @@ ContainerRenderVR(ContainerT* aContainer
   compositor->SetRenderTarget(surface);
 
   nsAutoTArray<Layer*, 12> children;
   aContainer->SortChildrenBy3DZOrder(children);
 
   /**
    * Render this container's contents.
    */
-  nsIntRect surfaceClipRect(0, 0, surfaceRect.width, surfaceRect.height);
+  gfx::IntRect surfaceClipRect(0, 0, surfaceRect.width, surfaceRect.height);
   RenderTargetIntRect rtClipRect(0, 0, surfaceRect.width, surfaceRect.height);
   for (uint32_t i = 0; i < children.Length(); i++) {
     LayerComposite* layerToRender = static_cast<LayerComposite*>(children.ElementAt(i)->ImplData());
     Layer* layer = layerToRender->GetLayer();
 
     if (layer->GetEffectiveVisibleRegion().IsEmpty() &&
         !layer->AsContainerLayer()) {
       continue;
@@ -347,35 +343,35 @@ RenderLayers(ContainerT* aContainer,
     if ((layer->GetContentFlags() & Layer::CONTENT_OPAQUE) &&
         LayerHasCheckerboardingAPZC(layer, &color)) {
       // Ideally we would want to intersect the checkerboard region from the APZ with the layer bounds
       // and only fill in that area. However the layer bounds takes into account the base translation
       // for the painted layer whereas the checkerboard region does not. One does not simply
       // intersect areas in different coordinate spaces. So we do this a little more permissively
       // and only fill in the background when we know there is checkerboard, which in theory
       // should only occur transiently.
-      nsIntRect layerBounds = layer->GetLayerBounds();
+      gfx::IntRect layerBounds = layer->GetLayerBounds();
       EffectChain effectChain(layer);
       effectChain.mPrimaryEffect = new EffectSolidColor(ToColor(color));
       aManager->GetCompositor()->DrawQuad(gfx::Rect(layerBounds.x, layerBounds.y, layerBounds.width, layerBounds.height),
                                           gfx::Rect(clipRect.ToUnknownRect()),
                                           effectChain, layer->GetEffectiveOpacity(),
                                           layer->GetEffectiveTransform());
     }
 
     if (layerToRender->HasLayerBeenComposited()) {
       // Composer2D will compose this layer so skip GPU composition
       // this time & reset composition flag for next composition phase
       layerToRender->SetLayerComposited(false);
-      nsIntRect clearRect = layerToRender->GetClearRect();
+      gfx::IntRect clearRect = layerToRender->GetClearRect();
       if (!clearRect.IsEmpty()) {
         // Clear layer's visible rect on FrameBuffer with transparent pixels
         gfx::Rect fbRect(clearRect.x, clearRect.y, clearRect.width, clearRect.height);
         compositor->ClearRect(fbRect);
-        layerToRender->SetClearRect(nsIntRect(0, 0, 0, 0));
+        layerToRender->SetClearRect(gfx::IntRect(0, 0, 0, 0));
       }
     } else {
       layerToRender->RenderLayer(RenderTargetPixel::ToUntyped(clipRect));
     }
 
     if (gfxPrefs::UniformityInfo()) {
       PrintUniformityInfo(layer);
     }
@@ -440,17 +436,17 @@ CreateOrRecycleTarget(ContainerT* aConta
   }
 }
 
 template<class ContainerT> RefPtr<CompositingRenderTarget>
 CreateTemporaryTargetAndCopyFromBackground(ContainerT* aContainer,
                                            LayerManagerComposite* aManager)
 {
   Compositor* compositor = aManager->GetCompositor();
-  nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
+  gfx::IntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
   RefPtr<CompositingRenderTarget> previousTarget = compositor->GetCurrentRenderTarget();
   gfx::IntRect surfaceRect = gfx::IntRect(visibleRect.x, visibleRect.y,
                                           visibleRect.width, visibleRect.height);
 
   gfx::IntPoint sourcePoint = gfx::IntPoint(visibleRect.x, visibleRect.y);
 
   gfx::Matrix4x4 transform = aContainer->GetEffectiveTransform();
   DebugOnly<gfx::Matrix> transform2d;
@@ -460,17 +456,17 @@ CreateTemporaryTargetAndCopyFromBackgrou
   sourcePoint -= compositor->GetCurrentRenderTarget()->GetOrigin();
 
   return compositor->CreateRenderTargetFromSource(surfaceRect, previousTarget, sourcePoint);
 }
 
 template<class ContainerT> void
 RenderIntermediate(ContainerT* aContainer,
                    LayerManagerComposite* aManager,
-                   const nsIntRect& aClipRect,
+                   const gfx::IntRect& aClipRect,
                    RefPtr<CompositingRenderTarget> surface)
 {
   Compositor* compositor = aManager->GetCompositor();
   RefPtr<CompositingRenderTarget> previousTarget = compositor->GetCurrentRenderTarget();
 
   if (!surface) {
     return;
   }
@@ -480,17 +476,17 @@ RenderIntermediate(ContainerT* aContaine
   RenderLayers(aContainer, aManager, RenderTargetPixel::FromUntyped(aClipRect));
   // Unbind the current surface and rebind the previous one.
   compositor->SetRenderTarget(previousTarget);
 }
 
 template<class ContainerT> void
 ContainerRender(ContainerT* aContainer,
                  LayerManagerComposite* aManager,
-                 const nsIntRect& aClipRect)
+                 const gfx::IntRect& aClipRect)
 {
   MOZ_ASSERT(aContainer->mPrepared);
 
   gfx::VRHMDInfo *hmdInfo = aContainer->GetVRHMDInfo();
   if (hmdInfo && hmdInfo->GetConfiguration().IsValid()) {
     ContainerRenderVR(aContainer, aManager, aClipRect, hmdInfo);
     aContainer->mPrepared = nullptr;
     return;
@@ -510,17 +506,17 @@ ContainerRender(ContainerT* aContainer,
 
     if (!surface) {
       aContainer->mPrepared = nullptr;
       return;
     }
 
     float opacity = aContainer->GetEffectiveOpacity();
 
-    nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
+    gfx::IntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
 #ifdef MOZ_DUMP_PAINTING
     if (gfxUtils::sDumpPainting) {
       RefPtr<gfx::DataSourceSurface> surf = surface->Dump(aManager->GetCompositor());
       if (surf) {
         WriteSnapshotToDumpFile(aContainer, surf);
       }
     }
 #endif
@@ -609,17 +605,17 @@ ContainerLayerComposite::GetFirstChildCo
 {
   if (!mFirstChild) {
     return nullptr;
    }
   return static_cast<LayerComposite*>(mFirstChild->ImplData());
 }
 
 void
-ContainerLayerComposite::RenderLayer(const nsIntRect& aClipRect)
+ContainerLayerComposite::RenderLayer(const gfx::IntRect& aClipRect)
 {
   ContainerRender(this, mCompositeManager, aClipRect);
 }
 
 void
 ContainerLayerComposite::Prepare(const RenderTargetIntRect& aClipRect)
 {
   ContainerPrepare(this, mCompositeManager, aClipRect);
@@ -660,17 +656,17 @@ RefLayerComposite::GetFirstChildComposit
 {
   if (!mFirstChild) {
     return nullptr;
    }
   return static_cast<LayerComposite*>(mFirstChild->ImplData());
 }
 
 void
-RefLayerComposite::RenderLayer(const nsIntRect& aClipRect)
+RefLayerComposite::RenderLayer(const gfx::IntRect& aClipRect)
 {
   ContainerRender(this, mCompositeManager, aClipRect);
 }
 
 void
 RefLayerComposite::Prepare(const RenderTargetIntRect& aClipRect)
 {
   ContainerPrepare(this, mCompositeManager, aClipRect);
--- a/gfx/layers/composite/ContainerLayerComposite.h
+++ b/gfx/layers/composite/ContainerLayerComposite.h
@@ -5,19 +5,17 @@
 
 #ifndef GFX_ContainerLayerComposite_H
 #define GFX_ContainerLayerComposite_H
 
 #include "Layers.h"                     // for Layer (ptr only), etc
 #include "mozilla/Attributes.h"         // for override
 #include "mozilla/UniquePtr.h"          // for UniquePtr
 #include "mozilla/layers/LayerManagerComposite.h"
-
-struct nsIntPoint;
-struct nsIntRect;
+#include "mozilla/gfx/Rect.h"
 
 namespace mozilla {
 namespace layers {
 
 class CompositableHost;
 class CompositingRenderTarget;
 struct PreparedData;
 
@@ -34,17 +32,17 @@ class ContainerLayerComposite : public C
                               const RenderTargetIntRect& aClipRect);
   template<class ContainerT>
   friend void RenderLayers(ContainerT* aContainer,
                            LayerManagerComposite* aManager,
                            const RenderTargetIntRect& aClipRect);
   template<class ContainerT>
   friend void RenderIntermediate(ContainerT* aContainer,
                    LayerManagerComposite* aManager,
-                   const nsIntRect& aClipRect,
+                   const gfx::IntRect& aClipRect,
                    RefPtr<CompositingRenderTarget> surface);
   template<class ContainerT>
   friend RefPtr<CompositingRenderTarget>
   CreateTemporaryTargetAndCopyFromBackground(ContainerT* aContainer,
                                              LayerManagerComposite* aManager,
                                              const RenderTargetIntRect& aClipRect);
   template<class ContainerT>
   friend RefPtr<CompositingRenderTarget>
@@ -72,17 +70,17 @@ public:
       child->SetLayerManager(aManager);
     }
   }
 
   virtual void Destroy() override;
 
   LayerComposite* GetFirstChildComposite() override;
 
-  virtual void RenderLayer(const nsIntRect& aClipRect) override;
+  virtual void RenderLayer(const gfx::IntRect& aClipRect) override;
   virtual void Prepare(const RenderTargetIntRect& aClipRect) override;
 
   virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
   {
     DefaultComputeEffectiveTransforms(aTransformToSurface);
   }
 
   virtual void CleanupResources() override;
@@ -121,52 +119,52 @@ class RefLayerComposite : public RefLaye
 {
   template<class ContainerT>
   friend void ContainerPrepare(ContainerT* aContainer,
                                LayerManagerComposite* aManager,
                                const RenderTargetIntRect& aClipRect);
   template<class ContainerT>
   friend void ContainerRender(ContainerT* aContainer,
                               LayerManagerComposite* aManager,
-                              const nsIntRect& aClipRect);
+                              const gfx::IntRect& aClipRect);
   template<class ContainerT>
   friend void RenderLayers(ContainerT* aContainer,
                            LayerManagerComposite* aManager,
-                           const nsIntRect& aClipRect);
+                           const gfx::IntRect& aClipRect);
   template<class ContainerT>
   friend void RenderIntermediate(ContainerT* aContainer,
                    LayerManagerComposite* aManager,
-                   const nsIntRect& aClipRect,
+                   const gfx::IntRect& aClipRect,
                    RefPtr<CompositingRenderTarget> surface);
   template<class ContainerT>
   friend RefPtr<CompositingRenderTarget>
   CreateTemporaryTargetAndCopyFromBackground(ContainerT* aContainer,
                                              LayerManagerComposite* aManager,
-                                             const nsIntRect& aClipRect);
+                                             const gfx::IntRect& aClipRect);
   template<class ContainerT>
   friend RefPtr<CompositingRenderTarget>
   CreateTemporaryTarget(ContainerT* aContainer,
                         LayerManagerComposite* aManager,
-                        const nsIntRect& aClipRect);
+                        const gfx::IntRect& aClipRect);
 
 public:
   explicit RefLayerComposite(LayerManagerComposite *aManager);
 
 protected:
   ~RefLayerComposite();
 
 public:
   /** LayerOGL implementation */
   Layer* GetLayer() override { return this; }
 
   void Destroy() override;
 
   LayerComposite* GetFirstChildComposite() override;
 
-  virtual void RenderLayer(const nsIntRect& aClipRect) override;
+  virtual void RenderLayer(const gfx::IntRect& aClipRect) override;
   virtual void Prepare(const RenderTargetIntRect& aClipRect) override;
 
   virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
   {
     DefaultComputeEffectiveTransforms(aTransformToSurface);
   }
 
   virtual void CleanupResources() override;
--- a/gfx/layers/composite/ContentHost.cpp
+++ b/gfx/layers/composite/ContentHost.cpp
@@ -322,17 +322,17 @@ ContentHostSingleBuffered::UpdateThebes(
 
   // Shift to the rotation point
   destRegion.MoveBy(aData.rotation());
 
   nsIntSize bufferSize = aData.rect().Size();
 
   // Select only the pixels that are still within the buffer.
   nsIntRegion finalRegion;
-  finalRegion.And(nsIntRect(nsIntPoint(), bufferSize), destRegion);
+  finalRegion.And(IntRect(IntPoint(), bufferSize), destRegion);
 
   // For each of the overlap areas (right, bottom-right, bottom), select those
   // pixels and wrap them around to the opposite edge of the buffer rect.
   AddWrappedRegion(destRegion, finalRegion, bufferSize, nsIntPoint(aData.rect().width, 0));
   AddWrappedRegion(destRegion, finalRegion, bufferSize, nsIntPoint(aData.rect().width, aData.rect().height));
   AddWrappedRegion(destRegion, finalRegion, bufferSize, nsIntPoint(0, aData.rect().height));
 
   MOZ_ASSERT(nsIntRect(0, 0, aData.rect().width, aData.rect().height).Contains(finalRegion.GetBounds()));
--- a/gfx/layers/composite/ImageLayerComposite.cpp
+++ b/gfx/layers/composite/ImageLayerComposite.cpp
@@ -16,18 +16,16 @@
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/Effects.h"     // for EffectChain
 #include "mozilla/layers/TextureHost.h"  // for TextureHost, etc
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAString.h"
 #include "nsRefPtr.h"                   // for nsRefPtr
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
 #include "nsString.h"                   // for nsAutoCString
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 
 ImageLayerComposite::ImageLayerComposite(LayerManagerComposite* aManager)
@@ -77,17 +75,17 @@ ImageLayerComposite::GetRenderState()
 
 Layer*
 ImageLayerComposite::GetLayer()
 {
   return this;
 }
 
 void
-ImageLayerComposite::RenderLayer(const nsIntRect& aClipRect)
+ImageLayerComposite::RenderLayer(const IntRect& aClipRect)
 {
   if (!mImageHost || !mImageHost->IsAttached()) {
     return;
   }
 
 #ifdef MOZ_DUMP_PAINTING
   if (gfxUtils::sDumpPainting) {
     RefPtr<gfx::DataSourceSurface> surf = mImageHost->GetAsSurface();
--- a/gfx/layers/composite/ImageLayerComposite.h
+++ b/gfx/layers/composite/ImageLayerComposite.h
@@ -4,26 +4,24 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_ImageLayerComposite_H
 #define GFX_ImageLayerComposite_H
 
 #include "GLTextureImage.h"             // for TextureImage
 #include "ImageLayers.h"                // for ImageLayer
 #include "mozilla/Attributes.h"         // for override
+#include "mozilla/gfx/Rect.h"
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "mozilla/layers/LayerManagerComposite.h"  // for LayerComposite, etc
 #include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
 #include "nsISupportsImpl.h"            // for TextureImage::AddRef, etc
 #include "nscore.h"                     // for nsACString
 #include "CompositableHost.h"           // for CompositableHost
 
-struct nsIntPoint;
-struct nsIntRect;
-
 namespace mozilla {
 namespace layers {
 
 class ImageHost;
 class Layer;
 
 class ImageLayerComposite : public ImageLayer,
                             public LayerComposite
@@ -49,17 +47,17 @@ public:
   {
     LayerComposite::SetLayerManager(aManager);
     mManager = aManager;
     if (mImageHost) {
       mImageHost->SetCompositor(mCompositor);
     }
   }
 
-  virtual void RenderLayer(const nsIntRect& aClipRect) override;
+  virtual void RenderLayer(const gfx::IntRect& aClipRect) override;
 
   virtual void ComputeEffectiveTransforms(const mozilla::gfx::Matrix4x4& aTransformToSurface) override;
 
   virtual void CleanupResources() override;
 
   CompositableHost* GetCompositableHost() override;
 
   virtual void GenEffectChain(EffectChain& aEffect) override;
--- a/gfx/layers/composite/PaintedLayerComposite.cpp
+++ b/gfx/layers/composite/PaintedLayerComposite.cpp
@@ -17,19 +17,16 @@
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/ContentHost.h"  // for ContentHost
 #include "mozilla/layers/Effects.h"     // for EffectChain
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAString.h"
 #include "nsRefPtr.h"                   // for nsRefPtr
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsMathUtils.h"                // for NS_lround
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
 #include "nsString.h"                   // for nsAutoCString
 #include "TextRenderer.h"
 #include "GeckoProfiler.h"
 
 namespace mozilla {
 namespace layers {
 
 class TiledLayerComposer;
@@ -109,17 +106,17 @@ PaintedLayerComposite::GetRenderState()
 {
   if (!mBuffer || !mBuffer->IsAttached() || mDestroyed) {
     return LayerRenderState();
   }
   return mBuffer->GetRenderState();
 }
 
 void
-PaintedLayerComposite::RenderLayer(const nsIntRect& aClipRect)
+PaintedLayerComposite::RenderLayer(const gfx::IntRect& aClipRect)
 {
   if (!mBuffer || !mBuffer->IsAttached()) {
     return;
   }
   PROFILER_LABEL("PaintedLayerComposite", "RenderLayer",
     js::ProfileEntry::Category::GRAPHICS);
 
   MOZ_ASSERT(mBuffer->GetCompositor() == mCompositeManager->GetCompositor() &&
--- a/gfx/layers/composite/PaintedLayerComposite.h
+++ b/gfx/layers/composite/PaintedLayerComposite.h
@@ -2,28 +2,25 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_PaintedLayerComposite_H
 #define GFX_PaintedLayerComposite_H
 
 #include "Layers.h"                     // for Layer (ptr only), etc
-#include "gfxRect.h"                    // for gfxRect
+#include "mozilla/gfx/Rect.h"
 #include "mozilla/Attributes.h"         // for override
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "mozilla/layers/LayerManagerComposite.h"  // for LayerComposite, etc
 #include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nscore.h"                     // for nsACString
 
-struct nsIntPoint;
-struct nsIntRect;
-
 
 namespace mozilla {
 namespace layers {
 
 /**
  * PaintedLayers use ContentHosts for their compsositable host.
  * By using different ContentHosts, PaintedLayerComposite support tiled and
  * non-tiled PaintedLayers and single or double buffering.
@@ -52,17 +49,17 @@ public:
   virtual void Destroy() override;
 
   virtual Layer* GetLayer() override;
 
   virtual void SetLayerManager(LayerManagerComposite* aManager) override;
 
   virtual TiledLayerComposer* GetTiledLayerComposer() override;
 
-  virtual void RenderLayer(const nsIntRect& aClipRect) override;
+  virtual void RenderLayer(const gfx::IntRect& aClipRect) override;
 
   virtual void CleanupResources() override;
 
   virtual void GenEffectChain(EffectChain& aEffect) override;
 
   virtual bool SetCompositableHost(CompositableHost* aHost) override;
 
   virtual LayerComposite* AsLayerComposite() override { return this; }
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -53,18 +53,16 @@
 #endif
 
 #if 0
 #define RECYCLE_LOG(...) printf_stderr(__VA_ARGS__)
 #else
 #define RECYCLE_LOG(...) do { } while (0)
 #endif
 
-struct nsIntPoint;
-
 namespace mozilla {
 namespace layers {
 
 /**
  * TextureParent is the host-side IPDL glue between TextureClient and TextureHost.
  * It is an IPDL actor just like LayerParent, CompositableParent, etc.
  */
 class TextureParent : public PTextureParent
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -23,19 +23,19 @@
 #include "mozilla/UniquePtr.h"          // for UniquePtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
 #include "nscore.h"                     // for nsACString
 #include "mozilla/layers/AtomicRefCountedWithFinalize.h"
+#include "mozilla/gfx/Rect.h"
 
 class gfxReusableSurfaceWrapper;
-struct nsIntRect;
 
 namespace mozilla {
 namespace gl {
 class SharedSurface;
 }
 namespace ipc {
 class Shmem;
 }
@@ -65,17 +65,17 @@ class TextureParent;
  * device texture, which forces us to split it in smaller parts.
  * Tiled Compositable is a different thing.
  */
 class BigImageIterator
 {
 public:
   virtual void BeginBigImageIteration() = 0;
   virtual void EndBigImageIteration() {};
-  virtual nsIntRect GetTileRect() = 0;
+  virtual gfx::IntRect GetTileRect() = 0;
   virtual size_t GetTileCount() = 0;
   virtual bool NextTile() = 0;
 };
 
 /**
  * TextureSource is the interface for texture objects that can be composited
  * by a given compositor backend. Since the drawing APIs are different
  * between backends, the TextureSource interface is split into different
--- a/gfx/layers/composite/TiledContentHost.cpp
+++ b/gfx/layers/composite/TiledContentHost.cpp
@@ -8,19 +8,19 @@
 #include "mozilla/gfx/BaseSize.h"       // for BaseSize
 #include "mozilla/gfx/Matrix.h"         // for Matrix4x4
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/Effects.h"     // for TexturedEffect, Effect, etc
 #include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
 #include "mozilla/layers/TextureHostOGL.h"  // for TextureHostOGL
 #include "nsAString.h"
 #include "nsDebug.h"                    // for NS_WARNING
-#include "nsPoint.h"                    // for nsIntPoint
+#include "nsPoint.h"                    // for IntPoint
 #include "nsPrintfCString.h"            // for nsPrintfCString
-#include "nsRect.h"                     // for nsIntRect
+#include "nsRect.h"                     // for IntRect
 #include "nsSize.h"                     // for nsIntSize
 #include "mozilla/layers/TiledContentClient.h"
 
 class gfxReusableSurfaceWrapper;
 
 namespace mozilla {
 using namespace gfx;
 namespace layers {
@@ -166,17 +166,17 @@ TiledLayerBufferComposite::Upload()
   // The TextureClients were created with the TextureFlags::IMMEDIATE_UPLOAD flag,
   // so calling Update on all the texture hosts will perform the texture upload.
   Update(mValidRegion, mPaintedRegion);
   ClearPaintedRegion();
 }
 
 TileHost
 TiledLayerBufferComposite::ValidateTile(TileHost aTile,
-                                        const nsIntPoint& aTileOrigin,
+                                        const IntPoint& aTileOrigin,
                                         const nsIntRegion& aDirtyRect)
 {
   if (aTile.IsPlaceholderTile()) {
     NS_WARNING("Placeholder tile encountered in painted region");
     return aTile;
   }
 
 #ifdef GFX_TILEDLAYER_PREF_WARNINGS
@@ -460,29 +460,29 @@ void
 TiledContentHost::RenderTile(const TileHost& aTile,
                              const gfxRGBA* aBackgroundColor,
                              EffectChain& aEffectChain,
                              float aOpacity,
                              const gfx::Matrix4x4& aTransform,
                              const gfx::Filter& aFilter,
                              const gfx::Rect& aClipRect,
                              const nsIntRegion& aScreenRegion,
-                             const nsIntPoint& aTextureOffset,
+                             const IntPoint& aTextureOffset,
                              const nsIntSize& aTextureBounds)
 {
   if (aTile.IsPlaceholderTile()) {
     // This shouldn't ever happen, but let's fail semi-gracefully. No need
     // to warn, the texture update would have already caught this.
     return;
   }
 
   if (aBackgroundColor) {
     aEffectChain.mPrimaryEffect = new EffectSolidColor(ToColor(*aBackgroundColor));
     nsIntRegionRectIterator it(aScreenRegion);
-    for (const nsIntRect* rect = it.Next(); rect != nullptr; rect = it.Next()) {
+    for (const IntRect* rect = it.Next(); rect != nullptr; rect = it.Next()) {
       Rect graphicsRect(rect->x, rect->y, rect->width, rect->height);
       mCompositor->DrawQuad(graphicsRect, aClipRect, aEffectChain, 1.0, aTransform);
     }
   }
 
   AutoLockTextureHost autoLock(aTile.mTextureHost);
   AutoLockTextureHost autoLockOnWhite(aTile.mTextureHostOnWhite);
   if (autoLock.Failed() ||
@@ -502,17 +502,17 @@ TiledContentHost::RenderTile(const TileH
   RefPtr<TexturedEffect> effect = CreateTexturedEffect(aTile.mTextureSource, aTile.mTextureSourceOnWhite, aFilter, true);
   if (!effect) {
     return;
   }
 
   aEffectChain.mPrimaryEffect = effect;
 
   nsIntRegionRectIterator it(aScreenRegion);
-  for (const nsIntRect* rect = it.Next(); rect != nullptr; rect = it.Next()) {
+  for (const IntRect* rect = it.Next(); rect != nullptr; rect = it.Next()) {
     Rect graphicsRect(rect->x, rect->y, rect->width, rect->height);
     Rect textureRect(rect->x - aTextureOffset.x, rect->y - aTextureOffset.y,
                      rect->width, rect->height);
 
     effect->mTextureCoords = Rect(textureRect.x / aTextureBounds.width,
                                   textureRect.y / aTextureBounds.height,
                                   textureRect.width / aTextureBounds.width,
                                   textureRect.height / aTextureBounds.height);
@@ -569,17 +569,17 @@ TiledContentHost::RenderLayerBuffer(Tile
   // for in the layer transform.
   aTransform.PreScale(1/(resolution * layerScale.width),
                       1/(resolution * layerScale.height), 1);
 
   DiagnosticFlags componentAlphaDiagnostic = DiagnosticFlags::NO_DIAGNOSTIC;
 
   uint32_t rowCount = 0;
   uint32_t tileX = 0;
-  nsIntRect visibleRect = aVisibleRegion.GetBounds();
+  IntRect visibleRect = aVisibleRegion.GetBounds();
   gfx::IntSize scaledTileSize = aLayerBuffer.GetScaledTileSize();
   for (int32_t x = visibleRect.x; x < visibleRect.x + visibleRect.width;) {
     rowCount++;
     int32_t tileStartX = aLayerBuffer.GetTileStart(x, scaledTileSize.width);
     int32_t w = scaledTileSize.width - tileStartX;
     if (x + w > visibleRect.x + visibleRect.width) {
       w = visibleRect.x + visibleRect.width - x;
     }
@@ -587,27 +587,27 @@ TiledContentHost::RenderLayerBuffer(Tile
     for (int32_t y = visibleRect.y; y < visibleRect.y + visibleRect.height;) {
       int32_t tileStartY = aLayerBuffer.GetTileStart(y, scaledTileSize.height);
       int32_t h = scaledTileSize.height - tileStartY;
       if (y + h > visibleRect.y + visibleRect.height) {
         h = visibleRect.y + visibleRect.height - y;
       }
 
       TileHost tileTexture = aLayerBuffer.
-        GetTile(nsIntPoint(aLayerBuffer.RoundDownToTileEdge(x, scaledTileSize.width),
-                           aLayerBuffer.RoundDownToTileEdge(y, scaledTileSize.height)));
+        GetTile(IntPoint(aLayerBuffer.RoundDownToTileEdge(x, scaledTileSize.width),
+                         aLayerBuffer.RoundDownToTileEdge(y, scaledTileSize.height)));
       if (tileTexture != aLayerBuffer.GetPlaceholderTile()) {
         nsIntRegion tileDrawRegion;
-        tileDrawRegion.And(nsIntRect(x, y, w, h), aLayerBuffer.GetValidRegion());
+        tileDrawRegion.And(IntRect(x, y, w, h), aLayerBuffer.GetValidRegion());
         tileDrawRegion.And(tileDrawRegion, aVisibleRegion);
         tileDrawRegion.Sub(tileDrawRegion, maskRegion);
 
         if (!tileDrawRegion.IsEmpty()) {
           tileDrawRegion.ScaleRoundOut(resolution, resolution);
-          nsIntPoint tileOffset((x - tileStartX) * resolution,
+          IntPoint tileOffset((x - tileStartX) * resolution,
                                 (y - tileStartY) * resolution);
           gfx::IntSize tileSize = aLayerBuffer.GetTileSize();
           RenderTile(tileTexture, aBackgroundColor, aEffectChain, aOpacity, aTransform,
                      aFilter, aClipRect, tileDrawRegion, tileOffset,
                      nsIntSize(tileSize.width, tileSize.height));
           if (tileTexture.mTextureHostOnWhite) {
             componentAlphaDiagnostic = DiagnosticFlags::COMPONENT_ALPHA;
           }
--- a/gfx/layers/composite/TiledContentHost.h
+++ b/gfx/layers/composite/TiledContentHost.h
@@ -27,18 +27,16 @@
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nscore.h"                     // for nsACString
 
 #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
 #include <ui/Fence.h>
 #endif
 
 class gfxReusableSurfaceWrapper;
-struct nsIntPoint;
-struct nsIntRect;
 
 namespace mozilla {
 namespace gfx {
 class Matrix4x4;
 }
 
 namespace layers {
 
@@ -159,17 +157,17 @@ public:
   bool IsValid() const { return mIsValid; }
 
   // Recycle callback for TextureHost.
   // Used when TiledContentClient is present in client side.
   static void RecycleCallback(TextureHost* textureHost, void* aClosure);
 
 protected:
   TileHost ValidateTile(TileHost aTile,
-                        const nsIntPoint& aTileRect,
+                        const gfx::IntPoint& aTileRect,
                         const nsIntRegion& dirtyRect);
 
   // do nothing, the desctructor in the texture host takes care of releasing resources
   void ReleaseTile(TileHost aTile) {}
 
   void SwapTiles(TileHost& aTileA, TileHost& aTileB) { std::swap(aTileA, aTileB); }
 
   void UnlockTile(TileHost aTile) {}
@@ -286,17 +284,17 @@ private:
   void RenderTile(const TileHost& aTile,
                   const gfxRGBA* aBackgroundColor,
                   EffectChain& aEffectChain,
                   float aOpacity,
                   const gfx::Matrix4x4& aTransform,
                   const gfx::Filter& aFilter,
                   const gfx::Rect& aClipRect,
                   const nsIntRegion& aScreenRegion,
-                  const nsIntPoint& aTextureOffset,
+                  const gfx::IntPoint& aTextureOffset,
                   const gfx::IntSize& aTextureBounds);
 
   void EnsureTileStore() {}
 
   TiledLayerBufferComposite    mTiledBuffer;
   TiledLayerBufferComposite    mLowPrecisionTiledBuffer;
   TiledLayerBufferComposite    mOldTiledBuffer;
   TiledLayerBufferComposite    mOldLowPrecisionTiledBuffer;
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -1071,17 +1071,17 @@ CompositorD3D11::BeginFrame(const nsIntR
 
   mContext->IASetInputLayout(mAttachments->mInputLayout);
 
   ID3D11Buffer* buffer = mAttachments->mVertexBuffer;
   UINT size = sizeof(Vertex);
   UINT offset = 0;
   mContext->IASetVertexBuffers(0, 1, &buffer, &size, &offset);
 
-  nsIntRect intRect = nsIntRect(nsIntPoint(0, 0), mSize);
+  nsIntRect intRect = IntRect(IntPoint(0, 0), mSize);
   // Sometimes the invalid region is larger than we want to draw.
   nsIntRegion invalidRegionSafe;
 
   if (mSize != oldSize) {
     invalidRegionSafe = intRect;
   } else {
     invalidRegionSafe.And(aInvalidRegion, intRect);
   }
--- a/gfx/layers/d3d9/DeviceManagerD3D9.cpp
+++ b/gfx/layers/d3d9/DeviceManagerD3D9.cpp
@@ -127,17 +127,17 @@ SwapChainD3D9::PrepareForRendering()
     
     return DeviceOK;
   }
 
   return DeviceFail;
 }
 
 void
-SwapChainD3D9::Present(const nsIntRect &aRect)
+SwapChainD3D9::Present(const gfx::IntRect &aRect)
 {
   RECT r;
   r.left = aRect.x;
   r.top = aRect.y;
   r.right = aRect.XMost();
   r.bottom = aRect.YMost();
 
   mSwapChain->Present(&r, &r, 0, 0, 0);
--- a/gfx/layers/d3d9/DeviceManagerD3D9.h
+++ b/gfx/layers/d3d9/DeviceManagerD3D9.h
@@ -7,18 +7,17 @@
 #define GFX_DEVICEMANAGERD3D9_H
 
 #include "gfxTypes.h"
 #include "nsAutoPtr.h"
 #include "d3d9.h"
 #include "nsTArray.h"
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/RefPtr.h"
-
-struct nsIntRect;
+#include "mozilla/gfx/Rect.h"
 
 namespace mozilla {
 namespace layers {
 
 class DeviceManagerD3D9;
 class LayerD3D9;
 class Nv3DVUtils;
 class Layer;
@@ -97,17 +96,17 @@ public:
   DeviceManagerState PrepareForRendering();
 
   already_AddRefed<IDirect3DSurface9> GetBackBuffer();
 
   /**
    * This function will present the selected rectangle of the swap chain to
    * its associated window.
    */
-  void Present(const nsIntRect &aRect);
+  void Present(const gfx::IntRect &aRect);
   void Present();
 
 private:
   friend class DeviceManagerD3D9;
 
   SwapChainD3D9(DeviceManagerD3D9 *aDeviceManager);
 
   // Private destructor, to discourage deletion outside of Release():
--- a/gfx/layers/ipc/CompositableForwarder.h
+++ b/gfx/layers/ipc/CompositableForwarder.h
@@ -10,19 +10,17 @@
 #include <stdint.h>                     // for int32_t, uint64_t
 #include "gfxTypes.h"
 #include "mozilla/Attributes.h"         // for override
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator
 #include "mozilla/layers/LayersTypes.h"  // for LayersBackend
 #include "mozilla/layers/TextureClient.h"  // for TextureClient
 #include "nsRegion.h"                   // for nsIntRegion
-
-struct nsIntPoint;
-struct nsIntRect;
+#include "mozilla/gfx/Rect.h"
 
 namespace mozilla {
 namespace layers {
 
 class CompositableClient;
 class AsyncTransactionTracker;
 struct TextureFactoryIdentifier;
 class SurfaceDescriptor;
@@ -74,17 +72,17 @@ public:
   virtual void UpdateTextureRegion(CompositableClient* aCompositable,
                                    const ThebesBufferData& aThebesBufferData,
                                    const nsIntRegion& aUpdatedRegion) = 0;
 
   /**
    * Communicate the picture rect of a YUV image in aLayer to the compositor
    */
   virtual void UpdatePictureRect(CompositableClient* aCompositable,
-                                 const nsIntRect& aRect) = 0;
+                                 const gfx::IntRect& aRect) = 0;
 
 #ifdef MOZ_WIDGET_GONK
   virtual void UseOverlaySource(CompositableClient* aCompositabl,
                                 const OverlaySource& aOverlay) = 0;
 #endif
 
   /**
    * Tell the CompositableHost on the compositor side to remove the texture
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -22,16 +22,17 @@
 #include "gfxPlatformGtk.h"             // for gfxPlatform
 #endif
 #include "gfxPrefs.h"                   // for gfxPrefs
 #include "mozilla/AutoRestore.h"        // for AutoRestore
 #include "mozilla/ClearOnShutdown.h"    // for ClearOnShutdown
 #include "mozilla/DebugOnly.h"          // for DebugOnly
 #include "mozilla/gfx/2D.h"          // for DrawTarget
 #include "mozilla/gfx/Point.h"          // for IntSize
+#include "mozilla/gfx/Rect.h"          // for IntSize
 #include "mozilla/ipc/Transport.h"      // for Transport
 #include "mozilla/layers/APZCTreeManager.h"  // for APZCTreeManager
 #include "mozilla/layers/APZThreadUtils.h"  // for APZCTreeManager
 #include "mozilla/layers/AsyncCompositionManager.h"
 #include "mozilla/layers/BasicCompositor.h"  // for BasicCompositor
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/CompositorOGL.h"  // for CompositorOGL
 #include "mozilla/layers/CompositorTypes.h"
@@ -43,17 +44,16 @@
 #include "mozilla/Telemetry.h"
 #ifdef MOZ_WIDGET_GTK
 #include "basic/X11BasicCompositor.h" // for X11BasicCompositor
 #endif
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_ASSERTION, etc
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsIWidget.h"                  // for nsIWidget
-#include "nsRect.h"                     // for nsIntRect
 #include "nsTArray.h"                   // for nsTArray
 #include "nsThreadUtils.h"              // for NS_IsMainThread
 #include "nsXULAppAPI.h"                // for XRE_GetIOMessageLoop
 #ifdef XP_WIN
 #include "mozilla/layers/CompositorD3D11.h"
 #include "mozilla/layers/CompositorD3D9.h"
 #endif
 #include "GeckoProfiler.h"
@@ -601,17 +601,17 @@ bool
 CompositorParent::RecvResume()
 {
   ResumeComposition();
   return true;
 }
 
 bool
 CompositorParent::RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
-                                   const nsIntRect& aRect)
+                                   const gfx::IntRect& aRect)
 {
   RefPtr<DrawTarget> target = GetDrawTargetForDescriptor(aInSnapshot, gfx::BackendType::CAIRO);
   ForceComposeToTarget(target, &aRect);
   return true;
 }
 
 bool
 CompositorParent::RecvFlushRendering()
@@ -972,17 +972,17 @@ CompositorParent::SetShadowProperties(La
 
   for (Layer* child = aLayer->GetFirstChild();
       child; child = child->GetNextSibling()) {
     SetShadowProperties(child);
   }
 }
 
 void
-CompositorParent::CompositeToTarget(DrawTarget* aTarget, const nsIntRect* aRect)
+CompositorParent::CompositeToTarget(DrawTarget* aTarget, const gfx::IntRect* aRect)
 {
   profiler_tracing("Paint", "Composite", TRACING_INTERVAL_START);
   PROFILER_LABEL("CompositorParent", "Composite",
     js::ProfileEntry::Category::GRAPHICS);
 
   MOZ_ASSERT(IsInCompositorThread(),
              "Composite can only be called on the compositor thread");
   TimeStamp start = TimeStamp::Now();
@@ -1067,17 +1067,17 @@ CompositorParent::CompositeToTarget(Draw
     ScheduleComposition();
   }
 
   mozilla::Telemetry::AccumulateTimeDelta(mozilla::Telemetry::COMPOSITE_TIME, start);
   profiler_tracing("Paint", "Composite", TRACING_INTERVAL_END);
 }
 
 void
-CompositorParent::ForceComposeToTarget(DrawTarget* aTarget, const nsIntRect* aRect)
+CompositorParent::ForceComposeToTarget(DrawTarget* aTarget, const gfx::IntRect* aRect)
 {
   PROFILER_LABEL("CompositorParent", "ForceComposeToTarget",
     js::ProfileEntry::Category::GRAPHICS);
 
   if (mCompositorVsyncObserver) {
     mCompositorVsyncObserver->OnForceComposeToTarget();
   }
 
@@ -1333,17 +1333,17 @@ CompositorParent::AllocPLayerTransaction
                                                const uint64_t& aId,
                                                TextureFactoryIdentifier* aTextureFactoryIdentifier,
                                                bool *aSuccess)
 {
   MOZ_ASSERT(aId == 0);
 
   // mWidget doesn't belong to the compositor thread, so it should be set to
   // nullptr before returning from this method, to avoid accessing it elsewhere.
-  nsIntRect rect;
+  gfx::IntRect rect;
   mWidget->GetClientBounds(rect);
   InitializeLayerManager(aBackendHints);
   mWidget = nullptr;
 
   if (!mLayerManager) {
     NS_WARNING("Failed to initialise Compositor");
     *aSuccess = false;
     LayerTransactionParent* p = new LayerTransactionParent(nullptr, this, 0);
@@ -1595,17 +1595,17 @@ public:
   virtual bool RecvRequestOverfill() override { return true; }
   virtual bool RecvWillStop() override { return true; }
   virtual bool RecvStop() override { return true; }
   virtual bool RecvPause() override { return true; }
   virtual bool RecvResume() override { return true; }
   virtual bool RecvNotifyChildCreated(const uint64_t& child) override;
   virtual bool RecvAdoptChild(const uint64_t& child) override { return false; }
   virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
-                                const nsIntRect& aRect) override
+                                const gfx::IntRect& aRect) override
   { return true; }
   virtual bool RecvFlushRendering() override { return true; }
   virtual bool RecvNotifyRegionInvalidated(const nsIntRegion& aRegion) override { return true; }
   virtual bool RecvStartFrameTimeRecording(const int32_t& aBufferSize, uint32_t* aOutStartIndex) override { return true; }
   virtual bool RecvStopFrameTimeRecording(const uint32_t& aStartIndex, InfallibleTArray<float>* intervals) override  { return true; }
   virtual bool RecvGetTileSize(int32_t* aWidth, int32_t* aHeight) override
   {
     *aWidth = gfxPlatform::GetPlatform()->GetTileWidth();
--- a/gfx/layers/ipc/CompositorParent.h
+++ b/gfx/layers/ipc/CompositorParent.h
@@ -162,17 +162,17 @@ public:
   virtual bool RecvRequestOverfill() override;
   virtual bool RecvWillStop() override;
   virtual bool RecvStop() override;
   virtual bool RecvPause() override;
   virtual bool RecvResume() override;
   virtual bool RecvNotifyChildCreated(const uint64_t& child) override;
   virtual bool RecvAdoptChild(const uint64_t& child) override;
   virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
-                                const nsIntRect& aRect) override;
+                                const gfx::IntRect& aRect) override;
   virtual bool RecvFlushRendering() override;
 
   virtual bool RecvGetTileSize(int32_t* aWidth, int32_t* aHeight) override;
 
   virtual bool RecvNotifyRegionInvalidated(const nsIntRegion& aRegion) override;
   virtual bool RecvStartFrameTimeRecording(const int32_t& aBufferSize, uint32_t* aOutStartIndex) override;
   virtual bool RecvStopFrameTimeRecording(const uint32_t& aStartIndex, InfallibleTArray<float>* intervals) override;
 
@@ -359,18 +359,18 @@ protected:
   virtual PLayerTransactionParent*
     AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints,
                                  const uint64_t& aId,
                                  TextureFactoryIdentifier* aTextureFactoryIdentifier,
                                  bool* aSuccess) override;
   virtual bool DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers) override;
   virtual void ScheduleTask(CancelableTask*, int);
   void CompositeCallback(TimeStamp aScheduleTime);
-  void CompositeToTarget(gfx::DrawTarget* aTarget, const nsIntRect* aRect = nullptr);
-  void ForceComposeToTarget(gfx::DrawTarget* aTarget, const nsIntRect* aRect = nullptr);
+  void CompositeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect = nullptr);
+  void ForceComposeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect = nullptr);
 
   void SetEGLSurfaceSize(int width, int height);
 
   void InitializeLayerManager(const nsTArray<LayersBackend>& aBackendHints);
   void PauseComposition();
   void ResumeComposition();
   void ResumeCompositionAndResize(int width, int height);
   void ForceComposition();
--- a/gfx/layers/ipc/ImageBridgeChild.cpp
+++ b/gfx/layers/ipc/ImageBridgeChild.cpp
@@ -33,18 +33,16 @@
 #include "nsISupportsImpl.h"            // for ImageContainer::AddRef, etc
 #include "nsTArray.h"                   // for nsAutoTArray, nsTArray, etc
 #include "nsTArrayForwardDeclare.h"     // for AutoInfallibleTArray
 #include "nsThreadUtils.h"              // for NS_IsMainThread
 #include "nsXULAppAPI.h"                // for XRE_GetIOMessageLoop
 #include "mozilla/StaticPtr.h"          // for StaticRefPtr
 #include "mozilla/layers/TextureClient.h"
 
-struct nsIntRect;
-
 namespace mozilla {
 namespace ipc {
 class Shmem;
 }
 
 namespace layers {
 
 using base::Thread;
@@ -144,17 +142,17 @@ ImageBridgeChild::UseOverlaySource(Compo
 {
   MOZ_ASSERT(aCompositable);
   mTxn->AddEdit(OpUseOverlaySource(nullptr, aCompositable->GetIPDLActor(), aOverlay));
 }
 #endif
 
 void
 ImageBridgeChild::UpdatePictureRect(CompositableClient* aCompositable,
-                                    const nsIntRect& aRect)
+                                    const gfx::IntRect& aRect)
 {
   MOZ_ASSERT(aCompositable);
   MOZ_ASSERT(aCompositable->GetIPDLActor());
   mTxn->AddNoSwapEdit(OpUpdatePictureRect(nullptr, aCompositable->GetIPDLActor(), aRect));
 }
 
 // Singleton
 static StaticRefPtr<ImageBridgeChild> sImageBridgeChildSingleton;
--- a/gfx/layers/ipc/ImageBridgeChild.h
+++ b/gfx/layers/ipc/ImageBridgeChild.h
@@ -12,20 +12,19 @@
 #include "mozilla/RefPtr.h"             // for TemporaryRef
 #include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
 #include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTrackerHolder
 #include "mozilla/layers/CompositableForwarder.h"
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/PImageBridgeChild.h"
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT
 #include "nsRegion.h"                   // for nsIntRegion
+#include "mozilla/gfx/Rect.h"
 
 class MessageLoop;
-struct nsIntPoint;
-struct nsIntRect;
 
 namespace base {
 class Thread;
 }
 
 namespace mozilla {
 namespace ipc {
 class Shmem;
@@ -236,17 +235,17 @@ public:
   {
     NS_RUNTIMEABORT("should not be called");
   }
 
   /**
    * Communicate the picture rect of a YUV image in aLayer to the compositor
    */
   virtual void UpdatePictureRect(CompositableClient* aCompositable,
-                                 const nsIntRect& aRect) override;
+                                 const gfx::IntRect& aRect) override;
 
 
   virtual void UpdateTextureRegion(CompositableClient* aCompositable,
                                    const ThebesBufferData& aThebesBufferData,
                                    const nsIntRegion& aUpdatedRegion) override {
     NS_RUNTIMEABORT("should not be called");
   }
 
--- a/gfx/layers/ipc/LayersMessages.ipdlh
+++ b/gfx/layers/ipc/LayersMessages.ipdlh
@@ -14,19 +14,19 @@ include protocol PTexture;
 
 include "gfxipc/ShadowLayerUtils.h";
 include "mozilla/GfxMessageUtils.h";
 include "ImageLayers.h";
 
 using mozilla::GraphicsFilterType from "mozilla/GfxMessageUtils.h";
 using struct gfxRGBA from "gfxColor.h";
 using struct mozilla::gfx::Point3D from "mozilla/gfx/Point.h";
+using mozilla::gfx::IntPoint from "mozilla/gfx/Point.h";
 using class mozilla::gfx::Matrix4x4 from "mozilla/gfx/Matrix.h";
 using nscoord from "nsCoord.h";
-using struct nsIntPoint from "nsPoint.h";
 using struct nsRect from "nsRect.h";
 using struct nsPoint from "nsPoint.h";
 using class mozilla::TimeDuration from "mozilla/TimeStamp.h";
 using class mozilla::TimeStamp from "mozilla/TimeStamp.h";
 using mozilla::ScreenRotation from "mozilla/WidgetUtils.h";
 using nsCSSProperty from "nsCSSProperty.h";
 using mozilla::dom::ScreenOrientation from "mozilla/dom/ScreenOrientation.h";
 using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h";
@@ -42,17 +42,17 @@ using struct mozilla::layers::FrameMetri
 using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h";
 using struct mozilla::layers::FenceHandle from "mozilla/layers/FenceUtils.h";
 using std::string from "string";
 
 namespace mozilla {
 namespace layers {
 
 struct TargetConfig {
-  nsIntRect naturalBounds;
+  IntRect naturalBounds;
   ScreenRotation rotation;
   ScreenOrientation orientation;
   nsIntRegion clearRegion;
 };
 
 // Create a shadow layer for |layer|
 struct OpCreatePaintedLayer     { PLayer layer; };
 struct OpCreateContainerLayer  { PLayer layer; };
@@ -67,18 +67,18 @@ struct OpAttachCompositable {
 };
 
 struct OpAttachAsyncCompositable {
   PLayer layer;
   uint64_t containerID;
 };
 
 struct ThebesBufferData {
-  nsIntRect rect;
-  nsIntPoint rotation;
+  IntRect rect;
+  IntPoint rotation;
 };
 
 struct CubicBezierFunction {
   float x1;
   float y1;
   float x2;
   float y2;
 };
@@ -190,17 +190,17 @@ struct Animation {
   // This uses the NS_STYLE_ANIMATION_DIRECTION_* constants.
   int32_t direction;
   nsCSSProperty property;
   AnimationData data;
 };
 
 // Change a layer's attributes
 struct CommonLayerAttributes {
-  nsIntRect layerBounds;
+  IntRect layerBounds;
   nsIntRegion visibleRegion;
   EventRegions eventRegions;
   TransformMatrix transform;
   float postXScale;
   float postYScale;
   uint32_t contentFlags;
   float opacity;
   bool useClipRect;
@@ -236,18 +236,18 @@ struct ContainerLayerAttributes {
   float presShellResolution;
   bool scaleToResolution;
   EventRegionsOverride eventRegionsOverride;
   // This is a bare pointer; LayerTransactionParent::RecvUpdate prevents this
   // from being used when !IsSameProcess(), but we should make this truly
   // cross process at some point by passing the HMDConfig
   uint64_t hmdInfo;
 };
-struct ColorLayerAttributes     { LayerColor color; nsIntRect bounds; };
-struct CanvasLayerAttributes    { GraphicsFilterType filter; nsIntRect bounds; };
+struct ColorLayerAttributes     { LayerColor color; IntRect bounds; };
+struct CanvasLayerAttributes    { GraphicsFilterType filter; IntRect bounds; };
 struct RefLayerAttributes {
   int64_t id;
   // TODO: Once bug 1132895 is fixed we shouldn't need to propagate the override
   // explicitly here.
   EventRegionsOverride eventRegionsOverride;
 };
 struct ImageLayerAttributes     { GraphicsFilterType filter; IntSize scaleToSize; ScaleMode scaleMode; };
 
@@ -264,18 +264,18 @@ union SpecificLayerAttributes {
 struct LayerAttributes {
   CommonLayerAttributes common;
   SpecificLayerAttributes specific;
 };
 
 // See nsIWidget Configurations
 struct PluginWindowData {
   uintptr_t windowId;
-  nsIntRect[] clip;
-  nsIntRect bounds;
+  IntRect[] clip;
+  IntRect bounds;
   bool visible;
 };
 
 struct OpSetLayerAttributes {
   PLayer layer;
   LayerAttributes attrs;
 };
 
@@ -343,17 +343,17 @@ struct OpUseOverlaySource {
 struct OpPaintTextureRegion {
   PCompositable compositable;
   ThebesBufferData bufferData;
   nsIntRegion updatedRegion;
 };
 
 struct OpUpdatePictureRect {
   PCompositable compositable;
-  nsIntRect picture;
+  IntRect picture;
 };
 
 /**
  * Tells the CompositableHost to remove the corresponding TextureHost
  */
 struct OpRemoveTexture {
   PCompositable compositable;
   PTexture texture;
--- a/gfx/layers/ipc/LayersSurfaces.ipdlh
+++ b/gfx/layers/ipc/LayersSurfaces.ipdlh
@@ -1,21 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 using struct gfxPoint from "gfxPoint.h";
-using struct nsIntRect from "nsRect.h";
 using nsIntRegion from "nsRegion.h";
 using struct mozilla::layers::MagicGrallocBufferHandle from "gfxipc/ShadowLayerUtils.h";
 using struct mozilla::layers::GrallocBufferRef from "gfxipc/ShadowLayerUtils.h";
 using struct mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h";
 using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
 using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
 using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
+using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
 using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
 using gfxImageFormat from "gfxTypes.h";
 
 namespace mozilla {
 namespace layers {
 
 union OverlayHandle {
   int32_t;
--- a/gfx/layers/ipc/PCompositor.ipdl
+++ b/gfx/layers/ipc/PCompositor.ipdl
@@ -55,17 +55,17 @@ child:
    */
   async RemotePaintIsReady();
 
   /**
    * Bounce plugin widget configurations over to the main thread for
    * application on the widgets. Used on Windows and Linux in managing
    * plugin widgets.
    */
-  async UpdatePluginConfigurations(nsIntPoint aContentOffset,
+  async UpdatePluginConfigurations(IntPoint aContentOffset,
                                    nsIntRegion aVisibleRegion,
                                    PluginWindowData[] aPlugins);
 
   /**
    * Sets the list of currently visible plugin windows based on a
    * list of plugin window ids.
    */
   async UpdatePluginVisibility(uintptr_t[] aVisibleIdList);
@@ -90,17 +90,17 @@ parent:
 
   // Make a snapshot of the content that would have been drawn to our
   // render target at the time this message is received.  If the size
   // or format of |inSnapshot| doesn't match our render target,
   // results are undefined.
   //
   // NB: this message will result in animations, transforms, effects,
   // and so forth being interpolated.  That's what we want to happen.
-  sync MakeSnapshot(SurfaceDescriptor inSnapshot, nsIntRect dirtyRect);
+  sync MakeSnapshot(SurfaceDescriptor inSnapshot, IntRect dirtyRect);
 
   // Make sure any pending composites are started immediately and
   // block until they are completed.
   sync FlushRendering();
 
   // Get the size of the tiles. This number should not change at runtime.
   sync GetTileSize()
     returns (int32_t tileWidth, int32_t tileHeight);
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -23,24 +23,21 @@
 #include "mozilla/layers/LayersMessages.h"  // for Edit, etc
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
 #include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_LOG
 #include "mozilla/layers/LayerTransactionChild.h"
 #include "ShadowLayerUtils.h"
 #include "mozilla/layers/TextureClient.h"  // for TextureClient
 #include "mozilla/mozalloc.h"           // for operator new, etc
 #include "nsAutoPtr.h"                  // for nsRefPtr, getter_AddRefs, etc
-#include "nsRect.h"                     // for nsIntRect
 #include "nsSize.h"                     // for nsIntSize
 #include "nsTArray.h"                   // for nsAutoTArray, nsTArray, etc
 #include "nsXULAppAPI.h"                // for XRE_GetProcessType, etc
 #include "mozilla/ReentrantMonitor.h"
 
-struct nsIntPoint;
-
 namespace mozilla {
 namespace ipc {
 class Shmem;
 }
 
 namespace layers {
 
 using namespace mozilla::ipc;
@@ -57,17 +54,17 @@ class Transaction
 public:
   Transaction()
     : mTargetRotation(ROTATION_0)
     , mSwapRequired(false)
     , mOpen(false)
     , mRotationChanged(false)
   {}
 
-  void Begin(const nsIntRect& aTargetBounds, ScreenRotation aRotation,
+  void Begin(const gfx::IntRect& aTargetBounds, ScreenRotation aRotation,
              dom::ScreenOrientation aOrientation)
   {
     mOpen = true;
     mTargetBounds = aTargetBounds;
     if (aRotation != mTargetRotation) {
       // the first time this is called, mRotationChanged will be false if
       // aRotation is 0, but we should be OK because for the first transaction
       // we should only compose if it is non-empty. See the caller(s) of
@@ -134,17 +131,17 @@ public:
   }
   bool Finished() const { return !mOpen && Empty(); }
 
   bool Opened() const { return mOpen; }
 
   EditVector mCset;
   EditVector mPaints;
   ShadowableLayerSet mMutants;
-  nsIntRect mTargetBounds;
+  gfx::IntRect mTargetBounds;
   ScreenRotation mTargetRotation;
   dom::ScreenOrientation mTargetOrientation;
   bool mSwapRequired;
 
 private:
   bool mOpen;
   bool mRotationChanged;
 
@@ -180,17 +177,17 @@ ShadowLayerForwarder::~ShadowLayerForwar
   delete mTxn;
   if (mShadowManager) {
     mShadowManager->SetForwarder(nullptr);
     mShadowManager->Destroy();
   }
 }
 
 void
-ShadowLayerForwarder::BeginTransaction(const nsIntRect& aTargetBounds,
+ShadowLayerForwarder::BeginTransaction(const gfx::IntRect& aTargetBounds,
                                        ScreenRotation aRotation,
                                        dom::ScreenOrientation aOrientation)
 {
   MOZ_ASSERT(HasShadowManager(), "no manager to forward to");
   MOZ_ASSERT(mTxn->Finished(), "uncommitted txn?");
   mTxn->Begin(aTargetBounds, aRotation, aOrientation);
 }
 
@@ -349,17 +346,17 @@ ShadowLayerForwarder::UpdateTextureRegio
   MOZ_ASSERT(aCompositable->GetIPDLActor());
   mTxn->AddPaint(OpPaintTextureRegion(nullptr, aCompositable->GetIPDLActor(),
                                       aThebesBufferData,
                                       aUpdatedRegion));
 }
 
 void
 ShadowLayerForwarder::UpdatePictureRect(CompositableClient* aCompositable,
-                                        const nsIntRect& aRect)
+                                        const gfx::IntRect& aRect)
 {
   MOZ_ASSERT(aCompositable);
   MOZ_ASSERT(aCompositable->GetIPDLActor());
   mTxn->AddNoSwapPaint(OpUpdatePictureRect(nullptr, aCompositable->GetIPDLActor(), aRect));
 }
 
 void
 ShadowLayerForwarder::UseTexture(CompositableClient* aCompositable,
--- a/gfx/layers/ipc/ShadowLayers.h
+++ b/gfx/layers/ipc/ShadowLayers.h
@@ -7,29 +7,27 @@
 
 #ifndef mozilla_layers_ShadowLayers_h
 #define mozilla_layers_ShadowLayers_h 1
 
 #include <stddef.h>                     // for size_t
 #include <stdint.h>                     // for uint64_t
 #include "gfxTypes.h"
 #include "mozilla/Attributes.h"         // for override
+#include "mozilla/gfx/Rect.h"
 #include "mozilla/WidgetUtils.h"        // for ScreenRotation
 #include "mozilla/dom/ScreenOrientation.h"  // for ScreenOrientation
 #include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
 #include "mozilla/layers/CompositableForwarder.h"
 #include "mozilla/layers/CompositorTypes.h"  // for OpenMode, etc
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nsTArrayForwardDeclare.h"     // for InfallibleTArray
 #include "nsIWidget.h"
 
-struct nsIntPoint;
-struct nsIntRect;
-
 namespace mozilla {
 namespace layers {
 
 class ClientTiledLayerBuffer;
 class CanvasClient;
 class CanvasLayerComposite;
 class CanvasSurface;
 class ColorLayerComposite;
@@ -165,17 +163,17 @@ public:
    */
   void AttachAsyncCompositable(uint64_t aCompositableID,
                                ShadowableLayer* aLayer);
 
   /**
    * Begin recording a transaction to be forwarded atomically to a
    * LayerManagerComposite.
    */
-  void BeginTransaction(const nsIntRect& aTargetBounds,
+  void BeginTransaction(const gfx::IntRect& aTargetBounds,
                         ScreenRotation aRotation,
                         mozilla::dom::ScreenOrientation aOrientation);
 
   /**
    * The following methods may only be called after BeginTransaction()
    * but before EndTransaction().  They mirror the LayerManager
    * interface in Layers.h.
    */
@@ -253,17 +251,17 @@ public:
   virtual void UpdateTextureRegion(CompositableClient* aCompositable,
                                    const ThebesBufferData& aThebesBufferData,
                                    const nsIntRegion& aUpdatedRegion) override;
 
   /**
    * Communicate the picture rect of an image to the compositor
    */
   void UpdatePictureRect(CompositableClient* aCompositable,
-                         const nsIntRect& aRect) override;
+                         const gfx::IntRect& aRect) override;
 
   /**
    * See CompositableForwarder::UseTexture
    */
   virtual void UseTexture(CompositableClient* aCompositable,
                           TextureClient* aClient) override;
   virtual void UseComponentAlphaTextures(CompositableClient* aCompositable,
                                          TextureClient* aClientOnBlack,
--- a/gfx/layers/opengl/GLBlitTextureImageHelper.cpp
+++ b/gfx/layers/opengl/GLBlitTextureImageHelper.cpp
@@ -32,18 +32,18 @@ GLBlitTextureImageHelper::~GLBlitTexture
 {
     GLContext *gl = mCompositor->gl();
     // Likely used by OGL Layers.
     gl->fDeleteProgram(mBlitProgram);
     gl->fDeleteFramebuffers(1, &mBlitFramebuffer);
 }
 
 void
-GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const nsIntRect& aSrcRect,
-                                           TextureImage *aDst, const nsIntRect& aDstRect)
+GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const gfx::IntRect& aSrcRect,
+                                           TextureImage *aDst, const gfx::IntRect& aDstRect)
 {
     GLContext *gl = mCompositor->gl();
     NS_ASSERTION(!aSrc->InUpdate(), "Source texture is in update!");
     NS_ASSERTION(!aDst->InUpdate(), "Destination texture is in update!");
 
     if (!aSrc || !aDst || aSrcRect.IsEmpty() || aDstRect.IsEmpty())
         return;
 
@@ -56,40 +56,40 @@ GLBlitTextureImageHelper::BlitTextureIma
     // 2.0 means scale up by two
     float blitScaleX = float(aDstRect.width) / float(aSrcRect.width);
     float blitScaleY = float(aDstRect.height) / float(aSrcRect.height);
 
     // We start iterating over all destination tiles
     aDst->BeginBigImageIteration();
     do {
         // calculate portion of the tile that is going to be painted to
-        nsIntRect dstSubRect;
-        nsIntRect dstTextureRect = ThebesIntRect(aDst->GetTileRect());
+        gfx::IntRect dstSubRect;
+        gfx::IntRect dstTextureRect = ThebesIntRect(aDst->GetTileRect());
         dstSubRect.IntersectRect(aDstRect, dstTextureRect);
 
         // this tile is not part of the destination rectangle aDstRect
         if (dstSubRect.IsEmpty())
             continue;
 
         // (*) transform the rect of this tile into the rectangle defined by aSrcRect...
-        nsIntRect dstInSrcRect(dstSubRect);
+        gfx::IntRect dstInSrcRect(dstSubRect);
         dstInSrcRect.MoveBy(-aDstRect.TopLeft());
         // ...which might be of different size, hence scale accordingly
         dstInSrcRect.ScaleRoundOut(1.0f / blitScaleX, 1.0f / blitScaleY);
         dstInSrcRect.MoveBy(aSrcRect.TopLeft());
 
         SetBlitFramebufferForDestTexture(aDst->GetTextureID());
         UseBlitProgram();
 
         aSrc->BeginBigImageIteration();
         // now iterate over all tiles in the source Image...
         do {
             // calculate portion of the source tile that is in the source rect
-            nsIntRect srcSubRect;
-            nsIntRect srcTextureRect = ThebesIntRect(aSrc->GetTileRect());
+            gfx::IntRect srcSubRect;
+            gfx::IntRect srcTextureRect = ThebesIntRect(aSrc->GetTileRect());
             srcSubRect.IntersectRect(aSrcRect, srcTextureRect);
 
             // this tile is not part of the source rect
             if (srcSubRect.IsEmpty()) {
                 continue;
             }
             // calculate intersection of source rect with destination rect
             srcSubRect.IntersectRect(srcSubRect, dstInSrcRect);
@@ -99,17 +99,17 @@ GLBlitTextureImageHelper::BlitTextureIma
             }
             // We now have the intersection of
             //     the current source tile
             // and the desired source rectangle
             // and the destination tile
             // and the desired destination rectange
             // in destination space.
             // We need to transform this back into destination space, inverting the transform from (*)
-            nsIntRect srcSubInDstRect(srcSubRect);
+            gfx::IntRect srcSubInDstRect(srcSubRect);
             srcSubInDstRect.MoveBy(-aSrcRect.TopLeft());
             srcSubInDstRect.ScaleRoundOut(blitScaleX, blitScaleY);
             srcSubInDstRect.MoveBy(aDstRect.TopLeft());
 
             // we transform these rectangles to be relative to the current src and dst tiles, respectively
             nsIntSize srcSize = srcTextureRect.Size();
             nsIntSize dstSize = dstTextureRect.Size();
             srcSubRect.MoveBy(-srcTextureRect.x, -srcTextureRect.y);
--- a/gfx/layers/opengl/GLBlitTextureImageHelper.h
+++ b/gfx/layers/opengl/GLBlitTextureImageHelper.h
@@ -5,18 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GLBLITTEXTUREIMAGEHELPER_H_
 #define GLBLITTEXTUREIMAGEHELPER_H_
 
 #include "mozilla/Attributes.h"
 #include "GLContextTypes.h"
 #include "GLConsts.h"
-
-struct nsIntRect;
+#include "mozilla/gfx/Rect.h"
 
 namespace mozilla {
 namespace gl {
     class GLContext;
     class TextureImage;
 }
 namespace layers {
 
@@ -57,16 +56,16 @@ public:
      *   - viewport
      *   - blend state (will be enabled at end)
      *   - scissor state (will be enabled at end)
      *   - vertex attrib 0 and 1 (pointer and enable state [enable state will be disabled at exit])
      *   - array buffer binding (will be 0)
      *   - active texture (will be 0)
      *   - texture 0 binding
      */
-    void BlitTextureImage(gl::TextureImage *aSrc, const nsIntRect& aSrcRect,
-                          gl::TextureImage *aDst, const nsIntRect& aDstRect);
+    void BlitTextureImage(gl::TextureImage *aSrc, const gfx::IntRect& aSrcRect,
+                          gl::TextureImage *aDst, const gfx::IntRect& aDstRect);
 };
 
 }
 }
 
 #endif // GLBLITTEXTUREIMAGEHELPER_H_
--- a/gfx/layers/opengl/OGLShaderProgram.h
+++ b/gfx/layers/opengl/OGLShaderProgram.h
@@ -16,17 +16,16 @@
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsPoint.h"                    // for nsIntPoint
 #include "nsTArray.h"                   // for nsTArray
 #include "mozilla/layers/CompositorTypes.h"
 
 #include <string>
 
 struct gfxRGBA;
-struct nsIntRect;
 
 namespace mozilla {
 namespace layers {
 
 class Layer;
 
 enum ShaderFeatures {
   ENABLE_RENDER_COLOR=0x01,
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -17,17 +17,16 @@
 #include "mozilla/gfx/Logging.h"        // for gfxCriticalError
 #ifdef MOZ_WIDGET_GONK
 # include "GrallocImages.h"  // for GrallocImage
 # include "EGLImageHelpers.h"
 #endif
 #include "mozilla/layers/ISurfaceAllocator.h"
 #include "mozilla/layers/YCbCrImageDataSerializer.h"
 #include "mozilla/layers/GrallocTextureHost.h"
-#include "nsPoint.h"                    // for nsIntPoint
 #include "nsRegion.h"                   // for nsIntRegion
 #include "AndroidSurfaceTexture.h"
 #include "GfxTexturesReporter.h"        // for GfxTexturesReporter
 #include "GLBlitTextureImageHelper.h"
 #ifdef XP_MACOSX
 #include "SharedSurfaceIO.h"
 #include "mozilla/layers/MacIOSurfaceTextureHostOGL.h"
 #endif
@@ -253,17 +252,17 @@ TextureImageTextureSourceOGL::Update(gfx
                                      LOCAL_GL_CLAMP_TO_EDGE,
                                      FlagsToGLFlags(mFlags),
                                      SurfaceFormatToImageFormat(aSurface->GetFormat()));
     }
     ClearCachedFilter();
 
     if (aDestRegion &&
         !aSrcOffset &&
-        !aDestRegion->IsEqual(nsIntRect(0, 0, size.width, size.height))) {
+        !aDestRegion->IsEqual(gfx::IntRect(0, 0, size.width, size.height))) {
       // UpdateFromDataSource will ignore our specified aDestRegion since the texture
       // hasn't been allocated with glTexImage2D yet. Call Resize() to force the
       // allocation (full size, but no upload), and then we'll only upload the pixels
       // we care about below.
       mTexImage->Resize(size);
     }
   }
 
@@ -287,19 +286,19 @@ TextureImageTextureSourceOGL::EnsureBuff
                                    aContentType,
                                    LOCAL_GL_CLAMP_TO_EDGE,
                                    FlagsToGLFlags(mFlags));
   }
   mTexImage->Resize(aSize);
 }
 
 void
-TextureImageTextureSourceOGL::CopyTo(const nsIntRect& aSourceRect,
+TextureImageTextureSourceOGL::CopyTo(const gfx::IntRect& aSourceRect,
                                      DataTextureSource *aDest,
-                                     const nsIntRect& aDestRect)
+                                     const gfx::IntRect& aDestRect)
 {
   MOZ_ASSERT(aDest->AsSourceOGL(), "Incompatible destination type!");
   TextureImageTextureSourceOGL *dest =
     aDest->AsSourceOGL()->AsTextureImageTextureSource();
   MOZ_ASSERT(dest, "Incompatible destination type!");
 
   mCompositor->BlitTextureImageHelper()->BlitTextureImage(mTexImage, aSourceRect,
                                                   dest->mTexImage, aDestRect);
@@ -336,17 +335,17 @@ TextureImageTextureSourceOGL::GetFormat(
 {
   if (mTexImage) {
     return mTexImage->GetTextureFormat();
   }
   NS_WARNING("Trying to query the format of an empty TextureSource.");
   return gfx::SurfaceFormat::UNKNOWN;
 }
 
-nsIntRect TextureImageTextureSourceOGL::GetTileRect()
+gfx::IntRect TextureImageTextureSourceOGL::GetTileRect()
 {
   return ThebesIntRect(mTexImage->GetTileRect());
 }
 
 void
 TextureImageTextureSourceOGL::BindTexture(GLenum aTextureUnit, gfx::Filter aFilter)
 {
   MOZ_ASSERT(mTexImage,
--- a/gfx/layers/opengl/TextureHostOGL.h
+++ b/gfx/layers/opengl/TextureHostOGL.h
@@ -34,18 +34,16 @@
 #include <ui/GraphicBuffer.h>
 #if ANDROID_VERSION >= 17
 #include <ui/Fence.h>
 #endif
 #endif
 
 class gfxReusableSurfaceWrapper;
 class nsIntRegion;
-struct nsIntPoint;
-struct nsIntRect;
 
 namespace mozilla {
 namespace gfx {
 class DataSourceSurface;
 }
 
 namespace gl {
 class AndroidSurfaceTexture;
@@ -199,19 +197,19 @@ public:
 
   virtual bool Update(gfx::DataSourceSurface* aSurface,
                       nsIntRegion* aDestRegion = nullptr,
                       gfx::IntPoint* aSrcOffset = nullptr) override;
 
   void EnsureBuffer(const gfx::IntSize& aSize,
                     gfxContentType aContentType);
 
-  void CopyTo(const nsIntRect& aSourceRect,
-                      DataTextureSource* aDest,
-                      const nsIntRect& aDestRect);
+  void CopyTo(const gfx::IntRect& aSourceRect,
+              DataTextureSource* aDest,
+              const gfx::IntRect& aDestRect);
 
   virtual TextureImageTextureSourceOGL* AsTextureImageTextureSource() override { return this; }
 
   // TextureSource
 
   virtual void DeallocateDeviceData() override
   {
     mTexImage = nullptr;
@@ -245,17 +243,17 @@ public:
     mIterating = true;
   }
 
   virtual void EndBigImageIteration() override
   {
     mIterating = false;
   }
 
-  virtual nsIntRect GetTileRect() override;
+  virtual gfx::IntRect GetTileRect() override;
 
   virtual size_t GetTileCount() override
   {
     return mTexImage->GetTileCount();
   }
 
   virtual bool NextTile() override
   {
--- a/gfx/src/nsPoint.h
+++ b/gfx/src/nsPoint.h
@@ -5,18 +5,22 @@
 
 #ifndef NSPOINT_H
 #define NSPOINT_H
 
 #include "nsCoord.h"
 #include "mozilla/gfx/BaseSize.h"
 #include "mozilla/gfx/BasePoint.h"
 #include "nsSize.h"
+#include "mozilla/gfx/Point.h"
 
-struct nsIntPoint;
+// nsIntPoint represents a point in one of the types of pixels.
+// Uses of nsIntPoint should eventually be converted to CSSIntPoint,
+// LayoutDeviceIntPoint, etc. (see layout/base/Units.h).
+typedef mozilla::gfx::IntPoint nsIntPoint;
 
 // nsPoint represents a point in app units.
 
 struct nsPoint : public mozilla::gfx::BasePoint<nscoord, nsPoint> {
   typedef mozilla::gfx::BasePoint<nscoord, nsPoint> Super;
 
   nsPoint() : Super() {}
   nsPoint(const nsPoint& aPoint) : Super(aPoint) {}
@@ -30,29 +34,17 @@ struct nsPoint : public mozilla::gfx::Ba
    * Return this point scaled to a different appunits per pixel (APP) ratio.
    * @param aFromAPP the APP to scale from
    * @param aToAPP the APP to scale to
    */
   MOZ_WARN_UNUSED_RESULT inline nsPoint
     ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
 };
 
-// nsIntPoint represents a point in one of the types of pixels.
-// Uses of nsIntPoint should eventually be converted to CSSIntPoint,
-// LayoutDeviceIntPoint, etc. (see layout/base/Units.h).
-
-struct nsIntPoint : public mozilla::gfx::BasePoint<int32_t, nsIntPoint> {
-  typedef mozilla::gfx::BasePoint<int32_t, nsIntPoint> Super;
-
-  nsIntPoint() : Super() {}
-  nsIntPoint(const nsIntPoint& aPoint) : Super(aPoint) {}
-  nsIntPoint(int32_t aX, int32_t aY) : Super(aX, aY) {}
-
-  inline nsPoint ToAppUnits(nscoord aAppUnitsPerPixel) const;
-};
+inline nsPoint ToAppUnits(const nsIntPoint& aPoint, nscoord aAppUnitsPerPixel);
 
 inline nsIntPoint
 nsPoint::ScaleToNearestPixels(float aXScale, float aYScale,
                               nscoord aAppUnitsPerPixel) const
 {
   return nsIntPoint(
       NSToIntRoundUp(NSAppUnitsToDoublePixels(x, aAppUnitsPerPixel) * aXScale),
       NSToIntRoundUp(NSAppUnitsToDoublePixels(y, aAppUnitsPerPixel) * aYScale));
@@ -73,15 +65,15 @@ nsPoint::ScaleToOtherAppUnits(int32_t aF
     point.y = NSToCoordRound(NSCoordScale(y, aFromAPP, aToAPP));
     return point;
   }
   return *this;
 }
 
 // app units are integer multiples of pixels, so no rounding needed
 inline nsPoint
-nsIntPoint::ToAppUnits(nscoord aAppUnitsPerPixel) const
+ToAppUnits(const nsIntPoint& aPoint, nscoord aAppUnitsPerPixel)
 {
-  return nsPoint(NSIntPixelsToAppUnits(x, aAppUnitsPerPixel),
-                 NSIntPixelsToAppUnits(y, aAppUnitsPerPixel));
+  return nsPoint(NSIntPixelsToAppUnits(aPoint.x, aAppUnitsPerPixel),
+                 NSIntPixelsToAppUnits(aPoint.y, aAppUnitsPerPixel));
 }
 
 #endif /* NSPOINT_H */
--- a/gfx/src/nsRect.cpp
+++ b/gfx/src/nsRect.cpp
@@ -10,16 +10,30 @@
 #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 nsIntRect& aRect, nscoord aAppUnitsPerPixel)
+{
+  return nsRect(NSIntPixelsToAppUnits(aRect.x, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(aRect.y, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(aRect.width, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(aRect.height, aAppUnitsPerPixel));
+}
+
+const nsIntRect& GetMaxSizedIntRect() {
+  static const nsIntRect r(0, 0, INT32_MAX, INT32_MAX);
+  return r;
+}
+
 #ifdef DEBUG
 // Diagnostics
 
 FILE* operator<<(FILE* out, const nsRect& rect)
 {
   nsAutoString tmp;
 
   // Output the coordinates in fractional pixels so they're easier to read
--- a/gfx/src/nsRect.h
+++ b/gfx/src/nsRect.h
@@ -8,28 +8,28 @@
 #define NSRECT_H
 
 #include <stdio.h>                      // for FILE
 #include <stdint.h>                     // for int32_t, int64_t
 #include <algorithm>                    // for min/max
 #include "nsDebug.h"                    // for NS_WARNING
 #include "gfxCore.h"                    // for NS_GFX
 #include "mozilla/Likely.h"             // for MOZ_UNLIKELY
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "mozilla/gfx/NumericTools.h"   // for RoundUpToMultiple, RoundDownToMultiple
+#include "mozilla/gfx/Rect.h"
 #include "nsCoord.h"                    // for nscoord, etc
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsPoint.h"                    // for nsIntPoint, nsPoint
 #include "nsSize.h"                     // for nsIntSize, nsSize
 #include "nscore.h"                     // for NS_BUILD_REFCNT_LOGGING
 
-struct nsIntRect;
 struct nsMargin;
 struct nsIntMargin;
 
+typedef mozilla::gfx::IntRect nsIntRect;
+
 struct NS_GFX nsRect :
   public mozilla::gfx::BaseRect<nscoord, nsRect, nsPoint, nsSize, nsMargin> {
   typedef mozilla::gfx::BaseRect<nscoord, nsRect, nsPoint, nsSize, nsMargin> Super;
 
   static void VERIFY_COORD(nscoord aValue) { ::VERIFY_COORD(aValue); }
 
   // Constructors
   nsRect() : Super()
@@ -174,66 +174,16 @@ struct NS_GFX nsRect :
 
   // This is here only to keep IPDL-generated code happy. DO NOT USE.
   bool operator==(const nsRect& aRect) const
   {
     return IsEqualEdges(aRect);
   }
 };
 
-struct NS_GFX nsIntRect :
-  public mozilla::gfx::BaseRect<int32_t, nsIntRect, nsIntPoint, nsIntSize, nsIntMargin> {
-  typedef mozilla::gfx::BaseRect<int32_t, nsIntRect, nsIntPoint, nsIntSize, nsIntMargin> Super;
-
-  // Constructors
-  nsIntRect() : Super()
-  {
-  }
-  nsIntRect(const nsIntRect& aRect) : Super(aRect)
-  {
-  }
-  nsIntRect(const nsIntPoint& aOrigin, const nsIntSize &aSize) : Super(aOrigin, aSize)
-  {
-  }
-  nsIntRect(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight) :
-      Super(aX, aY, aWidth, aHeight)
-  {
-  }
-
-  MOZ_WARN_UNUSED_RESULT inline nsRect
-  ToAppUnits(nscoord aAppUnitsPerPixel) const;
-
-  // Returns a special nsIntRect that's used in some places to signify
-  // "all available space".
-  static const nsIntRect& GetMaxSizedIntRect() {
-    static const nsIntRect r(0, 0, INT32_MAX, INT32_MAX);
-    return r;
-  }
-
-  void InflateToMultiple(const nsIntSize& aTileSize)
-  {
-    int32_t xMost = XMost();
-    int32_t yMost = YMost();
-
-    x = RoundDownToMultiple(x, aTileSize.width);
-    y = RoundDownToMultiple(y, aTileSize.height);
-    xMost = RoundUpToMultiple(xMost, aTileSize.width);
-    yMost = RoundUpToMultiple(yMost, aTileSize.height);
-
-    width = xMost - x;
-    height = yMost - y;
-  }
-
-  // This is here only to keep IPDL-generated code happy. DO NOT USE.
-  bool operator==(const nsIntRect& aRect) const
-  {
-    return IsEqualEdges(aRect);
-  }
-};
-
 /*
  * App Unit/Pixel conversions
  */
 
 inline nsRect
 nsRect::ScaleToOtherAppUnitsRoundOut(int32_t aFromAPP, int32_t aToAPP) const
 {
   if (aFromAPP == aToAPP) {
@@ -330,24 +280,20 @@ nsRect::ToOutsidePixels(nscoord aAppUnit
 }
 
 inline nsIntRect
 nsRect::ToInsidePixels(nscoord aAppUnitsPerPixel) const
 {
   return ScaleToInsidePixels(1.0f, 1.0f, aAppUnitsPerPixel);
 }
 
+const nsIntRect& GetMaxSizedIntRect();
+
 // app units are integer multiples of pixels, so no rounding needed
-inline nsRect
-nsIntRect::ToAppUnits(nscoord aAppUnitsPerPixel) const
-{
-  return nsRect(NSIntPixelsToAppUnits(x, aAppUnitsPerPixel),
-                NSIntPixelsToAppUnits(y, aAppUnitsPerPixel),
-                NSIntPixelsToAppUnits(width, aAppUnitsPerPixel),
-                NSIntPixelsToAppUnits(height, aAppUnitsPerPixel));
-}
+nsRect
+ToAppUnits(const nsIntRect& aRect, nscoord aAppUnitsPerPixel);
 
 #ifdef DEBUG
 // Diagnostics
 extern NS_GFX FILE* operator<<(FILE* out, const nsRect& rect);
 #endif // DEBUG
 
 #endif /* NSRECT_H */
--- a/gfx/src/nsRegion.h
+++ b/gfx/src/nsRegion.h
@@ -694,17 +694,17 @@ public:
   Rect GetBounds () const { return FromRect (mImpl.GetBounds ()); }
   uint64_t Area () const { return mImpl.Area(); }
   nsRegion ToAppUnits (nscoord aAppUnitsPerPixel) const
   {
     nsRegion result;
     RectIterator rgnIter(*this);
     const Rect* currentRect;
     while ((currentRect = rgnIter.Next())) {
-      nsRect appRect = currentRect->ToAppUnits(aAppUnitsPerPixel);
+      nsRect appRect = ::ToAppUnits(*currentRect, aAppUnitsPerPixel);
       result.Or(result, appRect);
     }
     return result;
   }
   Rect GetLargestRectangle (const Rect& aContainingRect = Rect()) const
   {
     return FromRect (mImpl.GetLargestRectangle( ToRect(aContainingRect) ));
   }
--- a/gfx/thebes/gfx2DGlue.h
+++ b/gfx/thebes/gfx2DGlue.h
@@ -71,16 +71,26 @@ inline Point ToPoint(const gfxPoint &aPo
   return Point(Float(aPoint.x), Float(aPoint.y));
 }
 
 inline IntPoint ToIntPoint(const nsIntPoint &aPoint)
 {
   return IntPoint(aPoint.x, aPoint.y);
 }
 
+inline IntMargin ToIntMargin(const nsIntMargin& aMargin)
+{
+  return IntMargin(aMargin.top, aMargin.right, aMargin.bottom, aMargin.left);
+}
+
+inline nsIntPoint ThebesIntPoint(const IntPoint &aPoint)
+{
+  return nsIntPoint(aPoint.x, aPoint.y);
+}
+
 inline Size ToSize(const gfxSize &aSize)
 {
   return Size(Float(aSize.width), Float(aSize.height));
 }
 
 inline Filter ToFilter(GraphicsFilter aFilter)
 {
   switch (aFilter) {
--- a/gfx/thebes/gfxASurface.h
+++ b/gfx/thebes/gfxASurface.h
@@ -7,26 +7,25 @@
 #define GFX_ASURFACE_H
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/UniquePtr.h"
 
 #include "gfxTypes.h"
 #include "nscore.h"
 #include "nsSize.h"
+#include "mozilla/gfx/Rect.h"
 
 #ifdef MOZILLA_INTERNAL_API
 #include "nsStringFwd.h"
 #else
 #include "nsStringAPI.h"
 #endif
 
 class gfxImageSurface;
-struct nsIntPoint;
-struct nsIntRect;
 struct gfxRect;
 struct gfxPoint;
 
 template <typename T>
 struct already_AddRefed;
 
 /**
  * A surface is something you can draw on. Instantiate a subclass of this
--- a/gfx/thebes/gfxAlphaRecovery.h
+++ b/gfx/thebes/gfxAlphaRecovery.h
@@ -3,19 +3,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _GFXALPHARECOVERY_H_
 #define _GFXALPHARECOVERY_H_
 
 #include "mozilla/SSE.h"
 #include "gfxTypes.h"
-#include "nsRect.h"
+#include "mozilla/gfx/Rect.h"
 
-struct nsIntRect;
 class gfxImageSurface;
 
 class gfxAlphaRecovery {
 public:
     /**
      * Some SIMD fast-paths only can be taken if the relative
      * byte-alignment of images' pointers and strides meets certain
      * criteria.  Aligning image pointers and strides by
@@ -48,21 +47,21 @@ public:
      * surface, the "black image", into which alpha-recovered pixels
      * are eventually to be written.  This function returns a rect
      * aligned so that recovering alpha for that rect will hit SIMD
      * fast-paths, if possible.  It's not always possible to align
      * |aRect| so that fast-paths will be taken.
      *
      * The returned rect is always a superset of |aRect|.
      */
-    static nsIntRect AlignRectForSubimageRecovery(const nsIntRect& aRect,
-                                                  gfxImageSurface* aSurface);
+    static mozilla::gfx::IntRect AlignRectForSubimageRecovery(const mozilla::gfx::IntRect& aRect,
+                                                              gfxImageSurface* aSurface);
 #else
-    static nsIntRect AlignRectForSubimageRecovery(const nsIntRect& aRect,
-                                                  gfxImageSurface*)
+    static mozilla::gfx::IntRect AlignRectForSubimageRecovery(const mozilla::gfx::IntRect& aRect,
+                                                              gfxImageSurface*)
     { return aRect; }
 #endif
 
     /** from cairo-xlib-utils.c, modified */
     /**
      * Given the RGB data for two image surfaces, one a source image composited
      * with OVER onto a black background, and one a source image composited with 
      * OVER onto a white background, reconstruct the original image data into
--- a/gfx/thebes/gfxAlphaRecoverySSE2.cpp
+++ b/gfx/thebes/gfxAlphaRecoverySSE2.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gfxAlphaRecovery.h"
 #include "gfxImageSurface.h"
-#include "nsRect.h"
 #include <emmintrin.h>
 
 // This file should only be compiled on x86 and x64 systems.  Additionally,
 // you'll need to compile it with -msse2 if you're using GCC on x86.
 
 #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))
 __declspec(align(16)) static uint32_t greenMaski[] =
     { 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00 };
@@ -132,18 +131,18 @@ gfxAlphaRecovery::RecoverAlphaSSE2(gfxIm
 }
 
 static int32_t
 ByteAlignment(int32_t aAlignToLog2, int32_t aX, int32_t aY=0, int32_t aStride=1)
 {
     return (aX + aStride * aY) & ((1 << aAlignToLog2) - 1);
 }
 
-/*static*/ nsIntRect
-gfxAlphaRecovery::AlignRectForSubimageRecovery(const nsIntRect& aRect,
+/*static*/ mozilla::gfx::IntRect
+gfxAlphaRecovery::AlignRectForSubimageRecovery(const mozilla::gfx::IntRect& aRect,
                                                gfxImageSurface* aSurface)
 {
     NS_ASSERTION(gfxImageFormat::ARGB32 == aSurface->Format(),
                  "Thebes grew support for non-ARGB32 COLOR_ALPHA?");
     static const int32_t kByteAlignLog2 = GoodAlignmentLog2();
     static const int32_t bpp = 4;
     static const int32_t pixPerAlign = (1 << kByteAlignLog2) / bpp;
     //
@@ -224,13 +223,13 @@ gfxAlphaRecovery::AlignRectForSubimageRe
             }
         }
     }
 
     // Didn't find a solution.
     return aRect;
 
 FOUND_SOLUTION:
-    nsIntRect solution = nsIntRect(x - dx, y - dy, w + dr + dx, h + dy);
-    MOZ_ASSERT(nsIntRect(0, 0, sw, surfaceSize.height).Contains(solution),
+    mozilla::gfx::IntRect solution = mozilla::gfx::IntRect(x - dx, y - dy, w + dr + dx, h + dy);
+    MOZ_ASSERT(mozilla::gfx::IntRect(0, 0, sw, surfaceSize.height).Contains(solution),
                "'Solution' extends outside surface bounds!");
     return solution;
 }
--- a/gfx/thebes/gfxD2DSurface.cpp
+++ b/gfx/thebes/gfxD2DSurface.cpp
@@ -52,17 +52,17 @@ gfxD2DSurface::~gfxD2DSurface()
 
 void
 gfxD2DSurface::Present()
 {
     cairo_d2d_present_backbuffer(CairoSurface());
 }
 
 void
-gfxD2DSurface::Scroll(const nsIntPoint &aDelta, const nsIntRect &aClip)
+gfxD2DSurface::Scroll(const nsIntPoint &aDelta, const mozilla::gfx::IntRect &aClip)
 {
     cairo_rectangle_t rect;
     rect.x = aClip.x;
     rect.y = aClip.y;
     rect.width = aClip.width;
     rect.height = aClip.height;
     cairo_d2d_scroll(CairoSurface(), aDelta.x, aDelta.y, &rect);
 }
@@ -75,17 +75,17 @@ gfxD2DSurface::GetTexture()
 
 HDC
 gfxD2DSurface::GetDC(bool aRetainContents)
 {
     return cairo_d2d_get_dc(CairoSurface(), aRetainContents);
 }
 
 void
-gfxD2DSurface::ReleaseDC(const nsIntRect *aUpdatedRect)
+gfxD2DSurface::ReleaseDC(const mozilla::gfx::IntRect *aUpdatedRect)
 {
     if (!aUpdatedRect) {
         return cairo_d2d_release_dc(CairoSurface(), nullptr);
     }
 
     cairo_rectangle_int_t rect;
     rect.x = aUpdatedRect->x;
     rect.y = aUpdatedRect->y;
--- a/gfx/thebes/gfxD2DSurface.h
+++ b/gfx/thebes/gfxD2DSurface.h
@@ -7,17 +7,16 @@
 #define GFX_D2DSURFACE_H
 
 #include "gfxASurface.h"
 #include "nsPoint.h"
 
 #include <windows.h>
 
 struct ID3D10Texture2D;
-struct nsIntRect;
 
 class gfxD2DSurface : public gfxASurface {
 public:
 
     gfxD2DSurface(HWND wnd,
                   gfxContentType aContent);
 
     gfxD2DSurface(const gfxIntSize& size,
@@ -27,19 +26,19 @@ public:
 
     gfxD2DSurface(ID3D10Texture2D *texture, gfxContentType aContent);
 
     gfxD2DSurface(cairo_surface_t *csurf);
 
     virtual ~gfxD2DSurface();
 
     void Present();
-    void Scroll(const nsIntPoint &aDelta, const nsIntRect &aClip);
+    void Scroll(const nsIntPoint &aDelta, const mozilla::gfx::IntRect &aClip);
 
-    virtual const gfxIntSize GetSize() const;
+    virtual const mozilla::gfx::IntSize GetSize() const;
 
     ID3D10Texture2D *GetTexture();
 
     HDC GetDC(bool aRetainContents);
-    void ReleaseDC(const nsIntRect *aUpdatedRect);
+    void ReleaseDC(const mozilla::gfx::IntRect *aUpdatedRect);
 };
 
 #endif /* GFX_D2DSURFACE_H */
--- a/gfx/thebes/gfxQtNativeRenderer.h
+++ b/gfx/thebes/gfxQtNativeRenderer.h
@@ -4,19 +4,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFXQTNATIVERENDER_H_
 #define GFXQTNATIVERENDER_H_
 
 #include "gfxColor.h"
 #include "gfxContext.h"
 #include "gfxXlibSurface.h"
+#include "mozilla/gfx/Rect.h"
 
 class QRect;
-struct nsIntRect;
 
 /**
  * This class lets us take code that draws into an Xlib surface drawable and lets us
  * use it to draw into any Thebes context. The user should subclass this class,
  * override NativeDraw, and then call Draw(). The drawing will be subjected
  * to all Thebes transformations, clipping etc.
  */
 class gfxQtNativeRenderer {
@@ -26,18 +26,19 @@ public:
      * @param offsetX draw at this offset into the given drawable
      * @param offsetY draw at this offset into the given drawable
      * @param clipRects an array of rects; clip to the union
      * @param numClipRects the number of rects in the array, or zero if
      * no clipping is required
      */
     virtual nsresult DrawWithXlib(cairo_surface_t* surface,
                                   nsIntPoint offset,
-                                  nsIntRect* clipRects, uint32_t numClipRects) = 0;
-  
+                                  mozilla::gfx::IntRect* clipRects,
+                                  uint32_t numClipRects) = 0;
+
     enum {
         // If set, then Draw() is opaque, i.e., every pixel in the intersection
         // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height)
         // will be set and there is no dependence on what the existing pixels
         // in the drawable are set to.
         DRAW_IS_OPAQUE = 0x01,
         // If set, then numClipRects can be zero or one
         DRAW_SUPPORTS_CLIP_RECT = 0x04,
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -685,17 +685,17 @@ gfxUtils::ImageFormatToDepth(gfxImageFor
     return 0;
 }
 
 static void
 PathFromRegionInternal(gfxContext* aContext, const nsIntRegion& aRegion)
 {
   aContext->NewPath();
   nsIntRegionRectIterator iter(aRegion);
-  const nsIntRect* r;
+  const IntRect* r;
   while ((r = iter.Next()) != nullptr) {
     aContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height));
   }
 }
 
 static void
 ClipToRegionInternal(gfxContext* aContext, const nsIntRegion& aRegion)
 {
@@ -704,33 +704,33 @@ ClipToRegionInternal(gfxContext* aContex
 }
 
 static TemporaryRef<Path>
 PathFromRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion)
 {
   RefPtr<PathBuilder> pb = aTarget->CreatePathBuilder();
   nsIntRegionRectIterator iter(aRegion);
 
-  const nsIntRect* r;
+  const IntRect* r;
   while ((r = iter.Next()) != nullptr) {
     pb->MoveTo(Point(r->x, r->y));
     pb->LineTo(Point(r->XMost(), r->y));
     pb->LineTo(Point(r->XMost(), r->YMost()));
     pb->LineTo(Point(r->x, r->YMost()));
     pb->Close();
   }
   RefPtr<Path> path = pb->Finish();
   return path;
 }
 
 static void
 ClipToRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion)
 {
   if (!aRegion.IsComplex()) {
-    nsIntRect rect = aRegion.GetBounds();
+    IntRect rect = aRegion.GetBounds();
     aTarget->PushClipRect(Rect(rect.x, rect.y, rect.width, rect.height));
     return;
   }
 
   RefPtr<Path> path = PathFromRegionInternal(aTarget, aRegion);
   aTarget->PushClip(path);
 }
 
@@ -842,19 +842,19 @@ gfxUtils::TransformRectToRect(const gfxR
   }
   return m;
 }
 
 /* This function is sort of shitty. We truncate doubles
  * to ints then convert those ints back to doubles to make sure that
  * they equal the doubles that we got in. */
 bool
-gfxUtils::GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut)
+gfxUtils::GfxRectToIntRect(const gfxRect& aIn, IntRect* aOut)
 {
-  *aOut = nsIntRect(int32_t(aIn.X()), int32_t(aIn.Y()),
+  *aOut = IntRect(int32_t(aIn.X()), int32_t(aIn.Y()),
   int32_t(aIn.Width()), int32_t(aIn.Height()));
   return gfxRect(aOut->x, aOut->y, aOut->width, aOut->height).IsEqualEdges(aIn);
 }
 
 void
 gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrData& aData,
                                          gfxImageFormat& aSuggestedFormat,
                                          gfxIntSize& aSuggestedSize)
@@ -990,34 +990,34 @@ gfxUtils::ConvertYCbCrToRGB(const Planar
                                aData.mYStride,
                                aData.mCbCrStride,
                                aStride,
                                yuvtype);
   }
 }
 
 /* static */ void gfxUtils::ClearThebesSurface(gfxASurface* aSurface,
-                                               nsIntRect* aRect,
+                                               IntRect* aRect,
                                                const gfxRGBA& aColor)
 {
   if (aSurface->CairoStatus()) {
     return;
   }
   cairo_surface_t* surf = aSurface->CairoSurface();
   if (cairo_surface_status(surf)) {
     return;
   }
   cairo_t* ctx = cairo_create(surf);
   cairo_set_source_rgba(ctx, aColor.r, aColor.g, aColor.b, aColor.a);
   cairo_set_operator(ctx, CAIRO_OPERATOR_SOURCE);
-  nsIntRect bounds;
+  IntRect bounds;
   if (aRect) {
     bounds = *aRect;
   } else {
-    bounds = nsIntRect(nsIntPoint(0, 0), aSurface->GetSize());
+    bounds = IntRect(nsIntPoint(0, 0), aSurface->GetSize());
   }
   cairo_rectangle(ctx, bounds.x, bounds.y, bounds.width, bounds.height);
   cairo_fill(ctx);
   cairo_destroy(ctx);
 }
 
 /* static */ TemporaryRef<DataSourceSurface>
 gfxUtils::CopySurfaceToDataSourceSurfaceWithFormat(SourceSurface* aSurface,
--- a/gfx/thebes/gfxUtils.h
+++ b/gfx/thebes/gfxUtils.h
@@ -9,24 +9,23 @@
 #include "gfxColor.h"
 #include "gfxTypes.h"
 #include "GraphicsFilter.h"
 #include "imgIContainer.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/RefPtr.h"
 #include "nsColor.h"
 #include "nsPrintfCString.h"
+#include "mozilla/gfx/Rect.h"
 
 class gfxASurface;
 class gfxDrawable;
 class nsIntRegion;
 class nsIPresShell;
 
-struct nsIntRect;
-
 namespace mozilla {
 namespace layers {
 struct PlanarYCbCrData;
 }
 namespace image {
 class ImageRegion;
 }
 }
@@ -116,21 +115,21 @@ public:
                                          const gfxPoint& aToBottomRight);
 
     static Matrix TransformRectToRect(const gfxRect& aFrom,
                                       const IntPoint& aToTopLeft,
                                       const IntPoint& aToTopRight,
                                       const IntPoint& aToBottomRight);
 
     /**
-     * If aIn can be represented exactly using an nsIntRect (i.e.
+     * If aIn can be represented exactly using an gfx::IntRect (i.e.
      * integer-aligned edges and coordinates in the int32_t range) then we
      * set aOut to that rectangle, otherwise return failure.
     */
-    static bool GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut);
+    static bool GfxRectToIntRect(const gfxRect& aIn, mozilla::gfx::IntRect* aOut);
 
     /**
      * Return the smallest power of kScaleResolution (2) greater than or equal to
      * aVal.
      */
     static gfxFloat ClampToScaleFactor(gfxFloat aVal);
 
     /**
@@ -158,17 +157,17 @@ public:
                       const gfxIntSize& aDestSize,
                       unsigned char* aDestBuffer,
                       int32_t aStride);
 
     /**
      * Clears surface to aColor (which defaults to transparent black).
      */
     static void ClearThebesSurface(gfxASurface* aSurface,
-                                   nsIntRect* aRect = nullptr,
+                                   mozilla::gfx::IntRect* aRect = nullptr,
                                    const gfxRGBA& aColor = gfxRGBA(0.0, 0.0, 0.0, 0.0));
 
     /**
      * Creates a copy of aSurface, but having the SurfaceFormat aFormat.
      *
      * This function always creates a new surface. Do not call it if aSurface's
      * format is the same as aFormat. Such a non-conversion would just be an
      * unnecessary and wasteful copy (this function asserts to prevent that).
--- a/gfx/thebes/gfxXlibNativeRenderer.cpp
+++ b/gfx/thebes/gfxXlibNativeRenderer.cpp
@@ -64,19 +64,19 @@ static cairo_bool_t
 {
     *v = (int32_t)coord;
     /* XXX allow some tolerance here? */
     return *v == coord;
 }
 
 static bool
 _get_rectangular_clip (cairo_t *cr,
-                       const nsIntRect& bounds,
+                       const IntRect& bounds,
                        bool *need_clip,
-                       nsIntRect *rectangles, int max_rectangles,
+                       IntRect *rectangles, int max_rectangles,
                        int *num_rectangles)
 {
     cairo_rectangle_list_t *cliplist;
     cairo_rectangle_t *clips;
     int i;
     bool retval = true;
 
     cliplist = cairo_copy_clip_rectangle_list (cr);
@@ -85,33 +85,33 @@ static bool
         NATIVE_DRAWING_NOTE("FALLBACK: non-rectangular clip");
         goto FINISH;
     }
 
     /* the clip is always in surface backend coordinates (i.e. native backend coords) */
     clips = cliplist->rectangles;
 
     for (i = 0; i < cliplist->num_rectangles; ++i) {
-        
-        nsIntRect rect;
+
+        IntRect rect;
         if (!_convert_coord_to_int (clips[i].x, &rect.x) ||
             !_convert_coord_to_int (clips[i].y, &rect.y) ||
             !_convert_coord_to_int (clips[i].width, &rect.width) ||
             !_convert_coord_to_int (clips[i].height, &rect.height))
         {
             retval = false;
             NATIVE_DRAWING_NOTE("FALLBACK: non-integer clip");
             goto FINISH;
         }
 
         if (rect.IsEqualInterior(bounds)) {
             /* the bounds are entirely inside the clip region so we don't need to clip. */
             *need_clip = false;
             goto FINISH;
-        }            
+        }
 
         NS_ASSERTION(bounds.Contains(rect),
                      "Was expecting to be clipped to bounds");
 
         if (i >= max_rectangles) {
             retval = false;
             NATIVE_DRAWING_NOTE("FALLBACK: unsupported clip rectangle count");
             goto FINISH;
@@ -171,37 +171,37 @@ gfxXlibNativeRenderer::DrawCairo(cairo_t
     cairo_surface_get_device_offset (target, &device_offset_x, &device_offset_y);
 
     /* Draw() checked that the matrix contained only a very-close-to-integer
        translation.  Here (and in several other places and thebes) device
        offsets are assumed to be integer. */
     NS_ASSERTION(int32_t(device_offset_x) == device_offset_x &&
                  int32_t(device_offset_y) == device_offset_y,
                  "Expected integer device offsets");
-    nsIntPoint offset(NS_lroundf(matrix.x0 + device_offset_x),
+    IntPoint offset(NS_lroundf(matrix.x0 + device_offset_x),
                       NS_lroundf(matrix.y0 + device_offset_y));
 
     int max_rectangles = 0;
     if (flags & DRAW_SUPPORTS_CLIP_RECT) {
       max_rectangles = 1;
     }
     if (flags & DRAW_SUPPORTS_CLIP_LIST) {
       max_rectangles = MAX_STATIC_CLIP_RECTANGLES;
     }
 
     /* The client won't draw outside the surface so consider this when
        analysing clip rectangles. */
-    nsIntRect bounds(offset, size);
+    IntRect bounds(offset, size);
     bounds.IntersectRect(bounds,
-                         nsIntRect(0, 0,
+                         IntRect(0, 0,
                                    cairo_xlib_surface_get_width(target),
                                    cairo_xlib_surface_get_height(target)));
 
     bool needs_clip = true;
-    nsIntRect rectangles[MAX_STATIC_CLIP_RECTANGLES];
+    IntRect rectangles[MAX_STATIC_CLIP_RECTANGLES];
     int rect_count = 0;
 
     /* Check that the clip is rectangular and aligned on unit boundaries. */
     /* Temporarily set the matrix for _get_rectangular_clip. It's basically
        the identity matrix, but we must adjust for the fact that our
        offset-rect is in device coordinates. */
     cairo_identity_matrix (cr);
     cairo_translate (cr, -device_offset_x, -device_offset_y);
@@ -355,17 +355,17 @@ CreateTempXlibSurface (cairo_surface_t* 
                     (gfxImageFormat)cairo_image_surface_get_format(cairoTarget);
             target_visual = gfxXlibSurface::FindVisual(screen, imageFormat);
             Display *dpy = DisplayOfScreen(screen);
             if (target_visual) {
                 target_format = XRenderFindVisualFormat(dpy, target_visual);
             } else {
                 target_format =
                     gfxXlibSurface::FindRenderFormat(dpy, imageFormat);
-            }                
+            }
         }
 
         if (supportsAlternateVisual &&
             (supportsAlternateScreen || screen == target_screen)) {
             if (target_visual) {
                 visual = target_visual;
                 screen = target_screen;
             }
@@ -431,17 +431,17 @@ CreateTempXlibSurface (cairo_surface_t* 
         *method = eAlphaExtraction;
     }
 
     return surface;
 }
 
 bool
 gfxXlibNativeRenderer::DrawOntoTempSurface(cairo_surface_t *tempXlibSurface,
-                                           nsIntPoint offset)
+                                           IntPoint offset)
 {
     cairo_surface_flush(tempXlibSurface);
     /* no clipping is needed because the callback can't draw outside the native
        surface anyway */
     nsresult rv = DrawWithXlib(tempXlibSurface, offset, nullptr, 0);
     cairo_surface_mark_dirty(tempXlibSurface);
     return NS_SUCCEEDED(rv);
 }
@@ -501,27 +501,27 @@ gfxXlibNativeRenderer::Draw(gfxContext* 
         if (clipExtents.IsEmpty())
             return; // nothing to do
 
         if (canDrawOverBackground &&
             DrawDirect(ctx, size, flags, screen, visual))
           return;
     }
 
-    nsIntRect drawingRect(nsIntPoint(0, 0), size);
+    IntRect drawingRect(IntPoint(0, 0), size);
     // Drawing need only be performed within the clip extents
     // (and padding for the filter).
     if (!matrixIsIntegerTranslation) {
         // The source surface may need to be a little larger than the clip
         // extents due to the filter footprint.
         clipExtents.Inflate(filterRadius);
     }
     clipExtents.RoundOut();
 
-    nsIntRect intExtents(int32_t(clipExtents.X()),
+    IntRect intExtents(int32_t(clipExtents.X()),
                          int32_t(clipExtents.Y()),
                          int32_t(clipExtents.Width()),
                          int32_t(clipExtents.Height()));
     drawingRect.IntersectRect(drawingRect, intExtents);
 
     gfxPoint offset(drawingRect.x, drawingRect.y);
 
     DrawingMethod method;
--- a/gfx/thebes/gfxXlibNativeRenderer.h
+++ b/gfx/thebes/gfxXlibNativeRenderer.h
@@ -3,28 +3,28 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFXXLIBNATIVERENDER_H_
 #define GFXXLIBNATIVERENDER_H_
 
 #include "nsPoint.h"
 #include "nsRect.h"
+#include "mozilla/gfx/Rect.h"
+#include "mozilla/gfx/Point.h"
 #include <X11/Xlib.h>
 
 namespace mozilla {
 namespace gfx {
   class DrawTarget;
 }
 }
 
 class gfxASurface;
 class gfxContext;
-struct nsIntRect;
-struct nsIntPoint;
 typedef struct _cairo cairo_t;
 typedef struct _cairo_surface cairo_surface_t;
 
 /**
  * This class lets us take code that draws into an X drawable and lets us
  * use it to draw into any Thebes context. The user should subclass this class,
  * override DrawWithXib, and then call Draw(). The drawing will be subjected
  * to all Thebes transformations, clipping etc.
@@ -40,18 +40,19 @@ public:
      * @param clipRects an array of rectangles; clip to the union.
      *                  Any rectangles provided will be contained by the
      *                  rectangle with size provided to Draw and by the
      *                  surface extents.
      * @param numClipRects the number of rects in the array, or zero if
      *                     no clipping is required.
      */
     virtual nsresult DrawWithXlib(cairo_surface_t* surface,
-                                  nsIntPoint offset,
-                                  nsIntRect* clipRects, uint32_t numClipRects) = 0;
+                                  mozilla::gfx::IntPoint offset,
+                                  mozilla::gfx::IntRect* clipRects,
+                                  uint32_t numClipRects) = 0;
   
     enum {
         // If set, then Draw() is opaque, i.e., every pixel in the intersection
         // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height)
         // will be set and there is no dependence on what the existing pixels
         // in the drawable are set to.
         DRAW_IS_OPAQUE = 0x01,
         // If set, then numClipRects can be zero or one
@@ -88,17 +89,17 @@ private:
     bool DrawDirect(gfxContext *ctx, mozilla::gfx::IntSize bounds,
                     uint32_t flags, Screen *screen, Visual *visual);
 
     bool DrawCairo(cairo_t* cr, mozilla::gfx::IntSize size,
                    uint32_t flags, Screen *screen, Visual *visual);
 
     void DrawFallback(mozilla::gfx::DrawTarget* dt, gfxContext* ctx,
                       gfxASurface* aSurface, mozilla::gfx::IntSize& size,
-                      nsIntRect& drawingRect, bool canDrawOverBackground,
+                      mozilla::gfx::IntRect& drawingRect, bool canDrawOverBackground,
                       uint32_t flags, Screen* screen, Visual* visual);
 
     bool DrawOntoTempSurface(cairo_surface_t *tempXlibSurface,
-                             nsIntPoint offset);
+                             mozilla::gfx::IntPoint offset);
 
 };
 
 #endif /*GFXXLIBNATIVERENDER_H_*/
--- a/hal/sandbox/PHal.ipdl
+++ b/hal/sandbox/PHal.ipdl
@@ -11,17 +11,17 @@ include "mozilla/GfxMessageUtils.h";
 
 using mozilla::dom::ScreenOrientation from "mozilla/dom/ScreenOrientation.h";
 using mozilla::hal::SensorType from "mozilla/HalSensor.h";
 using mozilla::hal::SensorAccuracyType from "mozilla/HalSensor.h";
 using mozilla::hal::WakeLockControl from "mozilla/HalTypes.h";
 using mozilla::hal::SwitchState from "mozilla/HalTypes.h";
 using mozilla::hal::SwitchDevice from "mozilla/HalTypes.h";
 using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
-using struct nsIntRect from "nsRect.h";
+using nsIntRect from "nsRect.h";
 using PRTime from "prtime.h";
 using mozilla::hal::FMRadioCountry from "mozilla/HalTypes.h";
 using mozilla::hal::FMRadioOperation from "mozilla/HalTypes.h";
 using mozilla::hal::FMRadioOperationStatus from "mozilla/HalTypes.h";
 
 namespace mozilla {
 
 namespace hal {
--- a/image/src/Decoder.cpp
+++ b/image/src/Decoder.cpp
@@ -623,17 +623,17 @@ Decoder::PostFrameStop(Opacity aFrameOpa
   mCurrentFrame->Finish(aFrameOpacity, aDisposalMethod, aTimeout, aBlendMethod);
 
   mProgress |= FLAG_FRAME_COMPLETE | FLAG_ONLOAD_UNBLOCKED;
 
   // If we're not sending partial invalidations, then we send an invalidation
   // here when the first frame is complete.
   if (!mSendPartialInvalidations && !mIsAnimated) {
     mInvalidRect.UnionRect(mInvalidRect,
-                           nsIntRect(nsIntPoint(0, 0), GetSize()));
+                           gfx::IntRect(gfx::IntPoint(0, 0), GetSize()));
   }
 }
 
 void
 Decoder::PostInvalidation(const nsIntRect& aRect,
                           const Maybe<nsIntRect>& aRectAtTargetSize
                             /* = Nothing() */)
 {
--- a/image/src/ImageOps.h
+++ b/image/src/ImageOps.h
@@ -3,20 +3,20 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_image_src_ImageOps_h
 #define mozilla_image_src_ImageOps_h
 
 #include "nsCOMPtr.h"
+#include "nsRect.h"
 
 class gfxDrawable;
 class imgIContainer;
-struct nsIntRect;
 
 namespace mozilla {
 namespace image {
 
 class Image;
 struct Orientation;
 
 class ImageOps
--- a/image/src/MultipartImage.cpp
+++ b/image/src/MultipartImage.cpp
@@ -177,17 +177,17 @@ void MultipartImage::FinishTransition()
   mTracker->ResetForNewRequest();
   SetInnerImage(mNextPart);
   mNextPart = nullptr;
   newCurrentPartTracker->AddObserver(this);
 
   // Finally, send all the notifications for the new current part and send a
   // FRAME_UPDATE notification so that observers know to redraw.
   mTracker->SyncNotifyProgress(newCurrentPartTracker->GetProgress(),
-                               nsIntRect::GetMaxSizedIntRect());
+                               GetMaxSizedIntRect());
 }
 
 already_AddRefed<imgIContainer>
 MultipartImage::Unwrap()
 {
   // Although we wrap another image, we don't allow callers to unwrap as. As far
   // as external code is concerned, MultipartImage is atomic.
   nsCOMPtr<imgIContainer> image = this;
--- a/image/src/ProgressTracker.cpp
+++ b/image/src/ProgressTracker.cpp
@@ -388,17 +388,17 @@ ProgressTracker::SyncNotify(IProgressObs
                        "ProgressTracker::SyncNotify", "uri", spec.get());
 #endif
 
   nsIntRect rect;
   if (mImage) {
     if (NS_FAILED(mImage->GetWidth(&rect.width)) ||
         NS_FAILED(mImage->GetHeight(&rect.height))) {
       // Either the image has no intrinsic size, or it has an error.
-      rect = nsIntRect::GetMaxSizedIntRect();
+      rect = GetMaxSizedIntRect();
     }
   }
 
   ObserverArray array;
   array.AppendElement(aObserver);
   SyncNotifyInternal(array, !!mImage, mProgress, rect);
 }
 
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -117,17 +117,17 @@ class ScaleRunner : public nsRunnable
     eReady,
     eFinish,
     eFinishWithError
   };
 
 public:
   ScaleRunner(RasterImage* aImage,
               uint32_t aImageFlags,
-              const nsIntSize& aSize,
+              const IntSize& aSize,
               RawAccessFrameRef&& aSrcRef)
     : mImage(aImage)
     , mSrcRef(Move(aSrcRef))
     , mDstSize(aSize)
     , mImageFlags(aImageFlags)
     , mState(eNew)
   {
     MOZ_ASSERT(!mSrcRef->GetIsPaletted());
@@ -230,17 +230,17 @@ private:
   {
     MOZ_ASSERT(!mSrcRef && !mDstRef,
                "Should have released strong refs in Run()");
   }
 
   WeakPtr<RasterImage> mImage;
   RawAccessFrameRef    mSrcRef;
   RawAccessFrameRef    mDstRef;
-  const nsIntSize      mDstSize;
+  const IntSize      mDstSize;
   uint32_t             mImageFlags;
   ScaleState           mState;
 };
 
 static nsCOMPtr<nsIThread> sScaleWorkerThread = nullptr;
 
 #ifndef DEBUG
 NS_IMPL_ISUPPORTS(RasterImage, imgIContainer, nsIProperties)
@@ -499,17 +499,17 @@ RasterImage::LookupFrameInternal(uint32_
                                        RasterSurfaceKey(aSize,
                                                         DecodeFlags(aFlags),
                                                         aFrameNum),
                                        alternateFlags);
 }
 
 DrawableFrameRef
 RasterImage::LookupFrame(uint32_t aFrameNum,
-                         const nsIntSize& aSize,
+                         const IntSize& aSize,
                          uint32_t aFlags)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   IntSize requestedSize = CanDownscaleDuringDecode(aSize, aFlags)
                         ? aSize : mSize;
 
   DrawableFrameRef ref = LookupFrameInternal(aFrameNum, requestedSize, aFlags);
@@ -563,25 +563,25 @@ RasterImage::GetCurrentFrameIndex() cons
 }
 
 uint32_t
 RasterImage::GetRequestedFrameIndex(uint32_t aWhichFrame) const
 {
   return aWhichFrame == FRAME_FIRST ? 0 : GetCurrentFrameIndex();
 }
 
-nsIntRect
+IntRect
 RasterImage::GetFirstFrameRect()
 {
   if (mAnim) {
     return mAnim->GetFirstFrameRefreshArea();
   }
 
   // Fall back to our size. This is implicitly zero-size if !mHasSize.
-  return nsIntRect(nsIntPoint(0,0), mSize);
+  return IntRect(IntPoint(0,0), mSize);
 }
 
 NS_IMETHODIMP_(bool)
 RasterImage::IsOpaque()
 {
   if (mError) {
     return false;
   }
@@ -697,17 +697,17 @@ RasterImage::CopyFrame(uint32_t aWhichFr
                                      size,
                                      mapping.mStride,
                                      SurfaceFormat::B8G8R8A8);
   if (!target) {
     gfxWarning() << "RasterImage::CopyFrame failed in CreateDrawTargetForData";
     return nullptr;
   }
 
-  nsIntRect intFrameRect = frameRef->GetRect();
+  IntRect intFrameRect = frameRef->GetRect();
   Rect rect(intFrameRect.x, intFrameRect.y,
             intFrameRect.width, intFrameRect.height);
   if (frameRef->IsSinglePixel()) {
     target->FillRect(rect, ColorPattern(frameRef->SinglePixelColor()),
                      DrawOptions(1.0f, CompositionOp::OP_SOURCE));
   } else {
     RefPtr<SourceSurface> srcSurf = frameRef->GetSurface();
     if (!srcSurf) {
@@ -756,17 +756,17 @@ RasterImage::GetFrameInternal(uint32_t a
   if (!frameRef) {
     // The OS threw this frame away and we couldn't redecode it.
     return MakePair(DrawResult::TEMPORARY_ERROR, RefPtr<SourceSurface>());
   }
 
   // If this frame covers the entire image, we can just reuse its existing
   // surface.
   RefPtr<SourceSurface> frameSurf;
-  nsIntRect frameRect = frameRef->GetRect();
+  IntRect frameRect = frameRef->GetRect();
   if (frameRect.x == 0 && frameRect.y == 0 &&
       frameRect.width == mSize.width &&
       frameRect.height == mSize.height) {
     frameSurf = frameRef->GetSurface();
   }
 
   // The image doesn't have a usable surface because it's been optimized away or
   // because it's a partial update frame from an animation. Create one.
@@ -900,39 +900,39 @@ RasterImage::SizeOfDecoded(gfxMemoryLoca
   return n;
 }
 
 class OnAddedFrameRunnable : public nsRunnable
 {
 public:
   OnAddedFrameRunnable(RasterImage* aImage,
                        uint32_t aNewFrameCount,
-                       const nsIntRect& aNewRefreshArea)
+                       const IntRect& aNewRefreshArea)
     : mImage(aImage)
     , mNewFrameCount(aNewFrameCount)
     , mNewRefreshArea(aNewRefreshArea)
   {
     MOZ_ASSERT(aImage);
   }
 
   NS_IMETHOD Run()
   {
     mImage->OnAddedFrame(mNewFrameCount, mNewRefreshArea);
     return NS_OK;
   }
 
 private:
   nsRefPtr<RasterImage> mImage;
   uint32_t mNewFrameCount;
-  nsIntRect mNewRefreshArea;
+  IntRect mNewRefreshArea;
 };
 
 void
 RasterImage::OnAddedFrame(uint32_t aNewFrameCount,
-                          const nsIntRect& aNewRefreshArea)
+                          const IntRect& aNewRefreshArea)
 {
   if (!NS_IsMainThread()) {
     nsCOMPtr<nsIRunnable> runnable =
       new OnAddedFrameRunnable(this, aNewFrameCount, aNewRefreshArea);
     NS_DispatchToMainThread(runnable);
     return;
   }
 
@@ -1142,18 +1142,18 @@ RasterImage::SetLoopCount(int32_t aLoopC
   }
 
   // No need to set this if we're not an animation.
   if (mAnim) {
     mAnim->SetLoopCount(aLoopCount);
   }
 }
 
-NS_IMETHODIMP_(nsIntRect)
-RasterImage::GetImageSpaceInvalidationRect(const nsIntRect& aRect)
+NS_IMETHODIMP_(IntRect)
+RasterImage::GetImageSpaceInvalidationRect(const IntRect& aRect)
 {
   return aRect;
 }
 
 nsresult
 RasterImage::OnImageDataComplete(nsIRequest*, nsISupports*, nsresult aStatus,
                                  bool aLastPart)
 {
@@ -1328,17 +1328,17 @@ RasterImage::Discard()
 bool
 RasterImage::CanDiscard() {
   return mHasSourceData &&       // ...have the source data...
          !mAnim;                 // Can never discard animated images
 }
 
 // Sets up a decoder for this image.
 already_AddRefed<Decoder>
-RasterImage::CreateDecoder(const Maybe<nsIntSize>& aSize, uint32_t aFlags)
+RasterImage::CreateDecoder(const Maybe<IntSize>& aSize, uint32_t aFlags)
 {
   // Make sure we actually get size before doing a full decode.
   if (aSize) {
     MOZ_ASSERT(mHasSize, "Must do a size decode before a full decode!");
     MOZ_ASSERT(mDownscaleDuringDecode || *aSize == mSize,
                "Can only decode to our intrinsic size if we're not allowed to "
                "downscale-during-decode");
   } else {
@@ -1467,32 +1467,32 @@ RasterImage::StartDecoding()
   if (mDecodeOnlyOnDraw) {
     return NS_OK;
   }
 
   return RequestDecodeForSize(mSize, FLAG_SYNC_DECODE_IF_FAST);
 }
 
 NS_IMETHODIMP
-RasterImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
+RasterImage::RequestDecodeForSize(const IntSize& aSize, uint32_t aFlags)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mError) {
     return NS_ERROR_FAILURE;
   }
 
   if (!mHasSize) {
     mWantFullDecode = true;
     return NS_OK;
   }
 
   // Fall back to our intrinsic size if we don't support
   // downscale-during-decode.
-  nsIntSize targetSize = mDownscaleDuringDecode ? aSize : mSize;
+  IntSize targetSize = mDownscaleDuringDecode ? aSize : mSize;
 
   // Decide whether to sync decode images we can decode quickly. Here we are
   // explicitly trading off flashing for responsiveness in the case that we're
   // redecoding an image (see bug 845147).
   bool shouldSyncDecodeIfFast =
     !mHasBeenDecoded && (aFlags & FLAG_SYNC_DECODE_IF_FAST);
 
   uint32_t flags = shouldSyncDecodeIfFast
@@ -1502,17 +1502,17 @@ RasterImage::RequestDecodeForSize(const 
   // Look up the first frame of the image, which will implicitly start decoding
   // if it's not available right now.
   LookupFrame(0, targetSize, flags);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-RasterImage::Decode(const Maybe<nsIntSize>& aSize, uint32_t aFlags)
+RasterImage::Decode(const Maybe<IntSize>& aSize, uint32_t aFlags)
 {
   MOZ_ASSERT(!aSize || NS_IsMainThread());
 
   if (mError) {
     return NS_ERROR_FAILURE;
   }
 
   // If we don't have a size yet, we can't do any other decoding.
@@ -1565,17 +1565,17 @@ RasterImage::Decode(const Maybe<nsIntSiz
 
   // Perform an async decode. We also take this path if we don't have all the
   // source data yet, since sync decoding is impossible in that situation.
   DecodePool::Singleton()->AsyncDecode(decoder);
   return NS_OK;
 }
 
 void
-RasterImage::RecoverFromLossOfFrames(const nsIntSize& aSize, uint32_t aFlags)
+RasterImage::RecoverFromLossOfFrames(const IntSize& aSize, uint32_t aFlags)
 {
   if (!mHasSize) {
     return;
   }
 
   NS_WARNING("An imgFrame became invalid. Attempting to recover...");
 
   // Discard all existing frames, since they're probably all now invalid.
@@ -1590,17 +1590,17 @@ RasterImage::RecoverFromLossOfFrames(con
   }
 
   // For non-animated images, it's fine to recover using an async decode.
   Decode(Some(aSize), aFlags);
 }
 
 bool
 RasterImage::CanScale(GraphicsFilter aFilter,
-                      const nsIntSize& aSize,
+                      const IntSize& aSize,
                       uint32_t aFlags)
 {
 #ifndef MOZ_ENABLE_SKIA
   // The high-quality scaler requires Skia.
   return false;
 #else
   // Check basic requirements: HQ downscaling is enabled, we have all the source
   // data and know our size, the flags allow us to do it, and a 'good' filter is
@@ -1650,17 +1650,17 @@ RasterImage::CanScale(GraphicsFilter aFi
   gfx::Size scale(double(aSize.width) / mSize.width,
                   double(aSize.height) / mSize.height);
   gfxFloat minFactor = gfxPrefs::ImageHQDownscalingMinFactor() / 1000.0;
   return (scale.width < minFactor || scale.height < minFactor);
 #endif
 }
 
 bool
-RasterImage::CanDownscaleDuringDecode(const nsIntSize& aSize, uint32_t aFlags)
+RasterImage::CanDownscaleDuringDecode(const IntSize& aSize, uint32_t aFlags)
 {
   // Check basic requirements: downscale-during-decode is enabled for this
   // image, we have all the source data and know our size, the flags allow us to
   // do it, and a 'good' filter is being used.
   if (!mDownscaleDuringDecode || !mHasSize ||
       !(aFlags & imgIContainer::FLAG_HIGH_QUALITY_SCALING)) {
     return false;
   }
@@ -1688,23 +1688,23 @@ RasterImage::CanDownscaleDuringDecode(co
   return true;
 }
 
 void
 RasterImage::NotifyNewScaledFrame()
 {
   // Send an invalidation so observers will repaint and can take advantage of
   // the new scaled frame if possible.
-  NotifyProgress(NoProgress, nsIntRect(0, 0, mSize.width, mSize.height));
+  NotifyProgress(NoProgress, IntRect(0, 0, mSize.width, mSize.height));
 }
 
 void
 RasterImage::RequestScale(imgFrame* aFrame,
                           uint32_t aFlags,
-                          const nsIntSize& aSize)
+                          const IntSize& aSize)
 {
   // We don't scale frames which aren't fully decoded.
   if (!aFrame->IsImageComplete()) {
     return;
   }
 
   // We can't scale frames that need padding or are single pixel.
   if (aFrame->NeedsPadding() || aFrame->IsSinglePixel()) {
@@ -1727,17 +1727,17 @@ RasterImage::RequestScale(imgFrame* aFra
 
     sScaleWorkerThread->Dispatch(runner, NS_DISPATCH_NORMAL);
   }
 }
 
 DrawResult
 RasterImage::DrawWithPreDownscaleIfNeeded(DrawableFrameRef&& aFrameRef,
                                           gfxContext* aContext,
-                                          const nsIntSize& aSize,
+                                          const IntSize& aSize,
                                           const ImageRegion& aRegion,
                                           GraphicsFilter aFilter,
                                           uint32_t aFlags)
 {
   DrawableFrameRef frameRef;
 
   if (CanScale(aFilter, aSize, aFlags)) {
     frameRef =
@@ -1793,24 +1793,24 @@ RasterImage::DrawWithPreDownscaleIfNeede
   return DrawResult::SUCCESS;
 }
 
 //******************************************************************************
 /* [noscript] void draw(in gfxContext aContext,
  *                      in gfxGraphicsFilter aFilter,
  *                      [const] in gfxMatrix aUserSpaceToImageSpace,
  *                      [const] in gfxRect aFill,
- *                      [const] in nsIntRect aSubimage,
- *                      [const] in nsIntSize aViewportSize,
+ *                      [const] in IntRect aSubimage,
+ *                      [const] in IntSize aViewportSize,
  *                      [const] in SVGImageContext aSVGContext,
  *                      in uint32_t aWhichFrame,
  *                      in uint32_t aFlags); */
 NS_IMETHODIMP_(DrawResult)
 RasterImage::Draw(gfxContext* aContext,
-                  const nsIntSize& aSize,
+                  const IntSize& aSize,
                   const ImageRegion& aRegion,
                   uint32_t aWhichFrame,
                   GraphicsFilter aFilter,
                   const Maybe<SVGImageContext>& /*aSVGContext - ignored*/,
                   uint32_t aFlags)
 {
   if (aWhichFrame > FRAME_MAX_VALUE) {
     return DrawResult::BAD_ARGS;
@@ -2023,17 +2023,17 @@ RasterImage::GetFramesNotified(uint32_t*
   *aFramesNotified = mFramesNotified;
 
   return NS_OK;
 }
 #endif
 
 void
 RasterImage::NotifyProgress(Progress aProgress,
-                            const nsIntRect& aInvalidRect /* = nsIntRect() */,
+                            const IntRect& aInvalidRect /* = IntRect() */,
                             uint32_t aFlags /* = DECODE_FLAGS_DEFAULT */)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // Ensure that we stay alive long enough to finish notifying.
   nsRefPtr<RasterImage> image(this);
 
   bool wasDefaultFlags = aFlags == DECODE_FLAGS_DEFAULT;
@@ -2106,29 +2106,29 @@ RasterImage::FinalizeDecoder(Decoder* aD
 
 already_AddRefed<imgIContainer>
 RasterImage::Unwrap()
 {
   nsCOMPtr<imgIContainer> self(this);
   return self.forget();
 }
 
-nsIntSize
+IntSize
 RasterImage::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame,
                                      GraphicsFilter aFilter, uint32_t aFlags)
 {
   MOZ_ASSERT(aDest.width >= 0 || ceil(aDest.width) <= INT32_MAX ||
              aDest.height >= 0 || ceil(aDest.height) <= INT32_MAX,
              "Unexpected destination size");
 
   if (mSize.IsEmpty() || aDest.IsEmpty()) {
-    return nsIntSize(0, 0);
+    return IntSize(0, 0);
   }
 
-  nsIntSize destSize(ceil(aDest.width), ceil(aDest.height));
+  IntSize destSize(ceil(aDest.width), ceil(aDest.height));
 
   if (aFilter == GraphicsFilter::FILTER_GOOD &&
       CanDownscaleDuringDecode(destSize, aFlags)) {
     return destSize;
   } else if (CanScale(aFilter, destSize, aFlags)) {
     DrawableFrameRef frameRef =
       SurfaceCache::Lookup(ImageKey(this),
                            RasterSurfaceKey(destSize,
--- a/image/src/SVGDocumentWrapper.cpp
+++ b/image/src/SVGDocumentWrapper.cpp
@@ -80,17 +80,17 @@ SVGDocumentWrapper::UpdateViewportBounds
   MOZ_ASSERT(!mIgnoreInvalidation, "shouldn't be reentrant");
   mIgnoreInvalidation = true;
 
   nsIntRect currentBounds;
   mViewer->GetBounds(currentBounds);
 
   // If the bounds have changed, we need to do a layout flush.
   if (currentBounds.Size() != aViewportSize) {
-    mViewer->SetBounds(nsIntRect(nsIntPoint(0, 0), aViewportSize));
+    mViewer->SetBounds(IntRect(IntPoint(0, 0), aViewportSize));
     FlushLayout();
   }
 
   mIgnoreInvalidation = false;
 }
 
 void
 SVGDocumentWrapper::FlushImageTransformInvalidation()
--- a/image/src/VectorImage.cpp
+++ b/image/src/VectorImage.cpp
@@ -241,31 +241,31 @@ private:
 };
 
 NS_IMPL_ISUPPORTS(SVGLoadEventListener, nsIDOMEventListener)
 
 // Helper-class: SVGDrawingCallback
 class SVGDrawingCallback : public gfxDrawingCallback {
 public:
   SVGDrawingCallback(SVGDocumentWrapper* aSVGDocumentWrapper,
-                     const nsIntRect& aViewport,
+                     const IntRect& aViewport,
                      const IntSize& aSize,
                      uint32_t aImageFlags)
     : mSVGDocumentWrapper(aSVGDocumentWrapper)
     , mViewport(aViewport)
     , mSize(aSize)
     , mImageFlags(aImageFlags)
   { }
   virtual bool operator()(gfxContext* aContext,
                           const gfxRect& aFillRect,
                           const GraphicsFilter& aFilter,
                           const gfxMatrix& aTransform);
 private:
   nsRefPtr<SVGDocumentWrapper> mSVGDocumentWrapper;
-  const nsIntRect              mViewport;
+  const IntRect              mViewport;
   const IntSize                mSize;
   uint32_t                     mImageFlags;
 };
 
 // Based loosely on nsSVGIntegrationUtils' PaintFrameCallback::operator()
 bool
 SVGDrawingCallback::operator()(gfxContext* aContext,
                                const gfxRect& aFillRect,
@@ -534,22 +534,22 @@ VectorImage::SendInvalidationNotificatio
   // invalidation notifications in OnSVGDocumentLoaded, but in rare cases the
   // SVG document may not be 100% ready to render at that time. In those cases
   // we would miss the subsequent invalidations if we didn't send out the
   // notifications directly in |InvalidateObservers...|.
 
   if (mProgressTracker) {
     SurfaceCache::RemoveImage(ImageKey(this));
     mProgressTracker->SyncNotifyProgress(FLAG_FRAME_COMPLETE,
-                                         nsIntRect::GetMaxSizedIntRect());
+                                         GetMaxSizedIntRect());
   }
 }
 
-NS_IMETHODIMP_(nsIntRect)
-VectorImage::GetImageSpaceInvalidationRect(const nsIntRect& aRect)
+NS_IMETHODIMP_(IntRect)
+VectorImage::GetImageSpaceInvalidationRect(const IntRect& aRect)
 {
   return aRect;
 }
 
 //******************************************************************************
 /* readonly attribute int32_t height; */
 NS_IMETHODIMP
 VectorImage::GetHeight(int32_t* aHeight)
@@ -849,17 +849,17 @@ VectorImage::Draw(gfxContext* aContext,
 void
 VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams)
 {
   mSVGDocumentWrapper->UpdateViewportBounds(aParams.viewportSize);
   mSVGDocumentWrapper->FlushImageTransformInvalidation();
 
   nsRefPtr<gfxDrawingCallback> cb =
     new SVGDrawingCallback(mSVGDocumentWrapper,
-                           nsIntRect(nsIntPoint(0, 0), aParams.viewportSize),
+                           IntRect(IntPoint(0, 0), aParams.viewportSize),
                            aParams.size,
                            aParams.flags);
 
   nsRefPtr<gfxDrawable> svgDrawable =
     new gfxCallbackDrawable(cb, aParams.size);
 
   bool bypassCache = bool(aParams.flags & FLAG_BYPASS_SURFACE_CACHE) ||
                      // Refuse to cache animated images:
@@ -911,17 +911,17 @@ VectorImage::CreateSurfaceAndShow(const 
   // Draw.
   nsRefPtr<gfxDrawable> drawable =
     new gfxSurfaceDrawable(surface, aParams.size);
   Show(drawable, aParams);
 
   // Send out an invalidation so that surfaces that are still in use get
   // re-locked. See the discussion of the UnlockSurfaces call above.
   mProgressTracker->SyncNotifyProgress(FLAG_FRAME_COMPLETE,
-                                       nsIntRect::GetMaxSizedIntRect());
+                                       GetMaxSizedIntRect());
 }
 
 
 void
 VectorImage::Show(gfxDrawable* aDrawable, const SVGDrawingParameters& aParams)
 {
   MOZ_ASSERT(aDrawable, "Should have a gfxDrawable by now");
   gfxUtils::DrawPixelSnapped(aParams.context, aDrawable,
@@ -1172,17 +1172,17 @@ VectorImage::OnSVGDocumentLoaded()
 
   // Tell *our* observers that we're done loading.
   if (mProgressTracker) {
     mProgressTracker->SyncNotifyProgress(FLAG_SIZE_AVAILABLE |
                                          FLAG_HAS_TRANSPARENCY |
                                          FLAG_FRAME_COMPLETE |
                                          FLAG_DECODE_COMPLETE |
                                          FLAG_ONLOAD_UNBLOCKED,
-                                         nsIntRect::GetMaxSizedIntRect());
+                                         GetMaxSizedIntRect());
   }
 
   EvaluateAnimation();
 }
 
 void
 VectorImage::OnSVGDocumentError()
 {
--- a/image/src/imgFrame.cpp
+++ b/image/src/imgFrame.cpp
@@ -690,17 +690,17 @@ nsresult
 imgFrame::ImageUpdatedInternal(const nsIntRect& aUpdateRect)
 {
   mMonitor.AssertCurrentThreadOwns();
 
   mDecoded.UnionRect(mDecoded, aUpdateRect);
 
   // clamp to bounds, in case someone sends a bogus updateRect (I'm looking at
   // you, gif decoder)
-  nsIntRect boundsRect(mOffset, nsIntSize(mSize.width, mSize.height));
+  nsIntRect boundsRect(gfx::ToIntPoint(mOffset), gfx::IntSize(mSize.width, mSize.height));
   mDecoded.IntersectRect(mDecoded, boundsRect);
 
   // If the image is now complete, wake up anyone who's waiting.
   if (IsImageCompleteInternal()) {
     mMonitor.NotifyAll();
   }
 
   return NS_OK;
@@ -723,17 +723,17 @@ imgFrame::Finish(Opacity aFrameOpacity /
   mTimeout = aRawTimeout;
   mBlendMethod = aBlendMethod;
   ImageUpdatedInternal(GetRect());
 }
 
 nsIntRect
 imgFrame::GetRect() const
 {
-  return nsIntRect(mOffset, nsIntSize(mSize.width, mSize.height));
+  return gfx::IntRect(gfx::ToIntPoint(mOffset), gfx::IntSize(mSize.width, mSize.height));
 }
 
 int32_t
 imgFrame::GetStride() const
 {
   mMonitor.AssertCurrentThreadOwns();
 
   if (mImageSurface) {
--- a/image/src/imgRequestProxy.cpp
+++ b/image/src/imgRequestProxy.cpp
@@ -835,17 +835,17 @@ NotificationTypeToString(int32_t aType)
     case imgINotificationObserver::HAS_TRANSPARENCY: return "HAS_TRANSPARENCY";
     default:
       NS_NOTREACHED("Notification list should be exhaustive");
       return "(unknown notification)";
   }
 }
 
 void
-imgRequestProxy::Notify(int32_t aType, const nsIntRect* aRect)
+imgRequestProxy::Notify(int32_t aType, const mozilla::gfx::IntRect* aRect)
 {
   MOZ_ASSERT(aType != imgINotificationObserver::LOAD_COMPLETE,
              "Should call OnLoadComplete");
 
   LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::Notify", "type",
                       NotificationTypeToString(aType));
 
   if (!mListener || mCanceled) {
--- a/image/src/imgRequestProxy.h
+++ b/image/src/imgRequestProxy.h
@@ -12,31 +12,31 @@
 
 #include "nsILoadGroup.h"
 #include "nsISupportsPriority.h"
 #include "nsITimedChannel.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "mozilla/TimeStamp.h"
+#include "mozilla/gfx/Rect.h"
 
 #include "imgRequest.h"
 #include "IProgressObserver.h"
 
 #define NS_IMGREQUESTPROXY_CID \
 { /* 20557898-1dd2-11b2-8f65-9c462ee2bc95 */         \
      0x20557898,                                     \
      0x1dd2,                                         \
      0x11b2,                                         \
     {0x8f, 0x65, 0x9c, 0x46, 0x2e, 0xe2, 0xbc, 0x95} \
 }
 
 class imgINotificationObserver;
 class imgStatusNotifyRunnable;
-struct nsIntRect;
 class ProxyBehaviour;
 
 namespace mozilla {
 namespace image {
 class Image;
 class ImageURL;
 class ProgressTracker;
 } // namespace image
@@ -93,17 +93,17 @@ public:
 
   // Synchronously notify this proxy's listener of the current state of the
   // image. Only use this function if you are currently servicing an
   // asynchronously-called function.
   void SyncNotifyListener();
 
   // imgINotificationObserver methods:
   virtual void Notify(int32_t aType,
-                      const nsIntRect* aRect = nullptr) override;
+                      const mozilla::gfx::IntRect* aRect = nullptr) override;
   virtual void OnLoadComplete(bool aLastPart) override;
 
   // imgIOnloadBlocker methods:
   virtual void BlockOnload() override;
   virtual void UnblockOnload() override;
 
   // Other, internal-only methods:
   virtual void SetHasImage() override;
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -2213,17 +2213,17 @@ nscolor
 ContainerState::FindOpaqueBackgroundColorInLayer(const PaintedLayerData* aData,
                                                  const nsIntRect& aRect,
                                                  bool* aOutIntersectsLayer) const
 {
   *aOutIntersectsLayer = true;
 
   // Scan the candidate's display items.
   nsIntRect deviceRect = aRect;
-  nsRect appUnitRect = deviceRect.ToAppUnits(mAppUnitsPerDevPixel);
+  nsRect appUnitRect = ToAppUnits(deviceRect, mAppUnitsPerDevPixel);
   appUnitRect.ScaleInverseRoundOut(mParameters.mXScale, mParameters.mYScale);
 
   for (auto& assignedItem : Reversed(aData->mAssignedDisplayItems)) {
     nsDisplayItem* item = assignedItem.mItem;
     bool snap;
     nsRect bounds = item->GetBounds(mBuilder, &snap);
     if (snap && mSnappingEnabled) {
       nsIntRect snappedBounds = ScaleToNearestPixels(bounds);
@@ -4813,17 +4813,17 @@ FrameLayerBuilder::BuildContainerLayerFo
   if (flags & Layer::CONTENT_COMPONENT_ALPHA) {
     flags |= Layer::CONTENT_COMPONENT_ALPHA_DESCENDANT;
   }
 
   // Make sure that rounding the visible region out didn't add any area
   // we won't paint
   if (aChildren->IsOpaque() && !aChildren->NeedsTransparentSurface()) {
     bounds.ScaleRoundIn(scaleParameters.mXScale, scaleParameters.mYScale);
-    if (bounds.Contains(pixBounds.ToAppUnits(appUnitsPerDevPixel))) {
+    if (bounds.Contains(ToAppUnits(pixBounds, appUnitsPerDevPixel))) {
       // Clear CONTENT_COMPONENT_ALPHA and add CONTENT_OPAQUE instead.
       flags &= ~Layer::CONTENT_COMPONENT_ALPHA;
       flags |= Layer::CONTENT_OPAQUE;
     }
   }
   containerLayer->SetContentFlags(flags);
   // If aContainerItem is non-null some BuildContainerLayer further up the
   // call stack is responsible for setting containerLayer's visible region.
@@ -5061,17 +5061,17 @@ FrameLayerBuilder::PaintItems(nsTArray<C
                               nsPresContext* aPresContext,
                               const nsIntPoint& aOffset,
                               float aXScale, float aYScale,
                               int32_t aCommonClipCount)
 {
   DrawTarget& aDrawTarget = *aRC->GetDrawTarget();
 
   int32_t appUnitsPerDevPixel = aPresContext->AppUnitsPerDevPixel();
-  nsRect boundRect = aRect.ToAppUnits(appUnitsPerDevPixel);
+  nsRect boundRect = ToAppUnits(aRect, appUnitsPerDevPixel);
   boundRect.MoveBy(NSIntPixelsToAppUnits(aOffset.x, appUnitsPerDevPixel),
                  NSIntPixelsToAppUnits(aOffset.y, appUnitsPerDevPixel));
   boundRect.ScaleInverseRoundOut(aXScale, aYScale);
 
   DisplayItemClip currentClip;
   bool currentClipIsSetInContext = false;
   DisplayItemClip tmpClip;
 
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -29,16 +29,17 @@
 #include "nsHashKeys.h"
 #include "nsISupports.h"
 #include "nsIContent.h"
 #include "nsQueryFrame.h"
 #include "nsCoord.h"
 #include "nsColor.h"
 #include "nsCompatibility.h"
 #include "nsFrameManagerBase.h"
+#include "nsRect.h"
 #include "mozFlushType.h"
 #include "nsWeakReference.h"
 #include <stdio.h> // for FILE definition
 #include "nsChangeHint.h"
 #include "nsRefPtrHashtable.h"
 #include "nsClassHashtable.h"
 #include "nsPresArena.h"
 #include "nsIImageLoadingContent.h"
@@ -75,18 +76,16 @@ class nsWeakFrame;
 class nsIScrollableFrame;
 class gfxContext;
 class nsIDOMEvent;
 class nsDisplayList;
 class nsDisplayListBuilder;
 class nsPIDOMWindow;
 struct nsPoint;
 class nsINode;
-struct nsIntPoint;
-struct nsIntRect;
 struct nsRect;
 class nsRegion;
 class nsRefreshDriver;
 class nsARefreshObserver;
 class nsAPostRefreshObserver;
 #ifdef ACCESSIBILITY
 class nsAccessibilityService;
 namespace mozilla {
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5287,17 +5287,17 @@ PresShell::RenderNode(nsIDOMNode* aNode,
     delete info;
     return nullptr;
   }
 
   if (aRegion) {
     // combine the area with the supplied region
     nsIntRect rrectPixels = aRegion->GetBounds();
 
-    nsRect rrect = rrectPixels.ToAppUnits(nsPresContext::AppUnitsPerCSSPixel());
+    nsRect rrect = ToAppUnits(rrectPixels, nsPresContext::AppUnitsPerCSSPixel());
     area.IntersectRect(area, rrect);
 
     nsPresContext* pc = GetPresContext();
     if (!pc)
       return nullptr;
 
     // move the region so that it is offset from the topleft corner of the surface
     aRegion->MoveBy(-pc->AppUnitsToDevPixels(area.x),
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -11,16 +11,17 @@
 #include <stdarg.h>
 #include <algorithm>
 
 #include "gfxUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
+#include "gfx2DGlue.h"
 
 #include "nsCOMPtr.h"
 #include "nsFrameList.h"
 #include "nsPlaceholderFrame.h"
 #include "nsIContent.h"
 #include "nsContentUtils.h"
 #include "nsIAtom.h"
 #include "nsString.h"
@@ -4919,17 +4920,17 @@ nsIFrame::GetTransformMatrix(const nsIFr
     // as part of the page if they're rendered at all.
     if (widget && rootPresContext) {
       nsIWidget* toplevel = rootPresContext->GetNearestWidget();
       if (toplevel) {
         nsIntRect screenBounds;
         widget->GetClientBounds(screenBounds);
         nsIntRect toplevelScreenBounds;
         toplevel->GetClientBounds(toplevelScreenBounds);
-        nsIntPoint translation = screenBounds.TopLeft() - toplevelScreenBounds.TopLeft();
+        nsIntPoint translation = gfx::ThebesIntPoint(screenBounds.TopLeft() - toplevelScreenBounds.TopLeft());
 
         Matrix4x4 transformToTop;
         transformToTop._41 = translation.x;
         transformToTop._42 = translation.y;
 
         *aOutAncestor = docRootFrame;
         Matrix4x4 docRootTransformToTop =
           nsLayoutUtils::GetTransformToAncestor(docRootFrame, nullptr);
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -609,17 +609,17 @@ nsImageFrame::OnFrameUpdate(imgIRequest*
     // We don't care
     return NS_OK;
   }
 
   nsIntRect layerInvalidRect = mImage
                              ? mImage->GetImageSpaceInvalidationRect(*aRect)
                              : *aRect;
 
-  if (layerInvalidRect.IsEqualInterior(nsIntRect::GetMaxSizedIntRect())) {
+  if (layerInvalidRect.IsEqualInterior(GetMaxSizedIntRect())) {
     // Invalidate our entire area.
     InvalidateSelf(nullptr, nullptr);
     return NS_OK;
   }
 
   nsRect frameInvalidRect = SourceRectToDest(layerInvalidRect);
   InvalidateSelf(&layerInvalidRect, &frameInvalidRect);
   return NS_OK;
--- a/layout/svg/nsFilterInstance.cpp
+++ b/layout/svg/nsFilterInstance.cpp
@@ -363,17 +363,17 @@ nsFilterInstance::BuildSourcePaint(Sourc
     return NS_ERROR_FAILURE;
   }
 
   if (!mPaintTransform.IsSingular()) {
     nsRefPtr<gfxContext> gfx = new gfxContext(offscreenDT);
     gfx->Save();
     gfx->Multiply(mPaintTransform *
                   deviceToFilterSpace *
-                  gfxMatrix::Translation(-neededRect.TopLeft()));
+                  gfxMatrix::Translation(ThebesIntPoint(-neededRect.TopLeft())));
     GeneralPattern pattern;
     if (aSource == &mFillPaint) {
       nsSVGUtils::MakeFillPatternFor(mTargetFrame, gfx, &pattern);
     } else if (aSource == &mStrokePaint) {
       nsSVGUtils::MakeStrokePatternFor(mTargetFrame, gfx, &pattern);
     }
     if (pattern.GetPattern()) {
       offscreenDT->FillRect(ToRect(FilterSpaceToUserSpace(neededRect)),
@@ -440,17 +440,17 @@ nsFilterInstance::BuildSourceImage(DrawT
   // code more complex while being hard to get right without introducing
   // subtle bugs, and in practice it probably makes no real difference.)
   gfxMatrix deviceToFilterSpace = GetFilterSpaceToDeviceSpaceTransform();
   if (!deviceToFilterSpace.Invert()) {
     return NS_ERROR_FAILURE;
   }
   nsRefPtr<gfxContext> ctx = new gfxContext(offscreenDT);
   ctx->SetMatrix(
-    ctx->CurrentMatrix().Translate(-neededRect.TopLeft()).
+    ctx->CurrentMatrix().Translate(ThebesIntPoint(-neededRect.TopLeft())).
                          PreMultiply(deviceToFilterSpace));
 
   mPaintCallback->Paint(*ctx, mTargetFrame, mPaintTransform, &dirty);
 
   mSourceGraphic.mSourceSurface = offscreenDT->Snapshot();
   mSourceGraphic.mSurfaceRect = ToIntRect(neededRect);
 
   return NS_OK;
--- a/layout/svg/nsISVGChildFrame.h
+++ b/layout/svg/nsISVGChildFrame.h
@@ -11,17 +11,16 @@
 
 class gfxContext;
 class gfxMatrix;
 class nsIFrame;
 class SVGBBox;
 
 struct nsPoint;
 struct nsRect;
-struct nsIntRect;
 
 namespace mozilla {
 class SVGAnimatedLengthList;
 class SVGAnimatedNumberList;
 class SVGLengthList;
 class SVGNumberList;
 class SVGUserUnitList;
 
--- a/layout/svg/nsSVGContainerFrame.h
+++ b/layout/svg/nsSVGContainerFrame.h
@@ -18,17 +18,16 @@
 class gfxContext;
 class nsFrameList;
 class nsIContent;
 class nsIPresShell;
 class nsStyleContext;
 
 struct nsPoint;
 struct nsRect;
-struct nsIntRect;
 
 typedef nsContainerFrame nsSVGContainerFrameBase;
 
 /**
  * Base class for SVG container frames. Frame sub-classes that do not
  * display their contents directly (such as the frames for <marker> or
  * <pattern>) just inherit this class. Frame sub-classes that do or can
  * display their contents directly (such as the frames for inner-<svg> or
--- a/layout/svg/nsSVGFilterPaintCallback.h
+++ b/layout/svg/nsSVGFilterPaintCallback.h
@@ -1,21 +1,21 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef __NS_SVGFILTERPAINTCALLBACK_H__
 #define __NS_SVGFILTERPAINTCALLBACK_H__
 
+#include "nsRect.h"
+
 class nsIFrame;
 class gfxContext;
 
-struct nsIntRect;
-
 class nsSVGFilterPaintCallback {
 public:
   /**
    * Paint the frame contents.
    * SVG frames will have had matrix propagation set to false already.
    * Non-SVG frames have to do their own thing.
    * The caller will do a Save()/Restore() as necessary so feel free
    * to mess with context state.
--- a/layout/svg/nsSVGImageFrame.cpp
+++ b/layout/svg/nsSVGImageFrame.cpp
@@ -344,17 +344,17 @@ nsSVGImageFrame::PaintSVG(gfxContext& aC
     }
 
     nscoord appUnitsPerDevPx = PresContext()->AppUnitsPerDevPixel();
     nsRect dirtyRect; // only used if aDirtyRect is non-null
     if (aDirtyRect) {
       NS_ASSERTION(!NS_SVGDisplayListPaintingEnabled() ||
                    (mState & NS_FRAME_IS_NONDISPLAY),
                    "Display lists handle dirty rect intersection test");
-      dirtyRect = aDirtyRect->ToAppUnits(appUnitsPerDevPx);
+      dirtyRect = ToAppUnits(*aDirtyRect, appUnitsPerDevPx);
       // Adjust dirtyRect to match our local coordinate system.
       nsRect rootRect =
         nsSVGUtils::TransformFrameRectToOuterSVG(mRect, aTransform,
                                                  PresContext());
       dirtyRect.MoveBy(-rootRect.TopLeft());
     }
 
     // XXXbholley - I don't think huge images in SVGs are common enough to
--- a/layout/svg/nsSVGIntegrationUtils.h
+++ b/layout/svg/nsSVGIntegrationUtils.h
@@ -14,17 +14,16 @@
 class gfxContext;
 class gfxDrawable;
 class nsDisplayList;
 class nsDisplayListBuilder;
 class nsIFrame;
 class nsIntRegion;
 
 struct nsRect;
-struct nsIntRect;
 
 namespace mozilla {
 namespace gfx {
 class DrawTarget;
 }
 namespace layers {
 class LayerManager;
 }
--- a/layout/svg/nsSVGPathGeometryFrame.h
+++ b/layout/svg/nsSVGPathGeometryFrame.h
@@ -27,17 +27,16 @@ class nsIAtom;
 class nsIFrame;
 class nsIPresShell;
 class nsStyleContext;
 class nsSVGMarkerFrame;
 class nsSVGMarkerProperty;
 
 struct nsPoint;
 struct nsRect;
-struct nsIntRect;
 
 typedef nsFrame nsSVGPathGeometryFrameBase;
 
 class nsSVGPathGeometryFrame : public nsSVGPathGeometryFrameBase,
                                public nsISVGChildFrame
 {
   typedef mozilla::gfx::DrawTarget DrawTarget;
 
--- a/layout/svg/nsSVGUtils.h
+++ b/layout/svg/nsSVGUtils.h
@@ -44,17 +44,16 @@ class nsSVGLength2;
 class nsSVGOuterSVGFrame;
 class nsSVGPathGeometryFrame;
 class nsTextFrame;
 class gfxTextContextPaint;
 
 struct nsStyleSVG;
 struct nsStyleSVGPaint;
 struct nsRect;
-struct nsIntRect;
 struct nsPoint;
 
 namespace mozilla {
 class SVGAnimatedPreserveAspectRatio;
 class SVGPreserveAspectRatio;
 namespace dom {
 class Element;
 class UserSpaceMetrics;
--- a/layout/tables/nsCellMap.h
+++ b/layout/tables/nsCellMap.h
@@ -7,29 +7,29 @@
 
 #include "nscore.h"
 #include "celldata.h"
 #include "nsTArray.h"
 #include "nsTArray.h"
 #include "nsCOMPtr.h"
 #include "nsAlgorithm.h"
 #include "nsAutoPtr.h"
+#include "nsRect.h"
 #include <algorithm>
 
 #undef DEBUG_TABLE_CELLMAP
 
 class nsTableColFrame;
 class nsTableCellFrame;
 class nsTableRowFrame;
 class nsTableRowGroupFrame;
 class nsTableFrame;
 class nsCellMap;
 class nsPresContext;
 class nsCellMapColumnIterator;
-struct nsIntRect;
 
 struct nsColInfo
 {
   int32_t mNumCellsOrig; // number of cells originating in the col
   int32_t mNumCellsSpan; // number of cells spanning into the col via colspans (not rowspans)
 
   nsColInfo();
   nsColInfo(int32_t aNumCellsOrig,
--- a/layout/xul/BoxObject.h
+++ b/layout/xul/BoxObject.h
@@ -12,20 +12,20 @@
 #include "nsIBoxObject.h"
 #include "nsPIBoxObject.h"
 #include "nsPoint.h"
 #include "nsAutoPtr.h"
 #include "nsHashKeys.h"
 #include "nsInterfaceHashtable.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
+#include "nsRect.h"
 
 class nsIFrame;
 class nsIDocShell;
-struct nsIntRect;
 class nsIPresShell;
 
 namespace mozilla {
 namespace dom {
 
 class Element;
 
 class BoxObject : public nsPIBoxObject,
--- a/layout/xul/PopupBoxObject.cpp
+++ b/layout/xul/PopupBoxObject.cpp
@@ -266,17 +266,17 @@ PopupBoxObject::GetOuterScreenRect()
   nsView* view = menuPopupFrame->GetView();
   if (view) {
     nsIWidget* widget = view->GetWidget();
     if (widget) {
       nsIntRect screenRect;
       widget->GetScreenBounds(screenRect);
 
       int32_t pp = menuPopupFrame->PresContext()->AppUnitsPerDevPixel();
-      rect->SetLayoutRect(screenRect.ToAppUnits(pp));
+      rect->SetLayoutRect(ToAppUnits(screenRect, pp));
     }
   }
   return rect.forget();
 }
 
 void
 PopupBoxObject::GetAlignmentPosition(nsString& positionStr)
 {
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -1494,17 +1494,17 @@ nsMenuPopupFrame::GetConstraintRect(cons
         screen->GetRect(&screenRectPixels.x, &screenRectPixels.y,
                         &screenRectPixels.width, &screenRectPixels.height);
       else
         screen->GetAvailRect(&screenRectPixels.x, &screenRectPixels.y,
                              &screenRectPixels.width, &screenRectPixels.height);
     }
   }
 
-  nsRect screenRect = screenRectPixels.ToAppUnits(presContext->AppUnitsPerDevPixel());
+  nsRect screenRect = ToAppUnits(screenRectPixels, presContext->AppUnitsPerDevPixel());
   if (mInContentShell) {
     // for content shells, clip to the client area rather than the screen area
     screenRect.IntersectRect(screenRect, aRootScreenRect);
   }
 
   return screenRect;
 }
 
--- a/layout/xul/nsResizerFrame.cpp
+++ b/layout/xul/nsResizerFrame.cpp
@@ -233,17 +233,17 @@ nsResizerFrame::HandleEvent(nsPresContex
         rect.IntersectRect(rect, LayoutDevicePixel::FromUntyped(screenRectPixels));
       }
 
       if (contentToResize) {
         // convert the rectangle into css pixels. When changing the size in a
         // direction, don't allow the new size to be less that the resizer's
         // size. This ensures that content isn't resized too small as to make
         // the resizer invisible.
-        nsRect appUnitsRect = LayoutDevicePixel::ToUntyped(rect).ToAppUnits(aPresContext->AppUnitsPerDevPixel());
+        nsRect appUnitsRect = ToAppUnits(LayoutDevicePixel::ToUntyped(rect), aPresContext->AppUnitsPerDevPixel());
         if (appUnitsRect.width < mRect.width && mouseMove.x)
           appUnitsRect.width = mRect.width;
         if (appUnitsRect.height < mRect.height && mouseMove.y)
           appUnitsRect.height = mRect.height;
         nsIntRect cssRect = appUnitsRect.ToInsidePixels(nsPresContext::AppUnitsPerCSSPixel());
 
         nsIntRect oldRect;
         nsWeakFrame weakFrame(menuPopupFrame);
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -686,17 +686,17 @@ nsSliderFrame::CurrentPositionChanged()
 
   if (IsHorizontal())
      newThumbRect.x = clientRect.x + NSToCoordRound(pos * mRatio);
   else
      newThumbRect.y = clientRect.y + NSToCoordRound(pos * mRatio);
 
   // avoid putting the scroll thumb at subpixel positions which cause needless invalidations
   nscoord appUnitsPerPixel = PresContext()->AppUnitsPerDevPixel();
-  nsRect snappedThumbRect = newThumbRect.ToNearestPixels(appUnitsPerPixel).ToAppUnits(appUnitsPerPixel);
+  nsRect snappedThumbRect = ToAppUnits(newThumbRect.ToNearestPixels(appUnitsPerPixel), appUnitsPerPixel);
   if (IsHorizontal()) {
     newThumbRect.x = snappedThumbRect.x;
     newThumbRect.width = snappedThumbRect.width;
   } else {
     newThumbRect.y = snappedThumbRect.y;
     newThumbRect.height = snappedThumbRect.height;
   }
   newThumbRect = newThumbRect.Intersect(clientRect);
--- a/view/nsView.cpp
+++ b/view/nsView.cpp
@@ -765,19 +765,19 @@ void nsView::List(FILE* out, int32_t aIn
 {
   int32_t i;
   for (i = aIndent; --i >= 0; ) fputs("  ", out);
   fprintf(out, "%p ", (void*)this);
   if (nullptr != mWindow) {
     nscoord p2a = mViewManager->AppUnitsPerDevPixel();
     nsIntRect rect;
     mWindow->GetClientBounds(rect);
-    nsRect windowBounds = rect.ToAppUnits(p2a);
+    nsRect windowBounds = ToAppUnits(rect, p2a);
     mWindow->GetBounds(rect);
-    nsRect nonclientBounds = rect.ToAppUnits(p2a);
+    nsRect nonclientBounds = ToAppUnits(rect, p2a);
     nsrefcnt widgetRefCnt = mWindow.get()->AddRef() - 1;
     mWindow.get()->Release();
     int32_t Z = mWindow->GetZIndex();
     fprintf(out, "(widget=%p[%" PRIuPTR "] z=%d pos={%d,%d,%d,%d}) ",
             (void*)mWindow, widgetRefCnt, Z,
             nonclientBounds.x, nonclientBounds.y,
             windowBounds.width, windowBounds.height);
   }
--- a/view/nsViewManager.cpp
+++ b/view/nsViewManager.cpp
@@ -470,17 +470,17 @@ void nsViewManager::FlushDirtyRegionToWi
     nearestViewWithWidget = nearestViewWithWidget->GetParent();
   }
   nsRegion r =
     ConvertRegionBetweenViews(*dirtyRegion, aView, nearestViewWithWidget);
 
   // If we draw the frame counter we need to make sure we invalidate the area
   // for it to make it on screen
   if (gfxPrefs::DrawFrameCounter()) {
-    nsRect counterBounds = gfxPlatform::FrameCounterBounds().ToAppUnits(AppUnitsPerDevPixel());
+    nsRect counterBounds = ToAppUnits(gfxPlatform::FrameCounterBounds(), AppUnitsPerDevPixel());
     r = r.Or(r, counterBounds);
   }
 
   nsViewManager* widgetVM = nearestViewWithWidget->GetViewManager();
   widgetVM->InvalidateWidgetArea(nearestViewWithWidget, r);
   dirtyRegion->SetEmpty();
 }
 
@@ -565,19 +565,18 @@ nsViewManager::InvalidateWidgetArea(nsVi
 #ifndef XP_MACOSX
         // GetBounds should compensate for chrome on a toplevel widget
         nsIntRect bounds;
         childWidget->GetBounds(bounds);
 
         nsTArray<nsIntRect> clipRects;
         childWidget->GetWindowClipRegion(&clipRects);
         for (uint32_t i = 0; i < clipRects.Length(); ++i) {
-          nsRect rr = (clipRects[i] + bounds.TopLeft()).
-            ToAppUnits(AppUnitsPerDevPixel());
-          children.Or(children, rr - aWidgetView->ViewToWidgetOffset()); 
+          nsRect rr = ToAppUnits(clipRects[i] + bounds.TopLeft(), AppUnitsPerDevPixel());
+          children.Or(children, rr - aWidgetView->ViewToWidgetOffset());
           children.SimplifyInward(20);
         }
 #endif
       }
     }
   }
 
   nsRegion leftOver;
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -1127,17 +1127,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(nsIntRect &aRect) {
-  aRect.MoveTo(LayoutDeviceIntPoint::ToUntyped(WidgetToScreenOffset()));
+  aRect.MoveTo(gfx::ToIntPoint(LayoutDeviceIntPoint::ToUntyped(WidgetToScreenOffset())));
   aRect.SizeTo(mBounds.Size());
   return NS_OK;
 }
 
 PuppetScreen::PuppetScreen(void *nativeScreen)
 {
 }
 
--- a/widget/android/AndroidDirectTexture.h
+++ b/widget/android/AndroidDirectTexture.h
@@ -4,18 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef AndroidDirectTexture_h_
 #define AndroidDirectTexture_h_
 
 #include "gfxTypes.h"
 #include "mozilla/Mutex.h"
 #include "AndroidGraphicBuffer.h"
-
-struct nsIntRect;
+#include "nsRect.h"
 
 namespace mozilla {
 
 /**
  * This is a thread safe wrapper around AndroidGraphicBuffer that handles
  * double buffering. Each call to Bind() flips the buffer when necessary.
  *
  * You need to be careful when destroying an instance of this class. If either
--- a/widget/android/AndroidGraphicBuffer.h
+++ b/widget/android/AndroidGraphicBuffer.h
@@ -2,22 +2,21 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef AndroidGraphicBuffer_h_
 #define AndroidGraphicBuffer_h_
 
 #include "gfxTypes.h"
+#include "nsRect.h"
 
 typedef void* EGLImageKHR;
 typedef void* EGLClientBuffer;
 
-struct nsIntRect;
-
 namespace mozilla {
 
 /**
  * This class allows access to Android's direct texturing mechanism. Locking
  * the buffer gives you a pointer you can read/write to directly. It is fully
  * threadsafe, but you probably really want to use the AndroidDirectTexture
  * class which will handle double buffering.
  *
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2650,17 +2650,17 @@ RectTextureImage::TextureSizeForSize(con
 TemporaryRef<gfx::DrawTarget>
 RectTextureImage::BeginUpdate(const nsIntSize& aNewSize,
                               const nsIntRegion& aDirtyRegion)
 {
   MOZ_ASSERT(!mInUpdate, "Beginning update during update!");
   mUpdateRegion = aDirtyRegion;
   if (aNewSize != mUsedSize) {
     mUsedSize = aNewSize;
-    mUpdateRegion = nsIntRect(nsIntPoint(0, 0), aNewSize);
+    mUpdateRegion = gfx::IntRect(gfx::IntPoint(0, 0), aNewSize);
   }
 
   if (mUpdateRegion.IsEmpty()) {
     return nullptr;
   }
 
   nsIntSize neededBufferSize = TextureSizeForSize(mUsedSize);
   if (!mUpdateDrawTarget || mBufferSize != neededBufferSize) {
@@ -2693,17 +2693,17 @@ RectTextureImage::EndUpdate(bool aKeepSu
   bool overwriteTexture = false;
   nsIntRegion updateRegion = mUpdateRegion;
   if (!mTexture || (mTextureSize != mBufferSize)) {
     overwriteTexture = true;
     mTextureSize = mBufferSize;
   }
 
   if (overwriteTexture || !CanUploadSubtextures()) {
-    updateRegion = nsIntRect(nsIntPoint(0, 0), mTextureSize);
+    updateRegion = gfx::IntRect(gfx::IntPoint(0, 0), mTextureSize);
   }
 
   RefPtr<gfx::SourceSurface> snapshot = mUpdateDrawTarget->Snapshot();
   RefPtr<gfx::DataSourceSurface> dataSnapshot = snapshot->GetDataSurface();
 
   UploadSurfaceToTexture(mGLContext,
                          dataSnapshot,
                          updateRegion,
--- a/widget/gonk/HwcComposer2D.cpp
+++ b/widget/gonk/HwcComposer2D.cpp
@@ -135,17 +135,17 @@ HwcComposer2D::HwcComposer2D()
         return;
     }
 
     nsIntSize screenSize;
 
     ANativeWindow *win = GetGonkDisplay()->GetNativeWindow();
     win->query(win, NATIVE_WINDOW_WIDTH, &screenSize.width);
     win->query(win, NATIVE_WINDOW_HEIGHT, &screenSize.height);
-    mScreenRect = nsIntRect(nsIntPoint(0, 0), screenSize);
+    mScreenRect = gfx::IntRect(gfx::IntPoint(0, 0), screenSize);
 
 #if ANDROID_VERSION >= 17
     int supported = 0;
 
     if (mHwc->query) {
         if (mHwc->query(mHwc, HwcUtils::HWC_COLOR_FILL, &supported) == NO_ERROR) {
             mColorFill = !!supported;
         }
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -156,17 +156,17 @@ nsWindow::nsWindow()
     nsIntSize screenSize;
 
     ANativeWindow *win = GetGonkDisplay()->GetNativeWindow();
 
     if (win->query(win, NATIVE_WINDOW_WIDTH, &screenSize.width) ||
         win->query(win, NATIVE_WINDOW_HEIGHT, &screenSize.height)) {
         NS_RUNTIMEABORT("Failed to get native window size, aborting...");
     }
-    gScreenBounds = nsIntRect(nsIntPoint(0, 0), screenSize);
+    gScreenBounds = gfx::IntRect(gfx::IntPoint(0, 0), screenSize);
 
     char propValue[PROPERTY_VALUE_MAX];
     property_get("ro.sf.hwrotation", propValue, "0");
     sPhysicalScreenRotation = atoi(propValue) / 90;
 
     sVirtualBounds = gScreenBounds;
 
     sScreenInitialized = true;
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsNativeThemeGTK.h"
 #include "nsThemeConstants.h"
 #include "gtkdrawing.h"
 
+#include "gfx2DGlue.h"
 #include "nsIObserverService.h"
 #include "nsIServiceManager.h"
 #include "nsIFrame.h"
 #include "nsIPresShell.h"
 #include "nsIContent.h"
 #include "nsViewManager.h"
 #include "nsNameSpaceManager.h"
 #include "nsGfxCIID.h"
@@ -844,17 +845,17 @@ nsNativeThemeGTK::DrawWidgetBackground(n
   dirtyRect.RoundOut();
 
   // GTK themes can only draw an integer number of pixels
   // (even when not snapped).
   nsIntRect widgetRect(0, 0, NS_lround(rect.Width()), NS_lround(rect.Height()));
   nsIntRect overflowRect(widgetRect);
   nsIntMargin extraSize;
   if (GetExtraSizeForWidget(aFrame, aWidgetType, &extraSize)) {
-    overflowRect.Inflate(extraSize);
+    overflowRect.Inflate(gfx::ToIntMargin(extraSize));
   }
 
   // This is the rectangle that will actually be drawn, in gdk pixels
   nsIntRect drawingRect(int32_t(dirtyRect.X()),
                         int32_t(dirtyRect.Y()),
                         int32_t(dirtyRect.Width()),
                         int32_t(dirtyRect.Height()));
   if (widgetRect.IsEmpty()
--- a/widget/nsBaseDragService.cpp
+++ b/widget/nsBaseDragService.cpp
@@ -511,17 +511,17 @@ nsBaseDragService::DrawDrag(nsIDOMNode* 
     // if a region was specified, set the screen rectangle to the area that
     // the region occupies
     if (aRegion) {
       // the region's coordinates are relative to the root frame
       nsIFrame* rootFrame = presShell->GetRootFrame();
       if (rootFrame && *aPresContext) {
         nsIntRect dragRect;
         aRegion->GetBoundingBox(&dragRect.x, &dragRect.y, &dragRect.width, &dragRect.height);
-        dragRect = dragRect.ToAppUnits(nsPresContext::AppUnitsPerCSSPixel()).
+        dragRect = ToAppUnits(dragRect, nsPresContext::AppUnitsPerCSSPixel()).
                             ToOutsidePixels((*aPresContext)->AppUnitsPerDevPixel());
 
         nsIntRect screenRect = rootFrame->GetScreenRectExternal();
         aScreenDragRect->SetRect(screenRect.x + dragRect.x, screenRect.y + dragRect.y,
                                  dragRect.width, dragRect.height);
       }
     }
     else {
--- a/widget/nsIPluginWidget.h
+++ b/widget/nsIPluginWidget.h
@@ -1,20 +1,20 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.h"
+#include "nsPoint.h"
 
 #define NS_IPLUGINWIDGET_IID    \
   { 0xEB9207E0, 0xD8F1, 0x44B9, \
     { 0xB7, 0x52, 0xAF, 0x8E, 0x9F, 0x8E, 0xBD, 0xF7 } }
 
-struct nsIntPoint;
 class nsIPluginInstanceOwner;
 
 /**
  * This is used by Mac only.
  */
 class NS_NO_VTABLE nsIPluginWidget : public nsISupports
 {
  public: 
--- a/widget/nsIRollupListener.h
+++ b/widget/nsIRollupListener.h
@@ -3,20 +3,20 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef __nsIRollupListener_h__
 #define __nsIRollupListener_h__
 
 #include "nsTArray.h"
+#include "nsPoint.h"
 
 class nsIContent;
 class nsIWidget;
-struct nsIntPoint;
 
 class nsIRollupListener {
  public: 
 
   /**
    * Notifies the object to rollup, optionally returning the node that
    * was just rolled up.
    *
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -1494,17 +1494,17 @@ void find_first_visible_parent(QWindow* 
             }
         }
     }
 }
 
 NS_IMETHODIMP
 nsWindow::GetScreenBounds(nsIntRect &aRect)
 {
-    aRect = nsIntRect(nsIntPoint(0, 0), mBounds.Size());
+    aRect = gfx::IntRect(gfx::IntPoint(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",
--- a/widget/windows/WinMouseScrollHandler.h
+++ b/widget/windows/WinMouseScrollHandler.h
@@ -9,19 +9,19 @@
 
 #include "nscore.h"
 #include "nsDebug.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/TimeStamp.h"
 #include "Units.h"
 #include <windows.h>
+#include "nsPoint.h"
 
 class nsWindowBase;
-struct nsIntPoint;
 
 namespace mozilla {
 namespace widget {
 
 class ModifierKeyState;
 
 struct MSGResult;
 
--- a/widget/windows/WinUtils.h
+++ b/widget/windows/WinUtils.h
@@ -17,16 +17,17 @@
 #undef CreateEvent
 #undef GetClassName
 #undef GetBinaryType
 #undef RemoveDirectory
 
 #include "nsAutoPtr.h"
 #include "nsString.h"
 #include "nsRegion.h"
+#include "nsRect.h"
 
 #include "nsIRunnable.h"
 #include "nsICryptoHash.h"
 #ifdef MOZ_PLACES
 #include "nsIFaviconService.h"
 #endif
 #include "nsIDownloader.h"
 #include "nsIURI.h"
@@ -70,17 +71,16 @@ public:                                 
 protected:                                                                    \
   nsAutoRefCnt mRefCnt;                                                       \
   NS_DECL_OWNINGTHREAD                                                        \
 public:
 
 class nsWindow;
 class nsWindowBase;
 struct KeyPair;
-struct nsIntRect;
 
 namespace mozilla {
 namespace widget {
 
 // Windows message debugging data
 typedef struct {
   const char * mStr;
   UINT         mId;
--- a/widget/windows/nsIMM32Handler.h
+++ b/widget/windows/nsIMM32Handler.h
@@ -8,19 +8,19 @@
 
 #include "nscore.h"
 #include <windows.h>
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsIWidget.h"
 #include "mozilla/EventForwards.h"
+#include "nsRect.h"
 
 class nsWindow;
-struct nsIntRect;
 
 namespace mozilla {
 namespace widget {
 
 struct MSGResult;
 
 } // namespace widget
 } // namespace mozilla
--- a/widget/windows/winrt/MetroInput.cpp
+++ b/widget/windows/winrt/MetroInput.cpp
@@ -15,16 +15,17 @@
 #include "MetroAppShell.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/Preferences.h"  // for Preferences
 #include "WinUtils.h"
 #include "nsIPresShell.h"
+#include "nsPoint.h"
 
 // System headers (alphabetical)
 #include <windows.ui.core.h> // ABI::Window::UI::Core namespace
 #include <windows.ui.input.h> // ABI::Window::UI::Input namespace
 
 //#define DEBUG_INPUT
 
 // Using declarations
--- a/widget/windows/winrt/MetroInput.h
+++ b/widget/windows/winrt/MetroInput.h
@@ -18,17 +18,16 @@
 // System headers (alphabetical)
 #include <EventToken.h>     // EventRegistrationToken
 #include <stdint.h>         // uint32_t
 #include <wrl\client.h>     // Microsoft::WRL::ComPtr class
 #include <wrl\implements.h> // Microsoft::WRL::InspectableClass macro
 
 // Moz forward declarations
 class MetroWidget;
-struct nsIntPoint;
 
 namespace mozilla {
 namespace dom {
 class Touch;
 }
 }
 
 // Windows forward declarations
--- a/widget/windows/winrt/MetroUtils.h
+++ b/widget/windows/winrt/MetroUtils.h
@@ -5,16 +5,17 @@
 
 #pragma once
 
 #include "nsDebug.h"
 #include "nsThreadUtils.h"
 #include "nsString.h"
 #include "nsPoint.h"
 #include "WinUtils.h"
+#include "nsRect.h"
 
 #include "mozwrlbase.h"
 
 #include <stdio.h>
 #include <windows.foundation.h>
 #include <windows.ui.viewmanagement.h>
 
 // HRESULT checkers, these warn on failure in debug builds
@@ -35,17 +36,16 @@
   }
 
 // MS Point helpers
 #define POINT_CEIL_X(position) (uint32_t)ceil(position.X)
 #define POINT_CEIL_Y(position) (uint32_t)ceil(position.Y)
 
 class nsIBrowserDOMWindow;
 class nsIDOMWindow;
-struct nsIntRect;
 
 namespace mozilla {
 namespace widget {
 namespace winrt {
 
 template<unsigned int size, typename T>
 HRESULT ActivateGenericInstance(wchar_t const (&RuntimeClassName)[size], Microsoft::WRL::ComPtr<T>& aOutObject) {
   Microsoft::WRL::ComPtr<IActivationFactory> factory;
--- a/xpfe/appshell/nsAppShellService.cpp
+++ b/xpfe/appshell/nsAppShellService.cpp
@@ -388,17 +388,17 @@ nsAppShellService::CreateWindowlessBrows
    * nsWebBrowser with an instance of PuppetWidget, which provides a stub
    * implementation of nsIWidget.
    */
   nsCOMPtr<nsIWidget> widget = nsIWidget::CreatePuppetWidget(nullptr);
   if (!widget) {
     NS_ERROR("Couldn't create instance of PuppetWidget");
     return NS_ERROR_FAILURE;
   }
-  widget->Create(nullptr, 0, nsIntRect(nsIntPoint(0, 0), nsIntSize(0, 0)),
+  widget->Create(nullptr, 0, gfx::IntRect(gfx::IntPoint(0, 0), gfx::IntSize(0, 0)),
                  nullptr);
   nsCOMPtr<nsIBaseWindow> window = do_QueryInterface(navigation);
   window->InitWindow(0, widget, 0, 0, 0, 0);
   window->Create();
 
   nsISupports *isstub = NS_ISUPPORTS_CAST(nsIWebBrowserChrome2*, stub);
   nsRefPtr<nsIWebNavigation> result = new WindowlessBrowserStub(browser, isstub);
   nsCOMPtr<nsIDocShell> docshell = do_GetInterface(result);