Bug 527384: implement device-width and device-height keywords for viewport meta tag [r=mark.finkle]
authorBrad Lassey <blassey@mozilla.com>
Mon, 23 Nov 2009 14:24:05 -0500
changeset 49655 53f9c3a3c3224c5d488ddb49aeed3eee8f94486d
parent 49654 7f8445b8c9dc98412ecba33ce425cfed8bf11655
child 49656 1986de65b52dd933f7dce3102d8cb7409a7388d0
push id15027
push useredward.lee@engineering.uiuc.edu
push dateThu, 12 Aug 2010 09:51:47 +0000
treeherderautoland@cdfff833edf9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmark.finkle
bugs527384
Bug 527384: implement device-width and device-height keywords for viewport meta tag [r=mark.finkle]
toolkit/content/Geometry.jsm
--- a/toolkit/content/Geometry.jsm
+++ b/toolkit/content/Geometry.jsm
@@ -117,23 +117,28 @@ 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};
 
     let viewportScale = parseFloat(windowUtils.getDocumentMetadata("viewport-initial-scale"));
-    if (viewportScale > 0) {
+    let viewportWidthStr = windowUtils.getDocumentMetadata("viewport-width");
+    let viewportHeightStr = windowUtils.getDocumentMetadata("viewport-height");
+    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: parseInt(windowUtils.getDocumentMetadata("viewport-width")),
-        height: parseInt(windowUtils.getDocumentMetadata("viewport-height"))
+        width: viewportWidth,
+        height: viewportHeight
       }
     }
 
     return {reason: "", result: false};
   },
 
   /**
    * Determines whether a home page override is needed.