From a5fdfffbe1165435e52563b2cf02521c3c3d5f38 Mon Sep 17 00:00:00 2001
From: Matt Brubeck <mbrubeck@mozilla.com>
Date: Fri, 18 May 2012 08:24:27 -0700
Subject: [PATCH] Bug 707571 (part 5) - Add a hidden pref to ignore
 user-scalable=no [r=mfinkle]

---
 mobile/android/app/mobile.js             | 14 ++------------
 mobile/android/chrome/content/browser.js | 10 ++++++++++
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/mobile/android/app/mobile.js b/mobile/android/app/mobile.js
index 8645b7d221332..c2fc37883c92a 100644
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -445,20 +445,10 @@ pref("dom.max_script_run_time", 20);
 // JS error console
 pref("devtools.errorconsole.enabled", false);
 
-pref("browser.ui.layout.tablet", -1); // on: 1, off: 0, auto: -1
-
-// kinetic tweakables
-pref("browser.ui.kinetic.updateInterval", 16);
-pref("browser.ui.kinetic.exponentialC", 1400);
-pref("browser.ui.kinetic.polynomialC", 100);
-pref("browser.ui.kinetic.swipeLength", 160);
-
 pref("font.size.inflation.minTwips", 120);
 
-// pinch gesture
-pref("browser.ui.pinch.maxGrowth", 150);     // max pinch distance growth
-pref("browser.ui.pinch.maxShrink", 200);     // max pinch distance shrinkage
-pref("browser.ui.pinch.scalingFactor", 500); // scaling factor for above pinch limits
+// When true, zooming will be enabled on all sites, even ones that declare user-scalable=no.
+pref("browser.ui.zoom.force-user-scalable", false);
 
 // Touch radius (area around the touch location to look for target elements),
 // in 1/240-inch pixels:
diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js
index 8dd60e7185024..6f1ac5e12772b 100644
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1616,6 +1616,7 @@ Tab.prototype = {
     this.browser.addEventListener("pageshow", this, true);
 
     Services.obs.addObserver(this, "before-first-paint", false);
+    Services.prefs.addObserver("browser.ui.zoom.force-user-scalable", this, false);
 
     if (!aParams.delayLoad) {
       let flags = "flags" in aParams ? aParams.flags : Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
@@ -1660,6 +1661,7 @@ Tab.prototype = {
     this.browser.removeEventListener("MozScrolledAreaChanged", this, true);
 
     Services.obs.removeObserver(this, "before-first-paint");
+    Services.prefs.removeObserver("browser.ui.zoom.force-user-scalable", this);
 
     // Make sure the previously selected panel remains selected. The selected panel of a deck is
     // not stable when panels are removed.
@@ -2350,6 +2352,10 @@ 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();
 
@@ -2545,6 +2551,10 @@ Tab.prototype = {
           this.contentDocumentIsDisplayed = true;
         }
         break;
+      case "nsPref:changed":
+        if (aData == "browser.ui.zoom.force-user-scalable")
+          ViewportHandler.updateMetadata(this);
+        break;
     }
   },
 
-- 
GitLab