mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1566991: Add some assertions to sanity-check that our mobile viewport zoom factors are positive. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D38419 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
a63f0a1fc3
commit
dd66dfe12b
@ -11,6 +11,11 @@
|
||||
using namespace mozilla;
|
||||
|
||||
void nsViewportInfo::ConstrainViewportValues() {
|
||||
// Non-positive zoom factors can produce NaN or negative viewport sizes,
|
||||
// so we better be sure our constraints will produce positive zoom factors.
|
||||
MOZ_ASSERT(mMinZoom > CSSToScreenScale(0.0f), "zoom factor must be positive");
|
||||
MOZ_ASSERT(mMaxZoom > CSSToScreenScale(0.0f), "zoom factor must be positive");
|
||||
|
||||
if (mDefaultZoom > mMaxZoom) {
|
||||
mDefaultZoomValid = false;
|
||||
mDefaultZoom = mMaxZoom;
|
||||
|
@ -219,6 +219,10 @@ void MobileViewportManager::UpdateResolution(
|
||||
CSSToLayoutDeviceScale cssToDev = mContext->CSSToDevPixelScale();
|
||||
LayoutDeviceToLayerScale res(mContext->GetResolution());
|
||||
CSSToScreenScale zoom = ResolutionToZoom(res, cssToDev);
|
||||
// Non-positive zoom factors can produce NaN or negative viewport sizes,
|
||||
// so we better be sure we've got a positive zoom factor.
|
||||
MOZ_ASSERT(zoom > CSSToScreenScale(0.0f), "zoom factor must be positive");
|
||||
|
||||
Maybe<CSSToScreenScale> newZoom;
|
||||
|
||||
ScreenIntSize compositionSize = GetCompositionSize(aDisplaySize);
|
||||
@ -391,6 +395,10 @@ void MobileViewportManager::UpdateResolution(
|
||||
|
||||
// If the zoom has changed, update the pres shell resolution accordingly.
|
||||
if (newZoom) {
|
||||
// Non-positive zoom factors can produce NaN or negative viewport sizes,
|
||||
// so we better be sure we've got a positive zoom factor.
|
||||
MOZ_ASSERT(*newZoom > CSSToScreenScale(0.0f),
|
||||
"zoom factor must be positive");
|
||||
LayoutDeviceToLayerScale resolution = ZoomToResolution(*newZoom, cssToDev);
|
||||
MVM_LOG("%p: setting resolution %f\n", this, resolution.scale);
|
||||
mContext->SetResolutionAndScaleTo(resolution.scale);
|
||||
|
Loading…
Reference in New Issue
Block a user