Bug 1086708 - Rename the snapping variant of NSRectToRect to NSRectToSnappedRect. r=mattwoodrow
authorJonathan Watt <jwatt@jwatt.org>
Wed, 22 Oct 2014 12:29:06 +0100
changeset 227899 b79c69671314ec6afb9558e6673752308f5b0fed
parent 227898 71cefcb137d7d0f1d90424056582d16dfd40a93b
child 227900 1328d46cf70426fe86c846d284c079e9cafa1265
push id7326
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:58:42 +0000
treeherdermozilla-aurora@d3a3b2a0f2f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1086708
milestone36.0a1
Bug 1086708 - Rename the snapping variant of NSRectToRect to NSRectToSnappedRect. r=mattwoodrow
layout/base/nsCSSRendering.cpp
layout/base/nsCaret.cpp
layout/base/nsDisplayList.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/base/nsPresShell.cpp
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsFieldSetFrame.cpp
layout/forms/nsGfxCheckboxControlFrame.cpp
layout/generic/nsBulletFrame.cpp
layout/generic/nsCanvasFrame.cpp
layout/generic/nsFrameSetFrame.cpp
layout/generic/nsImageFrame.cpp
layout/generic/nsPageFrame.cpp
layout/mathml/nsMathMLChar.cpp
layout/mathml/nsMathMLContainerFrame.cpp
layout/mathml/nsMathMLFrame.cpp
layout/svg/nsSVGIntegrationUtils.cpp
layout/svg/nsSVGUtils.cpp
layout/tables/nsTableCellFrame.cpp
layout/xul/nsBoxFrame.cpp
layout/xul/nsGroupBoxFrame.cpp
layout/xul/nsTextBoxFrame.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -679,19 +679,19 @@ nsCSSRendering::PaintBorderWithStyleBord
   if (::IsBoxDecorationSlice(aStyleBorder)) {
     if (joinedBorderArea.IsEqualEdges(aBorderArea)) {
       // No need for a clip, just skip the sides we don't want.
       border.ApplySkipSides(aSkipSides);
     } else {
       // We're drawing borders around the joined continuation boxes so we need
       // to clip that to the slice that we want for this frame.
       aRenderingContext.ThebesContext()->
-        Clip(NSRectToRect(aBorderArea,
-                          aForFrame->PresContext()->AppUnitsPerDevPixel(),
-                          *aRenderingContext.GetDrawTarget()));
+        Clip(NSRectToSnappedRect(aBorderArea,
+                                 aForFrame->PresContext()->AppUnitsPerDevPixel(),
+                                 *aRenderingContext.GetDrawTarget()));
     }
   } else {
     MOZ_ASSERT(joinedBorderArea.IsEqualEdges(aBorderArea),
                "Should use aBorderArea for box-decoration-break:clone");
     MOZ_ASSERT(aForFrame->GetSkipSides().IsEmpty(),
                "Should not skip sides for box-decoration-break:clone except "
                "::first-letter/line continuations or other frame types that "
                "don't have borders but those shouldn't reach this point.");
@@ -1367,19 +1367,19 @@ nsCSSRendering::PaintBoxShadowOuter(nsPr
           nscoord ymost = fragmentClip.YMost();
           nscoord overflow = ymost - aFrameArea.YMost();
           if (overflow > 0) {
             fragmentClip.height -= overflow;
           }
         }
       }
       aRenderingContext.ThebesContext()->
-        Clip(NSRectToRect(fragmentClip,
-                          aForFrame->PresContext()->AppUnitsPerDevPixel(),
-                          *aRenderingContext.GetDrawTarget()));
+        Clip(NSRectToSnappedRect(fragmentClip,
+                                 aForFrame->PresContext()->AppUnitsPerDevPixel(),
+                                 *aRenderingContext.GetDrawTarget()));
 
       gfxCornerSizes clipRectRadii;
       if (hasBorderRadius) {
         gfxFloat spreadDistance = shadowItem->mSpread / twipsPerPixel;
 
         gfxFloat borderSizes[4];
 
         borderSizes[NS_SIDE_LEFT] = spreadDistance;
@@ -3288,18 +3288,19 @@ DrawBorderImage(nsPresContext*       aPr
       // We're drawing borders around the joined continuation boxes so we need
       // to clip that to the slice that we want for this frame.
       borderImgArea.Inflate(imageOutset);
       imageOutset.ApplySkipSides(aSkipSides);
       nsRect clip = aBorderArea;
       clip.Inflate(imageOutset);
       autoSR.EnsureSaved(aRenderingContext.ThebesContext());
       aRenderingContext.ThebesContext()->
-        Clip(NSRectToRect(clip, aForFrame->PresContext()->AppUnitsPerDevPixel(),
-                          *aRenderingContext.GetDrawTarget()));
+        Clip(NSRectToSnappedRect(clip,
+                                 aForFrame->PresContext()->AppUnitsPerDevPixel(),
+                                 *aRenderingContext.GetDrawTarget()));
     }
   } else {
     borderImgArea = aBorderArea;
     borderImgArea.Inflate(imageOutset);
   }
 
   // Calculate the image size used to compute slice points.
   CSSSizeOrRatio intrinsicSize = renderer.ComputeIntrinsicSize();
