mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1277814 - Avoid division-by-zero when the cumulative resolution is zero. r=tnikkel
The division-by-zero was introducing NaNs into the displayport calculations, resulting in bad displayports. MozReview-Commit-ID: 5dbqIEOFADS --HG-- extra : source : 569276f2edd39600de534183e12b7f8762b917c8
This commit is contained in:
parent
8004b3209f
commit
06d34b07af
@ -179,11 +179,17 @@ public:
|
||||
|
||||
CSSSize CalculateCompositedSizeInCssPixels() const
|
||||
{
|
||||
if (GetZoom() == CSSToParentLayerScale2D(0, 0)) {
|
||||
return CSSSize(); // avoid division by zero
|
||||
}
|
||||
return mCompositionBounds.Size() / GetZoom();
|
||||
}
|
||||
|
||||
CSSRect CalculateCompositedRectInCssPixels() const
|
||||
{
|
||||
if (GetZoom() == CSSToParentLayerScale2D(0, 0)) {
|
||||
return CSSRect(); // avoid division by zero
|
||||
}
|
||||
return mCompositionBounds / GetZoom();
|
||||
}
|
||||
|
||||
|
@ -2697,7 +2697,10 @@ const ScreenMargin AsyncPanZoomController::CalculatePendingDisplayPort(
|
||||
}
|
||||
|
||||
CSSSize compositionSize = aFrameMetrics.CalculateBoundedCompositedSizeInCssPixels();
|
||||
CSSPoint velocity = aVelocity / aFrameMetrics.GetZoom();
|
||||
CSSPoint velocity;
|
||||
if (aFrameMetrics.GetZoom() != CSSToParentLayerScale2D(0, 0)) {
|
||||
velocity = aVelocity / aFrameMetrics.GetZoom(); // avoid division by zero
|
||||
}
|
||||
CSSRect scrollableRect = aFrameMetrics.GetExpandedScrollableRect();
|
||||
|
||||
// Calculate the displayport size based on how fast we're moving along each axis.
|
||||
|
@ -1000,6 +1000,19 @@ GetDisplayPortFromMarginsData(nsIContent* aContent,
|
||||
LayoutDeviceToScreenScale2D res(presContext->PresShell()->GetCumulativeResolution()
|
||||
* nsLayoutUtils::GetTransformToAncestorScale(frame));
|
||||
|
||||
// Calculate the expanded scrollable rect, which we'll be clamping the
|
||||
// displayport to.
|
||||
nsRect expandedScrollableRect =
|
||||
nsLayoutUtils::CalculateExpandedScrollableRect(frame);
|
||||
|
||||
// GetTransformToAncestorScale() can return 0. In this case, just return the
|
||||
// base rect (clamped to the expanded scrollable rect), as other calculations
|
||||
// would run into divisions by zero.
|
||||
if (res == LayoutDeviceToScreenScale2D(0, 0)) {
|
||||
// Make sure the displayport remains within the scrollable rect.
|
||||
return base.MoveInsideAndClamp(expandedScrollableRect - scrollPos);
|
||||
}
|
||||
|
||||
// First convert the base rect to screen pixels
|
||||
LayoutDeviceToScreenScale2D parentRes = res;
|
||||
if (isRoot) {
|
||||
@ -1113,8 +1126,6 @@ GetDisplayPortFromMarginsData(nsIContent* aContent,
|
||||
result = ApplyRectMultiplier(result, aMultiplier);
|
||||
|
||||
// Make sure the displayport remains within the scrollable rect.
|
||||
nsRect expandedScrollableRect =
|
||||
nsLayoutUtils::CalculateExpandedScrollableRect(frame);
|
||||
result = result.MoveInsideAndClamp(expandedScrollableRect - scrollPos);
|
||||
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user