From 3b3605ff77c7420a9ad38755180385fe87bc2ddd Mon Sep 17 00:00:00 2001 From: Anthony Jones Date: Mon, 6 Jan 2014 10:05:07 -0500 Subject: [PATCH] Bug 951463 - Rename ClampRect to ForceInside; r=botond --- gfx/2d/BaseRect.h | 12 ++++++------ gfx/layers/ipc/AsyncPanZoomController.cpp | 3 +-- layout/base/nsDisplayList.cpp | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gfx/2d/BaseRect.h b/gfx/2d/BaseRect.h index 459892defeb..08094a4fbda 100644 --- a/gfx/2d/BaseRect.h +++ b/gfx/2d/BaseRect.h @@ -441,18 +441,18 @@ struct BaseRect { } /** - * 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; } diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp index 789c4518a85..c5935e56602 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.cpp +++ b/gfx/layers/ipc/AsyncPanZoomController.cpp @@ -1257,8 +1257,7 @@ const CSSRect AsyncPanZoomController::CalculatePendingDisplayPort( scrollOffset.y = scrollableRect.y; } - CSSRect shiftedDisplayPort = displayPort + scrollOffset; - return scrollableRect.ClampRect(shiftedDisplayPort) - scrollOffset; + return displayPort.ForceInside(scrollableRect - scrollOffset); } void AsyncPanZoomController::ScheduleComposite() { diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index cdddac27c08..57328ea7177 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -716,7 +716,7 @@ static void RecordFrameMetrics(nsIFrame* aForFrame, 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; } }