mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-18 23:15:38 +00:00
Bug 1555511 Part 2: Remove a float division in MVM::ScaleZoomWithDisplayWidth. r=botond
This is a drive-by fix to turn a division into a multiplication. It also is more correct in that the existing code attempts a divide-by-zero if aNewViewport.width is zero. The updated code will instead return a zoom of zero in such a case. Differential Revision: https://phabricator.services.mozilla.com/D32909 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
8c5b5937fe
commit
2c084a33fd
@ -184,13 +184,13 @@ CSSToScreenScale MobileViewportManager::ClampZoom(
|
||||
CSSToScreenScale MobileViewportManager::ScaleZoomWithDisplayWidth(
|
||||
const CSSToScreenScale& aZoom, const float& aDisplayWidthChangeRatio,
|
||||
const CSSSize& aNewViewport, const CSSSize& aOldViewport) {
|
||||
float cssViewportChangeRatio = (aOldViewport.width == 0)
|
||||
? 1.0f
|
||||
: aNewViewport.width / aOldViewport.width;
|
||||
CSSToScreenScale newZoom(aZoom.scale * aDisplayWidthChangeRatio /
|
||||
cssViewportChangeRatio);
|
||||
MVM_LOG("%p: Old zoom was %f, changed by %f/%f to %f\n", this, aZoom.scale,
|
||||
aDisplayWidthChangeRatio, cssViewportChangeRatio, newZoom.scale);
|
||||
float inverseCssWidthChangeRatio =
|
||||
(aNewViewport.width == 0) ? 1.0f
|
||||
: aOldViewport.width / aNewViewport.width;
|
||||
CSSToScreenScale newZoom(aZoom.scale * aDisplayWidthChangeRatio *
|
||||
inverseCssWidthChangeRatio);
|
||||
MVM_LOG("%p: Old zoom was %f, changed by %f * %f to %f\n", this, aZoom.scale,
|
||||
aDisplayWidthChangeRatio, inverseCssWidthChangeRatio, newZoom.scale);
|
||||
return newZoom;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user