Bug 1513232 - Avoid clamping the layout viewport size to be larger than the display size. r=kats

The clamping is intended to be a safeguard against extreme values in the
meta viewport tag. If the layout viewport is sized to the display size,
avoid the clamping, since the display size could legitimately be small
(e.g. in Android 8's picture-in-picture mode).

Differential Revision: https://phabricator.services.mozilla.com/D15605

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2019-01-03 05:53:52 +00:00
Родитель 4e9e43bc92
Коммит f179255747
1 изменённых файлов: 9 добавлений и 2 удалений

Просмотреть файл

@ -6904,7 +6904,14 @@ nsViewportInfo nsIDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
size = displaySize;
}
size.width = clamped(size.width, float(kViewportMinSize.width),
// The purpose of clamping the viewport width to a minimum size is to
// prevent page authors from setting it to a ridiculously small value.
// If the page is actually being rendered in a very small area (as might
// happen in e.g. Android 8's picture-in-picture mode), we don't want to
// prevent the viewport from taking on that size.
CSSSize effectiveMinSize = Min(CSSSize(kViewportMinSize), displaySize);
size.width = clamped(size.width, effectiveMinSize.width,
float(kViewportMaxSize.width));
// Also recalculate the default zoom, if it wasn't specified in the
@ -6914,7 +6921,7 @@ nsViewportInfo nsIDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
scaleFloat = (scaleFloat > defaultScale) ? scaleFloat : defaultScale;
}
size.height = clamped(size.height, float(kViewportMinSize.height),
size.height = clamped(size.height, effectiveMinSize.height,
float(kViewportMaxSize.height));
// We need to perform a conversion, but only if the initial or maximum