Bug 821801: Make nsContentUtils::ViewportInfo into a separate class in order to allow better state tracking. [r=kats]
authorScott Johnson <sjohnson@mozilla.com>
Mon, 17 Dec 2012 15:24:41 -0600
changeset 116318 e75c8b88e65ef138fea48b66520e7e1c40fe8f9a
parent 116317 f5aaf21d0a2b3c9ec6366413d71bf2240be6e96d
child 116319 34d54961cd14b7d75410653493f6e30b5c8cbed5
push id19850
push usersjohnson@mozilla.com
push dateMon, 17 Dec 2012 21:24:56 +0000
treeherdermozilla-inbound@e75c8b88e65e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs821801
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 821801: Make nsContentUtils::ViewportInfo into a separate class in order to allow better state tracking. [r=kats]
content/base/public/Makefile.in
content/base/public/nsContentUtils.h
content/base/public/nsViewportInfo.h
content/base/src/Makefile.in
content/base/src/nsContentUtils.cpp
content/base/src/nsViewportInfo.cpp
dom/base/nsDOMWindowUtils.cpp
dom/ipc/TabChild.cpp
layout/base/nsLayoutUtils.cpp
--- a/content/base/public/Makefile.in
+++ b/content/base/public/Makefile.in
@@ -35,16 +35,17 @@ nsIXPathEvaluatorInternal.h \
 nsCaseTreatment.h \
 nsContentCID.h \
 nsCopySupport.h \
 nsContentCreatorFunctions.h \
 nsDOMFile.h \
 nsLineBreaker.h \
 nsReferencedElement.h \
 nsTreeSanitizer.h \
+nsViewportInfo.h \
 nsXMLNameSpaceMap.h \
 nsHostObjectProtocolHandler.h \
 $(NULL)
 
 EXPORTS_NAMESPACES = mozilla/dom mozilla
 
 EXPORTS_mozilla/dom = \
 		DirectionalityUtils.h \
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -96,16 +96,18 @@ class nsIObserver;
 class nsPresContext;
 class nsIChannel;
 class nsAutoScriptBlockerSuppressNodeRemoved;
 struct nsIntMargin;
 class nsPIDOMWindow;
 class nsIDocumentLoaderFactory;
 class nsIDOMHTMLInputElement;
 
+class nsViewportInfo;
+
 namespace mozilla {
 
 class Selection;
 
 namespace layers {
   class LayerManager;
 } // namespace layers
 
@@ -125,50 +127,16 @@ enum EventNameType {
   EventNameType_SVGSVG = 0x0008, // the svg element
   EventNameType_SMIL = 0x0010, // smil elements
   EventNameType_HTMLBodyOrFramesetOnly = 0x0020,
 
   EventNameType_HTMLXUL = 0x0003,
   EventNameType_All = 0xFFFF
 };
 
-/**
- * Information retrieved from the <meta name="viewport"> tag. See
- * GetViewportInfo for more information on this functionality.
- */
-struct ViewportInfo
-{
-    // Default zoom indicates the level at which the display is 'zoomed in'
-    // initially for the user, upon loading of the page.
-    double defaultZoom;
-
-    // The minimum zoom level permitted by the page.
-    double minZoom;
-
-    // The maximum zoom level permitted by the page.
-    double maxZoom;
-
-    // The width of the viewport, specified by the <meta name="viewport"> tag,
-    // in CSS pixels.
-    uint32_t width;
-
-    // The height of the viewport, specified by the <meta name="viewport"> tag,
-    // in CSS pixels.
-    uint32_t height;
-
-    // Whether or not we should automatically size the viewport to the device's
-    // width. This is true if the document has been optimized for mobile, and
-    // the width property of a specified <meta name="viewport"> tag is either
-    // not specified, or is set to the special value 'device-width'.
-    bool autoSize;
-
-    // Whether or not the user can zoom in and out on the page. Default is true.
-    bool allowZoom;
-};
-
 struct EventNameMapping
 {
   nsIAtom* mAtom;
   uint32_t mId;
   int32_t  mType;
   uint32_t mStructType;
 };
 
@@ -1544,26 +1512,19 @@ public:
    * @param aDisplayWidth width of the on-screen display area for this
    * document, in device pixels.
    * @param aDisplayHeight height of the on-screen display area for this
    * document, in device pixels.
    *
    * NOTE: If the site is optimized for mobile (via the doctype), this
    * will return viewport information that specifies default information.
    */
-  static ViewportInfo GetViewportInfo(nsIDocument* aDocument,
-                                      uint32_t aDisplayWidth,
-                                      uint32_t aDisplayHeight);
-
-  /**
-   * Constrain the viewport calculations from the GetViewportInfo() function
-   * in order to always return sane minimum/maximum values. This modifies the
-   * ViewportInfo struct passed as an input parameter, in place.
-   */
-  static void ConstrainViewportValues(ViewportInfo& aViewInfo);
+  static nsViewportInfo GetViewportInfo(nsIDocument* aDocument,
+                                        uint32_t aDisplayWidth,
+                                        uint32_t aDisplayHeight);
 
   /**
    * The device-pixel-to-CSS-px ratio used to adjust meta viewport values.
    */
   static double GetDevicePixelsPerMetaViewportPixel(nsIWidget* aWidget);
 
   // Call EnterMicroTask when you're entering JS execution.
   // Usually the best way to do this is to use nsAutoMicroTask.
new file mode 100644
--- /dev/null
+++ b/content/base/public/nsViewportInfo.h
@@ -0,0 +1,107 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef nsViewportInfo_h___
+#define nsViewportInfo_h___
+
+#include "nsContentUtils.h"
+
+/**
+ * Default values for the nsViewportInfo class.
+ */
+static const double   kViewportMinScale = 0.0;
+static const double   kViewportMaxScale = 10.0;
+static const uint32_t kViewportMinWidth = 200;
+static const uint32_t kViewportMaxWidth = 10000;
+static const uint32_t kViewportMinHeight = 223;
+static const uint32_t kViewportMaxHeight = 10000;
+static const int32_t  kViewportDefaultScreenWidth = 980;
+
+/**
+ * Information retrieved from the <meta name="viewport"> tag. See
+ * nsContentUtils::GetViewportInfo for more information on this functionality.
+ */
+class NS_STACK_CLASS nsViewportInfo
+{
+  public:
+    nsViewportInfo(uint32_t aDisplayWidth, uint32_t aDisplayHeight) :
+      mDefaultZoom(1.0),
+      mMinZoom(kViewportMinScale),
+      mMaxZoom(kViewportMaxScale),
+      mWidth(aDisplayWidth),
+      mHeight(aDisplayHeight),
+      mAutoSize(true),
+      mAllowZoom(true)
+    {
+        ConstrainViewportValues();
+    }
+
+    nsViewportInfo(double aDefaultZoom,
+                   double aMinZoom,
+                   double aMaxZoom,
+                   uint32_t aWidth,
+                   uint32_t aHeight,
+                   bool aAutoSize,
+                   bool aAllowZoom) :
+                     mDefaultZoom(aDefaultZoom),
+                     mMinZoom(aMinZoom),
+                     mMaxZoom(aMaxZoom),
+                     mWidth(aWidth),
+                     mHeight(aHeight),
+                     mAutoSize(aAutoSize),
+                     mAllowZoom(aAllowZoom)
+    {
+      ConstrainViewportValues();
+    }
+
+    double GetDefaultZoom() { return mDefaultZoom; }
+    void SetDefaultZoom(const double aDefaultZoom);
+    double GetMinZoom() { return mMinZoom; }
+    double GetMaxZoom() { return mMaxZoom; }
+
+    uint32_t GetWidth() { return mWidth; }
+    uint32_t GetHeight() { return mHeight; }
+
+    bool IsAutoSizeEnabled() { return mAutoSize; }
+    bool IsZoomAllowed() { return mAllowZoom; }
+
+  private:
+
+    /**
+     * Constrain the viewport calculations from the
+     * nsContentUtils::GetViewportInfo() function in order to always return
+     * sane minimum/maximum values.
+     */
+    void ConstrainViewportValues();
+
+    // Default zoom indicates the level at which the display is 'zoomed in'
+    // initially for the user, upon loading of the page.
+    double mDefaultZoom;
+
+    // The minimum zoom level permitted by the page.
+    double mMinZoom;
+
+    // The maximum zoom level permitted by the page.
+    double mMaxZoom;
+
+    // The width of the viewport, specified by the <meta name="viewport"> tag,
+    // in CSS pixels.
+    uint32_t mWidth;
+
+    // The height of the viewport, specified by the <meta name="viewport"> tag,
+    // in CSS pixels.
+    uint32_t mHeight;
+
+    // Whether or not we should automatically size the viewport to the device's
+    // width. This is true if the document has been optimized for mobile, and
+    // the width property of a specified <meta name="viewport"> tag is either
+    // not specified, or is set to the special value 'device-width'.
+    bool mAutoSize;
+
+    // Whether or not the user can zoom in and out on the page. Default is true.
+    bool mAllowZoom;
+};
+
+#endif
+
--- a/content/base/src/Makefile.in
+++ b/content/base/src/Makefile.in
@@ -115,16 +115,17 @@ CPPSRCS		= \
 		nsStyledElement.cpp \
 		nsStyleLinkElement.cpp \
 		nsSyncLoadService.cpp \
 		nsTextFragment.cpp \
 		nsTextNode.cpp \
 		nsTraversal.cpp \
 		nsTreeSanitizer.cpp \
 		nsTreeWalker.cpp \
+                nsViewportInfo.cpp \
 		WebSocket.cpp \
 		nsXHTMLContentSerializer.cpp \
 		nsXMLContentSerializer.cpp \
 		nsXMLHttpRequest.cpp \
 		nsXMLNameSpaceMap.cpp \
 		FragmentOrElement.cpp \
 		Link.cpp \
 		nsHostObjectProtocolHandler.cpp \
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -164,16 +164,17 @@
 #include "nsIParserService.h"
 #include "nsIDOMScriptObjectFactory.h"
 #include "nsSandboxFlags.h"
 #include "nsSVGFeatures.h"
 #include "MediaDecoder.h"
 #include "DecoderTraits.h"
 
 #include "nsWrapperCacheInlines.h"
+#include "nsViewportInfo.h"
 
 extern "C" int MOZ_XMLTranslateEntity(const char* ptr, const char* end,
                                       const char** next, PRUnichar* result);
 extern "C" int MOZ_XMLCheckQName(const char* ptr, const char* end,
                                  int ns_aware, const char** colon);
 
 class imgLoader;
 
@@ -236,27 +237,16 @@ uint32_t nsContentUtils::sHandlingInputT
 
 nsHtml5StringParser* nsContentUtils::sHTMLFragmentParser = nullptr;
 nsIParser* nsContentUtils::sXMLFragmentParser = nullptr;
 nsIFragmentContentSink* nsContentUtils::sXMLFragmentSink = nullptr;
 bool nsContentUtils::sFragmentParsingActive = false;
 
 namespace {
 
-/**
- * Default values for the ViewportInfo structure.
- */
-static const double   kViewportMinScale = 0.0;
-static const double   kViewportMaxScale = 10.0;
-static const uint32_t kViewportMinWidth = 200;
-static const uint32_t kViewportMaxWidth = 10000;
-static const uint32_t kViewportMinHeight = 223;
-static const uint32_t kViewportMaxHeight = 10000;
-static const int32_t  kViewportDefaultScreenWidth = 980;
-
 static const char kJSStackContractID[] = "@mozilla.org/js/xpc/ContextStack;1";
 static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
 static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
 
 static PLDHashTable sEventListenerManagersHash;
 
 class EventListenerManagerMapEntry : public PLDHashEntryHdr
 {
@@ -5033,68 +5023,47 @@ static void ProcessViewportToken(nsIDocu
   else if (key_atom == nsGkAtoms::user_scalable)
     aDocument->SetHeaderData(nsGkAtoms::viewport_user_scalable, value);
 }
 
 #define IS_SEPARATOR(c) ((c == '=') || (c == ',') || (c == ';') || \
                          (c == '\t') || (c == '\n') || (c == '\r'))
 
 /* static */
-void
-nsContentUtils::ConstrainViewportValues(ViewportInfo& aViewInfo)
-{
-  // Constrain the min/max zoom as specified at:
-  // dev.w3.org/csswg/css-device-adapt section 6.2
-  aViewInfo.maxZoom = NS_MAX(aViewInfo.minZoom, aViewInfo.maxZoom);
-
-  aViewInfo.defaultZoom = NS_MIN(aViewInfo.defaultZoom, aViewInfo.maxZoom);
-  aViewInfo.defaultZoom = NS_MAX(aViewInfo.defaultZoom, aViewInfo.minZoom);
-}
-
-/* static */
-ViewportInfo
+nsViewportInfo
 nsContentUtils::GetViewportInfo(nsIDocument *aDocument,
                                 uint32_t aDisplayWidth,
                                 uint32_t aDisplayHeight)
 {
-  ViewportInfo ret;
-  ret.defaultZoom = 1.0;
-  ret.autoSize = true;
-  ret.allowZoom = true;
-  ret.width = aDisplayWidth;
-  ret.height = aDisplayHeight;
-  ret.minZoom = kViewportMinScale;
-  ret.maxZoom = kViewportMaxScale;
-
   nsAutoString viewport;
   aDocument->GetHeaderData(nsGkAtoms::viewport, viewport);
   if (viewport.IsEmpty()) {
     // 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.
     nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aDocument));
     nsCOMPtr<nsIDOMDocumentType> docType;
     nsresult rv = domDoc->GetDoctype(getter_AddRefs(docType));
     if (NS_SUCCEEDED(rv) && docType) {
       nsAutoString docId;
       rv = docType->GetPublicId(docId);
       if (NS_SUCCEEDED(rv)) {
         if ((docId.Find("WAP") != -1) ||
             (docId.Find("Mobile") != -1) ||
             (docId.Find("WML") != -1))
         {
-          nsContentUtils::ConstrainViewportValues(ret);
+          nsViewportInfo ret(aDisplayWidth, aDisplayHeight);
           return ret;
         }
       }
     }
 
     nsAutoString handheldFriendly;
     aDocument->GetHeaderData(nsGkAtoms::handheldFriendly, handheldFriendly);
     if (handheldFriendly.EqualsLiteral("true")) {
-      nsContentUtils::ConstrainViewportValues(ret);
+      nsViewportInfo ret(aDisplayWidth, aDisplayHeight);
       return ret;
     }
   }
 
   nsAutoString minScaleStr;
   aDocument->GetHeaderData(nsGkAtoms::viewport_minimum_scale, minScaleStr);
 
   nsresult errorCode;
@@ -5214,25 +5183,18 @@ nsContentUtils::GetViewportInfo(nsIDocum
   aDocument->GetHeaderData(nsGkAtoms::viewport_user_scalable, userScalable);
 
   if ((userScalable.EqualsLiteral("0")) ||
       (userScalable.EqualsLiteral("no")) ||
       (userScalable.EqualsLiteral("false"))) {
     allowZoom = false;
   }
 
-  ret.allowZoom = allowZoom;
-  ret.width = width;
-  ret.height = height;
-  ret.defaultZoom = scaleFloat;
-  ret.minZoom = scaleMinFloat;
-  ret.maxZoom = scaleMaxFloat;
-  ret.autoSize = autoSize;
-
-  nsContentUtils::ConstrainViewportValues(ret);
+  nsViewportInfo ret(scaleFloat, scaleMinFloat, scaleMaxFloat, width, height,
+                     autoSize, allowZoom);
   return ret;
 }
 
 /* static */
 double
 nsContentUtils::GetDevicePixelsPerMetaViewportPixel(nsIWidget* aWidget)
 {
   int32_t prefValue = Preferences::GetInt("browser.viewport.scaleRatio", 0);
new file mode 100644
--- /dev/null
+++ b/content/base/src/nsViewportInfo.cpp
@@ -0,0 +1,23 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsViewportInfo.h"
+
+void
+nsViewportInfo::SetDefaultZoom(const double aDefaultZoom)
+{
+  MOZ_ASSERT(aDefaultZoom >= 0.0f);
+  mDefaultZoom = aDefaultZoom;
+}
+
+void
+nsViewportInfo::ConstrainViewportValues()
+{
+  // Constrain the min/max zoom as specified at:
+  // dev.w3.org/csswg/css-device-adapt section 6.2
+  mMaxZoom = NS_MAX(mMinZoom, mMaxZoom);
+
+  mDefaultZoom = NS_MIN(mDefaultZoom, mMaxZoom);
+  mDefaultZoom = NS_MAX(mDefaultZoom, mMinZoom);
+}
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -61,16 +61,17 @@
 
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/indexedDB/FileInfo.h"
 #include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
 #include "sampler.h"
 #include "nsDOMBlobBuilder.h"
 #include "nsIDOMFileHandle.h"
 #include "nsPrintfCString.h"
+#include "nsViewportInfo.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::layers;
 using namespace mozilla::widget;
 
 DOMCI_DATA(WindowUtils, nsDOMWindowUtils)
 
@@ -261,24 +262,24 @@ nsDOMWindowUtils::GetViewportInfo(uint32
                                   bool *aAutoSize)
 {
   nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
   NS_ENSURE_STATE(window);
 
   nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
   NS_ENSURE_STATE(doc);
 
-  ViewportInfo info = nsContentUtils::GetViewportInfo(doc, aDisplayWidth, aDisplayHeight);
-  *aDefaultZoom = info.defaultZoom;
-  *aAllowZoom = info.allowZoom;
-  *aMinZoom = info.minZoom;
-  *aMaxZoom = info.maxZoom;
-  *aWidth = info.width;
-  *aHeight = info.height;
-  *aAutoSize = info.autoSize;
+  nsViewportInfo info = nsContentUtils::GetViewportInfo(doc, aDisplayWidth, aDisplayHeight);
+  *aDefaultZoom = info.GetDefaultZoom();
+  *aAllowZoom = info.IsZoomAllowed();
+  *aMinZoom = info.GetMinZoom();
+  *aMaxZoom = info.GetMaxZoom();
+  *aWidth = info.GetWidth();
+  *aHeight = info.GetHeight();
+  *aAutoSize = info.IsAutoSizeEnabled();
   return NS_OK;
 }
 
 static void DestroyNsRect(void* aObject, nsIAtom* aPropertyName,
                           void* aPropertyValue, void* aData)
 {
   nsRect* rect = static_cast<nsRect*>(aPropertyValue);
   delete rect;
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -70,16 +70,17 @@
 #include "nsScriptLoader.h"
 #include "nsSerializationHelper.h"
 #include "nsThreadUtils.h"
 #include "nsWeakReference.h"
 #include "PCOMContentPermissionRequestChild.h"
 #include "PuppetWidget.h"
 #include "StructuredCloneUtils.h"
 #include "xpcpublic.h"
+#include "nsViewportInfo.h"
 
 #define BROWSER_ELEMENT_CHILD_SCRIPT \
     NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js")
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::dom::ipc;
 using namespace mozilla::ipc;
@@ -369,41 +370,41 @@ TabChild::HandlePossibleViewportChange()
   }
 
   nsCOMPtr<nsIDOMDocument> domDoc;
   mWebNav->GetDocument(getter_AddRefs(domDoc));
   nsCOMPtr<nsIDocument> document(do_QueryInterface(domDoc));
 
   nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
 
-  ViewportInfo viewportInfo =
+  nsViewportInfo viewportInfo =
     nsContentUtils::GetViewportInfo(document, mInnerSize.width, mInnerSize.height);
-  SendUpdateZoomConstraints(viewportInfo.allowZoom,
-                            viewportInfo.minZoom,
-                            viewportInfo.maxZoom);
+  SendUpdateZoomConstraints(viewportInfo.IsZoomAllowed(),
+                            viewportInfo.GetMinZoom(),
+                            viewportInfo.GetMaxZoom());
 
   float screenW = mInnerSize.width;
   float screenH = mInnerSize.height;
-  float viewportW = viewportInfo.width;
-  float viewportH = viewportInfo.height;
+  float viewportW = viewportInfo.GetWidth();
+  float viewportH = viewportInfo.GetHeight();
 
   // We're not being displayed in any way; don't bother doing anything because
   // that will just confuse future adjustments.
   if (!screenW || !screenH) {
     return;
   }
 
   // Make sure the viewport height is not shorter than the window when the page
   // is zoomed out to show its full width. Note that before we set the viewport
   // width, the "full width" of the page isn't properly defined, so that's why
   // we have to call SetCSSViewport twice - once to set the width, and the
   // second time to figure out the height based on the layout at that width.
   float oldBrowserWidth = mOldViewportWidth;
-  mLastMetrics.mViewport.width = viewportInfo.width;
-  mLastMetrics.mViewport.height = viewportInfo.height;
+  mLastMetrics.mViewport.width = viewportW;
+  mLastMetrics.mViewport.height = viewportH;
   if (!oldBrowserWidth) {
     oldBrowserWidth = kDefaultViewportSize.width;
   }
   SetCSSViewport(viewportW, viewportH);
 
   // If this page has not been painted yet, then this must be getting run
   // because a meta-viewport element was added (via the DOMMetaAdded handler).
   // in this case, we should not do anything that forces a reflow (see bug
@@ -440,17 +441,18 @@ TabChild::HandlePossibleViewportChange()
   } else {
     // For non-HTML content (e.g. SVG), just assume page size == viewport size.
     pageWidth = viewportW;
     pageHeight = viewportH;
   }
   NS_ENSURE_TRUE_VOID(pageWidth); // (return early rather than divide by 0)
 
   minScale = mInnerSize.width / pageWidth;
-  minScale = clamped((double)minScale, viewportInfo.minZoom, viewportInfo.maxZoom);
+  minScale = clamped((double)minScale, viewportInfo.GetMinZoom(),
+                     viewportInfo.GetMaxZoom());
   NS_ENSURE_TRUE_VOID(minScale); // (return early rather than divide by 0)
 
   viewportH = NS_MAX(viewportH, screenH / minScale);
   SetCSSViewport(viewportW, viewportH);
 
   // This change to the zoom accounts for all types of changes I can conceive:
   // 1. screen size changes, CSS viewport does not (pages with no meta viewport
   //    or a fixed size viewport)
@@ -479,25 +481,27 @@ TabChild::HandlePossibleViewportChange()
   nsresult rv = utils->GetIsFirstPaint(&isFirstPaint);
   MOZ_ASSERT(NS_SUCCEEDED(rv));
   if (NS_FAILED(rv) || isFirstPaint) {
     gfxSize intrinsicScale =
         AsyncPanZoomController::CalculateIntrinsicScale(metrics);
     // FIXME/bug 799585(?): GetViewportInfo() returns a defaultZoom of
     // 0.0 to mean "did not calculate a zoom".  In that case, we default
     // it to the intrinsic scale.
-    if (viewportInfo.defaultZoom < 0.01f) {
-      viewportInfo.defaultZoom = intrinsicScale.width;
+    if (viewportInfo.GetDefaultZoom() < 0.01f) {
+      viewportInfo.SetDefaultZoom(intrinsicScale.width);
     }
-    MOZ_ASSERT(viewportInfo.minZoom <= viewportInfo.defaultZoom &&
-               viewportInfo.defaultZoom <= viewportInfo.maxZoom);
+
+    double defaultZoom = viewportInfo.GetDefaultZoom();
+    MOZ_ASSERT(viewportInfo.GetMinZoom() <= defaultZoom &&
+               defaultZoom <= viewportInfo.GetMaxZoom());
     // GetViewportInfo() returns a resolution-dependent scale factor.
     // Convert that to a resolution-indepedent zoom.
-    metrics.mZoom = gfxSize(viewportInfo.defaultZoom / intrinsicScale.width,
-                            viewportInfo.defaultZoom / intrinsicScale.height);
+    metrics.mZoom = gfxSize(defaultZoom / intrinsicScale.width,
+                            defaultZoom / intrinsicScale.height);
   }
 
   metrics.mDisplayPort = AsyncPanZoomController::CalculatePendingDisplayPort(
     // The page must have been refreshed in some way such as a new document or
     // new CSS viewport, so we know that there's no velocity, acceleration, and
     // we have no idea how long painting will take.
     metrics, gfx::Point(0.0f, 0.0f), gfx::Point(0.0f, 0.0f), 0.0);
   gfxSize resolution = AsyncPanZoomController::CalculateResolution(metrics);
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -84,16 +84,17 @@
 
 #ifdef MOZ_XUL
 #include "nsXULPopupManager.h"
 #endif
 
 #include "sampler.h"
 #include "nsAnimationManager.h"
 #include "nsTransitionManager.h"
+#include "nsViewportInfo.h"
 
 using namespace mozilla;
 using namespace mozilla::css;
 using namespace mozilla::dom;
 using namespace mozilla::layers;
 using namespace mozilla::layout;
 
 #define FLEXBOX_ENABLED_PREF_NAME "layout.css.flexbox.enabled"
@@ -5208,21 +5209,21 @@ nsLayoutUtils::FontSizeInflationEnabled(
   NS_ENSURE_SUCCESS(rv, false);
 
   nsCOMPtr<nsIScreen> screen;
   screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
   if (screen) {
     int32_t screenLeft, screenTop, screenWidth, screenHeight;
     screen->GetRect(&screenLeft, &screenTop, &screenWidth, &screenHeight);
 
-    ViewportInfo vInf =
+    nsViewportInfo vInf =
       nsContentUtils::GetViewportInfo(aPresContext->PresShell()->GetDocument(),
                                       screenWidth, screenHeight);
 
-    if (vInf.defaultZoom >= 1.0 || vInf.autoSize) {
+  if (vInf.GetDefaultZoom() >= 1.0 || vInf.IsAutoSizeEnabled()) {
       return false;
     }
   }
 
   return true;
 }
 
 /* static */ nsRect