зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
8004b3209f
Коммит
06d34b07af
|
@ -179,11 +179,17 @@ public:
|
||||||
|
|
||||||
CSSSize CalculateCompositedSizeInCssPixels() const
|
CSSSize CalculateCompositedSizeInCssPixels() const
|
||||||
{
|
{
|
||||||
|
if (GetZoom() == CSSToParentLayerScale2D(0, 0)) {
|
||||||
|
return CSSSize(); // avoid division by zero
|
||||||
|
}
|
||||||
return mCompositionBounds.Size() / GetZoom();
|
return mCompositionBounds.Size() / GetZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSRect CalculateCompositedRectInCssPixels() const
|
CSSRect CalculateCompositedRectInCssPixels() const
|
||||||
{
|
{
|
||||||
|
if (GetZoom() == CSSToParentLayerScale2D(0, 0)) {
|
||||||
|
return CSSRect(); // avoid division by zero
|
||||||
|
}
|
||||||
return mCompositionBounds / GetZoom();
|
return mCompositionBounds / GetZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2697,7 +2697,10 @@ const ScreenMargin AsyncPanZoomController::CalculatePendingDisplayPort(
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSSize compositionSize = aFrameMetrics.CalculateBoundedCompositedSizeInCssPixels();
|
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();
|
CSSRect scrollableRect = aFrameMetrics.GetExpandedScrollableRect();
|
||||||
|
|
||||||
// Calculate the displayport size based on how fast we're moving along each axis.
|
// 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()
|
LayoutDeviceToScreenScale2D res(presContext->PresShell()->GetCumulativeResolution()
|
||||||
* nsLayoutUtils::GetTransformToAncestorScale(frame));
|
* 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
|
// First convert the base rect to screen pixels
|
||||||
LayoutDeviceToScreenScale2D parentRes = res;
|
LayoutDeviceToScreenScale2D parentRes = res;
|
||||||
if (isRoot) {
|
if (isRoot) {
|
||||||
|
@ -1113,8 +1126,6 @@ GetDisplayPortFromMarginsData(nsIContent* aContent,
|
||||||
result = ApplyRectMultiplier(result, aMultiplier);
|
result = ApplyRectMultiplier(result, aMultiplier);
|
||||||
|
|
||||||
// Make sure the displayport remains within the scrollable rect.
|
// Make sure the displayport remains within the scrollable rect.
|
||||||
nsRect expandedScrollableRect =
|
|
||||||
nsLayoutUtils::CalculateExpandedScrollableRect(frame);
|
|
||||||
result = result.MoveInsideAndClamp(expandedScrollableRect - scrollPos);
|
result = result.MoveInsideAndClamp(expandedScrollableRect - scrollPos);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче