bug 524900 - treat mobile doctypes like we treat handheld friendly content r=mfinkle
authorBrad Lassey <blassey@mozilla.com>
Wed, 28 Oct 2009 15:30:05 -0400
changeset 65731 0d337b9c94ae3438033a7eb15bb86cea6c7639b7
parent 65730 fe1e7c76e41717a1992a3193ce6368b824b9944a
child 65732 f470c36cf0b2994f41081f3d8788f7c5fa7b6ba6
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)
reviewersmfinkle
bugs524900
bug 524900 - treat mobile doctypes like we treat handheld friendly content r=mfinkle
mobile/chrome/content/BrowserView.js
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/BrowserView.js
+++ b/mobile/chrome/content/BrowserView.js
@@ -552,22 +552,27 @@ BrowserView.prototype = {
     this.setZoomLevel(this.getZoomForPage());
   },
 
   getZoomForPage: function getZoomForPage() {
     let browser = this._browser;
     if (!browser)
       return 0;
 
-    var windowUtils = browser.contentWindow
+    let windowUtils = browser.contentWindow
                              .QueryInterface(Ci.nsIInterfaceRequestor)
                              .getInterface(Ci.nsIDOMWindowUtils);
-    var handheldFriendly = windowUtils.getDocumentMetadata("HandheldFriendly");
-    
-    if (handheldFriendly == "true") {
+    let handheldFriendly = windowUtils.getDocumentMetadata("HandheldFriendly");
+    let handheldDoctype = 
+          (browser.contentDocument.doctype && 
+           (browser.contentDocument.doctype.publicId.search("WAP") != -1 ||
+            browser.contentDocument.doctype.publicId.search("WML") != -1 ||
+            browser.contentDocument.doctype.publicId.search("Mobile") != -1)); 
+
+    if (handheldFriendly == "true" || handheldDoctype) {
       return 1;
     } else {
       let [w, h] = BrowserView.Util.getBrowserDimensions(browser);
       return BrowserView.Util.pageZoomLevel(this.getVisibleRect(), w, h);
     }
   },
 
   zoom: function zoom(aDirection) {
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -2485,17 +2485,23 @@ Tab.prototype = {
 
   endLoading: function() {
     // Determine at what resolution the browser is rendered based on meta tag
     let browser = this._browser;
     let windowUtils = browser.contentWindow
                              .QueryInterface(Ci.nsIInterfaceRequestor)
                              .getInterface(Ci.nsIDOMWindowUtils);
     let handheldFriendly = windowUtils.getDocumentMetadata("HandheldFriendly");
-    if (handheldFriendly == "true") {
+    let handheldDoctype = 
+          (browser.contentDocument.doctype && 
+           (browser.contentDocument.doctype.publicId.search("WAP") != -1 ||
+            browser.contentDocument.doctype.publicId.search("WML") != -1 ||
+            browser.contentDocument.doctype.publicId.search("Mobile") != -1)); 
+
+    if (handheldFriendly == "true" || handheldDoctype) {
       browser.className = "browser-handheld";
     } else {
       browser.className = "browser";
     }
 
     //if (!this._loading)
     //  dump("!!! Already finished loading this tab, please file a bug\n");
     this.setIcon(this._browser.mIconURL);