Bug 489485. nsRect::ToNearest/Inner/OuterPixels should be nonstatic. r+sr=roc
authorRyo Onodera <ryoqun@gmail.com>
Fri, 08 May 2009 14:31:04 +1200
changeset 28113 665b73eb15c804b90b4978b7820e41067a955d59
parent 28112 4aa17bf8dcdae7a64ae4256cffdf9e87558a8cc6
child 28114 c9db288cd5cca9ff3b7a58e57c763b95909be2ba
push idunknown
push userunknown
push dateunknown
bugs489485
milestone1.9.2a1pre
Bug 489485. nsRect::ToNearest/Inner/OuterPixels should be nonstatic. r+sr=roc
accessible/src/base/nsCaretAccessible.cpp
content/events/src/nsContentEventHandler.cpp
editor/libeditor/base/nsEditor.cpp
editor/libeditor/text/nsPlaintextEditor.cpp
gfx/public/nsRect.h
layout/base/nsImageLoader.cpp
layout/base/nsPresShell.cpp
layout/generic/nsFrame.cpp
layout/generic/nsObjectFrame.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/src/nsMenuPopupFrame.cpp
layout/xul/base/src/nsScrollBoxObject.cpp
layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
view/src/nsScrollPortView.cpp
view/src/nsView.cpp
view/src/nsViewManager.cpp
widget/src/xpwidgets/nsBaseDragService.cpp
--- a/accessible/src/base/nsCaretAccessible.cpp
+++ b/accessible/src/base/nsCaretAccessible.cpp
@@ -338,17 +338,17 @@ nsCaretAccessible::GetCaretRect(nsIWidge
   nsPoint offsetFromWidget;
   *aOutWidget = view->GetNearestWidget(&offsetFromWidget);
   NS_ENSURE_TRUE(*aOutWidget, nsIntRect());
 
   nsPresContext *presContext = presShell->GetPresContext();
   NS_ENSURE_TRUE(presContext, nsIntRect());
 
   rect += offsetFromWidget;
-  caretRect = nsRect::ToOutsidePixels(rect, presContext->AppUnitsPerDevPixel());
+  caretRect = rect.ToOutsidePixels(presContext->AppUnitsPerDevPixel());
 
   caretRect.MoveBy((*aOutWidget)->WidgetToScreenOffset());
 
   // 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/content/events/src/nsContentEventHandler.cpp
+++ b/content/events/src/nsContentEventHandler.cpp
@@ -590,17 +590,17 @@ nsContentEventHandler::OnQueryTextRect(n
   frameRect.width -= lastFrame->GetRect().width - ptOffset.x - 1;
 
   if (firstFrame == lastFrame) {
     rect.IntersectRect(rect, frameRect);
   } else {
     rect.UnionRect(rect, frameRect);
   }
   aEvent->mReply.mRect =
-      nsRect::ToOutsidePixels(rect, mPresContext->AppUnitsPerDevPixel());
+      rect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel());
   aEvent->mSucceeded = PR_TRUE;
   return NS_OK;
 }
 
 nsresult
 nsContentEventHandler::OnQueryEditorRect(nsQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
@@ -619,17 +619,17 @@ nsContentEventHandler::OnQueryEditorRect
   while ((frame = frame->GetNextContinuation()) != nsnull) {
     nsRect frameRect(nsPoint(0, 0), frame->GetRect().Size());
     rv = ConvertToRootViewRelativeOffset(frame, frameRect);
     NS_ENSURE_SUCCESS(rv, rv);
     resultRect.UnionRect(resultRect, frameRect);
   }
 
   aEvent->mReply.mRect =
-      nsRect::ToOutsidePixels(resultRect, mPresContext->AppUnitsPerDevPixel());
+      resultRect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel());
   aEvent->mSucceeded = PR_TRUE;
   return NS_OK;
 }
 
 nsresult
 nsContentEventHandler::OnQueryCaretRect(nsQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
@@ -653,17 +653,17 @@ nsContentEventHandler::OnQueryCaretRect(
     NS_ENSURE_SUCCESS(rv, rv);
     if (offset == aEvent->mInput.mOffset) {
       PRBool isCollapsed;
       nsRect rect;
       rv = caret->GetCaretCoordinates(nsCaret::eTopLevelWindowCoordinates,
                                       mSelection, &rect,
                                       &isCollapsed, nsnull);
       aEvent->mReply.mRect =
-          nsRect::ToOutsidePixels(rect, mPresContext->AppUnitsPerDevPixel());
+          rect.ToOutsidePixels(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();
@@ -685,17 +685,17 @@ nsContentEventHandler::OnQueryCaretRect(
   rect.y = posInFrame.y;
   rect.width = caret->GetCaretRect().width;
   rect.height = frame->GetSize().height;
 
   rv = ConvertToRootViewRelativeOffset(frame, rect);
   NS_ENSURE_SUCCESS(rv, rv);
 
   aEvent->mReply.mRect =
-      nsRect::ToOutsidePixels(rect, mPresContext->AppUnitsPerDevPixel());
+      rect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel());
   aEvent->mSucceeded = PR_TRUE;
   return NS_OK;
 }
 
 nsresult
 nsContentEventHandler::OnQueryContentState(nsQueryContentEvent * aEvent)
 {
   nsresult rv = Init(aEvent);
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -1996,18 +1996,17 @@ nsEditor::QueryComposition(nsTextEventRe
       nsRect rect;
       result =
         caretP->GetCaretCoordinates(nsCaret::eRenderingViewCoordinates,
                                     selection,
                                     &rect,
                                     &(aReply->mCursorIsCollapsed),
                                     &view);
       aReply->mCursorPosition =
-        nsRect::ToOutsidePixels(rect,
-                                ps->GetPresContext()->AppUnitsPerDevPixel());
+        rect.ToOutsidePixels(ps->GetPresContext()->AppUnitsPerDevPixel());
       if (NS_SUCCEEDED(result) && view)
         aReply->mReferenceWidget = view->GetWidget();
     }
   }
   return result;
 }
 
 NS_IMETHODIMP
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -1730,18 +1730,17 @@ nsPlaintextEditor::SetCompositionString(
     nsIView *view = nsnull;
     nsRect rect;
     result = caretP->GetCaretCoordinates(nsCaret::eRenderingViewCoordinates,
                                          selection,
                                          &rect,
                                          &(aReply->mCursorIsCollapsed),
                                          &view);
     aReply->mCursorPosition =
-       nsRect::ToOutsidePixels(rect,
-                               ps->GetPresContext()->AppUnitsPerDevPixel());
+       rect.ToOutsidePixels(ps->GetPresContext()->AppUnitsPerDevPixel());
     NS_ASSERTION(NS_SUCCEEDED(result), "cannot get caret position");
     if (NS_SUCCEEDED(result) && view)
       aReply->mReferenceWidget = view->GetWidget();
   }
 
   return result;
 }
 
--- a/gfx/public/nsRect.h
+++ b/gfx/public/nsRect.h
@@ -181,19 +181,19 @@ struct NS_GFX nsRect {
   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;}
 
-  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);
+  inline nsIntRect ToNearestPixels(nscoord aAppUnitsPerPixel) const;
+  inline nsIntRect ToOutsidePixels(nscoord aAppUnitsPerPixel) const;
+  inline nsIntRect ToInsidePixels(nscoord aAppUnitsPerPixel) const;
 };
 
 struct NS_GFX nsIntRect {
   PRInt32 x, y;
   PRInt32 width, height;
 
   // Constructors
   nsIntRect() : x(0), y(0), width(0), height(0) {}
@@ -300,72 +300,72 @@ struct NS_GFX nsIntRect {
   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);
+  inline nsRect ToAppUnits(nscoord aAppUnitsPerPixel) const;
 };
 
 /*
  * App Unit/Pixel conversions
  */
 // scale the rect but round to preserve centers
 inline nsIntRect