@@ -3593,33 +3594,36 @@ DrawSolidBorderSegment(nsRenderingContex
       ((0 == aStartBevelOffset) && (0 == aEndBevelOffset))) {
     // simple line or rectangle
     if ((NS_SIDE_TOP == aStartBevelSide) || (NS_SIDE_BOTTOM == aStartBevelSide)) {
       if (1 == aRect.height)
         StrokeLineWithSnapping(aRect.TopLeft(), aRect.BottomLeft(),
                                aAppUnitsPerDevPixel, *drawTarget,
                                color, StrokeOptions(), drawOptions);
       else
-        drawTarget->FillRect(NSRectToRect(aRect, aAppUnitsPerDevPixel, *drawTarget),
+        drawTarget->FillRect(NSRectToSnappedRect(aRect, aAppUnitsPerDevPixel,
+                                                 *drawTarget),
                              color, drawOptions);
     }
     else {
       if (1 == aRect.width)
         StrokeLineWithSnapping(aRect.TopLeft(), aRect.TopRight(),
                                aAppUnitsPerDevPixel, *drawTarget,
                                color, StrokeOptions(), drawOptions);
       else
-        drawTarget->FillRect(NSRectToRect(aRect, aAppUnitsPerDevPixel, *drawTarget),
+        drawTarget->FillRect(NSRectToSnappedRect(aRect, aAppUnitsPerDevPixel,
+                                                 *drawTarget),
                              color, drawOptions);
     }
   }
   else {
     // polygon with beveling
     Point poly[4];
-    SetPoly(NSRectToRect(aRect, aAppUnitsPerDevPixel, *drawTarget), poly);
+    SetPoly(NSRectToSnappedRect(aRect, aAppUnitsPerDevPixel, *drawTarget),
+            poly);
 
     Float startBevelOffset =
       NSAppUnitsToFloatPixels(aStartBevelOffset, aAppUnitsPerDevPixel);
     switch(aStartBevelSide) {
     case NS_SIDE_TOP:
       poly[0].x += startBevelOffset;
       break;
     case NS_SIDE_BOTTOM:
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -527,19 +527,19 @@ void nsCaret::PaintCaret(nsDisplayListBu
   DrawTarget* drawTarget = aCtx->GetDrawTarget();
   int32_t appUnitsPerDevPixel = frame->PresContext()->AppUnitsPerDevPixel();
 
   nsRect caretRect;
   nsRect hookRect;
   ComputeCaretRects(frame, contentOffset, &caretRect, &hookRect);
 
   Rect devPxCaretRect =
-    NSRectToRect(caretRect + aOffset, appUnitsPerDevPixel, *drawTarget);
+    NSRectToSnappedRect(caretRect + aOffset, appUnitsPerDevPixel, *drawTarget);
   Rect devPxHookRect =
-    NSRectToRect(hookRect + aOffset, appUnitsPerDevPixel, *drawTarget);
+    NSRectToSnappedRect(hookRect + aOffset, appUnitsPerDevPixel, *drawTarget);
   ColorPattern color(ToDeviceColor(frame->GetCaretColorAt(contentOffset)));
 
   drawTarget->FillRect(devPxCaretRect, color);
   if (!hookRect.IsEmpty()) {
     drawTarget->FillRect(devPxHookRect, color);
   }
 }
 
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1835,17 +1835,18 @@ nsDisplaySolidColor::GetBounds(nsDisplay
 }
 
 void
 nsDisplaySolidColor::Paint(nsDisplayListBuilder* aBuilder,
                            nsRenderingContext* aCtx)
 {
   int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
   DrawTarget* drawTarget = aCtx->GetDrawTarget();
-  Rect rect = NSRectToRect(mVisibleRect, appUnitsPerDevPixel, *drawTarget);
+  Rect rect =
+    NSRectToSnappedRect(mVisibleRect, appUnitsPerDevPixel, *drawTarget);
   drawTarget->FillRect(rect, ColorPattern(ToDeviceColor(mColor)));
 }
 
 #ifdef MOZ_DUMP_PAINTING
 void
 nsDisplaySolidColor::WriteDebugInfo(nsACString& aTo)
 {
   aTo += nsPrintfCString(" (rgba %d,%d,%d,%d)",
@@ -3113,17 +3114,17 @@ nsDisplayBoxShadowInner::Paint(nsDisplay
     js::ProfileEntry::Category::GRAPHICS);
 
   DrawTarget* drawTarget = aCtx->GetDrawTarget();
   gfxContext* gfx = aCtx->ThebesContext();
   int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
 
   for (uint32_t i = 0; i < rects.Length(); ++i) {
     gfx->Save();
-    gfx->Clip(NSRectToRect(rects[i], appUnitsPerDevPixel, *drawTarget));
+    gfx->Clip(NSRectToSnappedRect(rects[i], appUnitsPerDevPixel, *drawTarget));
     nsCSSRendering::PaintBoxShadowInner(presContext, *aCtx, mFrame,
                                         borderRect, rects[i]);
     gfx->Restore();
   }
 }
 
 bool
 nsDisplayBoxShadowInner::ComputeVisibility(nsDisplayListBuilder* aBuilder,
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -7044,18 +7044,18 @@ Rect NSRectToRect(const nsRect& aRect, d
   // Note that by making aAppUnitsPerPixel a double we're doing floating-point
   // division using a larger type and avoiding rounding error.
   return Rect(Float(aRect.x / aAppUnitsPerPixel),
               Float(aRect.y / aAppUnitsPerPixel),
               Float(aRect.width / aAppUnitsPerPixel),
               Float(aRect.height / aAppUnitsPerPixel));
 }
 
-Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel,
-                  const gfx::DrawTarget& aSnapDT)
+Rect NSRectToSnappedRect(const nsRect& aRect, double aAppUnitsPerPixel,
+                         const gfx::DrawTarget& aSnapDT)
 {
   // Note that by making aAppUnitsPerPixel a double we're doing floating-point
   // division using a larger type and avoiding rounding error.
   Rect rect(Float(aRect.x / aAppUnitsPerPixel),
             Float(aRect.y / aAppUnitsPerPixel),
             Float(aRect.width / aAppUnitsPerPixel),
             Float(aRect.height / aAppUnitsPerPixel));
   MaybeSnapToDevicePixels(rect, aSnapDT, true);
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2418,18 +2418,18 @@ gfx::Rect NSRectToRect(const nsRect& aRe
  * are device pixels or CSS px depends on what the caller chooses to pass as
  * aAppUnitsPerPixel).
  *
  * The passed DrawTarget is used to additionally snap the returned Rect to
  * device pixels, if appropriate (as decided and carried out by Moz2D's
  * MaybeSnapToDevicePixels helper, which this function calls to do any
  * snapping).
  */
-gfx::Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel,
-                       const gfx::DrawTarget& aSnapDT);
+gfx::Rect NSRectToSnappedRect(const nsRect& aRect, double aAppUnitsPerPixel,
+                              const gfx::DrawTarget& aSnapDT);
 
 void StrokeLineWithSnapping(const nsPoint& aP1, const nsPoint& aP2,
                             int32_t aAppUnitsPerDevPixel,
                             gfx::DrawTarget& aDrawTarget,
                             const gfx::Pattern& aPattern,
                             const gfx::StrokeOptions& aStrokeOptions = gfx::StrokeOptions(),
                             const gfx::DrawOptions& aDrawOptions = gfx::DrawOptions());
 
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -10128,17 +10128,18 @@ void ReflowCountMgr::PaintCount(const ch
         } else {
           rc = 255;
         }
         color  = NS_RGB(rc,gc,bc);
         color2 = NS_RGB(rc/2,gc/2,bc/2);
       }
 
       nsRect rect(0,0, width+15, height+15);
-      Rect devPxRect = NSRectToRect(rect, appUnitsPerDevPixel, *drawTarget);
+      Rect devPxRect =
+        NSRectToSnappedRect(rect, appUnitsPerDevPixel, *drawTarget);
       ColorPattern black(ToDeviceColor(Color(0.f, 0.f, 0.f, 1.f)));
       drawTarget->FillRect(devPxRect, black);
 
       aRenderingContext->ThebesContext()->SetColor(color2);
       aRenderingContext->DrawString(buf, strlen(buf), x+15,y+15);
       aRenderingContext->ThebesContext()->SetColor(color);
       aRenderingContext->DrawString(buf, strlen(buf), x,y);
 
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1504,19 +1504,19 @@ void nsComboboxControlFrame::PaintFocus(
   EventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED) || sFocused != this)
     return;
 
   gfxContext* gfx = aRenderingContext.ThebesContext();
 
   gfx->Save();
   nsRect clipRect = mDisplayFrame->GetRect() + aPt;
-  gfx->Clip(NSRectToRect(clipRect,
-                         PresContext()->AppUnitsPerDevPixel(),
-                         *aRenderingContext.GetDrawTarget()));
+  gfx->Clip(NSRectToSnappedRect(clipRect,
+                                PresContext()->AppUnitsPerDevPixel(),
+                                *aRenderingContext.GetDrawTarget()));
 
   // REVIEW: Why does the old code paint mDisplayFrame again? We've
   // already painted it in the children above. So clipping it here won't do
   // us much good.
 
   /////////////////////
   // draw focus
 
--- a/layout/forms/nsFieldSetFrame.cpp
+++ b/layout/forms/nsFieldSetFrame.cpp
@@ -222,42 +222,42 @@ nsFieldSetFrame::PaintBorderBackground(n
     clipRect.width = legendRect.x - rect.x;
     clipRect.height = topBorder;
 
     DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
     gfxContext* gfx = aRenderingContext.ThebesContext();
     int32_t appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
 
     gfx->Save();
-    gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
+    gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
     nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
                                 aDirtyRect, rect, mStyleContext);
     gfx->Restore();
 
 
     // draw right side
     clipRect = rect;
     clipRect.x = legendRect.XMost();
     clipRect.width = rect.XMost() - legendRect.XMost();
     clipRect.height = topBorder;
 
     gfx->Save();
-    gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
+    gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
     nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
                                 aDirtyRect, rect, mStyleContext);
     gfx->Restore();
 
     
     // draw bottom
     clipRect = rect;
     clipRect.y += topBorder;
     clipRect.height = mRect.height - (yoff + topBorder);
     
     gfx->Save();
-    gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
+    gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
     nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
                                 aDirtyRect, rect, mStyleContext);
     gfx->Restore();
   } else {
 
     nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
                                 aDirtyRect,
                                 nsRect(aPt, mRect.Size()),
--- a/layout/forms/nsGfxCheckboxControlFrame.cpp
+++ b/layout/forms/nsGfxCheckboxControlFrame.cpp
@@ -65,17 +65,17 @@ PaintIndeterminateMark(nsIFrame* aFrame,
   DrawTarget* drawTarget = aCtx->GetDrawTarget();
   int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
 
   nsRect rect(aPt, aFrame->GetSize());
   rect.Deflate(aFrame->GetUsedBorderAndPadding());
   rect.y += (rect.height - rect.height/4) / 2;
   rect.height /= 4;
 
-  Rect devPxRect = NSRectToRect(rect, appUnitsPerDevPixel, *drawTarget);
+  Rect devPxRect = NSRectToSnappedRect(rect, appUnitsPerDevPixel, *drawTarget);
 
   drawTarget->FillRect(devPxRect,
                     ColorPattern(ToDeviceColor(aFrame->StyleColor()->mColor)));
 }
 
 //------------------------------------------------------------
 nsIFrame*
 NS_NewGfxCheckboxControlFrame(nsIPresShell* aPresShell,
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -330,17 +330,18 @@ nsBulletFrame::PaintBullet(nsRenderingCo
 
   case NS_STYLE_LIST_STYLE_DISC:
   case NS_STYLE_LIST_STYLE_CIRCLE:
     {
       nsRect rect(padding.left + aPt.x,
                   padding.top + aPt.y,
                   mRect.width - (padding.left + padding.right),
                   mRect.height - (padding.top + padding.bottom));
-      Rect devPxRect = NSRectToRect(rect, appUnitsPerDevPixel, *drawTarget);
+      Rect devPxRect =
+        NSRectToSnappedRect(rect, appUnitsPerDevPixel, *drawTarget);
       RefPtr<PathBuilder> builder = drawTarget->CreatePathBuilder();
       AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size());
       RefPtr<Path> ellipse = builder->Finish();
       if (listStyleType->GetStyle() == NS_STYLE_LIST_STYLE_DISC) {
         drawTarget->Fill(ellipse, color);
       } else {
         drawTarget->Stroke(ellipse, color);
       }
@@ -359,17 +360,18 @@ nsBulletFrame::PaintBullet(nsRenderingCo
       // FIXME: We should really only do this if we're not transformed
       // (like gfxContext::UserToDevicePixelSnapped does).
       nsPresContext *pc = PresContext();
       nsRect snapRect(rect.x, rect.y, 
                       pc->RoundAppUnitsToNearestDevPixels(rect.width),
                       pc->RoundAppUnitsToNearestDevPixels(rect.height));
       snapRect.MoveBy((rect.width - snapRect.width) / 2,
                       (rect.height - snapRect.height) / 2);
-      Rect devPxRect = NSRectToRect(snapRect, appUnitsPerDevPixel, *drawTarget);
+      Rect devPxRect =
+        NSRectToSnappedRect(snapRect, appUnitsPerDevPixel, *drawTarget);
       drawTarget->FillRect(devPxRect, color);
     }
     break;
 
   case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
   case NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN:
     {
       nsRect rect(aPt, mRect.Size());
--- a/layout/generic/nsCanvasFrame.cpp
+++ b/layout/generic/nsCanvasFrame.cpp
@@ -241,17 +241,18 @@ nsDisplayCanvasBackgroundColor::Paint(ns
                                       nsRenderingContext* aCtx)
 {
   nsCanvasFrame* frame = static_cast<nsCanvasFrame*>(mFrame);
   nsPoint offset = ToReferenceFrame();
   nsRect bgClipRect = frame->CanvasArea() + offset;
   if (NS_GET_A(mColor) > 0) {
     DrawTarget* drawTarget = aCtx->GetDrawTarget();
     int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
-    Rect devPxRect = NSRectToRect(bgClipRect, appUnitsPerDevPixel, *drawTarget);
+    Rect devPxRect =
+      NSRectToSnappedRect(bgClipRect, appUnitsPerDevPixel, *drawTarget);
     drawTarget->FillRect(devPxRect, ColorPattern(ToDeviceColor(mColor)));
   }
 }
 
 #ifdef MOZ_DUMP_PAINTING
 void
 nsDisplayCanvasBackgroundColor::WriteDebugInfo(nsACString& aTo)
 {
--- a/layout/generic/nsFrameSetFrame.cpp
+++ b/layout/generic/nsFrameSetFrame.cpp
@@ -1695,17 +1695,18 @@ public:
   NS_DISPLAY_DECL_NAME("FramesetBlank", TYPE_FRAMESET_BLANK)
 };
 
 void nsDisplayFramesetBlank::Paint(nsDisplayListBuilder* aBuilder,
                                    nsRenderingContext* aCtx)
 {
   DrawTarget* drawTarget = aCtx->GetDrawTarget();
   int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
-  Rect rect = NSRectToRect(mVisibleRect, appUnitsPerDevPixel, *drawTarget);
+  Rect rect =
+    NSRectToSnappedRect(mVisibleRect, appUnitsPerDevPixel, *drawTarget);
   ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
   drawTarget->FillRect(rect, white);
 }
 
 void
 nsHTMLFramesetBlankFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                            const nsRect&           aDirtyRect,
                                            const nsDisplayListSet& aLists)
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1220,18 +1220,18 @@ nsImageFrame::DisplayAltFeedback(nsRende
     return;
   }
 
   DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
   gfxContext* gfx = aRenderingContext.ThebesContext();
 
   // Clip so we don't render outside the inner rect
   gfx->Save();
-  gfx->Clip(NSRectToRect(inner, PresContext()->AppUnitsPerDevPixel(),
-                         *drawTarget));
+  gfx->Clip(NSRectToSnappedRect(inner, PresContext()->AppUnitsPerDevPixel(),
+                                *drawTarget));
 
   // Check if we should display image placeholders
   if (gIconLoad->mPrefShowPlaceholders) {
     const nsStyleVisibility* vis = StyleVisibility();
     nscoord size = nsPresContext::CSSPixelsToAppUnits(ICON_SIZE);
 
     bool iconUsed = false;
 
--- a/layout/generic/nsPageFrame.cpp
+++ b/layout/generic/nsPageFrame.cpp
@@ -377,18 +377,18 @@ nsPageFrame::DrawHeaderFooter(nsRenderin
       y = aRect.YMost() - aHeight - mPD->mEdgePaperMargin.bottom;
     }
 
     DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
     gfxContext* gfx = aRenderingContext.ThebesContext();
 
     // set up new clip and draw the text
     gfx->Save();
-    gfx->Clip(NSRectToRect(aRect, PresContext()->AppUnitsPerDevPixel(),
-                           *drawTarget));
+    gfx->Clip(NSRectToSnappedRect(aRect, PresContext()->AppUnitsPerDevPixel(),
+                                  *drawTarget));
     aRenderingContext.ThebesContext()->SetColor(NS_RGB(0,0,0));
     nsLayoutUtils::DrawString(this, &aRenderingContext, str.get(), str.Length(), nsPoint(x, y + aAscent));
     gfx->Restore();
   }
 }
 
 /**
  * Remove all leaf display items that are not for descendants of
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -1829,19 +1829,19 @@ public:
 private:
   nsRect    mRect;
 };
 
 void nsDisplayMathMLSelectionRect::Paint(nsDisplayListBuilder* aBuilder,
                                          nsRenderingContext* aCtx)
 {
   DrawTarget* drawTarget = aCtx->GetDrawTarget();
-  Rect rect = NSRectToRect(mRect + ToReferenceFrame(),
-                           mFrame->PresContext()->AppUnitsPerDevPixel(),
-                           *drawTarget);
+  Rect rect = NSRectToSnappedRect(mRect + ToReferenceFrame(),
+                                  mFrame->PresContext()->AppUnitsPerDevPixel(),
+                                  *drawTarget);
   // get color to use for selection from the look&feel object
   nscolor bgColor =
     LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackground,
                           NS_RGB(0, 0, 0));
   drawTarget->FillRect(rect, ColorPattern(ToDeviceColor(bgColor)));
 }
 
 class nsDisplayMathMLCharBackground : public nsDisplayItem {
--- a/layout/mathml/nsMathMLContainerFrame.cpp
+++ b/layout/mathml/nsMathMLContainerFrame.cpp
@@ -96,18 +96,19 @@ void nsDisplayMathMLError::Paint(nsDispl
   // Set color and font ...
   nsRefPtr<nsFontMetrics> fm;
   nsLayoutUtils::GetFontMetricsForFrame(mFrame, getter_AddRefs(fm));
   aCtx->SetFont(fm);
 
   nsPoint pt = ToReferenceFrame();
   int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
   DrawTarget* drawTarget = aCtx->GetDrawTarget();
-  Rect rect = NSRectToRect(nsRect(pt, mFrame->GetSize()), appUnitsPerDevPixel,
-                           *drawTarget);
+  Rect rect = NSRectToSnappedRect(nsRect(pt, mFrame->GetSize()),
+                                  appUnitsPerDevPixel,
+                                  *drawTarget);
   ColorPattern red(ToDeviceColor(Color(1.f, 0.f, 0.f, 1.f)));
   drawTarget->FillRect(rect, red);
 
   aCtx->ThebesContext()->SetColor(NS_RGB(255,255,255));
   nscoord ascent = aCtx->FontMetrics()->MaxAscent();
   NS_NAMED_LITERAL_STRING(errorMsg, "invalid-markup");
   aCtx->DrawString(errorMsg.get(), uint32_t(errorMsg.Length()),
                    pt.x, pt.y+ascent);
--- a/layout/mathml/nsMathMLFrame.cpp
+++ b/layout/mathml/nsMathMLFrame.cpp
@@ -361,19 +361,19 @@ private:
   nsRect    mRect;
 };
 
 void nsDisplayMathMLBar::Paint(nsDisplayListBuilder* aBuilder,
                                nsRenderingContext* aCtx)
 {
   // paint the bar with the current text color
   DrawTarget* drawTarget = aCtx->GetDrawTarget();
-  Rect rect = NSRectToRect(mRect + ToReferenceFrame(),
-                           mFrame->PresContext()->AppUnitsPerDevPixel(),
-                           *drawTarget);
+  Rect rect = NSRectToSnappedRect(mRect + ToReferenceFrame(),
+                                  mFrame->PresContext()->AppUnitsPerDevPixel(),
+                                  *drawTarget);
   ColorPattern color(ToDeviceColor(
                        mFrame->GetVisitedDependentColor(eCSSProperty_color)));
   drawTarget->FillRect(rect, color);
 }
 
 void
 nsMathMLFrame::DisplayBar(nsDisplayListBuilder* aBuilder,
                           nsIFrame* aFrame, const nsRect& aRect,
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -517,19 +517,19 @@ nsSVGIntegrationUtils::PaintFramesWithEf
   /* 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)
       || aFrame->StyleDisplay()->mMixBlendMode != NS_STYLE_BLEND_NORMAL) {
     complexEffects = true;
     gfx->Save();
     nsRect clipRect =
       aFrame->GetVisualOverflowRectRelativeToSelf() + toUserSpace;
-    gfx->Clip(NSRectToRect(clipRect,
-                           aFrame->PresContext()->AppUnitsPerDevPixel(),
-                           *drawTarget));
+    gfx->Clip(NSRectToSnappedRect(clipRect,
+                                  aFrame->PresContext()->AppUnitsPerDevPixel(),
+                                  *drawTarget));
     gfx->PushGroup(gfxContentType::COLOR_ALPHA);
   }
 
   /* If this frame has only a trivial clipPath, set up cairo's clipping now so
    * we can just do normal painting and get it clipped appropriately.
    */
   if (clipPathFrame && isTrivialClip) {
     gfx->Save();
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -584,19 +584,19 @@ nsSVGUtils::PaintFrameWithEffects(nsIFra
       gfx->Multiply(aTransform);
       nsRect overflowRect = aFrame->GetVisualOverflowRectRelativeToSelf();
       if (aFrame->IsFrameOfType(nsIFrame::eSVGGeometry) ||
           aFrame->IsSVGText()) {
         // Unlike containers, leaf frames do not include GetPosition() in
         // GetCanvasTM().
         overflowRect = overflowRect + aFrame->GetPosition();
       }
-      gfx->Clip(NSRectToRect(overflowRect,
-                             aFrame->PresContext()->AppUnitsPerDevPixel(),
-                             *drawTarget));
+      gfx->Clip(NSRectToSnappedRect(overflowRect,
+                                    aFrame->PresContext()->AppUnitsPerDevPixel(),
+                                    *drawTarget));
     }
     gfx->PushGroup(gfxContentType::COLOR_ALPHA);
   }
 
   /* If this frame has only a trivial clipPath, set up cairo's clipping now so
    * we can just do normal painting and get it clipped appropriately.
    */
   if (clipPathFrame && isTrivialClip) {
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -343,17 +343,18 @@ nsTableCellFrame::DecorateForSelection(n
                                nsPoint(mRect.width, mRect.height),
                                appUnitsPerDevPixel, *drawTarget, color);
         StrokeLineWithSnapping(nsPoint(mRect.width, onePixel),
                                nsPoint(mRect.width, mRect.height),
                                appUnitsPerDevPixel, *drawTarget, color);
         //middle
         nsRect r(onePixel, onePixel,
                  mRect.width - onePixel, mRect.height - onePixel);
-        Rect devPixelRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
+        Rect devPixelRect =
+          NSRectToSnappedRect(r, appUnitsPerDevPixel, *drawTarget);
         drawTarget->StrokeRect(devPixelRect, color);
         //shading
         StrokeLineWithSnapping(nsPoint(2*onePixel, mRect.height-2*onePixel),
                                nsPoint(mRect.width-onePixel, mRect.height- (2*onePixel)),
                                appUnitsPerDevPixel, *drawTarget, color);
         StrokeLineWithSnapping(nsPoint(mRect.width - (2*onePixel), 2*onePixel),
                                nsPoint(mRect.width - (2*onePixel), mRect.height-onePixel),
                                appUnitsPerDevPixel, *drawTarget, color);
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -1607,20 +1607,20 @@ nsBoxFrame::DrawLine(DrawTarget& aDrawTa
     ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
     StrokeLineWithSnapping(p1, p2, PresContext()->AppUnitsPerDevPixel(),
                            aDrawTarget, color);
 }
 
 void
 nsBoxFrame::FillRect(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height)
 {
-    Rect rect = NSRectToRect(aHorizontal ? nsRect(x, y, width, height) :
-                                           nsRect(y, x, height, width),
-                             PresContext()->AppUnitsPerDevPixel(),
-                             aDrawTarget);
+    Rect rect = NSRectToSnappedRect(aHorizontal ? nsRect(x, y, width, height) :
+                                                  nsRect(y, x, height, width),
+                                    PresContext()->AppUnitsPerDevPixel(),
+                                    aDrawTarget);
     ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
     aDrawTarget.FillRect(rect, white);
 }
 
 void 
 nsBoxFrame::DrawSpacer(nsPresContext* aPresContext, DrawTarget& aDrawTarget,
                        bool aHorizontal, int32_t flex, nscoord x, nscoord y,
                        nscoord size, nscoord spacerSize)
--- a/layout/xul/nsGroupBoxFrame.cpp
+++ b/layout/xul/nsGroupBoxFrame.cpp
@@ -168,41 +168,41 @@ nsGroupBoxFrame::PaintBorderBackground(n
     // to achieve the same effect.
 
     // draw left side
     nsRect clipRect(rect);
     clipRect.width = groupRect.x - rect.x;
     clipRect.height = border.top;
 
     gfx->Save();
-    gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
+    gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
     nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
                                 aDirtyRect, rect, mStyleContext, skipSides);
     gfx->Restore();
 
     // draw right side
     clipRect = rect;
     clipRect.x = groupRect.XMost();
     clipRect.width = rect.XMost() - groupRect.XMost();
     clipRect.height = border.top;
 
     gfx->Save();
-    gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
+    gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
     nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
                                 aDirtyRect, rect, mStyleContext, skipSides);
     gfx->Restore();
   
     // draw bottom
 
     clipRect = rect;
     clipRect.y += border.top;
     clipRect.height = mRect.height - (yoff + border.top);
   
     gfx->Save();
-    gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
+    gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
     nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
                                 aDirtyRect, rect, mStyleContext, skipSides);
     gfx->Restore();
     
   } else {
     nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
                                 aDirtyRect, nsRect(aPt, GetSize()),
                                 mStyleContext, skipSides);
