Bug 1327095 - Shift the rootCompBounds to maximize overlap with the displayportBase before intersecting. r?tnikkel
MozReview-Commit-ID: 457RfGOwRZU
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -3680,16 +3680,40 @@ ScrollFrameHelper::DecideScrollableLayer
// an overflow:hidden document) it is not (see bug 1280013).
// XXX: Eventually we may want to create a modified version of
// TransformRect that includes the APZ callback transforms
// directly.
nsLayoutUtils::TransformRect(rootFrame, mOuter, rootCompBounds);
rootCompBounds += CSSPoint::ToAppUnits(
nsLayoutUtils::GetCumulativeApzCallbackTransform(mOuter));
+ // We want to limit displayportBase to be no larger than rootCompBounds on
+ // either axis, but we don't want to just blindly intersect the two, because
+ // rootCompBounds might be offset from where displayportBase is (see bug
+ // 1327095 comment 8). Instead, we translate rootCompBounds so as to
+ // maximize the overlap with displayportBase, and *then* do the intersection.
+ if (rootCompBounds.x > displayportBase.x && rootCompBounds.XMost() > displayportBase.XMost()) {
+ // rootCompBounds is at a greater x-position for both left and right, so translate it such
+ // that the XMost() values are the same. This will line up the right edge of the two rects,
+ // and might mean that rootCompbounds.x is smaller than displayportBase.x. We can avoid that
+ // by taking the min of the x delta and XMost() delta, but it doesn't really matter because
+ // the intersection between the two rects below will end up the same.
+ rootCompBounds.x -= (rootCompBounds.XMost() - displayportBase.XMost());
+ } else if (rootCompBounds.x < displayportBase.x && rootCompBounds.XMost() < displayportBase.XMost()) {
+ // Analaogous code for when the rootCompBounds is at a smaller x-position.
+ rootCompBounds.x = displayportBase.x;
+ }
+ // Do the same for y-axis
+ if (rootCompBounds.y > displayportBase.y && rootCompBounds.YMost() > displayportBase.YMost()) {
+ rootCompBounds.y -= (rootCompBounds.YMost() - displayportBase.YMost());
+ } else if (rootCompBounds.y < displayportBase.y && rootCompBounds.YMost() < displayportBase.YMost()) {
+ rootCompBounds.y = displayportBase.y;
+ }
+
+ // Now we can do the intersection
displayportBase = displayportBase.Intersect(rootCompBounds);
}
}
}
displayportBase -= mScrollPort.TopLeft();
}