Bug 448830. Make nsIntRect/nsIntSize/nsIntPoint/nsIntMargin separate types so we get appunit vs pixel typechecking. r+sr=roc
authorJeremy Lea <reg@openpave.org>
Fri, 26 Sep 2008 10:42:19 +1200
changeset 19745 b3412569801fb11b3cc2f76f86645bc3bae1bb47
parent 19744 71004cbe3d8a836e93cfa2d7accb6a7eca823ef7
child 19746 c30d3bdb2bd561ef74b74575c9925bea506b814d
push idunknown
push userunknown
push dateunknown
bugs448830
milestone1.9.1b1pre
Bug 448830. Make nsIntRect/nsIntSize/nsIntPoint/nsIntMargin separate types so we get appunit vs pixel typechecking. r+sr=roc
accessible/src/base/nsAccessible.cpp
accessible/src/base/nsCaretAccessible.cpp
accessible/src/base/nsCaretAccessible.h
accessible/src/html/nsHTMLAreaAccessible.cpp
accessible/src/html/nsHyperTextAccessible.cpp
content/base/src/nsImageLoadingContent.cpp
content/events/src/nsDOMUIEvent.cpp
content/events/src/nsDOMUIEvent.h
content/events/src/nsEventListenerManager.cpp
content/events/src/nsEventListenerManager.h
content/events/src/nsEventStateManager.cpp
content/events/src/nsEventStateManager.h
content/events/src/nsQueryContentEventHandler.cpp
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsIContentViewer.idl
docshell/shistory/public/nsISHEntry.idl
docshell/shistory/src/nsSHEntry.cpp
docshell/shistory/src/nsSHEntry.h
editor/libeditor/base/nsEditor.cpp
editor/libeditor/text/nsPlaintextEditor.cpp
embedding/browser/gtk/src/EmbedContextMenuInfo.cpp
embedding/browser/gtk/src/EmbedContextMenuInfo.h
embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
embedding/browser/webBrowser/nsWebBrowser.cpp
embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
gfx/public/nsITheme.h
gfx/public/nsMargin.h
gfx/public/nsPoint.h
gfx/public/nsRect.h
gfx/public/nsSize.h
gfx/src/nsRect.cpp
gfx/src/thebes/nsThebesImage.cpp
gfx/src/thebes/nsThebesImage.h
gfx/src/thebes/nsThebesRenderingContext.cpp
layout/base/nsCSSRendering.cpp
layout/base/nsDocumentViewer.cpp
layout/base/nsIPresShell.h
layout/base/nsImageLoader.cpp
layout/base/nsImageLoader.h
layout/base/nsLayoutUtils.cpp
layout/base/nsPresContext.h
layout/base/nsPresShell.cpp
layout/generic/nsBulletFrame.cpp
layout/generic/nsBulletFrame.h
layout/generic/nsFrame.cpp
layout/generic/nsFrameFrame.cpp
layout/generic/nsFrameSetFrame.cpp
layout/generic/nsFrameSetFrame.h
layout/generic/nsHTMLCanvasFrame.cpp
layout/generic/nsHTMLCanvasFrame.h
layout/generic/nsHTMLReflowState.cpp
layout/generic/nsImageFrame.cpp
layout/generic/nsImageFrame.h
layout/generic/nsObjectFrame.cpp
layout/generic/nsObjectFrame.h
layout/generic/nsPageFrame.cpp
layout/generic/nsSimplePageSequence.cpp
layout/printing/nsPrintEngine.cpp
layout/svg/base/src/nsSVGEffects.cpp
layout/svg/base/src/nsSVGForeignObjectFrame.cpp
layout/svg/base/src/nsSVGIntegrationUtils.cpp
layout/svg/base/src/nsSVGOuterSVGFrame.cpp
layout/svg/base/src/nsSVGUtils.cpp
layout/xul/base/public/nsXULPopupManager.h
layout/xul/base/src/nsBox.cpp
layout/xul/base/src/nsBoxObject.cpp
layout/xul/base/src/nsBoxObject.h
layout/xul/base/src/nsImageBoxFrame.cpp
layout/xul/base/src/nsImageBoxFrame.h
layout/xul/base/src/nsMenuPopupFrame.cpp
layout/xul/base/src/nsResizerFrame.h
layout/xul/base/src/nsScrollBoxObject.cpp
layout/xul/base/src/nsTitleBarFrame.cpp
layout/xul/base/src/nsTitleBarFrame.h
layout/xul/base/src/nsXULPopupManager.cpp
layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
layout/xul/base/src/tree/src/nsTreeImageListener.cpp
layout/xul/base/src/tree/src/nsTreeImageListener.h
view/public/nsIViewManager.h
view/src/nsScrollPortView.cpp
view/src/nsScrollPortView.h
view/src/nsView.cpp
view/src/nsView.h
view/src/nsViewManager.cpp
view/src/nsViewManager.h
widget/public/nsGUIEvent.h
widget/public/nsIPrintSettings.idl
widget/public/nsIScreenManager.idl
widget/public/nsIWidget.h
widget/src/cocoa/nsChildView.h
widget/src/cocoa/nsChildView.mm
widget/src/cocoa/nsCocoaUtils.h
widget/src/cocoa/nsCocoaUtils.mm
widget/src/cocoa/nsCocoaWindow.h
widget/src/cocoa/nsCocoaWindow.mm
widget/src/cocoa/nsDragService.h
widget/src/cocoa/nsDragService.mm
widget/src/cocoa/nsNativeThemeCocoa.h
widget/src/cocoa/nsNativeThemeCocoa.mm
widget/src/cocoa/nsScreenCocoa.mm
widget/src/cocoa/nsScreenManagerCocoa.mm
widget/src/gtk2/nsCommonWidget.cpp
widget/src/gtk2/nsCommonWidget.h
widget/src/gtk2/nsDragService.cpp
widget/src/gtk2/nsDragService.h
widget/src/gtk2/nsNativeThemeGTK.cpp
widget/src/gtk2/nsNativeThemeGTK.h
widget/src/gtk2/nsPrintSettingsGTK.cpp
widget/src/gtk2/nsPrintSettingsGTK.h
widget/src/gtk2/nsScreenGtk.cpp
widget/src/gtk2/nsScreenGtk.h
widget/src/gtk2/nsScreenManagerGtk.cpp
widget/src/gtk2/nsWindow.cpp
widget/src/gtk2/nsWindow.h
widget/src/windows/nsDragService.cpp
widget/src/windows/nsNativeThemeWin.cpp
widget/src/windows/nsNativeThemeWin.h
widget/src/windows/nsWindow.cpp
widget/src/windows/nsWindow.h
widget/src/xpwidgets/nsBaseDragService.cpp
widget/src/xpwidgets/nsBaseDragService.h
widget/src/xpwidgets/nsBaseWidget.cpp
widget/src/xpwidgets/nsBaseWidget.h
widget/src/xpwidgets/nsPrintOptionsImpl.cpp
widget/src/xpwidgets/nsPrintOptionsImpl.h
widget/src/xpwidgets/nsPrintSettingsImpl.cpp
widget/src/xpwidgets/nsPrintSettingsImpl.h
xpfe/appshell/src/nsWebShellWindow.cpp
xpfe/appshell/src/nsXULWindow.cpp
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -1362,17 +1362,17 @@ NS_IMETHODIMP nsAccessible::GetBounds(PR
 
   *x      = presContext->AppUnitsToDevPixels(unionRectTwips.x); 
   *y      = presContext->AppUnitsToDevPixels(unionRectTwips.y);
   *width  = presContext->AppUnitsToDevPixels(unionRectTwips.width);
   *height = presContext->AppUnitsToDevPixels(unionRectTwips.height);
 
   // We have the union of the rectangle, now we need to put it in absolute screen coords
 
-  nsRect orgRectPixels = aBoundingFrame->GetScreenRectExternal();
+  nsIntRect orgRectPixels = aBoundingFrame->GetScreenRectExternal();
   *x += orgRectPixels.x;
   *y += orgRectPixels.y;
 
   return NS_OK;
 }
 
 // helpers
 
--- a/accessible/src/base/nsCaretAccessible.cpp
+++ b/accessible/src/base/nsCaretAccessible.cpp
@@ -339,20 +339,20 @@ nsCaretAccessible::SpellcheckSelectionCh
   nsCOMPtr<nsIAccessibleEvent> event =
     new nsAccEvent(nsIAccessibleEvent::EVENT_TEXT_ATTRIBUTE_CHANGED,
                    containerAccessible, nsnull);
   NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
 
   return mRootAccessible->FireAccessibleEvent(event);
 }
 
-nsRect
+nsIntRect
 nsCaretAccessible::GetCaretRect(nsIWidget **aOutWidget)
 {
-  nsRect caretRect;
+  nsIntRect caretRect;
   NS_ENSURE_TRUE(aOutWidget, caretRect);
   *aOutWidget = nsnull;
   NS_ENSURE_TRUE(mRootAccessible, caretRect);
 
   if (!mLastTextAccessible) {
     return caretRect;    // Return empty rect
   }
 
@@ -370,38 +370,37 @@ nsCaretAccessible::GetCaretRect(nsIWidge
   presShell->GetCaret(getter_AddRefs(caret));
   NS_ENSURE_TRUE(caret, caretRect);
 
   PRBool isCollapsed;
   nsIView *view;
   nsCOMPtr<nsISelection> caretSelection(do_QueryReferent(mLastUsedSelection));
   NS_ENSURE_TRUE(caretSelection, caretRect);
   
+  nsRect rect;
   caret->GetCaretCoordinates(nsCaret::eRenderingViewCoordinates, caretSelection,
-                             &caretRect, &isCollapsed, &view);
-  if (!view || caretRect.IsEmpty()) {
-    return nsRect(); // Return empty rect
+                             &rect, &isCollapsed, &view);
+  if (!view || rect.IsEmpty()) {
+    return nsIntRect(); // Return empty rect
   }
 
   PRBool isVisible;
   caret->GetCaretVisible(&isVisible);
   if (!isVisible) {
-    return nsRect();  // Return empty rect
+    return nsIntRect();  // Return empty rect
   }
   nsPoint offsetFromWidget;
   *aOutWidget = view->GetNearestWidget(&offsetFromWidget);
-  NS_ENSURE_TRUE(*aOutWidget, nsRect());
+  NS_ENSURE_TRUE(*aOutWidget, nsIntRect());
 
   nsPresContext *presContext = presShell->GetPresContext();
-  NS_ENSURE_TRUE(presContext, nsRect());
+  NS_ENSURE_TRUE(presContext, nsIntRect());
 
-  caretRect.x = presContext->AppUnitsToDevPixels(caretRect.x + offsetFromWidget.x);
-  caretRect.y = presContext->AppUnitsToDevPixels(caretRect.y + offsetFromWidget.y);
-  caretRect.width = presContext->AppUnitsToDevPixels(caretRect.width);
-  caretRect.height = presContext->AppUnitsToDevPixels(caretRect.height);
+  rect += offsetFromWidget;
+  caretRect = nsRect::ToOutsidePixels(rect, presContext->AppUnitsPerDevPixel());
 
   (*aOutWidget)->WidgetToScreen(caretRect, caretRect);
 
   // Correct for character size, so that caret always matches the size of the character
   // This is important for font size transitions, and is necessary because the Gecko caret uses the
   // previous character's size as the user moves forward in the text by character.
   PRInt32 charX, charY, charWidth, charHeight;
   if (NS_SUCCEEDED(mLastTextAccessible->GetCharacterExtents(mLastCaretOffset, &charX, &charY,
--- a/accessible/src/base/nsCaretAccessible.h
+++ b/accessible/src/base/nsCaretAccessible.h
@@ -114,17 +114,17 @@ public:
    * If the document goes away, this method needs to be called for 
    * that document by the owner of the caret. We use presShell because
    * instead of document because it is more direct than getting it from
    * the document, and in any case it is unavailable from the doc after a pagehide.
    * @param aShell   PresShell for document to no longer listen to selection events from.
    */
   nsresult RemoveDocSelectionListener(nsIPresShell *aShell);
 
-  nsRect GetCaretRect(nsIWidget **aOutWidget);
+  nsIntRect GetCaretRect(nsIWidget **aOutWidget);
 
 protected:
   nsresult NormalSelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel);
   nsresult SpellcheckSelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel);
 
   already_AddRefed<nsISelectionController>
   GetSelectionControllerForNode(nsIDOMNode *aNode);
 
--- a/accessible/src/html/nsHTMLAreaAccessible.cpp
+++ b/accessible/src/html/nsHTMLAreaAccessible.cpp
@@ -144,17 +144,18 @@ nsHTMLAreaAccessible::GetBounds(PRInt32 
   nsIImageFrame *imageFrame;
   nsresult rv = frame->QueryInterface(NS_GET_IID(nsIImageFrame), (void**)&imageFrame);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIImageMap> map;
   imageFrame->GetImageMap(presContext, getter_AddRefs(map));
   NS_ENSURE_TRUE(map, NS_ERROR_FAILURE);
 
-  nsRect rect, orgRectPixels;
+  nsRect rect;
+  nsIntRect orgRectPixels;
   rv = map->GetBoundsForAreaContent(ourContent, presContext, rect);
   NS_ENSURE_SUCCESS(rv, rv);
 
   *x      = presContext->AppUnitsToDevPixels(rect.x); 
   *y      = presContext->AppUnitsToDevPixels(rect.y); 
 
   // XXX Areas are screwy; they return their rects as a pair of points, one pair
   // stored into the width and height.
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -296,23 +296,23 @@ nsIntRect nsHyperTextAccessible::GetBoun
     frame->GetOffsets(startFrameTextOffset, endFrameTextOffset);
     PRInt32 frameTotalTextLength = endFrameTextOffset - startFrameTextOffset;
     PRInt32 seekLength = endContentOffset - startContentOffset;
     PRInt32 frameSubStringLength = PR_MIN(frameTotalTextLength - startContentOffsetInFrame, seekLength);
 
     // Add the point where the string starts to the frameScreenRect
     nsPoint frameTextStartPoint;
     rv = frame->GetPointFromOffset(startContentOffset, &frameTextStartPoint);
-    NS_ENSURE_SUCCESS(rv, nsRect());   
+    NS_ENSURE_SUCCESS(rv, nsIntRect());   
     frameScreenRect.x += context->AppUnitsToDevPixels(frameTextStartPoint.x);
 
     // Use the point for the end offset to calculate the width
     nsPoint frameTextEndPoint;
     rv = frame->GetPointFromOffset(startContentOffset + frameSubStringLength, &frameTextEndPoint);
-    NS_ENSURE_SUCCESS(rv, nsRect());   
+    NS_ENSURE_SUCCESS(rv, nsIntRect());   
     frameScreenRect.width = context->AppUnitsToDevPixels(frameTextEndPoint.x - frameTextStartPoint.x);
 
     screenRect.UnionRect(frameScreenRect, screenRect);
 
     // Get ready to loop back for next frame continuation
     startContentOffset += frameSubStringLength;
     startContentOffsetInFrame = 0;
     frame = frame->GetNextContinuation();
@@ -1341,22 +1341,22 @@ nsHyperTextAccessible::GetOffsetAtPoint(
                                                   this, &coords);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // coords are currently screen coordinates, and we need to turn them into
   // frame coordinates relative to the current accessible
   if (!frameScreenRect.Contains(coords.x, coords.y)) {
     return NS_OK;   // Not found, will return -1
   }
-  nsPoint pointInHyperText(coords.x - frameScreenRect.x,
+  nsIntPoint pxInHyperText(coords.x - frameScreenRect.x,
                            coords.y - frameScreenRect.y);
   nsPresContext *context = GetPresContext();
   NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
-  pointInHyperText.x = context->DevPixelsToAppUnits(pointInHyperText.x);
-  pointInHyperText.y = context->DevPixelsToAppUnits(pointInHyperText.y);
+  nsPoint pointInHyperText(context->DevPixelsToAppUnits(pxInHyperText.x),
+                           context->DevPixelsToAppUnits(pxInHyperText.y));
 
   // Go through the frames to check if each one has the point.
   // When one does, add up the character offsets until we have a match
 
   // We have an point in an accessible child of this, now we need to add up the
   // offsets before it to what we already have
   nsCOMPtr<nsIAccessible> accessible;
   PRInt32 offset = 0;
--- a/content/base/src/nsImageLoadingContent.cpp
+++ b/content/base/src/nsImageLoadingContent.cpp
@@ -153,17 +153,17 @@ nsImageLoadingContent::~nsImageLoadingCo
 
 
 /*
  * imgIContainerObserver impl
  */
 NS_IMETHODIMP
 nsImageLoadingContent::FrameChanged(imgIContainer* aContainer,
                                     gfxIImageFrame* aFrame,
-                                    nsRect* aDirtyRect)
+                                    nsIntRect* aDirtyRect)
 {
   LOOP_OVER_OBSERVERS(FrameChanged(aContainer, aFrame, aDirtyRect));
   return NS_OK;
 }
             
 /*
  * imgIDecoderObserver impl
  */
@@ -199,17 +199,17 @@ nsImageLoadingContent::OnStartFrame(imgI
 {
   LOOP_OVER_OBSERVERS(OnStartFrame(aRequest, aFrame));
   return NS_OK;    
 }
 
 NS_IMETHODIMP
 nsImageLoadingContent::OnDataAvailable(imgIRequest* aRequest,
                                        gfxIImageFrame* aFrame,
-                                       const nsRect* aRect)
+                                       const nsIntRect* aRect)
 {
   LOOP_OVER_OBSERVERS(OnDataAvailable(aRequest, aFrame, aRect));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsImageLoadingContent::OnStopFrame(imgIRequest* aRequest,
                                    gfxIImageFrame* aFrame)
--- a/content/events/src/nsDOMUIEvent.cpp
+++ b/content/events/src/nsDOMUIEvent.cpp
@@ -116,59 +116,63 @@ NS_IMPL_RELEASE_INHERITED(nsDOMUIEvent, 
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMUIEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMUIEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMNSUIEvent)
   NS_INTERFACE_MAP_ENTRY(nsIPrivateCompositionEvent)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(UIEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
-nsPoint nsDOMUIEvent::GetScreenPoint() {
+nsIntPoint
+nsDOMUIEvent::GetScreenPoint()
+{
   if (!mEvent || 
        (mEvent->eventStructType != NS_MOUSE_EVENT &&
         mEvent->eventStructType != NS_POPUP_EVENT &&
         mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
         mEvent->eventStructType != NS_DRAG_EVENT)) {
-    return nsPoint(0, 0);
+    return nsIntPoint(0, 0);
   }
 
   if (!((nsGUIEvent*)mEvent)->widget ) {
     return mEvent->refPoint;
   }
 
-  nsRect bounds(mEvent->refPoint, nsSize(1, 1));
-  nsRect offset;
+  nsIntRect bounds(mEvent->refPoint, nsIntSize(1, 1));
+  nsIntRect offset;
   ((nsGUIEvent*)mEvent)->widget->WidgetToScreen ( bounds, offset );
-  PRInt32 factor = mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
-  return nsPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
-                 nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
+  nscoord factor = mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
+  return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
+                    nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
 }
 
-nsPoint nsDOMUIEvent::GetClientPoint() {
+nsIntPoint
+nsDOMUIEvent::GetClientPoint()
+{
   if (!mEvent ||
       (mEvent->eventStructType != NS_MOUSE_EVENT &&
        mEvent->eventStructType != NS_POPUP_EVENT &&
        mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
        mEvent->eventStructType != NS_DRAG_EVENT) ||
       !mPresContext ||
       !((nsGUIEvent*)mEvent)->widget) {
     return mClientPoint;
   }
 
   nsPoint pt(0, 0);
   nsIPresShell* shell = mPresContext->GetPresShell();
   if (!shell) {
-    return pt;
+    return nsIntPoint(0, 0);
   }
   nsIFrame* rootFrame = shell->GetRootFrame();
   if (rootFrame)
     pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, rootFrame);
 
-  return nsPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
-                 nsPresContext::AppUnitsToIntCSSPixels(pt.y));
+  return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
+                    nsPresContext::AppUnitsToIntCSSPixels(pt.y));
 }
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetView(nsIDOMAbstractView** aView)
 {
   *aView = mView;
   NS_IF_ADDREF(*aView);
   return NS_OK;
@@ -189,33 +193,33 @@ nsDOMUIEvent::InitUIEvent(const nsAStrin
   
   mDetail = detailArg;
   mView = viewArg;
 
   return NS_OK;
 }
 
 // ---- nsDOMNSUIEvent implementation -------------------
-nsPoint
+nsIntPoint
 nsDOMUIEvent::GetPagePoint()
 {
   if (mPrivateDataDuplicated) {
     return mPagePoint;
   }
 
-  nsPoint pagePoint = GetClientPoint();
+  nsIntPoint pagePoint(GetClientPoint());
 
   // If there is some scrolling, add scroll info to client point.
   if (mPresContext && mPresContext->GetPresShell()) {
     nsIPresShell* shell = mPresContext->GetPresShell();
     nsIScrollableFrame* scrollframe = shell->GetRootScrollFrameAsScrollable();
     if (scrollframe) {
       nsPoint pt = scrollframe->GetScrollPosition();
-      pagePoint += nsPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
-                           nsPresContext::AppUnitsToIntCSSPixels(pt.y));
+      pagePoint += nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
+                              nsPresContext::AppUnitsToIntCSSPixels(pt.y));
     }
   }
 
   return pagePoint;
 }
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetPageX(PRInt32* aPageX)
@@ -301,36 +305,37 @@ nsDOMUIEvent::SetCancelBubble(PRBool aCa
   if (aCancelBubble) {
     mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;
   } else {
     mEvent->flags &= ~NS_EVENT_FLAG_STOP_DISPATCH;
   }
   return NS_OK;
 }
 
-nsPoint nsDOMUIEvent::GetLayerPoint() {
+nsIntPoint
+nsDOMUIEvent::GetLayerPoint()
+{
   if (!mEvent ||
       (mEvent->eventStructType != NS_MOUSE_EVENT &&
        mEvent->eventStructType != NS_POPUP_EVENT &&
        mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
        mEvent->eventStructType != NS_DRAG_EVENT) ||
       !mPresContext ||
       mEventIsInternal) {
     return mLayerPoint;
   }
   // XXX I'm not really sure this is correct; it's my best shot, though
   nsIFrame* targetFrame;
   mPresContext->EventStateManager()->GetEventTarget(&targetFrame);
   if (!targetFrame)
     return mLayerPoint;
   nsIFrame* layer = nsLayoutUtils::GetClosestLayer(targetFrame);
   nsPoint pt(nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, layer));
-  pt.x =  nsPresContext::AppUnitsToIntCSSPixels(pt.x);
-  pt.y =  nsPresContext::AppUnitsToIntCSSPixels(pt.y);
-  return pt;
+  return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
+                    nsPresContext::AppUnitsToIntCSSPixels(pt.y));
 }
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetLayerX(PRInt32* aLayerX)
 {
   NS_ENSURE_ARG_POINTER(aLayerX);
   *aLayerX = GetLayerPoint().x;
   return NS_OK;
@@ -384,17 +389,17 @@ NS_METHOD nsDOMUIEvent::GetCompositionRe
 
 NS_METHOD
 nsDOMUIEvent::DuplicatePrivateData()
 {
   mClientPoint = GetClientPoint();
   mLayerPoint = GetLayerPoint();
   mPagePoint = GetPagePoint();
   // GetScreenPoint converts mEvent->refPoint to right coordinates.
-  nsPoint screenPoint = GetScreenPoint();
+  nsIntPoint screenPoint(GetScreenPoint());
   nsresult rv = nsDOMEvent::DuplicatePrivateData();
   if (NS_SUCCEEDED(rv)) {
     mEvent->refPoint = screenPoint;
   }
   return rv;
 }
 
 nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult,
--- a/content/events/src/nsDOMUIEvent.h
+++ b/content/events/src/nsDOMUIEvent.h
@@ -69,27 +69,27 @@ public:
   NS_IMETHOD GetCompositionReply(nsTextEventReply** aReply);
   
   // Forward to nsDOMEvent
   NS_FORWARD_TO_NSDOMEVENT
 
 protected:
 
   // Internal helper functions
-  nsPoint GetClientPoint();
-  nsPoint GetScreenPoint();
-  nsPoint GetLayerPoint();
-  nsPoint GetPagePoint();
+  nsIntPoint GetClientPoint();
+  nsIntPoint GetScreenPoint();
+  nsIntPoint GetLayerPoint();
+  nsIntPoint GetPagePoint();
   
 protected:
   nsCOMPtr<nsIDOMAbstractView> mView;
   PRInt32 mDetail;
-  nsPoint mClientPoint;
+  nsIntPoint mClientPoint;
   // Screenpoint is mEvent->refPoint.
-  nsPoint mLayerPoint;
-  nsPoint mPagePoint;
+  nsIntPoint mLayerPoint;
+  nsIntPoint mPagePoint;
 };
 
 #define NS_FORWARD_TO_NSDOMUIEVENT \
   NS_FORWARD_NSIDOMUIEVENT(nsDOMUIEvent::) \
   NS_FORWARD_TO_NSDOMEVENT
 
 #endif // nsDOMUIEvent_h__
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -1375,17 +1375,17 @@ nsEventListenerManager::FixContextMenuEv
       aEvent->refPoint.y = 0;
     }
     ret = NS_NewDOMMouseEvent(aDOMEvent, aPresContext, static_cast<nsInputEvent*>(aEvent));
     NS_ENSURE_SUCCESS(ret, ret);
   }
 
   // see if we should use the caret position for the popup
   if (contextMenuKey) {
-    nsPoint caretPoint;
+    nsIntPoint caretPoint;
     // Beware! This may flush notifications via synchronous
     // ScrollSelectionIntoView.
     if (PrepareToUseCaretPosition(((nsGUIEvent*)aEvent)->widget,
                                   shell, caretPoint)) {
       // caret position is good
       aEvent->refPoint.x = caretPoint.x;
       aEvent->refPoint.y = caretPoint.y;
       return NS_OK;
@@ -1408,17 +1408,17 @@ nsEventListenerManager::FixContextMenuEv
         if (focusController)
           focusController->GetFocusedElement(getter_AddRefs(currentFocus));
       }
     }
   }
 
   if (currentFocus) {
     // Reset event coordinates relative to focused frame in view
-    nsPoint targetPt;
+    nsIntPoint targetPt;
     GetCoordinatesFor(currentFocus, aPresContext, shell, targetPt);
     aEvent->refPoint.x = targetPt.x;
     aEvent->refPoint.y = targetPt.y;
 
     currentTarget = do_QueryInterface(currentFocus);
     nsCOMPtr<nsIPrivateDOMEvent> pEvent(do_QueryInterface(*aDOMEvent));
     pEvent->SetTarget(currentTarget);
   }
@@ -1436,17 +1436,17 @@ nsEventListenerManager::FixContextMenuEv
 //    The event widget should be the widget that generated the event, and
 //    whose coordinate system the resulting event's refPoint should be
 //    relative to.  The returned point is in device pixels realtive to the
 //    widget passed in.
 
 PRBool
 nsEventListenerManager::PrepareToUseCaretPosition(nsIWidget* aEventWidget,
                                                   nsIPresShell* aShell,
-                                                  nsPoint& aTargetPt)
+                                                  nsIntPoint& aTargetPt)
 {
   nsresult rv;
 
   // check caret visibility
   nsRefPtr<nsCaret> caret;
   rv = aShell->GetCaret(getter_AddRefs(caret));
   NS_ENSURE_SUCCESS(rv, PR_FALSE);
   NS_ENSURE_TRUE(caret, PR_FALSE);
@@ -1529,31 +1529,31 @@ nsEventListenerManager::PrepareToUseCare
   // in case the view used for caret coordinates was something else, we need
   // to bring those coordinates into the space of the widget view
   nsIView* widgetView = nsIView::GetViewFor(aEventWidget);
   NS_ENSURE_TRUE(widgetView, PR_FALSE);
   nsPoint viewToWidget;
   widgetView->GetNearestWidget(&viewToWidget);
   nsPoint viewDelta = view->GetOffsetTo(widgetView) + viewToWidget;
 
-  // caret coordinates are in twips, convert to pixels
+  // caret coordinates are in app units, convert to pixels
   nsPresContext* presContext = aShell->GetPresContext();
   aTargetPt.x = presContext->AppUnitsToDevPixels(viewDelta.x + caretCoords.x + caretCoords.width);
   aTargetPt.y = presContext->AppUnitsToDevPixels(viewDelta.y + caretCoords.y + caretCoords.height);
 
   return PR_TRUE;
 }
 
 // Get coordinates in device pixels relative to root view for element, 
 // first ensuring the element is onscreen
 void
 nsEventListenerManager::GetCoordinatesFor(nsIDOMElement *aCurrentEl, 
                                           nsPresContext *aPresContext,
                                           nsIPresShell *aPresShell, 
-                                          nsPoint& aTargetPt)
+                                          nsIntPoint& aTargetPt)
 {
   nsCOMPtr<nsIContent> focusedContent(do_QueryInterface(aCurrentEl));
   aPresShell->ScrollContentIntoView(focusedContent,
                                     NS_PRESSHELL_SCROLL_ANYWHERE,
                                     NS_PRESSHELL_SCROLL_ANYWHERE);
 
   PRBool istree = PR_FALSE, checkLineHeight = PR_TRUE;
   PRInt32 extraPixelsY = 0, extraTreeY = 0;
--- a/content/events/src/nsEventListenerManager.h
+++ b/content/events/src/nsEventListenerManager.h
@@ -176,19 +176,19 @@ protected:
   const EventTypeData* GetTypeDataForIID(const nsIID& aIID);
   const EventTypeData* GetTypeDataForEventName(nsIAtom* aName);
   nsresult FixContextMenuEvent(nsPresContext* aPresContext,
                                nsISupports* aCurrentTarget,
                                nsEvent* aEvent,
                                nsIDOMEvent** aDOMEvent);
   PRBool PrepareToUseCaretPosition(nsIWidget* aEventWidget,
                                    nsIPresShell* aShell,
-                                   nsPoint& aTargetPt);
+                                   nsIntPoint& aTargetPt);
   void GetCoordinatesFor(nsIDOMElement *aCurrentEl, nsPresContext *aPresContext,
-                         nsIPresShell *aPresShell, nsPoint& aTargetPt);
+                         nsIPresShell *aPresShell, nsIntPoint& aTargetPt);
   nsresult GetDOM2EventGroup(nsIDOMEventGroup** aGroup);
   PRBool ListenerCanHandle(nsListenerStruct* aLs, nsEvent* aEvent);
 
   nsAutoTObserverArray<nsListenerStruct, 2> mListeners;
   nsISupports*                              mTarget;  //WEAK
   PRUint32                                  mMayHaveMutationListeners : 1;
   // These two member variables are used to cache the information
   // about the last event which was handled but for which event listener manager
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -308,17 +308,17 @@ class nsMouseWheelTransaction {
 public:
   static nsIFrame* GetTargetFrame() { return sTargetFrame; }
   static void BeginTransaction(nsIFrame* aTargetFrame,
                                nsGUIEvent* aEvent);
   static void UpdateTransaction();
   static void EndTransaction();
   static void OnEvent(nsEvent* aEvent);
 protected:
-  static nsPoint GetScreenPoint(nsGUIEvent* aEvent);
+  static nsIntPoint GetScreenPoint(nsGUIEvent* aEvent);
   static PRUint32 GetTimeoutTime();
   static PRUint32 GetIgnoreMoveDelayTime();
 
   static nsWeakFrame sTargetFrame;
   static PRUint32    sTime;        // in milliseconds
   static PRUint32    sMouseMoved;  // in milliseconds
 };
 
@@ -380,17 +380,17 @@ nsMouseWheelTransaction::OnEvent(nsEvent
         EndTransaction();
       }
       return;
     case NS_MOUSE_MOVE:
     case NS_DRAGDROP_OVER:
       if (((nsMouseEvent*)aEvent)->reason == nsMouseEvent::eReal) {
         // If the cursor is moving to be outside the frame,
         // terminate the scrollwheel transaction.
-        nsPoint pt = GetScreenPoint((nsGUIEvent*)aEvent);
+        nsIntPoint pt(GetScreenPoint((nsGUIEvent*)aEvent));
         nsIntRect r = sTargetFrame->GetScreenRectExternal();
         if (!r.Contains(pt)) {
           EndTransaction();
           return;
         }
 
         // If the cursor is moving inside the frame, and it is less than
         // ignoremovedelay milliseconds since the last scroll operation, ignore
@@ -411,23 +411,23 @@ nsMouseWheelTransaction::OnEvent(nsEvent
     case NS_MOUSE_CLICK:
     case NS_CONTEXTMENU:
     case NS_DRAGDROP_DROP:
       EndTransaction();
       return;
   }
 }
 
-nsPoint
+nsIntPoint
 nsMouseWheelTransaction::GetScreenPoint(nsGUIEvent* aEvent)
 {
   NS_ASSERTION(aEvent, "aEvent is null");
   NS_ASSERTION(aEvent->widget, "aEvent-widget is null");
-  nsRect tmpRect;
-  aEvent->widget->WidgetToScreen(nsRect(aEvent->refPoint, nsSize(1, 1)),
+  nsIntRect tmpRect;
+  aEvent->widget->WidgetToScreen(nsIntRect(aEvent->refPoint, nsIntSize(1, 1)),
                                  tmpRect);
   return tmpRect.TopLeft();
 }
 
 PRUint32
 nsMouseWheelTransaction::GetTimeoutTime()
 {
   return (PRUint32)
@@ -1880,18 +1880,18 @@ nsEventStateManager::FireContextClick()
 //
 void
 nsEventStateManager::BeginTrackingDragGesture(nsPresContext* aPresContext,
                                               nsMouseEvent* inDownEvent,
                                               nsIFrame* inDownFrame)
 {
   // Note that |inDownEvent| could be either a mouse down event or a
   // synthesized mouse move event.
-  nsRect screenPt;
-  inDownEvent->widget->WidgetToScreen(nsRect(inDownEvent->refPoint, nsSize(1, 1)),
+  nsIntRect screenPt;
+  inDownEvent->widget->WidgetToScreen(nsIntRect(inDownEvent->refPoint, nsIntSize(1, 1)),
                                       screenPt);
   mGestureDownPoint = screenPt.TopLeft();
 
   inDownFrame->GetContentForEvent(aPresContext, inDownEvent,
                                   getter_AddRefs(mGestureDownContent));
 
   mGestureDownFrameOwner = inDownFrame->GetContent();
   mGestureDownShift = inDownEvent->isShift;
@@ -1924,17 +1924,17 @@ void
 nsEventStateManager::FillInEventFromGestureDown(nsMouseEvent* aEvent)
 {
   NS_ASSERTION(aEvent->widget == mCurrentTarget->GetWindow(),
                "Incorrect widget in event");
 
   // Set the coordinates in the new event to the coordinates of
   // the old event, adjusted for the fact that the widget might be
   // different
-  nsRect tmpRect(0, 0, 1, 1);
+  nsIntRect tmpRect(0, 0, 1, 1);
   aEvent->widget->WidgetToScreen(tmpRect, tmpRect);
   aEvent->refPoint = mGestureDownPoint - tmpRect.TopLeft();
   aEvent->isShift = mGestureDownShift;
   aEvent->isControl = mGestureDownControl;
   aEvent->isAlt = mGestureDownAlt;
   aEvent->isMeta = mGestureDownMeta;
 }
 
@@ -1985,20 +1985,20 @@ nsEventStateManager::GenerateDragGesture
       lf->GetMetric(nsILookAndFeel::eMetric_DragThresholdY, pixelThresholdY);
       if (!pixelThresholdX)
         pixelThresholdX = 5;
       if (!pixelThresholdY)
         pixelThresholdY = 5;
     }
 
     // fire drag gesture if mouse has moved enough
-    nsRect tmpRect;
-    aEvent->widget->WidgetToScreen(nsRect(aEvent->refPoint, nsSize(1, 1)),
+    nsIntRect tmpRect;
+    aEvent->widget->WidgetToScreen(nsIntRect(aEvent->refPoint, nsIntSize(1, 1)),
                                    tmpRect);
-    nsPoint pt = tmpRect.TopLeft();
+    nsIntPoint pt(tmpRect.TopLeft());
     if (PR_ABS(pt.x - mGestureDownPoint.x) > pixelThresholdX ||
         PR_ABS(pt.y - mGestureDownPoint.y) > pixelThresholdY) {
 #ifdef CLICK_HOLD_CONTEXT_MENUS
       // stop the click-hold before we fire off the drag gesture, in case
       // it takes a long time
       KillClickHoldTimer();
 #endif
 
--- a/content/events/src/nsEventStateManager.h
+++ b/content/events/src/nsEventStateManager.h
@@ -380,17 +380,17 @@ protected:
 
   nsWeakFrame mCurrentTarget;
   nsCOMPtr<nsIContent> mCurrentTargetContent;
   nsWeakFrame mLastMouseOverFrame;
   nsCOMPtr<nsIContent> mLastMouseOverElement;
   nsWeakFrame mLastDragOverFrame;
 
   // member variables for the d&d gesture state machine
-  nsPoint mGestureDownPoint; // screen coordinates
+  nsIntPoint mGestureDownPoint; // screen coordinates
   // The content to use as target if we start a d&d (what we drag).
   nsCOMPtr<nsIContent> mGestureDownContent;
   // The content of the frame where the mouse-down event occurred. It's the same
   // as the target in most cases but not always - for example when dragging
   // an <area> of an image map this is the image. (bug 289667)
   nsCOMPtr<nsIContent> mGestureDownFrameOwner;
   // State of keys when the original gesture-down happened
   PRPackedBool mGestureDownShift;
--- a/content/events/src/nsQueryContentEventHandler.cpp
+++ b/content/events/src/nsQueryContentEventHandler.cpp
@@ -432,35 +432,35 @@ nsQueryContentEventHandler::QueryRectFor
   nsIFrame* frame;
   nsresult rv = GetStartFrameAndOffset(aRange, &frame, &offsetInFrame);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsPoint posInFrame;
   rv = frame->GetPointFromOffset(aRange->StartOffset(), &posInFrame);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  aEvent->mReply.mRect.y = posInFrame.y;
-  aEvent->mReply.mRect.height = frame->GetSize().height;
+  nsRect rect;
+  rect.y = posInFrame.y;
+  rect.height = frame->GetSize().height;
 
   if (aEvent->message == NS_QUERY_CHARACTER_RECT) {
     nsPoint nextPos;
     rv = frame->GetPointFromOffset(aRange->EndOffset(), &nextPos);
     NS_ENSURE_SUCCESS(rv, rv);
-    aEvent->mReply.mRect.x = PR_MIN(posInFrame.x, nextPos.x);
-    aEvent->mReply.mRect.width = PR_ABS(posInFrame.x - nextPos.x);
+    rect.x = PR_MIN(posInFrame.x, nextPos.x);
+    rect.width = PR_ABS(posInFrame.x - nextPos.x);
   } else {
-    aEvent->mReply.mRect.x = posInFrame.x;
-    aEvent->mReply.mRect.width = aCaret->GetCaretRect().width;
+    rect.x = posInFrame.x;
+    rect.width = aCaret->GetCaretRect().width;
   }
 
-  // The coordinates are app units here, they will be converted to system
-  // coordinates by view manager.
-  rv = ConvertToRootViewRelativeOffset(frame, aEvent->mReply.mRect);
+  rv = ConvertToRootViewRelativeOffset(frame, rect);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  aEvent->mReply.mRect = nsRect::ToOutsidePixels(rect, mPresContext->AppUnitsPerDevPixel());
   aEvent->mSucceeded = PR_TRUE;
   return NS_OK;
 }
 
 nsresult
 nsQueryContentEventHandler::OnQueryCharacterRect(nsQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
@@ -499,19 +499,21 @@ nsQueryContentEventHandler::OnQueryCaret
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (selectionIsCollapsed) {
     PRUint32 offset;
     rv = GetFlatTextOffsetOfRange(mFirstSelectedRange, &offset);
     NS_ENSURE_SUCCESS(rv, rv);
     if (offset == aEvent->mInput.mOffset) {
       PRBool isCollapsed;
+      nsRect rect;
       rv = caret->GetCaretCoordinates(nsCaret::eTopLevelWindowCoordinates,
-                                      mSelection, &aEvent->mReply.mRect,
+                                      mSelection, &rect,
                                       &isCollapsed, nsnull);
+      aEvent->mReply.mRect = nsRect::ToOutsidePixels(rect, mPresContext->AppUnitsPerDevPixel());
       NS_ENSURE_SUCCESS(rv, rv);
       aEvent->mSucceeded = PR_TRUE;
       return NS_OK;
     }
   }
 
   // Otherwise, we should set the guessed caret rect.
   nsCOMPtr<nsIRange> range = new nsRange();
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -5490,17 +5490,17 @@ nsDocShell::CaptureState()
     if (shell) {
         nsIViewManager *vm = shell->GetViewManager();
         if (vm) {
             nsIView *rootView = nsnull;
             vm->GetRootView(rootView);
             if (rootView) {
                 nsIWidget *widget = rootView->GetWidget();
                 if (widget) {
-                    nsRect bounds(0, 0, 0, 0);
+                    nsIntRect bounds(0, 0, 0, 0);
                     widget->GetBounds(bounds);
                     rv = mOSHE->SetViewerBounds(bounds);
                 }
             }
         }
     }
 
     // Capture the docshell hierarchy.
@@ -5815,17 +5815,17 @@ nsDocShell::RestoreFromHistory()
         }
     }
 
     // Save off the root view's parent and sibling so that we can insert the
     // new content viewer's root view at the same position.  Also save the
     // bounds of the root view's widget.
 
     nsIView *rootViewSibling = nsnull, *rootViewParent = nsnull;
-    nsRect newBounds(0, 0, 0, 0);
+    nsIntRect newBounds(0, 0, 0, 0);
 
     nsCOMPtr<nsIPresShell> oldPresShell;
     nsDocShell::GetPresShell(getter_AddRefs(oldPresShell));
     if (oldPresShell) {
         nsIViewManager *vm = oldPresShell->GetViewManager();
         if (vm) {
             nsIView *oldRootView = nsnull;
             vm->GetRootView(oldRootView);
@@ -5871,17 +5871,17 @@ nsDocShell::RestoreFromHistory()
     PRInt32 i = 0;
     nsCOMPtr<nsIDocShellTreeItem> child;
     while (NS_SUCCEEDED(mLSHE->ChildShellAt(i++, getter_AddRefs(child))) &&
            child) {
         childShells.AppendObject(child);
     }
 
     // get the previous content viewer size
-    nsRect oldBounds(0, 0, 0, 0);
+    nsIntRect oldBounds(0, 0, 0, 0);
     mLSHE->GetViewerBounds(oldBounds);
 
     // Restore the refresh URI list.  The refresh timers will be restarted
     // when EndPageLoad() is called.
     nsCOMPtr<nsISupportsArray> refreshURIList;
     mLSHE->GetRefreshURIList(getter_AddRefs(refreshURIList));
 
     // Reattach to the window object.
@@ -6445,17 +6445,17 @@ nsDocShell::SetupNewViewer(nsIContentVie
         mContentViewer = nsnull;
     }
 
     mContentViewer = aNewViewer;
 
     nsCOMPtr<nsIWidget> widget;
     NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(widget)), NS_ERROR_FAILURE);
 
-    nsRect bounds(x, y, cx, cy);
+    nsIntRect bounds(x, y, cx, cy);
 
     if (NS_FAILED(mContentViewer->Init(widget, bounds))) {
         mContentViewer = nsnull;
         NS_ERROR("ContentViewer Initialization failed");
         return NS_ERROR_FAILURE;
     }
 
     // If we have old state to copy, set the old state onto the new content
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -615,30 +615,30 @@ protected:
     /**
      * Content-Type Hint of the most-recently initiated load. Used for
      * session history entries.
      */
     nsCString                  mContentTypeHint;
     nsCOMPtr<nsISupportsArray> mRefreshURIList;
     nsCOMPtr<nsISupportsArray> mSavedRefreshURIList;
     nsRefPtr<nsDSURIContentListener> mContentListener;
-    nsRect                     mBounds; // Dimensions of the docshell
+    nsIntRect                  mBounds; // Dimensions of the docshell
     nsCOMPtr<nsIContentViewer> mContentViewer;
     nsCOMPtr<nsIDocumentCharsetInfo> mDocumentCharsetInfo;
     nsCOMPtr<nsIWidget>        mParentWidget;
     nsCOMPtr<nsIPrefBranch>    mPrefs;
 
     // mCurrentURI should be marked immutable on set if possible.
     nsCOMPtr<nsIURI>           mCurrentURI;
     nsCOMPtr<nsIURI>           mReferrerURI;
     nsCOMPtr<nsIScriptGlobalObject> mScriptGlobal;
     nsCOMPtr<nsISHistory>      mSessionHistory;
     nsCOMPtr<nsIGlobalHistory2> mGlobalHistory;
     nsCOMPtr<nsIWebBrowserFind> mFind;
-    nsPoint                    mDefaultScrollbarPref; // persistent across doc loads
+    nsIntPoint                 mDefaultScrollbarPref; // persistent across doc loads
     // Reference to the SHEntry for this docshell until the page is destroyed.
     // Somebody give me better name
     nsCOMPtr<nsISHEntry>       mOSHE; 
     // Reference to the SHEntry for this docshell until the page is loaded
     // Somebody give me better name
     nsCOMPtr<nsISHEntry>       mLSHE;
 
     // Holds a weak pointer to a RestorePresentationEvent object if any that
--- a/docshell/base/nsIContentViewer.idl
+++ b/docshell/base/nsIContentViewer.idl
@@ -2,28 +2,28 @@
 
 interface nsIDOMDocument;
 interface nsISHEntry;
 interface nsIPrintSettings;
 
 
 %{ C++
 class nsIWidget;
-struct nsRect;
+struct nsIntRect;
 %}
 
 [ptr] native nsIWidgetPtr(nsIWidget);
-[ref] native nsRectRef(nsRect);
+[ref] native nsIntRectRef(nsIntRect);
 
-[scriptable, uuid(05b290ac-d880-4900-bb1f-2211b5f8accc)]
+[scriptable, uuid(c9aba5da-7d8b-46a8-87cd-9ab7e16480b8)]
 interface nsIContentViewer : nsISupports
 {
 
   [noscript] void init(in nsIWidgetPtr aParentWidget,
-                       [const] in nsRectRef aBounds);
+                       [const] in nsIntRectRef aBounds);
 
   attribute nsISupports container;
 
   void loadStart(in nsISupports aDoc);
   void loadComplete(in unsigned long aStatus);
   boolean permitUnload();
   void pageHide(in boolean isUnload);
 
@@ -50,18 +50,18 @@ interface nsIContentViewer : nsISupports
    */
   void close(in nsISHEntry historyEntry);
   void destroy();
 
   void stop();
 
   attribute nsIDOMDocument DOMDocument;
 
-  [noscript] void getBounds(in nsRectRef aBounds);
-  [noscript] void setBounds([const] in nsRectRef aBounds);
+  [noscript] void getBounds(in nsIntRectRef aBounds);
+  [noscript] void setBounds([const] in nsIntRectRef aBounds);
 
   /**
    * The previous content viewer, which has been |close|d but not
    * |destroy|ed.
    */
   [noscript] attribute nsIContentViewer previousViewer;
 
   void move(in long aX, in long aY);
--- a/docshell/shistory/public/nsISHEntry.idl
+++ b/docshell/shistory/public/nsISHEntry.idl
@@ -46,24 +46,24 @@
 
 interface nsILayoutHistoryState;
 interface nsIContentViewer;
 interface nsIURI;
 interface nsIInputStream;
 interface nsIDocShellTreeItem;
 interface nsISupportsArray;
 %{C++
-struct nsRect;
+struct nsIntRect;
 class nsDocShellEditorData;
 %}
-[ref] native nsRect(nsRect);
+[ref] native nsIntRect(nsIntRect);
 [ptr] native nsDocShellEditorDataPtr(nsDocShellEditorData);
 
 
-[scriptable, uuid(c16fde76-3108-450e-8c8c-ae8286f286ed)]
+[scriptable, uuid(09fecea6-5453-43ba-bf91-3ff32618f037)]
 interface nsISHEntry : nsIHistoryEntry
 {
     /** URI for the document */
     void setURI(in nsIURI aURI);
 
     /** Referrer URI */
     attribute nsIURI referrerURI;
 
@@ -76,18 +76,18 @@ interface nsISHEntry : nsIHistoryEntry
     /** Saved state of the global window object */
     attribute nsISupports windowState;
 
     /**
      * Saved position and dimensions of the content viewer; we must adjust the
      * root view's widget accordingly if this has changed when the presentation
      * is restored.
      */
-    [noscript] void getViewerBounds(in nsRect bounds);
-    [noscript] void setViewerBounds([const] in nsRect bounds);
+    [noscript] void getViewerBounds(in nsIntRect bounds);
+    [noscript] void setViewerBounds([const] in nsIntRect bounds);
 
     /**
      * Saved child docshells corresponding to contentViewer.  The child shells
      * are restored as children of the parent docshell, in this order, when the
      * parent docshell restores a saved presentation.
      */
 
     /** Append a child shell to the end of our list. */
--- a/docshell/shistory/src/nsSHEntry.cpp
+++ b/docshell/shistory/src/nsSHEntry.cpp
@@ -531,24 +531,24 @@ nsSHEntry::SetWindowState(nsISupports *a
 NS_IMETHODIMP
 nsSHEntry::GetWindowState(nsISupports **aState)
 {
   NS_IF_ADDREF(*aState = mWindowState);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::SetViewerBounds(const nsRect &aBounds)
+nsSHEntry::SetViewerBounds(const nsIntRect &aBounds)
 {
   mViewerBounds = aBounds;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetViewerBounds(nsRect &aBounds)
+nsSHEntry::GetViewerBounds(nsIntRect &aBounds)
 {
   aBounds = mViewerBounds;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHEntry::GetOwner(nsISupports **aOwner)
 {
--- a/docshell/shistory/src/nsSHEntry.h
+++ b/docshell/shistory/src/nsSHEntry.h
@@ -105,17 +105,17 @@ private:
   PRPackedBool                    mIsFrameNavigation;
   PRPackedBool                    mSaveLayoutState;
   PRPackedBool                    mExpired;
   PRPackedBool                    mSticky;
   nsCString                       mContentType;
   nsCOMPtr<nsISupports>           mCacheKey;
   nsISHEntry *                    mParent;  // weak reference
   nsCOMPtr<nsISupports>           mWindowState;
-  nsRect                          mViewerBounds;
+  nsIntRect                       mViewerBounds;
   nsCOMArray<nsIDocShellTreeItem> mChildShells;
   nsCOMPtr<nsISupportsArray>      mRefreshURIList;
   nsCOMPtr<nsISupports>           mOwner;
   nsExpirationState               mExpirationState;
   nsAutoPtr<nsDocShellEditorData> mEditorData;
 };
 
 #endif /* nsSHEntry_h */
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -1978,28 +1978,33 @@ nsEditor::QueryComposition(nsTextEventRe
         if (restoreFlags)
           SetFlags(flags);
       }
 
 
       // XXX_kin: END HACK! HACK! HACK!
 
       nsIView *view = nsnull;
+      nsRect rect;
       result =
         caretP->GetCaretCoordinates(nsCaret::eRenderingViewCoordinates,
                                     selection,
-                                    &(aReply->mCursorPosition),
+                                    &rect,
                                     &(aReply->mCursorIsCollapsed),
                                     &view);
+      aReply->mCursorPosition =
+        nsRect::ToOutsidePixels(rect,
+                                ps->GetPresContext()->AppUnitsPerDevPixel());
       if (NS_SUCCEEDED(result) && view)
         aReply->mReferenceWidget = view->GetWidget();
     }
   }
   return result;
 }
+
 NS_IMETHODIMP
 nsEditor::BeginComposition(nsTextEventReply* aReply)
 {
 #ifdef DEBUG_tague
   printf("nsEditor::StartComposition\n");
 #endif
   nsresult ret = QueryComposition(aReply);
   mInIMEMode = PR_TRUE;
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -1732,21 +1732,25 @@ nsPlaintextEditor::SetCompositionString(
       SetFlags(flags);
 
     // XXX_kin: END HACK! HACK! HACK!
   }
 
   if (caretP)
   {
     nsIView *view = nsnull;
+    nsRect rect;
     result = caretP->GetCaretCoordinates(nsCaret::eRenderingViewCoordinates,
                                          selection,
-                                         &(aReply->mCursorPosition),
+                                         &rect,
                                          &(aReply->mCursorIsCollapsed),
                                          &view);
+    aReply->mCursorPosition =
+       nsRect::ToOutsidePixels(rect, 
+                               ps->GetPresContext()->AppUnitsPerDevPixel());
     NS_ASSERTION(NS_SUCCEEDED(result), "cannot get caret position");
     if (NS_SUCCEEDED(result) && view)
       aReply->mReferenceWidget = view->GetWidget();
   }
 
   return result;
 }
 
--- a/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp
+++ b/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp
@@ -89,17 +89,17 @@ EmbedContextMenuInfo::EmbedContextMenuIn
 {
   mOwner = aOwner;
   mEventNode = nsnull;
   mCtxDocument = nsnull;
   mNSHHTMLElement = nsnull;
   mNSHHTMLElementSc = nsnull;
   mCtxEvent = nsnull;
   mEventNode = nsnull;
-  mFormRect = nsRect(0,0,0,0);
+  mFormRect = nsIntRect(0,0,0,0);
 }
 
 EmbedContextMenuInfo::~EmbedContextMenuInfo(void)
 {
   mEventNode = nsnull;
   mCtxDocument = nsnull;
   mNSHHTMLElement = nsnull;
   mNSHHTMLElementSc = nsnull;
--- a/embedding/browser/gtk/src/EmbedContextMenuInfo.h
+++ b/embedding/browser/gtk/src/EmbedContextMenuInfo.h
@@ -79,17 +79,17 @@ public:
 
   PRInt32                 mX, mY, mObjWidth, mObjHeight, mCtxFrameNum;
   nsString                mCtxURI, mCtxHref, mCtxImgHref;
   PRUint32                mEmbedCtxType;
   PRInt32 mCtxFormType;
   nsCOMPtr<nsIDOMNode>    mEventNode;
   nsCOMPtr<nsIDOMEventTarget> mEventTarget;
   nsCOMPtr<nsIDOMDocument>mCtxDocument;
-  nsRect               mFormRect;
+  nsIntRect               mFormRect;
   nsCOMPtr<nsIDOMWindow>  mCtxDomWindow;
   nsCOMPtr<nsIDOMEvent>   mCtxEvent;
   nsCOMPtr<nsIDOMNSHTMLElement> mNSHHTMLElement;
   nsCOMPtr<nsIDOMNSHTMLElement> mNSHHTMLElementSc;
 private:
   nsresult          SetFrameIndex();
   nsresult          SetFormControlType(nsIDOMEventTarget *originalTarget);
   nsresult          CheckDomHtmlNode(nsIDOMNode *aNode = nsnull);
--- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
+++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
@@ -1477,18 +1477,18 @@ ChromeTooltipListener::sTooltipCallback(
       PRBool textFound = PR_FALSE;
 
       self->mTooltipTextProvider->GetNodeText(
           self->mPossibleTooltipNode, getter_Copies(tooltipText), &textFound);
       
       if (textFound) {
         nsString tipText(tooltipText);
         self->CreateAutoHideTimer();
-        nsRect widgetDot(0, 0, 1, 1);
-        nsRect screenDot;
+        nsIntRect widgetDot(0, 0, 1, 1);
+        nsIntRect screenDot;
         widget->WidgetToScreen(widgetDot, screenDot);
         self->ShowTooltip (self->mMouseScreenX - screenDot.x,
                            self->mMouseScreenY - screenDot.y,
                            tipText);
       }
     }
     
     // release tooltip target if there is one, NO MATTER WHAT
--- a/embedding/browser/webBrowser/nsWebBrowser.cpp
+++ b/embedding/browser/webBrowser/nsWebBrowser.cpp
@@ -1124,17 +1124,17 @@ NS_IMETHODIMP nsWebBrowser::Create()
       docShellParentWidget = mInternalWidget;
       nsWidgetInitData  widgetInit;
 
       widgetInit.clipChildren = PR_TRUE;
       widgetInit.mContentType = (mContentType == typeChrome || 
         mContentType == typeChromeWrapper)? eContentTypeUI: eContentTypeContent;
 
       widgetInit.mWindowType = eWindowType_child;
-      nsRect bounds(mInitInfo->x, mInitInfo->y, mInitInfo->cx, mInitInfo->cy);
+      nsIntRect bounds(mInitInfo->x, mInitInfo->y, mInitInfo->cx, mInitInfo->cy);
       
       mInternalWidget->SetClientData(static_cast<nsWebBrowser *>(this));
       mInternalWidget->Create(mParentNativeWindow, bounds, nsWebBrowser::HandleEvent,
                               nsnull, nsnull, nsnull, &widgetInit);  
       }
 
    nsCOMPtr<nsIDocShell> docShell(do_CreateInstance("@mozilla.org/webshell;1"));
    NS_ENSURE_SUCCESS(SetDocShell(docShell), NS_ERROR_FAILURE);
@@ -1312,17 +1312,17 @@ NS_IMETHODIMP nsWebBrowser::GetPositionA
          *aCX = mInitInfo->cx;
       if(aCY)
          *aCY = mInitInfo->cy;
       }
    else
       {
       if(mInternalWidget)
          {
-         nsRect bounds;
+         nsIntRect bounds;
          NS_ENSURE_SUCCESS(mInternalWidget->GetBounds(bounds), NS_ERROR_FAILURE);
 
          if(aX)
             *aX = bounds.x;
          if(aY)
             *aY = bounds.y;
          if(aCX)
             *aCX = bounds.width;
--- a/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
+++ b/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
@@ -508,17 +508,17 @@ static void Show(HWND aWnd, PRBool bStat
 //--------------------------------------------------------
 // Create a child window "control"
 static HWND CreateControl(LPCTSTR          aType,
                           DWORD            aStyle,
                           HINSTANCE        aHInst, 
                           HWND             aHdlg, 
                           int              aId, 
                           const nsAString& aStr, 
-                          const nsRect&    aRect)
+                          const nsIntRect& aRect)
 {
   nsCAutoString str;
   if (NS_FAILED(NS_CopyUnicodeToNative(aStr, str)))
     return NULL;
 
   HWND hWnd = ::CreateWindow (aType, str.get(),
                               WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | aStyle,
                               aRect.x, aRect.y, aRect.width, aRect.height,
@@ -536,30 +536,30 @@ static HWND CreateControl(LPCTSTR       
 }
 
 //--------------------------------------------------------
 // Create a Radio Button
 static HWND CreateRadioBtn(HINSTANCE        aHInst, 
                            HWND             aHdlg, 
                            int              aId, 
                            const char*      aStr, 
-                           const nsRect&    aRect)
+                           const nsIntRect& aRect)
 {
   nsString cStr;
   cStr.AssignWithConversion(aStr);
   return CreateControl("BUTTON", BS_RADIOBUTTON, aHInst, aHdlg, aId, cStr, aRect);
 }
 
 //--------------------------------------------------------
 // Create a Group Box
 static HWND CreateGroupBox(HINSTANCE        aHInst, 
                            HWND             aHdlg, 
                            int              aId, 
                            const nsAString& aStr, 
-                           const nsRect&    aRect)
+                           const nsIntRect& aRect)
 {
   return CreateControl("BUTTON", BS_GROUPBOX, aHInst, aHdlg, aId, aStr, aRect);
 }
 
 //--------------------------------------------------------
 // Localizes and initializes the radio buttons and group
 static void InitializeExtendedDialog(HWND hdlg, PRInt16 aHowToEnableFrameUI) 
 {
@@ -660,17 +660,17 @@ static UINT CALLBACK PrintHookProc(HWND 
     int rbGap     = rad3Rect.top - rad1Rect.bottom;     // gap between radiobtns
     int grpBotGap = dlgRect.bottom - rad2Rect.bottom;   // gap from bottom rb to bottom of grpbox
     int grpGap    = dlgRect.top - prtRect.bottom ;      // gap between group boxes
     int top       = dlgRect.bottom + grpGap;            
     int radHgt    = rad1Rect.bottom - rad1Rect.top + 1; // top of new group box
     int y         = top+(rad1Rect.top-dlgRect.top);     // starting pos of first radio
     int rbWidth   = dlgRect.right - rad1Rect.left - 5;  // measure from rb left to the edge of the groupbox
                                                         // (5 is arbitrary)
-    nsRect rect;
+    nsIntRect rect;
 
     // Create and position the radio buttons
     //
     // If any one control cannot be created then 
     // hide the others and bail out
     //
     rect.SetRect(rad1Rect.left, y, rbWidth,radHgt);
     HWND rad4Wnd = CreateRadioBtn(hInst, hdlg, rad4, kAsLaidOutOnScreenStr, rect);
--- a/gfx/public/nsITheme.h
+++ b/gfx/public/nsITheme.h
@@ -41,30 +41,30 @@
 #ifndef nsITheme_h_
 #define nsITheme_h_
 
 #include "nsISupports.h"
 #include "nsCOMPtr.h"
 #include "nsColor.h"
 
 struct nsRect;
-struct nsSize;
+struct nsIntSize;
 struct nsFont;
-struct nsMargin;
+struct nsIntMargin;
 class nsPresContext;
 class nsIRenderingContext;
 class nsIDeviceContext;
 class nsIFrame;
 class nsIContent;
 class nsIAtom;
 
 // IID for the nsITheme interface
-// {df8baf21-5ea7-49eb-a2bc-f2fd4a9fd896}
+// {887e8902-db6b-41b4-8481-a80f49c5a93a}
 #define NS_ITHEME_IID     \
-{ 0xdf8baf21, 0x5ea7, 0x49eb, { 0xa2, 0xbc, 0xf2, 0xfd, 0x4a, 0x9f, 0xd8, 0x96 } }
+{ 0x887e8902, 0xdb6b, 0x41b4, { 0x84, 0x81, 0xa8, 0x0f, 0x49, 0xc5, 0xa9, 0x3a } }
 
 // {D930E29B-6909-44e5-AB4B-AF10D6923705}
 #define NS_THEMERENDERER_CID \
 { 0xd930e29b, 0x6909, 0x44e5, { 0xab, 0x4b, 0xaf, 0x10, 0xd6, 0x92, 0x37, 0x5 } }
 
 /**
  * nsITheme is a service that provides platform-specific native
  * rendering for widgets.  In other words, it provides the necessary
@@ -86,31 +86,31 @@ public:
                                   const nsRect& aDirtyRect)=0;
 
   /**
    * Get the computed CSS border for the widget, in pixels.
    */
   NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, 
                              nsIFrame* aFrame,
                              PRUint8 aWidgetType,
-                             nsMargin* aResult)=0;
+                             nsIntMargin* aResult)=0;
 
   /**
    * This method can return PR_FALSE to indicate that the CSS padding
    * value should be used.  Otherwise, it will fill in aResult with the
    * computed padding, in pixels, and return PR_TRUE.
    *
    * XXXldb This ought to be required to return true for non-containers
    * so that we don't let specified padding that has no effect change
    * the computed padding and potentially the size.
    */
   virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
-                                  nsMargin* aResult) = 0;
+                                  nsIntMargin* aResult) = 0;
 
   /**
    * On entry, *aResult is positioned at 0,0 and sized to the new size
    * of aFrame (aFrame->GetSize() may be stale and should not be used).
    * This method can return PR_FALSE to indicate that no special
    * overflow area is required by the native widget. Otherwise it will
    * fill in aResult with the desired overflow area, in appunits, relative
    * to the frame origin, and return PR_TRUE.
@@ -125,17 +125,17 @@ public:
    * Get the minimum border-box size of a widget, in *pixels* (in
    * |aResult|).  If |aIsOverridable| is set to true, this size is a
    * minimum size; if false, this size is the only valid size for the
    * widget.
    */
   NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
-                                  nsSize* aResult,
+                                  nsIntSize* aResult,
                                   PRBool* aIsOverridable)=0;
 
   NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, 
                                 nsIAtom* aAttribute, PRBool* aShouldRepaint)=0;
 
   NS_IMETHOD ThemeChanged()=0;
 
   /**
--- a/gfx/public/nsMargin.h
+++ b/gfx/public/nsMargin.h
@@ -100,24 +100,39 @@ struct nsMargin {
                                                  return *this;}
   nsMargin& operator-=(const nsMargin& aMargin) {left -= aMargin.left;
                                                  top -= aMargin.top;
                                                  right -= aMargin.right;
                                                  bottom -= aMargin.bottom;
                                                  return *this;}
 };
 
-#ifdef NS_COORD_IS_FLOAT
 struct nsIntMargin {
   PRInt32 top, right, bottom, left;
 
   // Constructors
   nsIntMargin() {}
   nsIntMargin(const nsIntMargin& aMargin) {*this = aMargin;}
   nsIntMargin(PRInt32 aLeft,  PRInt32 aTop,
               PRInt32 aRight, PRInt32 aBottom) {left = aLeft; top = aTop;
                                                 right = aRight; bottom = aBottom;}
+  void SizeTo(PRInt32 aLeft,  PRInt32 aTop,
+              PRInt32 aRight, PRInt32 aBottom) {left = aLeft; top = aTop;
+                                                right = aRight; bottom = aBottom;}
+  PRInt32& side(PRUint8 aSide) {
+    NS_PRECONDITION(aSide <= NS_SIDE_LEFT, "Out of range side");
+    return *(&top + aSide);
+  }    
+
+  PRInt32 side(PRUint8 aSide) const {
+    NS_PRECONDITION(aSide <= NS_SIDE_LEFT, "Out of range side");
+    return *(&top + aSide);
+  }    
+  PRInt32 LeftRight() const { return left + right; }
+  PRInt32 TopBottom() const { return top + bottom; }
+
+  nsIntMargin operator+(const nsIntMargin& aMargin) const {
+    return nsIntMargin(left + aMargin.left, top + aMargin.top,
+                    right + aMargin.right, bottom + aMargin.bottom);
+  }
 };
-#else
-typedef nsMargin nsIntMargin;
-#endif
 
 #endif /* NSMARGIN_H */
--- a/gfx/public/nsPoint.h
+++ b/gfx/public/nsPoint.h
@@ -76,64 +76,42 @@ struct nsPoint {
     return *this;
   }
 
   nsPoint operator-() const {
     return nsPoint(-x, -y);
   }
 };
 
-#ifdef NS_COORD_IS_FLOAT
 struct nsIntPoint {
   PRInt32 x, y;
 
   // Constructors
   nsIntPoint() {}
   nsIntPoint(const nsIntPoint& aPoint) { x = aPoint.x; y = aPoint.y;}
   nsIntPoint(PRInt32 aX, PRInt32 aY) { x = aX; y = aY;}
 
-  void MoveTo(PRInt32 aX, PRInt32 aY) {x = aX; y = aY;}
-};
-
-typedef nsPoint nsFloatPoint;
-#else
-typedef nsPoint nsIntPoint;
-
-struct nsFloatPoint {
-  float x, y;
-
-  // Constructors
-  nsFloatPoint() {}
-  nsFloatPoint(const nsFloatPoint& aPoint) {x = aPoint.x; y = aPoint.y;}
-  nsFloatPoint(float aX, float aY) {x = aX; y = aY;}
-
-  void MoveTo(float aX, float aY) {x = aX; y = aY;}
-  void MoveTo(nscoord aX, nscoord aY) {x = (float)aX; y = (float)aY;}
-  void MoveBy(float aDx, float aDy) {x += aDx; y += aDy;}
-
-  // Overloaded operators. Note that '=' isn't defined so we'll get the
-  // compiler generated default assignment operator
-  PRBool   operator==(const nsFloatPoint& aPoint) const {
+  PRBool   operator==(const nsIntPoint& aPoint) const {
     return (PRBool) ((x == aPoint.x) && (y == aPoint.y));
   }
-  PRBool   operator!=(const nsFloatPoint& aPoint) const {
+  PRBool   operator!=(const nsIntPoint& aPoint) const {
     return (PRBool) ((x != aPoint.x) || (y != aPoint.y));
   }
-  nsFloatPoint operator+(const nsFloatPoint& aPoint) const {
-    return nsFloatPoint(x + aPoint.x, y + aPoint.y);
+  nsIntPoint operator+(const nsIntPoint& aPoint) const {
+    return nsIntPoint(x + aPoint.x, y + aPoint.y);
   }
-  nsFloatPoint operator-(const nsFloatPoint& aPoint) const {
-    return nsFloatPoint(x - aPoint.x, y - aPoint.y);
+  nsIntPoint operator-(const nsIntPoint& aPoint) const {
+    return nsIntPoint(x - aPoint.x, y - aPoint.y);
   }
-  nsFloatPoint& operator+=(const nsFloatPoint& aPoint) {
+  nsIntPoint& operator+=(const nsIntPoint& aPoint) {
     x += aPoint.x;
     y += aPoint.y;
     return *this;
   }
-  nsFloatPoint& operator-=(const nsFloatPoint& aPoint) {
+  nsIntPoint& operator-=(const nsIntPoint& aPoint) {
     x -= aPoint.x;
     y -= aPoint.y;
     return *this;
   }
+  void MoveTo(PRInt32 aX, PRInt32 aY) {x = aX; y = aY;}
 };
-#endif // !NS_COORD_IS_FLOAT
 
 #endif /* NSPOINT_H */
--- a/gfx/public/nsRect.h
+++ b/gfx/public/nsRect.h
@@ -42,16 +42,18 @@
 #include <stdio.h>
 #include "nsCoord.h"
 #include "nsPoint.h"
 #include "nsSize.h"
 #include "nsMargin.h"
 #include "gfxCore.h"
 #include "nsTraceRefcnt.h"
 
+struct nsIntRect;
+
 struct NS_GFX nsRect {
   nscoord x, y;
   nscoord width, height;
 
   // Constructors
   nsRect() : x(0), y(0), width(0), height(0) {
     MOZ_COUNT_CTOR(nsRect);
   }
@@ -163,91 +165,216 @@ struct NS_GFX nsRect {
     return nsRect(x + aPoint.x, y + aPoint.y, width, height);
   }
   nsRect  operator-(const nsPoint& aPoint) const {
     return nsRect(x - aPoint.x, y - aPoint.y, width, height);
   }
   nsRect& operator+=(const nsPoint& aPoint) {x += aPoint.x; y += aPoint.y; return *this;}
   nsRect& operator-=(const nsPoint& aPoint) {x -= aPoint.x; y -= aPoint.y; return *this;}
 
-  nsRect& operator*=(const float aScale) {x = NSToCoordRound(x * aScale); 
-                                          y = NSToCoordRound(y * aScale); 
-                                          width = NSToCoordRound(width * aScale); 
-                                          height = NSToCoordRound(height * aScale); 
-                                          return *this;}
-
-  // Scale by aScale, converting coordinates to integers so that the result
-  // is the smallest integer-coordinate rectangle containing the unrounded result
-  nsRect& ScaleRoundOut(float aScale);
-  // Scale by the inverse of aScale, converting coordinates to integers so that the result
-  // is the smallest integer-coordinate rectangle containing the unrounded result.
-  // More accurate than ScaleRoundOut(1.0/aScale).
-  nsRect& ScaleRoundOutInverse(float aScale);
-  // Scale by aScale, converting coordinates to integers so that the result
-  // is the larges integer-coordinate rectangle contained in the unrounded result
-  nsRect& ScaleRoundIn(float aScale);
-  // Scale by the inverse of aScale, converting coordinates to integers so that
-  // the result contains the same pixel centers as the unrounded result
-  nsRect& ScaleRoundPreservingCentersInverse(float aScale);
-
   // Helpers for accessing the vertices
   nsPoint TopLeft() const { return nsPoint(x, y); }
   nsPoint TopRight() const { return nsPoint(XMost(), y); }
   nsPoint BottomLeft() const { return nsPoint(x, YMost()); }
   nsPoint BottomRight() const { return nsPoint(XMost(), YMost()); }
 
   nsSize Size() const { return nsSize(width, height); }
 
   // Helper methods for computing the extents
   nscoord XMost() const {return x + width;}
   nscoord YMost() const {return y + height;}
+
+  inline nsRect ScaleRoundOutInverse(float aFactor);
+
+  static inline nsIntRect ToNearestPixels(const nsRect &aRect, nscoord aAppUnitsPerPixel);
+  static inline nsIntRect ToOutsidePixels(const nsRect &aRect, nscoord aAppUnitsPerPixel);
+  static inline nsIntRect ToInsidePixels(const nsRect &aRect, nscoord aAppUnitsPerPixel);
 };
 
-#ifdef NS_COORD_IS_FLOAT
 struct NS_GFX nsIntRect {
   PRInt32 x, y;
   PRInt32 width, height;
 
   // Constructors
   nsIntRect() : x(0), y(0), width(0), height(0) {}
   nsIntRect(const nsIntRect& aRect) {*this = aRect;}
+  nsIntRect(const nsIntPoint& aOrigin, const nsIntSize &aSize) {
+    x = aOrigin.x; y = aOrigin.y;
+    width = aSize.width; height = aSize.height;
+  }
   nsIntRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) {
     x = aX; y = aY; width = aWidth; height = aHeight;
   }
 
   // Emptiness. An empty rect is one that has no area, i.e. its height or width
   // is <= 0
   PRBool IsEmpty() const {
     return (PRBool) ((height <= 0) || (width <= 0));
   }
+  void Empty() {width = height = 0;}
+
+  // Inflate the rect by the specified width/height or margin
+  void Inflate(PRInt32 aDx, PRInt32 aDy) {
+    x -= aDx;
+    y -= aDy;
+    width += aDx*2;
+    height += aDy*2;
+  }
+  void Inflate(const nsIntMargin &aMargin) {
+    x -= aMargin.left;
+    y -= aMargin.top;
+    width += aMargin.left + aMargin.right;
+    height += aMargin.top + aMargin.bottom;
+  }
+
+  // Overloaded operators. Note that '=' isn't defined so we'll get the
+  // compiler generated default assignment operator.
+  PRBool operator==(const nsIntRect& aRect) const {
+    return (PRBool) ((IsEmpty() && aRect.IsEmpty()) ||
+                     ((x == aRect.x) && (y == aRect.y) &&
+                      (width == aRect.width) && (height == aRect.height)));
+  }
+  PRBool  operator!=(const nsIntRect& aRect) const {
+    return (PRBool) !operator==(aRect);
+  }
+
+  nsIntRect  operator+(const nsIntPoint& aPoint) const {
+    return nsIntRect(x + aPoint.x, y + aPoint.y, width, height);
+  }
+  nsIntRect  operator-(const nsIntPoint& aPoint) const {
+    return nsIntRect(x - aPoint.x, y - aPoint.y, width, height);
+  }
+  nsIntRect& operator+=(const nsIntPoint& aPoint) {x += aPoint.x; y += aPoint.y; return *this;}
+  nsIntRect& operator-=(const nsIntPoint& aPoint) {x -= aPoint.x; y -= aPoint.y; return *this;}
 
   void SetRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) {
     x = aX; y = aY; width = aWidth; height = aHeight;
   }
 
+  void MoveTo(PRInt32 aX, PRInt32 aY) {x = aX; y = aY;}
+  void MoveTo(const nsIntPoint& aPoint) {x = aPoint.x; y = aPoint.y;}
+  void MoveBy(PRInt32 aDx, PRInt32 aDy) {x += aDx; y += aDy;}
+  void MoveBy(const nsIntPoint& aPoint) {x += aPoint.x; y += aPoint.y;}
+  void SizeTo(PRInt32 aWidth, PRInt32 aHeight) {width = aWidth; height = aHeight;}
+  void SizeTo(const nsIntSize& aSize) {SizeTo(aSize.width, aSize.height);}
+  void SizeBy(PRInt32 aDeltaWidth, PRInt32 aDeltaHeight) {width += aDeltaWidth;
+                                                          height += aDeltaHeight;}
+
+  PRBool Contains(const nsIntRect& aRect) const
+  {
+    return (PRBool) ((aRect.x >= x) && (aRect.y >= y) &&
+                     (aRect.XMost() <= XMost()) && (aRect.YMost() <= YMost()));
+  }
+  PRBool Contains(PRInt32 aX, PRInt32 aY) const
+  {
+    return (PRBool) ((aX >= x) && (aY >= y) &&
+                     (aX < XMost()) && (aY < YMost()));
+  }
+  PRBool Contains(const nsIntPoint& aPoint) const { return Contains(aPoint.x, aPoint.y); }
+
+  // Intersection. Returns TRUE if the receiver overlaps aRect and
+  // FALSE otherwise
+  PRBool Intersects(const nsIntRect& aRect) const {
+    return (PRBool) ((x < aRect.XMost()) && (y < aRect.YMost()) &&
+                     (aRect.x < XMost()) && (aRect.y < YMost()));
+  }
+  
   // Computes the area in which aRect1 and aRect2 overlap, and fills 'this' with
   // the result. Returns FALSE if the rectangles don't intersect, and sets 'this'
   // rect to be an empty rect.
   //
   // 'this' can be the same object as either aRect1 or aRect2
   PRBool IntersectRect(const nsIntRect& aRect1, const nsIntRect& aRect2);
 
   // Computes the smallest rectangle that contains both aRect1 and aRect2 and
   // fills 'this' with the result. Returns FALSE and sets 'this' rect to be an
   // empty rect if both aRect1 and aRect2 are empty
   //
   // 'this' can be the same object as either aRect1 or aRect2
   PRBool UnionRect(const nsIntRect& aRect1, const nsIntRect& aRect2);
 
+  // Helpers for accessing the vertices
+  nsIntPoint TopLeft() const { return nsIntPoint(x, y); }
+  nsIntPoint TopRight() const { return nsIntPoint(XMost(), y); }
+  nsIntPoint BottomLeft() const { return nsIntPoint(x, YMost()); }
+  nsIntPoint BottomRight() const { return nsIntPoint(XMost(), YMost()); }
+
+  nsIntSize Size() const { return nsIntSize(width, height); }
+
   // Helper methods for computing the extents
   PRInt32 XMost() const {return x + width;}
   PRInt32 YMost() const {return y + height;}
+
+  static inline nsRect ToAppUnits(const nsIntRect &aRect, nscoord aAppUnitsPerPixel);
 };
-#else
-typedef nsRect nsIntRect;
-#endif
+
+inline nsRect
+nsRect::ScaleRoundOutInverse(float aFactor)
+{
+  nsRect rect;
+  rect.x = NSToIntFloor(x / aFactor);
+  rect.y = NSToIntFloor(y / aFactor);
+  rect.width = NSToIntCeil(XMost() / aFactor) - rect.x;
+  rect.height = NSToIntCeil(YMost() / aFactor) - rect.y;
+  return rect;
+}
+
+/* 
+ * App Unit/Pixel conversions
+ */
+// scale the rect but round to preserve centers
+inline nsIntRect
+nsRect::ToNearestPixels(const nsRect &aRect, nscoord aAppUnitsPerPixel)
+{
+  nsIntRect rect;  
+  rect.x = NSToIntRound(NSAppUnitsToFloatPixels(aRect.x, aAppUnitsPerPixel));
+  rect.y = NSToIntRound(NSAppUnitsToFloatPixels(aRect.y, aAppUnitsPerPixel));
+  rect.width  = NSToIntRound(NSAppUnitsToFloatPixels(aRect.XMost(),
+                             aAppUnitsPerPixel)) - rect.x;
+  rect.height = NSToIntRound(NSAppUnitsToFloatPixels(aRect.YMost(),
+                             aAppUnitsPerPixel)) - rect.y;
+  return rect;
+}
+
+// scale the rect but round to smallest containing rect
+inline nsIntRect
+nsRect::ToOutsidePixels(const nsRect &aRect, nscoord aAppUnitsPerPixel)
+{
+  nsIntRect rect;  
+  rect.x = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.x, aAppUnitsPerPixel));
+  rect.y = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.y, aAppUnitsPerPixel));
+  rect.width  = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.XMost(),
+                            aAppUnitsPerPixel)) - rect.x;
+  rect.height = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.YMost(),
+                            aAppUnitsPerPixel)) - rect.y;
+  return rect;
+}
+
+// scale the rect but round to largest contained rect
+inline nsIntRect
+nsRect::ToInsidePixels(const nsRect &aRect, nscoord aAppUnitsPerPixel)
+{
+  nsIntRect rect;  
+  rect.x = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.x, aAppUnitsPerPixel));
+  rect.y = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.y, aAppUnitsPerPixel));
+  rect.width  = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.XMost(),
+                             aAppUnitsPerPixel)) - rect.x;
+  rect.height = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.YMost(),
+                             aAppUnitsPerPixel)) - rect.y;
+  return rect;
+}
+
+// app units are integer multiples of pixels, so no rounding needed
+inline nsRect
+nsIntRect::ToAppUnits(const nsIntRect &aRect, nscoord aAppUnitsPerPixel)
+{
+  return nsRect(NSIntPixelsToAppUnits(aRect.x, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(aRect.y, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(aRect.width, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(aRect.height, aAppUnitsPerPixel));
+}
 
 #ifdef DEBUG
 // Diagnostics
 extern NS_GFX FILE* operator<<(FILE* out, const nsRect& rect);
 #endif // DEBUG
 
 #endif /* NSRECT_H */
--- a/gfx/public/nsSize.h
+++ b/gfx/public/nsSize.h
@@ -66,23 +66,28 @@ struct nsSize {
   nsSize operator+(const nsSize& aSize) const {
     return nsSize(width + aSize.width, height + aSize.height);
   }
   nsSize& operator+=(const nsSize& aSize) {width += aSize.width;
                                            height += aSize.height;
                                            return *this;}
 };
 
-#ifdef NS_COORD_IS_FLOAT
 struct nsIntSize {
   PRInt32 width, height;
 
   nsIntSize() {}
   nsIntSize(const nsIntSize& aSize) {width = aSize.width; height = aSize.height;}
   nsIntSize(PRInt32 aWidth, PRInt32 aHeight) {width = aWidth; height = aHeight;}
 
+  // Overloaded operators. Note that '=' isn't defined so we'll get the
+  // compiler generated default assignment operator
+  PRBool  operator==(const nsIntSize& aSize) const {
+    return (PRBool) ((width == aSize.width) && (height == aSize.height));
+  }
+  PRBool  operator!=(const nsIntSize& aSize) const {
+    return (PRBool) ((width != aSize.width) || (height != aSize.height));
+  }
+
   void SizeTo(PRInt32 aWidth, PRInt32 aHeight) {width = aWidth; height = aHeight;}
 };
-#else
-typedef nsSize nsIntSize;
-#endif
 
 #endif /* NSSIZE_H */
--- a/gfx/src/nsRect.cpp
+++ b/gfx/src/nsRect.cpp
@@ -168,62 +168,16 @@ void nsRect::Deflate(nscoord aDx, nscoor
 void nsRect::Deflate(const nsMargin &aMargin)
 {
   x += aMargin.left;
   y += aMargin.top;
   width = PR_MAX(0, width - aMargin.LeftRight());
   height = PR_MAX(0, height - aMargin.TopBottom());
 }
 
-// scale the rect but round to smallest containing rect
-nsRect& nsRect::ScaleRoundOut(float aScale) 
-{
-  nscoord right = NSToCoordCeil(float(XMost()) * aScale);
-  nscoord bottom = NSToCoordCeil(float(YMost()) * aScale);
-  x = NSToCoordFloor(float(x) * aScale);
-  y = NSToCoordFloor(float(y) * aScale);
-  width = (right - x);
-  height = (bottom - y);
-  return *this;
-}
-
-nsRect& nsRect::ScaleRoundOutInverse(float aScale) 
-{
-  nscoord right = NSToCoordCeil(float(XMost()) / aScale);
-  nscoord bottom = NSToCoordCeil(float(YMost()) / aScale);
-  x = NSToCoordFloor(float(x) / aScale);
-  y = NSToCoordFloor(float(y) / aScale);
-  width = (right - x);
-  height = (bottom - y);
-  return *this;
-}
-
-// scale the rect but round to largest contained rect
-nsRect& nsRect::ScaleRoundIn(float aScale) 
-{
-  nscoord right = NSToCoordFloor(float(XMost()) * aScale);
-  nscoord bottom = NSToCoordFloor(float(YMost()) * aScale);
-  x = NSToCoordCeil(float(x) * aScale);
-  y = NSToCoordCeil(float(y) * aScale);
-  width = (right - x);
-  height = (bottom - y);
-  return *this;
-}
-
-nsRect& nsRect::ScaleRoundPreservingCentersInverse(float aScale)
-{
-  nscoord right = NSToCoordRound(float(XMost()) / aScale);
-  nscoord bottom = NSToCoordRound(float(YMost()) / aScale);
-  x = NSToCoordRound(float(x) / aScale);
-  y = NSToCoordRound(float(y) / aScale);
-  width = (right - x);
-  height = (bottom - y);
-  return *this;
-}
-
 #ifdef DEBUG
 // Diagnostics
 
 FILE* operator<<(FILE* out, const nsRect& rect)
 {
   nsAutoString tmp;
 
   // Output the coordinates in fractional pixels so they're easier to read
@@ -239,17 +193,18 @@ FILE* operator<<(FILE* out, const nsRect
   tmp.AppendLiteral(", ");
   tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.height,
                        nsIDeviceContext::AppUnitsPerCSSPixel()));
   tmp.AppendLiteral("}");
   fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
   return out;
 }
 
-#ifdef NS_COORD_IS_FLOAT
+#endif // DEBUG
+
 // Computes the area in which aRect1 and aRect2 overlap and fills 'this' with
 // the result. Returns FALSE if the rectangles don't intersect.
 PRBool nsIntRect::IntersectRect(const nsIntRect &aRect1, const nsIntRect &aRect2)
 {
   PRInt32  xmost1 = aRect1.XMost();
   PRInt32  ymost1 = aRect1.YMost();
   PRInt32  xmost2 = aRect2.XMost();
   PRInt32  ymost2 = aRect2.YMost();
@@ -309,11 +264,9 @@ PRBool nsIntRect::UnionRect(const nsIntR
 
     // Compute the size
     width = PR_MAX(xmost1, xmost2) - x;
     height = PR_MAX(ymost1, ymost2) - y;
   }
 
   return result;
 }
-#endif
 
-#endif // DEBUG
--- a/gfx/src/thebes/nsThebesImage.cpp
+++ b/gfx/src/thebes/nsThebesImage.cpp
@@ -215,17 +215,17 @@ nsThebesImage::GetAlphaBits()
 
 PRInt32
 nsThebesImage::GetAlphaLineStride()
 {
     return (mAlphaDepth > 0) ? mStride : 0;
 }
 
 nsresult
-nsThebesImage::ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect)
+nsThebesImage::ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsIntRect *aUpdateRect)
 {
     // Check to see if we are running OOM
     nsCOMPtr<nsIMemory> mem;
     NS_GetMemoryManager(getter_AddRefs(mem));
     if (!mem)
         return NS_ERROR_UNEXPECTED;
 
     PRBool lowMemory;
@@ -240,17 +240,17 @@ nsThebesImage::ImageUpdated(nsIDeviceCon
 #endif
     return NS_OK;
 }
 
 PRBool
 nsThebesImage::GetIsImageComplete()
 {
     if (!mImageComplete)
-        mImageComplete = (mDecoded == nsRect(0, 0, mWidth, mHeight));
+        mImageComplete = (mDecoded == nsIntRect(0, 0, mWidth, mHeight));
     return mImageComplete;
 }
 
 nsresult
 nsThebesImage::Optimize(nsIDeviceContext* aContext)
 {
     if (gDisableOptimize)
         return NS_OK;
--- a/gfx/src/thebes/nsThebesImage.h
+++ b/gfx/src/thebes/nsThebesImage.h
@@ -66,17 +66,17 @@ public:
     virtual PRInt32 GetWidth();
     virtual PRInt32 GetHeight();
     virtual PRUint8 *GetBits();
     virtual PRInt32 GetLineStride();
     virtual PRBool GetHasAlphaMask();
     virtual PRUint8 *GetAlphaBits();
     virtual PRInt32 GetAlphaLineStride();
     virtual PRBool GetIsImageComplete();
-    virtual nsresult ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect);
+    virtual nsresult ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsIntRect *aUpdateRect);
     virtual nsresult Optimize(nsIDeviceContext* aContext);
     virtual nsColorMap *GetColorMap();
 
     NS_IMETHOD Draw(nsIRenderingContext &aContext,
                     const gfxRect &aSourceRect,
                     const gfxRect &aSubimageRect,
                     const gfxRect &aDestRect);
 
@@ -154,17 +154,17 @@ protected:
         }
         return PR_TRUE;
     }
 
     gfxImageSurface::gfxImageFormat mFormat;
     PRInt32 mWidth;
     PRInt32 mHeight;
     PRInt32 mStride;
-    nsRect mDecoded;
+    nsIntRect mDecoded;
     PRPackedBool mImageComplete;
     PRPackedBool mSinglePixel;
     PRPackedBool mFormatChanged;
 #ifdef XP_WIN
     PRPackedBool mIsDDBSurface;
 #endif
 
     gfxRGBA mSinglePixelColor;
--- a/gfx/src/thebes/nsThebesRenderingContext.cpp
+++ b/gfx/src/thebes/nsThebesRenderingContext.cpp
@@ -775,17 +775,17 @@ nsThebesRenderingContext::DrawTile(imgIC
     nscoord containerWidth, containerHeight;
     aImage->GetWidth(&containerWidth);
     aImage->GetHeight(&containerHeight);
 
     nsCOMPtr<gfxIImageFrame> imgFrame;
     aImage->GetCurrentFrame(getter_AddRefs(imgFrame));
     if (!imgFrame) return NS_ERROR_FAILURE;
 
-    nsRect imgFrameRect;
+    nsIntRect imgFrameRect;
     imgFrame->GetRect(imgFrameRect);
 
     nsCOMPtr<nsIImage> img(do_GetInterface(imgFrame));
     if (!img) return NS_ERROR_FAILURE;
     
     nsThebesImage *thebesImage = static_cast<nsThebesImage*>((nsIImage*) img.get());
 
     /* Phase offset of the repeated image from the origin */
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -1577,22 +1577,23 @@ nsCSSRendering::PaintBackgroundWithSC(ns
     PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
                          aColor, aBorder, canDrawBackgroundColor);
     return;
   }
 
   nsCOMPtr<imgIContainer> image;
   req->GetImage(getter_AddRefs(image));
 
+  nsIntSize imageIntSize;
+  image->GetWidth(&imageIntSize.width);
+  image->GetHeight(&imageIntSize.height);
+
   nsSize imageSize;
-  image->GetWidth(&imageSize.width);
-  image->GetHeight(&imageSize.height);
-
-  imageSize.width = nsPresContext::CSSPixelsToAppUnits(imageSize.width);
-  imageSize.height = nsPresContext::CSSPixelsToAppUnits(imageSize.height);
+  imageSize.width = nsPresContext::CSSPixelsToAppUnits(imageIntSize.width);
+  imageSize.height = nsPresContext::CSSPixelsToAppUnits(imageIntSize.height);
 
   req = nsnull;
 
   nsRect bgOriginArea;
 
   nsIAtom* frameType = aForFrame->GetType();
   if (frameType == nsGkAtoms::inlineFrame ||
       frameType == nsGkAtoms::positionedInlineFrame) {
@@ -1654,20 +1655,20 @@ nsCSSRendering::PaintBackgroundWithSC(ns
         // If the image is completely opaque, we do not need to paint the
         // background color
         nsCOMPtr<gfxIImageFrame> gfxImgFrame;
         image->GetCurrentFrame(getter_AddRefs(gfxImgFrame));
         if (gfxImgFrame) {
           gfxImgFrame->GetNeedsBackground(&needBackgroundColor);
 
           /* check for tiling of a image where frame smaller than container */
-          nsSize iSize;
+          nsIntSize iSize;
           image->GetWidth(&iSize.width);
           image->GetHeight(&iSize.height);
-          nsRect iframeRect;
+          nsIntRect iframeRect;
           gfxImgFrame->GetRect(iframeRect);
           if (iSize.width != iframeRect.width ||
               iSize.height != iframeRect.height) {
             needBackgroundColor = PR_TRUE;
           }
         }
       }
       break;
@@ -1963,19 +1964,19 @@ nsCSSRendering::PaintBackgroundWithSC(ns
                    "We shouldn't need to tile here");
       // The entire drawRect is contained inside a single tile; just
       // draw the corresponding part of the image once.
       nsLayoutUtils::DrawImage(&aRenderingContext, image,
               destRect, drawRect, &subimageRect);
     } else {
       // Note that the subimage is in tile space so it may cover
       // multiple tiles of the image.
-      subimageRect.ScaleRoundOutInverse(nsIDeviceContext::AppUnitsPerCSSPixel());
+      nsIntRect subimagePxRect(nsRect::ToOutsidePixels(subimageRect, nsIDeviceContext::AppUnitsPerCSSPixel()));
       aRenderingContext.DrawTile(image, absTileRect.x, absTileRect.y,
-              &drawRect, &subimageRect);
+              &drawRect, &subimagePxRect);
     }
   }
 
   ctx->Restore();
 
 }
 
 static void
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -363,17 +363,17 @@ private:
    */
   nsresult CreateDeviceContext(nsIWidget* aWidget);
 
   /**
    * Make sure to set up mDeviceContext as needed before calling this
    */
   nsresult InitInternal(nsIWidget* aParentWidget,
                         nsISupports *aState,
-                        const nsRect& aBounds,
+                        const nsIntRect& aBounds,
                         PRBool aDoCreation,
                         PRBool aInPrintPreview,
                         PRBool aNeedMakeCX = PR_TRUE);
   /**
    * @param aDoInitialReflow set to true if you want to kick off the initial
    * reflow
    * @param aReenableRefresh set to true if you want this to reenable refresh
    * before returning; otherwise this will return with refresh disabled
@@ -661,17 +661,17 @@ DocumentViewerImpl::GetContainer(nsISupp
    *aResult = nsnull;
    nsCOMPtr<nsISupports> container = do_QueryReferent(mContainer);
    container.swap(*aResult);
    return NS_OK;
 }
 
 NS_IMETHODIMP
 DocumentViewerImpl::Init(nsIWidget* aParentWidget,
-                         const nsRect& aBounds)
+                         const nsIntRect& aBounds)
 {
   nsresult rv = CreateDeviceContext(aParentWidget);
   NS_ENSURE_SUCCESS(rv, rv);
   
   return InitInternal(aParentWidget, nsnull, aBounds, PR_TRUE, PR_FALSE);
 }
 
 nsresult
@@ -704,17 +704,17 @@ DocumentViewerImpl::InitPresentationStuf
     // to avoid bogus notifications.
 
     mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
   }
 
   mPresShell->BeginObservingDocument();
 
   // Initialize our view manager
-  nsRect bounds;
+  nsIntRect bounds;
   mWindow->GetBounds(bounds);
 
   nscoord width = mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel() * bounds.width;
   nscoord height = mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel() * bounds.height;
 
   mViewManager->DisableRefresh();
   mViewManager->SetWindowDimensions(width, height);
   mPresContext->SetTextZoom(mTextZoom);
@@ -800,17 +800,17 @@ DocumentViewerImpl::InitPresentationStuf
 
 //-----------------------------------------------
 // This method can be used to initial the "presentation"
 // The aDoCreation indicates whether it should create
 // all the new objects or just initialize the existing ones
 nsresult
 DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
                                  nsISupports *aState,
-                                 const nsRect& aBounds,
+                                 const nsIntRect& aBounds,
                                  PRBool aDoCreation,
                                  PRBool aInPrintPreview,
                                  PRBool aNeedMakeCX /*= PR_TRUE*/)
 {
   mParentWidget = aParentWidget; // not ref counted
 
   nsresult rv = NS_OK;
   NS_ENSURE_TRUE(mDocument, NS_ERROR_NULL_POINTER);
@@ -1242,17 +1242,17 @@ DocumentViewerImpl::Open(nsISupports *aS
   NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_INITIALIZED);
 
   // Our container might have gone away while we were closed.
   // If this is the case, we must fail to open so we don't crash.
   nsCOMPtr<nsISupports> container = do_QueryReferent(mContainer);
   if (!container)
     return NS_ERROR_NOT_AVAILABLE;
 
-  nsRect bounds;
+  nsIntRect bounds;
   mWindow->GetBounds(bounds);
 
   nsresult rv = InitInternal(mParentWidget, aState, bounds, PR_FALSE, PR_FALSE);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (mDocument)
     mDocument->SetContainer(nsCOMPtr<nsISupports>(do_QueryReferent(mContainer)));
 
@@ -1733,17 +1733,17 @@ NS_IMETHODIMP
 DocumentViewerImpl::GetPresContext(nsPresContext** aResult)
 {
   nsPresContext* pc = GetPresContext();
   NS_IF_ADDREF(*aResult = pc);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-DocumentViewerImpl::GetBounds(nsRect& aResult)
+DocumentViewerImpl::GetBounds(nsIntRect& aResult)
 {
   NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
   NS_PRECONDITION(mWindow, "null window");
   if (mWindow) {
     mWindow->GetBounds(aResult);
   }
   else {
     aResult.SetRect(0, 0, 0, 0);
@@ -1788,17 +1788,17 @@ DocumentViewerImpl::SetPreviousViewer(ns
     }
   }
 
   mPreviousViewer = aViewer;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-DocumentViewerImpl::SetBounds(const nsRect& aBounds)
+DocumentViewerImpl::SetBounds(const nsIntRect& aBounds)
 {
   NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
 
   if (mWindow) {
     // Don't have the widget repaint. Layout will generate repaint requests
     // during reflow
     mWindow->Resize(aBounds.x, aBounds.y, aBounds.width, aBounds.height,
                     PR_FALSE);
@@ -1895,17 +1895,17 @@ DocumentViewerImpl::Show(void)
     NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);
 
     rv = mPresContext->Init(mDeviceContext);
     if (NS_FAILED(rv)) {
       mPresContext = nsnull;
       return rv;
     }
 
-    nsRect tbounds;
+    nsIntRect tbounds;
     mParentWidget->GetBounds(tbounds);
 
     rv = MakeWindow(nsSize(mPresContext->DevPixelsToAppUnits(tbounds.width),
                            mPresContext->DevPixelsToAppUnits(tbounds.height)));
     if (NS_FAILED(rv))
       return rv;
 
     if (mPresContext && base_win) {
@@ -4083,17 +4083,17 @@ DocumentViewerImpl::OnDonePrinting()
 }
 
 NS_IMETHODIMP DocumentViewerImpl::SetPageMode(PRBool aPageMode, nsIPrintSettings* aPrintSettings)
 {
   // XXX Page mode is only partially working; it's currently used for
   // reftests that require a paginated context
   mIsPageMode = aPageMode;
   // Get the current size of what is being viewed
-  nsRect bounds;
+  nsIntRect bounds;
   mWindow->GetBounds(bounds);
 
   if (mPresShell) {
     // Break circular reference (or something)
     mPresShell->EndObservingDocument();
     nsCOMPtr<nsISelection> selection;
     nsresult rv = GetDocumentSelection(getter_AddRefs(selection));
     nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(selection));
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -97,21 +97,20 @@ template<class E> class nsCOMArray;
 class nsWeakFrame;
 class nsIScrollableFrame;
 class gfxASurface;
 class gfxContext;
 
 typedef short SelectionType;
 typedef PRUint32 nsFrameState;
 
-
-// 134e504f-4fd1-4590-9f5d-899afee63d0f
+// b86c23c5-602d-4ca6-a968-379b244fed9e
 #define NS_IPRESSHELL_IID \
-{ 0x134e504f, 0x4fd1, 0x4590, \
-  { 0x9f, 0x5d, 0x89, 0x9a, 0xfe, 0xe6, 0x3d, 0x0f } }
+{ 0xb86c23c5, 0x602d, 0x4ca6, \
+  { 0xa9, 0x68, 0x37, 0x9b, 0x24, 0x4f, 0xed, 0x9e } }
 
 // Constants for ScrollContentIntoView() function
 #define NS_PRESSHELL_SCROLL_TOP      0
 #define NS_PRESSHELL_SCROLL_BOTTOM   100
 #define NS_PRESSHELL_SCROLL_LEFT     0
 #define NS_PRESSHELL_SCROLL_RIGHT    100
 #define NS_PRESSHELL_SCROLL_CENTER   50
 #define NS_PRESSHELL_SCROLL_ANYWHERE -1
@@ -734,18 +733,18 @@ public:
   /**
    * Renders a node aNode to a surface and returns it. The aRegion may be used
    * to clip the rendering. This region is measured in device pixels from the
    * edge of the presshell area. The aPoint, aScreenRect and aSurface
    * arguments function in a similar manner as RenderSelection.
    */
   virtual already_AddRefed<gfxASurface> RenderNode(nsIDOMNode* aNode,
                                                    nsIRegion* aRegion,
-                                                   nsPoint& aPoint,
-                                                   nsRect* aScreenRect) = 0;
+                                                   nsIntPoint& aPoint,
+                                                   nsIntRect* aScreenRect) = 0;
 
   /*
    * Renders a selection to a surface and returns it. This method is primarily
    * intended to create the drag feedback when dragging a selection.
    *
    * aScreenRect will be filled in with the bounding rectangle of the
    * selection area on screen.
    *
@@ -753,18 +752,18 @@ public:
    * The argument aPoint is used in this case as a reference point when
    * determining the new screen rectangle after scaling. Typically, this
    * will be the mouse position, so that the screen rectangle is positioned
    * such that the mouse is over the same point in the scaled image as in
    * the original. When scaling does not occur, the mouse point isn't used
    * as the position can be determined from the displayed frames.
    */
   virtual already_AddRefed<gfxASurface> RenderSelection(nsISelection* aSelection,
-                                                        nsPoint& aPoint,
-                                                        nsRect* aScreenRect) = 0;
+                                                        nsIntPoint& aPoint,
+                                                        nsIntRect* aScreenRect) = 0;
 
   void AddWeakFrame(nsWeakFrame* aWeakFrame);
   void RemoveWeakFrame(nsWeakFrame* aWeakFrame);
 
 #ifdef NS_DEBUG
   nsIFrame* GetDrawEventTargetFrame() { return mDrawEventTargetFrame; }
 #endif
 
--- a/layout/base/nsImageLoader.cpp
+++ b/layout/base/nsImageLoader.cpp
@@ -179,32 +179,27 @@ NS_IMETHODIMP nsImageLoader::OnStopFrame
   
   // Draw the background image
   RedrawDirtyFrame(nsnull);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsImageLoader::FrameChanged(imgIContainer *aContainer,
                                           gfxIImageFrame *newframe,
-                                          nsRect * dirtyRect)
+                                          nsIntRect *dirtyRect)
 {
   if (!mFrame)
     return NS_ERROR_FAILURE;
 
   if (!mRequest) {
     // We're in the middle of a paint anyway
     return NS_OK;
   }
   
-  nsRect r(*dirtyRect);
-
-  r.x = nsPresContext::CSSPixelsToAppUnits(r.x);
-  r.y = nsPresContext::CSSPixelsToAppUnits(r.y);
-  r.width = nsPresContext::CSSPixelsToAppUnits(r.width);
-  r.height = nsPresContext::CSSPixelsToAppUnits(r.height);
+  nsRect r(nsIntRect::ToAppUnits(*dirtyRect, nsPresContext::AppUnitsPerCSSPixel()));
 
   RedrawDirtyFrame(&r);
 
   return NS_OK;
 }
 
 
 void
--- a/layout/base/nsImageLoader.h
+++ b/layout/base/nsImageLoader.h
@@ -62,17 +62,17 @@ public:
   // Do not override OnDataAvailable since background images are not
   // displayed incrementally; they are displayed after the entire image
   // has been loaded.
   // Note: Images referenced by the <img> element are displayed
   // incrementally in nsImageFrame.cpp.
 
   // imgIContainerObserver (override nsStubImageDecoderObserver)
   NS_IMETHOD FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe,
-                          nsRect * dirtyRect);
+                          nsIntRect *dirtyRect);
 
   void Init(nsIFrame *aFrame, nsPresContext *aPresContext,
             PRBool aReflowOnLoad);
   nsresult Load(imgIRequest *aImage);
 
   void Destroy();
 
   nsIFrame *GetFrame() { return mFrame; }
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -811,21 +811,21 @@ nsLayoutUtils::GetEventCoordinatesForNea
   aFrame->GetOffsetFromView(viewToFrame, &frameView);
   if (aView)
     *aView = frameView;
 
   return TranslateWidgetToView(aFrame->PresContext(), GUIEvent->widget,
                                GUIEvent->refPoint, frameView);
 }
 
-static nsPoint GetWidgetOffset(nsIWidget* aWidget, nsIWidget*& aRootWidget) {
-  nsPoint offset(0, 0);
+static nsIntPoint GetWidgetOffset(nsIWidget* aWidget, nsIWidget*& aRootWidget) {
+  nsIntPoint offset(0, 0);
   nsIWidget* parent = aWidget->GetParent();
   while (parent) {
-    nsRect bounds;
+    nsIntRect bounds;
     aWidget->GetBounds(bounds);
     offset += bounds.TopLeft();
     aWidget = parent;
     parent = aWidget->GetParent();
   }
   aRootWidget = aWidget;
   return offset;
 }
@@ -834,19 +834,19 @@ nsPoint
 nsLayoutUtils::TranslateWidgetToView(nsPresContext* aPresContext, 
                                      nsIWidget* aWidget, nsIntPoint aPt,
                                      nsIView* aView)
 {
   nsPoint viewOffset;
   nsIWidget* viewWidget = aView->GetNearestWidget(&viewOffset);
 
   nsIWidget* fromRoot;
-  nsPoint fromOffset = GetWidgetOffset(aWidget, fromRoot);
+  nsIntPoint fromOffset(GetWidgetOffset(aWidget, fromRoot));
   nsIWidget* toRoot;
-  nsPoint toOffset = GetWidgetOffset(viewWidget, toRoot);
+  nsIntPoint toOffset(GetWidgetOffset(viewWidget, toRoot));
 
   nsIntPoint widgetPoint;
   if (fromRoot == toRoot) {
     widgetPoint = aPt + fromOffset - toOffset;
   } else {
     nsIntRect widgetRect(0, 0, 0, 0);
     nsIntRect screenRect;
     aWidget->WidgetToScreen(widgetRect, screenRect);
@@ -1981,17 +1981,17 @@ nsLayoutUtils::IntrinsicForContainer(nsI
   }
 
   min = AddPercents(aType, min, pctTotal);
   if (result < min)
     result = min;
 
   const nsStyleDisplay *disp = aFrame->GetStyleDisplay();
   if (aFrame->IsThemed(disp)) {
-    nsSize size(0, 0);
+    nsIntSize size(0, 0);
     PRBool canOverride = PR_TRUE;
     nsPresContext *presContext = aFrame->PresContext();
     presContext->GetTheme()->
       GetMinimumWidgetSize(aRenderingContext, aFrame, disp->mAppearance,
                            &size, &canOverride);
 
     nscoord themeWidth = presContext->DevPixelsToAppUnits(size.width);
 
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -560,17 +560,17 @@ public:
                    AppUnitsToGfxUnits(aAppRect.width),
                    AppUnitsToGfxUnits(aAppRect.height)); }
 
   nscoord TwipsToAppUnits(PRInt32 aTwips) const
   { return NSToCoordRound(NS_TWIPS_TO_INCHES(aTwips) *
                           mDeviceContext->AppUnitsPerInch()); }
 
   // Margin-specific version, since they often need TwipsToAppUnits
-  nsMargin TwipsToAppUnits(const nsMargin &marginInTwips) const
+  nsMargin TwipsToAppUnits(const nsIntMargin &marginInTwips) const
   { return nsMargin(TwipsToAppUnits(marginInTwips.left), 
                     TwipsToAppUnits(marginInTwips.top),
                     TwipsToAppUnits(marginInTwips.right),
                     TwipsToAppUnits(marginInTwips.bottom)); }
 
   PRInt32 AppUnitsToTwips(nscoord aTwips) const
   { return NS_INCHES_TO_TWIPS((float)aTwips /
                               mDeviceContext->AppUnitsPerInch()); }
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -882,22 +882,22 @@ public:
 
   NS_IMETHOD RenderDocument(const nsRect& aRect, PRBool aUntrusted,
                             PRBool aIgnoreViewportScrolling,
                             nscolor aBackgroundColor,
                             gfxContext* aThebesContext);
 
   virtual already_AddRefed<gfxASurface> RenderNode(nsIDOMNode* aNode,
                                                    nsIRegion* aRegion,
-                                                   nsPoint& aPoint,
-                                                   nsRect* aScreenRect);
+                                                   nsIntPoint& aPoint,
+                                                   nsIntRect* aScreenRect);
 
   virtual already_AddRefed<gfxASurface> RenderSelection(nsISelection* aSelection,
-                                                        nsPoint& aPoint,
-                                                        nsRect* aScreenRect);
+                                                        nsIntPoint& aPoint,
+                                                        nsIntRect* aScreenRect);
 
   //nsIViewObserver interface
 
   NS_IMETHOD Paint(nsIView *aView,
                    nsIRenderingContext* aRenderingContext,
                    const nsRegion& aDirtyRegion);
   NS_IMETHOD ComputeRepaintRegionForCopy(nsIView*      aRootView,
                                          nsIView*      aMovingView,
@@ -1092,18 +1092,18 @@ protected:
    * aScreenRect - [out] set to the area of the screen the painted area should
    *               be displayed at
    */
   already_AddRefed<gfxASurface>
   PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
                       nsISelection* aSelection,
                       nsIRegion* aRegion,
                       nsRect aArea,
-                      nsPoint& aPoint,
-                      nsRect* aScreenRect);
+                      nsIntPoint& aPoint,
+                      nsIntRect* aScreenRect);
 
   /**
    * Methods to handle changes to user and UA sheet lists that we get
    * notified about.
    */
   void AddUserSheet(nsISupports* aSheet);
   void AddAgentSheet(nsISupports* aSheet);
   void RemoveSheet(nsStyleSet::sheetType aType, nsISupports* aSheet);
@@ -5153,28 +5153,27 @@ PresShell::CreateRangePaintInfo(nsIDOMRa
   return info;
 }
 
 already_AddRefed<gfxASurface>
 PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
                                nsISelection* aSelection,
                                nsIRegion* aRegion,
                                nsRect aArea,
-                               nsPoint& aPoint,
-                               nsRect* aScreenRect)
+                               nsIntPoint& aPoint,
+                               nsIntRect* aScreenRect)
 {
   nsPresContext* pc = GetPresContext();
   if (!pc || aArea.width == 0 || aArea.height == 0)
     return nsnull;
 
   nsIDeviceContext* deviceContext = pc->DeviceContext();
 
   // use the rectangle to create the surface
-  nsRect pixelArea = aArea;
-  pixelArea.ScaleRoundOut(1.0 / pc->AppUnitsPerDevPixel());
+  nsIntRect pixelArea(nsRect::ToOutsidePixels(aArea, pc->AppUnitsPerDevPixel()));
 
   // if the area of the image is larger than the maximum area, scale it down
   float scale = 0.0;
   nsIntRect rootScreenRect = GetRootFrame()->GetScreenRect();
 
   // if the image is larger in one or both directions than half the size of
   // the available screen area, scale the image down to that size.
   nsRect maxSize;
@@ -5268,18 +5267,18 @@ PresShell::PaintRangePaintInfo(nsTArray<
 
   NS_ADDREF(surface);
   return surface;
 }
 
 already_AddRefed<gfxASurface>
 PresShell::RenderNode(nsIDOMNode* aNode,
                       nsIRegion* aRegion,
-                      nsPoint& aPoint,
-                      nsRect* aScreenRect)
+                      nsIntPoint& aPoint,
+                      nsIntRect* aScreenRect)
 {
   // area will hold the size of the surface needed to draw the node, measured
   // from the root frame.
   nsRect area;
   nsTArray<nsAutoPtr<RangePaintInfo> > rangeItems;
 
   // nothing to draw if the node isn't in a document
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
@@ -5293,22 +5292,21 @@ PresShell::RenderNode(nsIDOMNode* aNode,
   RangePaintInfo* info = CreateRangePaintInfo(range, area);
   if (info && !rangeItems.AppendElement(info)) {
     delete info;
     return nsnull;
   }
 
   if (aRegion) {
     // combine the area with the supplied region
-    nsRect rrectPixels;
+    nsIntRect rrectPixels;
     aRegion->GetBoundingBox(&rrectPixels.x, &rrectPixels.y,
                             &rrectPixels.width, &rrectPixels.height);
 
-    nsRect rrect = rrectPixels;
-    rrect.ScaleRoundOut(nsPresContext::AppUnitsPerCSSPixel());
+    nsRect rrect(nsIntRect::ToAppUnits(rrectPixels, nsPresContext::AppUnitsPerCSSPixel()));
     area.IntersectRect(area, rrect);
     
     nsPresContext* pc = GetPresContext();
     if (!pc)
       return nsnull;
 
     // move the region so that it is offset from the topleft corner of the surface
     aRegion->Offset(-rrectPixels.x + (rrectPixels.x - pc->AppUnitsToDevPixels(area.x)),
@@ -5316,18 +5314,18 @@ PresShell::RenderNode(nsIDOMNode* aNode,
   }
 
   return PaintRangePaintInfo(&rangeItems, nsnull, aRegion, area, aPoint,
                              aScreenRect);
 }
 
 already_AddRefed<gfxASurface>
 PresShell::RenderSelection(nsISelection* aSelection,
-                           nsPoint& aPoint,
-                           nsRect* aScreenRect)
+                           nsIntPoint& aPoint,
+                           nsIntRect* aScreenRect)
 {
   // area will hold the size of the surface needed to draw the selection,
   // measured from the root frame.
   nsRect area;
   nsTArray<nsAutoPtr<RangePaintInfo> > rangeItems;
 
   // iterate over each range and collect them into the rangeItems array.
   // This is done so that the size of selection can be determined so as
@@ -6704,16 +6702,47 @@ LogVerifyMessage(nsIFrame* k1, nsIFrame*
     fputs(NS_LossyConvertUTF16toASCII(name).get(), stdout);
     fprintf(stdout, " %p ", (void*)k2);
   }
   printf("{%d, %d, %d, %d}\n", r2.x, r2.y, r2.width, r2.height);
 
   printf("  %s\n", aMsg);
 }
 
+static void
+LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg,
+                 const nsIntRect& r1, const nsIntRect& r2)
+{
+  printf("VerifyReflow Error:\n");
+  nsAutoString name;
+  nsIFrameDebug*  frameDebug;
+
+  if (NS_SUCCEEDED(k1->QueryInterface(NS_GET_IID(nsIFrameDebug),
+                                      (void**)&frameDebug))) {
+    fprintf(stdout, "  ");
+    frameDebug->GetFrameName(name);
+    fputs(NS_LossyConvertUTF16toASCII(name).get(), stdout);
+    fprintf(stdout, " %p ", (void*)k1);
+  }
+  printf("{%d, %d, %d, %d}", r1.x, r1.y, r1.width, r1.height);
+
+  printf(" != \n");
+
+  if (NS_SUCCEEDED(k2->QueryInterface(NS_GET_IID(nsIFrameDebug),
+                                      (void**)&frameDebug))) {
+    fprintf(stdout, "  ");
+    frameDebug->GetFrameName(name);
+    fputs(NS_LossyConvertUTF16toASCII(name).get(), stdout);
+    fprintf(stdout, " %p ", (void*)k2);
+  }
+  printf("{%d, %d, %d, %d}\n", r2.x, r2.y, r2.width, r2.height);
+
+  printf("  %s\n", aMsg);
+}
+
 static PRBool
 CompareTrees(nsPresContext* aFirstPresContext, nsIFrame* aFirstFrame, 
              nsPresContext* aSecondPresContext, nsIFrame* aSecondFrame)
 {
   if (!aFirstPresContext || !aFirstFrame || !aSecondPresContext || !aSecondFrame)
     return PR_TRUE;
   // XXX Evil hack to reduce false positives; I can't seem to figure
   // out how to flush scrollbar changes correctly
@@ -6731,17 +6760,17 @@ CompareTrees(nsPresContext* aFirstPresCo
       ok = PR_FALSE;
       LogVerifyMessage(k1, k2, "child counts don't match: ");
       printf("%d != %d\n", l1, l2);
       if (0 == (VERIFY_REFLOW_ALL & gVerifyReflowFlags)) {
         break;
       }
     }
 
-    nsRect r1, r2;
+    nsIntRect r1, r2;
     nsIView* v1, *v2;
     for (;;) {
       if (((nsnull == k1) && (nsnull != k2)) ||
           ((nsnull != k1) && (nsnull == k2))) {
         ok = PR_FALSE;
         LogVerifyMessage(k1, k2, "child lists are different\n");
         break;
       }
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -67,22 +67,22 @@ class nsBulletListener : public nsStubIm
 public:
   nsBulletListener();
   virtual ~nsBulletListener();
 
   NS_DECL_ISUPPORTS
   // imgIDecoderObserver (override nsStubImageDecoderObserver)
   NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
   NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame,
-                             const nsRect *aRect);
+                             const nsIntRect *aRect);
   NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status,
                           const PRUnichar *statusArg);
   // imgIContainerObserver (override nsStubImageDecoderObserver)
   NS_IMETHOD FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe,
-                          nsRect * dirtyRect);
+                          nsIntRect *dirtyRect);
 
   void SetFrame(nsBulletFrame *frame) { mFrame = frame; }
 
 private:
   nsBulletFrame *mFrame;
 };
 
 
@@ -1457,17 +1457,17 @@ NS_IMETHODIMP nsBulletFrame::OnStartCont
   aImage->StartAnimation();
 
   
   return NS_OK;
 }
 
 NS_IMETHODIMP nsBulletFrame::OnDataAvailable(imgIRequest *aRequest,
                                              gfxIImageFrame *aFrame,
-                                             const nsRect *aRect)
+                                             const nsIntRect *aRect)
 {
   // The image has changed.
   // Invalidate the entire content area. Maybe it's not optimal but it's simple and
   // always correct, and I'll be a stunned mullet if it ever matters for performance
   Invalidate(nsRect(0, 0, mRect.width, mRect.height));
 
   return NS_OK;
 }
@@ -1488,17 +1488,17 @@ NS_IMETHODIMP nsBulletFrame::OnStopDecod
   }
 #endif
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsBulletFrame::FrameChanged(imgIContainer *aContainer,
                                           gfxIImageFrame *aNewFrame,
-                                          nsRect *aDirtyRect)
+                                          nsIntRect *aDirtyRect)
 {
   // Invalidate the entire content area. Maybe it's not optimal but it's simple and
   // always correct.
   Invalidate(nsRect(0, 0, mRect.width, mRect.height));
 
   return NS_OK;
 }
 
@@ -1546,17 +1546,17 @@ NS_IMETHODIMP nsBulletListener::OnStartC
   if (!mFrame)
     return NS_ERROR_FAILURE;
 
   return mFrame->OnStartContainer(aRequest, aImage);
 }
 
 NS_IMETHODIMP nsBulletListener::OnDataAvailable(imgIRequest *aRequest,
                                                 gfxIImageFrame *aFrame,
-                                                const nsRect *aRect)
+                                                const nsIntRect *aRect)
 {
   if (!mFrame)
     return NS_ERROR_FAILURE;
 
   return mFrame->OnDataAvailable(aRequest, aFrame, aRect);
 }
 
 NS_IMETHODIMP nsBulletListener::OnStopDecode(imgIRequest *aRequest,
@@ -1566,15 +1566,15 @@ NS_IMETHODIMP nsBulletListener::OnStopDe
   if (!mFrame)
     return NS_ERROR_FAILURE;
   
   return mFrame->OnStopDecode(aRequest, status, statusArg);
 }
 
 NS_IMETHODIMP nsBulletListener::FrameChanged(imgIContainer *aContainer,
                                              gfxIImageFrame *newframe,
-                                             nsRect * dirtyRect)
+                                             nsIntRect *dirtyRect)
 {
   if (!mFrame)
     return NS_ERROR_FAILURE;
 
   return mFrame->FrameChanged(aContainer, newframe, dirtyRect);
 }
--- a/layout/generic/nsBulletFrame.h
+++ b/layout/generic/nsBulletFrame.h
@@ -77,23 +77,23 @@ public:
 
   // nsBulletFrame
   PRInt32 SetListItemOrdinal(PRInt32 aNextOrdinal, PRBool* aChanged);
 
 
   NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
   NS_IMETHOD OnDataAvailable(imgIRequest *aRequest,
                              gfxIImageFrame *aFrame,
-                             const nsRect * rect);
+                             const nsIntRect *aRect);
   NS_IMETHOD OnStopDecode(imgIRequest *aRequest,
                           nsresult aStatus,
                           const PRUnichar *aStatusArg);
   NS_IMETHOD FrameChanged(imgIContainer *aContainer,
                           gfxIImageFrame *aNewframe,
-                          nsRect *aDirtyRect);
+                          nsIntRect *aDirtyRect);
 
   /* get list item text, without '.' */
   static PRBool AppendCounterText(PRInt32 aListStyleType,
                                   PRInt32 aOrdinal,
                                   nsString& aResult);
 
   /* get list item text, with '.' */
   PRBool GetListItemText(const nsStyleList& aStyleList,
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -579,26 +579,25 @@ nsIFrame::GetUsedBorder() const
                "cannot call GetUsedBorder on a dirty frame not currently "
                "being reflowed");
 
   // Theme methods don't use const-ness.
   nsIFrame *mutable_this = const_cast<nsIFrame*>(this);
 
   const nsStyleDisplay *disp = GetStyleDisplay();
   if (mutable_this->IsThemed(disp)) {
-    nsMargin result;
+    nsIntMargin result;
     nsPresContext *presContext = PresContext();
     presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
                                              mutable_this, disp->mAppearance,
                                              &result);
-    result.top = presContext->DevPixelsToAppUnits(result.top);
-    result.right = presContext->DevPixelsToAppUnits(result.right);
-    result.bottom = presContext->DevPixelsToAppUnits(result.bottom);
-    result.left = presContext->DevPixelsToAppUnits(result.left);
-    return result;
+    return nsMargin(presContext->DevPixelsToAppUnits(result.top),
+                    presContext->DevPixelsToAppUnits(result.right),
+                    presContext->DevPixelsToAppUnits(result.bottom),
+                    presContext->DevPixelsToAppUnits(result.left));
   }
 
   return GetStyleBorder()->GetActualBorder();
 }
 
 /* virtual */ nsMargin
 nsIFrame::GetUsedPadding() const
 {
@@ -611,24 +610,25 @@ nsIFrame::GetUsedPadding() const
   nsMargin padding(0, 0, 0, 0);
 
   // Theme methods don't use const-ness.
   nsIFrame *mutable_this = const_cast<nsIFrame*>(this);
 
   const nsStyleDisplay *disp = GetStyleDisplay();
   if (mutable_this->IsThemed(disp)) {
     nsPresContext *presContext = PresContext();
+    nsIntMargin widget;
     if (presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(),
                                                   mutable_this,
                                                   disp->mAppearance,
-                                                  &padding)) {
-      padding.top = presContext->DevPixelsToAppUnits(padding.top);
-      padding.right = presContext->DevPixelsToAppUnits(padding.right);
-      padding.bottom = presContext->DevPixelsToAppUnits(padding.bottom);
-      padding.left = presContext->DevPixelsToAppUnits(padding.left);
+                                                  &widget)) {
+      padding.top = presContext->DevPixelsToAppUnits(widget.top);
+      padding.right = presContext->DevPixelsToAppUnits(widget.right);
+      padding.bottom = presContext->DevPixelsToAppUnits(widget.bottom);
+      padding.left = presContext->DevPixelsToAppUnits(widget.left);
       return padding;
     }
   }
   if (!GetStylePadding()->GetPadding(padding)) {
     nsMargin *p = static_cast<nsMargin*>
                              (GetProperty(nsGkAtoms::usedPaddingProperty));
     NS_ASSERTION(p, "used padding property missing (out of memory?)");
     if (p) {
@@ -811,19 +811,19 @@ void nsDisplaySelectionOverlay::Paint(ns
   gfxRGBA c(color);
   c.a = .5;
 
   gfxContext *ctx = aCtx->ThebesContext();
   ctx->SetColor(c);
 
   nsRect rect(aBuilder->ToReferenceFrame(mFrame), mFrame->GetSize());
   rect.IntersectRect(rect, aDirtyRect);
-  rect.ScaleRoundOut(1.0f / mFrame->PresContext()->AppUnitsPerDevPixel());
+  nsIntRect pxRect(nsRect::ToOutsidePixels(rect, mFrame->PresContext()->AppUnitsPerDevPixel()));
   ctx->NewPath();
-  ctx->Rectangle(gfxRect(rect.x, rect.y, rect.width, rect.height), PR_TRUE);
+  ctx->Rectangle(gfxRect(pxRect.x, pxRect.y, pxRect.width, pxRect.height), PR_TRUE);
   ctx->Fill();
 }
 
 /********************************************************
 * Refreshes each content's frame
 *********************************************************/
 
 nsresult
@@ -3062,23 +3062,23 @@ nsFrame::IntrinsicWidthOffsets(nsIRender
   const nsStyleBorder *styleBorder = GetStyleBorder();
   result.hBorder += styleBorder->GetActualBorderWidth(NS_SIDE_LEFT);
   result.hBorder += styleBorder->GetActualBorderWidth(NS_SIDE_RIGHT);
 
   const nsStyleDisplay *disp = GetStyleDisplay();
   if (IsThemed(disp)) {
     nsPresContext *presContext = PresContext();
 
-    nsMargin border;
+    nsIntMargin border;
     presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
                                              this, disp->mAppearance,
                                              &border);
     result.hBorder = presContext->DevPixelsToAppUnits(border.LeftRight());
 
-    nsMargin padding;
+    nsIntMargin padding;
     if (presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(),
                                                   this, disp->mAppearance,
                                                   &padding)) {
       result.hPadding = presContext->DevPixelsToAppUnits(padding.LeftRight());
       result.hPctPadding = 0;
     }
   }
 
@@ -3179,25 +3179,26 @@ nsFrame::ComputeSize(nsIRenderingContext
         boxSizingAdjust.height;
       if (minHeight > result.height)
         result.height = minHeight;
     }
   }
 
   const nsStyleDisplay *disp = GetStyleDisplay();
   if (IsThemed(disp)) {
-    nsSize size(0, 0);
+    nsIntSize widget(0, 0);
     PRBool canOverride = PR_TRUE;
     nsPresContext *presContext = PresContext();
     presContext->GetTheme()->
       GetMinimumWidgetSize(aRenderingContext, this, disp->mAppearance,
-                           &size, &canOverride);
-
-    size.width = presContext->DevPixelsToAppUnits(size.width);
-    size.height = presContext->DevPixelsToAppUnits(size.height);
+                           &widget, &canOverride);
+
+    nsSize size;
+    size.width = presContext->DevPixelsToAppUnits(widget.width);
+    size.height = presContext->DevPixelsToAppUnits(widget.height);
 
     // GMWS() returns border-box; we need content-box
     size.width -= aBorder.width + aPadding.width;
     size.height -= aBorder.height + aPadding.height;
 
     if (size.height > result.height || !canOverride)
       result.height = size.height;
     if (size.width > result.width || !canOverride)
@@ -3544,19 +3545,17 @@ nsPoint nsIFrame::GetOffsetTo(const nsIF
 // virtual
 nsIntRect nsIFrame::GetScreenRectExternal() const
 {
   return GetScreenRect();
 }
 
 nsIntRect nsIFrame::GetScreenRect() const
 {
-  nsRect r = GetScreenRectInAppUnits().ScaleRoundOutInverse(PresContext()->AppUnitsPerDevPixel());
-  // nsRect and nsIntRect are not necessarily the same
-  return nsIntRect(r.x, r.y, r.width, r.height);
+  return nsRect::ToOutsidePixels(GetScreenRectInAppUnits(), PresContext()->AppUnitsPerDevPixel());
 }
 
 // virtual
 nsRect nsIFrame::GetScreenRectInAppUnitsExternal() const
 {
   return GetScreenRectInAppUnits();
 }
 
@@ -3566,17 +3565,16 @@ nsRect nsIFrame::GetScreenRectInAppUnits
   nsPoint toViewOffset(0,0);
   nsIView* view = GetClosestView(&toViewOffset);
 
   if (view) {
     nsPoint toWidgetOffset(0,0);
     nsIWidget* widget = view->GetNearestWidget(&toWidgetOffset);
 
     if (widget) {
-      // WidgetToScreen really should take nsIntRect, not nsRect
       nsIntRect localRect(0,0,0,0), screenRect;
       widget->WidgetToScreen(localRect, screenRect);
 
       retval = mRect;
       retval.MoveTo(toViewOffset + toWidgetOffset);
       retval.x += PresContext()->DevPixelsToAppUnits(screenRect.x);
       retval.y += PresContext()->DevPixelsToAppUnits(screenRect.y);
     }
--- a/layout/generic/nsFrameFrame.cpp
+++ b/layout/generic/nsFrameFrame.cpp
@@ -186,17 +186,17 @@ public:
 
   NS_IMETHOD  VerifyTree() const;
 
   // nsIReflowCallback
   virtual PRBool ReflowFinished();
   virtual void ReflowCallbackCanceled();
 
 protected:
-  nsSize GetMargin();
+  nsIntSize GetMargin();
   PRBool IsInline() { return mIsInline; }
   nsresult ShowDocShell();
   nsresult CreateViewAndWidget(nsContentType aContentType);
 
   virtual nscoord GetIntrinsicWidth();
   virtual nscoord GetIntrinsicHeight();
 
   virtual PRIntn GetSkipSides() const;
@@ -798,19 +798,19 @@ nsSubDocumentFrame::HideViewer()
       baseWin->SetVisibility(PR_FALSE);
 
       // Clear out the parentWidget, since it might be about to die with us
       baseWin->SetParentWidget(nsnull);
     }
   }
 }
 
-nsSize nsSubDocumentFrame::GetMargin()
+nsIntSize nsSubDocumentFrame::GetMargin()
 {
-  nsSize result(-1, -1);
+  nsIntSize result(-1, -1);
   nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent);
   if (content) {
     const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::marginwidth);
     if (attr && attr->Type() == nsAttrValue::eInteger)
       result.width = attr->GetIntegerValue();
     attr = content->GetParsedAttr(nsGkAtoms::marginheight);
     if (attr && attr->Type() == nsAttrValue::eInteger)
       result.height = attr->GetIntegerValue();
@@ -914,17 +914,17 @@ nsSubDocumentFrame::ShowDocShell()
   if (presShell) {
     // The docshell is already showing, nothing left to do...
     NS_ASSERTION(mInnerView, "What's going on?");
     return NS_OK;
   }
 
   // pass along marginwidth, marginheight, scrolling so sub document
   // can use it
-  nsSize margin = GetMargin();
+  nsIntSize margin(GetMargin());
   docShell->SetMarginWidth(margin.width);
   docShell->SetMarginHeight(margin.height);
 
   // Current and initial scrolling is set so that all succeeding docs
   // will use the scrolling value set here, regardless if scrolling is
   // set by viewing a particular document (e.g. XUL turns off scrolling)
   nsCOMPtr<nsIScrollable> sc(do_QueryInterface(docShell));
 
--- a/layout/generic/nsFrameSetFrame.cpp
+++ b/layout/generic/nsFrameSetFrame.cpp
@@ -739,41 +739,42 @@ nsHTMLFramesetFrame* nsHTMLFramesetFrame
   }
 
   return parent;
 }
 
 // only valid for non border children
 void nsHTMLFramesetFrame::GetSizeOfChildAt(PRInt32  aIndexInParent, 
                                            nsSize&  aSize, 
-                                           nsPoint& aCellIndex)
+                                           nsIntPoint& aCellIndex)
 {
   PRInt32 row = aIndexInParent / mNumCols;
   PRInt32 col = aIndexInParent - (row * mNumCols); // remainder from dividing index by mNumCols
   if ((row < mNumRows) && (col < mNumCols)) {
     aSize.width  = mColSizes[col];
     aSize.height = mRowSizes[row];
     aCellIndex.x = col;
     aCellIndex.y = row;
   } else {
-    aSize.width = aSize.height = aCellIndex.x = aCellIndex.y = 0;
+    aSize.width = aSize.height = 0;
+    aCellIndex.x = aCellIndex.y = 0;
   }
 }
 
 // only valid for non border children
 void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild, 
                                          nsSize&   aSize)
 {
   // Reflow only creates children frames for <frameset> and <frame> content.
   // this assumption is used here
   int i = 0;
   for (nsIFrame* child = mFrames.FirstChild(); child;
        child = child->GetNextSibling()) {
     if (aChild == child) {
-      nsPoint ignore;
+      nsIntPoint ignore;
       GetSizeOfChildAt(i, aSize, ignore);
       return;
     }
     i++;
   }
   aSize.width  = 0;
   aSize.height = 0;
 }  
@@ -858,17 +859,17 @@ nsHTMLFramesetFrame::BuildDisplayList(ns
 }
 
 void 
 nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame*                aChild,
                                       nsPresContext*          aPresContext,
                                       const nsHTMLReflowState& aReflowState,
                                       nsPoint&                 aOffset,
                                       nsSize&                  aSize,
-                                      nsPoint*                 aCellIndex)
+                                      nsIntPoint*              aCellIndex)
 {
   // reflow the child
   nsHTMLReflowState  reflowState(aPresContext, aReflowState, aChild, aSize);
   nsHTMLReflowMetrics metrics;
   metrics.width = aSize.width;
   metrics.height= aSize.height;
   nsReflowStatus status;
   
@@ -1063,17 +1064,17 @@ nsHTMLFramesetFrame::Reflow(nsPresContex
   PRInt32 borderChildX = mNonBorderChildCount; // index of border children
   nsHTMLFramesetBorderFrame* borderFrame = nsnull;
   nsPoint offset(0,0);
   nsSize size, lastSize;
   nsIFrame* child = mFrames.FirstChild();
   nsIFrame* lastChild = mFrames.LastChild();
 
   for (PRInt32 childX = 0; childX < mNonBorderChildCount; childX++) {
-    nsPoint cellIndex;
+    nsIntPoint cellIndex;
     GetSizeOfChildAt(childX, size, cellIndex);
 
     if (lastRow != cellIndex.y) {  // changed to next row
       offset.x = 0;
       offset.y += lastSize.height;
       if (firstTime) { // create horizontal border
 
         nsRefPtr<nsStyleContext> pseudoStyleContext;
--- a/layout/generic/nsFrameSetFrame.h
+++ b/layout/generic/nsFrameSetFrame.h
@@ -122,17 +122,17 @@ public:
                   nsIFrame*        aPrevInFlow);
 
   static PRBool  gDragInProgress;
 
   void GetSizeOfChild(nsIFrame* aChild, nsSize& aSize);
 
   void GetSizeOfChildAt(PRInt32  aIndexInParent, 
                         nsSize&  aSize, 
-                        nsPoint& aCellIndex);
+                        nsIntPoint& aCellIndex);
 
   static nsHTMLFramesetFrame* GetFramesetParent(nsIFrame* aChild);
 
   NS_IMETHOD HandleEvent(nsPresContext* aPresContext, 
                          nsGUIEvent*     aEvent,
                          nsEventStatus*  aEventStatus);
 
   NS_IMETHOD GetCursor(const nsPoint&    aPoint,
@@ -220,17 +220,17 @@ protected:
   
   virtual PRIntn GetSkipSides() const;
 
   void ReflowPlaceChild(nsIFrame*                aChild,
                         nsPresContext*          aPresContext,
                         const nsHTMLReflowState& aReflowState,
                         nsPoint&                 aOffset,
                         nsSize&                  aSize,
-                        nsPoint*                 aCellIndex = 0);
+                        nsIntPoint*              aCellIndex = 0);
   
   PRBool CanResize(PRBool aVertical, 
                    PRBool aLeft); 
 
   PRBool CanChildResize(PRBool  aVertical, 
                         PRBool  aLeft, 
                         PRInt32 aChildX,
                         PRBool  aFrameset);
@@ -251,17 +251,17 @@ protected:
   PRInt32          mEdgeVisibility;
   nsBorderColor    mEdgeColors;
   nsFrameborder    mParentFrameborder;
   nscolor          mParentBorderColor;
   PRInt32          mParentBorderWidth;
 
   nsHTMLFramesetBorderFrame* mDragger;
   nsFramesetDrag   mDrag;
-  nsPoint          mFirstDragPoint;
+  nsIntPoint       mFirstDragPoint;
   PRInt32          mPrevNeighborOrigSize; // used during resize
   PRInt32          mNextNeighborOrigSize;
   PRInt32          mMinDrag;
   PRInt32          mChildCount;
   nsHTMLFramesetFrame* mTopLevelFrameset;
   nsHTMLFramesetBorderFrame** mVerBorders;  // vertical borders
   nsHTMLFramesetBorderFrame** mHorBorders;  // horizontal borders
 
--- a/layout/generic/nsHTMLCanvasFrame.cpp
+++ b/layout/generic/nsHTMLCanvasFrame.cpp
@@ -54,34 +54,34 @@ NS_NewHTMLCanvasFrame(nsIPresShell* aPre
 {
   return new (aPresShell) nsHTMLCanvasFrame(aContext);
 }
 
 nsHTMLCanvasFrame::~nsHTMLCanvasFrame()
 {
 }
 
-nsSize
+nsIntSize
 nsHTMLCanvasFrame::GetCanvasSize()
 {
   PRUint32 w, h;
   nsresult rv;
   nsCOMPtr<nsICanvasElement> canvas(do_QueryInterface(GetContent()));
   if (canvas) {
     rv = canvas->GetSize(&w, &h);
   } else {
     rv = NS_ERROR_NULL_POINTER;
   }
 
   if (NS_FAILED(rv)) {
     NS_NOTREACHED("couldn't get canvas size");
     h = w = 1;
   }
 
-  return nsSize(w, h);
+  return nsIntSize(w, h);
 }
 
 /* virtual */ nscoord
 nsHTMLCanvasFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
 {
   // XXX The caller doesn't account for constraints of the height,
   // min-height, and max-height properties.
   nscoord result = nsPresContext::CSSPixelsToAppUnits(GetCanvasSize().width);
@@ -97,32 +97,34 @@ nsHTMLCanvasFrame::GetPrefWidth(nsIRende
   nscoord result = nsPresContext::CSSPixelsToAppUnits(GetCanvasSize().width);
   DISPLAY_PREF_WIDTH(this, result);
   return result;
 }
 
 /* virtual */ nsSize
 nsHTMLCanvasFrame::GetIntrinsicRatio()
 {
-  return GetCanvasSize();
+  nsIntSize size(GetCanvasSize());
+  return nsSize(nsPresContext::CSSPixelsToAppUnits(size.width),
+                nsPresContext::CSSPixelsToAppUnits(size.height));
 }
 
 /* virtual */ nsSize
 nsHTMLCanvasFrame::ComputeSize(nsIRenderingContext *aRenderingContext,
                                nsSize aCBSize, nscoord aAvailableWidth,
                                nsSize aMargin, nsSize aBorder, nsSize aPadding,
                                PRBool aShrinkWrap)
 {
-  nsSize size = GetCanvasSize();
+  nsIntSize size(GetCanvasSize());
 
   IntrinsicSize intrinsicSize;
   intrinsicSize.width.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(size.width));
   intrinsicSize.height.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(size.height));
 
-  nsSize& intrinsicRatio = size; // won't actually be used
+  nsSize intrinsicRatio(size.width, size.height); // won't actually be used
 
   return nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
                             aRenderingContext, this,
                             intrinsicSize, intrinsicRatio, aCBSize,
                             aMargin, aBorder, aPadding);
 }
 
 NS_IMETHODIMP
@@ -192,17 +194,17 @@ nsHTMLCanvasFrame::PaintCanvas(nsIRender
   nsCOMPtr<nsICanvasElement> canvas(do_QueryInterface(GetContent()));
   if (!canvas)
     return;
 
   // anything to do?
   if (inner.width == 0 || inner.height == 0)
     return;
 
-  nsSize canvasSize = GetCanvasSize();
+  nsIntSize canvasSize(GetCanvasSize());
   nsSize sizeAppUnits(PresContext()->DevPixelsToAppUnits(canvasSize.width),
                       PresContext()->DevPixelsToAppUnits(canvasSize.height));
 
   // XXXvlad clip to aDirtyRect!
 
   if (inner.Size() != sizeAppUnits)
   {
     float sx = inner.width / (float) sizeAppUnits.width;
--- a/layout/generic/nsHTMLCanvasFrame.h
+++ b/layout/generic/nsHTMLCanvasFrame.h
@@ -56,17 +56,17 @@ public:
   NS_IMETHOD BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                               const nsRect&           aDirtyRect,
                               const nsDisplayListSet& aLists);
 
   void PaintCanvas(nsIRenderingContext& aRenderingContext,
                    const nsRect& aDirtyRect, nsPoint aPt);
                               
   /* get the size of the canvas's image */
-  nsSize GetCanvasSize();
+  nsIntSize GetCanvasSize();
 
   virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext);
   virtual nscoord GetPrefWidth(nsIRenderingContext *aRenderingContext);
   virtual nsSize GetIntrinsicRatio();
 
   virtual nsSize ComputeSize(nsIRenderingContext *aRenderingContext,
                              nsSize aCBSize, nscoord aAvailableWidth,
                              nsSize aMargin, nsSize aBorder, nsSize aPadding,
--- a/layout/generic/nsHTMLReflowState.cpp
+++ b/layout/generic/nsHTMLReflowState.cpp
@@ -1824,47 +1824,49 @@ nsCSSOffsetState::InitOffsets(nscoord aC
   // XXX fix to provide 0,0 for the top&bottom margins for
   // inline-non-replaced elements
   ComputeMargin(aContainingBlockWidth);
 
   const nsStyleDisplay *disp = frame->GetStyleDisplay();
   PRBool isThemed = frame->IsThemed(disp);
   nsPresContext *presContext = frame->PresContext();
 
+  nsIntMargin widget;
   if (isThemed &&
       presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(),
                                                 frame, disp->mAppearance,
-                                                &mComputedPadding)) {
-    mComputedPadding.top = presContext->DevPixelsToAppUnits(mComputedPadding.top);
-    mComputedPadding.right = presContext->DevPixelsToAppUnits(mComputedPadding.right);
-    mComputedPadding.bottom = presContext->DevPixelsToAppUnits(mComputedPadding.bottom);
-    mComputedPadding.left = presContext->DevPixelsToAppUnits(mComputedPadding.left);
+                                                &widget)) {
+    mComputedPadding.top = presContext->DevPixelsToAppUnits(widget.top);
+    mComputedPadding.right = presContext->DevPixelsToAppUnits(widget.right);
+    mComputedPadding.bottom = presContext->DevPixelsToAppUnits(widget.bottom);
+    mComputedPadding.left = presContext->DevPixelsToAppUnits(widget.left);
   }
   else if (aPadding) { // padding is an input arg
     mComputedPadding.top    = aPadding->top;
     mComputedPadding.right  = aPadding->right;
     mComputedPadding.bottom = aPadding->bottom;
     mComputedPadding.left   = aPadding->left;
   }
   else {
     ComputePadding(aContainingBlockWidth);
   }
 
   if (isThemed) {
+    nsIntMargin widget;
     presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
                                              frame, disp->mAppearance,
-                                             &mComputedBorderPadding);
+                                             &widget);
     mComputedBorderPadding.top =
-      presContext->DevPixelsToAppUnits(mComputedBorderPadding.top);
+      presContext->DevPixelsToAppUnits(widget.top);
     mComputedBorderPadding.right =
-      presContext->DevPixelsToAppUnits(mComputedBorderPadding.right);
+      presContext->DevPixelsToAppUnits(widget.right);
     mComputedBorderPadding.bottom =
-      presContext->DevPixelsToAppUnits(mComputedBorderPadding.bottom);
+      presContext->DevPixelsToAppUnits(widget.bottom);
     mComputedBorderPadding.left =
-      presContext->DevPixelsToAppUnits(mComputedBorderPadding.left);
+      presContext->DevPixelsToAppUnits(widget.left);
   }
   else if (aBorder) {  // border is an input arg
     mComputedBorderPadding = *aBorder;
   }
   else {
     mComputedBorderPadding = frame->GetStyleBorder()->GetActualBorder();
   }
   mComputedBorderPadding += mComputedPadding;
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -298,17 +298,17 @@ nsImageFrame::Init(nsIContent*      aCon
 PRBool
 nsImageFrame::UpdateIntrinsicSize(imgIContainer* aImage)
 {
   NS_PRECONDITION(aImage, "null image");
 
   PRBool intrinsicSizeChanged = PR_FALSE;
   
   if (aImage) {
-    nsSize imageSizeInPx;
+    nsIntSize imageSizeInPx;
     aImage->GetWidth(&imageSizeInPx.width);
     aImage->GetHeight(&imageSizeInPx.height);
     nsSize newSize(nsPresContext::CSSPixelsToAppUnits(imageSizeInPx.width),
                    nsPresContext::CSSPixelsToAppUnits(imageSizeInPx.height));
     if (mIntrinsicSize != newSize) {
       intrinsicSizeChanged = PR_TRUE;
       mIntrinsicSize = newSize;
     }
@@ -382,17 +382,17 @@ nsImageFrame::IsPendingLoad(imgIContaine
   nsCOMPtr<imgIContainer> currentContainer;
   currentRequest->GetImage(getter_AddRefs(currentContainer));
 
   return currentContainer != aContainer;
   
 }
 
 nsRect
-nsImageFrame::SourceRectToDest(const nsRect& aRect)
+nsImageFrame::SourceRectToDest(const nsIntRect& aRect)
 {
   // When scaling the image, row N of the source image may (depending on
   // the scaling function) be used to draw any row in the destination image
   // between floor(F * (N-1)) and ceil(F * (N+1)), where F is the
   // floating-point scaling factor.  The same holds true for columns.
   // So, we start by computing that bound without the floor and ceiling.
 
   nsRect r(nsPresContext::CSSPixelsToAppUnits(aRect.x - 1),
@@ -527,17 +527,17 @@ nsImageFrame::OnStartContainer(imgIReque
   }
 
   return NS_OK;
 }
 
 nsresult
 nsImageFrame::OnDataAvailable(imgIRequest *aRequest,
                               gfxIImageFrame *aFrame,
-                              const nsRect *aRect)
+                              const nsIntRect *aRect)
 {
   // XXX do we need to make sure that the reflow from the
   // OnStartContainer has been processed before we start calling
   // invalidate?
 
   NS_ENSURE_ARG_POINTER(aRect);
 
   if (!(mState & IMAGE_GOTINITIALREFLOW)) {
@@ -639,17 +639,17 @@ nsImageFrame::OnStopDecode(imgIRequest *
   }
 
   return NS_OK;
 }
 
 nsresult
 nsImageFrame::FrameChanged(imgIContainer *aContainer,
                            gfxIImageFrame *aNewFrame,
-                           nsRect *aDirtyRect)
+                           nsIntRect *aDirtyRect)
 {
   if (!GetStyleVisibility()->IsVisible()) {
     return NS_OK;
   }
 
   if (IsPendingLoad(aContainer)) {
     // We don't care about it
     return NS_OK;
@@ -1833,17 +1833,17 @@ NS_IMETHODIMP nsImageListener::OnStartCo
   if (!mFrame)
     return NS_ERROR_FAILURE;
 
   return mFrame->OnStartContainer(aRequest, aImage);
 }
 
 NS_IMETHODIMP nsImageListener::OnDataAvailable(imgIRequest *aRequest,
                                                gfxIImageFrame *aFrame,
-                                               const nsRect *aRect)
+                                               const nsIntRect *aRect)
 {
   if (!mFrame)
     return NS_ERROR_FAILURE;
 
   return mFrame->OnDataAvailable(aRequest, aFrame, aRect);
 }
 
 NS_IMETHODIMP nsImageListener::OnStopDecode(imgIRequest *aRequest,
@@ -1853,17 +1853,17 @@ NS_IMETHODIMP nsImageListener::OnStopDec
   if (!mFrame)
     return NS_ERROR_FAILURE;
 
   return mFrame->OnStopDecode(aRequest, status, statusArg);
 }
 
 NS_IMETHODIMP nsImageListener::FrameChanged(imgIContainer *aContainer,
                                             gfxIImageFrame *newframe,
-                                            nsRect * dirtyRect)
+                                            nsIntRect * dirtyRect)
 {
   if (!mFrame)
     return NS_ERROR_FAILURE;
 
   return mFrame->FrameChanged(aContainer, newframe, dirtyRect);
 }
 
 static PRBool
--- a/layout/generic/nsImageFrame.h
+++ b/layout/generic/nsImageFrame.h
@@ -69,22 +69,22 @@ class nsImageListener : public nsStubIma
 public:
   nsImageListener(nsImageFrame *aFrame);
   virtual ~nsImageListener();
 
   NS_DECL_ISUPPORTS
   // imgIDecoderObserver (override nsStubImageDecoderObserver)
   NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
   NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame,
-                             const nsRect *aRect);
+                             const nsIntRect *aRect);
   NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status,
                           const PRUnichar *statusArg);
   // imgIContainerObserver (override nsStubImageDecoderObserver)
   NS_IMETHOD FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe,
-                          nsRect * dirtyRect);
+                          nsIntRect * dirtyRect);
 
   void SetFrame(nsImageFrame *frame) { mFrame = frame; }
 
 private:
   nsImageFrame *mFrame;
 };
 
 #define IMAGE_SIZECONSTRAINED       0x00100000
@@ -220,23 +220,23 @@ protected:
   void PaintImage(nsIRenderingContext& aRenderingContext, nsPoint aPt,
                   const nsRect& aDirtyRect, imgIContainer* aImage);
                   
 protected:
   friend class nsImageListener;
   nsresult OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
   nsresult OnDataAvailable(imgIRequest *aRequest,
                            gfxIImageFrame *aFrame,
-                           const nsRect * rect);
+                           const nsIntRect *rect);
   nsresult OnStopDecode(imgIRequest *aRequest,
                         nsresult aStatus,
                         const PRUnichar *aStatusArg);
   nsresult FrameChanged(imgIContainer *aContainer,
                         gfxIImageFrame *aNewframe,
-                        nsRect *aDirtyRect);
+                        nsIntRect *aDirtyRect);
 
 private:
   // random helpers
   inline void SpecToURI(const nsAString& aSpec, nsIIOService *aIOService,
                         nsIURI **aURI);
 
   inline void GetLoadGroup(nsPresContext *aPresContext,
                            nsILoadGroup **aLoadGroup);
@@ -263,17 +263,17 @@ private:
    */
   PRBool IsPendingLoad(imgIRequest* aRequest) const;
   PRBool IsPendingLoad(imgIContainer* aContainer) const;
 
   /**
    * Function to convert a dirty rect in the source image to a dirty
    * rect for the image frame.
    */
-  nsRect SourceRectToDest(const nsRect & aRect);
+  nsRect SourceRectToDest(const nsIntRect & aRect);
 
   nsImageMap*         mImageMap;
 
   nsCOMPtr<imgIDecoderObserver> mListener;
 
   nsSize mComputedSize;
   nsSize mIntrinsicSize;
   nsTransform2D mTransform;
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -518,20 +518,16 @@ private:
     nsIPluginInstance* mInstance;
     const nsIntSize& mPluginSize;
     const nsIntRect& mDirtyRect;
   };
 #endif
 
 };
 
-#if defined(XP_WIN) || (defined(DO_DIRTY_INTERSECT) && defined(XP_MACOSX)) || defined(XP_OS2)
-static void ConvertAppUnitsToPixels(const nsPresContext& aPresContext, const nsRect& aTwipsRect, nsIntRect& aPixelRect);
-#endif
-
   // Mac specific code to fix up port position and clip during paint
 #ifdef XP_MACOSX
 
 #ifdef DO_DIRTY_INTERSECT
   // convert relative coordinates to absolute
   static void ConvertRelativeToWindowAbsolute(nsIFrame* aFrame, nsPoint& aRel, nsPoint& aAbs, nsIWidget *&aContainerWidget);
 #endif
 
@@ -911,17 +907,17 @@ nsObjectFrame::FixupWindow(const nsSize&
   NS_ENSURE_TRUE(window, /**/);
 
 #ifdef XP_MACOSX
   mInstanceOwner->FixUpPluginWindow(ePluginPaintDisable);
 #endif
 
   PRBool windowless = (window->type == nsPluginWindowType_Drawable);
 
-  nsPoint origin = GetWindowOriginInPixels(windowless);
+  nsIntPoint origin = GetWindowOriginInPixels(windowless);
 
   window->x = origin.x;
   window->y = origin.y;
 
   window->width = presContext->AppUnitsToDevPixels(aSize.width);
   window->height = presContext->AppUnitsToDevPixels(aSize.height);
 
   // on the Mac we need to set the clipRect to { 0, 0, 0, 0 } for now. This will keep
@@ -958,17 +954,17 @@ nsObjectFrame::CallSetWindow()
   mInstanceOwner->FixUpPluginWindow(ePluginPaintDisable);
 #endif
 
   if (IsHidden())
     return;
 
   PRBool windowless = (window->type == nsPluginWindowType_Drawable);
 
-  nsPoint origin = GetWindowOriginInPixels(windowless);
+  nsIntPoint origin = GetWindowOriginInPixels(windowless);
 
   window->x = origin.x;
   window->y = origin.y;
 
   // refresh the plugin port as well
   window->window = mInstanceOwner->GetPluginPort();
 
   // this will call pi->SetWindow and take care of window subclassing
@@ -1011,17 +1007,17 @@ nsObjectFrame::IsHidden(PRBool aCheckVis
          !hidden.LowerCaseEqualsLiteral("off")))) {
       return PR_TRUE;
     }
   }
 
   return PR_FALSE;
 }
 
-nsPoint nsObjectFrame::GetWindowOriginInPixels(PRBool aWindowless)
+nsIntPoint nsObjectFrame::GetWindowOriginInPixels(PRBool aWindowless)
 {
   nsIView * parentWithView;
   nsPoint origin(0,0);
 
   GetOffsetFromView(origin, &parentWithView);
 
   // if it's windowless, let's make sure we have our origin set right
   // it may need to be corrected, like after scrolling
@@ -1040,20 +1036,18 @@ nsPoint nsObjectFrame::GetWindowOriginIn
       if (theView->GetViewManager() != parentVM)
         break;
 
       origin += theView->GetPosition();
       theView = theView->GetParent();
     }  
   }
 
-  origin.x = PresContext()->AppUnitsToDevPixels(origin.x);
-  origin.y = PresContext()->AppUnitsToDevPixels(origin.y);
-
-  return origin;
+  return nsIntPoint(PresContext()->AppUnitsToDevPixels(origin.x),
+                    PresContext()->AppUnitsToDevPixels(origin.y));
 }
 
 NS_IMETHODIMP
 nsObjectFrame::DidReflow(nsPresContext*            aPresContext,
                          const nsHTMLReflowState*  aReflowState,
                          nsDidReflowStatus         aStatus)
 {
   // Do this check before calling the superclass, as that clears
@@ -1422,17 +1416,17 @@ nsObjectFrame::PaintPlugin(nsIRenderingC
     if (window->type == nsPluginWindowType_Drawable) {
       // FIXME - Bug 385435: Doesn't aDirtyRect need translating too?
       nsIRenderingContext::AutoPushTranslation
         translate(&aRenderingContext, aFramePt.x, aFramePt.y);
 
       // check if we need to call SetWindow with updated parameters
       PRBool doupdatewindow = PR_FALSE;
       // the offset of the DC
-      nsPoint origin;
+      nsIntPoint origin;
 
       /*
        * Layout now has an optimized way of painting. Now we always get
        * a new drawing surface, sized to be just what's needed. Windowless
        * plugins need a transform applied to their origin so they paint
        * in the right place. Since |SetWindow| is no longer being used
        * to tell the plugin where it is, we dispatch a NPWindow through
        * |HandleEvent| to tell the plugin when its window moved
@@ -1516,17 +1510,17 @@ nsObjectFrame::PaintPlugin(nsIRenderingC
            // must be clipped in some way to prevent the plugin attempting to paint over areas it shouldn't;
            //
            // since the two uses of the rectangle are mutually exclusive in some cases,
            // and since I don't see any incorrect painting (at least with Flash and ViewPoint - the originator of 135737),
            // it seems that windowless plugins are not relying on information here for clipping their drawing,
            // and we can safely use this message to tell the plugin exactly where it is in all cases.
 
               origin = GetWindowOriginInPixels(PR_TRUE);
-              nsRect winlessRect = nsRect(origin, nsSize(window->width, window->height));
+              nsIntRect winlessRect(origin, nsIntSize(window->width, window->height));
               // XXX I don't think we can be certain that the location wrt to
               // the window only changes when the location wrt to the drawable
               // changes, but the hdc probably changes on every paint so
               // doupdatewindow is rarely false, and there is not likely to be
               // a problem.
               if (mWindowlessRect != winlessRect) {
                 mWindowlessRect = winlessRect;
 
@@ -3705,18 +3699,18 @@ nsEventStatus nsPluginInstanceOwner::Pro
         const nsPresContext* presContext = mOwner->PresContext();
         nsPoint appPoint =
           nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mOwner); 
         nsIntPoint pluginPoint(presContext->AppUnitsToDevPixels(appPoint.x),
                                presContext->AppUnitsToDevPixels(appPoint.y));
         const nsMouseEvent& mouseEvent =
           static_cast<const nsMouseEvent&>(anEvent);
         // Get reference point relative to screen:
-        nsRect windowRect(anEvent.refPoint, nsSize(1, 1));
-        nsRect rootPoint(-1,-1,1,1);
+        nsIntRect windowRect(anEvent.refPoint, nsIntSize(1, 1));
+        nsIntRect rootPoint(-1,-1,1,1);
         if (widget)
           widget->WidgetToScreen(windowRect, rootPoint);
 #ifdef MOZ_WIDGET_GTK2
         Window root = GDK_ROOT_WINDOW();
 #else
         Window root = None; // Could XQueryTree, but this is not important.
 #endif
 
@@ -3979,22 +3973,18 @@ void nsPluginInstanceOwner::Paint(const 
 #ifdef DO_DIRTY_INTERSECT   // aDirtyRect isn't always correct, see bug 56128
   nsPoint rel(aDirtyRect.x, aDirtyRect.y);
   nsPoint abs(0,0);
   nsCOMPtr<nsIWidget> containerWidget;
 
   // Convert dirty rect relative coordinates to absolute and also get the containerWidget
   ConvertRelativeToWindowAbsolute(mOwner, rel, abs, *getter_AddRefs(containerWidget));
 
-  nsRect absDirtyRect = nsRect(abs.x, abs.y, aDirtyRect.width, aDirtyRect.height);
-
   // Convert to absolute pixel values for the dirty rect
-  nsIntRect absDirtyRectInPixels;
-  ConvertAppUnitsToPixels(*mOwner->GetPresContext(), absDirtyRect,
-                          absDirtyRectInPixels);
+  nsIntRect absDirtyRect(nsRect::ToOutsidePixels(nsRect(abs, aDirtyRect), *mOwner->GetPresContext()->AppUnitsPerDevPixel()));
 #endif
 
   nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
   if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
     WindowRef window = FixUpPluginWindow(ePluginPaintEnable);
     if (window) {
       EventRecord updateEvent;
       InitializeEventRecord(&updateEvent);
@@ -4013,28 +4003,25 @@ void nsPluginInstanceOwner::Paint(const 
 #ifdef XP_WIN
 void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, HDC ndc)
 {
   if (!mInstance || !mOwner)
     return;
 
   nsPluginWindow * window;
   GetWindow(window);
-  nsRect relDirtyRect = nsRect(aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
-  nsIntRect relDirtyRectInPixels;
-  ConvertAppUnitsToPixels(*mOwner->PresContext(), relDirtyRect,
-                          relDirtyRectInPixels);
+  nsIntRect relDirtyRect(nsRect::ToOutsidePixels(aDirtyRect, mOwner->PresContext()->AppUnitsPerDevPixel()));
 
   // we got dirty rectangle in relative window coordinates, but we
   // need it in absolute units and in the (left, top, right, bottom) form
   RECT drc;
-  drc.left   = relDirtyRectInPixels.x + window->x;
-  drc.top    = relDirtyRectInPixels.y + window->y;
-  drc.right  = drc.left + relDirtyRectInPixels.width;
-  drc.bottom = drc.top + relDirtyRectInPixels.height;
+  drc.left   = relDirtyRect.x + window->x;
+  drc.top    = relDirtyRect.y + window->y;
+  drc.right  = drc.left + relDirtyRect.width;
+  drc.bottom = drc.top + relDirtyRect.height;
 
   nsPluginEvent pluginEvent;
   pluginEvent.event = WM_PAINT;
   pluginEvent.wParam = (uint32)ndc;
   pluginEvent.lParam = (uint32)&drc;
   PRBool eventHandled = PR_FALSE;
   mInstance->HandleEvent(&pluginEvent, &eventHandled);
 }
@@ -4043,28 +4030,25 @@ void nsPluginInstanceOwner::Paint(const 
 #ifdef XP_OS2
 void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, HPS aHPS)
 {
   if (!mInstance || !mOwner)
     return;
 
   nsPluginWindow * window;
   GetWindow(window);
-  nsRect relDirtyRect = nsRect(aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
-  nsIntRect relDirtyRectInPixels;
-  ConvertAppUnitsToPixels(*mOwner->PresContext(), relDirtyRect,
-                          relDirtyRectInPixels);
+  nsIntRect relDirtyRect(nsRect::ToOutsidePixels(aDirtyRect, mOwner->PresContext()->AppUnitsPerDevicePixel()));
 
   // we got dirty rectangle in relative window coordinates, but we
   // need it in absolute units and in the (left, top, right, bottom) form
   RECTL rectl;
-  rectl.xLeft   = relDirtyRectInPixels.x + window->x;
-  rectl.yBottom = relDirtyRectInPixels.y + window->y;
-  rectl.xRight  = rectl.xLeft + relDirtyRectInPixels.width;
-  rectl.yTop    = rectl.yBottom + relDirtyRectInPixels.height;
+  rectl.xLeft   = relDirtyRect.x + window->x;
+  rectl.yBottom = relDirtyRect.y + window->y;
+  rectl.xRight  = rectl.xLeft + relDirtyRect.width;
+  rectl.yTop    = rectl.yBottom + relDirtyRect.height;
 
   nsPluginEvent pluginEvent;
   pluginEvent.event = WM_PAINT;
   pluginEvent.wParam = (uint32)aHPS;
   pluginEvent.lParam = (uint32)&rectl;
   PRBool eventHandled = PR_FALSE;
   mInstance->HandleEvent(&pluginEvent, &eventHandled);
 }
@@ -4539,27 +4523,16 @@ NS_IMETHODIMP nsPluginInstanceOwner::Cre
   return rv;
 }
 
 void nsPluginInstanceOwner::SetPluginHost(nsIPluginHost* aHost)
 {
   mPluginHost = aHost;
 }
 
-#if defined(XP_WIN) || (defined(DO_DIRTY_INTERSECT) && defined(XP_MACOSX)) || defined(XP_OS2)
-// convert frame coordinates from twips to pixels
-static void ConvertAppUnitsToPixels(const nsPresContext& aPresContext, const nsRect& aTwipsRect, nsIntRect& aPixelRect)
-{
-  aPixelRect.x = aPresContext.AppUnitsToDevPixels(aTwipsRect.x);
-  aPixelRect.y = aPresContext.AppUnitsToDevPixels(aTwipsRect.y);
-  aPixelRect.width = aPresContext.AppUnitsToDevPixels(aTwipsRect.width);
-  aPixelRect.height = aPresContext.AppUnitsToDevPixels(aTwipsRect.height);
-}
-#endif
-
   // Mac specific code to fix up the port location and clipping region
 #ifdef XP_MACOSX
 
 #ifdef DO_DIRTY_INTERSECT
 // Convert from a frame relative coordinate to a coordinate relative to its
 // containing window
 static void ConvertRelativeToWindowAbsolute(nsIFrame*   aFrame,
                                             nsPoint&    aRel, 
@@ -4630,23 +4603,23 @@ WindowRef nsPluginInstanceOwner::FixUpPl
   else if (drawingModel == NPDrawingModelCoreGraphics)
 #endif
   {
     // This would be a lot easier if we could use obj-c here,
     // but we can't. Since we have only nsIWidget and we can't
     // use its native widget (an obj-c object) we have to go
     // from the widget's screen coordinates to its window coords
     // instead of straight to window coords.
-    nsRect geckoBounds;
+    nsIntRect geckoBounds;
     mWidget->GetBounds(geckoBounds);
     // we need a rect that is the entire *internal* rect, so the
     // x and y coords are 0, width is the same.
     geckoBounds.x = 0;
     geckoBounds.y = 0;
-    nsRect geckoScreenCoords;
+    nsIntRect geckoScreenCoords;
     mWidget->WidgetToScreen(geckoBounds, geckoScreenCoords);
 
     Rect windowRect;
     WindowRef window = (WindowRef)pluginPort->cgPort.window;
     ::GetWindowBounds(window, kWindowStructureRgn, &windowRect);
 
     mPluginWindow->x = geckoScreenCoords.x - windowRect.left;
     mPluginWindow->y = geckoScreenCoords.y - windowRect.top;
--- a/layout/generic/nsObjectFrame.h
+++ b/layout/generic/nsObjectFrame.h
@@ -170,17 +170,17 @@ protected:
 
   PRBool IsFocusable(PRInt32 *aTabIndex = nsnull, PRBool aWithMouse = PR_FALSE);
 
   // check attributes and optionally CSS to see if we should display anything
   PRBool IsHidden(PRBool aCheckVisibilityStyle = PR_TRUE) const;
 
   void NotifyContentObjectWrapper();
 
-  nsPoint GetWindowOriginInPixels(PRBool aWindowless);
+  nsIntPoint GetWindowOriginInPixels(PRBool aWindowless);
 
   static void PaintPrintPlugin(nsIFrame* aFrame,
                                nsIRenderingContext* aRenderingContext,
                                const nsRect& aDirtyRect, nsPoint aPt);
   static void PaintPlugin(nsIFrame* aFrame,
                                nsIRenderingContext* aRenderingContext,
                                const nsRect& aDirtyRect, nsPoint aPt);
   void PrintPlugin(nsIRenderingContext& aRenderingContext,
@@ -192,17 +192,17 @@ protected:
    * Makes sure that mInstanceOwner is valid and without a current plugin
    * instance. Essentially, this prepares the frame to receive a new plugin.
    */
   NS_HIDDEN_(nsresult) PrepareInstanceOwner();
 
   friend class nsPluginInstanceOwner;
 private:
   nsRefPtr<nsPluginInstanceOwner> mInstanceOwner;
-  nsRect                mWindowlessRect;
+  nsIntRect                       mWindowlessRect;
 
   // For assertions that make it easier to determine if a crash is due
   // to the underlying problem described in bug 136927, and to prevent
   // reentry into instantiation.
   PRBool mPreventInstantiation;
 };
 
 
--- a/layout/generic/nsPageFrame.cpp
+++ b/layout/generic/nsPageFrame.cpp
@@ -540,19 +540,18 @@ nsPageFrame::PaintPageContent(nsIRenderi
   nsIFrame* pageContentFrame  = mFrames.FirstChild();
   nsRect rect = aDirtyRect;
   float scale = PresContext()->GetPageScale();
   aRenderingContext.PushState();
   nsPoint framePos = aPt + pageContentFrame->GetOffsetTo(this);
   aRenderingContext.Translate(framePos.x, framePos.y);
   // aPt translates to coords relative to this, then margins translate to
   // pageContentFrame's coords
-  rect -= framePos;
   aRenderingContext.Scale(scale, scale);
-  rect.ScaleRoundOut(1.0f / scale);
+  rect = (rect - framePos).ScaleRoundOutInverse(scale);
   // Make sure we don't draw where we aren't supposed to draw, especially
   // when printing selection
   nsRect clipRect(nsPoint(0, 0), pageContentFrame->GetSize());
   // Note: this computation matches how we compute maxSize.height
   // in nsPageFrame::Reflow
   nscoord expectedPageContentHeight = 
     NSToCoordCeil((GetSize().height - mPD->mReflowMargin.TopBottom()) / scale);
   if (clipRect.height > expectedPageContentHeight) {
--- a/layout/generic/nsSimplePageSequence.cpp
+++ b/layout/generic/nsSimplePageSequence.cpp
@@ -194,35 +194,35 @@ nsSimplePageSequenceFrame::Reflow(nsPres
   // See if we can get a Print Settings from the Context
   if (!mPageData->mPrintSettings &&
       aPresContext->Medium() == nsGkAtoms::print) {
       mPageData->mPrintSettings = aPresContext->GetPrintSettings();
   }
 
   // now get out margins & edges
   if (mPageData->mPrintSettings) {
-    nsMargin unwriteableTwips;
+    nsIntMargin unwriteableTwips;
     mPageData->mPrintSettings->GetUnwriteableMarginInTwips(unwriteableTwips);
     NS_ASSERTION(unwriteableTwips.left  >= 0 && unwriteableTwips.top >= 0 &&
                  unwriteableTwips.right >= 0 && unwriteableTwips.bottom >= 0,
                  "Unwriteable twips should be non-negative");
 
-    nsMargin marginTwips;
+    nsIntMargin marginTwips;
     mPageData->mPrintSettings->GetMarginInTwips(marginTwips);
     mMargin = aPresContext->TwipsToAppUnits(marginTwips + unwriteableTwips);
 
     PRInt16 printType;
     mPageData->mPrintSettings->GetPrintRange(&printType);
     mPrintRangeType = printType;
 
-    nsMargin edgeTwips;
+    nsIntMargin edgeTwips;
     mPageData->mPrintSettings->GetEdgeInTwips(edgeTwips);
 
     // sanity check the values. three inches are sometimes needed
-    nscoord inchInTwips = NS_INCHES_TO_TWIPS(3.0);
+    PRInt32 inchInTwips = NS_INCHES_TO_TWIPS(3.0);
     edgeTwips.top = PR_MIN(PR_MAX(edgeTwips.top, 0), inchInTwips);
     edgeTwips.bottom = PR_MIN(PR_MAX(edgeTwips.bottom, 0), inchInTwips);
     edgeTwips.left = PR_MIN(PR_MAX(edgeTwips.left, 0), inchInTwips);
     edgeTwips.right = PR_MIN(PR_MAX(edgeTwips.right, 0), inchInTwips);
 
     mPageData->mEdgePaperMargin =
       aPresContext->TwipsToAppUnits(edgeTwips + unwriteableTwips);
   }
@@ -695,19 +695,18 @@ void
 nsSimplePageSequenceFrame::PaintPageSequence(nsIRenderingContext& aRenderingContext,
                                              const nsRect&        aDirtyRect,
                                              nsPoint              aPt) {
   nsRect rect = aDirtyRect;
   float scale = PresContext()->GetPrintPreviewScale();
   aRenderingContext.PushState();
   nsPoint framePos = aPt;
   aRenderingContext.Translate(framePos.x, framePos.y);
-  rect -= framePos;
   aRenderingContext.Scale(scale, scale);
-  rect.ScaleRoundOut(1.0f / scale);
+  rect = (rect - framePos).ScaleRoundOutInverse(scale);
 
   // Now the rect and the rendering coordinates are are relative to this frame.
   // Loop over the pages and paint them.
   nsIFrame* child = GetFirstChild(nsnull);
   while (child) {
     nsPoint pt = child->GetPosition();
     // The rendering context has to be translated before each call to PaintFrame
     aRenderingContext.PushState();
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -2197,18 +2197,18 @@ nsPrintEngine::DoPrint(nsPrintObject * a
           selectionPS = poPresShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL);
 
           rv = GetPageRangeForSelection(poPresShell, poPresContext, *rc, selectionPS, pageSequence,
                                         &startFrame, startPageNum, startRect,
                                         &endFrame, endPageNum, endRect);
           if (NS_SUCCEEDED(rv)) {
             mPrt->mPrintSettings->SetStartPageRange(startPageNum);
             mPrt->mPrintSettings->SetEndPageRange(endPageNum);
-            nsMargin marginTwips(0,0,0,0);
-            nsMargin unwrtMarginTwips(0,0,0,0);
+            nsIntMargin marginTwips(0,0,0,0);
+            nsIntMargin unwrtMarginTwips(0,0,0,0);
             mPrt->mPrintSettings->GetMarginInTwips(marginTwips);
             mPrt->mPrintSettings->GetUnwriteableMarginInTwips(unwrtMarginTwips);
             nsMargin totalMargin = poPresContext->TwipsToAppUnits(marginTwips + 
                                                               unwrtMarginTwips);
             if (startPageNum == endPageNum) {
               {
                 startRect.y -= totalMargin.top;
                 endRect.y   -= totalMargin.top;
--- a/layout/svg/base/src/nsSVGEffects.cpp
+++ b/layout/svg/base/src/nsSVGEffects.cpp
@@ -122,18 +122,17 @@ nsSVGFilterProperty::nsSVGFilterProperty
   UpdateRect();
 }
 
 void
 nsSVGFilterProperty::UpdateRect()
 {
   nsSVGFilterFrame *filter = GetFilterFrame(nsnull);
   if (filter) {
-    mFilterRect = filter->GetFilterBBox(mFrame, nsnull);
-    mFilterRect.ScaleRoundOut(filter->PresContext()->AppUnitsPerDevPixel());
+    mFilterRect = nsIntRect::ToAppUnits(filter->GetFilterBBox(mFrame, nsnull), filter->PresContext()->AppUnitsPerDevPixel());
   } else {
     mFilterRect = nsRect();
   }
 }
 
 void
 nsSVGFilterProperty::DoUpdate()
 {
--- a/layout/svg/base/src/nsSVGForeignObjectFrame.cpp
+++ b/layout/svg/base/src/nsSVGForeignObjectFrame.cpp
@@ -695,18 +695,17 @@ void
 nsSVGForeignObjectFrame::InvalidateDirtyRect(nsSVGOuterSVGFrame* aOuter,
     const nsRect& aRect, PRUint32 aFlags)
 {
   if (aRect.IsEmpty())
     return;
 
   nsPresContext* presContext = PresContext();
   nsCOMPtr<nsIDOMSVGMatrix> tm = GetTMIncludingOffset();
-  nsIntRect r = aRect;
-  r.ScaleRoundOut(1.0f / presContext->AppUnitsPerDevPixel());
+  nsIntRect r(nsRect::ToOutsidePixels(aRect, presContext->AppUnitsPerDevPixel()));
   float x = r.x, y = r.y, w = r.width, h = r.height;
   nsRect rect = GetTransformedRegion(x, y, w, h, tm, presContext);
 
   // XXX invalidate the entire covered region
   // See bug 418063
   rect.UnionRect(rect, mRect);
 
   rect = nsSVGUtils::FindFilterInvalidation(this, rect);
--- a/layout/svg/base/src/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/base/src/nsSVGIntegrationUtils.cpp
@@ -118,19 +118,19 @@ nsSVGIntegrationUtils::ComputeFrameEffec
 
   // XXX this isn't really right. We can't compute the correct filter
   // bbox until all aFrame's continuations have been reflowed.
   // but then it's too late to set the overflow areas for the earlier frames.
   nsRect userSpaceRect = GetNonSVGUserSpace(firstFrame);
   nsRect r = GetSVGBBox(firstFrame, aFrame, aOverflowRect, userSpaceRect);
   // r is relative to user space
   PRUint32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
-  r.ScaleRoundOutInverse(appUnitsPerDevPixel);
-  r = filterFrame->GetFilterBBox(firstFrame, &r);
-  r.ScaleRoundOut(appUnitsPerDevPixel);
+  nsIntRect p(nsRect::ToOutsidePixels(r, appUnitsPerDevPixel));
+  p = filterFrame->GetFilterBBox(firstFrame, &p);
+  r = nsIntRect::ToAppUnits(p, appUnitsPerDevPixel);
   // Make it relative to aFrame again
   return r + userSpaceRect.TopLeft() - aFrame->GetOffsetTo(firstFrame);
 }
 
 nsRect
 nsSVGIntegrationUtils::GetInvalidAreaForChangedSource(nsIFrame* aFrame,
                                                       const nsRect& aInvalidRect)
 {
@@ -141,19 +141,19 @@ nsSVGIntegrationUtils::GetInvalidAreaFor
   nsSVGFilterFrame* filterFrame = nsSVGEffects::GetFilterFrame(firstFrame);
   if (!filterFrame)
     return aInvalidRect;
 
   PRInt32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
   nsRect userSpaceRect = GetNonSVGUserSpace(firstFrame);
   nsPoint offset = aFrame->GetOffsetTo(firstFrame) - userSpaceRect.TopLeft();
   nsRect r = aInvalidRect + offset;
-  r.ScaleRoundOutInverse(appUnitsPerDevPixel);
-  r = filterFrame->GetInvalidationBBox(firstFrame, r);
-  r.ScaleRoundOut(appUnitsPerDevPixel);
+  nsIntRect p(nsRect::ToOutsidePixels(r, appUnitsPerDevPixel));
+  p = filterFrame->GetInvalidationBBox(firstFrame, p);
+  r = nsIntRect::ToAppUnits(p, appUnitsPerDevPixel);
   return r - offset;
 }
 
 nsRect
 nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea(nsIFrame* aFrame,
                                                        const nsRect& aDamageRect)
 {
   // Don't bother calling GetEffectProperties; the filter property should
@@ -164,19 +164,19 @@ nsSVGIntegrationUtils::GetRequiredSource
     nsSVGEffects::GetFilterFrame(firstFrame);
   if (!filterFrame)
     return aDamageRect;
   
   PRInt32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
   nsRect userSpaceRect = GetNonSVGUserSpace(firstFrame);
   nsPoint offset = aFrame->GetOffsetTo(firstFrame) - userSpaceRect.TopLeft();
   nsRect r = aDamageRect + offset;
-  r.ScaleRoundOutInverse(appUnitsPerDevPixel);
-  r = filterFrame->GetSourceForInvalidArea(firstFrame, r);
-  r.ScaleRoundOut(appUnitsPerDevPixel);
+  nsIntRect p(nsRect::ToOutsidePixels(r, appUnitsPerDevPixel));
+  p = filterFrame->GetSourceForInvalidArea(firstFrame, p);
+  r = nsIntRect::ToAppUnits(p, appUnitsPerDevPixel);
   return r - offset;
 }
 
 PRBool
 nsSVGIntegrationUtils::HitTestFrameForEffects(nsIFrame* aFrame, const nsPoint& aPt)
 {
   nsIFrame* firstFrame =
     nsLayoutUtils::GetFirstContinuationOrSpecialSibling(aFrame);
@@ -211,18 +211,17 @@ public:
     // adjust.
     gfxFloat scale =
       nsPresContext::AppUnitsToFloatCSSPixels(aTarget->PresContext()->AppUnitsPerDevPixel());
     gfxCtx->Scale(scale, scale);
 
     nsIRenderingContext::AutoPushTranslation push(ctx, -mOffset.x, -mOffset.y);
     nsRect dirty;
     if (aDirtyRect) {
-      dirty = *aDirtyRect;
-      dirty.ScaleRoundOut(nsIDeviceContext::AppUnitsPerCSSPixel());
+      dirty = nsIntRect::ToAppUnits(*aDirtyRect, nsIDeviceContext::AppUnitsPerCSSPixel());
       dirty += mOffset;
     } else {
       dirty = mInnerList->GetBounds(mBuilder);
     }
     mInnerList->Paint(mBuilder, ctx, dirty);
   }
 
 private:
@@ -285,18 +284,17 @@ nsSVGIntegrationUtils::PaintFramesWithEf
   }
 
   gfxContext* gfx = aCtx->ThebesContext();
   gfxMatrix savedCTM = gfx->CurrentMatrix();
   nsSVGRenderState svgContext(aCtx);
 
   nsRect userSpaceRect = GetNonSVGUserSpace(firstFrame) + aBuilder->ToReferenceFrame(firstFrame);
   PRInt32 appUnitsPerDevPixel = aEffectsFrame->PresContext()->AppUnitsPerDevPixel();
-  userSpaceRect.ScaleRoundPreservingCentersInverse(appUnitsPerDevPixel);
-  userSpaceRect.ScaleRoundOut(appUnitsPerDevPixel);
+  userSpaceRect = nsIntRect::ToAppUnits(nsRect::ToNearestPixels(userSpaceRect, appUnitsPerDevPixel), appUnitsPerDevPixel);
   aCtx->Translate(userSpaceRect.x, userSpaceRect.y);
 
   nsCOMPtr<nsIDOMSVGMatrix> matrix = GetInitialMatrix(aEffectsFrame);
 
   PRBool complexEffects = PR_FALSE;
   /* Check if we need to do additional operations on this child's
    * rendering, which necessitates rendering into another surface. */
   if (opacity != 1.0f || maskFrame || (clipPathFrame && !isTrivialClip)) {
@@ -311,18 +309,17 @@ nsSVGIntegrationUtils::PaintFramesWithEf
   if (clipPathFrame && isTrivialClip) {
     gfx->Save();
     clipPathFrame->ClipPaint(&svgContext, aEffectsFrame, matrix);
   }
 
   /* Paint the child */
   if (filterFrame) {
     RegularFramePaintCallback paint(aBuilder, aInnerList, userSpaceRect.TopLeft());
-    nsRect r = aDirtyRect - userSpaceRect.TopLeft();
-    r.ScaleRoundOutInverse(appUnitsPerDevPixel);
+    nsIntRect r(nsRect::ToOutsidePixels(aDirtyRect - userSpaceRect.TopLeft(), appUnitsPerDevPixel));
     filterFrame->FilterPaint(&svgContext, aEffectsFrame, &paint, &r);
   } else {
     gfx->SetMatrix(savedCTM);
     aInnerList->Paint(aBuilder, aCtx, aDirtyRect);
     aCtx->Translate(userSpaceRect.x, userSpaceRect.y);
   }
 
   if (clipPathFrame && isTrivialClip) {
--- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp
@@ -555,32 +555,32 @@ nsSVGOuterSVGFrame::Paint(nsIRenderingCo
   aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
   aRenderingContext.Translate(viewportRect.x, viewportRect.y);
   nsRect dirtyRect = clipRect - viewportOffset;
 
 #if defined(DEBUG) && defined(SVG_DEBUG_PAINT_TIMING)
   PRTime start = PR_Now();
 #endif
 
-  dirtyRect.ScaleRoundOut(1.0f / PresContext()->AppUnitsPerDevPixel());
+  nsIntRect dirtyPxRect(nsRect::ToOutsidePixels(dirtyRect, PresContext()->AppUnitsPerDevPixel()));
 
   nsSVGRenderState ctx(&aRenderingContext);
 
 #ifdef XP_MACOSX
   if (mEnableBitmapFallback) {
     // nquartz fallback paths, which svg tends to trigger, need
     // a non-window context target
     ctx.GetGfxContext()->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
   }
 #endif
 
   // paint children:
   for (nsIFrame* kid = mFrames.FirstChild(); kid;
        kid = kid->GetNextSibling()) {
-    nsSVGUtils::PaintChildWithEffects(&ctx, &dirtyRect, kid);
+    nsSVGUtils::PaintChildWithEffects(&ctx, &dirtyPxRect, kid);
   }
 
 #ifdef XP_MACOSX
   if (mEnableBitmapFallback) {
     // show the surface we pushed earlier for fallbacks
     ctx.GetGfxContext()->PopGroupToSource();
     ctx.GetGfxContext()->Paint();
   }
--- a/layout/svg/base/src/nsSVGUtils.cpp
+++ b/layout/svg/base/src/nsSVGUtils.cpp
@@ -580,35 +580,33 @@ nsSVGUtils::GetBBox(nsFrameList *aFrames
 
   return NS_ERROR_FAILURE;
 }
 
 nsRect
 nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame, const nsRect& aRect)
 {
   PRInt32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
-  nsRect rect = aRect;
-  rect.ScaleRoundOutInverse(appUnitsPerDevPixel);
+  nsIntRect rect(nsRect::ToOutsidePixels(aRect, appUnitsPerDevPixel));
 
   while (aFrame) {
     if (aFrame->GetStateBits() & NS_STATE_IS_OUTER_SVG)
       break;
 
     nsSVGFilterProperty *property = nsSVGEffects::GetFilterProperty(aFrame);
     if (property) {
       nsSVGFilterFrame *filter = property->GetFilterFrame(nsnull);
       if (filter) {
         rect = filter->GetInvalidationBBox(aFrame, rect);
       }
     }
     aFrame = aFrame->GetParent();
   }
 
-  rect.ScaleRoundOut(appUnitsPerDevPixel);
-  return rect;
+  return nsIntRect::ToAppUnits(rect, appUnitsPerDevPixel);
 }
 
 void
 nsSVGUtils::UpdateFilterRegion(nsIFrame *aFrame)
 {
   nsSVGEffects::EffectProperties props =
     nsSVGEffects::GetEffectProperties(aFrame);
   if (props.mFilter) {
@@ -992,18 +990,17 @@ nsSVGUtils::PaintChildWithEffects(nsSVGR
    * true for path geometry and glyphs, so basically we're traversing
    * all containers and we can only skip leaves here.
    */
   if (aDirtyRect && svgChildFrame->HasValidCoveredRect()) {
     if (filterFrame) {
       if (!aDirtyRect->Intersects(filterFrame->GetFilterBBox(aFrame, nsnull)))
         return;
     } else {
-      nsRect rect = *aDirtyRect;
-      rect.ScaleRoundOut(aFrame->PresContext()->AppUnitsPerDevPixel());
+      nsRect rect(nsIntRect::ToAppUnits(*aDirtyRect, aFrame->PresContext()->AppUnitsPerDevPixel()));
       if (!rect.Intersects(aFrame->GetRect()))
         return;
     }
   }
 
   /* SVG defines the following rendering model:
    *
    *  1. Render geometry
--- a/layout/xul/base/public/nsXULPopupManager.h
+++ b/layout/xul/base/public/nsXULPopupManager.h
@@ -719,17 +719,17 @@ protected:
   nsCOMPtr<nsIDOMEventTarget> mKeyListener;
 
   // widget that is currently listening to rollup events
   nsCOMPtr<nsIWidget> mWidget;
 
   // range parent and offset set in SetTriggerEvent
   nsCOMPtr<nsIDOMNode> mRangeParent;
   PRInt32 mRangeOffset;
-  nsPoint mCachedMousePoint;
+  nsIntPoint mCachedMousePoint;
 
   // set to the currently active menu bar, if any
   nsMenuBarFrame* mActiveMenuBar;
 
   // linked list of dismissable menus.
   nsMenuChainItem* mCurrentMenu;
 
   // linked list of panels
--- a/layout/xul/base/src/nsBox.cpp
+++ b/layout/xul/base/src/nsBox.cpp
@@ -339,17 +339,17 @@ nsBox::GetBorder(nsMargin& aMargin)
 {
   aMargin.SizeTo(0,0,0,0);
     
   const nsStyleDisplay* disp = GetStyleDisplay();
   if (disp->mAppearance && gTheme) {
     // Go to the theme for the border.
     nsPresContext *context = PresContext();
     if (gTheme->ThemeSupportsWidget(context, this, disp->mAppearance)) {
-      nsMargin margin(0, 0, 0, 0);
+      nsIntMargin margin(0, 0, 0, 0);
       gTheme->GetWidgetBorder(context->DeviceContext(), this,
                               disp->mAppearance, &margin);
       aMargin.top = context->DevPixelsToAppUnits(margin.top);
       aMargin.right = context->DevPixelsToAppUnits(margin.right);
       aMargin.bottom = context->DevPixelsToAppUnits(margin.bottom);
       aMargin.left = context->DevPixelsToAppUnits(margin.left);
       return NS_OK;
     }
@@ -363,17 +363,17 @@ nsBox::GetBorder(nsMargin& aMargin)
 NS_IMETHODIMP
 nsBox::GetPadding(nsMargin& aMargin)
 {
   const nsStyleDisplay *disp = GetStyleDisplay();
   if (disp->mAppearance && gTheme) {
     // Go to the theme for the padding.
     nsPresContext *context = PresContext();
     if (gTheme->ThemeSupportsWidget(context, this, disp->mAppearance)) {
-      nsMargin margin(0, 0, 0, 0);
+      nsIntMargin margin(0, 0, 0, 0);
       PRBool useThemePadding;
 
       useThemePadding = gTheme->GetWidgetPadding(context->DeviceContext(),
                                                  this, disp->mAppearance,
                                                  &margin);
       if (useThemePadding) {
         aMargin.top = context->DevPixelsToAppUnits(margin.top);
         aMargin.right = context->DevPixelsToAppUnits(margin.right);
@@ -723,17 +723,17 @@ nsIBox::AddCSSMinSize(nsBoxLayoutState& 
     PRBool heightSet = PR_FALSE;
     PRBool canOverride = PR_TRUE;
 
     // See if a native theme wants to supply a minimum size.
     const nsStyleDisplay* display = aBox->GetStyleDisplay();
     if (display->mAppearance) {
       nsITheme *theme = aState.PresContext()->GetTheme();
       if (theme && theme->ThemeSupportsWidget(aState.PresContext(), aBox, display->mAppearance)) {
-        nsSize size;
+        nsIntSize size;
         nsIRenderingContext* rendContext = aState.GetRenderingContext();
         if (rendContext) {
           theme->GetMinimumWidgetSize(rendContext, aBox,
                                       display->mAppearance, &size, &canOverride);
           if (size.width) {
             aSize.width = aState.PresContext()->DevPixelsToAppUnits(size.width);
             widthSet = PR_TRUE;
           }
--- a/layout/xul/base/src/nsBoxObject.cpp
+++ b/layout/xul/base/src/nsBoxObject.cpp
@@ -154,20 +154,19 @@ nsBoxObject::GetPresShell(PRBool aFlushL
   if (aFlushLayout) {
     doc->FlushPendingNotifications(Flush_Layout);
   }
 
   return doc->GetPrimaryShell();
 }
 
 nsresult 
-nsBoxObject::GetOffsetRect(nsRect& aRect)
+nsBoxObject::GetOffsetRect(nsIntRect& aRect)
 {
-  aRect.x = aRect.y = 0;
-  aRect.Empty();
+  aRect.SetRect(0, 0, 0, 0);
  
   if (!mContent)
     return NS_ERROR_NOT_INITIALIZED;
 
   // Get the Frame for our content
   nsIFrame* frame = GetFrame(PR_TRUE);
   if (frame) {
     // Get its origin
@@ -236,44 +235,44 @@ nsBoxObject::GetScreenPosition(nsIntPoin
   }
   
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBoxObject::GetX(PRInt32* aResult)
 {
-  nsRect rect;
+  nsIntRect rect;
   GetOffsetRect(rect);
   *aResult = rect.x;
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 nsBoxObject::GetY(PRInt32* aResult)
 {
-  nsRect rect;
+  nsIntRect rect;
   GetOffsetRect(rect);
   *aResult = rect.y;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBoxObject::GetWidth(PRInt32* aResult)
 {
-  nsRect rect;
+  nsIntRect rect;
   GetOffsetRect(rect);
   *aResult = rect.width;
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 nsBoxObject::GetHeight(PRInt32* aResult)
 {
-  nsRect rect;
+  nsIntRect rect;
   GetOffsetRect(rect);
   *aResult = rect.height;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBoxObject::GetScreenX(PRInt32 *_retval)
 {
--- a/layout/xul/base/src/nsBoxObject.h
+++ b/layout/xul/base/src/nsBoxObject.h
@@ -43,17 +43,17 @@
 #include "nsPIBoxObject.h"
 #include "nsPoint.h"
 #include "nsAutoPtr.h"
 #include "nsHashKeys.h"
 #include "nsInterfaceHashtable.h"
 
 class nsIFrame;
 class nsIDocShell;
-struct nsRect;
+struct nsIntRect;
 
 class nsBoxObject : public nsPIBoxObject
 {
   NS_DECL_ISUPPORTS
   NS_DECL_NSIBOXOBJECT
 
 public:
   nsBoxObject();
@@ -61,17 +61,17 @@ public:
 
   // nsPIBoxObject
   virtual nsresult Init(nsIContent* aContent);
   virtual void Clear();
   virtual void ClearCachedValues();
 
   nsIFrame* GetFrame(PRBool aFlushLayout);
   nsIPresShell* GetPresShell(PRBool aFlushLayout);
-  nsresult GetOffsetRect(nsRect& aRect);
+  nsresult GetOffsetRect(nsIntRect& aRect);
   nsresult GetScreenPosition(nsIntPoint& aPoint);
 
   // Given a parent frame and a child frame, find the frame whose
   // next sibling is the given child frame and return its element
   static nsresult GetPreviousSibling(nsIFrame* aParentFrame, nsIFrame* aFrame,
                                      nsIDOMElement** aResult);
 
 protected:
--- a/layout/xul/base/src/nsImageBoxFrame.cpp
+++ b/layout/xul/base/src/nsImageBoxFrame.cpp
@@ -537,17 +537,17 @@ NS_IMETHODIMP nsImageBoxFrame::OnStopDec
     FireImageDOMEvent(mContent, NS_LOAD_ERROR);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsImageBoxFrame::FrameChanged(imgIContainer *container,
                                             gfxIImageFrame *newframe,
-                                            nsRect * dirtyRect)
+                                            nsIntRect *dirtyRect)
 {
   nsBoxLayoutState state(PresContext());
   this->Redraw(state);
 
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS2(nsImageBoxListener, imgIDecoderObserver, imgIContainerObserver)
@@ -585,16 +585,16 @@ NS_IMETHODIMP nsImageBoxListener::OnStop
   if (!mFrame)
     return NS_ERROR_FAILURE;
 
   return mFrame->OnStopDecode(request, status, statusArg);
 }
 
 NS_IMETHODIMP nsImageBoxListener::FrameChanged(imgIContainer *container,
                                                gfxIImageFrame *newframe,
-                                               nsRect * dirtyRect)
+                                               nsIntRect *dirtyRect)
 {
   if (!mFrame)
     return NS_ERROR_FAILURE;
 
   return mFrame->FrameChanged(container, newframe, dirtyRect);
 }
 
--- a/layout/xul/base/src/nsImageBoxFrame.h
+++ b/layout/xul/base/src/nsImageBoxFrame.h
@@ -55,17 +55,17 @@ public:
   NS_DECL_ISUPPORTS
   // imgIDecoderObserver (override nsStubImageDecoderObserver)
   NS_IMETHOD OnStartContainer(imgIRequest *request, imgIContainer *image);
   NS_IMETHOD OnStopContainer(imgIRequest *request, imgIContainer *image);
   NS_IMETHOD OnStopDecode(imgIRequest *request, nsresult status,
                           const PRUnichar *statusArg);
   // imgIContainerObserver (override nsStubImageDecoderObserver)
   NS_IMETHOD FrameChanged(imgIContainer *container, gfxIImageFrame *newframe,
-                          nsRect * dirtyRect);
+                          nsIntRect *dirtyRect);
 
   void SetFrame(nsImageBoxFrame *frame) { mFrame = frame; }
 
 private:
   nsImageBoxFrame *mFrame;
 };
 
 class nsImageBoxFrame : public nsLeafBoxFrame
@@ -118,17 +118,17 @@ public:
 
   NS_IMETHOD OnStartContainer(imgIRequest *request, imgIContainer *image);
   NS_IMETHOD OnStopContainer(imgIRequest *request, imgIContainer *image);
   NS_IMETHOD OnStopDecode(imgIRequest *request,
                           nsresult status,
                           const PRUnichar *statusArg);
   NS_IMETHOD FrameChanged(imgIContainer *container,
                           gfxIImageFrame *newframe,
-                          nsRect * dirtyRect);
+                          nsIntRect *dirtyRect);
 
   virtual ~nsImageBoxFrame();
 
   void  PaintImage(nsIRenderingContext& aRenderingContext,
                    const nsRect& aDirtyRect,
                    nsPoint aPt);
 
 protected:
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -995,17 +995,18 @@ nsMenuPopupFrame::SetPopupPosition(nsIFr
     // if we are anchored to our parent, there are certain things we don't want to do
     // when repositioning the view to fit on the screen, such as end up positioned over
     // the parent. When doing this reposition, we want to move the popup to the side with
     // the most room. The combination of anchor and alignment dictate if we readjust 
     // above/below or to the left/right.
     if (mAnchorContent) {
       anchorScreenRect = aAnchorFrame->GetScreenRectInAppUnits();
       // adjust for differences in the anchor frame's scaling
-      anchorScreenRect.ScaleRoundOut(adj);
+      anchorScreenRect = nsIntRect::ToAppUnits(nsRect::ToOutsidePixels(anchorScreenRect,
+                         aAnchorFrame->PresContext()->AppUnitsPerDevPixel()), presContext->AppUnitsPerDevPixel());
       xpos = anchorScreenRect.x - rootScreenRect.x;
       ypos = anchorScreenRect.y - rootScreenRect.y;
 
       // move the popup according to the anchor and alignment. This will also tell us
       // which axis the popup is flush against in case we have to move it around later.
       AdjustPositionForAnchorAlign(&xpos, &ypos, parentSize, &readjustAboveBelow);
     }
     else {
--- a/layout/xul/base/src/nsResizerFrame.h
+++ b/layout/xul/base/src/nsResizerFrame.h
@@ -60,12 +60,12 @@ public:
   virtual void MouseClicked(nsPresContext* aPresContext, nsGUIEvent *aEvent);
 
 protected:
   Direction GetDirection();
   static void AdjustDimensions(PRInt32* aPos, PRInt32* aSize,
                         PRInt32 aMovement, PRInt8 aResizerDirection);
 
 protected:
-	nsRect mWidgetRect;
+	nsIntRect mWidgetRect;
 }; // class nsResizerFrame
 
 #endif /* nsResizerFrame_h___ */
--- a/layout/xul/base/src/nsScrollBoxObject.cpp
+++ b/layout/xul/base/src/nsScrollBoxObject.cpp
@@ -285,19 +285,19 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollT
     rect.y = nsPresContext::CSSPixelsToAppUnits(y);
 
     // TODO: make sure the child is inside the box
 
     // get our current info
     nsPoint cp;
     scrollableView->GetScrollPosition(cp.x,cp.y);
 
-    GetOffsetRect(crect);    
-    crect.x = nsPresContext::CSSPixelsToAppUnits(crect.x);
-    crect.y = nsPresContext::CSSPixelsToAppUnits(crect.y);
+    nsIntRect prect;
+    GetOffsetRect(prect);    
+    crect = nsIntRect::ToAppUnits(prect, nsPresContext::AppUnitsPerCSSPixel());
     nscoord newx=cp.x, newy=cp.y;
 
     // we only scroll in the direction of the scrollbox orientation
     // always scroll to left or top edge of child element
     if (scrolledBox->IsHorizontal()) {
         newx = rect.x - crect.x;
     } else {
         newy = rect.y - crect.y;
@@ -385,21 +385,19 @@ NS_IMETHODIMP nsScrollBoxObject::EnsureE
     rect.width = nsPresContext::CSSPixelsToAppUnits(width);
     rect.height = nsPresContext::CSSPixelsToAppUnits(height);
 
     // TODO: make sure the child is inside the box
 
     // get our current info
     nsPoint cp;
     scrollableView->GetScrollPosition(cp.x,cp.y);
-    GetOffsetRect(crect);    
-    crect.x = nsPresContext::CSSPixelsToAppUnits(crect.x);
-    crect.y = nsPresContext::CSSPixelsToAppUnits(crect.y);
-    crect.width = nsPresContext::CSSPixelsToAppUnits(crect.width);
-    crect.height = nsPresContext::CSSPixelsToAppUnits(crect.height);
+    nsIntRect prect;
+    GetOffsetRect(prect);    
+    crect = nsIntRect::ToAppUnits(prect, nsPresContext::AppUnitsPerCSSPixel());
 
     nscoord newx=cp.x, newy=cp.y;
 
     // we only scroll in the direction of the scrollbox orientation
     if (scrolledBox->IsHorizontal()) {
         if ((rect.x - crect.x) + rect.width > cp.x + crect.width) {
             newx = cp.x + (((rect.x - crect.x) + rect.width)-(cp.x + crect.width));
         } else if (rect.x - crect.x < cp.x) {
--- a/layout/xul/base/src/nsTitleBarFrame.cpp
+++ b/layout/xul/base/src/nsTitleBarFrame.cpp
@@ -154,29 +154,29 @@ nsTitleBarFrame::HandleEvent(nsPresConte
          doDefault = PR_FALSE;
        }
      }
      break;
 
    case NS_MOUSE_MOVE: {
        if(mTrackingMouseMove)
        {
-         nsPoint nsMoveBy = aEvent->refPoint - mLastPoint;
+         nsIntPoint nsMoveBy(aEvent->refPoint - mLastPoint);
 
          nsIFrame* parent = GetParent();
          while (parent && parent->GetType() != nsGkAtoms::menuPopupFrame)
            parent = parent->GetParent();
 
          // if the titlebar is in a popup, move the popup's widget, otherwise
          // move the widget associated with the window
          if (parent) {
            nsCOMPtr<nsIWidget> widget;
            (static_cast<nsMenuPopupFrame*>(parent))->
              GetWidget(getter_AddRefs(widget));
-           nsRect bounds;
+           nsIntRect bounds;
            widget->GetScreenBounds(bounds);
            widget->Move(bounds.x + nsMoveBy.x, bounds.y + nsMoveBy.y);
          }
          else {
            nsIPresShell* presShell = aPresContext->PresShell();
            nsPIDOMWindow *window = presShell->GetDocument()->GetWindow();
            window->MoveBy(nsMoveBy.x, nsMoveBy.y);
          }
--- a/layout/xul/base/src/nsTitleBarFrame.h
+++ b/layout/xul/base/src/nsTitleBarFrame.h
@@ -65,14 +65,14 @@ public:
   virtual void MouseClicked(nsPresContext* aPresContext, nsGUIEvent* aEvent);
 
 protected:
 
   NS_IMETHOD CaptureMouseEvents(nsPresContext* aPresContext,PRBool aGrabMouseEvents);
 
 protected:
 	PRBool mTrackingMouseMove;	
-	nsPoint mLastPoint;
+	nsIntPoint mLastPoint;
 
 
 }; // class nsTitleBarFrame
 
 #endif /* nsTitleBarFrame_h___ */
--- a/layout/xul/base/src/nsXULPopupManager.cpp
+++ b/layout/xul/base/src/nsXULPopupManager.cpp
@@ -303,17 +303,17 @@ nsXULPopupManager::GetMouseLocation(nsID
   *aNode = mRangeParent;
   NS_IF_ADDREF(*aNode);
   *aOffset = mRangeOffset;
 }
 
 void
 nsXULPopupManager::SetTriggerEvent(nsIDOMEvent* aEvent, nsIContent* aPopup)
 {
-  mCachedMousePoint = nsPoint(0, 0);
+  mCachedMousePoint = nsIntPoint(0, 0);
 
   nsCOMPtr<nsIDOMNSUIEvent> uiEvent = do_QueryInterface(aEvent);
   if (uiEvent) {
     uiEvent->GetRangeParent(getter_AddRefs(mRangeParent));
     uiEvent->GetRangeOffset(&mRangeOffset);
 
     // get the event coordinates relative to the root frame of the document
     // containing the popup.
@@ -333,25 +333,24 @@ nsXULPopupManager::SetTriggerEvent(nsIDO
                  event->eventStructType == NS_MOUSE_SCROLL_EVENT) &&
                  !(static_cast<nsGUIEvent *>(event))->widget) {
               // no widget, so just use the client point if available
               nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent);
               mouseEvent->GetClientX(&mCachedMousePoint.x);
               mouseEvent->GetClientY(&mCachedMousePoint.y);
 
               // convert to device pixels
-              PRInt32 adj = presContext->DeviceContext()->AppUnitsPerDevPixel();
-              mCachedMousePoint.x = nsPresContext::CSSPixelsToAppUnits(mCachedMousePoint.x) / adj;
-              mCachedMousePoint.y = nsPresContext::CSSPixelsToAppUnits(mCachedMousePoint.y) / adj;
+              mCachedMousePoint.x = presContext->AppUnitsToDevPixels(nsPresContext::CSSPixelsToAppUnits(mCachedMousePoint.x));
+              mCachedMousePoint.y = presContext->AppUnitsToDevPixels(nsPresContext::CSSPixelsToAppUnits(mCachedMousePoint.y));
             }
             else if (rootFrame) {
               nsPoint pnt =
                 nsLayoutUtils::GetEventCoordinatesRelativeTo(event, rootFrame);
-              mCachedMousePoint = nsPoint(presContext->AppUnitsToDevPixels(pnt.x),
-                                          presContext->AppUnitsToDevPixels(pnt.y));
+              mCachedMousePoint = nsIntPoint(presContext->AppUnitsToDevPixels(pnt.x),
+                                             presContext->AppUnitsToDevPixels(pnt.y));
             }
           }
         }
       }
     }
   }
   else {
     mRangeParent = nsnull;
@@ -994,17 +993,17 @@ nsXULPopupManager::FirePopupShowingEvent
   //   all the globals people keep adding to nsIDOMXULDocument.
   nsEventStatus status = nsEventStatus_eIgnore;
   nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_SHOWING, nsnull, nsMouseEvent::eReal);
   nsPoint pnt;
   event.widget = presShell->GetRootFrame()->
                             GetClosestView()->GetNearestWidget(&pnt);
   event.refPoint = mCachedMousePoint;
   nsEventDispatcher::Dispatch(aPopup, aPresContext, &event, nsnull, &status);
-  mCachedMousePoint = nsPoint(0, 0);
+  mCachedMousePoint = nsIntPoint(0, 0);
 
   // if a panel, blur whatever has focus so that the panel can take the focus.
   // This is done after the popupshowing event in case that event is cancelled.
   // Using noautofocus="true" will disable this behaviour, which is needed for
   // the autocomplete widget as it manages focus itself.
   if (aPopupType == ePopupTypePanel &&
       !aPopup->AttrValueIs(kNameSpaceID_None, nsGkAtoms::noautofocus,
                            nsGkAtoms::_true, eCaseMatters)) {
--- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -653,18 +653,17 @@ nsTreeBodyFrame::GetSelectionRegion(nsIS
   mView->GetSelection(getter_AddRefs(selection));
   NS_ENSURE_TRUE(selection, NS_OK);
 
   nsCOMPtr<nsIScriptableRegion> region = do_CreateInstance("@mozilla.org/gfx/region;1");
   NS_ENSURE_TRUE(region, NS_ERROR_FAILURE);
   region->Init();
 
   nsRefPtr<nsPresContext> presContext = PresContext();
-  nsRect rect = mRect;
-  rect.ScaleRoundOut(1.0 / presContext->AppUnitsPerCSSPixel());
+  nsIntRect rect(nsRect::ToOutsidePixels(mRect, presContext->AppUnitsPerCSSPixel()));
 
   nsIFrame* rootFrame = presContext->PresShell()->GetRootFrame();
   nsPoint origin = GetOffsetTo(rootFrame);
 
   // iterate through the visible rows and add the selected ones to the
   // drag region
   PRInt32 x = nsPresContext::AppUnitsToIntCSSPixels(origin.x);
   PRInt32 y = nsPresContext::AppUnitsToIntCSSPixels(origin.y);
@@ -2122,24 +2121,25 @@ nsTreeBodyFrame::GetTwistyRect(PRInt32 a
   const nsStyleDisplay* twistyDisplayData = aTwistyContext->GetStyleDisplay();
   if (twistyDisplayData->mAppearance) {
     theme = aPresContext->GetTheme();
     if (theme && theme->ThemeSupportsWidget(aPresContext, nsnull, twistyDisplayData->mAppearance))
       useTheme = PR_TRUE;
   }
 
   if (useTheme) {
-    nsSize minTwistySize(0,0);
+    nsIntSize minTwistySizePx(0,0);
     PRBool canOverride = PR_TRUE;
     theme->GetMinimumWidgetSize(&aRenderingContext, this, twistyDisplayData->mAppearance,
-                                &minTwistySize, &canOverride);
-
-    // GMWS() returns size in pixels, we need to convert it back to twips
-    minTwistySize.width = aPresContext->DevPixelsToAppUnits(minTwistySize.width);
-    minTwistySize.height = aPresContext->DevPixelsToAppUnits(minTwistySize.height);
+                                &minTwistySizePx, &canOverride);
+
+    // GMWS() returns size in pixels, we need to convert it back to app units
+    nsSize minTwistySize;
+    minTwistySize.width = aPresContext->DevPixelsToAppUnits(minTwistySizePx.width);
+    minTwistySize.height = aPresContext->DevPixelsToAppUnits(minTwistySizePx.height);
 
     if (aTwistyRect.width < minTwistySize.width || !canOverride)
       aTwistyRect.width = minTwistySize.width;
   }
 
   return useTheme ? theme : nsnull;
 }
 
--- a/layout/xul/base/src/tree/src/nsTreeImageListener.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeImageListener.cpp
@@ -60,25 +60,25 @@ NS_IMETHODIMP nsTreeImageListener::OnSta
 {
   // Ensure the animation (if any) is started
   aImage->StartAnimation();                                                     
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeImageListener::OnDataAvailable(imgIRequest *aRequest,
                                                    gfxIImageFrame *aFrame,
-                                                   const nsRect *aRect)
+                                                   const nsIntRect *aRect)
 {
   Invalidate();
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeImageListener::FrameChanged(imgIContainer *aContainer,
                                                 gfxIImageFrame *newframe,
-                                                nsRect * dirtyRect)
+                                                nsIntRect *dirtyRect)
 {
   Invalidate();
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsTreeImageListener::AddCell(PRInt32 aIndex, nsITreeColumn* aCol)
--- a/layout/xul/base/src/tree/src/nsTreeImageListener.h
+++ b/layout/xul/base/src/tree/src/nsTreeImageListener.h
@@ -68,20 +68,20 @@ class nsTreeImageListener : public nsStu
 public:
   nsTreeImageListener(nsITreeBoxObject* aTree);
   ~nsTreeImageListener();
 
   NS_DECL_ISUPPORTS
   // imgIDecoderObserver (override nsStubImageDecoderObserver)
   NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
   NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame,
-                             const nsRect *aRect);
+                             const nsIntRect *aRect);
   // imgIContainerObserver (override nsStubImageDecoderObserver)
   NS_IMETHOD FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe,
-                          nsRect * dirtyRect);
+                          nsIntRect *dirtyRect);
 
   NS_IMETHOD AddCell(PRInt32 aIndex, nsITreeColumn* aCol);
  
   friend class nsTreeBodyFrame;
 
 protected:
   void UnsuppressInvalidation() { mInvalidationSuppressed = PR_FALSE; }
   void Invalidate();
--- a/view/public/nsIViewManager.h
+++ b/view/public/nsIViewManager.h
@@ -55,20 +55,20 @@ enum nsRectVisibility {
   nsRectVisibility_kVisible, 
   nsRectVisibility_kAboveViewport, 
   nsRectVisibility_kBelowViewport, 
   nsRectVisibility_kLeftOfViewport, 
   nsRectVisibility_kRightOfViewport, 
   nsRectVisibility_kZeroAreaRect
 }; 
 
-// 7eae119d-9fc8-482d-92ec-145eef228a4a
+// de2a2d24-9753-4488-9fdc-dd0accb484f7
 #define NS_IVIEWMANAGER_IID   \
-{ 0x7eae119d, 0x9fc8, 0x482d, \
-  { 0x92, 0xec, 0x14, 0x5e, 0xef, 0x22, 0x8a, 0x4a } }
+{ 0xde2a2d24, 0x9753, 0x4488, \
+  { 0x9f, 0xdc, 0xdd, 0x0a, 0xcc, 0xb4, 0x84, 0xf7 } };
 
 class nsIViewManager : public nsISupports
 {
 public:
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID)
   /**
    * Initialize the ViewManager
@@ -472,17 +472,17 @@ public:
    * @param aView view that aRect coordinates are specified relative to
    * @param aRect rectangle in twips to test for visibility 
    * @param aMinTwips is the min. pixel rows or cols at edge of screen 
    *                  needed for object to be counted visible
    * @param aRectVisibility returns eVisible if the rect is visible, 
    *                        otherwise it returns an enum indicating why not
    */
   NS_IMETHOD GetRectVisibility(nsIView *aView, const nsRect &aRect, 
-                               PRUint16 aMinTwips, 
+                               nscoord aMinTwips, 
                                nsRectVisibility *aRectVisibility)=0;
 
   /**
    * Dispatch a mouse move event based on the most recent mouse
    * position.  This is used when the contents of the page moved
    * (aFromScroll is false) or scrolled (aFromScroll is true).
    */
   NS_IMETHOD SynthesizeMouseMove(PRBool aFromScroll)=0;
--- a/view/src/nsScrollPortView.cpp
+++ b/view/src/nsScrollPortView.cpp
@@ -510,17 +510,17 @@ NS_IMETHODIMP nsScrollPortView::CanScrol
   }
 
   // Can scroll to Bottom or to Right?
   aResult = (offset < max) ? PR_TRUE : PR_FALSE;
 
   return NS_OK;
 }
 
-void nsScrollPortView::Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsPoint aPixDelta,
+void nsScrollPortView::Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsIntPoint aPixDelta,
                               PRInt32 aP2A)
 {
   if (aTwipsDelta.x != 0 || aTwipsDelta.y != 0)
   {
     /* If we should invalidate our wrapped view, we should do so at this
      * point.
      */
     if (aScrolledView->NeedsInvalidateFrameOnScroll())
@@ -560,37 +560,35 @@ void nsScrollPortView::Scroll(nsView *aS
       nsRect bounds(GetBounds());
       nsPoint topLeft(bounds.x, bounds.y);
       AdjustChildWidgets(aScrolledView,
                          GetPosition() - topLeft, aP2A, PR_FALSE);
       // We should call this after fixing up the widget positions to be
       // consistent with the view hierarchy.
       mViewManager->UpdateView(this, NS_VMREFRESH_DEFERRED);
     } else { // if we can blit and have a scrollwidget then scroll.
-      nsRect* toScrollPtr = nsnull;
+      nsIntRect* toScrollPtr = nsnull;
 
 #ifdef XP_WIN
-      nsRect toScroll;
+      nsIntRect toScroll;
       if (!updateRegion.IsEmpty()) {
         nsRegion regionToScroll;
         regionToScroll.Sub(nsRect(nsPoint(0,0), GetBounds().Size()),
                            updateRegion);
         nsRegionRectIterator iter(regionToScroll);
         nsRect biggestRect(0,0,0,0);
         const nsRect* r;
         for (r = iter.Next(); r; r = iter.Next()) {
-          if (r->width*r->height > biggestRect.width*biggestRect.height) {
+          if (PRInt64(r->width)*PRInt64(r->height) > PRInt64(biggestRect.width)*PRInt64(biggestRect.height)) {
             biggestRect = *r;
           }
         }
         toScrollPtr = &toScroll;
-        biggestRect.ScaleRoundIn(1.0/aP2A);
-        toScroll = biggestRect;
-        biggestRect *= aP2A;
-        regionToScroll.Sub(regionToScroll, biggestRect);
+        toScroll = nsRect::ToInsidePixels(biggestRect, aP2A);
+        regionToScroll.Sub(regionToScroll, nsIntRect::ToAppUnits(toScroll, aP2A));
         updateRegion.Or(updateRegion, regionToScroll);
       }
 #endif
 
       // Scroll the contents of the widget by the specified amount, and scroll
       // the child widgets
       scrollWidget->Scroll(aPixDelta.x, aPixDelta.y, toScrollPtr);
       mViewManager->UpdateViewAfterScroll(this, updateRegion);
@@ -666,17 +664,17 @@ NS_IMETHODIMP nsScrollPortView::ScrollTo
   }
 
   nsPoint twipsDelta(aX - mOffsetX, aY - mOffsetY);
 
   // store the new position
   mOffsetX = aX;
   mOffsetY = aY;
 
-  Scroll(scrolledView, twipsDelta, nsPoint(dxPx, dyPx), p2a);
+  Scroll(scrolledView, twipsDelta, nsIntPoint(dxPx, dyPx), p2a);
 
   mViewManager->SynthesizeMouseMove(PR_TRUE);
   
   // notify the listeners.
   if (nsnull != mListeners) {
     if (NS_SUCCEEDED(mListeners->Count(&listenerCount))) {
       for (PRUint32 i = 0; i < listenerCount; i++) {
         if (NS_SUCCEEDED(mListeners->QueryElementAt(i, kScrollPositionListenerIID, (void**)&listener))) {
--- a/view/src/nsScrollPortView.h
+++ b/view/src/nsScrollPortView.h
@@ -97,17 +97,17 @@ private:
   void        IncrementalScroll();
   PRBool      IsSmoothScrollingEnabled();
   static void SmoothScrollAnimationCallback(nsITimer *aTimer, void* aESM);
 
 protected:
   virtual ~nsScrollPortView();
 
   //private
-  void Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsPoint aPixDelta, PRInt32 p2a);
+  void Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsIntPoint aPixDelta, nscoord aP2A);
   PRBool CannotBitBlt(nsView* aScrolledView);
 
   nscoord             mOffsetX, mOffsetY;
   PRUint32            mScrollProperties;
   nscoord             mLineHeight;
   nsISupportsArray   *mListeners;
 };
 
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -351,75 +351,74 @@ void nsView::ResetWidgetBounds(PRBool aR
   } else if (aRecurse) {
     // reposition any widgets under this view
     for (nsView* v = GetFirstChild(); v; v = v->GetNextSibling()) {
       v->ResetWidgetBounds(PR_TRUE, aMoveOnly, aInvalidateChangedSize);
     }
   }
 }
 
-nsRect nsView::CalcWidgetBounds(nsWindowType aType)
+nsIntRect nsView::CalcWidgetBounds(nsWindowType aType)
 {
   nsCOMPtr<nsIDeviceContext> dx;
   mViewManager->GetDeviceContext(*getter_AddRefs(dx));
   NS_ASSERTION(dx, "View manager can't be created without a device context");
   PRInt32 p2a = dx->AppUnitsPerDevPixel();
 
   nsRect viewBounds(mDimBounds);
 
   if (GetParent()) {
     // put offset into screen coordinates
     nsPoint offset;
     nsIWidget* parentWidget = GetParent()->GetNearestWidget(&offset);
     viewBounds += offset;
 
     if (parentWidget && aType == eWindowType_popup &&
         mVis == nsViewVisibility_kShow) {
-      nsRect screenRect(0,0,1,1);
+      nsIntRect screenRect(0,0,1,1);
       parentWidget->WidgetToScreen(screenRect, screenRect);
       viewBounds += nsPoint(NSIntPixelsToAppUnits(screenRect.x, p2a),
                             NSIntPixelsToAppUnits(screenRect.y, p2a));
     }
   }
 
-  nsRect newBounds(viewBounds);
-  newBounds.ScaleRoundPreservingCentersInverse(p2a);
+  nsIntRect newBounds(nsRect::ToNearestPixels(viewBounds, p2a));
 
   nsPoint roundedOffset(NSIntPixelsToAppUnits(newBounds.x, p2a),
                         NSIntPixelsToAppUnits(newBounds.y, p2a));
   mViewToWidgetOffset = viewBounds.TopLeft() - roundedOffset;
 
   return newBounds;
 }
 
 void nsView::DoResetWidgetBounds(PRBool aMoveOnly,
                                  PRBool aInvalidateChangedSize) {
   // The geometry of a root view's widget is controlled externally,
   // NOT by sizing or positioning the view
   if (mViewManager->GetRootView() == this) {
     return;
   }
   
-  nsRect curBounds;
+  nsIntRect curBounds;
   mWindow->GetBounds(curBounds);
   nsWindowType type;
   mWindow->GetWindowType(type);
 
   if (curBounds.IsEmpty() && mDimBounds.IsEmpty() && type == eWindowType_popup) {
     // Don't manipulate empty popup widgets. For example there's no point
     // moving hidden comboboxes around, or doing X server roundtrips
     // to compute their true screen position. This could mean that WidgetToScreen
     // operations on these widgets don't return up-to-date values, but popup
     // positions aren't reliable anyway because of correction to be on or off-screen.
     return;
   }
 
   NS_PRECONDITION(mWindow, "Why was this called??");
 
-  nsRect newBounds = CalcWidgetBounds(type);
+  nsIntRect newBounds = CalcWidgetBounds(type);
 
   PRBool changedPos = curBounds.TopLeft() != newBounds.TopLeft();
   PRBool changedSize = curBounds.Size() != newBounds.Size();
 
   if (changedPos) {
     if (changedSize && !aMoveOnly) {
       mWindow->Resize(newBounds.x, newBounds.y, newBounds.width, newBounds.height,
                       aInvalidateChangedSize);
@@ -631,19 +630,19 @@ nsresult nsIView::CreateWidget(const nsI
     NS_IF_RELEASE(wrapper);
     mWindow->SetClientData(nsnull);
     mWindow->Destroy();
     NS_RELEASE(mWindow);
   }
 
   nsView* v = static_cast<nsView*>(this);
 
-  nsRect trect = v->CalcWidgetBounds(aWidgetInitData
-                                     ? aWidgetInitData->mWindowType
-                                     : eWindowType_child);
+  nsIntRect trect = v->CalcWidgetBounds(aWidgetInitData
+                                        ? aWidgetInitData->mWindowType
+                                        : eWindowType_child);
 
   if (NS_OK == v->LoadWidget(aWindowIID))
   {
     PRBool usewidgets;
     nsCOMPtr<nsIDeviceContext> dx;
     mViewManager->GetDeviceContext(*getter_AddRefs(dx));
     dx->SupportsNativeWidgets(usewidgets);
 
@@ -750,27 +749,25 @@ nsresult nsView::LoadWidget(const nsCID 
 
 #ifdef DEBUG
 void nsIView::List(FILE* out, PRInt32 aIndent) const
 {
   PRInt32 i;
   for (i = aIndent; --i >= 0; ) fputs("  ", out);
   fprintf(out, "%p ", (void*)this);
   if (nsnull != mWindow) {
-    nsRect windowBounds;
-    nsRect nonclientBounds;
-    float p2t;
     nsIDeviceContext *dx;
     mViewManager->GetDeviceContext(dx);
-    p2t = (float) dx->AppUnitsPerDevPixel();
+    nscoord p2a = dx->AppUnitsPerDevPixel();
     NS_RELEASE(dx);
-    mWindow->GetClientBounds(windowBounds);
-    windowBounds *= p2t;
-    mWindow->GetBounds(nonclientBounds);
-    nonclientBounds *= p2t;
+    nsIntRect rect;
+    mWindow->GetClientBounds(rect);
+    nsRect windowBounds(nsIntRect::ToAppUnits(rect, p2a));
+    mWindow->GetBounds(rect);
+    nsRect nonclientBounds(nsIntRect::ToAppUnits(rect, p2a));
     nsrefcnt widgetRefCnt = mWindow->AddRef() - 1;
     mWindow->Release();
     PRInt32 Z;
     mWindow->GetZIndex(&Z);
     fprintf(out, "(widget=%p[%d] z=%d pos={%d,%d,%d,%d}) ",
             (void*)mWindow, widgetRefCnt, Z,
             nonclientBounds.x, nonclientBounds.y,
             windowBounds.width, windowBounds.height);
--- a/view/src/nsView.h
+++ b/view/src/nsView.h
@@ -187,17 +187,17 @@ public:
       // widget top-left is always positioned at that inner view's widget's
       // top-left, so its ViewToWidgetOffset is actually the same as
       // its parent's.
       return mParent->ViewToWidgetOffset();
     }
     return mViewToWidgetOffset;
   }
 
-  nsRect CalcWidgetBounds(nsWindowType aType);
+  nsIntRect CalcWidgetBounds(nsWindowType aType);
 
 protected:
   // Do the actual work of ResetWidgetBounds, unconditionally.  Don't
   // call this method if we have no widget.
   void DoResetWidgetBounds(PRBool aMoveOnly, PRBool aInvalidateChangedSize);
 
   nsRegion*    mDirtyRegion;
   nsPoint      mViewToWidgetOffset;
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -863,18 +863,17 @@ nsViewManager::UpdateWidgetArea(nsView *
   nsRegion leftOver;
   leftOver.Sub(intersection, children);
 
   if (!leftOver.IsEmpty()) {
     NS_ASSERTION(IsRefreshEnabled(), "Can only get here with refresh enabled, I hope");
 
     const nsRect* r;
     for (nsRegionRectIterator iter(leftOver); (r = iter.Next());) {
-      nsRect bounds = *r;
-      ViewToWidget(aWidgetView, aWidgetView, bounds);
+      nsIntRect bounds(ViewToWidget(aWidgetView, aWidgetView, *r));
       widget->Invalidate(bounds, PR_FALSE);
     }
   }
 }
 
 NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect, PRUint32 aUpdateFlags)
 {
   NS_PRECONDITION(nsnull != aView, "null view");
@@ -1004,24 +1003,16 @@ void nsViewManager::SuppressFocusEvents(
 #endif
       nsGUIEvent event(PR_TRUE, NS_GOTFOCUS, widget);
       widget->DispatchEvent(&event, status); 
     }
   }
 
 }
 
-static void ConvertRectAppUnitsToIntPixels(nsRect& aRect, PRInt32 p2a)
-{
-  aRect.x = NSAppUnitsToIntPixels(aRect.x, p2a);
-  aRect.y = NSAppUnitsToIntPixels(aRect.y, p2a);
-  aRect.width = NSAppUnitsToIntPixels(aRect.width, p2a);
-  aRect.height = NSAppUnitsToIntPixels(aRect.height, p2a);
-}
-
 NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aStatus)
 {
   *aStatus = nsEventStatus_eIgnore;
 
   switch(aEvent->message)
     {
     case NS_SIZE:
       {
@@ -1061,17 +1052,17 @@ NS_IMETHODIMP nsViewManager::DispatchEve
 
         // The rect is in device units, and it's in the coordinate space of its
         // associated window.
         nsCOMPtr<nsIRegion> region = event->region;
         if (!region) {
           if (NS_FAILED(CreateRegion(getter_AddRefs(region))))
             break;
 
-          const nsRect& damrect = *event->rect;
+          const nsIntRect& damrect = *event->rect;
           region->SetTo(damrect.x, damrect.y, damrect.width, damrect.height);
         }
         
         if (region->IsEmpty())
           break;
 
         // Refresh the view
         if (IsRefreshEnabled()) {
@@ -1143,20 +1134,19 @@ NS_IMETHODIMP nsViewManager::DispatchEve
             if (view) {
               Refresh(view, event->renderingContext, region,
                       NS_VMREFRESH_DOUBLE_BUFFER);
             }
           }
         } else {
           // since we got an NS_PAINT event, we need to
           // draw something so we don't get blank areas.
-          nsRect damRect;
-          region->GetBoundingBox(&damRect.x, &damRect.y, &damRect.width, &damRect.height);
-          PRInt32 p2a = mContext->AppUnitsPerDevPixel();
-          damRect.ScaleRoundOut(float(p2a));
+          nsIntRect damIntRect;
+          region->GetBoundingBox(&damIntRect.x, &damIntRect.y, &damIntRect.width, &damIntRect.height);
+          nsRect damRect(nsIntRect::ToAppUnits(damIntRect, mContext->AppUnitsPerDevPixel()));
           DefaultRefresh(view, event->renderingContext, &damRect);
         
           // Clients like the editor can trigger multiple
           // reflows during what the user perceives as a single
           // edit operation, so it disables view manager
           // refreshing until the edit operation is complete
           // so that users don't see the intermediate steps.
           // 
@@ -1285,18 +1275,18 @@ NS_IMETHODIMP nsViewManager::DispatchEve
                static_cast<nsMouseEvent*>(aEvent)->reason ==
                  nsMouseEvent::eReal) ||
               aEvent->message == NS_MOUSE_ENTER) {
             // aEvent->point is relative to the widget, i.e. the view top-left,
             // so we need to add the offset to the view origin
             nsPoint rootOffset = baseView->GetDimensions().TopLeft();
             rootOffset += baseView->GetOffsetTo(RootViewManager()->mRootView);
             RootViewManager()->mMouseLocation = aEvent->refPoint +
-                nsPoint(NSAppUnitsToIntPixels(rootOffset.x, p2a),
-                        NSAppUnitsToIntPixels(rootOffset.y, p2a));
+                nsIntPoint(NSAppUnitsToIntPixels(rootOffset.x, p2a),
+                           NSAppUnitsToIntPixels(rootOffset.y, p2a));
 #ifdef DEBUG_MOUSE_LOCATION
             if (aEvent->message == NS_MOUSE_ENTER)
               printf("[vm=%p]got mouse enter for %p\n",
                      this, aEvent->widget);
             printf("[vm=%p]setting mouse location to (%d,%d)\n",
                    this, mMouseLocation.x, mMouseLocation.y);
 #endif
             if (aEvent->message == NS_MOUSE_ENTER)
@@ -1304,17 +1294,17 @@ NS_IMETHODIMP nsViewManager::DispatchEve
           } else if (aEvent->message == NS_MOUSE_EXIT) {
             // Although we only care about the mouse moving into an area
             // for which this view manager doesn't receive mouse move
             // events, we don't check which view the mouse exit was for
             // since this seems to vary by platform.  Hopefully this
             // won't matter at all since we'll get the mouse move or
             // enter after the mouse exit when the mouse moves from one
             // of our widgets into another.
-            RootViewManager()->mMouseLocation = nsPoint(NSCOORD_NONE, NSCOORD_NONE);
+            RootViewManager()->mMouseLocation = nsIntPoint(NSCOORD_NONE, NSCOORD_NONE);
 #ifdef DEBUG_MOUSE_LOCATION
             printf("[vm=%p]got mouse exit for %p\n",
                    this, aEvent->widget);
             printf("[vm=%p]clearing mouse location\n",
                    this);
 #endif
           }
 
@@ -1341,36 +1331,16 @@ NS_IMETHODIMP nsViewManager::DispatchEve
           nsPoint pt;
           pt.x = baseViewDimensions.x + 
             NSFloatPixelsToAppUnits(float(aEvent->refPoint.x) + 0.5f, p2a);
           pt.y = baseViewDimensions.y + 
             NSFloatPixelsToAppUnits(float(aEvent->refPoint.y) + 0.5f, p2a);
           pt += offset;
 
           *aStatus = HandleEvent(view, pt, aEvent, capturedEvent);
-
-          //
-          // need to map the reply back into platform coordinates
-          //
-          switch (aEvent->message) {
-            case NS_TEXT_TEXT:
-              ConvertRectAppUnitsToIntPixels(
-                ((nsTextEvent*)aEvent)->theReply.mCursorPosition, p2a);
-              break;
-            case NS_COMPOSITION_START:
-            case NS_COMPOSITION_QUERY:
-              ConvertRectAppUnitsToIntPixels(
-                ((nsCompositionEvent*)aEvent)->theReply.mCursorPosition, p2a);
-              break;
-            case NS_QUERY_CHARACTER_RECT:
-            case NS_QUERY_CARET_RECT:
-              ConvertRectAppUnitsToIntPixels(
-                ((nsQueryContentEvent*)aEvent)->mReply.mRect, p2a);
-              break;
-          }
         }
     
         break;
       }
     }
 
   return NS_OK;
 }
@@ -2045,35 +2015,36 @@ nsPoint nsViewManager::ComputeViewOffset
     aView = aView->GetParent();
   }
   NS_ASSERTION(rootView ==
                origView->GetViewManager()->RootViewManager()->GetRootView(),
                "Unexpected root view");
   return origin;
 }
 
-void nsViewManager::ViewToWidget(nsView *aView, nsView* aWidgetView, nsRect &aRect) const
+nsIntRect nsViewManager::ViewToWidget(nsView *aView, nsView* aWidgetView, const nsRect &aRect) const
 {
+  nsRect rect = aRect;
   while (aView != aWidgetView) {
-    aView->ConvertToParentCoords(&aRect.x, &aRect.y);
+    aView->ConvertToParentCoords(&rect.x, &rect.y);
     aView = aView->GetParent();
   }
   
   // intersect aRect with bounds of aWidgetView, to prevent generating any illegal rectangles.
   nsRect bounds;
   aWidgetView->GetDimensions(bounds);
-  aRect.IntersectRect(aRect, bounds);
+  rect.IntersectRect(rect, bounds);
   // account for the view's origin not lining up with the widget's
-  aRect.x -= bounds.x;
-  aRect.y -= bounds.y;
-
-  aRect += aView->ViewToWidgetOffset();
+  rect.x -= bounds.x;
+  rect.y -= bounds.y;
+  
+  rect += aView->ViewToWidgetOffset();
 
   // finally, convert to device coordinates.
-  aRect.ScaleRoundOut(1.0f / mContext->AppUnitsPerDevPixel());
+  return nsRect::ToOutsidePixels(rect, mContext->AppUnitsPerDevPixel());
 }
 
 nsresult nsViewManager::GetVisibleRect(nsRect& aVisibleRect)
 {
   nsresult rv = NS_OK;
 
   // Get the viewport scroller
   nsIScrollableView* scrollingView;
@@ -2121,17 +2092,17 @@ nsresult nsViewManager::GetAbsoluteRect(
   }
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP nsViewManager::GetRectVisibility(nsIView *aView, 
                                                const nsRect &aRect,
-                                               PRUint16 aMinTwips, 
+                                               nscoord aMinTwips, 
                                                nsRectVisibility *aRectVisibility)
 {
   nsView* view = static_cast<nsView*>(aView);
 
   // The parameter aMinTwips determines how many rows/cols of pixels must be visible on each side of the element,
   // in order to be counted as visible
 
   *aRectVisibility = nsRectVisibility_kZeroAreaRect;
@@ -2312,17 +2283,17 @@ private:
 };
 
 NS_IMETHODIMP
 nsViewManager::SynthesizeMouseMove(PRBool aFromScroll)
 {
   if (!IsRootVM())
     return RootViewManager()->SynthesizeMouseMove(aFromScroll);
 
-  if (mMouseLocation == nsPoint(NSCOORD_NONE, NSCOORD_NONE))
+  if (mMouseLocation == nsIntPoint(NSCOORD_NONE, NSCOORD_NONE))
     return NS_OK;
 
   if (!mSynthMouseMoveEvent.IsPending()) {
     nsRefPtr<nsViewManagerEvent> ev =
         new nsSynthMouseMoveEvent(this, aFromScroll);
 
     if (NS_FAILED(NS_DispatchToCurrentThread(ev))) {
       NS_WARNING("failed to dispatch nsSynthMouseMoveEvent");
@@ -2367,44 +2338,44 @@ nsViewManager::ProcessSynthMouseMoveEven
 {
   // allow new event to be posted while handling this one only if the
   // source of the event is a scroll (to prevent infinite reflow loops)
   if (aFromScroll)
     mSynthMouseMoveEvent.Forget();
 
   NS_ASSERTION(IsRootVM(), "Only the root view manager should be here");
 
-  if (mMouseLocation == nsPoint(NSCOORD_NONE, NSCOORD_NONE) || !mRootView) {
+  if (mMouseLocation == nsIntPoint(NSCOORD_NONE, NSCOORD_NONE) || !mRootView) {
     mSynthMouseMoveEvent.Forget();
     return;
   }
 
   // Hold a ref to ourselves so DispatchEvent won't destroy us (since
   // we need to access members after we call DispatchEvent).
   nsCOMPtr<nsIViewManager> kungFuDeathGrip(this);
   
 #ifdef DEBUG_MOUSE_LOCATION
   printf("[vm=%p]synthesizing mouse move to (%d,%d)\n",
          this, mMouseLocation.x, mMouseLocation.y);
 #endif
                                                        
-  nsPoint pt = mMouseLocation;
+  nsPoint pt;
   PRInt32 p2a = mContext->AppUnitsPerDevPixel();
   pt.x = NSIntPixelsToAppUnits(mMouseLocation.x, p2a);
   pt.y = NSIntPixelsToAppUnits(mMouseLocation.y, p2a);
   // This could be a bit slow (traverses entire view hierarchy)
   // but it's OK to do it once per synthetic mouse event
   nsView* view = FindFloatingViewContaining(mRootView, pt);
-  nsPoint offset(0, 0);
+  nsIntPoint offset(0, 0);
   if (!view) {
     view = mRootView;
   } else {
-    offset = view->GetOffsetTo(mRootView);
-    offset.x = NSAppUnitsToIntPixels(offset.x, p2a);
-    offset.y = NSAppUnitsToIntPixels(offset.y, p2a);
+    nsPoint viewoffset(view->GetOffsetTo(mRootView));
+    offset.x = NSAppUnitsToIntPixels(viewoffset.x, p2a);
+    offset.y = NSAppUnitsToIntPixels(viewoffset.y, p2a);
   }
   nsMouseEvent event(PR_TRUE, NS_MOUSE_MOVE, view->GetWidget(),
                      nsMouseEvent::eSynthesized);
   event.refPoint = mMouseLocation - offset;
   event.time = PR_IntervalNow();
   // XXX set event.isShift, event.isControl, event.isAlt, event.isMeta ?
 
   nsEventStatus status;
--- a/view/src/nsViewManager.h
+++ b/view/src/nsViewManager.h
@@ -188,17 +188,17 @@ public:
    * @param aView view that aRect coordinates are specified relative to
    * @param aRect rectangle in twips to test for visibility 
    * @param aMinTwips is the min. pixel rows or cols at edge of screen 
    *                  needed for object to be counted visible
    * @param aRectVisibility returns eVisible if the rect is visible, 
    *                        otherwise it returns an enum indicating why not
    */
   NS_IMETHOD GetRectVisibility(nsIView *aView, const nsRect &aRect, 
-                               PRUint16 aMinTwips, 
+                               nscoord aMinTwips, 
                                nsRectVisibility *aRectVisibility);
 
   NS_IMETHOD SynthesizeMouseMove(PRBool aFromScroll);
   void ProcessSynthMouseMoveEvent(PRBool aFromScroll);
 
   /* Update the cached RootViewManager pointer on this view manager. */
   void InvalidateHierarchy();
 
@@ -286,17 +286,17 @@ private:
    */
   void UpdateWidgetsForView(nsView* aView);
 
   /**
    * Transforms a rectangle from aView's coordinate system to the coordinate
    * system of the widget attached to aWidgetView, which should be an ancestor
    * of aView.
    */
-  void ViewToWidget(nsView *aView, nsView* aWidgetView, nsRect &aRect) const;
+  nsIntRect ViewToWidget(nsView *aView, nsView* aWidgetView, const nsRect &aRect) const;
 
   /**
    * Transforms a rectangle from specified view's coordinate system to
    * an absolute coordinate rectangle which can be compared against the
    * rectangle returned by GetVisibleRect to determine visibility.
    * @param aView view that aRect coordinates are specified relative to
    * @param aRect rectangle in twips to convert to absolute coordinates
    * @param aAbsRect rectangle in absolute coorindates.
@@ -428,17 +428,17 @@ public: // NOT in nsIViewManager, so pri
   // Call this when you need to let the viewmanager know that it now has
   // pending updates.
   void PostPendingUpdate() { RootViewManager()->mHasPendingUpdates = PR_TRUE; }
 private:
   nsIDeviceContext  *mContext;
   nsIViewObserver   *mObserver;
   nsIScrollableView *mRootScrollable;
   nscolor           mDefaultBackgroundColor;
-  nsPoint           mMouseLocation; // device units, relative to mRootView
+  nsIntPoint        mMouseLocation; // device units, relative to mRootView
 
   // The size for a resize that we delayed until the root view becomes
   // visible again.
   nsSize            mDelayedResize;
 
   nsCOMPtr<nsIFactory> mRegionFactory;
   nsView            *mRootView;
   // mRootViewManager is a strong ref unless it equals |this|.  It's
--- a/widget/public/nsGUIEvent.h
+++ b/widget/public/nsGUIEvent.h
@@ -440,17 +440,17 @@ public:
     MOZ_COUNT_DTOR(nsEvent);
   }
 
   // See event struct types
   PRUint8     eventStructType;
   // See GUI MESSAGES,
   PRUint32    message;
   // In widget relative coordinates, not modified by layout code.
-  nsPoint     refPoint;
+  nsIntPoint  refPoint;
   // Elapsed time, in milliseconds, from a platform-specific zero time
   // to the time the message was created
   PRUint32    time;
   // Flags to hold event flow stage and capture/bubble cancellation
   // status. This is used also to indicate whether the event is trusted.
   PRUint32    flags;
   // Additional type info for user defined events
   nsCOMPtr<nsIAtom>     userType;
@@ -526,17 +526,17 @@ class nsSizeEvent : public nsGUIEvent
 public:
   nsSizeEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
     : nsGUIEvent(isTrusted, msg, w, NS_SIZE_EVENT),
       windowSize(nsnull), mWinWidth(0), mWinHeight(0)
   {
   }
 
   /// x,y width, height in pixels (client area)
-  nsRect          *windowSize;    
+  nsIntRect       *windowSize;    
   /// width of entire window (in pixels)
   PRInt32         mWinWidth;    
   /// height of entire window (in pixels)
   PRInt32         mWinHeight;    
 };
 
 /**
  * Window size mode event
@@ -588,17 +588,17 @@ public:
   {
   }
 
   /// Context to paint in.
   nsIRenderingContext *renderingContext;
   /// area to paint  (should be used instead of rect)
   nsIRegion           *region;
   /// x,y, width, height in pixels of area to paint
-  nsRect              *rect;      
+  nsIntRect           *rect;      
 };
 
 /**
  * Scrollbar event
  */
 
 class nsScrollbarEvent : public nsGUIEvent
 {
@@ -817,17 +817,17 @@ typedef nsTextRange* nsTextRangeArray;
 
 struct nsTextEventReply
 {
   nsTextEventReply()
     : mCursorIsCollapsed(PR_FALSE), mReferenceWidget(nsnull)
   {
   }
 
-  nsRect mCursorPosition;
+  nsIntRect mCursorPosition;
   PRBool mCursorIsCollapsed;
   nsIWidget* mReferenceWidget;
 };
 
 typedef struct nsTextEventReply nsTextEventReply;
 
 class nsTextEvent : public nsInputEvent
 {
@@ -956,17 +956,17 @@ public:
   struct {
     PRUint32 mOffset;
     PRUint32 mLength;
   } mInput;
   struct {
     void* mContentsRoot;
     PRUint32 mOffset;
     nsString mString;
-    nsRect mRect; // Finally, the coordinates is system coordinates.
+    nsIntRect mRect; // Finally, the coordinates is system coordinates.
     // The return widget has the caret. This is set at all query events.
     nsIWidget* mFocusedWidget;
   } mReply;
 };
 
 /**
  * MenuItem event
  * 
--- a/widget/public/nsIPrintSettings.idl
+++ b/widget/public/nsIPrintSettings.idl
@@ -44,26 +44,26 @@
 
 %{ C++
 #include "nsMargin.h"
 %}
 
 /**
  * Native types
  */
-  [ref] native nsNativeMarginRef(nsMargin);
+  [ref] native nsNativeIntMarginRef(nsIntMargin);
   
 interface nsIPrintSession;
 
 /**
  * Simplified graphics interface for JS rendering.
  *
  * @status UNDER_REVIEW
  */
-[scriptable, uuid(5af07661-6477-4235-8814-4a45215855b8)]
+[scriptable, uuid(343700dd-078b-42b6-a809-b9c1d7e951d0)]
 
 interface nsIPrintSettings : nsISupports
 {
   /**
    * PrintSettings to be Saved Navigation Constants
    */
   const unsigned long kInitSaveOddEvenPages   = 0x00000001;
   const unsigned long kInitSaveHeaderLeft     = 0x00000002;
@@ -299,21 +299,21 @@ interface nsIPrintSettings : nsISupports
    * This attribute tracks whether the PS has been initialized 
    * from prefs. If a different name is set into the "printerName" 
    * attribute than the one it was initialized with the PS
    * will then get intialized from prefs again.
    */
   attribute boolean isInitializedFromPrefs;
 
   /* C++ Helper Functions */
-  [noscript] void SetMarginInTwips(in nsNativeMarginRef aMargin);
-  [noscript] void SetEdgeInTwips(in nsNativeMarginRef aEdge);
+  [noscript] void SetMarginInTwips(in nsNativeIntMarginRef aMargin);
+  [noscript] void SetEdgeInTwips(in nsNativeIntMarginRef aEdge);
   /* Purposely made this an "in" arg */
-  [noscript] void GetMarginInTwips(in nsNativeMarginRef aMargin);
-  [noscript] void GetEdgeInTwips(in nsNativeMarginRef aEdge);
+  [noscript] void GetMarginInTwips(in nsNativeIntMarginRef aMargin);
+  [noscript] void GetEdgeInTwips(in nsNativeIntMarginRef aEdge);
 
   /**
    * We call this function so that anything that requires a run of the event loop
    * can do so safely. The print dialog runs the event loop but in silent printing
    * that doesn't happen.
    *
    * Either this or ShowPrintDialog (but not both) MUST be called by the print engine
    * before printing, otherwise printing can fail on some platforms.
@@ -324,11 +324,11 @@ interface nsIPrintSettings : nsISupports
    * Sets/Gets the "unwriteable margin" for the page format.  This defines
    * the boundary from which we'll measure the EdgeInTwips and MarginInTwips 
    * attributes, to place the headers and content, respectively.
    *
    * Note: Implementations of SetUnwriteableMarginInTwips should handle
    * negative margin values by falling back on the system default for
    * that margin.
    */
-  [noscript] void SetUnwriteableMarginInTwips(in nsNativeMarginRef aEdge);
-  [noscript] void GetUnwriteableMarginInTwips(in nsNativeMarginRef aEdge);
+  [noscript] void SetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge);
+  [noscript] void GetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge);
 };
--- a/widget/public/nsIScreenManager.idl
+++ b/widget/public/nsIScreenManager.idl
@@ -41,17 +41,17 @@
 
 [scriptable, uuid(e224bd44-252b-4b66-b869-99738250904a)]
 interface nsIScreenManager : nsISupports
 {
     //
     // Returns the screen that contains the rectangle. If the rect overlaps
     // multiple screens, it picks the screen with the greatest area of intersection.
     //
-    // The coordinates are in pixels (not twips) and in screen coordinates.
+    // The coordinates are in pixels (not app units) and in screen coordinates.
     //
   nsIScreen screenForRect ( in long left, in long top, in long width, in long height ) ;
   
     // The screen with the menubar/taskbar. This shouldn't be needed very
     // often.
   readonly attribute nsIScreen primaryScreen;
   
     // Holds the number of screens that are available
--- a/widget/public/nsIWidget.h
+++ b/widget/public/nsIWidget.h
@@ -88,20 +88,20 @@ typedef nsEventStatus (*PR_CALLBACK EVEN
 #define NS_NATIVE_PLUGIN_PORT 8
 #define NS_NATIVE_SCREEN      9
 #define NS_NATIVE_SHELLWIDGET 10      // Get the shell GtkWidget
 #ifdef XP_MACOSX
 #define NS_NATIVE_PLUGIN_PORT_QD    100
 #define NS_NATIVE_PLUGIN_PORT_CG    101
 #endif
 
-// 0e64821f-00a2-4adc-ac3b-3439d61f4491
+// a85944af-7fce-4e45-bf04-ac12c823394b
 #define NS_IWIDGET_IID \
-{ 0x0e64821f, 0x00a2, 0x4adc, \
-  { 0xac, 0x3b, 0x34, 0x39, 0xd6, 0x1f, 0x44, 0x91 } }
+{ 0xa85944af, 0x7fce, 0x4e45, \
+  { 0xbf, 0x04, 0xac, 0x12, 0xc8, 0x23, 0x39, 0x4b } }
 
 // Hide the native window systems real window type so as to avoid
 // including native window system types and APIs. This is necessary
 // to ensure cross-platform code.
 typedef void* nsNativeWidget;
 
 /**
  * Border styles
@@ -307,17 +307,17 @@ class nsIWidget : public nsISupports {
      * @param     aContext
      * @param     aAppShell the parent application shell. If nsnull,
      *                      the parent window's application shell will be used.
      * @param     aToolkit
      * @param     aInitData data that is used for widget initialization
      *
      */
     NS_IMETHOD Create(nsIWidget        *aParent,
-                        const nsRect     &aRect,
+                        const nsIntRect  &aRect,
                         EVENT_CALLBACK   aHandleEventFunction,
                         nsIDeviceContext *aContext,
                         nsIAppShell      *aAppShell = nsnull,
                         nsIToolkit       *aToolkit = nsnull,
                         nsWidgetInitData *aInitData = nsnull) = 0;
 
     /**
      * Create and initialize a widget with a native window parent
@@ -334,17 +334,17 @@ class nsIWidget : public nsISupports {
      * to the os. The assumption is that if the event handler returns
      * false the widget does not see the event.
      *
      * @param     aParent   native window.
      * @param     aRect     the widget dimension
      * @param     aHandleEventFunction the event handler callback function
      */
     NS_IMETHOD Create(nsNativeWidget aParent,
-                        const nsRect     &aRect,
+                        const nsIntRect  &aRect,
                         EVENT_CALLBACK   aHandleEventFunction,
                         nsIDeviceContext *aContext,
                         nsIAppShell      *aAppShell = nsnull,
                         nsIToolkit       *aToolkit = nsnull,
                         nsWidgetInitData *aInitData = nsnull) = 0;
 
 
     /**
@@ -578,40 +578,40 @@ class nsIWidget : public nsISupports {
     NS_IMETHOD SetFocus(PRBool aRaise = PR_FALSE) = 0;
 
     /**
      * Get this widget's outside dimensions relative to its parent widget
      *
      * @param aRect on return it holds the  x, y, width and height of this widget
      *
      */
-    NS_IMETHOD GetBounds(nsRect &aRect) = 0;
+    NS_IMETHOD GetBounds(nsIntRect &aRect) = 0;
 
 
     /**
      * Get this widget's outside dimensions in global coordinates. (One might think this
      * could be accomplished by stringing together other methods in this interface, but
      * then one would bloody one's nose on different coordinate system handling by different
      * platforms.) This includes any title bar on the window.
      *
      *
      * @param aRect on return it holds the  x, y, width and height of this widget
      *
      */
-    NS_IMETHOD GetScreenBounds(nsRect &aRect) = 0;
+    NS_IMETHOD GetScreenBounds(nsIntRect &aRect) = 0;
 
 
     /**
      * Get this widget's client area dimensions, if the window has a 3D border appearance
      * this returns the area inside the border, The x and y are always zero
      *
      * @param aRect on return it holds the  x. y, width and height of the client area of this widget
      *
      */
-    NS_IMETHOD GetClientBounds(nsRect &aRect) = 0;
+    NS_IMETHOD GetClientBounds(nsIntRect &aRect) = 0;
 
     /**
      * Gets the width and height of the borders
      * @param aWidth the width of the border
      * @param aHeight the height of the border
      *
      */
     NS_IMETHOD GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight) = 0;
@@ -740,17 +740,17 @@ class nsIWidget : public nsISupports {
 
     /**
      * Invalidate a specified rect for a widget and repaints it.
      *
      * @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later.
      * @see #Update()
      */
 
-    NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous) = 0;
+    NS_IMETHOD Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous) = 0;
 
     /**
      * Invalidate a specified region for a widget and repaints it.
      *
      * @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later.
      * @see #Update()
      */
 
@@ -797,17 +797,17 @@ class nsIWidget : public nsISupports {
      * Scroll this widget. 
      *
      * @param aDx amount to scroll along the x-axis
      * @param aDy amount to scroll along the y-axis.
      * @param aClipRect clipping rectangle to limit the scroll to.
      *
      */
 
-    NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) = 0;
+    NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *aClipRect) = 0;
 
     /**
      * Scroll the contents of the widget. 
      * All child widgets are also scrolled by offsetting their coordinates.
      * A NS_PAINT message is synchronously dispatched for the newly exposed rectangle.
      *
      * @param aDx amount to scroll along the x-axis in pixels
      * @param aDy amount to scroll along the y-axis in pixels
@@ -821,17 +821,17 @@ class nsIWidget : public nsISupports {
      * A NS_PAINT message is synchronously dispatched for the newly exposed rectangle.
      *
      * @param aRect source rectangle to scroll in the widget in pixels
      * @param aDx x offset from the source in pixels
      * @param aDy y offset from the source in pixels
      *
      */
 
-    NS_IMETHOD ScrollRect(nsRect &aSrcRect, PRInt32 aDx, PRInt32 aDy) = 0;
+    NS_IMETHOD ScrollRect(nsIntRect &aSrcRect, PRInt32 aDx, PRInt32 aDy) = 0;
 
     /** 
      * Internal methods
      */
 
     //@{
     virtual void AddChild(nsIWidget* aChild) = 0;
     virtual void RemoveChild(nsIWidget* aChild) = 0;
@@ -891,26 +891,26 @@ class nsIWidget : public nsISupports {
 
     /**
      * Convert from this widget coordinates to screen coordinates.
      *
      * @param  aOldRect  widget coordinates stored in the x,y members
      * @param  aNewRect  screen coordinates stored in the x,y members
      */
 
-    NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) = 0;
+    NS_IMETHOD WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect) = 0;
 
     /**
      * Convert from screen coordinates to this widget's coordinates.
      *
      * @param  aOldRect  screen coordinates stored in the x,y members
      * @param  aNewRect  widget's coordinates stored in the x,y members
      */
 
-    NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) = 0;
+    NS_IMETHOD ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect) = 0;
 
     /**
      * When adjustments are to made to a whole set of child widgets, call this
      * before resizing/positioning the child windows to minimize repaints. Must
      * be followed by EndResizingChildren() after child windows have been
      * adjusted.
      *
      */
--- a/widget/src/cocoa/nsChildView.h
+++ b/widget/src/cocoa/nsChildView.h
@@ -254,35 +254,35 @@ private:
 public:
                           nsChildView();
   virtual                 ~nsChildView();
   
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIWidget interface
   NS_IMETHOD              Create(nsIWidget *aParent,
-                                 const nsRect &aRect,
+                                 const nsIntRect &aRect,
                                  EVENT_CALLBACK aHandleEventFunction,
                                  nsIDeviceContext *aContext,
                                  nsIAppShell *aAppShell = nsnull,
                                  nsIToolkit *aToolkit = nsnull,
                                  nsWidgetInitData *aInitData = nsnull);
   NS_IMETHOD              Create(nsNativeWidget aNativeParent,
-                                 const nsRect &aRect,
+                                 const nsIntRect &aRect,
                                  EVENT_CALLBACK aHandleEventFunction,
                                  nsIDeviceContext *aContext,
                                  nsIAppShell *aAppShell = nsnull,
                                  nsIToolkit *aToolkit = nsnull,
                                  nsWidgetInitData *aInitData = nsnull);
 
    // Utility method for implementing both Create(nsIWidget ...) and
    // Create(nsNativeWidget...)
 
   virtual nsresult        StandardCreate(nsIWidget *aParent,
-                              const nsRect &aRect,
+                              const nsIntRect &aRect,
                               EVENT_CALLBACK aHandleEventFunction,
                               nsIDeviceContext *aContext,
                               nsIAppShell *aAppShell,
                               nsIToolkit *aToolkit,
                               nsWidgetInitData *aInitData,
                               nsNativeWidget aNativeParent = nsnull);
 
   NS_IMETHOD              Destroy();
@@ -299,43 +299,43 @@ public:
                                             PRInt32 *aX, PRInt32 *aY);
   NS_IMETHOD              Move(PRInt32 aX, PRInt32 aY);
   NS_IMETHOD              Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
   NS_IMETHOD              Resize(PRInt32 aX, PRInt32 aY,PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
 
   NS_IMETHOD              Enable(PRBool aState);
   NS_IMETHOD              IsEnabled(PRBool *aState);
   NS_IMETHOD              SetFocus(PRBool aRaise);
-  NS_IMETHOD              SetBounds(const nsRect &aRect);
-  NS_IMETHOD              GetBounds(nsRect &aRect);
+  NS_IMETHOD              SetBounds(const nsIntRect &aRect);
+  NS_IMETHOD              GetBounds(nsIntRect &aRect);
 
   NS_IMETHOD              Invalidate(PRBool aIsSynchronous);
-  NS_IMETHOD              Invalidate(const nsRect &aRect,PRBool aIsSynchronous);
+  NS_IMETHOD              Invalidate(const nsIntRect &aRect, PRBool aIsSynchronous);
   NS_IMETHOD              InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous);
   NS_IMETHOD              Validate();
 
   virtual void*           GetNativeData(PRUint32 aDataType);
   NS_IMETHOD              SetColorMap(nsColorMap *aColorMap);
-  NS_IMETHOD              Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
-  NS_IMETHOD              WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect);
-  NS_IMETHOD              ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect);
+  NS_IMETHOD              Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *aClipRect);
+  NS_IMETHOD              WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect);
+  NS_IMETHOD              ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect);
   NS_IMETHOD              BeginResizingChildren(void);
   NS_IMETHOD              EndResizingChildren(void);
   virtual PRBool          ShowsResizeIndicator(nsIntRect* aResizerRect);
 
   static  PRBool          ConvertStatus(nsEventStatus aStatus)
                           { return aStatus == nsEventStatus_eConsumeNoDefault; }
   NS_IMETHOD              DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
 
   NS_IMETHOD              Update();
 
   virtual void      ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
-  void              LocalToWindowCoordinate(nsPoint& aPoint)            { ConvertToDeviceCoordinates(aPoint.x, aPoint.y); }
+  void              LocalToWindowCoordinate(nsIntPoint& aPoint)         { ConvertToDeviceCoordinates(aPoint.x, aPoint.y); }
   void              LocalToWindowCoordinate(nscoord& aX, nscoord& aY)   { ConvertToDeviceCoordinates(aX, aY); }
-  void              LocalToWindowCoordinate(nsRect& aRect)              { ConvertToDeviceCoordinates(aRect.x, aRect.y); }
+  void              LocalToWindowCoordinate(nsIntRect& aRect)           { ConvertToDeviceCoordinates(aRect.x, aRect.y); }
 
   NS_IMETHOD        SetMenuBar(void* aMenuBar);
   NS_IMETHOD        ShowMenuBar(PRBool aShow);
 
   NS_IMETHOD        GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
   NS_IMETHOD        SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
   
   NS_IMETHOD        SetCursor(nsCursor aCursor);
--- a/widget/src/cocoa/nsChildView.mm
+++ b/widget/src/cocoa/nsChildView.mm
@@ -134,17 +134,17 @@ nsIWidget         * gRollupWidget   = ns
 
 
 @interface ChildView(Private)
 
 // sets up our view, attaching it to its owning gecko view
 - (id)initWithFrame:(NSRect)inFrame geckoChild:(nsChildView*)inChild;
 
 // sends gecko an ime composition event
-- (nsRect) sendCompositionEvent:(PRInt32)aEventType;
+- (nsIntRect) sendCompositionEvent:(PRInt32)aEventType;
 
 // sends gecko an ime text event
 - (void) sendTextEvent:(PRUnichar*) aBuffer 
                        attributedString:(NSAttributedString*) aString
                        selectedRange:(NSRange)selRange
                        markedRange:(NSRange)markRange
                        doCommit:(BOOL)doCommit;
 
@@ -203,31 +203,31 @@ nsIWidget         * gRollupWidget   = ns
  * (0,0) in the bottom-left of the screen. Both nsRect and NSRect
  * contain width/height info, with no difference in their use.
  * If a Cocoa rect is from a flipped view, there is no need to
  * convert coordinate systems.
  */
 
 
 static inline void
-GeckoRectToNSRect(const nsRect & inGeckoRect, NSRect & outCocoaRect)
+GeckoRectToNSRect(const nsIntRect & inGeckoRect, NSRect & outCocoaRect)
 {
   outCocoaRect.origin.x = inGeckoRect.x;
   outCocoaRect.origin.y = inGeckoRect.y;
   outCocoaRect.size.width = inGeckoRect.width;
   outCocoaRect.size.height = inGeckoRect.height;
 }
 
 static inline void
-NSRectToGeckoRect(const NSRect & inCocoaRect, nsRect & outGeckoRect)
-{
-  outGeckoRect.x = static_cast<nscoord>(inCocoaRect.origin.x);
-  outGeckoRect.y = static_cast<nscoord>(inCocoaRect.origin.y);
-  outGeckoRect.width = static_cast<nscoord>(inCocoaRect.size.width);
-  outGeckoRect.height = static_cast<nscoord>(inCocoaRect.size.height);
+NSRectToGeckoRect(const NSRect & inCocoaRect, nsIntRect & outGeckoRect)
+{
+  outGeckoRect.x = NSToIntFloor(inCocoaRect.origin.x);
+  outGeckoRect.y = NSToIntFloor(inCocoaRect.origin.y);
+  outGeckoRect.width = NSToIntCeil(inCocoaRect.size.width);
+  outGeckoRect.height = NSToIntCeil(inCocoaRect.size.height);
 }
 
 
 static inline void 
 ConvertGeckoRectToMacRect(const nsRect& aRect, Rect& outMacRect)
 {
   outMacRect.left = aRect.x;
   outMacRect.top = aRect.y;
@@ -447,17 +447,17 @@ nsChildView::~nsChildView()
 
 
 NS_IMPL_ISUPPORTS_INHERITED1(nsChildView, nsBaseWidget, nsIPluginWidget)
 
 
 // Utility method for implementing both Create(nsIWidget ...)
 // and Create(nsNativeWidget...)
 nsresult nsChildView::StandardCreate(nsIWidget *aParent,
-                      const nsRect &aRect,
+                      const nsIntRect &aRect,
                       EVENT_CALLBACK aHandleEventFunction,
                       nsIDeviceContext *aContext,
                       nsIAppShell *aAppShell,
                       nsIToolkit *aToolkit,
                       nsWidgetInitData *aInitData,
                       nsNativeWidget aNativeParent)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@@ -577,31 +577,31 @@ void nsChildView::TearDownView()
   mView = nil;
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 
 // create a nsChildView
 NS_IMETHODIMP nsChildView::Create(nsIWidget *aParent,
-                      const nsRect &aRect,
+                      const nsIntRect &aRect,
                       EVENT_CALLBACK aHandleEventFunction,
                       nsIDeviceContext *aContext,
                       nsIAppShell *aAppShell,
                       nsIToolkit *aToolkit,
                       nsWidgetInitData *aInitData)
 {  
   return(StandardCreate(aParent, aRect, aHandleEventFunction, aContext,
                         aAppShell, aToolkit, aInitData, nsnull));
 }
 
 
 // Creates a main nsChildView using a native widget (an NSView)
 NS_IMETHODIMP nsChildView::Create(nsNativeWidget aNativeParent,
-                      const nsRect &aRect,
+                      const nsIntRect &aRect,
                       EVENT_CALLBACK aHandleEventFunction,
                       nsIDeviceContext *aContext,
                       nsIAppShell *aAppShell,
                       nsIToolkit *aToolkit,
                       nsWidgetInitData *aInitData)
 {
   // what we're passed in |aNativeParent| is an NSView. 
   return(StandardCreate(nsnull, aRect, aHandleEventFunction, aContext,
@@ -985,24 +985,24 @@ NS_IMETHODIMP nsChildView::SetCursor(img
   return nsBaseWidget::SetCursor(aCursor, aHotspotX, aHotspotY);
 }
 
 
 #pragma mark -
 
 
 // Get this component dimension
-NS_IMETHODIMP nsChildView::GetBounds(nsRect &aRect)
+NS_IMETHODIMP nsChildView::GetBounds(nsIntRect &aRect)
 {
   aRect = mBounds;
   return NS_OK;
 }
 
 
-NS_IMETHODIMP nsChildView::SetBounds(const nsRect &aRect)
+NS_IMETHODIMP nsChildView::SetBounds(const nsIntRect &aRect)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   nsresult rv = Inherited::SetBounds(aRect);
   if (NS_SUCCEEDED(rv)) {
     NSRect r;
     GeckoRectToNSRect(aRect, r);
     [mView setFrame:r];
@@ -1521,17 +1521,17 @@ NS_IMETHODIMP nsChildView::Invalidate(PR
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 // Invalidate this component's visible area
-NS_IMETHODIMP nsChildView::Invalidate(const nsRect &aRect, PRBool aIsSynchronous)
+NS_IMETHODIMP nsChildView::Invalidate(const nsIntRect &aRect, PRBool aIsSynchronous)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   if (!mView || !mVisible)
     return NS_OK;
 
   NSRect r;
   GeckoRectToNSRect(aRect, r);
@@ -1571,17 +1571,17 @@ NS_IMETHODIMP nsChildView::InvalidateReg
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   if (!mView || !mVisible)
     return NS_OK;
 
   // FIXME rewrite to use a Cocoa region when nsIRegion isn't a QD Region
   NSRect r;
-  nsRect bounds;
+  nsIntRect bounds;
   nsIRegion* region = const_cast<nsIRegion*>(aRegion);     // ugh. this method should be const
   region->GetBoundingBox(&bounds.x, &bounds.y, &bounds.width, &bounds.height);
   GeckoRectToNSRect(bounds, r);
   
   if (aIsSynchronous)
     [mView displayRect:r];
   else
     [mView setNeedsDisplayInRect:r];
@@ -1621,17 +1621,17 @@ NS_IMETHODIMP nsChildView::Update()
 }
 
 
 #pragma mark -
 
 
 // Scroll the bits of a view and its children
 // FIXME: I'm sure the invalidating can be optimized, just no time now.
-NS_IMETHODIMP nsChildView::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
+NS_IMETHODIMP nsChildView::Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *aClipRect)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   NS_ASSERTION(mParentView, "Attempting to scroll a view that does not have a parent");
   if (!mParentView)
     return NS_ERROR_NOT_AVAILABLE;
 
   BOOL viewWasDirty = NO;
@@ -1643,17 +1643,17 @@ NS_IMETHODIMP nsChildView::Scroll(PRInt3
   }
   
   // Scroll the children (even if the widget is not visible)
   for (nsIWidget* kid = mFirstChild; kid; kid = kid->GetNextSibling()) {
     // We use resize rather than move since it gives us control
     // over repainting.  We can scroll like a bat out of hell
     // by not wasting time invalidating the widgets, since it's
     // completely unnecessary to do so.
-    nsRect bounds;
+    nsIntRect bounds;
     kid->GetBounds(bounds);
     kid->Resize(bounds.x + aDx, bounds.y + aDy, bounds.width, bounds.height, PR_FALSE);
   }
 
   if (mOnDestroyCalled)
     return NS_OK;
 
   if (mVisible) {
@@ -1862,37 +1862,37 @@ NS_IMETHODIMP nsChildView::CalcOffset(PR
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 // Find if a point in local coordinates is inside this object
 PRBool nsChildView::PointInWidget(Point aThePoint)
 {
   // get the origin in local coordinates
-  nsPoint widgetOrigin(0, 0);
+  nsIntPoint widgetOrigin(0, 0);
   LocalToWindowCoordinate(widgetOrigin);
 
   // get rectangle relatively to the parent
-  nsRect widgetRect;
+  nsIntRect widgetRect;
   GetBounds(widgetRect);
 
   // convert the topLeft corner to local coordinates
   widgetRect.MoveBy(widgetOrigin.x, widgetOrigin.y);
 
   // finally tell whether it's a hit
   return widgetRect.Contains(aThePoint.h, aThePoint.v);
 }
 
 #pragma mark -
 
 
 //    Convert the given rect to global coordinates.
 //    @param aLocalRect  -- rect in local coordinates of this widget
 //    @param aGlobalRect -- |aLocalRect| in global coordinates
-NS_IMETHODIMP nsChildView::WidgetToScreen(const nsRect& aLocalRect, nsRect& aGlobalRect)
+NS_IMETHODIMP nsChildView::WidgetToScreen(const nsIntRect& aLocalRect, nsIntRect& aGlobalRect)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   NSRect temp;
   GeckoRectToNSRect(aLocalRect, temp);
   
   // 1. First translate this rect into window coords. The returned rect is always in
   //    bottom-left coordinates.
@@ -1922,17 +1922,17 @@ NS_IMETHODIMP nsChildView::WidgetToScree
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 //    Convert the given rect to local coordinates.
 //    @param aGlobalRect  -- rect in screen coordinates 
 //    @param aLocalRect -- |aGlobalRect| in coordinates of this widget
-NS_IMETHODIMP nsChildView::ScreenToWidget(const nsRect& aGlobalRect, nsRect& aLocalRect)
+NS_IMETHODIMP nsChildView::ScreenToWidget(const nsIntRect& aGlobalRect, nsIntRect& aLocalRect)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   NSRect temp;
   GeckoRectToNSRect(aGlobalRect, temp);
   FlipCocoaScreenCoordinate(temp.origin);
 
   temp.origin = [[mView nativeWindow] convertScreenToBase:temp.origin];   // convert to screen coords
@@ -2738,17 +2738,17 @@ NSEvent* gLastDragEvent = nil;
 
   PRBool isVisible;
   if (!mGeckoChild || NS_FAILED(mGeckoChild->IsVisible(isVisible)) ||
       !isVisible || [self isPaintingSuppressed])
     return;
 
   CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
 
-  nsRect geckoBounds;
+  nsIntRect geckoBounds;
   mGeckoChild->GetBounds(geckoBounds);
 
   NSRect bounds = [self bounds];
   nsRefPtr<gfxQuartzSurface> targetSurface =
     new gfxQuartzSurface(cgContext, gfxSize(bounds.size.width, bounds.size.height));
 
 #ifdef DEBUG_UPDATE
   fprintf (stderr, "---- Update[%p][%p] [%f %f %f %f] cgc: %p\n  gecko bounds: [%d %d %d %d]\n",
@@ -2782,17 +2782,17 @@ NSEvent* gLastDragEvent = nil;
       rgn->Union((PRInt32)r.origin.x, (PRInt32)r.origin.y, (PRInt32)r.size.width, (PRInt32)r.size.height);
 
     // to the context for clipping
     targetContext->Rectangle(gfxRect(r.origin.x, r.origin.y, r.size.width, r.size.height));
   }
   targetContext->Clip();
   
   // bounding box of the dirty area
-  nsRect fullRect;
+  nsIntRect fullRect;
   NSRectToGeckoRect(aRect, fullRect);
 
   nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, mGeckoChild);
   paintEvent.renderingContext = rc;
   paintEvent.rect = &fullRect;
   paintEvent.region = rgn;
 
   nsAutoRetainCocoaObject kungFuDeathGrip(self);
@@ -4691,24 +4691,24 @@ GetUSLayoutCharFromKeyTranslate(UInt32 a
   }
 
   ::ReleaseEvent(cloneEvent);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 
-- (nsRect)sendCompositionEvent:(PRInt32) aEventType
+- (nsIntRect)sendCompositionEvent:(PRInt32) aEventType
 {
 #ifdef DEBUG_IME
   NSLog(@"****in sendCompositionEvent; type = %d", aEventType);
 #endif
 
   if (!mGeckoChild)
-    return nsRect(0, 0, 0, 0);
+    return nsIntRect(0, 0, 0, 0);
 
   // static void init_composition_event( *aEvent, int aType)
   nsCompositionEvent event(PR_TRUE, aEventType, mGeckoChild);
   event.time = PR_IntervalNow();
   mGeckoChild->DispatchWindowEvent(event);
   return event.theReply.mCursorPosition;
 }
 
@@ -5063,17 +5063,17 @@ GetUSLayoutCharFromKeyTranslate(UInt32 a
   // XXX this returns first character rect or caret rect, it is limitation of
   // now. We need more work for returns first line rect. But current
   // implementation is enough for IMEs.
 
   NSRect rect;
   if (!mGeckoChild || theRange.location == NSNotFound)
     return rect;
 
-  nsRect r;
+  nsIntRect r;
   PRBool useCaretRect = theRange.length == 0;
   if (!useCaretRect) {
     nsQueryContentEvent charRect(PR_TRUE, NS_QUERY_CHARACTER_RECT, mGeckoChild);
     charRect.InitForQueryCharacterRect(theRange.location);
     mGeckoChild->DispatchWindowEvent(charRect);
     if (charRect.mSucceeded)
       r = charRect.mReply.mRect;
     else
--- a/widget/src/cocoa/nsCocoaUtils.h
+++ b/widget/src/cocoa/nsCocoaUtils.h
@@ -110,20 +110,20 @@ class nsCocoaUtils
   // flipped from Gecko to Cocoa or Cocoa to Gecko.
   static float FlippedScreenY(float y);
   
   // Gecko rects (nsRect) contain an origin (x,y) in a coordinate
   // system with (0,0) in the top-left of the primary screen. Cocoa rects
   // (NSRect) contain an origin (x,y) in a coordinate system with (0,0)
   // in the bottom-left of the primary screen. Both nsRect and NSRect
   // contain width/height info, with no difference in their use.
-  static NSRect GeckoRectToCocoaRect(const nsRect &geckoRect);
+  static NSRect GeckoRectToCocoaRect(const nsIntRect &geckoRect);
   
   // See explanation for geckoRectToCocoaRect, guess what this does...
-  static nsRect CocoaRectToGeckoRect(const NSRect &cocoaRect);
+  static nsIntRect CocoaRectToGeckoRect(const NSRect &cocoaRect);
   
   // Gives the location for the event in screen coordinates. Do not call this
   // unless the window the event was originally targeted at is still alive!
   static NSPoint ScreenLocationForEvent(NSEvent* anEvent);
   
   // Determines if an event happened over a window, whether or not the event
   // is for the window. Does not take window z-order into account.
   static BOOL IsEventOverWindow(NSEvent* anEvent, NSWindow* aWindow);
--- a/widget/src/cocoa/nsCocoaUtils.mm
+++ b/widget/src/cocoa/nsCocoaUtils.mm
@@ -65,40 +65,42 @@ float nsCocoaUtils::MenuBarScreenHeight(
 
 
 float nsCocoaUtils::FlippedScreenY(float y)
 {
   return MenuBarScreenHeight() - y;
 }
 
 
-NSRect nsCocoaUtils::GeckoRectToCocoaRect(const nsRect &geckoRect)
+NSRect nsCocoaUtils::GeckoRectToCocoaRect(const nsIntRect &geckoRect)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   // We only need to change the Y coordinate by starting with the primary screen
   // height, subtracting the gecko Y coordinate, and subtracting the height.
   return NSMakeRect(geckoRect.x,
                     MenuBarScreenHeight() - (geckoRect.y + geckoRect.height),
                     geckoRect.width,
                     geckoRect.height);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NSMakeRect(0.0, 0.0, 0.0, 0.0));
 }
 
 
-nsRect nsCocoaUtils::CocoaRectToGeckoRect(const NSRect &cocoaRect)
+nsIntRect nsCocoaUtils::CocoaRectToGeckoRect(const NSRect &cocoaRect)
 {
   // We only need to change the Y coordinate by starting with the primary screen
   // height and subtracting both the cocoa y origin and the height of the
   // cocoa rect.
-  return nsRect((nscoord)cocoaRect.origin.x,
-                (nscoord)(MenuBarScreenHeight() - (cocoaRect.origin.y + cocoaRect.size.height)),
-                (nscoord)cocoaRect.size.width,
-                (nscoord)cocoaRect.size.height);
+  nsIntRect rect;
+  rect.x = NSToIntFloor(cocoaRect.origin.x);
+  rect.y = NSToIntFloor(MenuBarScreenHeight() - (cocoaRect.origin.y + cocoaRect.size.height));
+  rect.width = NSToIntCeil(cocoaRect.origin.x + cocoaRect.size.width) - rect.x;
+  rect.height = NSToIntCeil(MenuBarScreenHeight() - cocoaRect.origin.y) - rect.y;
+  return rect;
 }
 
 
 NSPoint nsCocoaUtils::ScreenLocationForEvent(NSEvent* anEvent)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   return [[anEvent window] convertBaseToScreen:[anEvent locationInWindow]];
--- a/widget/src/cocoa/nsCocoaWindow.h
+++ b/widget/src/cocoa/nsCocoaWindow.h
@@ -198,37 +198,37 @@ public:
 
     nsCocoaWindow();
     virtual ~nsCocoaWindow();
 
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_NSPIWIDGETCOCOA
       
     NS_IMETHOD              Create(nsNativeWidget aParent,
-                                   const nsRect &aRect,
+                                   const nsIntRect &aRect,
                                    EVENT_CALLBACK aHandleEventFunction,
                                    nsIDeviceContext *aContext,
                                    nsIAppShell *aAppShell = nsnull,
                                    nsIToolkit *aToolkit = nsnull,
                                    nsWidgetInitData *aInitData = nsnull);
 
     NS_IMETHOD              Create(nsIWidget* aParent,
-                                   const nsRect &aRect,
+                                   const nsIntRect &aRect,
                                    EVENT_CALLBACK aHandleEventFunction,
                                    nsIDeviceContext *aContext,
                                    nsIAppShell *aAppShell = nsnull,
                                    nsIToolkit *aToolkit = nsnull,
                                    nsWidgetInitData *aInitData = nsnull);
 
     NS_IMETHOD              Destroy();
      // Utility method for implementing both Create(nsIWidget ...) and
      // Create(nsNativeWidget...)
 
     virtual nsresult        StandardCreate(nsIWidget *aParent,
-                                    const nsRect &aRect,
+                                    const nsIntRect &aRect,
                                     EVENT_CALLBACK aHandleEventFunction,
                                     nsIDeviceContext *aContext,
                                     nsIAppShell *aAppShell,
                                     nsIToolkit *aToolkit,
                                     nsWidgetInitData *aInitData,
                                     nsNativeWidget aNativeWindow = nsnull);
 
     NS_IMETHOD              Show(PRBool aState);
@@ -237,40 +237,40 @@ public:
     NS_IMETHOD              Enable(PRBool aState);
     NS_IMETHOD              IsEnabled(PRBool *aState);
     NS_IMETHOD              SetModal(PRBool aState);
     NS_IMETHOD              IsVisible(PRBool & aState);
     NS_IMETHOD              SetFocus(PRBool aState=PR_FALSE);
     NS_IMETHOD              SetMenuBar(void* aMenuBar);
     virtual nsMenuBarX*     GetMenuBar();
     NS_IMETHOD              ShowMenuBar(PRBool aShow);
-    NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect);
-    NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect);
+    NS_IMETHOD WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect);
+    NS_IMETHOD ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect);
     
     virtual void* GetNativeData(PRUint32 aDataType) ;
 
     NS_IMETHOD              ConstrainPosition(PRBool aAllowSlop,
                                               PRInt32 *aX, PRInt32 *aY);
     NS_IMETHOD              Move(PRInt32 aX, PRInt32 aY);
     NS_IMETHOD              PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
                                         nsIWidget *aWidget, PRBool aActivate);
     NS_IMETHOD              SetSizeMode(PRInt32 aMode);
 
     NS_IMETHOD              Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
     NS_IMETHOD              Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint);
-    NS_IMETHOD              GetScreenBounds(nsRect &aRect);
+    NS_IMETHOD              GetScreenBounds(nsIntRect &aRect);
     virtual PRBool          OnPaint(nsPaintEvent &event);
     void                    ReportSizeEvent(NSRect *overrideRect = nsnull);
 
     NS_IMETHOD              SetTitle(const nsAString& aTitle);
 
-    NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous);
+    NS_IMETHOD Invalidate(const nsIntRect &aRect, PRBool aIsSynchronous);
     NS_IMETHOD Invalidate(PRBool aIsSynchronous);
     NS_IMETHOD Update();
-    NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *alCipRect) { return NS_OK; }
+    NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *alCipRect) { return NS_OK; }
     NS_IMETHOD SetColorMap(nsColorMap *aColorMap) { return NS_OK; }
     NS_IMETHOD BeginResizingChildren(void) { return NS_OK; }
     NS_IMETHOD EndResizingChildren(void) { return NS_OK; }
     NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight) { return NS_OK; }
     NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight) { return NS_OK; }
     NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) ;
     NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent);
     NS_IMETHOD GetAttention(PRInt32 aCycleCount);
--- a/widget/src/cocoa/nsCocoaWindow.mm
+++ b/widget/src/cocoa/nsCocoaWindow.mm
@@ -175,17 +175,17 @@ static bool WindowSizeAllowed(PRInt32 aW
   }
   return true;
 }
 
 
 // Utility method for implementing both Create(nsIWidget ...) and
 // Create(nsNativeWidget...)
 nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent,
-                        const nsRect &aRect,
+                        const nsIntRect &aRect,
                         EVENT_CALLBACK aHandleEventFunction,
                         nsIDeviceContext *aContext,
                         nsIAppShell *aAppShell,
                         nsIToolkit *aToolkit,
                         nsWidgetInitData *aInitData,
                         nsNativeWidget aNativeWindow)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@@ -401,30 +401,30 @@ nsresult nsCocoaWindow::StandardCreate(n
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 // Create a nsCocoaWindow using a native window provided by the application
 NS_IMETHODIMP nsCocoaWindow::Create(nsNativeWidget aNativeWindow,
-                      const nsRect &aRect,
+                      const nsIntRect &aRect,
                       EVENT_CALLBACK aHandleEventFunction,
                       nsIDeviceContext *aContext,
                       nsIAppShell *aAppShell,
                       nsIToolkit *aToolkit,
                       nsWidgetInitData *aInitData)
 {
   return(StandardCreate(nsnull, aRect, aHandleEventFunction, aContext,
                         aAppShell, aToolkit, aInitData, aNativeWindow));
 }
 
 
 NS_IMETHODIMP nsCocoaWindow::Create(nsIWidget* aParent,
-                      const nsRect &aRect,
+                      const nsIntRect &aRect,
                       EVENT_CALLBACK aHandleEventFunction,
                       nsIDeviceContext *aContext,
                       nsIAppShell *aAppShell,
                       nsIToolkit *aToolkit,
                       nsWidgetInitData *aInitData)
 {
   return(StandardCreate(aParent, aRect, aHandleEventFunction, aContext,
                         aAppShell, aToolkit, aInitData, nsnull));
@@ -933,24 +933,24 @@ NS_METHOD nsCocoaWindow::SetSizeMode(PRI
 
 NS_IMETHODIMP nsCocoaWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   if (!WindowSizeAllowed(aWidth, aHeight))
     return NS_ERROR_FAILURE;
 
-  nsRect windowBounds(nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame]));
+  nsIntRect windowBounds(nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame]));
   BOOL isMoving = (windowBounds.x != aX || windowBounds.y != aY);
   BOOL isResizing = (windowBounds.width != aWidth || windowBounds.height != aHeight);
 
   if (IsResizing() || !mWindow || (!isMoving && !isResizing))
     return NS_OK;
 
-  nsRect geckoRect(aX, aY, aWidth, aHeight);
+  nsIntRect geckoRect(aX, aY, aWidth, aHeight);
   NSRect newFrame = nsCocoaUtils::GeckoRectToCocoaRect(geckoRect);
 
   // We have to report the size event -first-, to make sure that content
   // repositions itself.  Cocoa views are anchored at the bottom left,
   // so if we don't do this our child view will end up being stuck in the
   // wrong place during a resize.
   if (isResizing)
     ReportSizeEvent(&newFrame);
@@ -980,32 +980,28 @@ NS_IMETHODIMP nsCocoaWindow::Resize(PRIn
 
 NS_IMETHODIMP nsCocoaWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   if (!WindowSizeAllowed(aWidth, aHeight))
     return NS_ERROR_FAILURE;
 
-  nsRect windowBounds(nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame]));
+  nsIntRect windowBounds(nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame]));
   return Resize(windowBounds.x, windowBounds.y, aWidth, aHeight, aRepaint);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
-NS_IMETHODIMP nsCocoaWindow::GetScreenBounds(nsRect &aRect)
+NS_IMETHODIMP nsCocoaWindow::GetScreenBounds(nsIntRect &aRect)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
-  nsRect windowFrame = nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame]);
-  aRect.x = windowFrame.x;
-  aRect.y = windowFrame.y;
-  aRect.width = windowFrame.width;
-  aRect.height = windowFrame.height;
+  aRect = nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame]);
   // printf("GetScreenBounds: output: %d,%d,%d,%d\n", aRect.x, aRect.y, aRect.width, aRect.height);
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 PRBool nsCocoaWindow::OnPaint(nsPaintEvent &event)
@@ -1023,17 +1019,17 @@ NS_IMETHODIMP nsCocoaWindow::SetTitle(co
   [mWindow setTitle:title];
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
-NS_IMETHODIMP nsCocoaWindow::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
+NS_IMETHODIMP nsCocoaWindow::Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous)
 {
   if (mPopupContentView)
     return mPopupContentView->Invalidate(aRect, aIsSynchronous);
 
   return NS_OK;
 }
 
 
@@ -1221,38 +1217,38 @@ NS_IMETHODIMP nsCocoaWindow::SetFocus(PR
 
 
 NS_IMETHODIMP nsCocoaWindow::ShowMenuBar(PRBool aShow)
 {
   return NS_ERROR_FAILURE;
 }
 
 
-NS_IMETHODIMP nsCocoaWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
+NS_IMETHODIMP nsCocoaWindow::WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
-  nsRect r = nsCocoaUtils::CocoaRectToGeckoRect([mWindow contentRectForFrameRect:[mWindow frame]]);
+  nsIntRect r(nsCocoaUtils::CocoaRectToGeckoRect([mWindow contentRectForFrameRect:[mWindow frame]]));
 
   aNewRect.x = r.x + aOldRect.x;
   aNewRect.y = r.y + aOldRect.y;
   aNewRect.width = aOldRect.width;
   aNewRect.height = aOldRect.height;
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
-NS_IMETHODIMP nsCocoaWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect)
+NS_IMETHODIMP nsCocoaWindow::ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
-  nsRect r = nsCocoaUtils::CocoaRectToGeckoRect([mWindow contentRectForFrameRect:[mWindow frame]]);
+  nsIntRect r(nsCocoaUtils::CocoaRectToGeckoRect([mWindow contentRectForFrameRect:[mWindow frame]]));
 
   aNewRect.x = aOldRect.x - r.x;
   aNewRect.y = aOldRect.y - r.y;
   aNewRect.width = aOldRect.width;
   aNewRect.height = aOldRect.height;
 
   return NS_OK;
 
@@ -1541,17 +1537,17 @@ NS_IMETHODIMP nsCocoaWindow::EndSecureKe
   RollUpPopups();
 }
 
 
 - (void)windowDidMove:(NSNotification *)aNotification
 {
   // Dispatch the move event to Gecko
   nsGUIEvent guiEvent(PR_TRUE, NS_MOVE, mGeckoWindow);
-  nsRect rect;
+  nsIntRect rect;
   mGeckoWindow->GetScreenBounds(rect);
   guiEvent.refPoint.x = rect.x;
   guiEvent.refPoint.y = rect.y;
   guiEvent.time = PR_IntervalNow();
   nsEventStatus status = nsEventStatus_eIgnore;
   mGeckoWindow->DispatchEvent(&guiEvent, status);
 }
 
--- a/widget/src/cocoa/nsDragService.h
+++ b/widget/src/cocoa/nsDragService.h
@@ -62,17 +62,17 @@ public:
   // nsIDragSession
   NS_IMETHOD GetData(nsITransferable * aTransferable, PRUint32 aItemIndex);
   NS_IMETHOD IsDataFlavorSupported(const char *aDataFlavor, PRBool *_retval);
   NS_IMETHOD GetNumDropItems(PRUint32 * aNumItems);
 
 private:
 
   NSImage* ConstructDragImage(nsIDOMNode* aDOMNode,
-                              nsRect* aDragRect,
+                              nsIntRect* aDragRect,
                               nsIScriptableRegion* aRegion);
 
   nsCOMPtr<nsISupportsArray> mDataItems; // only valid for a drag started within gecko
   NSView* mNativeDragView;
   NSEvent* mNativeDragEvent;
 };
 
 #endif // nsDragService_h_
--- a/widget/src/cocoa/nsDragService.mm
+++ b/widget/src/cocoa/nsDragService.mm
@@ -155,17 +155,17 @@ static nsresult SetUpDragClipboard(nsISu
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 NSImage*
 nsDragService::ConstructDragImage(nsIDOMNode* aDOMNode,
-                                  nsRect* aDragRect,
+                                  nsIntRect* aDragRect,
                                   nsIScriptableRegion* aRegion)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   NSPoint screenPoint = [[gLastDragView window] convertBaseToScreen:[gLastDragEvent locationInWindow]];
   // Y coordinates are bottom to top, so reverse this
   if ([[NSScreen screens] count] > 0)
     screenPoint.y = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - screenPoint.y;
@@ -259,17 +259,17 @@ nsDragService::InvokeDragSession(nsIDOMN
   NS_ENSURE_SUCCESS(rv, rv);
 
   mDataItems = aTransferableArray;
 
   // put data on the clipboard
   if (NS_FAILED(SetUpDragClipboard(aTransferableArray)))
     return NS_ERROR_FAILURE;
 
-  nsRect dragRect(0, 0, 20, 20);
+  nsIntRect dragRect(0, 0, 20, 20);
   NSImage* image = ConstructDragImage(aDOMNode, &dragRect, aDragRgn);
   if (!image) {
     // if no image was returned, just draw a rectangle
     NSSize size;
     size.width = dragRect.width;
     size.height = dragRect.height;
     image = [[NSImage alloc] initWithSize:size];
     [image lockFocus];
--- a/widget/src/cocoa/nsNativeThemeCocoa.h
+++ b/widget/src/cocoa/nsNativeThemeCocoa.h
@@ -63,29 +63,29 @@ public:
   NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aDirtyRect);
   NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, 
                              nsIFrame* aFrame,
                              PRUint8 aWidgetType,
-                             nsMargin* aResult);
+                             nsIntMargin* aResult);
 
   virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
-                                  nsMargin* aResult);
+                                  nsIntMargin* aResult);
 
   virtual PRBool GetWidgetOverflow(nsIDeviceContext* aContext, nsIFrame* aFrame,
                                    PRUint8 aWidgetType, nsRect* aOverflowRect);
 
   NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
-                                  nsSize* aResult, PRBool* aIsOverridable);
+                                  nsIntSize* aResult, PRBool* aIsOverridable);
   NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, 
                                 nsIAtom* aAttribute, PRBool* aShouldRepaint);
   NS_IMETHOD ThemeChanged();
   PRBool ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType);
   PRBool WidgetIsContainer(PRUint8 aWidgetType);
   PRBool ThemeDrawsFocusForWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType);
   PRBool ThemeNeedsComboboxDropmarker();
 
--- a/widget/src/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/src/cocoa/nsNativeThemeCocoa.mm
@@ -1493,17 +1493,17 @@ nsNativeThemeCocoa::DrawWidgetBackground
 
 static const int kAquaDropdownLeftBorder = 5;
 static const int kAquaDropdownRightBorder = 22;
 
 NS_IMETHODIMP
 nsNativeThemeCocoa::GetWidgetBorder(nsIDeviceContext* aContext, 
                                     nsIFrame* aFrame,
                                     PRUint8 aWidgetType,
-                                    nsMargin* aResult)
+                                    nsIntMargin* aResult)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   aResult->SizeTo(0, 0, 0, 0);
 
   switch (aWidgetType) {
     case NS_THEME_BUTTON:
     {
@@ -1581,17 +1581,17 @@ nsNativeThemeCocoa::GetWidgetBorder(nsID
 // Return PR_FALSE here to indicate that CSS padding values should be used. There is
 // no reason to make a distinction between padding and border values, just specify
 // whatever values you want in GetWidgetBorder and only use this to return PR_TRUE
 // if you want to override CSS padding values.
 PRBool
 nsNativeThemeCocoa::GetWidgetPadding(nsIDeviceContext* aContext, 
                                      nsIFrame* aFrame,
                                      PRUint8 aWidgetType,
-                                     nsMargin* aResult)
+                                     nsIntMargin* aResult)
 {
   // We don't want CSS padding being used for certain widgets.
   // See bug 381639 for an example of why.
   switch (aWidgetType) {
     case NS_THEME_BUTTON:
     // Radios and checkboxes return a fixed size in GetMinimumWidgetSize
     // and have a meaningful baseline, so they can't have
     // author-specified padding.
@@ -1638,17 +1638,17 @@ nsNativeThemeCocoa::GetWidgetOverflow(ns
   return PR_FALSE;
 }
 
 
 NS_IMETHODIMP
 nsNativeThemeCocoa::GetMinimumWidgetSize(nsIRenderingContext* aContext,
                                          nsIFrame* aFrame,
                                          PRUint8 aWidgetType,
-                                         nsSize* aResult,
+                                         nsIntSize* aResult,
                                          PRBool* aIsOverridable)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   aResult->SizeTo(0,0);
   *aIsOverridable = PR_TRUE;
 
   switch (aWidgetType) {
--- a/widget/src/cocoa/nsScreenCocoa.mm
+++ b/widget/src/cocoa/nsScreenCocoa.mm
@@ -58,30 +58,30 @@ nsScreenCocoa::~nsScreenCocoa ()
   [mScreen release];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 NS_IMETHODIMP
 nsScreenCocoa::GetRect(PRInt32 *outX, PRInt32 *outY, PRInt32 *outWidth, PRInt32 *outHeight)
 {
-  nsRect r = nsCocoaUtils::CocoaRectToGeckoRect([mScreen frame]);
+  nsIntRect r(nsCocoaUtils::CocoaRectToGeckoRect([mScreen frame]));
 
   *outX = r.x;
   *outY = r.y;
   *outWidth = r.width;
   *outHeight = r.height;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsScreenCocoa::GetAvailRect(PRInt32 *outX, PRInt32 *outY, PRInt32 *outWidth, PRInt32 *outHeight)
 {
-  nsRect r = nsCocoaUtils::CocoaRectToGeckoRect([mScreen visibleFrame]);
+  nsIntRect r(nsCocoaUtils::CocoaRectToGeckoRect([mScreen visibleFrame]));
 
   *outX = r.x;
   *outY = r.y;
   *outWidth = r.width;
   *outHeight = r.height;
 
   return NS_OK;
 }
--- a/widget/src/cocoa/nsScreenManagerCocoa.mm
+++ b/widget/src/cocoa/nsScreenManagerCocoa.mm
@@ -71,17 +71,17 @@ nsScreenManagerCocoa::ScreenForCocoaScre
 
 NS_IMETHODIMP
 nsScreenManagerCocoa::ScreenForRect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight,
                                      nsIScreen **outScreen)
 {
     NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
     NSEnumerator *screenEnum = [[NSScreen screens] objectEnumerator];
-    NSRect inRect = nsCocoaUtils::GeckoRectToCocoaRect(nsRect(aX, aY, aWidth, aHeight));
+    NSRect inRect(nsCocoaUtils::GeckoRectToCocoaRect(nsIntRect(aX, aY, aWidth, aHeight)));
     NSScreen *screenWindowIsOn = [NSScreen mainScreen];
     float greatestArea = 0;
 
     while (NSScreen *screen = [screenEnum nextObject]) {
         NSDictionary *desc = [screen deviceDescription];
         if ([desc objectForKey:NSDeviceIsScreen] == nil)
             continue;
 
--- a/widget/src/gtk2/nsCommonWidget.cpp
+++ b/widget/src/gtk2/nsCommonWidget.cpp
@@ -123,17 +123,17 @@ void
 nsCommonWidget::DispatchDeactivateEvent(void)
 {
     nsGUIEvent event(PR_TRUE, NS_DEACTIVATE, this);
     nsEventStatus status;
     DispatchEvent(&event, status);
 }
 
 void
-nsCommonWidget::DispatchResizeEvent(nsRect &aRect, nsEventStatus &aStatus)
+nsCommonWidget::DispatchResizeEvent(nsIntRect &aRect, nsEventStatus &aStatus)
 {
     nsSizeEvent event(PR_TRUE, NS_SIZE, this);
 
     event.windowSize = &aRect;
     event.refPoint.x = aRect.x;
     event.refPoint.y = aRect.y;
     event.mWinWidth = aRect.width;
     event.mWinHeight = aRect.height;
@@ -199,17 +199,17 @@ nsCommonWidget::Show(PRBool aState)
     NativeShow(aState);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCommonWidget::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
 {
-    mBounds.SizeTo(GetSafeWindowSize(nsSize(aWidth, aHeight)));
+    mBounds.SizeTo(GetSafeWindowSize(nsIntSize(aWidth, aHeight)));
 
     if (!mCreated)
         return NS_OK;
 
     // There are several cases here that we need to handle, based on a
     // matrix of the visibility of the widget, the sanity of this resize
     // and whether or not the widget was previously sane.
 
@@ -258,31 +258,31 @@ nsCommonWidget::Resize(PRInt32 aWidth, P
         }
         else {
             mNeedsResize = PR_TRUE;
         }
     }
 
     // synthesize a resize event if this isn't a toplevel
     if (mIsTopLevel || mListenForResizes) {
-        nsRect rect(mBounds.x, mBounds.y, aWidth, aHeight);
+        nsIntRect rect(mBounds.x, mBounds.y, aWidth, aHeight);
         nsEventStatus status;
         DispatchResizeEvent(rect, status);
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCommonWidget::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight,
                        PRBool aRepaint)
 {
     mBounds.x = aX;
     mBounds.y = aY;
-    mBounds.SizeTo(GetSafeWindowSize(nsSize(aWidth, aHeight)));
+    mBounds.SizeTo(GetSafeWindowSize(nsIntSize(aWidth, aHeight)));
 
     mPlaced = PR_TRUE;
 
     if (!mCreated)
         return NS_OK;
 
     // There are several cases here that we need to handle, based on a
     // matrix of the visibility of the widget, the sanity of this resize
@@ -323,17 +323,17 @@ nsCommonWidget::Resize(PRInt32 aX, PRInt
         else {
             mNeedsResize = PR_TRUE;
             mNeedsMove = PR_TRUE;
         }
     }
 
     if (mIsTopLevel || mListenForResizes) {
         // synthesize a resize event
-        nsRect rect(aX, aY, aWidth, aHeight);
+        nsIntRect rect(aX, aY, aWidth, aHeight);
         nsEventStatus status;
         DispatchResizeEvent(rect, status);
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/widget/src/gtk2/nsCommonWidget.h
+++ b/widget/src/gtk2/nsCommonWidget.h
@@ -80,34 +80,34 @@ public:
 
     // event handling code
     void InitKeyEvent(nsKeyEvent &aEvent, GdkEventKey *aGdkEvent);
 
     void DispatchGotFocusEvent(void);
     void DispatchLostFocusEvent(void);
     void DispatchActivateEvent(void);
     void DispatchDeactivateEvent(void);
-    void DispatchResizeEvent(nsRect &aRect, nsEventStatus &aStatus);
+    void DispatchResizeEvent(nsIntRect &aRect, nsEventStatus &aStatus);
 
     NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, nsEventStatus &aStatus);
 
     // virtual interfaces for some nsIWidget methods
     virtual void NativeResize(PRInt32 aWidth,
                               PRInt32 aHeight,
                               PRBool  aRepaint) = 0;
 
     virtual void NativeResize(PRInt32 aX,
                               PRInt32 aY,
                               PRInt32 aWidth,
                               PRInt32 aHeight,
                               PRBool  aRepaint) = 0;
 
     virtual void NativeShow  (PRBool  aAction) = 0;
 
-    virtual nsSize GetSafeWindowSize(nsSize aSize) = 0;
+    virtual nsIntSize GetSafeWindowSize(const nsIntSize &aSize) = 0;
 
     // Some of the nsIWidget methods
     NS_IMETHOD         Show             (PRBool aState);
     NS_IMETHOD         Resize           (PRInt32 aWidth,
                                          PRInt32 aHeight,
                                          PRBool  aRepaint);
     NS_IMETHOD         Resize           (PRInt32 aX,
                                          PRInt32 aY,
--- a/widget/src/gtk2/nsDragService.cpp
+++ b/widget/src/gtk2/nsDragService.cpp
@@ -203,30 +203,30 @@ nsDragService::InvokeDragSession(nsIDOMN
         // start our drag.
         GdkDragContext *context = gtk_drag_begin(mHiddenWidget,
                                                  sourceList,
                                                  action,
                                                  1,
                                                  &event);
 
         PRBool needsFallbackIcon = PR_FALSE;
-        nsRect dragRect;
+        nsIntRect dragRect;
         nsPresContext* pc;
         nsRefPtr<gfxASurface> surface;
         if (mHasImage || mSelection) {
           DrawDrag(aDOMNode, aRegion, mScreenX, mScreenY,
                    &dragRect, getter_AddRefs(surface), &pc);
         }
 
         if (surface) {
           PRInt32 sx = mScreenX, sy = mScreenY;
           ConvertToUnscaledDevPixels(pc, &sx, &sy);
 
-          PRInt32 offsetX = sx - NSToIntRound(dragRect.x);
-          PRInt32 offsetY = sy - NSToIntRound(dragRect.y);
+          PRInt32 offsetX = sx - dragRect.x;
+          PRInt32 offsetY = sy - dragRect.y;
           if (!SetAlphaPixmap(surface, context, offsetX, offsetY, dragRect)) {
             GdkPixbuf* dragPixbuf =
               nsImageToPixbuf::SurfaceToPixbuf(surface, dragRect.width, dragRect.height);
             if (dragPixbuf)
               gtk_drag_set_icon_pixbuf(context, dragPixbuf, offsetX, offsetY);
             else
               needsFallbackIcon = PR_TRUE;
           }
@@ -243,17 +243,17 @@ nsDragService::InvokeDragSession(nsIDOMN
     return NS_OK;
 }
 
 PRBool
 nsDragService::SetAlphaPixmap(gfxASurface *aSurface,
                                  GdkDragContext *aContext,
                                  PRInt32 aXOffset,
                                  PRInt32 aYOffset,
-                                 const nsRect& dragRect)
+                                 const nsIntRect& dragRect)
 {
     GdkScreen* screen = gtk_widget_get_screen(mHiddenWidget);
 
     // Transparent drag icons need, like a lot of transparency-related things,
     // a compositing X window manager
     if (!gdk_screen_is_composited(screen))
       return PR_FALSE;
 
--- a/widget/src/gtk2/nsDragService.h
+++ b/widget/src/gtk2/nsDragService.h
@@ -139,18 +139,18 @@ private:
     GtkWidget     *mHiddenWidget;
     // our source data items
     nsCOMPtr<nsISupportsArray> mSourceDataItems;
     // get a list of the sources in gtk's format
     GtkTargetList *GetSourceList(void);
 
     // attempts to create a semi-transparent drag image. Returns TRUE if
     // successful, FALSE if not
-    PRBool SetAlphaPixmap(gfxASurface    *aPixbuf,
-                          GdkDragContext *aContext,
-                          PRInt32         aXOffset,
-                          PRInt32         aYOffset,
-                          const nsRect&   dragRect);
+    PRBool SetAlphaPixmap(gfxASurface     *aPixbuf,
+                          GdkDragContext  *aContext,
+                          PRInt32          aXOffset,
+                          PRInt32          aYOffset,
+                          const nsIntRect &dragRect);
 
 };
 
 #endif // nsDragService_h__
 
--- a/widget/src/gtk2/nsNativeThemeGTK.cpp
+++ b/widget/src/gtk2/nsNativeThemeGTK.cpp
@@ -809,17 +809,17 @@ nsNativeThemeGTK::DrawWidgetBackground(n
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNativeThemeGTK::GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame,
-                                  PRUint8 aWidgetType, nsMargin* aResult)
+                                  PRUint8 aWidgetType, nsIntMargin* aResult)
 {
   GtkTextDirection direction = GetTextDirection(aFrame);
   aResult->top = aResult->left = aResult->right = aResult->bottom = 0;
   switch (aWidgetType) {
   case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
   case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
     {
       MozGtkScrollbarMetrics metrics;
@@ -862,17 +862,17 @@ nsNativeThemeGTK::GetWidgetBorder(nsIDev
     }
   }
   return NS_OK;
 }
 
 PRBool
 nsNativeThemeGTK::GetWidgetPadding(nsIDeviceContext* aContext,
                                    nsIFrame* aFrame, PRUint8 aWidgetType,
-                                   nsMargin* aResult)
+                                   nsIntMargin* aResult)
 {
   switch (aWidgetType) {
     case NS_THEME_BUTTON_FOCUS:
     case NS_THEME_TOOLBAR_BUTTON:
     case NS_THEME_TOOLBAR_DUAL_BUTTON:
     case NS_THEME_TAB_SCROLLARROW_BACK:
     case NS_THEME_TAB_SCROLLARROW_FORWARD:
     case NS_THEME_DROPDOWN_BUTTON:
@@ -926,17 +926,17 @@ nsNativeThemeGTK::GetWidgetOverflow(nsID
 
   aOverflowRect->Inflate(m);
   return PR_TRUE;
 }
 
 NS_IMETHODIMP
 nsNativeThemeGTK::GetMinimumWidgetSize(nsIRenderingContext* aContext,
                                        nsIFrame* aFrame, PRUint8 aWidgetType,
-                                       nsSize* aResult, PRBool* aIsOverridable)
+                                       nsIntSize* aResult, PRBool* aIsOverridable)
 {
   aResult->width = aResult->height = 0;
   *aIsOverridable = PR_TRUE;
 
   switch (aWidgetType) {
     case NS_THEME_SCROLLBAR_BUTTON_UP:
     case NS_THEME_SCROLLBAR_BUTTON_DOWN:
       {
@@ -1082,17 +1082,17 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
   case NS_THEME_TOOLBAR_BUTTON:
   case NS_THEME_TREEVIEW_HEADER_CELL:
     {
       // Just include our border, and let the box code augment the size.
 
       nsCOMPtr<nsIDeviceContext> dc;
       aContext->GetDeviceContext(*getter_AddRefs(dc));
 
-      nsMargin border;
+      nsIntMargin border;
       nsNativeThemeGTK::GetWidgetBorder(dc, aFrame, aWidgetType, &border);
       aResult->width = border.left + border.right;
       aResult->height = border.top + border.bottom;
     }
     break;
   case NS_THEME_TOOLBAR_SEPARATOR:
     {
       gint separator_width;
--- a/widget/src/gtk2/nsNativeThemeGTK.h
+++ b/widget/src/gtk2/nsNativeThemeGTK.h
@@ -55,31 +55,31 @@ public:
 
   // The nsITheme interface.
   NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
                                   nsIFrame* aFrame, PRUint8 aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aDirtyRect);
 
   NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame,
-                             PRUint8 aWidgetType, nsMargin* aResult);
+                             PRUint8 aWidgetType, nsIntMargin* aResult);
 
   virtual NS_HIDDEN_(PRBool) GetWidgetPadding(nsIDeviceContext* aContext,
                                               nsIFrame* aFrame,
                                               PRUint8 aWidgetType,
-                                              nsMargin* aResult);
+                                              nsIntMargin* aResult);
 
   virtual NS_HIDDEN_(PRBool) GetWidgetOverflow(nsIDeviceContext* aContext,
                                                nsIFrame* aFrame,
                                                PRUint8 aWidgetType,
                                                nsRect* aOverflowRect);
 
   NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext,
                                   nsIFrame* aFrame, PRUint8 aWidgetType,
-                                  nsSize* aResult, PRBool* aIsOverridable);
+                                  nsIntSize* aResult, PRBool* aIsOverridable);
 
   NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, 
                                 nsIAtom* aAttribute, PRBool* aShouldRepaint);
 
   NS_IMETHOD ThemeChanged();
 
   NS_IMETHOD_(PRBool) ThemeSupportsWidget(nsPresContext* aPresContext,
                                           nsIFrame* aFrame,
--- a/widget/src/gtk2/nsPrintSettingsGTK.cpp
+++ b/widget/src/gtk2/nsPrintSettingsGTK.cpp
@@ -606,17 +606,17 @@ nsPrintSettingsGTK::InitUnwriteableMargi
  *
  * It's important that the following functions pass 
  * mUnwriteableMargin values rather than aUnwriteableMargin values
  * to gtk_page_setup_set_[blank]_margin, because the two may not be
  * the same.  (Specifically, negative values of aUnwriteableMargin
  * are ignored by the nsPrintSettings::SetUnwriteableMargin functions.)
  */
 NS_IMETHODIMP 
-nsPrintSettingsGTK::SetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin)
+nsPrintSettingsGTK::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin)
 {
   nsPrintSettings::SetUnwriteableMarginInTwips(aUnwriteableMargin);
   gtk_page_setup_set_top_margin(mPageSetup,
            NS_TWIPS_TO_INCHES(mUnwriteableMargin.top), GTK_UNIT_INCH);
   gtk_page_setup_set_left_margin(mPageSetup,
            NS_TWIPS_TO_INCHES(mUnwriteableMargin.left), GTK_UNIT_INCH);
   gtk_page_setup_set_bottom_margin(mPageSetup,
            NS_TWIPS_TO_INCHES(mUnwriteableMargin.bottom), GTK_UNIT_INCH);
--- a/widget/src/gtk2/nsPrintSettingsGTK.h
+++ b/widget/src/gtk2/nsPrintSettingsGTK.h
@@ -116,17 +116,17 @@ public:
 
   NS_IMETHOD GetScaling(double *aScaling);
   NS_IMETHOD SetScaling(double aScaling);
 
   // A name recognised by GTK is strongly advised here, as this is used to create a GtkPaperSize.
   NS_IMETHOD GetPaperName(PRUnichar * *aPaperName);
   NS_IMETHOD SetPaperName(const PRUnichar * aPaperName);
 
-  NS_IMETHOD SetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin);
+  NS_IMETHOD SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin);
   NS_IMETHOD SetUnwriteableMarginTop(double aUnwriteableMarginTop);
   NS_IMETHOD SetUnwriteableMarginLeft(double aUnwriteableMarginLeft);
   NS_IMETHOD SetUnwriteableMarginBottom(double aUnwriteableMarginBottom);
   NS_IMETHOD SetUnwriteableMarginRight(double aUnwriteableMarginRight);
 
   NS_IMETHOD GetPaperWidth(double *aPaperWidth);
   NS_IMETHOD SetPaperWidth(double aPaperWidth);
 
--- a/widget/src/gtk2/nsScreenGtk.cpp
+++ b/widget/src/gtk2/nsScreenGtk.cpp
@@ -109,17 +109,17 @@ nsScreenGtk :: GetColorDepth(PRInt32 *aC
 
 void
 nsScreenGtk :: Init (GdkWindow *aRootWindow)
 {
   // We listen for configure events on the root window to pick up
   // changes to this rect.  We could listen for "size_changed" signals
   // on the default screen to do this, except that doesn't work with
   // versions of GDK predating the GdkScreen object.  See bug 256646.
-  mAvailRect = mRect = nsRect(0, 0, gdk_screen_width(), gdk_screen_height());
+  mAvailRect = mRect = nsIntRect(0, 0, gdk_screen_width(), gdk_screen_height());
 
 #ifdef MOZ_X11
   // We need to account for the taskbar, etc in the available rect.
   // See http://freedesktop.org/Standards/wm-spec/index.html#id2767771
 
   // XXX do we care about _NET_WM_STRUT_PARTIAL?  That will
   // add much more complexity to the code here (our screen
   // could have a non-rectangular shape), but should
@@ -157,18 +157,18 @@ nsScreenGtk :: Init (GdkWindow *aRootWin
 
   if (!gdk_error_trap_pop() &&
       type_returned == cardinal_atom &&
       length_returned && (length_returned % 4) == 0 &&
       format_returned == 32) {
     int num_items = length_returned / sizeof(long);
 
     for (int i = 0; i < num_items; i += 4) {
-      nsRect workarea(workareas[i],     workareas[i + 1],
-                      workareas[i + 2], workareas[i + 3]);
+      nsIntRect workarea(workareas[i],     workareas[i + 1],
+                         workareas[i + 2], workareas[i + 3]);
       if (!mRect.Contains(workarea)) {
         // Note that we hit this when processing screen size changes,
         // since we'll get the configure event before the toolbars have
         // been moved.  We'll end up cleaning this up when we get the
         // change notification to the _NET_WORKAREA property.  However,
         // we still want to listen to both, so we'll handle changes
         // properly for desktop environments that don't set the
         // _NET_WORKAREA property.
@@ -182,16 +182,16 @@ nsScreenGtk :: Init (GdkWindow *aRootWin
   g_free (workareas);
 #endif
 }
 
 #ifdef MOZ_X11
 void
 nsScreenGtk :: Init (XineramaScreenInfo *aScreenInfo)
 {
-  nsRect xineRect(aScreenInfo->x_org, aScreenInfo->y_org,
-                  aScreenInfo->width, aScreenInfo->height);
+  nsIntRect xineRect(aScreenInfo->x_org, aScreenInfo->y_org,
+                     aScreenInfo->width, aScreenInfo->height);
 
   mScreenNum = aScreenInfo->screen_number;
 
   mAvailRect = mRect = xineRect;
 }
 #endif
--- a/widget/src/gtk2/nsScreenGtk.h
+++ b/widget/src/gtk2/nsScreenGtk.h
@@ -67,13 +67,13 @@ public:
 
   void Init(GdkWindow *aRootWindow);
 #ifdef MOZ_X11
   void Init(XineramaScreenInfo *aScreenInfo);
 #endif /* MOZ_X11 */
 
 private:
   PRUint32 mScreenNum;
-  nsRect mRect; // in pixels, not twips
-  nsRect mAvailRect; // in pixels, not twips
+  nsIntRect mRect;
+  nsIntRect mAvailRect;
 };
 
 #endif  // nsScreenGtk_h___ 
--- a/widget/src/gtk2/nsScreenManagerGtk.cpp
+++ b/widget/src/gtk2/nsScreenManagerGtk.cpp
@@ -252,17 +252,17 @@ nsScreenManagerGtk :: Init()
 
 
 //
 // ScreenForRect 
 //
 // Returns the screen that contains the rectangle. If the rect overlaps
 // multiple screens, it picks the screen with the greatest area of intersection.
 //
-// The coordinates are in pixels (not twips) and in screen coordinates.
+// The coordinates are in pixels (not app units) and in screen coordinates.
 //
 NS_IMETHODIMP
 nsScreenManagerGtk :: ScreenForRect ( PRInt32 aX, PRInt32 aY,
                                       PRInt32 aWidth, PRInt32 aHeight,
                                       nsIScreen **aOutScreen )
 {
   nsresult rv;
   rv = EnsureInit();
@@ -274,23 +274,23 @@ nsScreenManagerGtk :: ScreenForRect ( PR
   PRUint32 which = 0;
   // Optimize for the common case.  If the number of screens is only
   // one then this will fall through with which == 0 and will get the
   // primary screen.
   if (mCachedScreenArray.Count() > 1) {
     // walk the list of screens and find the one that has the most
     // surface area.
     PRUint32 area = 0;
-    nsRect   windowRect(aX, aY, aWidth, aHeight);
+    nsIntRect windowRect(aX, aY, aWidth, aHeight);
     for (PRInt32 i = 0, i_end = mCachedScreenArray.Count(); i < i_end; ++i) {
       PRInt32  x, y, width, height;
       x = y = width = height = 0;
       mCachedScreenArray[i]->GetRect(&x, &y, &width, &height);
       // calculate the surface area
-      nsRect screenRect(x, y, width, height);
+      nsIntRect screenRect(x, y, width, height);
       screenRect.IntersectRect(screenRect, windowRect);
       PRUint32 tempArea = screenRect.width * screenRect.height;
       if (tempArea >= area) {
         which = i;
         area = tempArea;
       }
     }
   }
--- a/widget/src/gtk2/nsWindow.cpp
+++ b/widget/src/gtk2/nsWindow.cpp
@@ -460,31 +460,31 @@ nsWindow::ReleaseGlobals()
   }
 }
 
 NS_IMPL_ISUPPORTS_INHERITED1(nsWindow, nsCommonWidget,
                              nsISupportsWeakReference)
 
 NS_IMETHODIMP
 nsWindow::Create(nsIWidget        *aParent,
-                 const nsRect     &aRect,
+                 const nsIntRect  &aRect,
                  EVENT_CALLBACK   aHandleEventFunction,
                  nsIDeviceContext *aContext,
                  nsIAppShell      *aAppShell,
                  nsIToolkit       *aToolkit,
                  nsWidgetInitData *aInitData)
 {
     nsresult rv = NativeCreate(aParent, nsnull, aRect, aHandleEventFunction,
                                aContext, aAppShell, aToolkit, aInitData);
     return rv;
 }
 
 NS_IMETHODIMP
 nsWindow::Create(nsNativeWidget aParent,
-                 const nsRect     &aRect,
+                 const nsIntRect  &aRect,
                  EVENT_CALLBACK   aHandleEventFunction,
                  nsIDeviceContext *aContext,
                  nsIAppShell      *aAppShell,
                  nsIToolkit       *aToolkit,
                  nsWidgetInitData *aInitData)
 {
     nsresult rv = NativeCreate(nsnull, aParent, aRect, aHandleEventFunction,
                                aContext, aAppShell, aToolkit, aInitData);
@@ -989,19 +989,19 @@ nsWindow::SetFocus(PRBool aRaise)
 
     LOGFOCUS(("  done dispatching events in SetFocus() [%p]\n",
               (void *)this));
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsWindow::GetScreenBounds(nsRect &aRect)
-{
-    nsRect origin(0, 0, mBounds.width, mBounds.height);
+nsWindow::GetScreenBounds(nsIntRect &aRect)
+{
+    nsIntRect origin(0, 0, mBounds.width, mBounds.height);
     WidgetToScreen(origin, aRect);
     LOG(("GetScreenBounds %d %d | %d %d | %d %d\n",
          aRect.x, aRect.y,
          mBounds.width, mBounds.height,
          aRect.width, aRect.height));
     return NS_OK;
 }
 
@@ -1259,18 +1259,18 @@ nsWindow::Invalidate(PRBool aIsSynchrono
                                &rect, FALSE);
     if (aIsSynchronous)
         gdk_window_process_updates(mDrawingarea->inner_window, FALSE);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsWindow::Invalidate(const nsRect &aRect,
-                     PRBool        aIsSynchronous)
+nsWindow::Invalidate(const nsIntRect &aRect,
+                     PRBool           aIsSynchronous)
 {
     GdkRectangle rect;
 
     rect.x = aRect.x;
     rect.y = aRect.y;
     rect.width = aRect.width;
     rect.height = aRect.height;
 
@@ -1326,35 +1326,35 @@ nsWindow::Update()
 
 NS_IMETHODIMP
 nsWindow::SetColorMap(nsColorMap *aColorMap)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsWindow::Scroll(PRInt32  aDx,
-                 PRInt32  aDy,
-                 nsRect  *aClipRect)
+nsWindow::Scroll(PRInt32     aDx,
+                 PRInt32     aDy,
+                 nsIntRect  *aClipRect)
 {
     if (!mDrawingarea)
         return NS_OK;
 
     D_DEBUG_AT( ns_Window, "%s( %4d,%4d )\n", __FUNCTION__, aDx, aDy );
 
     if (aClipRect) {
          D_DEBUG_AT( ns_Window, "  -> aClipRect: %4d,%4d-%4dx%4d\n",
                      aClipRect->x, aClipRect->y, aClipRect->width, aClipRect->height );
     }
 
     moz_drawingarea_scroll(mDrawingarea, aDx, aDy);
 
     // Update bounds on our child windows
     for (nsIWidget* kid = mFirstChild; kid; kid = kid->GetNextSibling()) {
-        nsRect bounds;
+        nsIntRect bounds;
         kid->GetBounds(bounds);
         bounds.x += aDx;
         bounds.y += aDy;
         static_cast<nsBaseWidget*>(kid)->SetBounds(bounds);
     }
 
     // Process all updates so that everything is drawn.
     gdk_window_process_all_updates();
@@ -1368,19 +1368,19 @@ nsWindow::ScrollWidgets(PRInt32 aDx,
     if (!mDrawingarea)
         return NS_OK;
 
     moz_drawingarea_scroll(mDrawingarea, aDx, aDy);
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsWindow::ScrollRect(nsRect  &aSrcRect,
-                     PRInt32  aDx,
-                     PRInt32  aDy)
+nsWindow::ScrollRect(nsIntRect  &aSrcRect,
+                     PRInt32     aDx,
+                     PRInt32     aDy)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 void*
 nsWindow::GetNativeData(PRUint32 aDataType)
 {
     switch (aDataType) {
@@ -1495,17 +1495,17 @@ nsWindow::SetMenuBar(void * aMenuBar)
 
 NS_IMETHODIMP
 nsWindow::ShowMenuBar(PRBool aShow)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
+nsWindow::WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect)
 {
     gint x = 0, y = 0;
 
     if (mContainer) {
         gdk_window_get_root_origin(GTK_WIDGET(mContainer)->window,
                                    &x, &y);
         LOG(("WidgetToScreen (container) %d %d\n", x, y));
     }
@@ -1518,17 +1518,17 @@ nsWindow::WidgetToScreen(const nsRect& a
     aNewRect.y = y + aOldRect.y;
     aNewRect.width = aOldRect.width;
     aNewRect.height = aOldRect.height;
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect)
+nsWindow::ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect)
 {
     gint x = 0, y = 0;
 
     if (mContainer) {
         gdk_window_get_root_origin(GTK_WIDGET(mContainer)->window,
                                    &x, &y);
     }
     else if (mDrawingarea) {
@@ -1890,17 +1890,17 @@ nsWindow::OnExposeEvent(GtkWidget *aWidg
         }  else {
             // global's big enough, just use it
             bufferPixmap = gBufferPixmap;
             bufferPixmapSize = gBufferPixmapSize;
         }
 
         if (bufferPixmap) {
             bufferPixmapSurface = GetSurfaceForGdkDrawable(GDK_DRAWABLE(bufferPixmap),
-                                                           nsSize(bufferPixmapSize.width, bufferPixmapSize.height));
+                                                           nsIntSize(bufferPixmapSize.width, bufferPixmapSize.height));
 
             if (bufferPixmapSurface && bufferPixmapSurface->CairoStatus()) {
                 bufferPixmapSurface = nsnull;
             }
             if (bufferPixmapSurface) {
                 gfxPlatformGtk::GetPlatform()->SetGdkDrawable(
                         static_cast<gfxASurface *>(bufferPixmapSurface), 
                         GDK_DRAWABLE(bufferPixmap));
@@ -1964,18 +1964,18 @@ nsWindow::OnExposeEvent(GtkWidget *aWidg
             
                     nsRefPtr<gfxContext> imgCtx = new gfxContext(img);
                     if (imgCtx) {
                         imgCtx->SetPattern(pattern);
                         imgCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
                         imgCtx->Paint();
                     }
 
-                    UpdateTranslucentWindowAlphaInternal(nsRect(boundsRect.x, boundsRect.y,
-                                                                boundsRect.width, boundsRect.height),
+                    UpdateTranslucentWindowAlphaInternal(nsIntRect(boundsRect.x, boundsRect.y,
+                                                                   boundsRect.width, boundsRect.height),
                                                          img->Data(), img->Stride());
                 }
             } else {
                 if (bufferPixmapSurface) {
                     ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
                     ctx->SetSource(bufferPixmapSurface);
                     ctx->Paint();
                 }
@@ -2016,17 +2016,17 @@ nsWindow::OnConfigureEvent(GtkWidget *aW
         return FALSE;
 
     // Toplevel windows need to have their bounds set so that we can
     // keep track of our location.  It's not often that the x,y is set
     // by the layout engine.  Width and height are set elsewhere.
     if (mIsTopLevel) {
         mPlaced = PR_TRUE;
         // Need to translate this into the right coordinates
-        nsRect oldrect, newrect;
+        nsIntRect oldrect, newrect;
         WidgetToScreen(oldrect, newrect);
         mBounds.x = newrect.x;
         mBounds.y = newrect.y;
     }
 
     nsGUIEvent event(PR_TRUE, NS_MOVE, this);
 
     event.refPoint.x = aEvent->x;
@@ -2042,18 +2042,18 @@ nsWindow::OnConfigureEvent(GtkWidget *aW
 
 void
 nsWindow::OnSizeAllocate(GtkWidget *aWidget, GtkAllocation *aAllocation)
 {
     LOG(("size_allocate [%p] %d %d %d %d\n",
          (void *)this, aAllocation->x, aAllocation->y,
          aAllocation->width, aAllocation->height));
 
-    nsRect rect(aAllocation->x, aAllocation->y,
-                aAllocation->width, aAllocation->height);
+    nsIntRect rect(aAllocation->x, aAllocation->y,
+                   aAllocation->width, aAllocation->height);
 
     ResizeTransparencyBitmap(rect.width, rect.height);
 
     mBounds.width = rect.width;
     mBounds.height = rect.height;
 
     if (!mDrawingarea)
         return;
@@ -2251,18 +2251,18 @@ nsWindow::OnMotionNotifyEvent(GtkWidget 
 #endif /* MOZ_X11 */
     }
     else {
         // XXX see OnScrollEvent()
         if (aEvent->window == mDrawingarea->inner_window) {
             event.refPoint.x = nscoord(aEvent->x);
             event.refPoint.y = nscoord(aEvent->y);
         } else {
-            nsRect windowRect;
-            ScreenToWidget(nsRect(nscoord(aEvent->x_root), nscoord(aEvent->y_root), 1, 1), windowRect);
+            nsIntRect windowRect;
+            ScreenToWidget(nsIntRect(NSToIntFloor(aEvent->x_root), NSToIntFloor(aEvent->y_root), 1, 1), windowRect);
 
             event.refPoint.x = windowRect.x;
             event.refPoint.y = windowRect.y;
         }
 
         event.isShift   = (aEvent->state & GDK_SHIFT_MASK)
             ? PR_TRUE : PR_FALSE;
         event.isControl = (aEvent->state & GDK_CONTROL_MASK)
@@ -2282,18 +2282,18 @@ void
 nsWindow::InitButtonEvent(nsMouseEvent &aEvent,
                           GdkEventButton *aGdkEvent)
 {
     // XXX see OnScrollEvent()
     if (aGdkEvent->window == mDrawingarea->inner_window) {
         aEvent.refPoint.x = nscoord(aGdkEvent->x);
         aEvent.refPoint.y = nscoord(aGdkEvent->y);
     } else {
-        nsRect windowRect;
-        ScreenToWidget(nsRect(nscoord(aGdkEvent->x_root), nscoord(aGdkEvent->y_root), 1, 1), windowRect);
+        nsIntRect windowRect;
+        ScreenToWidget(nsIntRect(NSToIntFloor(aGdkEvent->x_root), NSToIntFloor(aGdkEvent->y_root), 1, 1), windowRect);
 
         aEvent.refPoint.x = windowRect.x;
         aEvent.refPoint.y = windowRect.y;
     }
 
     aEvent.isShift   = (aGdkEvent->state & GDK_SHIFT_MASK) != 0;
     aEvent.isControl = (aGdkEvent->state & GDK_CONTROL_MASK) != 0;
     aEvent.isAlt     = (aGdkEvent->state & GDK_MOD1_MASK) != 0;
@@ -2833,18 +2833,18 @@ nsWindow::OnScrollEvent(GtkWidget *aWidg
     if (aEvent->window == mDrawingarea->inner_window) {
         // we are the window that the event happened on so no need for expensive ScreenToWidget
         event.refPoint.x = nscoord(aEvent->x);
         event.refPoint.y = nscoord(aEvent->y);
     } else {
         // XXX we're never quite sure which GdkWindow the event came from due to our custom bubbling
         // in scroll_event_cb(), so use ScreenToWidget to translate the screen root coordinates into
         // coordinates relative to this widget.
-        nsRect windowRect;
-        ScreenToWidget(nsRect(nscoord(aEvent->x_root), nscoord(aEvent->y_root), 1, 1), windowRect);
+        nsIntRect windowRect;
+        ScreenToWidget(nsIntRect(NSToIntFloor(aEvent->x_root), NSToIntFloor(aEvent->y_root), 1, 1), windowRect);
 
         event.refPoint.x = windowRect.x;
         event.refPoint.y = windowRect.y;
     }
 
     event.isShift   = (aEvent->state & GDK_SHIFT_MASK) != 0;
     event.isControl = (aEvent->state & GDK_CONTROL_MASK) != 0;
     event.isAlt     = (aEvent->state & GDK_MOD1_MASK) != 0;
@@ -3271,17 +3271,17 @@ GetBrandName(nsXPIDLString& brandName)
 
     if (brandName.IsEmpty())
         brandName.Assign(NS_LITERAL_STRING("Mozilla"));
 }
 
 nsresult
 nsWindow::NativeCreate(nsIWidget        *aParent,
                        nsNativeWidget    aNativeParent,
-                       const nsRect     &aRect,
+                       const nsIntRect  &aRect,
                        EVENT_CALLBACK    aHandleEventFunction,
                        nsIDeviceContext *aContext,
                        nsIAppShell      *aAppShell,
                        nsIToolkit       *aToolkit,
                        nsWidgetInitData *aInitData)
 {
     // only set the base parent if we're going to be a dialog or a
     // toplevel
@@ -3892,20 +3892,20 @@ nsWindow::NativeShow (PRBool  aAction)
             moz_drawingarea_set_visibility(mDrawingarea, FALSE);
         }
         if (mDrawingarea) {
             moz_drawingarea_set_visibility(mDrawingarea, FALSE);
         }
     }
 }
 
-nsSize
-nsWindow::GetSafeWindowSize(nsSize aSize)
-{
-    nsSize result = aSize;
+nsIntSize
+nsWindow::GetSafeWindowSize(const nsIntSize &aSize)
+{
+    nsIntSize result = aSize;
     const PRInt32 kInt16Max = 32767;
     if (result.width > kInt16Max) {
         NS_WARNING("Clamping huge window width");
         result.width = kInt16Max;
     }
     if (result.height > kInt16Max) {
         NS_WARNING("Clamping huge window height");
         result.height = kInt16Max;
@@ -4021,17 +4021,17 @@ nsWindow::ResizeTransparencyBitmap(PRInt
     delete[] mTransparencyBitmap;
     mTransparencyBitmap = newBits;
     mTransparencyBitmapWidth = aNewWidth;
     mTransparencyBitmapHeight = aNewHeight;
 }
 
 static PRBool
 ChangedMaskBits(gchar* aMaskBits, PRInt32 aMaskWidth, PRInt32 aMaskHeight,
-        const nsRect& aRect, PRUint8* aAlphas, PRInt32 aStride)
+        const nsIntRect& aRect, PRUint8* aAlphas, PRInt32 aStride)
 {
     PRInt32 x, y, xMax = aRect.XMost(), yMax = aRect.YMost();
     PRInt32 maskBytesPerRow = (aMaskWidth + 7)/8;
     for (y = aRect.y; y < yMax; y++) {
         gchar* maskBytes = aMaskBits + y*maskBytesPerRow;
         PRUint8* alphas = aAlphas;
         for (x = aRect.x; x < xMax; x++) {
             PRBool newBit = *alphas > 0;
@@ -4047,17 +4047,17 @@ ChangedMaskBits(gchar* aMaskBits, PRInt3
         aAlphas += aStride;
     }
 
     return PR_FALSE;
 }
 
 static
 void UpdateMaskBits(gchar* aMaskBits, PRInt32 aMaskWidth, PRInt32 aMaskHeight,
-        const nsRect& aRect, PRUint8* aAlphas, PRInt32 aStride)
+        const nsIntRect& aRect, PRUint8* aAlphas, PRInt32 aStride)
 {
     PRInt32 x, y, xMax = aRect.XMost(), yMax = aRect.YMost();
     PRInt32 maskBytesPerRow = (aMaskWidth + 7)/8;
     for (y = aRect.y; y < yMax; y++) {
         gchar* maskBytes = aMaskBits + y*maskBytesPerRow;
         PRUint8* alphas = aAlphas;
         for (x = aRect.x; x < xMax; x++) {
             PRBool newBit = *alphas > 0;
@@ -4082,17 +4082,17 @@ nsWindow::ApplyTransparencyBitmap()
     if (!maskBitmap)
         return;
 
     gtk_widget_shape_combine_mask(mShell, maskBitmap, 0, 0);
     gdk_bitmap_unref(maskBitmap);
 }
 
 nsresult
-nsWindow::UpdateTranslucentWindowAlphaInternal(const nsRect& aRect,
+nsWindow::UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect,
                                                PRUint8* aAlphas, PRInt32 aStride)
 {
     if (!mShell) {
         // Pass the request to the toplevel window
         GtkWidget *topWidget = nsnull;
         GetToplevelWidget(&topWidget);
         if (!topWidget)
             return NS_ERROR_FAILURE;
@@ -5502,17 +5502,17 @@ is_context_menu_key(const nsKeyEvent& aK
             (aKeyEvent.keyCode == NS_VK_CONTEXT_MENU && !aKeyEvent.isShift &&
              !aKeyEvent.isControl && !aKeyEvent.isMeta && !aKeyEvent.isAlt));
 }
 
 void
 key_event_to_context_menu_event(nsMouseEvent &aEvent,
                                 GdkEventKey *aGdkEvent)
 {
-    aEvent.refPoint = nsPoint(0, 0);
+    aEvent.refPoint = nsIntPoint(0, 0);
     aEvent.isShift = PR_FALSE;
     aEvent.isControl = PR_FALSE;
     aEvent.isAlt = PR_FALSE;
     aEvent.isMeta = PR_FALSE;
     aEvent.time = aGdkEvent->time;
     aEvent.clickCount = 1;
 }
 
@@ -6571,17 +6571,17 @@ IM_get_input_context(nsWindow *aWindow)
     return data->mDummyContext;
 }
 
 #endif
 
 #ifdef MOZ_X11
 /* static */ already_AddRefed<gfxASurface>
 nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,
-                                   const nsSize& aSize)
+                                   const nsIntSize& aSize)
 {
     GdkVisual* visual = gdk_drawable_get_visual(aDrawable);
     Display* xDisplay = gdk_x11_drawable_get_xdisplay(aDrawable);
     Drawable xDrawable = gdk_x11_drawable_get_xid(aDrawable);
 
     gfxASurface* result = nsnull;
 
     if (visual) {
--- a/widget/src/gtk2/nsWindow.h
+++ b/widget/src/gtk2/nsWindow.h
@@ -82,24 +82,24 @@ public:
     virtual ~nsWindow();
 
     static void ReleaseGlobals();
 
     NS_DECL_ISUPPORTS_INHERITED
 
     // nsIWidget
     NS_IMETHOD         Create(nsIWidget        *aParent,
-                              const nsRect     &aRect,
+                              const nsIntRect  &aRect,
                               EVENT_CALLBACK   aHandleEventFunction,
                               nsIDeviceContext *aContext,
                               nsIAppShell      *aAppShell,
                               nsIToolkit       *aToolkit,
                               nsWidgetInitData *aInitData);
     NS_IMETHOD         Create(nsNativeWidget aParent,
-                              const nsRect     &aRect,
+                              const nsIntRect  &aRect,
                               EVENT_CALLBACK   aHandleEventFunction,
                               nsIDeviceContext *aContext,
                               nsIAppShell      *aAppShell,
                               nsIToolkit       *aToolkit,
                               nsWidgetInitData *aInitData);
     NS_IMETHOD         Destroy(void);
     NS_IMETHOD         SetParent(nsIWidget* aNewParent);
     NS_IMETHOD         SetModal(PRBool aModal);
@@ -111,49 +111,49 @@ public:
                             PRInt32 aY);
     NS_IMETHOD         PlaceBehind(nsTopLevelWidgetZPlacement  aPlacement,
                                    nsIWidget                  *aWidget,
                                    PRBool                      aActivate);
     NS_IMETHOD         SetZIndex(PRInt32 aZIndex);
     NS_IMETHOD         SetSizeMode(PRInt32 aMode);
     NS_IMETHOD         Enable(PRBool aState);
     NS_IMETHOD         SetFocus(PRBool aRaise = PR_FALSE);
-    NS_IMETHOD         GetScreenBounds(nsRect &aRect);
+    NS_IMETHOD         GetScreenBounds(nsIntRect &aRect);
     NS_IMETHOD         SetForegroundColor(const nscolor &aColor);
     NS_IMETHOD         SetBackgroundColor(const nscolor &aColor);
     NS_IMETHOD         SetCursor(nsCursor aCursor);
     NS_IMETHOD         SetCursor(imgIContainer* aCursor,
                                  PRUint32 aHotspotX, PRUint32 aHotspotY);
     NS_IMETHOD         Validate();
     NS_IMETHOD         Invalidate(PRBool aIsSynchronous);
-    NS_IMETHOD         Invalidate(const nsRect &aRect,
-                                  PRBool        aIsSynchronous);
+    NS_IMETHOD         Invalidate(const nsIntRect &aRect,
+                                  PRBool           aIsSynchronous);
     NS_IMETHOD         InvalidateRegion(const nsIRegion *aRegion,
                                         PRBool           aIsSynchronous);
     NS_IMETHOD         Update();
     NS_IMETHOD         SetColorMap(nsColorMap *aColorMap);
-    NS_IMETHOD         Scroll(PRInt32  aDx,
-                              PRInt32  aDy,
-                              nsRect  *aClipRect);
+    NS_IMETHOD         Scroll(PRInt32     aDx,
+                              PRInt32     aDy,
+                              nsIntRect  *aClipRect);
     NS_IMETHOD         ScrollWidgets(PRInt32 aDx,
                                      PRInt32 aDy);
-    NS_IMETHOD         ScrollRect(nsRect  &aSrcRect,
-                                  PRInt32  aDx,
-                                  PRInt32  aDy);
+    NS_IMETHOD         ScrollRect(nsIntRect  &aSrcRect,
+                                  PRInt32     aDx,
+                                  PRInt32     aDy);
     virtual void*      GetNativeData(PRUint32 aDataType);
     NS_IMETHOD         SetBorderStyle(nsBorderStyle aBorderStyle);
     NS_IMETHOD         SetTitle(const nsAString& aTitle);
     NS_IMETHOD         SetIcon(const nsAString& aIconSpec);
     NS_IMETHOD         SetWindowClass(const nsAString& xulWinType);
     NS_IMETHOD         SetMenuBar(void * aMenuBar);
     NS_IMETHOD         ShowMenuBar(PRBool aShow);
-    NS_IMETHOD         WidgetToScreen(const nsRect& aOldRect,
-                                      nsRect& aNewRect);
-    NS_IMETHOD         ScreenToWidget(const nsRect& aOldRect,
-                                      nsRect& aNewRect);
+    NS_IMETHOD         WidgetToScreen(const nsIntRect& aOldRect,
+                                      nsIntRect& aNewRect);
+    NS_IMETHOD         ScreenToWidget(const nsIntRect& aOldRect,
+                                      nsIntRect& aNewRect);
     NS_IMETHOD         BeginResizingChildren(void);
     NS_IMETHOD         EndResizingChildren(void);
     NS_IMETHOD         EnableDragDrop(PRBool aEnable);
     virtual void       ConvertToDeviceCoordinates(nscoord &aX,
                                                   nscoord &aY);
     NS_IMETHOD         PreCreateWidget(nsWidgetInitData *aWidgetInitData);
     NS_IMETHOD         CaptureMouse(PRBool aCapture);
     NS_IMETHOD         CaptureRollupEvents(nsIRollupListener *aListener,
@@ -225,17 +225,17 @@ public:
                                                guint            aTime,
                                                gpointer         aData);
     void               OnDragLeave(void);
     void               OnDragEnter(nscoord aX, nscoord aY);
 
 
     nsresult           NativeCreate(nsIWidget        *aParent,
                                     nsNativeWidget    aNativeParent,
-                                    const nsRect     &aRect,
+                                    const nsIntRect   &aRect,
                                     EVENT_CALLBACK    aHandleEventFunction,
                                     nsIDeviceContext *aContext,
                                     nsIAppShell      *aAppShell,
                                     nsIToolkit       *aToolkit,
                                     nsWidgetInitData *aInitData);
 
     void               NativeResize(PRInt32 aWidth,
                                     PRInt32 aHeight,
@@ -243,17 +243,17 @@ public:
 
     void               NativeResize(PRInt32 aX,
                                     PRInt32 aY,
                                     PRInt32 aWidth,
                                     PRInt32 aHeight,
                                     PRBool  aRepaint);
 
     void               NativeShow  (PRBool  aAction);
-    virtual nsSize     GetSafeWindowSize(nsSize aSize);
+    virtual nsIntSize  GetSafeWindowSize(const nsIntSize &aSize);
 
     void               EnsureGrabs  (void);
     void               GrabPointer  (void);
     void               GrabKeyboard (void);
     void               ReleaseGrabs (void);
 
     enum PluginType {
         PluginType_NONE = 0,   /* do not have any plugin */
@@ -363,23 +363,23 @@ public:
     NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState);
 
 #endif
 
    void                ResizeTransparencyBitmap(PRInt32 aNewWidth, PRInt32 aNewHeight);
    void                ApplyTransparencyBitmap();
    virtual void        SetTransparencyMode(nsTransparencyMode aMode);
    virtual nsTransparencyMode GetTransparencyMode();
-   nsresult            UpdateTranslucentWindowAlphaInternal(const nsRect& aRect,
+   nsresult            UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect,
                                                             PRUint8* aAlphas, PRInt32 aStride);
 
     gfxASurface       *GetThebesSurface();
 
     static already_AddRefed<gfxASurface> GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,
-                                                                  const nsSize& aSize);
+                                                                  const nsIntSize& aSize);
 
 #ifdef ACCESSIBILITY
     static PRBool      sAccessibilityEnabled;
 #endif
 
 private:
     void               GetToplevelWidget(GtkWidget **aWidget);
     GtkWidget         *GetMozContainerWidget();
--- a/widget/src/windows/nsDragService.cpp
+++ b/widget/src/windows/nsDragService.cpp
@@ -104,17 +104,17 @@ nsDragService::CreateDragImage(nsIDOMNod
   if (!psdi)
     return PR_FALSE;
 
   memset(psdi, 0, sizeof(SHDRAGIMAGE));
   if (!aDOMNode) 
     return PR_FALSE;
 
   // Prepare the drag image
-  nsRect dragRect;
+  nsIntRect dragRect;
   nsRefPtr<gfxASurface> surface;
   nsPresContext* pc;
   DrawDrag(aDOMNode, aRegion,
            mScreenX, mScreenY,
            &dragRect, getter_AddRefs(surface), &pc);
   if (!surface)
     return PR_FALSE;
 
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -93,17 +93,17 @@ nsNativeThemeWin::nsNativeThemeWin() {
   // static widget style variables (e.g. sButtonBorderSize) should be 
   // reinitialized here.
 }
 
 nsNativeThemeWin::~nsNativeThemeWin() {
   nsUXThemeData::Invalidate();
 }
 
-static void GetNativeRect(const nsRect& aSrc, RECT& aDst) 
+static void GetNativeRect(const nsIntRect& aSrc, RECT& aDst) 
 {
   aDst.top = aSrc.y;
   aDst.bottom = aSrc.y + aSrc.height;
   aDst.left = aSrc.x;
   aDst.right = aSrc.x + aSrc.width;
 }
 
 static PRBool IsTopLevelMenu(nsIFrame *aFrame)
@@ -1181,17 +1181,17 @@ RENDER_AGAIN:
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNativeThemeWin::GetWidgetBorder(nsIDeviceContext* aContext, 
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
-                                  nsMargin* aResult)
+                                  nsIntMargin* aResult)
 {
   HANDLE theme = GetTheme(aWidgetType);
   if (!theme)
     return ClassicGetWidgetBorder(aContext, aFrame, aWidgetType, aResult); 
 
   (*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = 0;
 
   if (!WidgetIsContainer(aWidgetType) ||
@@ -1230,17 +1230,17 @@ nsNativeThemeWin::GetWidgetBorder(nsIDev
   outerRect.right = outerRect.bottom = 200;
   RECT contentRect(outerRect);
   HRESULT res = nsUXThemeData::getThemeContentRect(theme, NULL, part, state, &outerRect, &contentRect);
   
   if (FAILED(res))
     return NS_ERROR_FAILURE;
 
   // Now compute the delta in each direction and place it in our
-  // nsMargin struct.
+  // nsIntMargin struct.
   aResult->top = contentRect.top - outerRect.top;
   aResult->bottom = outerRect.bottom - contentRect.bottom;
   aResult->left = contentRect.left - outerRect.left;
   aResult->right = outerRect.right - contentRect.right;
 
   // Remove the edges for tabs that are before or after the selected tab,
   if (aWidgetType == NS_THEME_TAB_LEFT_EDGE)
     // Remove the right edge, since we won't be drawing it.
@@ -1263,17 +1263,17 @@ nsNativeThemeWin::GetWidgetBorder(nsIDev
 
   return NS_OK;
 }
 
 PRBool
 nsNativeThemeWin::GetWidgetPadding(nsIDeviceContext* aContext, 
                                    nsIFrame* aFrame,
                                    PRUint8 aWidgetType,
-                                   nsMargin* aResult)
+                                   nsIntMargin* aResult)
 {
   switch (aWidgetType) {
     // Radios and checkboxes return a fixed size in GetMinimumWidgetSize
     // and have a meaningful baseline, so they can't have
     // author-specified padding.
     case NS_THEME_CHECKBOX:
     case NS_THEME_CHECKBOX_SMALL:
     case NS_THEME_RADIO:
@@ -1409,17 +1409,17 @@ nsNativeThemeWin::GetWidgetOverflow(nsID
 #endif
 
   return PR_FALSE;
 }
 
 NS_IMETHODIMP
 nsNativeThemeWin::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
                                        PRUint8 aWidgetType,
-                                       nsSize* aResult, PRBool* aIsOverridable)
+                                       nsIntSize* aResult, PRBool* aIsOverridable)
 {
   (*aResult).width = (*aResult).height = 0;
   *aIsOverridable = PR_TRUE;
 
   HANDLE theme = GetTheme(aWidgetType);
   if (!theme)
     return ClassicGetMinimumWidgetSize(aContext, aFrame, aWidgetType, aResult, aIsOverridable);
 
@@ -1738,17 +1738,17 @@ nsNativeThemeWin::ClassicThemeSupportsWi
   }
   return PR_FALSE;
 }
 
 nsresult
 nsNativeThemeWin::ClassicGetWidgetBorder(nsIDeviceContext* aContext, 
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
-                                  nsMargin* aResult)
+                                  nsIntMargin* aResult)
 {
   switch (aWidgetType) {
     case NS_THEME_BUTTON:
       (*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 2; 
       break;
     case NS_THEME_STATUSBAR:
       (*aResult).bottom = (*aResult).left = (*aResult).right = 0;
       (*aResult).top = 2;
@@ -1817,17 +1817,17 @@ nsNativeThemeWin::ClassicGetWidgetBorder
       break;
   }
   return NS_OK;
 }
 
 nsresult
 nsNativeThemeWin::ClassicGetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
                                        PRUint8 aWidgetType,
-                                       nsSize* aResult, PRBool* aIsOverridable)
+                                       nsIntSize* aResult, PRBool* aIsOverridable)
 {
   (*aResult).width = (*aResult).height = 0;
   *aIsOverridable = PR_TRUE;
   switch (aWidgetType) {
     case NS_THEME_RADIO:
     case NS_THEME_RADIO_SMALL:
     case NS_THEME_CHECKBOX:
     case NS_THEME_CHECKBOX_SMALL:
--- a/widget/src/windows/nsNativeThemeWin.h
+++ b/widget/src/windows/nsNativeThemeWin.h
@@ -38,46 +38,49 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsITheme.h"
 #include "nsCOMPtr.h"
 #include "nsIAtom.h"
 #include "nsNativeTheme.h"
 #include <windows.h>
 
+struct nsIntRect;
+struct nsIntSize;
+
 class nsNativeThemeWin : private nsNativeTheme,
                          public nsITheme {
 public:
   NS_DECL_ISUPPORTS
 
   // The nsITheme interface.
   NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aDirtyRect);
 
   NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, 
                              nsIFrame* aFrame,
                              PRUint8 aWidgetType,
-                             nsMargin* aResult);
+                             nsIntMargin* aResult);
 
   virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
-                                  nsMargin* aResult);
+                                  nsIntMargin* aResult);
 
   virtual PRBool GetWidgetOverflow(nsIDeviceContext* aContext,
                                    nsIFrame* aFrame,
                                    PRUint8 aWidgetType,
                                    nsRect* aOverflowRect);
 
   NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
-                                  nsSize* aResult,
+                                  nsIntSize* aResult,
                                   PRBool* aIsOverridable);
 
   NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, 
                                 nsIAtom* aAttribute, PRBool* aShouldRepaint);
 
   NS_IMETHOD ThemeChanged();
 
   PRBool ThemeSupportsWidget(nsPresContext* aPresContext, 
@@ -102,21 +105,21 @@ protected:
   nsresult ClassicDrawWidgetBackground(nsIRenderingContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aClipRect);
   nsresult ClassicGetWidgetBorder(nsIDeviceContext* aContext, 
                              nsIFrame* aFrame,
                              PRUint8 aWidgetType,
-                             nsMargin* aResult);
+                             nsIntMargin* aResult);
 
   nsresult ClassicGetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
-                                  nsSize* aResult,
+                                  nsIntSize* aResult,
                                   PRBool* aIsOverridable);
 
   PRBool ClassicThemeSupportsWidget(nsPresContext* aPresContext, 
                              nsIFrame* aFrame,
                              PRUint8 aWidgetType);
 
   void DrawCheckedRect(HDC hdc, const RECT& rc, PRInt32 fore, PRInt32 back,
                        HBRUSH defaultBack);
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -815,30 +815,30 @@ NS_METHOD nsWindow::EndResizingChildren(
 {
   if (NULL != mDeferredPositioner) {
     ::EndDeferWindowPos(mDeferredPositioner);
     mDeferredPositioner = NULL;
   }
   return NS_OK;
 }
 
-NS_METHOD nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
+NS_METHOD nsWindow::WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect)
 {
   POINT point;
   point.x = aOldRect.x;
   point.y = aOldRect.y;
   ::ClientToScreen(mWnd, &point);
   aNewRect.x = point.x;
   aNewRect.y = point.y;
   aNewRect.width = aOldRect.width;
   aNewRect.height = aOldRect.height;
   return NS_OK;
 }
 
-NS_METHOD nsWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect)
+NS_METHOD nsWindow::ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect)
 {
   POINT point;
   point.x = aOldRect.x;
   point.y = aOldRect.y;
   ::ScreenToClient(mWnd, &point);
   aNewRect.x = point.x;
   aNewRect.y = point.y;
   aNewRect.width = aOldRect.width;
@@ -864,20 +864,20 @@ LPARAM nsWindow::lParamToClient(LPARAM l
   return MAKELPARAM(pt.x, pt.y);
 }
 
 //-------------------------------------------------------------------------
 //
 // Initialize an event to dispatch
 //
 //-------------------------------------------------------------------------
-void nsWindow::InitEvent(nsGUIEvent& event, nsPoint* aPoint)
+void nsWindow::InitEvent(nsGUIEvent& event, nsIntPoint* aPoint)
 {
   if (nsnull == aPoint) {     // use the point from the event
-    // get the message position in client coordinates and in twips
+    // get the message position in client coordinates
     if (mWnd != NULL) {
 
       DWORD pos = ::GetMessagePos();
       POINT cpos;
       
       cpos.x = GET_X_LPARAM(pos);
       cpos.y = GET_Y_LPARAM(pos);
 
@@ -1194,17 +1194,17 @@ LRESULT CALLBACK nsWindow::DefaultWindow
 //-------------------------------------------------------------------------
 //
 // Utility method for implementing both Create(nsIWidget ...) and
 // Create(nsNativeWidget...)
 //-------------------------------------------------------------------------
 
 nsresult
 nsWindow::StandardWindowCreate(nsIWidget *aParent,
-                               const nsRect &aRect,
+                               const nsIntRect &aRect,
                                EVENT_CALLBACK aHandleEventFunction,
                                nsIDeviceContext *aContext,
                                nsIAppShell *aAppShell,
                                nsIToolkit *aToolkit,
                                nsWidgetInitData *aInitData,
                                nsNativeWidget aNativeParent)
 {
   nsIWidget *baseParent = aInitData &&
@@ -1358,17 +1358,17 @@ nsWindow::StandardWindowCreate(nsIWidget
 }
 
 //-------------------------------------------------------------------------
 //
 // Create the proper widget
 //
 //-------------------------------------------------------------------------
 NS_METHOD nsWindow::Create(nsIWidget *aParent,
-                           const nsRect &aRect,
+                           const nsIntRect &aRect,
                            EVENT_CALLBACK aHandleEventFunction,
                            nsIDeviceContext *aContext,
                            nsIAppShell *aAppShell,
                            nsIToolkit *aToolkit,
                            nsWidgetInitData *aInitData)
 {
   if (aInitData)
     mUnicodeWidget = aInitData->mUnicode;
@@ -1380,17 +1380,17 @@ NS_METHOD nsWindow::Create(nsIWidget *aP
 
 //-------------------------------------------------------------------------
 //
 // create with a native parent
 //
 //-------------------------------------------------------------------------
 
 NS_METHOD nsWindow::Create(nsNativeWidget aParent,
-                           const nsRect &aRect,
+                           const nsIntRect &aRect,
                            EVENT_CALLBACK aHandleEventFunction,
                            nsIDeviceContext *aContext,
                            nsIAppShell *aAppShell,
                            nsIToolkit *aToolkit,
                            nsWidgetInitData *aInitData)
 {
   if (aInitData)
     mUnicodeWidget = aInitData->mUnicode;
@@ -2126,17 +2126,17 @@ NS_METHOD nsWindow::SetFocus(PRBool aRai
 }
 
 
 //-------------------------------------------------------------------------
 //
 // Get this component dimension
 //
 //-------------------------------------------------------------------------
-NS_METHOD nsWindow::GetBounds(nsRect &aRect)
+NS_METHOD nsWindow::GetBounds(nsIntRect &aRect)
 {
   if (mWnd) {
     RECT r;
     VERIFY(::GetWindowRect(mWnd, &r));
 
     // assign size
     aRect.width  = r.right - r.left;
     aRect.height = r.bottom - r.top;
@@ -2158,17 +2158,17 @@ NS_METHOD nsWindow::GetBounds(nsRect &aR
   return NS_OK;
 }
 
 //-------------------------------------------------------------------------
 //
 // Get this component dimension
 //
 //-------------------------------------------------------------------------
-NS_METHOD nsWindow::GetClientBounds(nsRect &aRect)
+NS_METHOD nsWindow::GetClientBounds(nsIntRect &aRect)
 {
   if (mWnd) {
     RECT r;
     VERIFY(::GetClientRect(mWnd, &r));
 
     // assign size
     aRect.x = 0;
     aRect.y = 0;
@@ -2178,17 +2178,17 @@ NS_METHOD nsWindow::GetClientBounds(nsRe
   } else {
     aRect.SetRect(0,0,0,0);
   }
   return NS_OK;
 }
 
 //get the bounds, but don't take into account the client size
 
-void nsWindow::GetNonClientBounds(nsRect &aRect)
+void nsWindow::GetNonClientBounds(nsIntRect &aRect)
 {
   if (mWnd) {
     RECT r;
     VERIFY(::GetWindowRect(mWnd, &r));
 
     // assign size
     aRect.width = r.right - r.left;
     aRect.height = r.bottom - r.top;
@@ -2204,17 +2204,17 @@ void nsWindow::GetNonClientBounds(nsRect
     aRect.x = r.left;
     aRect.y = r.top;
   } else {
     aRect.SetRect(0,0,0,0);
   }
 }
 
 // like GetBounds, but don't offset by the parent
-NS_METHOD nsWindow::GetScreenBounds(nsRect &aRect)
+NS_METHOD nsWindow::GetScreenBounds(nsIntRect &aRect)
 {
   if (mWnd) {
     RECT r;
     VERIFY(::GetWindowRect(mWnd, &r));
 
     aRect.width  = r.right - r.left;
     aRect.height = r.bottom - r.top;
     aRect.x = r.left;
@@ -2677,17 +2677,17 @@ NS_METHOD nsWindow::Invalidate(PRBool aI
   return NS_OK;
 }
 
 //-------------------------------------------------------------------------
 //
 // Invalidate this component visible area
 //
 //-------------------------------------------------------------------------
-NS_METHOD nsWindow::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
+NS_METHOD nsWindow::Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous)
 {
   if (mWnd)
   {
 #ifdef NS_DEBUG
     debug_DumpInvalidate(stdout,
                          this,
                          &aRect,
                          aIsSynchronous,
@@ -2855,17 +2855,17 @@ BOOL CALLBACK nsWindow::InvalidateForeig
 
 
 //-------------------------------------------------------------------------
 //
 // Scroll the bits of a window
 //
 //-------------------------------------------------------------------------
 //XXX Scroll is obsolete and should go away soon
-NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
+NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *aClipRect)
 {
   RECT  trect;
 
   if (nsnull != aClipRect)
   {
     trect.left = aClipRect->x;
     trect.top = aClipRect->y;
     trect.right = aClipRect->XMost();
@@ -2886,17 +2886,17 @@ NS_IMETHODIMP nsWindow::ScrollWidgets(PR
 {
   // Scroll the entire contents of the window + change the offset of any child windows
   ::ScrollWindowEx(mWnd, aDx, aDy, NULL, NULL, NULL,
                    NULL, SW_INVALIDATE | SW_SCROLLCHILDREN);
   ::UpdateWindow(mWnd); // Force synchronous generation of NS_PAINT
   return NS_OK;
 }
 
-NS_IMETHODIMP nsWindow::ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy)
+NS_IMETHODIMP nsWindow::ScrollRect(nsIntRect &aRect, PRInt32 aDx, PRInt32 aDy)
 {
   RECT  trect;
 
   trect.left = aRect.x;
   trect.top = aRect.y;
   trect.right = aRect.XMost();
   trect.bottom = aRect.YMost();
 
@@ -2918,28 +2918,28 @@ NS_IMETHODIMP nsWindow::ScrollRect(nsRec
 BOOL nsWindow::CallMethod(MethodInfo *info)
 {
   BOOL bRet = TRUE;
 
   switch (info->methodId) {
     case nsWindow::CREATE:
       NS_ASSERTION(info->nArgs == 7, "Wrong number of arguments to CallMethod");
       Create((nsIWidget*)(info->args[0]),
-             (nsRect&)*(nsRect*)(info->args[1]),
+             (nsIntRect&)*(nsIntRect*)(info->args[1]),
              (EVENT_CALLBACK)(info->args[2]),
              (nsIDeviceContext*)(info->args[3]),
              (nsIAppShell *)(info->args[4]),
              (nsIToolkit*)(info->args[5]),
              (nsWidgetInitData*)(info->args[6]));
       break;
 
     case nsWindow::CREATE_NATIVE:
       NS_ASSERTION(info->nArgs == 7, "Wrong number of arguments to CallMethod");
       Create((nsNativeWidget)(info->args[0]),
-             (nsRect&)*(nsRect*)(info->args[1]),
+             (nsIntRect&)*(nsIntRect*)(info->args[1]),
              (EVENT_CALLBACK)(info->args[2]),
              (nsIDeviceContext*)(info->args[3]),
              (nsIAppShell *)(info->args[4]),
              (nsIToolkit*)(info->args[5]),
              (nsWidgetInitData*)(info->args[6]));
       return TRUE;
 
     case nsWindow::DESTROY:
@@ -3016,17 +3016,17 @@ UINT nsWindow::MapFromNativeToDOM(UINT a
 // OnKey
 //
 //-------------------------------------------------------------------------
 PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode,
                    const nsTArray<nsAlternativeCharCode>* aAlternativeCharCodes,
                    UINT aVirtualCharCode, LPARAM aKeyData, PRUint32 aFlags)
 {
   nsKeyEvent event(PR_TRUE, aEventType, this);
-  nsPoint point(0, 0);
+  nsIntPoint point(0, 0);
 
   InitEvent(event, &point); // this add ref's event.widget
 
   event.flags |= aFlags;
   event.charCode = aCharCode;
   if (aAlternativeCharCodes)
     event.alternativeCharCodes.AppendElements(*aAlternativeCharCodes);
   event.keyCode  = aVirtualCharCode;
@@ -4129,17 +4129,17 @@ PRBool nsWindow::ProcessMessage(UINT msg
   //PrintEvent(msg, PR_FALSE, PR_FALSE);
 
   switch (msg) {
     case WM_COMMAND:
     {
       WORD wNotifyCode = HIWORD(wParam); // notification code
       if ((CBN_SELENDOK == wNotifyCode) || (CBN_SELENDCANCEL == wNotifyCode)) { // Combo box change
         nsGUIEvent event(PR_TRUE, NS_CONTROL_CHANGE, this);
-        nsPoint point(0,0);
+        nsIntPoint point(0,0);
         InitEvent(event, &point); // this add ref's event.widget
         result = DispatchWindowEvent(&event);
       } else if (wNotifyCode == 0) { // Menu selection
         nsMenuEvent event(PR_TRUE, NS_MENU_SELECTED, this);
         event.mCommand = LOWORD(wParam);
         InitEvent(event);
         result = DispatchWindowEvent(&event);
       }
@@ -4850,17 +4850,17 @@ PRBool nsWindow::ProcessMessage(UINT msg
         // XXX Why are we using the client size area? If the size notification
         // is for the client area then the origin should be (0,0) and not
         // the window origin in screen coordinates...
         RECT r;
         ::GetWindowRect(mWnd, &r);
         PRInt32 newWidth, newHeight;
         newWidth = PRInt32(r.right - r.left);
         newHeight = PRInt32(r.bottom - r.top);
-        nsRect rect(wp->x, wp->y, newWidth, newHeight);
+        nsIntRect rect(wp->x, wp->y, newWidth, newHeight);
 
 
 #ifdef MOZ_XUL
         if (eTransparencyTransparent == mTransparencyMode)
           ResizeTranslucentWindow(newWidth, newHeight);
 #endif
 
         if (newWidth > mLastSize.width)
@@ -5759,17 +5759,16 @@ ConvertHRGNToRegion(HRGN aRgn)
 
 //-------------------------------------------------------------------------
 //
 // Paint
 //
 //-------------------------------------------------------------------------
 PRBool nsWindow::OnPaint(HDC aDC)
 {
-  nsRect bounds;
   PRBool result = PR_TRUE;
   PAINTSTRUCT ps;
   nsEventStatus eventStatus = nsEventStatus_eIgnore;
 
 #ifdef MOZ_XUL
   if (!aDC && (eTransparencyTransparent == mTransparencyMode))
   {
     // For layered translucent windows all drawing should go to memory DC and no
@@ -5943,17 +5942,17 @@ PRBool nsWindow::OnPaint(HDC aDC)
 }
 
 
 //-------------------------------------------------------------------------
 //
 // Send a resize message to the listener
 //
 //-------------------------------------------------------------------------
-PRBool nsWindow::OnResize(nsRect &aWindowRect)
+PRBool nsWindow::OnResize(nsIntRect &aWindowRect)
 {
   // call the event callback
   if (mEventCallback) {
     nsSizeEvent event(PR_TRUE, NS_SIZE, this);
     InitEvent(event);
     event.windowSize = &aWindowRect;
     RECT r;
     if (::GetWindowRect(mWnd, &r)) {
@@ -5997,39 +5996,39 @@ PRBool nsWindow::DispatchMouseEvent(PRUi
                                     PRInt16 aButton)
 {
   PRBool result = PR_FALSE;
 
   if (!mEventCallback) {
     return result;
   }
 
-  nsPoint eventPoint;
+  nsIntPoint eventPoint;
   eventPoint.x = GET_X_LPARAM(lParam);
   eventPoint.y = GET_Y_LPARAM(lParam);
 
   nsMouseEvent event(PR_TRUE, aEventType, this, nsMouseEvent::eReal,
                      aIsContextMenuKey
                      ? nsMouseEvent::eContextMenuKey
                      : nsMouseEvent::eNormal);
   if (aEventType == NS_CONTEXTMENU && aIsContextMenuKey) {
-    nsPoint zero(0, 0);
+    nsIntPoint zero(0, 0);
     InitEvent(event, &zero);
   } else {
     InitEvent(event, &eventPoint);
   }
 
   event.isShift   = IS_VK_DOWN(NS_VK_SHIFT);
   event.isControl = IS_VK_DOWN(NS_VK_CONTROL);
   event.isMeta    = PR_FALSE;
   event.isAlt     = IS_VK_DOWN(NS_VK_ALT);
   event.button    = aButton;
 
-  nsRect mpWidget;
-  nsRect mpScreen;
+  nsIntRect mpWidget;
+  nsIntRect mpScreen;
   mpWidget.x = eventPoint.x;
   mpWidget.y = eventPoint.y;
   WidgetToScreen(mpWidget, mpScreen);
 
   // Suppress mouse moves caused by widget creation
   if (aEventType == NS_MOUSE_MOVE) 
   {
     if ((gLastMouseMovePoint.x == mpScreen.x) && (gLastMouseMovePoint.y == mpScreen.y))
@@ -6166,17 +6165,17 @@ PRBool nsWindow::DispatchMouseEvent(PRUi
   // call the event callback
   if (nsnull != mEventCallback) {
     if (nsToolkit::gMouseTrailer)
       nsToolkit::gMouseTrailer->Disable();
     if (aEventType == NS_MOUSE_MOVE) {
       if (nsToolkit::gMouseTrailer && !mIsInMouseCapture) {
         nsToolkit::gMouseTrailer->SetMouseTrailerWindow(mWnd);
       }
-      nsRect rect;
+      nsIntRect rect;
       GetBounds(rect);
       rect.x = 0;
       rect.y = 0;
 
       if (rect.Contains(event.refPoint)) {
         if (gCurrentWindow == NULL || gCurrentWindow != this) {
           if ((nsnull != gCurrentWindow) && (!gCurrentWindow->mIsDestroying)) {
             LPARAM pos = gCurrentWindow->lParamToClient(lParamToScreen(lParam));
@@ -6210,17 +6209,17 @@ PRBool nsWindow::DispatchMouseEvent(PRUi
 }
 
 //-------------------------------------------------------------------------
 //
 // Deal with accessibile event
 //
 //-------------------------------------------------------------------------
 #ifdef ACCESSIBILITY
-PRBool nsWindow::DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aAcc, nsPoint* aPoint)
+PRBool nsWindow::DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aAcc, nsIntPoint* aPoint)
 {
   PRBool result = PR_FALSE;
 
   if (nsnull == mEventCallback) {
     return result;
   }
 
   *aAcc = nsnull;
@@ -6454,17 +6453,17 @@ nsWindow::HandleTextEvent(HIMC hIMEConte
 {
   NS_ASSERTION(sIMECompUnicode, "sIMECompUnicode is null");
   NS_ASSERTION(sIMEIsComposing, "conflict state");
 
   if (!sIMECompUnicode)
     return;
 
   nsTextEvent event(PR_TRUE, NS_TEXT_TEXT, this);
-  nsPoint point(0, 0);
+  nsIntPoint point(0, 0);
 
   InitEvent(event, &point);
 
   if (aCheckAttr) {
     GetTextRangeList(&(event.rangeCount),&(event.rangeArray));
   } else {
     event.rangeCount = 0;
     event.rangeArray = nsnull;
@@ -6481,17 +6480,17 @@ nsWindow::HandleTextEvent(HIMC hIMEConte
   if (event.rangeArray)
     delete [] event.rangeArray;
 
   //
   // Post process event
   //
   if (event.theReply.mCursorPosition.width || event.theReply.mCursorPosition.height)
   {
-    nsRect cursorPosition;
+    nsIntRect cursorPosition;
     ResolveIMECaretPos(event.theReply.mReferenceWidget,
                        event.theReply.mCursorPosition,
                        this, cursorPosition);
     CANDIDATEFORM candForm;
     candForm.dwIndex = 0;
     candForm.dwStyle = CFS_EXCLUDE;
     candForm.ptCurrentPos.x = cursorPosition.x;
     candForm.ptCurrentPos.y = cursorPosition.y;
@@ -6547,28 +6546,28 @@ nsWindow::HandleStartComposition(HIMC hI
   // 1. WM_IME_COMPOSITION
   // 2. WM_IME_STARTCOMPOSITION
   // We call this function at both step #1 and #2.
   // However, the composition start event should occur only once.
   if (sIMEIsComposing)
     return PR_TRUE;
 
   nsCompositionEvent event(PR_TRUE, NS_COMPOSITION_START, this);
-  nsPoint point(0, 0);
+  nsIntPoint point(0, 0);
   CANDIDATEFORM candForm;
 
   InitEvent(event, &point);
   DispatchWindowEvent(&event);
 
   //
   // Post process event
   //
   if (event.theReply.mCursorPosition.width || event.theReply.mCursorPosition.height)
   {
-    nsRect cursorPosition;
+    nsIntRect cursorPosition;
     ResolveIMECaretPos(event.theReply.mReferenceWidget,
                        event.theReply.mCursorPosition,
                        this, cursorPosition);
     candForm.dwIndex = 0;
     candForm.dwStyle = CFS_CANDIDATEPOS;
     candForm.ptCurrentPos.x = cursorPosition.x + IME_X_OFFSET;
     candForm.ptCurrentPos.y = cursorPosition.y + IME_Y_OFFSET +
                               cursorPosition.height;
@@ -6610,17 +6609,17 @@ nsWindow::HandleStartComposition(HIMC hI
 
 void
 nsWindow::HandleEndComposition(void)
 {
   if (!sIMEIsComposing)
     return;
 
   nsCompositionEvent event(PR_TRUE, NS_COMPOSITION_END, this);
-  nsPoint point(0, 0);
+  nsIntPoint point(0, 0);
 
   if (gPinYinIMECaretCreated)
   {
     DestroyCaret();
     gPinYinIMECaretCreated = PR_FALSE;
   }
 
   InitEvent(event,&point);
@@ -7085,17 +7084,17 @@ PRBool nsWindow::OnIMEReconvert(LPARAM a
 #ifdef DEBUG_IME
   printf("OnIMEReconvert\n");
 #endif
 
   *oResult = 0;
   RECONVERTSTRING* pReconv = (RECONVERTSTRING*) aData;
 
   nsQueryContentEvent selection(PR_TRUE, NS_QUERY_SELECTED_TEXT, this);
-  nsPoint point(0, 0);
+  nsIntPoint point(0, 0);
   InitEvent(selection, &point);
   DispatchWindowEvent(&selection);
   if (!selection.mSucceeded)
     return PR_FALSE;
 
   if (!pReconv) {
     // Return need size to reconvert.
     if (selection.mReply.mString.IsEmpty())
@@ -7141,28 +7140,28 @@ PRBool nsWindow::OnIMEQueryCharPosition(
   *oResult = FALSE;
   IMECHARPOSITION* pCharPosition = (IMECHARPOSITION*)aData;
   if (!pCharPosition ||
       pCharPosition->dwSize < sizeof(IMECHARPOSITION) ||
       ::GetFocus() != mWnd ||
       pCharPosition->dwCharPos > len)
     return PR_FALSE;
 
-  nsPoint point(0, 0);
+  nsIntPoint point(0, 0);
 
   nsQueryContentEvent selection(PR_TRUE, NS_QUERY_SELECTED_TEXT, this);
   InitEvent(selection, &point);
   DispatchWindowEvent(&selection);
   if (!selection.mSucceeded)
     return PR_FALSE;
 
   PRUint32 offset = selection.mReply.mOffset + pCharPosition->dwCharPos;
   PRBool useCaretRect = selection.mReply.mString.IsEmpty();
 
-  nsRect r;
+  nsIntRect r;
   if (!useCaretRect) {
     nsQueryContentEvent charRect(PR_TRUE, NS_QUERY_CHARACTER_RECT, this);
     charRect.InitForQueryCharacterRect(offset);
     InitEvent(charRect, &point);
     DispatchWindowEvent(&charRect);
     if (charRect.mSucceeded)
       r = charRect.mReply.mRect;
     else
@@ -7174,17 +7173,17 @@ PRBool nsWindow::OnIMEQueryCharPosition(
     caretRect.InitForQueryCaretRect(offset);
     InitEvent(caretRect, &point);
     DispatchWindowEvent(&caretRect);
     if (!caretRect.mSucceeded)
       return PR_FALSE;
     r = caretRect.mReply.mRect;
   }
 
-  nsRect screenRect;
+  nsIntRect screenRect;
   // We always need top level window that is owner window of the popup window
   // even if the content of the popup window has focus.
   ResolveIMECaretPos(GetTopLevelWindow(PR_FALSE), r, nsnull, screenRect);
   pCharPosition->pt.x = screenRect.x;
   pCharPosition->pt.y = screenRect.y;
 
   pCharPosition->cLineHeight = r.height;
 
@@ -7193,19 +7192,19 @@ PRBool nsWindow::OnIMEQueryCharPosition(
 
   *oResult = TRUE;
   return PR_TRUE;
 }
 
 //==========================================================================
 void
 nsWindow::ResolveIMECaretPos(nsIWidget* aReferenceWidget,
-                             nsRect&    aCursorRect,
+                             nsIntRect& aCursorRect,
                              nsIWidget* aNewOriginWidget,
-                             nsRect&    aOutRect)
+                             nsIntRect& aOutRect)
 {
   aOutRect = aCursorRect;
 
   if (aReferenceWidget == aNewOriginWidget)
     return;
 
   if (aReferenceWidget)
     aReferenceWidget->WidgetToScreen(aOutRect, aOutRect);
--- a/widget/src/windows/nsWindow.h
+++ b/widget/src/windows/nsWindow.h
@@ -124,35 +124,35 @@ class nsWindow : public nsSwitchToUIThre
 public:
   nsWindow();
   virtual ~nsWindow();
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIWidget interface
   NS_IMETHOD              Create(nsIWidget *aParent,
-                                 const nsRect &aRect,
+                                 const nsIntRect &aRect,
                                  EVENT_CALLBACK aHandleEventFunction,
                                  nsIDeviceContext *aContext,
                                  nsIAppShell *aAppShell = nsnull,
                                  nsIToolkit *aToolkit = nsnull,
                                  nsWidgetInitData *aInitData = nsnull);
   NS_IMETHOD              Create(nsNativeWidget aParent,
-                                 const nsRect &aRect,
+                                 const nsIntRect &aRect,
                                  EVENT_CALLBACK aHandleEventFunction,
                                  nsIDeviceContext *aContext,
                                  nsIAppShell *aAppShell = nsnull,
                                  nsIToolkit *aToolkit = nsnull,
                                  nsWidgetInitData *aInitData = nsnull);
 
   // Utility method for implementing both Create(nsIWidget ...) and
   // Create(nsNativeWidget...)
 
   virtual nsresult        StandardWindowCreate(nsIWidget *aParent,
-                                               const nsRect &aRect,
+                                               const nsIntRect &aRect,
                                                EVENT_CALLBACK aHandleEventFunction,
                                                nsIDeviceContext *aContext,
                                                nsIAppShell *aAppShell,
                                                nsIToolkit *aToolkit,
                                                nsWidgetInitData *aInitData,
                                                nsNativeWidget aNativeParent = nsnull);
 
   NS_IMETHOD              Destroy();
@@ -166,42 +166,42 @@ public:
   NS_IMETHOD              CaptureMouse(PRBool aCapture);
   NS_IMETHOD              ConstrainPosition(PRBool aAllowSlop, PRInt32 *aX, PRInt32 *aY);
   NS_IMETHOD              Move(PRInt32 aX, PRInt32 aY);
   NS_IMETHOD              Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint);
   NS_IMETHOD              Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint);
   NS_IMETHOD              Enable(PRBool aState);
   NS_IMETHOD              IsEnabled(PRBool *aState);
   NS_IMETHOD              SetFocus(PRBool aRaise);
-  NS_IMETHOD              GetBounds(nsRect &aRect);
-  NS_IMETHOD              GetClientBounds(nsRect &aRect);
-  NS_IMETHOD              GetScreenBounds(nsRect &aRect);
+  NS_IMETHOD              GetBounds(nsIntRect &aRect);
+  NS_IMETHOD              GetClientBounds(nsIntRect &aRect);
+  NS_IMETHOD              GetScreenBounds(nsIntRect &aRect);
   NS_IMETHOD              SetBackgroundColor(const nscolor &aColor);
   NS_IMETHOD              SetCursor(nsCursor aCursor);
   NS_IMETHOD              SetCursor(imgIContainer* aCursor,
                                     PRUint32 aHotspotX, PRUint32 aHotspotY);
   NS_IMETHOD              HideWindowChrome(PRBool aShouldHide);
   NS_IMETHOD              Validate();
   NS_IMETHOD              Invalidate(PRBool aIsSynchronous);
-  NS_IMETHOD              Invalidate(const nsRect & aRect, PRBool aIsSynchronous);
+  NS_IMETHOD              Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous);
   NS_IMETHOD              InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous);
   NS_IMETHOD              Update();
   virtual void*           GetNativeData(PRUint32 aDataType);
   virtual void            FreeNativeData(void * data, PRUint32 aDataType);//~~~
   NS_IMETHOD              SetColorMap(nsColorMap *aColorMap);
   //XXX-Scroll is obsolete it is going away soon
-  NS_IMETHOD              Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
+  NS_IMETHOD              Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *aClipRect);
   NS_IMETHOD              ScrollWidgets(PRInt32 aDx, PRInt32 aDy);
-  NS_IMETHOD              ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy);
+  NS_IMETHOD              ScrollRect(nsIntRect &aRect, PRInt32 aDx, PRInt32 aDy);
   NS_IMETHOD              SetTitle(const nsAString& aTitle);
   NS_IMETHOD              SetIcon(const nsAString& aIconSpec);
   NS_IMETHOD              SetMenuBar(void * aMenuBar) { return NS_ERROR_FAILURE; }
   NS_IMETHOD              ShowMenuBar(PRBool aShow)         { return NS_ERROR_FAILURE; }
-  NS_IMETHOD              WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect);
-  NS_IMETHOD              ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect);
+  NS_IMETHOD              WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect);
+  NS_IMETHOD              ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect);
   NS_IMETHOD              BeginResizingChildren(void);
   NS_IMETHOD              EndResizingChildren(void);
   NS_IMETHOD              GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
   NS_IMETHOD              SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
   NS_IMETHOD              DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
   NS_IMETHOD              EnableDragDrop(PRBool aEnable);
 
   virtual void            SetUpForPaint(HDC aHDC);
@@ -251,25 +251,25 @@ public:
   HWND                    GetWindowHandle() { return mWnd; }
   WNDPROC                 GetPrevWindowProc() { return mPrevWndProc; }
 
   virtual PRBool          DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam,
                                              LPARAM lParam,
                                              PRBool aIsContextMenuKey = PR_FALSE,
                                              PRInt16 aButton = nsMouseEvent::eLeftButton);
 #ifdef ACCESSIBILITY
-  virtual PRBool          DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aAccessible, nsPoint* aPoint = nsnull);
+  virtual PRBool          DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aAccessible, nsIntPoint* aPoint = nsnull);
   already_AddRefed<nsIAccessible> GetRootAccessible();
 #endif
   virtual PRBool          AutoErase();
-  nsPoint*                GetLastPoint() { return &mLastPoint; }
+  nsIntPoint*             GetLastPoint() { return &mLastPoint; }
 
   PRInt32                 GetNewCmdMenuId() { mMenuCmdId++; return mMenuCmdId; }
 
-  void                    InitEvent(nsGUIEvent& event, nsPoint* aPoint = nsnull);
+  void                    InitEvent(nsGUIEvent& event, nsIntPoint* aPoint = nsnull);
 
   void                    SuppressBlurEvents(PRBool aSuppress);
   PRBool                  BlurEventsSuppressed();
 
 protected:
 
 #ifndef WINCE
 
@@ -309,17 +309,17 @@ protected:
   virtual DWORD           WindowStyle();
   virtual DWORD           WindowExStyle();
 
   virtual void            SubclassWindow(BOOL bState);
 
   virtual void            OnDestroy();
   virtual PRBool          OnMove(PRInt32 aX, PRInt32 aY);
   virtual PRBool          OnPaint(HDC aDC = nsnull);
-  virtual PRBool          OnResize(nsRect &aWindowRect);
+  virtual PRBool          OnResize(nsIntRect &aWindowRect);
   
   void                    SetupModKeyState();
   BOOL                    OnChar(UINT charCode, UINT aScanCode, PRUint32 aFlags = 0);
   BOOL                    OnKeyDown( UINT aVirtualKeyCode, LPARAM aKeyCode,
                                      nsFakeCharMessage* aFakeCharMessage);
   BOOL                    OnKeyUp( UINT aVirtualKeyCode, LPARAM aKeyCode);
   UINT                    MapFromNativeToDOM(UINT aNativeKeyCode);
 
@@ -350,19 +350,19 @@ protected:
    *                          coordinates, set nsnull.
    *  @param aCursorRect      The cursor rect.
    *  @param aNewOriginWidget aOutRect will be in this widget's coordinates. If
    *                          this is nsnull, aOutRect will be in screen
    *                          coordinates.
    *  @param aOutRect         The converted cursor rect.
    */
   void                    ResolveIMECaretPos(nsIWidget* aReferenceWidget,
-                                             nsRect&    aCursorRect,
+                                             nsIntRect& aCursorRect,
                                              nsIWidget* aNewOriginWidget,
-                                             nsRect&    aOutRect);
+                                             nsIntRect& aOutRect);
 
   virtual PRBool          DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode,
                             const nsTArray<nsAlternativeCharCode>* aAlternativeChars,
                             UINT aVirtualCharCode, LPARAM aKeyCode,
                             PRUint32 aFlags = 0);
 
   virtual PRBool          DispatchFocus(PRUint32 aEventType, PRBool isMozWindowTakingFocus);
   virtual PRBool          OnScroll(UINT scrollCode, int cPos);
@@ -374,17 +374,17 @@ protected:
   // Convert nsEventStatus value to a windows boolean
   static PRBool ConvertStatus(nsEventStatus aStatus)
                        { return aStatus == nsEventStatus_eConsumeNoDefault; }
 
   PRBool DispatchStandardEvent(PRUint32 aMsg);
   PRBool DispatchCommandEvent(PRUint32 aEventCommand);
   void RelayMouseEvent(UINT aMsg, WPARAM wParam, LPARAM lParam);
 
-  void GetNonClientBounds(nsRect &aRect);
+  void GetNonClientBounds(nsIntRect &aRect);
   void HandleTextEvent(HIMC hIMEContext, PRBool aCheckAttr=PR_TRUE);
   BOOL HandleStartComposition(HIMC hIMEContext);
   void HandleEndComposition(void);
   void GetTextRangeList(PRUint32* textRangeListLengthResult, nsTextRangeArray* textRangeListResult);
 
   void ConstrainZLevel(HWND *aAfter);
 
   LPARAM lParamToScreen(LPARAM lParam);
@@ -424,19 +424,19 @@ protected:
   static PRInt32    sIMECompClauseArraySize;
   static long       sIMECursorPosition;
 
   // For describing composing frame
   static RECT*      sIMECompCharPos;
 
   static TriStateBool sCanQuit;
 
-  nsSize        mLastSize;
+  nsIntSize     mLastSize;
   static        nsWindow* gCurrentWindow;
-  nsPoint       mLastPoint;
+  nsIntPoint    mLastPoint;
   HWND          mWnd;
   HDC           mPaintDC; // only set during painting
 #if 0
   HPALETTE      mPalette;
 #endif
   WNDPROC       mPrevWndProc;
   HBRUSH        mBrush;
 
--- a/widget/src/xpwidgets/nsBaseDragService.cpp
+++ b/widget/src/xpwidgets/nsBaseDragService.cpp
@@ -396,17 +396,17 @@ GetPresShellForContent(nsIDOMNode* aDOMN
 
   return nsnull;
 }
 
 nsresult
 nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode,
                             nsIScriptableRegion* aRegion,
                             PRInt32 aScreenX, PRInt32 aScreenY,
-                            nsRect* aScreenDragRect,
+                            nsIntRect* aScreenDragRect,
                             gfxASurface** aSurface,
                             nsPresContext** aPresContext)
 {
   *aSurface = nsnull;
   *aPresContext = nsnull;
 
   // use a default size, in case of an error.
   aScreenDragRect->x = aScreenX - mImageX;
@@ -436,20 +436,21 @@ nsBaseDragService::DrawDrag(nsIDOMNode* 
   // didn't want an image, so just set the screen rectangle to the frame size
   if (!enableDragImages || !mHasImage) {
     // 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) {
-        nsRect dragRect;
+        nsIntRect dragRect;
         aRegion->GetBoundingBox(&dragRect.x, &dragRect.y, &dragRect.width, &dragRect.height);
-        dragRect.ScaleRoundOut(nsPresContext::AppUnitsPerCSSPixel());
-        dragRect.ScaleRoundOut(1.0 / (*aPresContext)->AppUnitsPerDevPixel());
+        dragRect = nsRect::ToOutsidePixels(nsIntRect::ToAppUnits(dragRect,
+                                                                 nsPresContext::AppUnitsPerCSSPixel()),
+                                           (*aPresContext)->AppUnitsPerDevPixel());
 
         nsIntRect screenRect = rootFrame->GetScreenRectExternal();
         aScreenDragRect->SetRect(screenRect.x + dragRect.x, screenRect.y + dragRect.y,
                                  dragRect.width, dragRect.height);
       }
     }
     else {
       // otherwise, there was no region so just set the rectangle to
@@ -463,17 +464,17 @@ nsBaseDragService::DrawDrag(nsIDOMNode* 
       }
     }
 
     return NS_OK;
   }
 
   // draw the image for selections
   if (mSelection) {
-    nsPoint pnt(aScreenDragRect->x, aScreenDragRect->y);
+    nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y);
     nsRefPtr<gfxASurface> surface = presShell->RenderSelection(mSelection, pnt, aScreenDragRect);
     *aSurface = surface;
     NS_IF_ADDREF(*aSurface);
     return NS_OK;
   }
 
   // if an custom image was specified, check if it is an image node and draw
   // using the source rather than the displayed image. But if mImage isn't
@@ -493,17 +494,17 @@ nsBaseDragService::DrawDrag(nsIDOMNode* 
     }
   }
 
   // otherwise, just draw the node
   nsCOMPtr<nsIRegion> clipRegion;
   if (aRegion)
     aRegion->GetRegion(getter_AddRefs(clipRegion));
 
-  nsPoint pnt(aScreenDragRect->x, aScreenDragRect->y);
+  nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y);
   nsRefPtr<gfxASurface> surface = presShell->RenderNode(dragNode, clipRegion,
                                                         pnt, aScreenDragRect);
 
   // if an image was specified, reposition the drag rectangle to
   // the supplied offset in mImageX and mImageY.
   if (mImage) {
     aScreenDragRect->x = aScreenX - mImageX;
     aScreenDragRect->y = aScreenY - mImageY;
@@ -515,17 +516,17 @@ nsBaseDragService::DrawDrag(nsIDOMNode* 
   return NS_OK;
 }
 
 nsresult
 nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext,
                                     nsIImageLoadingContent* aImageLoader,
                                     nsICanvasElement* aCanvas,
                                     PRInt32 aScreenX, PRInt32 aScreenY,
-                                    nsRect* aScreenDragRect,
+                                    nsIntRect* aScreenDragRect,
                                     gfxASurface** aSurface)
 {
   nsCOMPtr<nsIImage> img;
   if (aImageLoader) {
     nsCOMPtr<imgIRequest> imgRequest;
     nsresult rv = aImageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
                                           getter_AddRefs(imgRequest));
     NS_ENSURE_SUCCESS(rv, rv);
@@ -554,19 +555,19 @@ nsBaseDragService::DrawDragForImage(nsPr
   else {
     NS_ASSERTION(aCanvas, "both image and canvas are null");
     PRUint32 width, height;
     aCanvas->GetSize(&width, &height);
     aScreenDragRect->width = width;
     aScreenDragRect->height = height;
   }
 
-  nsRect srcRect = *aScreenDragRect;
+  nsIntRect srcRect = *aScreenDragRect;
   srcRect.MoveTo(0, 0);
-  nsRect destRect = srcRect;
+  nsIntRect destRect = srcRect;
 
   if (destRect.width == 0 || destRect.height == 0)
     return NS_ERROR_FAILURE;
 
   // if the image is larger than half the screen size, scale it down. This
   // scaling algorithm is the same as is used in nsPresShell::PaintRangePaintInfo
   nsIDeviceContext* deviceContext = aPresContext->DeviceContext();
   nsRect maxSize;
--- a/widget/src/xpwidgets/nsBaseDragService.h
+++ b/widget/src/xpwidgets/nsBaseDragService.h
@@ -98,29 +98,29 @@ protected:
    * aScreenDragRect will still be set to the drag area.
    *
    * aPresContext will be set to the nsPresContext used determined from
    * whichever of mImage or aDOMNode is used.
    */
   nsresult DrawDrag(nsIDOMNode* aDOMNode,
                     nsIScriptableRegion* aRegion,
                     PRInt32 aScreenX, PRInt32 aScreenY,
-                    nsRect* aScreenDragRect,
+                    nsIntRect* aScreenDragRect,
                     gfxASurface** aSurface,
                     nsPresContext **aPresContext);
 
   /**
    * Draw a drag image for an image node specified by aImageLoader or aCanvas.
    * This is called by DrawDrag.
    */
   nsresult DrawDragForImage(nsPresContext* aPresContext,
                             nsIImageLoadingContent* aImageLoader,
                             nsICanvasElement* aCanvas,
                             PRInt32 aScreenX, PRInt32 aScreenY,
-                            nsRect* aScreenDragRect,
+                            nsIntRect* aScreenDragRect,
                             gfxASurface** aSurface);
 
   /**
    * Convert aScreenX and aScreenY from CSS pixels into unscaled device pixels.
    */
   void
   ConvertToUnscaledDevPixels(nsPresContext* aPresContext,
                              PRInt32* aScreenX, PRInt32* aScreenY);
--- a/widget/src/xpwidgets/nsBaseWidget.cpp
+++ b/widget/src/xpwidgets/nsBaseWidget.cpp
@@ -140,17 +140,17 @@ nsBaseWidget::~nsBaseWidget()
 
 
 //-------------------------------------------------------------------------
 //
 // Basic create.
 //
 //-------------------------------------------------------------------------
 void nsBaseWidget::BaseCreate(nsIWidget *aParent,
-                              const nsRect &aRect,
+                              const nsIntRect &aRect,
                               EVENT_CALLBACK aHandleEventFunction,
                               nsIDeviceContext *aContext,
                               nsIAppShell *aAppShell,
                               nsIToolkit *aToolkit,
                               nsWidgetInitData *aInitData)
 {
   if (nsnull == mToolkit) {
     if (nsnull != aToolkit) {
@@ -586,17 +586,17 @@ NS_IMETHODIMP nsBaseWidget::HideWindowCh
 NS_IMETHODIMP nsBaseWidget::MakeFullScreen(PRBool aFullScreen)
 {
   HideWindowChrome(aFullScreen);
 
   nsCOMPtr<nsIFullScreen> fullScreen = do_GetService("@mozilla.org/browser/fullscreen;1");
 
   if (aFullScreen) {
     if (!mOriginalBounds)
-      mOriginalBounds = new nsRect();
+      mOriginalBounds = new nsIntRect();
     GetScreenBounds(*mOriginalBounds);
 
     // Move to top-left corner of screen and size to the screen dimensions
     nsCOMPtr<nsIScreenManager> screenManager;
     screenManager = do_GetService("@mozilla.org/gfx/screenmanager;1"); 
     NS_ASSERTION(screenManager, "Unable to grab screenManager.");
     if (screenManager) {
       nsCOMPtr<nsIScreen> screen;
@@ -734,77 +734,77 @@ NS_METHOD nsBaseWidget::AddEventListener
   mEventListener = aListener;
   return NS_OK;
 }
 
 /**
 * If the implementation of nsWindow supports borders this method MUST be overridden
 *
 **/
-NS_METHOD nsBaseWidget::GetClientBounds(nsRect &aRect)
+NS_METHOD nsBaseWidget::GetClientBounds(nsIntRect &aRect)
 {
   return GetBounds(aRect);
 }
 
 /**
 * If the implementation of nsWindow supports borders this method MUST be overridden
 *
 **/
-NS_METHOD nsBaseWidget::GetBounds(nsRect &aRect)
+NS_METHOD nsBaseWidget::GetBounds(nsIntRect &aRect)
 {
   aRect = mBounds;
   return NS_OK;
 }
 
 /**
 * If the implementation of nsWindow uses a local coordinate system within the window,
 * this method must be overridden
 *
 **/
-NS_METHOD nsBaseWidget::GetScreenBounds(nsRect &aRect)
+NS_METHOD nsBaseWidget::GetScreenBounds(nsIntRect &aRect)
 {
   return GetBounds(aRect);
 }
 
 /**
 * 
 *
 **/
-NS_METHOD nsBaseWidget::SetBounds(const nsRect &aRect)
+NS_METHOD nsBaseWidget::SetBounds(const nsIntRect &aRect)
 {
   mBounds = aRect;
 
   return NS_OK;
 }
  
 
 
 /**
 * Calculates the border width and height  
 *
 **/
 NS_METHOD nsBaseWidget::GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight)
 {
-  nsRect rectWin;
-  nsRect rect;
+  nsIntRect rectWin;
+  nsIntRect rect;
   GetBounds(rectWin);
   GetClientBounds(rect);
 
   aWidth  = (rectWin.width - rect.width) / 2;
   aHeight = (rectWin.height - rect.height) / 2;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsBaseWidget::ScrollWidgets(PRInt32 aDx, PRInt32 aDy)
 {
   return NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP nsBaseWidget::ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy)
+NS_IMETHODIMP nsBaseWidget::ScrollRect(nsIntRect &aRect, PRInt32 aDx, PRInt32 aDy)
 {
   return NS_ERROR_FAILURE;
 }
 
 NS_METHOD nsBaseWidget::EnableDragDrop(PRBool aEnable)
 {
   return NS_OK;
 }
@@ -1245,17 +1245,17 @@ nsBaseWidget::debug_DumpPaintEvent(FILE 
   }
   
   fprintf(aFileOut,"\n");
 }
 //////////////////////////////////////////////////////////////
 /* static */ void
 nsBaseWidget::debug_DumpInvalidate(FILE *                aFileOut,
                                    nsIWidget *           aWidget,
-                                   const nsRect *        aRect,
+                                   const nsIntRect *     aRect,
                                    PRBool                aIsSynchronous,
                                    const nsCAutoString & aWidgetName,
                                    PRInt32               aWindowID)
 {
   if (!debug_GetCachedBoolPref("nglayout.debug.invalidate_dumping"))
     return;
 
   NS_ASSERTION(nsnull != aFileOut,"cmon, null output FILE");
--- a/widget/src/xpwidgets/nsBaseWidget.h
+++ b/widget/src/xpwidgets/nsBaseWidget.h
@@ -113,22 +113,22 @@ public:
   virtual nsIToolkit*     GetToolkit();  
   virtual gfxASurface*    GetThebesSurface();
   NS_IMETHOD              SetModal(PRBool aModal); 
   NS_IMETHOD              ModalEventFilter(PRBool aRealEvent, void *aEvent,
                             PRBool *aForWindow);
   NS_IMETHOD              SetWindowClass(const nsAString& xulWinType);
   NS_IMETHOD              SetBorderStyle(nsBorderStyle aBorderStyle); 
   NS_IMETHOD              AddEventListener(nsIEventListener * aListener);
-  NS_IMETHOD              SetBounds(const nsRect &aRect);
-  NS_IMETHOD              GetBounds(nsRect &aRect);
-  NS_IMETHOD              GetClientBounds(nsRect &aRect);
-  NS_IMETHOD              GetScreenBounds(nsRect &aRect);
+  NS_IMETHOD              SetBounds(const nsIntRect &aRect);
+  NS_IMETHOD              GetBounds(nsIntRect &aRect);
+  NS_IMETHOD              GetClientBounds(nsIntRect &aRect);
+  NS_IMETHOD              GetScreenBounds(nsIntRect &aRect);
   NS_IMETHOD              GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight);
-  NS_IMETHOD              ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy);
+  NS_IMETHOD              ScrollRect(nsIntRect &aRect, PRInt32 aDx, PRInt32 aDy);
   NS_IMETHOD              ScrollWidgets(PRInt32 aDx, PRInt32 aDy);
   NS_IMETHOD              EnableDragDrop(PRBool aEnable);
   NS_IMETHOD              GetAttention(PRInt32 aCycleCount);
   NS_IMETHOD              GetLastInputEventTime(PRUint32& aTime);
   NS_IMETHOD              SetIcon(const nsAString &anIconSpec);
   NS_IMETHOD              BeginSecureKeyboardInput();
   NS_IMETHOD              EndSecureKeyboardInput();
   NS_IMETHOD              SetWindowTitlebarColor(nscolor aColor, PRBool aActive);
@@ -148,17 +148,17 @@ public:
 
 protected:
 
   virtual void            ResolveIconName(const nsAString &aIconName,
                                           const nsAString &aIconSuffix,
                                           nsILocalFile **aResult);
   virtual void            OnDestroy();
   virtual void            BaseCreate(nsIWidget *aParent,
-                                     const nsRect &aRect,
+                                     const nsIntRect &aRect,
                                      EVENT_CALLBACK aHandleEventFunction,
                                      nsIDeviceContext *aContext,
                                      nsIAppShell *aAppShell,
                                      nsIToolkit *aToolkit,
                                      nsWidgetInitData *aInitData);
 
   virtual nsIContent* GetLastRollup()
   {
@@ -183,18 +183,18 @@ protected:
   nsCursor          mCursor;
   nsWindowType      mWindowType;
   nsBorderStyle     mBorderStyle;
   PRPackedBool      mIsShiftDown;
   PRPackedBool      mIsControlDown;
   PRPackedBool      mIsAltDown;
   PRPackedBool      mIsDestroying;
   PRPackedBool      mOnDestroyCalled;
-  nsRect            mBounds;
-  nsRect*           mOriginalBounds;
+  nsIntRect         mBounds;
+  nsIntRect*        mOriginalBounds;
   PRInt32           mZIndex;
   nsSizeMode        mSizeMode;
 
   // the last rolled up popup. Only set this when an nsAutoRollup is in scope,
   // so it can be cleared automatically.
   static nsIContent* mLastRollup;
     
     // Enumeration of the methods which are accessible on the "main GUI thread"
@@ -211,17 +211,17 @@ protected:
 
 #ifdef DEBUG
 protected:
   static nsAutoString debug_GuiEventToString(nsGUIEvent * aGuiEvent);
   static PRBool debug_WantPaintFlashing();
 
   static void debug_DumpInvalidate(FILE *                aFileOut,
                                    nsIWidget *           aWidget,
-                                   const nsRect *        aRect,
+                                   const nsIntRect *     aRect,
                                    PRBool                aIsSynchronous,
                                    const nsCAutoString & aWidgetName,
                                    PRInt32               aWindowID);
 
   static void debug_DumpEvent(FILE *                aFileOut,
                               nsIWidget *           aWidget,
                               nsGUIEvent *          aGuiEvent,
                               const nsCAutoString & aWidgetName,
--- a/widget/src/xpwidgets/nsPrintOptionsImpl.cpp
+++ b/widget/src/xpwidgets/nsPrintOptionsImpl.cpp
@@ -33,17 +33,16 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsPrintOptionsImpl.h"
-#include "nsCoord.h"
 #include "nsReadableUtils.h"
 #include "nsPrintSettingsImpl.h"
 
 #include "nsIDOMWindow.h"
 #include "nsIServiceManager.h"
 #include "nsIDialogParamBlock.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
@@ -247,55 +246,52 @@ GetPrefName((_a2), aPrefName), (_a3));
 nsresult 
 nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
                           PRUint32 aFlags)
 {
   NS_ENSURE_STATE(mPrefBranch);
   NS_ENSURE_ARG_POINTER(aPS);
 
   if (aFlags & nsIPrintSettings::kInitSaveMargins) {
-    nscoord halfInch = NS_INCHES_TO_TWIPS(0.5);
-    nsMargin margin;
-    margin.SizeTo(halfInch, halfInch, halfInch, halfInch);
+    PRInt32 halfInch = NS_INCHES_TO_TWIPS(0.5);
+    nsIntMargin margin(halfInch, halfInch, halfInch, halfInch);
     ReadInchesToTwipsPref(GetPrefName(kMarginTop, aPrinterName), margin.top,
                           kMarginTop);
     DUMP_INT(kReadStr, kMarginTop, margin.top);
     ReadInchesToTwipsPref(GetPrefName(kMarginLeft, aPrinterName), margin.left,
                           kMarginLeft);
     DUMP_INT(kReadStr, kMarginLeft, margin.left);
     ReadInchesToTwipsPref(GetPrefName(kMarginBottom, aPrinterName),
                           margin.bottom, kMarginBottom);
     DUMP_INT(kReadStr, kMarginBottom, margin.bottom);
     ReadInchesToTwipsPref(GetPrefName(kMarginRight, aPrinterName), margin.right,
                           kMarginRight);
     DUMP_INT(kReadStr, kMarginRight, margin.right);
     aPS->SetMarginInTwips(margin);
   }
 
   if (aFlags & nsIPrintSettings::kInitSaveEdges) {
-    nsMargin margin;
-    margin.SizeTo(0,0,0,0);
+    nsIntMargin margin(0,0,0,0);
     ReadInchesIntToTwipsPref(GetPrefName(kEdgeTop, aPrinterName), margin.top,
                              kEdgeTop);
     DUMP_INT(kReadStr, kEdgeTop, margin.top);
     ReadInchesIntToTwipsPref(GetPrefName(kEdgeLeft, aPrinterName), margin.left,
                              kEdgeLeft);
     DUMP_INT(kReadStr, kEdgeLeft, margin.left);
     ReadInchesIntToTwipsPref(GetPrefName(kEdgeBottom, aPrinterName),
                              margin.bottom, kEdgeBottom);
     DUMP_INT(kReadStr, kEdgeBottom, margin.bottom);
     ReadInchesIntToTwipsPref(GetPrefName(kEdgeRight, aPrinterName), margin.right,
                              kEdgeRight);
     DUMP_INT(kReadStr, kEdgeRight, margin.right);
     aPS->SetEdgeInTwips(margin);
   }
 
   if (aFlags & nsIPrintSettings::kInitSaveUnwriteableMargins) {
-    nsMargin margin;
-    margin.SizeTo(0,0,0,0);
+    nsIntMargin margin;
     ReadInchesIntToTwipsPref(GetPrefName(kUnwriteableMarginTop, aPrinterName), margin.top,
                              kUnwriteableMarginTop);
     DUMP_INT(kReadStr, kUnwriteableMarginTop, margin.top);
     ReadInchesIntToTwipsPref(GetPrefName(kUnwriteableMarginLeft, aPrinterName), margin.left,
                              kUnwriteableMarginLeft);
     DUMP_INT(kReadStr, kUnwriteableMarginLeft, margin.left);
     ReadInchesIntToTwipsPref(GetPrefName(kUnwriteableMarginBottom, aPrinterName),
                              margin.bottom, kUnwriteableMarginBottom);
@@ -553,17 +549,17 @@ nsPrintOptions::ReadPrefs(nsIPrintSettin
  */
 nsresult 
 nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName,
                            PRUint32 aFlags)
 {
   NS_ENSURE_ARG_POINTER(aPS);
   NS_ENSURE_STATE(mPrefBranch);
 
-  nsMargin margin;
+  nsIntMargin margin;
   if (aFlags & nsIPrintSettings::kInitSaveMargins) {
     if (NS_SUCCEEDED(aPS->GetMarginInTwips(margin))) {
       WriteInchesFromTwipsPref(GetPrefName(kMarginTop, aPrinterName),
                                margin.top);
       DUMP_INT(kWriteStr, kMarginTop, margin.top);
       WriteInchesFromTwipsPref(GetPrefName(kMarginLeft, aPrinterName),
                                margin.left);
       DUMP_INT(kWriteStr, kMarginLeft, margin.top);
@@ -571,17 +567,17 @@ nsPrintOptions::WritePrefs(nsIPrintSetti
                                margin.bottom);
       DUMP_INT(kWriteStr, kMarginBottom, margin.top);
       WriteInchesFromTwipsPref(GetPrefName(kMarginRight, aPrinterName),
                                margin.right);
       DUMP_INT(kWriteStr, kMarginRight, margin.top);
     }
   }
 
-  nsMargin edge;
+  nsIntMargin edge;
   if (aFlags & nsIPrintSettings::kInitSaveEdges) {
     if (NS_SUCCEEDED(aPS->GetEdgeInTwips(edge))) {
       WriteInchesIntFromTwipsPref(GetPrefName(kEdgeTop, aPrinterName),
                                   edge.top);
       DUMP_INT(kWriteStr, kEdgeTop, edge.top);
       WriteInchesIntFromTwipsPref(GetPrefName(kEdgeLeft, aPrinterName),
                                   edge.left);
       DUMP_INT(kWriteStr, kEdgeLeft, edge.top);
@@ -589,17 +585,17 @@ nsPrintOptions::WritePrefs(nsIPrintSetti
                                   edge.bottom);
       DUMP_INT(kWriteStr, kEdgeBottom, edge.top);
       WriteInchesIntFromTwipsPref(GetPrefName(kEdgeRight, aPrinterName),
                                   edge.right);
       DUMP_INT(kWriteStr, kEdgeRight, edge.top);
     }
   }
 
-  nsMargin unwriteableMargin;
+  nsIntMargin unwriteableMargin;
   if (aFlags & nsIPrintSettings::kInitSaveUnwriteableMargins) {
     if (NS_SUCCEEDED(aPS->GetUnwriteableMarginInTwips(unwriteableMargin))) {
       WriteInchesIntFromTwipsPref(GetPrefName(kUnwriteableMarginTop, aPrinterName),
                                   unwriteableMargin.top);
       DUMP_INT(kWriteStr, kUnwriteableMarginTop, unwriteableMargin.top);
       WriteInchesIntFromTwipsPref(GetPrefName(kUnwriteableMarginLeft, aPrinterName),
                                   unwriteableMargin.left);
       DUMP_INT(kWriteStr, kUnwriteableMarginLeft, unwriteableMargin.top);
@@ -1165,17 +1161,17 @@ nsPrintOptions::WritePrefDouble(const ch
   char str[16]; // max 9 chars in below snprintf(), 16 will do nicely
   int ret = PR_snprintf(str, sizeof(str), "%6.2f", aVal);
   NS_ENSURE_TRUE(ret >= 0, NS_ERROR_FAILURE);
 
   return mPrefBranch->SetCharPref(aPrefId, str);
 }
 
 void
-nsPrintOptions::ReadInchesToTwipsPref(const char * aPrefId, nscoord& aTwips,
+nsPrintOptions::ReadInchesToTwipsPref(const char * aPrefId, PRInt32& aTwips,
                                       const char * aMarginPref)
 {
   if (!mPrefBranch) {
     return;
   }
 
   char * str = nsnull;
   nsresult rv = mPrefBranch->GetCharPref(aPrefId, &str);
@@ -1191,31 +1187,31 @@ nsPrintOptions::ReadInchesToTwipsPref(co
     } else {
       aTwips = 0;
     }
     nsMemory::Free(str);
   }
 }
 
 void
-nsPrintOptions::WriteInchesFromTwipsPref(const char * aPrefId, nscoord aTwips)
+nsPrintOptions::WriteInchesFromTwipsPref(const char * aPrefId, PRInt32 aTwips)
 {
   if (!mPrefBranch) {
     return;
   }
 
   double inches = NS_TWIPS_TO_INCHES(aTwips);
   nsCAutoString inchesStr;
   inchesStr.AppendFloat(inches);
 
   mPrefBranch->SetCharPref(aPrefId, inchesStr.get());
 }
 
 void
-nsPrintOptions::ReadInchesIntToTwipsPref(const char * aPrefId, nscoord& aTwips,
+nsPrintOptions::ReadInchesIntToTwipsPref(const char * aPrefId, PRInt32& aTwips,
                                          const char * aMarginPref)
 {
   if (!mPrefBranch) {
     return;
   }
 
   PRInt32 value;
   nsresult rv = mPrefBranch->GetIntPref(aPrefId, &value);
@@ -1225,17 +1221,17 @@ nsPrintOptions::ReadInchesIntToTwipsPref
   if (NS_SUCCEEDED(rv)) {
     aTwips = NS_INCHES_TO_TWIPS(float(value)/100.0f);
   } else {
     aTwips = 0;
   }
 }
 
 void
-nsPrintOptions::WriteInchesIntFromTwipsPref(const char * aPrefId, nscoord aTwips)
+nsPrintOptions::WriteInchesIntFromTwipsPref(const char * aPrefId, PRInt32 aTwips)
 {
   if (!mPrefBranch) {
     return;
   }
 
   mPrefBranch->SetIntPref(aPrefId, PRInt32(NS_TWIPS_TO_INCHES(aTwips)*100.0f + 0.5f));
 }
 
--- a/widget/src/xpwidgets/nsPrintOptionsImpl.h
+++ b/widget/src/xpwidgets/nsPrintOptionsImpl.h
@@ -71,22 +71,22 @@ public:
   virtual ~nsPrintOptions();
 
 protected:
   void ReadBitFieldPref(const char * aPrefId, PRInt32 anOption);
   void WriteBitFieldPref(const char * aPrefId, PRInt32 anOption);
   void ReadJustification(const char * aPrefId, PRInt16& aJust,
                          PRInt16 aInitValue);
   void WriteJustification(const char * aPrefId, PRInt16 aJust);
-  void ReadInchesToTwipsPref(const char * aPrefId, nscoord&  aTwips,
+  void ReadInchesToTwipsPref(const char * aPrefId, PRInt32&  aTwips,
                              const char * aMarginPref);
-  void WriteInchesFromTwipsPref(const char * aPrefId, nscoord aTwips);
-  void ReadInchesIntToTwipsPref(const char * aPrefId, nscoord&  aTwips,
+  void WriteInchesFromTwipsPref(const char * aPrefId, PRInt32 aTwips);
+  void ReadInchesIntToTwipsPref(const char * aPrefId, PRInt32&  aTwips,
                                 const char * aMarginPref);
-  void WriteInchesIntFromTwipsPref(const char * aPrefId, nscoord aTwips);
+  void WriteInchesIntFromTwipsPref(const char * aPrefId, PRInt32 aTwips);
 
   nsresult ReadPrefString(const char * aPrefId, nsAString& aString);
   /**
    * method WritePrefString
    *   Writes PRUnichar* to Prefs and deletes the contents of aString
    */
   nsresult WritePrefString(const char * aPrefId, const nsAString& aString);
   nsresult WritePrefString(PRUnichar*& aStr, const char* aPrefId);
--- a/widget/src/xpwidgets/nsPrintSettingsImpl.cpp
+++ b/widget/src/xpwidgets/nsPrintSettingsImpl.cpp
@@ -31,17 +31,16 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsPrintSettingsImpl.h"
-#include "nsCoord.h"
 #include "nsReadableUtils.h"
 #include "nsIPrintSession.h"
 
 #define DEFAULT_MARGIN_WIDTH 0.5
 
 NS_IMPL_ISUPPORTS1(nsPrintSettings, nsIPrintSettings)
 
 /** ---------------------------------------------------
@@ -77,17 +76,17 @@ nsPrintSettings::nsPrintSettings() :
   mNumCopies(1),
   mPrintToFile(PR_FALSE),
   mOutputFormat(kOutputFormatNative),
   mIsInitedFromPrinter(PR_FALSE),
   mIsInitedFromPrefs(PR_FALSE)
 {
 
   /* member initializers and constructor code */
-  nscoord marginWidth = NS_INCHES_TO_TWIPS(DEFAULT_MARGIN_WIDTH);
+  PRInt32 marginWidth = NS_INCHES_TO_TWIPS(DEFAULT_MARGIN_WIDTH);
   mMargin.SizeTo(marginWidth, marginWidth, marginWidth, marginWidth);
   mEdge.SizeTo(0, 0, 0, 0);
   mUnwriteableMargin.SizeTo(0,0,0,0);
 
   mPrintOptions = kPrintOddPages | kPrintEvenPages;
 
   mHeaderStrs[0].AssignLiteral("&T");
   mHeaderStrs[2].AssignLiteral("&U");
@@ -999,34 +998,34 @@ NS_IMETHODIMP nsPrintSettings::SetPaperD
 }
 
 /** ---------------------------------------------------
  *  See documentation in nsPrintOptionsImpl.h
  *	@update 6/21/00 dwc
  *	@update 1/12/01 rods
  */
 NS_IMETHODIMP 
-nsPrintSettings::SetMarginInTwips(nsMargin& aMargin)
+nsPrintSettings::SetMarginInTwips(nsIntMargin& aMargin)
 {
   mMargin = aMargin;
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsPrintSettings::SetEdgeInTwips(nsMargin& aEdge)
+nsPrintSettings::SetEdgeInTwips(nsIntMargin& aEdge)
 {
   mEdge = aEdge;
   return NS_OK;
 }
 
 // NOTE: Any subclass implementation of this function should make sure
 // to check for negative margin values in aUnwriteableMargin (which 
 // would indicate that we should use the system default unwriteable margin.)
 NS_IMETHODIMP 
-nsPrintSettings::SetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin)
+nsPrintSettings::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin)
 {
   if (aUnwriteableMargin.top >= 0) {
     mUnwriteableMargin.top = aUnwriteableMargin.top;
   }
   if (aUnwriteableMargin.left >= 0) {
     mUnwriteableMargin.left = aUnwriteableMargin.left;
   }
   if (aUnwriteableMargin.bottom >= 0) {
@@ -1038,31 +1037,31 @@ nsPrintSettings::SetUnwriteableMarginInT
   return NS_OK;
 }
 
 /** ---------------------------------------------------
  *  See documentation in nsPrintOptionsImpl.h
  *	@update 6/21/00 dwc
  */
 NS_IMETHODIMP 
-nsPrintSettings::GetMarginInTwips(nsMargin& aMargin)
+nsPrintSettings::GetMarginInTwips(nsIntMargin& aMargin)
 {
   aMargin = mMargin;
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsPrintSettings::GetEdgeInTwips(nsMargin& aEdge)
+nsPrintSettings::GetEdgeInTwips(nsIntMargin& aEdge)
 {
   aEdge = mEdge;
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsPrintSettings::GetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin)
+nsPrintSettings::GetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin)
 {
   aUnwriteableMargin = mUnwriteableMargin;
   return NS_OK;
 }
 
 /** ---------------------------------------------------
  * Stub - platform-specific implementations can use this function.
  */
--- a/widget/src/xpwidgets/nsPrintSettingsImpl.h
+++ b/widget/src/xpwidgets/nsPrintSettingsImpl.h
@@ -77,19 +77,19 @@ protected:
 
   nsresult GetMarginStrs(PRUnichar * *aTitle, nsHeaderFooterEnum aType, PRInt16 aJust);
   nsresult SetMarginStrs(const PRUnichar * aTitle, nsHeaderFooterEnum aType, PRInt16 aJust);
 
   // Members
   nsWeakPtr     mSession; // Should never be touched by Clone or Assign
  
   // mMargin, mEdge, and mUnwriteableMargin are stored in twips
-  nsMargin      mMargin;
-  nsMargin      mEdge;
-  nsMargin      mUnwriteableMargin;
+  nsIntMargin   mMargin;
+  nsIntMargin   mEdge;
+  nsIntMargin   mUnwriteableMargin;
 
   PRInt32       mPrintOptions;
 
   // scriptable data members
   PRInt16       mPrintRange;
   PRInt32       mStartPageNum; // only used for ePrintRange_SpecifiedRange
   PRInt32       mEndPageNum;
   double        mScaling;
--- a/xpfe/appshell/src/nsWebShellWindow.cpp
+++ b/xpfe/appshell/src/nsWebShellWindow.cpp
@@ -177,17 +177,17 @@ nsresult nsWebShellWindow::Initialize(ns
 {
   nsresult rv;
   nsCOMPtr<nsIWidget> parentWidget;
 
   mIsHiddenWindow = aIsHiddenWindow;
   
   // XXX: need to get the default window size from prefs...
   // Doesn't come from prefs... will come from CSS/XUL/RDF
-  nsRect r(0, 0, aInitialWidth, aInitialHeight);
+  nsIntRect r(0, 0, aInitialWidth, aInitialHeight);
   
   // Create top level window
   mWindow = do_CreateInstance(kWindowCID, &rv);
   if (NS_OK != rv) {
     return rv;
   }
 
   /* This next bit is troublesome. We carry two different versions of a pointer
--- a/xpfe/appshell/src/nsXULWindow.cpp
+++ b/xpfe/appshell/src/nsXULWindow.cpp
@@ -611,17 +611,17 @@ NS_IMETHODIMP nsXULWindow::SetPositionAn
   PersistentAttributesDirty(PAD_POSITION | PAD_SIZE);
   SavePersistentAttributes();
   return NS_OK;
 }
 
 NS_IMETHODIMP nsXULWindow::GetPositionAndSize(PRInt32* x, PRInt32* y, PRInt32* cx,
    PRInt32* cy)
 {
-  nsRect rect;
+  nsIntRect rect;
 
   if (!mWindow)
     return NS_ERROR_FAILURE;
 
   mWindow->GetScreenBounds(rect);
 
   if(x)
     *x = rect.x;