Bug 951463 - Rename ClampRect to ForceInside; r=botond

This commit is contained in:
Anthony Jones 2014-01-06 10:05:07 -05:00
parent e1cec36a10
commit 3b3605ff77
3 changed files with 8 additions and 9 deletions

View File

@ -441,18 +441,18 @@ struct BaseRect {
} }
/** /**
* Clamp aRect to this rectangle. This returns aRect after it is forced * Clamp this rectangle to be inside aRect. The function returns a copy of
* inside the bounds of this rectangle. It will attempt to retain the size * this rect after it is forced inside the bounds of aRect. It will attempt to
* but will shrink the dimensions that don't fit. * 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), Sub rect(std::max(aRect.x, x),
std::max(aRect.y, y), std::max(aRect.y, y),
std::min(aRect.width, width), std::min(aRect.width, width),
std::min(aRect.height, height)); std::min(aRect.height, height));
rect.x = std::min(rect.XMost(), XMost()) - rect.width; rect.x = std::min(rect.XMost(), aRect.XMost()) - rect.width;
rect.y = std::min(rect.YMost(), YMost()) - rect.height; rect.y = std::min(rect.YMost(), aRect.YMost()) - rect.height;
return rect; return rect;
} }

View File

@ -1257,8 +1257,7 @@ const CSSRect AsyncPanZoomController::CalculatePendingDisplayPort(
scrollOffset.y = scrollableRect.y; scrollOffset.y = scrollableRect.y;
} }
CSSRect shiftedDisplayPort = displayPort + scrollOffset; return displayPort.ForceInside(scrollableRect - scrollOffset);
return scrollableRect.ClampRect(shiftedDisplayPort) - scrollOffset;
} }
void AsyncPanZoomController::ScheduleComposite() { void AsyncPanZoomController::ScheduleComposite() {

View File

@ -716,7 +716,7 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
ScreenIntRect screenBounds = ScreenIntRect::FromUnknownRect(mozilla::gfx::IntRect( ScreenIntRect screenBounds = ScreenIntRect::FromUnknownRect(mozilla::gfx::IntRect(
bounds.x, bounds.y, bounds.width, bounds.height)); bounds.x, bounds.y, bounds.width, bounds.height));
AdjustForScrollBars(screenBounds, scrollableFrame); AdjustForScrollBars(screenBounds, scrollableFrame);
metrics.mCompositionBounds = screenBounds.ClampRect(metrics.mCompositionBounds); metrics.mCompositionBounds = metrics.mCompositionBounds.ForceInside(screenBounds);
useWidgetBounds = true; useWidgetBounds = true;
} }
} }