Bug 951463 - Rename ClampRect to ForceInside. r=botond, a=1.3+
authorAnthony Jones <ajones@mozilla.com>
Mon, 06 Jan 2014 10:05:07 -0500
changeset 175637 2850f1dad667f9e523e0f5273849d76e778a9224
parent 175636 27f7d967a13e7916487796b6c7d3592db8f78dbd
child 175638 9d0760b64f760d956cf13c3a83a1dc113b9a2e7c
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond, 1
bugs951463
milestone28.0a2
Bug 951463 - Rename ClampRect to ForceInside. r=botond, a=1.3+
gfx/2d/BaseRect.h
layout/base/nsDisplayList.cpp
--- a/gfx/2d/BaseRect.h
+++ b/gfx/2d/BaseRect.h
@@ -436,28 +436,28 @@ struct BaseRect {
    */
   Point ClampPoint(const Point& aPoint) const
   {
     return Point(std::max(x, std::min(XMost(), aPoint.x)),
                  std::max(y, std::min(YMost(), aPoint.y)));
   }
 
   /**
-   * Clamp aRect to this rectangle. This returns aRect after it is forced
-   * inside the bounds of this rectangle. It will attempt to retain the size
-   * but will shrink the dimensions that don't fit.
+   * Clamp this rectangle to be inside aRect. The function returns a copy of
+   * this rect after it is forced inside the bounds of aRect. It will attempt to
+   * retain the size but will shrink the dimensions that don't fit.
    */
-  Sub ClampRect(const Sub& aRect) const
+  Sub ForceInside(const Sub& aRect) const
   {
     Sub rect(std::max(aRect.x, x),
              std::max(aRect.y, y),
              std::min(aRect.width, width),
              std::min(aRect.height, height));
-    rect.x = std::min(rect.XMost(), XMost()) - rect.width;
-    rect.y = std::min(rect.YMost(), YMost()) - rect.height;
+    rect.x = std::min(rect.XMost(), aRect.XMost()) - rect.width;
+    rect.y = std::min(rect.YMost(), aRect.YMost()) - rect.height;
     return rect;
   }
 
 private:
   // Do not use the default operator== or operator!= !
   // Use IsEqualEdges or IsEqualInterior explicitly.
   bool operator==(const Sub& aRect) const { return false; }
   bool operator!=(const Sub& aRect) const { return false; }
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -701,17 +701,17 @@ static void RecordFrameMetrics(nsIFrame*
                                       && aScrollFrame == presShell->GetRootScrollFrame();
   if (isRootContentDocRootScrollFrame) {
     if (nsIWidget* widget = aForFrame->GetNearestWidget()) {
       nsIntRect bounds;
       widget->GetBounds(bounds);
       ScreenIntRect screenBounds = ScreenIntRect::FromUnknownRect(mozilla::gfx::IntRect(
           bounds.x, bounds.y, bounds.width, bounds.height));
       AdjustForScrollBars(screenBounds, scrollableFrame);
-      metrics.mCompositionBounds = screenBounds.ClampRect(metrics.mCompositionBounds);
+      metrics.mCompositionBounds = metrics.mCompositionBounds.ForceInside(screenBounds);
       useWidgetBounds = true;
     }
   }
 
   // Adjust composition bounds for the size of scroll bars.
   // If the widget bounds were used to clamp the composition bounds,
   // this adjustment was already made to the widget bounds.
   if (!useWidgetBounds) {