--- a/layout/xul/nsTextBoxFrame.cpp
+++ b/layout/xul/nsTextBoxFrame.cpp
@@ -556,17 +556,18 @@ nsTextBoxFrame::DrawText(nsRenderingCont
                            refContext.get());
     }
 
     if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
       nsRect r(aTextRect.x + mAccessKeyInfo->mBeforeWidth,
                aTextRect.y + mAccessKeyInfo->mAccessOffset,
                mAccessKeyInfo->mAccessWidth,
                mAccessKeyInfo->mAccessUnderlineSize);
-      Rect devPxRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
+      Rect devPxRect =
+        NSRectToSnappedRect(r, appUnitsPerDevPixel, *drawTarget);
       drawTarget->FillRect(devPxRect, color);
     }
 
     // Strikeout is drawn on top of the text, per
     // http://www.w3.org/TR/CSS21/zindex.html point 7.2.1.4.1.1.
     if ((decorations & NS_FONT_DECORATION_LINE_THROUGH) &&
         strikeStyle != NS_STYLE_TEXT_DECORATION_STYLE_NONE) {
       fontMet->GetStrikeout(offset, size);
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -2797,18 +2797,19 @@ nsTreeBodyFrame::PaintTreeBody(nsRenderi
 {
   // Update our available height and our page count.
   CalcInnerBox();
 
   DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
   gfxContext* gfx = aRenderingContext.ThebesContext();
 
   gfx->Save();
-  gfx->Clip(NSRectToRect(mInnerBox + aPt, PresContext()->AppUnitsPerDevPixel(),
-                         *drawTarget));
+  gfx->Clip(NSRectToSnappedRect(mInnerBox + aPt,
+                                PresContext()->AppUnitsPerDevPixel(),
+                                *drawTarget));
   int32_t oldPageCount = mPageLength;
   if (!mHasFixedRowCount)
     mPageLength = mInnerBox.height/mRowHeight;
 
   if (oldPageCount != mPageLength || mHorzWidth != CalcHorzWidth(GetScrollParts())) {
     // Schedule a ResizeReflow that will update our info properly.
     PresContext()->PresShell()->
       FrameNeedsReflow(this, nsIPresShell::eResize, NS_FRAME_IS_DIRTY);
@@ -3623,30 +3624,33 @@ nsTreeBodyFrame::PaintText(int32_t      
   uint8_t decorations = textContext->StyleTextReset()->mTextDecorationLine;
 
   nscoord offset;
   nscoord size;
   if (decorations & (NS_FONT_DECORATION_OVERLINE | NS_FONT_DECORATION_UNDERLINE)) {
     fontMet->GetUnderline(offset, size);
     if (decorations & NS_FONT_DECORATION_OVERLINE) {
       nsRect r(textRect.x, textRect.y, textRect.width, size);
-      Rect devPxRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
+      Rect devPxRect =
+        NSRectToSnappedRect(r, appUnitsPerDevPixel, *drawTarget);
       drawTarget->FillRect(devPxRect, color);
     }
     if (decorations & NS_FONT_DECORATION_UNDERLINE) {
       nsRect r(textRect.x, textRect.y + baseline - offset,
                textRect.width, size);
-      Rect devPxRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
+      Rect devPxRect =
+        NSRectToSnappedRect(r, appUnitsPerDevPixel, *drawTarget);
       drawTarget->FillRect(devPxRect, color);
     }
   }
   if (decorations & NS_FONT_DECORATION_LINE_THROUGH) {
     fontMet->GetStrikeout(offset, size);
     nsRect r(textRect.x, textRect.y + baseline - offset, textRect.width, size);
-    Rect devPxRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
+    Rect devPxRect =
+      NSRectToSnappedRect(r, appUnitsPerDevPixel, *drawTarget);
     drawTarget->FillRect(devPxRect, color);
   }
   nsStyleContext* cellContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecell);
 
   gfxContext* ctx = aRenderingContext.ThebesContext();
   if (opacity != 1.0f) {
     ctx->PushGroup(gfxContentType::COLOR_ALPHA);
   }
@@ -3783,17 +3787,18 @@ nsTreeBodyFrame::PaintProgressMeter(int3
                   height*nsDeviceContext::AppUnitsPerCSSPixel());
       nsLayoutUtils::DrawImage(&aRenderingContext, aPresContext, image,
           nsLayoutUtils::GetGraphicsFilterForFrame(this),
           nsRect(meterRect.TopLeft(), size), meterRect, meterRect.TopLeft(),
           aDirtyRect, imgIContainer::FLAG_NONE);
     } else {
       DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
       int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
-      Rect rect = NSRectToRect(meterRect, appUnitsPerDevPixel, *drawTarget);
+      Rect rect =
+        NSRectToSnappedRect(meterRect, appUnitsPerDevPixel, *drawTarget);
       ColorPattern color(ToDeviceColor(
                            GetVisitedDependentColor(eCSSProperty_color)));
       drawTarget->FillRect(rect, color);
     }
   }
   else if (state == nsITreeView::PROGRESS_UNDETERMINED) {
     // Adjust the rect for its border and padding.
     AdjustForBorderPadding(meterContext, meterRect);