Bug 831237 - Reduce APZC buffer churn; r=BenWa

Prevents the display port from getting smaller as the visible region
approaches the edges of the scrollable rect.
This commit is contained in:
Anthony Jones 2013-05-28 16:17:09 +12:00
parent bf4fc9d9a6
commit b7c0e66763
2 changed files with 17 additions and 1 deletions

View File

@ -418,6 +418,22 @@ struct BaseRect {
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.
*/
Sub ClampRect(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;
return rect;
}
private:
// Do not use the default operator== or operator!= !
// Use IsEqualEdges or IsEqualInterior explicitly.

View File

@ -987,7 +987,7 @@ const gfx::Rect AsyncPanZoomController::CalculatePendingDisplayPort(
gfx::Rect shiftedDisplayPort = displayPort;
shiftedDisplayPort.MoveBy(scrollOffset.x, scrollOffset.y);
displayPort = shiftedDisplayPort.Intersect(scrollableRect);
displayPort = scrollableRect.ClampRect(shiftedDisplayPort);
displayPort.MoveBy(-scrollOffset.x, -scrollOffset.y);
return displayPort;