-nsRect::ToNearestPixels(const nsRect &aRect, nscoord aAppUnitsPerPixel)
+nsRect::ToNearestPixels(nscoord aAppUnitsPerPixel) const
 {
   nsIntRect rect;
-  rect.x = NSToIntRound(NSAppUnitsToFloatPixels(aRect.x, float(aAppUnitsPerPixel)));
-  rect.y = NSToIntRound(NSAppUnitsToFloatPixels(aRect.y, float(aAppUnitsPerPixel)));
-  rect.width  = NSToIntRound(NSAppUnitsToFloatPixels(aRect.XMost(),
+  rect.x = NSToIntRound(NSAppUnitsToFloatPixels(x, float(aAppUnitsPerPixel)));
+  rect.y = NSToIntRound(NSAppUnitsToFloatPixels(y, float(aAppUnitsPerPixel)));
+  rect.width  = NSToIntRound(NSAppUnitsToFloatPixels(XMost(),
                              float(aAppUnitsPerPixel))) - rect.x;
-  rect.height = NSToIntRound(NSAppUnitsToFloatPixels(aRect.YMost(),
+  rect.height = NSToIntRound(NSAppUnitsToFloatPixels(YMost(),
                              float(aAppUnitsPerPixel))) - rect.y;
   return rect;
 }
 
 // scale the rect but round to smallest containing rect
 inline nsIntRect
-nsRect::ToOutsidePixels(const nsRect &aRect, nscoord aAppUnitsPerPixel)
+nsRect::ToOutsidePixels(nscoord aAppUnitsPerPixel) const
 {
   nsIntRect rect;
-  rect.x = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.x, float(aAppUnitsPerPixel)));
-  rect.y = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.y, float(aAppUnitsPerPixel)));
-  rect.width  = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.XMost(),
+  rect.x = NSToIntFloor(NSAppUnitsToFloatPixels(x, float(aAppUnitsPerPixel)));
+  rect.y = NSToIntFloor(NSAppUnitsToFloatPixels(y, float(aAppUnitsPerPixel)));
+  rect.width  = NSToIntCeil(NSAppUnitsToFloatPixels(XMost(),
                             float(aAppUnitsPerPixel))) - rect.x;
-  rect.height = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.YMost(),
+  rect.height = NSToIntCeil(NSAppUnitsToFloatPixels(YMost(),
                             float(aAppUnitsPerPixel))) - rect.y;
   return rect;
 }
 
 // scale the rect but round to largest contained rect
 inline nsIntRect
