Bug 784612 - Remove old XUL content autoScale hack from meta viewport code [r=mfinkle,jwir3]
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 22 Aug 2012 09:42:24 -0700
changeset 105073 0f34437ce5332e039d7ecb37ee9f8b754971e0f0
parent 105072 2a9b3c766512e7841b7393be8f425e7c78738997
child 105074 91cba558c70c3a08699ba5c4958239f2c77f6d33
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersmfinkle, jwir3
bugs784612
milestone17.0a1
Bug 784612 - Remove old XUL content autoScale hack from meta viewport code [r=mfinkle,jwir3]
content/base/public/nsContentUtils.h
content/base/src/nsContentUtils.cpp
mobile/android/chrome/content/browser.js
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -169,24 +169,16 @@ struct ViewportInfo
     // 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;
-
-    // This is a holdover from e10s fennec, and might be removed in the future.
-    // It's a hack to work around bugs that didn't allow zooming of documents
-    // from within the parent process. It is still used in native Fennec for XUL
-    // documents, but it should probably be removed.
-    // Currently, from, within GetViewportInfo(), This is only set to false
-    // if the document is a XUL document.
-    bool autoScale;
 };
 
 struct EventNameMapping
 {
   nsIAtom* mAtom;
   uint32_t mId;
   int32_t  mType;
   uint32_t mStructType;
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -5050,17 +5050,16 @@ static void ProcessViewportToken(nsIDocu
 /* static */
 ViewportInfo
 nsContentUtils::GetViewportInfo(nsIDocument *aDocument)
 {
   ViewportInfo ret;
   ret.defaultZoom = 1.0;
   ret.autoSize = true;
   ret.allowZoom = true;
-  ret.autoScale = true;
 
   // 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));
@@ -5072,21 +5071,16 @@ nsContentUtils::GetViewportInfo(nsIDocum
           (docId.Find("Mobile") != -1) ||
           (docId.Find("WML") != -1))
       {
         return ret;
       }
     }
   }
 
-  if (aDocument->IsXUL()) {
-    ret.autoScale = false;
-    return ret;
-  }
-
   nsAutoString handheldFriendly;
   aDocument->GetHeaderData(nsGkAtoms::handheldFriendly, handheldFriendly);
 
   if (handheldFriendly.EqualsLiteral("true")) {
     return ret;
   }
 
   nsAutoString minScaleStr;
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3074,26 +3074,26 @@ Tab.prototype = {
   },
 
   /** Update viewport when the metadata changes. */
   updateViewportMetadata: function updateViewportMetadata(aMetadata) {
     if (Services.prefs.getBoolPref("browser.ui.zoom.force-user-scalable")) {
       aMetadata.allowZoom = true;
       aMetadata.minZoom = aMetadata.maxZoom = NaN;
     }
-    if (aMetadata && aMetadata.autoScale) {
-      let scaleRatio = aMetadata.scaleRatio = ViewportHandler.getScaleRatio();
-
-      if ("defaultZoom" in aMetadata && aMetadata.defaultZoom > 0)
-        aMetadata.defaultZoom *= scaleRatio;
-      if ("minZoom" in aMetadata && aMetadata.minZoom > 0)
-        aMetadata.minZoom *= scaleRatio;
-      if ("maxZoom" in aMetadata && aMetadata.maxZoom > 0)
-        aMetadata.maxZoom *= scaleRatio;
-    }
+
+    let scaleRatio = aMetadata.scaleRatio = ViewportHandler.getScaleRatio();
+
+    if ("defaultZoom" in aMetadata && aMetadata.defaultZoom > 0)
+      aMetadata.defaultZoom *= scaleRatio;
+    if ("minZoom" in aMetadata && aMetadata.minZoom > 0)
+      aMetadata.minZoom *= scaleRatio;
+    if ("maxZoom" in aMetadata && aMetadata.maxZoom > 0)
+      aMetadata.maxZoom *= scaleRatio;
+
     ViewportHandler.setMetadataForDocument(this.browser.contentDocument, aMetadata);
     this.updateViewportSize(gScreenWidth);
     this.sendViewportMetadata();
   },
 
   /** Update viewport when the metadata or the window size changes. */
   updateViewportSize: function updateViewportSize(aOldScreenWidth) {
     // When this function gets called on window resize, we must execute
@@ -4542,22 +4542,18 @@ var ViewportHandler = {
    * Returns an object with the page's preferred viewport properties:
    *   defaultZoom (optional float): The initial scale when the page is loaded.
    *   minZoom (optional float): The minimum zoom level.
    *   maxZoom (optional float): The maximum zoom level.
    *   width (optional int): The CSS viewport width in px.
    *   height (optional int): The CSS viewport height in px.
    *   autoSize (boolean): Resize the CSS viewport when the window resizes.
    *   allowZoom (boolean): Let the user zoom in or out.
-   *   autoScale (boolean): Adjust the viewport properties to account for display density.
    */
   getViewportMetadata: function getViewportMetadata(aWindow) {
-    if (aWindow.document instanceof XULDocument)
-      return { defaultZoom: 1, autoSize: true, allowZoom: false, autoScale: false };
-
     let windowUtils = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
 
     // viewport details found here
     // http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html
     // http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html
 
     // Note: These values will be NaN if parseFloat or parseInt doesn't find a number.
     // Remember that NaN is contagious: Math.max(1, NaN) == Math.min(1, NaN) == NaN.
@@ -4572,21 +4568,21 @@ var ViewportHandler = {
 
     let allowZoomStr = windowUtils.getDocumentMetadata("viewport-user-scalable");
     let allowZoom = !/^(0|no|false)$/.test(allowZoomStr); // WebKit allows 0, "no", or "false"
 
     if (isNaN(scale) && isNaN(minScale) && isNaN(maxScale) && allowZoomStr == "" && widthStr == "" && heightStr == "") {
       // Only check for HandheldFriendly if we don't have a viewport meta tag
       let handheldFriendly = windowUtils.getDocumentMetadata("HandheldFriendly");
       if (handheldFriendly == "true")
-        return { defaultZoom: 1, autoSize: true, allowZoom: true, autoScale: true };
+        return { defaultZoom: 1, autoSize: true, allowZoom: true };
 
       let doctype = aWindow.document.doctype;
       if (doctype && /(WAP|WML|Mobile)/.test(doctype.publicId))
-        return { defaultZoom: 1, autoSize: true, allowZoom: true, autoScale: true };
+        return { defaultZoom: 1, autoSize: true, allowZoom: true };
     }
 
     scale = this.clamp(scale, kViewportMinScale, kViewportMaxScale);
     minScale = this.clamp(minScale, kViewportMinScale, kViewportMaxScale);
     maxScale = this.clamp(maxScale, minScale, kViewportMaxScale);
 
     // If initial scale is 1.0 and width is not set, assume width=device-width
     let autoSize = (widthStr == "device-width" ||
@@ -4594,18 +4590,17 @@ var ViewportHandler = {
 
     return {
       defaultZoom: scale,
       minZoom: minScale,
       maxZoom: maxScale,
       width: width,
       height: height,
       autoSize: autoSize,
-      allowZoom: allowZoom,
-      autoScale: true
+      allowZoom: allowZoom
     };
   },
 
   clamp: function(num, min, max) {
     return Math.max(min, Math.min(max, num));
   },
 
   // The device-pixel-to-CSS-px ratio used to adjust meta viewport values.
@@ -4648,17 +4643,16 @@ var ViewportHandler = {
       this._metadata.set(aDocument, aMetadata);
   },
 
   /** Returns the default viewport metadata for a document. */
   getDefaultMetadata: function getDefaultMetadata() {
     return {
       autoSize: false,
       allowZoom: true,
-      autoScale: true,
       scaleRatio: ViewportHandler.getScaleRatio()
     };
   }
 };
 
 /**
  * Handler for blocked popups, triggered by DOMUpdatePageReport events in browser.xml
  */