Bug 1310900 - Speed up ScrollFrameHelper::GetScrolledRect for the case where there is no overflow. r?mattwoodrow
MozReview-Commit-ID: 35CWyjlkfsg
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -5768,16 +5768,25 @@ ScrollFrameHelper::GetScrolledRect() con
}
if (result.height < mScrollPort.height) {
NS_WARNING("Scrolled rect smaller than scrollport?");
}
// Expand / contract the result by up to half a layer pixel so that scrolling
// to the right / bottom edge does not change the layer pixel alignment of
// the scrolled contents.
+
+ if (result.x == 0 && result.y == 0 &&
+ result.width == mScrollPort.width &&
+ result.height == mScrollPort.height) {
+ // The edges that we would snap are already aligned with the scroll port,
+ // so we can skip all the work below.
+ return result;
+ }
+
// For that, we first convert the scroll port and the scrolled rect to rects
// relative to the reference frame, since that's the space where painting does
// snapping.
nsSize scrollPortSize = GetScrollPositionClampingScrollPortSize();
nsIFrame* referenceFrame = nsLayoutUtils::GetReferenceFrame(mOuter);
nsPoint toReferenceFrame = mOuter->GetOffsetToCrossDoc(referenceFrame);
nsRect scrollPort(mScrollPort.TopLeft() + toReferenceFrame, scrollPortSize);
nsRect scrolledRect = result + scrollPort.TopLeft();