-nsRect::ToInsidePixels(const nsRect &aRect, nscoord aAppUnitsPerPixel)
+nsRect::ToInsidePixels(nscoord aAppUnitsPerPixel) const
 {
   nsIntRect rect;
-  rect.x = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.x, float(aAppUnitsPerPixel)));
-  rect.y = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.y, float(aAppUnitsPerPixel)));
-  rect.width  = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.XMost(),
+  rect.x = NSToIntCeil(NSAppUnitsToFloatPixels(x, float(aAppUnitsPerPixel)));
+  rect.y = NSToIntCeil(NSAppUnitsToFloatPixels(y, float(aAppUnitsPerPixel)));
+  rect.width  = NSToIntFloor(NSAppUnitsToFloatPixels(XMost(),
                              float(aAppUnitsPerPixel))) - rect.x;
-  rect.height = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.YMost(),
+  rect.height = NSToIntFloor(NSAppUnitsToFloatPixels(YMost(),
                              float(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)
+nsIntRect::ToAppUnits(nscoord aAppUnitsPerPixel) const
 {
-  return nsRect(NSIntPixelsToAppUnits(aRect.x, aAppUnitsPerPixel),
-                NSIntPixelsToAppUnits(aRect.y, aAppUnitsPerPixel),
-                NSIntPixelsToAppUnits(aRect.width, aAppUnitsPerPixel),
-                NSIntPixelsToAppUnits(aRect.height, aAppUnitsPerPixel));
+  return nsRect(NSIntPixelsToAppUnits(x, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(y, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(width, aAppUnitsPerPixel),
+                NSIntPixelsToAppUnits(height, aAppUnitsPerPixel));
 }
 
 #ifdef DEBUG
 // Diagnostics
 extern NS_GFX FILE* operator<<(FILE* out, const nsRect& rect);
 #endif // DEBUG
 
 #endif /* NSRECT_H */
--- a/layout/base/nsImageLoader.cpp
+++ b/layout/base/nsImageLoader.cpp
@@ -188,17 +188,17 @@ NS_IMETHODIMP nsImageLoader::FrameChange
   if (!mFrame)
     return NS_ERROR_FAILURE;
 
   if (!mRequest) {
     // We're in the middle of a paint anyway
     return NS_OK;
   }
   
-  nsRect r = nsIntRect::ToAppUnits(*dirtyRect, nsPresContext::AppUnitsPerCSSPixel());
+  nsRect r = dirtyRect->ToAppUnits(nsPresContext::AppUnitsPerCSSPixel());
 
   RedrawDirtyFrame(&r);
 
   return NS_OK;
 }
 
 
 void
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5402,17 +5402,17 @@ PresShell::PaintRangePaintInfo(nsTArray<
 {
   nsPresContext* pc = GetPresContext();
   if (!pc || aArea.width == 0 || aArea.height == 0)
     return nsnull;
 
   nsIDeviceContext* deviceContext = pc->DeviceContext();
 
   // use the rectangle to create the surface
-  nsIntRect pixelArea = nsRect::ToOutsidePixels(aArea, pc->AppUnitsPerDevPixel());
+  nsIntRect pixelArea = aArea.ToOutsidePixels(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;
@@ -5536,17 +5536,17 @@ PresShell::RenderNode(nsIDOMNode* aNode,
   }
 
   if (aRegion) {
     // combine the area with the supplied region
     nsIntRect rrectPixels;
     aRegion->GetBoundingBox(&rrectPixels.x, &rrectPixels.y,
                             &rrectPixels.width, &rrectPixels.height);
 
-    nsRect rrect = nsIntRect::ToAppUnits(rrectPixels, nsPresContext::AppUnitsPerCSSPixel());
+    nsRect rrect = rrectPixels.ToAppUnits(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)),
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -865,17 +865,17 @@ 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);
-  nsIntRect pxRect = nsRect::ToOutsidePixels(rect, mFrame->PresContext()->AppUnitsPerDevPixel());
+  nsIntRect pxRect = rect.ToOutsidePixels(mFrame->PresContext()->AppUnitsPerDevPixel());
   ctx->NewPath();
   ctx->Rectangle(gfxRect(pxRect.x, pxRect.y, pxRect.width, pxRect.height), PR_TRUE);
   ctx->Fill();
 }
 
 /********************************************************
 * Refreshes each content's frame
 *********************************************************/
@@ -3603,17 +3603,17 @@ nsPoint nsIFrame::GetOffsetTo(const nsIF
 // virtual
 nsIntRect nsIFrame::GetScreenRectExternal() const
 {
   return GetScreenRect();
 }
 
 nsIntRect nsIFrame::GetScreenRect() const
 {
-  return nsRect::ToNearestPixels(GetScreenRectInAppUnits(), PresContext()->AppUnitsPerDevPixel());
+  return GetScreenRectInAppUnits().ToNearestPixels(PresContext()->AppUnitsPerDevPixel());
 }
 
 // virtual
 nsRect nsIFrame::GetScreenRectInAppUnitsExternal() const
 {
   return GetScreenRectInAppUnits();
 }
 
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -4320,17 +4320,17 @@ void nsPluginInstanceOwner::Paint(const 
   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));
 
   // Convert to absolute pixel values for the dirty rect
-  nsIntRect absDirtyRect = nsRect::ToOutsidePixels(nsRect(abs, aDirtyRect.Size()), *mOwner->GetPresContext()->AppUnitsPerDevPixel());
+  nsIntRect absDirtyRect = nsRect(abs, aDirtyRect.Size()).ToOutsidePixels(*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);
@@ -4364,17 +4364,17 @@ void nsPluginInstanceOwner::Paint(const 
 #ifdef XP_OS2
 void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, HPS aHPS)
 {
   if (!mInstance || !mOwner)
     return;
 
   nsPluginWindow * window;
   GetWindow(window);
-  nsIntRect relDirtyRect = nsRect::ToOutsidePixels(aDirtyRect, mOwner->PresContext()->AppUnitsPerDevPixel());
+  nsIntRect relDirtyRect = aDirtyRect.ToOutsidePixels(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
   RECTL rectl;
   rectl.xLeft   = relDirtyRect.x + window->x;
   rectl.yBottom = relDirtyRect.y + window->y;
   rectl.xRight  = rectl.xLeft + relDirtyRect.width;
   rectl.yTop    = rectl.yBottom + relDirtyRect.height;
--- a/layout/svg/base/src/nsSVGForeignObjectFrame.cpp
+++ b/layout/svg/base/src/nsSVGForeignObjectFrame.cpp
@@ -675,17 +675,17 @@ nsSVGForeignObjectFrame::InvalidateDirty
 
   nsSVGForeignObjectElement *fO =
     static_cast<nsSVGForeignObjectElement*>(mContent);
   float x, y;
   fO->GetAnimatedLengthValues(&x, &y, nsnull);
   nsCOMPtr<nsIDOMSVGMatrix> localTM;
   ctm->Translate(x, y, getter_AddRefs(localTM));
 
-  nsIntRect r = nsRect::ToOutsidePixels(aRect, presContext->AppUnitsPerDevPixel());
+  nsIntRect r = aRect.ToOutsidePixels(presContext->AppUnitsPerDevPixel());
   nsRect rect = GetTransformedRegion(r.x, r.y, r.width, r.height,
                                      localTM, 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
@@ -121,19 +121,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();
-  nsIntRect p = nsRect::ToOutsidePixels(r, appUnitsPerDevPixel);
+  nsIntRect p = r.ToOutsidePixels(appUnitsPerDevPixel);
   p = filterFrame->GetFilterBBox(firstFrame, &p);
-  r = nsIntRect::ToAppUnits(p, appUnitsPerDevPixel);
+  r = p.ToAppUnits(appUnitsPerDevPixel);
   // Make it relative to aFrame again
   return r + userSpaceRect.TopLeft() - aFrame->GetOffsetTo(firstFrame);
 }
 
 nsRect
 nsSVGIntegrationUtils::GetInvalidAreaForChangedSource(nsIFrame* aFrame,
                                                       const nsRect& aInvalidRect)
 {
@@ -152,19 +152,19 @@ nsSVGIntegrationUtils::GetInvalidAreaFor
     // Be conservative.
     return aFrame->GetOverflowRect();
   }
 
   PRInt32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
   nsRect userSpaceRect = GetNonSVGUserSpace(firstFrame);
   nsPoint offset = aFrame->GetOffsetTo(firstFrame) - userSpaceRect.TopLeft();
   nsRect r = aInvalidRect + offset;
-  nsIntRect p = nsRect::ToOutsidePixels(r, appUnitsPerDevPixel);
+  nsIntRect p = r.ToOutsidePixels(appUnitsPerDevPixel);
   p = filterFrame->GetInvalidationBBox(firstFrame, p);
-  r = nsIntRect::ToAppUnits(p, appUnitsPerDevPixel);
+  r = p.ToAppUnits(appUnitsPerDevPixel);
   return r - offset;
 }
 
 nsRect
 nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea(nsIFrame* aFrame,
                                                        const nsRect& aDamageRect)
 {
   // Don't bother calling GetEffectProperties; the filter property should
@@ -175,19 +175,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;
-  nsIntRect p = nsRect::ToOutsidePixels(r, appUnitsPerDevPixel);
+  nsIntRect p = r.ToOutsidePixels(appUnitsPerDevPixel);
   p = filterFrame->GetSourceForInvalidArea(firstFrame, p);
-  r = nsIntRect::ToAppUnits(p, appUnitsPerDevPixel);
+  r = p.ToAppUnits(appUnitsPerDevPixel);
   return r - offset;
 }
 
 PRBool
 nsSVGIntegrationUtils::HitTestFrameForEffects(nsIFrame* aFrame, const nsPoint& aPt)
 {
   nsIFrame* firstFrame =
     nsLayoutUtils::GetFirstContinuationOrSpecialSibling(aFrame);
@@ -207,17 +207,17 @@ public:
 
   virtual void Paint(nsSVGRenderState *aContext, nsIFrame *aTarget,
                      const nsIntRect* aDirtyRect)
   {
     nsIRenderingContext* ctx = aContext->GetRenderingContext(aTarget);
     nsIRenderingContext::AutoPushTranslation push(ctx, -mOffset.x, -mOffset.y);
     nsRect dirty;
     if (aDirtyRect) {
-      dirty = nsIntRect::ToAppUnits(*aDirtyRect, nsIDeviceContext::AppUnitsPerCSSPixel());
+      dirty = aDirtyRect->ToAppUnits(nsIDeviceContext::AppUnitsPerCSSPixel());
       dirty += mOffset;
     } else {
       dirty = mInnerList->GetBounds(mBuilder);
     }
     mInnerList->Paint(mBuilder, ctx, dirty);
   }
 
 private:
@@ -276,17 +276,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 = nsIntRect::ToAppUnits(nsRect::ToNearestPixels(userSpaceRect, appUnitsPerDevPixel), appUnitsPerDevPixel);
+  userSpaceRect = userSpaceRect.ToNearestPixels(appUnitsPerDevPixel).ToAppUnits(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)) {
@@ -301,17 +301,17 @@ nsSVGIntegrationUtils::PaintFramesWithEf
   if (clipPathFrame && isTrivialClip) {
     gfx->Save();
     clipPathFrame->ClipPaint(&svgContext, aEffectsFrame, matrix);
   }
 
   /* Paint the child */
   if (filterFrame) {
     RegularFramePaintCallback paint(aBuilder, aInnerList, userSpaceRect.TopLeft());
-    nsIntRect r = nsRect::ToOutsidePixels(aDirtyRect - userSpaceRect.TopLeft(), appUnitsPerDevPixel);
+    nsIntRect r = (aDirtyRect - userSpaceRect.TopLeft()).ToOutsidePixels(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
@@ -548,17 +548,17 @@ 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
 
-  nsIntRect dirtyPxRect = nsRect::ToOutsidePixels(dirtyRect, PresContext()->AppUnitsPerDevPixel());
+  nsIntRect dirtyPxRect = dirtyRect.ToOutsidePixels(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);
--- a/layout/svg/base/src/nsSVGUtils.cpp
+++ b/layout/svg/base/src/nsSVGUtils.cpp
@@ -507,17 +507,17 @@ nsSVGUtils::GetFarthestViewportElement(n
 
   return NS_OK;
 }
 
 nsRect
 nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame, const nsRect& aRect)
 {
   PRInt32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
-  nsIntRect rect = nsRect::ToOutsidePixels(aRect, appUnitsPerDevPixel);
+  nsIntRect rect = aRect.ToOutsidePixels(appUnitsPerDevPixel);
 
   while (aFrame) {
     if (aFrame->GetStateBits() & NS_STATE_IS_OUTER_SVG)
       break;
 
     nsSVGFilterFrame *filter = nsSVGEffects::GetFilterFrame(aFrame);
     if (filter) {
       // When we are under AttributeChanged, we can no longer get the old bbox
@@ -560,17 +560,17 @@ nsSVGUtils::FindFilterInvalidation(nsIFr
       } else {
         NS_NOTREACHED("Not going to invalidate the correct area");
       }
       aFrame = viewportFrame;
     }
     aFrame = aFrame->GetParent();
   }
 
-  return nsIntRect::ToAppUnits(rect, appUnitsPerDevPixel);
+  return rect.ToAppUnits(appUnitsPerDevPixel);
 }
 
 void
 nsSVGUtils::InvalidateCoveredRegion(nsIFrame *aFrame)
 {
   if (aFrame->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)
     return;
 
@@ -927,17 +927,17 @@ nsSVGUtils::PaintFrameWithEffects(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 = nsIntRect::ToAppUnits(*aDirtyRect, aFrame->PresContext()->AppUnitsPerDevPixel());
+      nsRect rect = aDirtyRect->ToAppUnits(aFrame->PresContext()->AppUnitsPerDevPixel());
       if (!rect.Intersects(aFrame->GetRect()))
         return;
     }
   }
 
   /* SVG defines the following rendering model:
    *
    *  1. Render geometry
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -1047,17 +1047,17 @@ nsMenuPopupFrame::SetPopupPosition(nsIFr
       if (mMenuCanOverlapOSBar)
         screen->GetRect(&screenRectPixels.x, &screenRectPixels.y,
                         &screenRectPixels.width, &screenRectPixels.height);
       else
         screen->GetAvailRect(&screenRectPixels.x, &screenRectPixels.y,
                              &screenRectPixels.width, &screenRectPixels.height);
     }
   }
-  nsRect screenRect = nsIntRect::ToAppUnits(screenRectPixels, presContext->AppUnitsPerDevPixel());
+  nsRect screenRect = screenRectPixels.ToAppUnits(presContext->AppUnitsPerDevPixel());
 
   // keep a 3 pixel margin to the right and bottom of the screen for the WinXP dropshadow
   screenRect.SizeBy(-nsPresContext::CSSPixelsToAppUnits(3),
                     -nsPresContext::CSSPixelsToAppUnits(3));
 
   // for content shells, clip to the client area rather than the screen area
   if (mInContentShell)
     screenRect.IntersectRect(screenRect, rootScreenRect);
--- a/layout/xul/base/src/nsScrollBoxObject.cpp
+++ b/layout/xul/base/src/nsScrollBoxObject.cpp
@@ -285,17 +285,17 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollT
     // TODO: make sure the child is inside the box
 
     // get our current info
     nsPoint cp;
     scrollableView->GetScrollPosition(cp.x,cp.y);
 
     nsIntRect prect;
     GetOffsetRect(prect);
-    crect = nsIntRect::ToAppUnits(prect, nsPresContext::AppUnitsPerCSSPixel());
+    crect = prect.ToAppUnits(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,17 +385,17 @@ NS_IMETHODIMP nsScrollBoxObject::EnsureE
 
     // TODO: make sure the child is inside the box
 
     // get our current info
     nsPoint cp;
     scrollableView->GetScrollPosition(cp.x,cp.y);
     nsIntRect prect;
     GetOffsetRect(prect);
-    crect = nsIntRect::ToAppUnits(prect, nsPresContext::AppUnitsPerCSSPixel());
+    crect = prect.ToAppUnits(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/tree/src/nsTreeBodyFrame.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -643,17 +643,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();
-  nsIntRect rect = nsRect::ToOutsidePixels(mRect, presContext->AppUnitsPerCSSPixel());
+  nsIntRect rect = mRect.ToOutsidePixels(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);
--- a/view/src/nsScrollPortView.cpp
+++ b/view/src/nsScrollPortView.cpp
@@ -573,18 +573,18 @@ void nsScrollPortView::Scroll(nsView *aS
         nsRect biggestRect(0,0,0,0);
         const nsRect* r;
         for (r = iter.Next(); r; r = iter.Next()) {
           if (PRInt64(r->width)*PRInt64(r->height) > PRInt64(biggestRect.width)*PRInt64(biggestRect.height)) {
             biggestRect = *r;
           }
         }
         toScrollPtr = &toScroll;
-        toScroll = nsRect::ToInsidePixels(biggestRect, aP2A);
-        biggestRect = nsIntRect::ToAppUnits(toScroll, aP2A);
+        toScroll = biggestRect.ToInsidePixels(aP2A);
+        biggestRect = toScroll.ToAppUnits(aP2A);
         regionToScroll.Sub(regionToScroll, biggestRect);
         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);
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -374,17 +374,17 @@ nsIntRect nsView::CalcWidgetBounds(nsWin
     if (parentWidget && aType == eWindowType_popup &&
         mVis == nsViewVisibility_kShow) {
       nsIntPoint screenPoint = parentWidget->WidgetToScreenOffset();
       viewBounds += nsPoint(NSIntPixelsToAppUnits(screenPoint.x, p2a),
                             NSIntPixelsToAppUnits(screenPoint.y, p2a));
     }
   }
 
-  nsIntRect newBounds = nsRect::ToNearestPixels(viewBounds, p2a);
+  nsIntRect newBounds = viewBounds.ToNearestPixels(p2a);
 
   nsPoint roundedOffset(NSIntPixelsToAppUnits(newBounds.x, p2a),
                         NSIntPixelsToAppUnits(newBounds.y, p2a));
   mViewToWidgetOffset = viewBounds.TopLeft() - roundedOffset;
 
   return newBounds;
 }
 
@@ -754,19 +754,19 @@ void nsIView::List(FILE* out, PRInt32 aI
   fprintf(out, "%p ", (void*)this);
   if (nsnull != mWindow) {
     nsIDeviceContext *dx;
     mViewManager->GetDeviceContext(dx);
     nscoord p2a = dx->AppUnitsPerDevPixel();
     NS_RELEASE(dx);
     nsIntRect rect;
     mWindow->GetClientBounds(rect);
-    nsRect windowBounds = nsIntRect::ToAppUnits(rect, p2a);
+    nsRect windowBounds = rect.ToAppUnits(p2a);
     mWindow->GetBounds(rect);
-    nsRect nonclientBounds = nsIntRect::ToAppUnits(rect, p2a);
+    nsRect nonclientBounds = rect.ToAppUnits(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/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -1108,17 +1108,17 @@ NS_IMETHODIMP nsViewManager::DispatchEve
         } else {
           // since we got an NS_PAINT event, we need to
           // draw something so we don't get blank areas,
           // unless there's no widget or it's transparent.
           nsIntRect damIntRect;
           region->GetBoundingBox(&damIntRect.x, &damIntRect.y,
                                  &damIntRect.width, &damIntRect.height);
           nsRect damRect =
-            nsIntRect::ToAppUnits(damIntRect, mContext->AppUnitsPerDevPixel());
+            damIntRect.ToAppUnits(mContext->AppUnitsPerDevPixel());
 
           nsIWidget* widget = view->GetNearestWidget(nsnull);
           if (widget && widget->GetTransparencyMode() == eTransparencyOpaque) {
             nsCOMPtr<nsIRenderingContext> context = event->renderingContext;
             if (!context)
               context = CreateRenderingContext(*view);
 
             if (context)
@@ -2010,17 +2010,17 @@ nsIntRect nsViewManager::ViewToWidget(ns
   rect.IntersectRect(rect, bounds);
   // account for the view's origin not lining up with the widget's
   rect.x -= bounds.x;
   rect.y -= bounds.y;
 
   rect += aView->ViewToWidgetOffset();
 
   // finally, convert to device coordinates.
-  return nsRect::ToOutsidePixels(rect, mContext->AppUnitsPerDevPixel());
+  return rect.ToOutsidePixels(mContext->AppUnitsPerDevPixel());
 }
 
 nsresult nsViewManager::GetVisibleRect(nsRect& aVisibleRect)
 {
   nsresult rv = NS_OK;
 
   // Get the viewport scroller
   nsIScrollableView* scrollingView;
--- a/widget/src/xpwidgets/nsBaseDragService.cpp
+++ b/widget/src/xpwidgets/nsBaseDragService.cpp
@@ -445,19 +445,18 @@ nsBaseDragService::DrawDrag(nsIDOMNode* 
     // if a region was specified, set the screen rectangle to the area that
     // the region occupies
     if (aRegion) {
       // the region's coordinates are relative to the root frame
       nsIFrame* rootFrame = presShell->GetRootFrame();
       if (rootFrame && *aPresContext) {
         nsIntRect dragRect;
         aRegion->GetBoundingBox(&dragRect.x, &dragRect.y, &dragRect.width, &dragRect.height);
-        dragRect = nsRect::ToOutsidePixels(nsIntRect::ToAppUnits(dragRect,
-                                                                 nsPresContext::AppUnitsPerCSSPixel()),
-                                           (*aPresContext)->AppUnitsPerDevPixel());
+        dragRect = dragRect.ToAppUnits(nsPresContext::AppUnitsPerCSSPixel()).
+                            ToOutsidePixels((*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