Bug 1500314 Part 1: Only apply mobile viewport stretching for documents with no meta viewport tag. r=botond

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2019-03-22 16:46:23 +00:00
Родитель fe1ca24c8b
Коммит 8da8465a37
2 изменённых файлов: 29 добавлений и 14 удалений

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

@ -6627,7 +6627,11 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
case Unknown: {
nsAutoString viewport;
GetHeaderData(nsGkAtoms::viewport, viewport);
if (viewport.IsEmpty()) {
// We might early exit if the viewport is empty. Even if we don't,
// at the end of this case we'll note that it was empty. Later, when
// we're using the cached values, this will trigger alternate code paths.
bool viewportIsEmpty = viewport.IsEmpty();
if (viewportIsEmpty) {
// If the docType specifies that we are on a site optimized for mobile,
// then we want to return specially crafted defaults for the viewport
// info.
@ -6721,11 +6725,12 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
mValidMaxScale =
!maxScaleStr.IsEmpty() && NS_SUCCEEDED(scaleMaxErrorCode);
mViewportType = Specified;
mViewportType = viewportIsEmpty ? Empty : Specified;
mViewportOverflowType = ViewportOverflowType::NoOverflow;
MOZ_FALLTHROUGH;
}
case Specified:
case Empty:
default:
LayoutDeviceToScreenScale effectiveMinScale = mScaleMinFloat;
LayoutDeviceToScreenScale effectiveMaxScale = mScaleMaxFloat;
@ -6830,18 +6835,28 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
// https://drafts.csswg.org/css-device-adapt/#resolve-width
if (width == nsViewportInfo::Auto) {
if (height == nsViewportInfo::Auto || aDisplaySize.height == 0) {
// If we don't have any applicable viewport width constraints, this is
// most likely a desktop page written without mobile devices in mind.
// We use the desktop mode viewport for those pages by default,
// because a narrow viewport based on typical mobile device screen
// sizes (especially in portrait mode) will frequently break the
// layout of such pages. To keep text readable in that case, we rely
// on font inflation instead.
// What we do in this situation deviates somewhat from the spec. We
// want to consider the case where no viewport information has been
// provided, in which case we want to assume that the document is not
// optimized for aDisplaySize, and we should instead force a useful
// size.
if (mViewportType == Empty) {
// If we don't have any applicable viewport width constraints, this
// is most likely a desktop page written without mobile devices in
// mind. We use the desktop mode viewport for those pages by
// default, because a narrow viewport based on typical mobile device
// screen sizes (especially in portrait mode) will frequently break
// the layout of such pages. To keep text readable in that case, we
// rely on font inflation instead.
// Divide by fullZoom to stretch CSS pixel size of viewport in order
// to keep device pixel size unchanged after full zoom applied.
// See bug 974242.
width = gfxPrefs::DesktopViewportWidth() / fullZoom;
// Divide by fullZoom to stretch CSS pixel size of viewport in order
// to keep device pixel size unchanged after full zoom applied.
// See bug 974242.
width = gfxPrefs::DesktopViewportWidth() / fullZoom;
} else {
// Some viewport information was provided; follow the spec.
width = displaySize.width;
}
} else {
width = height * aDisplaySize.width / aDisplaySize.height;
}

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

@ -4480,7 +4480,7 @@ class Document : public nsINode,
// Our update nesting level
uint32_t mUpdateNestLevel;
enum ViewportType : uint8_t { DisplayWidthHeight, Specified, Unknown };
enum ViewportType : uint8_t { DisplayWidthHeight, Specified, Unknown, Empty };
ViewportType mViewportType;