diff --git a/layout/base/MobileViewportManager.cpp b/layout/base/MobileViewportManager.cpp index be330abd742e..fe681700cbfa 100644 --- a/layout/base/MobileViewportManager.cpp +++ b/layout/base/MobileViewportManager.cpp @@ -324,8 +324,21 @@ MobileViewportManager::UpdateResolution(const nsViewportInfo& aViewportInfo, } else { // aType == UpdateType::ContentSize MOZ_ASSERT(aType == UpdateType::ContentSize); MOZ_ASSERT(aDisplayWidthChangeRatio.isNothing()); - if (zoom != intrinsicScale) { - newZoom = Some(intrinsicScale); + + // We try to scale down the contents only IF the document has no initial-scale + // AND IF it's the initial paint AND IF it's not restored documents. + if (mIsFirstPaint && !mRestoreResolution && + !aViewportInfo.IsDefaultZoomValid()) { + if (zoom != intrinsicScale) { + newZoom = Some(intrinsicScale); + } + } else { + // Even in other scenarios, we want to ensure that zoom level is + // not _smaller_ than the intrinsic scale, otherwise we might be + // trying to show regions where there is no content to show. + if (zoom < intrinsicScale) { + newZoom = Some(intrinsicScale); + } } } @@ -516,13 +529,6 @@ MobileViewportManager::ShrinkToDisplaySizeIfNeeded( return; } - // We try to scale down the contents only IF the document has no initial-scale - // AND IF it's the initial paint AND IF it's not restored documents. - if (aViewportInfo.IsDefaultZoomValid() || - !mIsFirstPaint || mRestoreResolution) { - return; - } - nsIScrollableFrame* rootScrollableFrame = mPresShell->GetRootScrollFrameAsScrollable(); if (rootScrollableFrame) {