Bug 556618 - portrait mode - viewport device-width pages do not resize when changing orientation [r=blassey]
authorMark Finkle <mfinkle@mozilla.com>
Fri, 02 Apr 2010 20:00:15 -0400
changeset 49666 5f5e42b7c60a3d0be875e6b56c6267c32fbb68d5
parent 49665 7bc8a4206e9801dcc013a740fa6f42ab7dcc0a8d
child 49667 0df295450c44ddfe26285d3027ef138cc41ca54e
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs556618
Bug 556618 - portrait mode - viewport device-width pages do not resize when changing orientation [r=blassey]
toolkit/content/Geometry.jsm
--- a/toolkit/content/Geometry.jsm
+++ b/toolkit/content/Geometry.jsm
@@ -120,29 +120,39 @@ let Util = {
 
     let windowUtils = browser.contentWindow
                              .QueryInterface(Ci.nsIInterfaceRequestor)
                              .getInterface(Ci.nsIDOMWindowUtils);
     let handheldFriendly = windowUtils.getDocumentMetadata("HandheldFriendly");
     if (handheldFriendly == "true")
       return {reason: "handheld", result: true};
 
+    // 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
+    
     let viewportScale = parseFloat(windowUtils.getDocumentMetadata("viewport-initial-scale"));
     let viewportWidthStr = windowUtils.getDocumentMetadata("viewport-width");
     let viewportHeightStr = windowUtils.getDocumentMetadata("viewport-height");
+
+    // If initial scale is 1.0 and width is not set, assume width=device-width
+    if (viewportScale == 1.0 && !viewportWidthStr)
+      viewportWidthStr = "device-width";
+
     let viewportWidth = viewportWidthStr == "device-width" ? window.innerWidth : parseInt(viewportWidthStr);
     let viewportHeight = viewportHeightStr == "device-height" ? window.innerHeight : parseInt(viewportHeightStr);
-    
+
     if (viewportScale > 0 || viewportWidth > 0 || viewportHeight > 0) {
       return {
         reason: "viewport",
         result: true,
         scale: viewportScale,
         width: viewportWidth,
-        height: viewportHeight
+        height: viewportHeight,
+        autoSize: viewportWidthStr == "device-width" || viewportHeightStr == "device-height"
       }
     }
 
     return {reason: "", result: false};
   },
 
   /**
    * Determines whether a home page override is needed.