Bug 1251638 - Do a bit of cleanup on the displayport margin computation in APZC; no functional changes. r?botond
MozReview-Commit-ID: 18HPNVcd7Rk
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -2809,38 +2809,40 @@ const ScreenMargin AsyncPanZoomControlle
if (aFrameMetrics.IsScrollInfoLayer()) {
// Don't compute margins. Since we can't asynchronously scroll this frame,
// we don't want to paint anything more than the composition bounds.
return ScreenMargin();
}
CSSSize compositionSize = aFrameMetrics.CalculateBoundedCompositedSizeInCssPixels();
CSSPoint velocity = aVelocity / aFrameMetrics.GetZoom();
- CSSPoint scrollOffset = aFrameMetrics.GetScrollOffset();
CSSRect scrollableRect = aFrameMetrics.GetExpandedScrollableRect();
// Calculate the displayport size based on how fast we're moving along each axis.
CSSSize displayPortSize = CalculateDisplayPortSize(compositionSize, velocity);
if (gfxPrefs::APZEnlargeDisplayPortWhenClipped()) {
RedistributeDisplayPortExcess(displayPortSize, scrollableRect);
}
+ // We calculate a "displayport" here which is relative to the scroll offset.
+ // Note that the scroll offset we have here in the APZ code may not be the
+ // same as the base rect that gets used on the layout side when the displayport
+ // margins are actually applied, so it is important to only consider the
+ // displayport as margins relative to something rather than an absolute rect.
+
+ // Center the displayport based on its expansion over the composition size.
+ CSSRect displayPort((compositionSize.width - displayPortSize.width) / 2.0f,
+ (compositionSize.height - displayPortSize.height) / 2.0f,
+ displayPortSize.width, displayPortSize.height);
+
// Offset the displayport, depending on how fast we're moving and the
// estimated time it takes to paint, to try to minimise checkerboarding.
float paintFactor = kDefaultEstimatedPaintDurationMs;
- CSSRect displayPort = CSSRect(scrollOffset + (velocity * paintFactor * gfxPrefs::APZVelocityBias()),
- displayPortSize);
-
- // Re-center the displayport based on its expansion over the composition size.
- displayPort.MoveBy((compositionSize.width - displayPort.width)/2.0f,
- (compositionSize.height - displayPort.height)/2.0f);
-
- // Make the displayport relative to the scroll offset
- displayPort = displayPort - scrollOffset;
+ displayPort.MoveBy(velocity * paintFactor * gfxPrefs::APZVelocityBias());
APZC_LOG_FM(aFrameMetrics,
"Calculated displayport as (%f %f %f %f) from velocity %s paint time %f metrics",
displayPort.x, displayPort.y, displayPort.width, displayPort.height,
ToString(aVelocity).c_str(), paintFactor);
CSSMargin cssMargins;
cssMargins.left = -displayPort.x;