Bug 382595: Lines across embedded svg when scrolling. Followup rounding fix. r+sr=roc
authorsharparrow1@yahoo.com
Sun, 08 Jul 2007 22:04:01 -0700
changeset 3253 550b7530ee6362927d372d1354e7f405be4f5b2d
parent 3252 4f0622e7ad321ef990061cb60235c6e86c13103e
child 3254 7064e8c25060b5cffe08d6191840d238fbdc569e
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs382595
milestone1.9a7pre
Bug 382595: Lines across embedded svg when scrolling. Followup rounding fix. r+sr=roc
gfx/public/nsRect.h
gfx/src/nsRect.cpp
view/src/nsView.cpp
--- a/gfx/public/nsRect.h
+++ b/gfx/public/nsRect.h
@@ -160,19 +160,19 @@ struct NS_GFX nsRect {
                                           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 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 aScale, converting coordinates to integers so that the result
-  // contains the same pixel centers as the unrounded result
-  nsRect& ScaleRoundPreservingCenters(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); }
--- a/gfx/src/nsRect.cpp
+++ b/gfx/src/nsRect.cpp
@@ -199,22 +199,22 @@ nsRect& nsRect::ScaleRoundIn(float aScal
   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::ScaleRoundPreservingCenters(float aScale)
+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);
+  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
 
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -353,17 +353,17 @@ nsRect nsView::CalcWidgetBounds(nsWindow
       nsRect screenRect(0,0,1,1);
       parentWidget->WidgetToScreen(screenRect, screenRect);
       viewBounds += nsPoint(NSIntPixelsToAppUnits(screenRect.x, p2a),
                             NSIntPixelsToAppUnits(screenRect.y, p2a));
     }
   }
 
   nsRect newBounds(viewBounds);
-  newBounds.ScaleRoundPreservingCenters(1.0f / p2a);
+  newBounds.ScaleRoundPreservingCentersInverse(p2a);
 
   nsPoint roundedOffset(NSIntPixelsToAppUnits(newBounds.x, p2a),
                         NSIntPixelsToAppUnits(newBounds.y, p2a));
   mViewToWidgetOffset = viewBounds.TopLeft() - roundedOffset;
 
   return newBounds;
 }