--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1439,19 +1439,16 @@ nsIDocument::nsIDocument()
mDOMCompleteSet(false),
mAutoFocusFired(false),
mScrolledToRefAlready(false),
mChangeScrollPosWhenScrollingToRef(false),
mHasWarnedAboutBoxObjects(false),
mDelayFrameLoaderInitialization(false),
mSynchronousDOMContentLoaded(false),
mMaybeServiceWorkerControlled(false),
- mValidWidth(false),
- mValidHeight(false),
- mAutoSize(false),
mAllowZoom(false),
mValidScaleFloat(false),
mValidMaxScale(false),
mScaleStrEmpty(false),
mWidthStrEmpty(false),
mParserAborted(false),
mReportedUseCounters(false),
mHasReportedShadowDOMUsage(false),
@@ -7432,38 +7429,16 @@ nsIDocument::GetViewportInfo(const Scree
GetHeaderData(nsGkAtoms::viewport_height, heightStr);
GetHeaderData(nsGkAtoms::viewport_width, widthStr);
// Parse width and height properties
// This function sets m{Min,Max}{Width,Height}.
ParseWidthAndHeightInMetaViewport(widthStr, heightStr, scaleStr);
- mAutoSize = false;
- if (mMaxWidth == nsViewportInfo::DeviceSize) {
- mAutoSize = true;
- }
- if (widthStr.IsEmpty() &&
- (mMaxHeight == nsViewportInfo::DeviceSize ||
- (mScaleFloat.scale == 1.0)))
- {
- mAutoSize = true;
- }
-
- // If width or height has not been set to a valid number by this point,
- // fall back to a default value.
- mValidWidth = (!widthStr.IsEmpty() && mMaxWidth > 0);
- mValidHeight = (!heightStr.IsEmpty() && mMaxHeight > 0);
-
- // If the width is set to some unrecognized value, and there is no
- // height set, treat it as if device-width were specified.
- if ((!mValidWidth && !widthStr.IsEmpty()) && !mValidHeight) {
- mAutoSize = true;
- }
-
mAllowZoom = true;
nsAutoString userScalable;
GetHeaderData(nsGkAtoms::viewport_user_scalable, userScalable);
if ((userScalable.EqualsLiteral("0")) ||
(userScalable.EqualsLiteral("no")) ||
(userScalable.EqualsLiteral("false"))) {
mAllowZoom = false;
@@ -7603,17 +7578,26 @@ nsIDocument::GetViewportInfo(const Scree
MOZ_ASSERT(width != nsViewportInfo::Auto && height != nsViewportInfo::Auto);
CSSSize size(width, height);
CSSToScreenScale scaleFloat = mScaleFloat * layoutDeviceScale;
CSSToScreenScale scaleMinFloat = effectiveMinScale * layoutDeviceScale;
CSSToScreenScale scaleMaxFloat = effectiveMaxScale * layoutDeviceScale;
- if (mAutoSize) {
+ const bool autoSize =
+ mMaxWidth == nsViewportInfo::DeviceSize ||
+ (mWidthStrEmpty &&
+ (mMaxHeight == nsViewportInfo::DeviceSize ||
+ mScaleFloat.scale == 1.0f)) ||
+ (!mWidthStrEmpty && mMaxWidth == nsViewportInfo::Auto && mMaxHeight < 0);
+
+ // FIXME: Resolving width and height should be done above 'Resolve width
+ // value' and 'Resolve height value'.
+ if (autoSize) {
size = displaySize;
}
size.width = clamped(size.width, float(kViewportMinSize.width), float(kViewportMaxSize.width));
// Also recalculate the default zoom, if it wasn't specified in the metadata,
// and the width is specified.
if (mScaleStrEmpty && !mWidthStrEmpty) {
@@ -7631,17 +7615,17 @@ nsIDocument::GetViewportInfo(const Scree
size.height = std::max(size.height, displaySize.height);
} else if (effectiveValidMaxScale) {
CSSSize displaySize = ScreenSize(aDisplaySize) / scaleMaxFloat;
size.width = std::max(size.width, displaySize.width);
size.height = std::max(size.height, displaySize.height);
}
return nsViewportInfo(scaleFloat, scaleMinFloat, scaleMaxFloat, size,
- mAutoSize, effectiveAllowZoom);
+ autoSize, effectiveAllowZoom);
}
}
void
nsIDocument::UpdateViewportOverflowType(nscoord aScrolledWidth,
nscoord aScrollportWidth)
{
#ifdef DEBUG