Bug 922337 - Remove unused viewport zooming code from /browser/metro [r=jimm]
authorMatt Brubeck <mbrubeck@mozilla.com>
Mon, 30 Sep 2013 20:27:05 -0700
changeset 149352 d63ba64a8319c4a46195c89178f5d346fca6f504
parent 149351 20e8d2ba4e5eb4a0ea748f57e0da14d97b2267ac
child 149353 132dbcea6676aa0bd73ee984d13ae83b217b607a
push id25385
push useremorley@mozilla.com
push dateTue, 01 Oct 2013 09:25:32 +0000
treeherdermozilla-central@a55240c523be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs922337
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 922337 - Remove unused viewport zooming code from /browser/metro [r=jimm]
browser/metro/base/content/BrowserTouchHandler.js
browser/metro/base/content/WebProgress.js
browser/metro/base/content/browser.js
browser/metro/base/content/contenthandlers/PluginCTPHandler.js
browser/metro/base/content/contenthandlers/ViewportHandler.js
browser/metro/base/content/input.js
browser/metro/base/jar.mn
browser/metro/profile/metro.js
--- a/browser/metro/base/content/BrowserTouchHandler.js
+++ b/browser/metro/base/content/BrowserTouchHandler.js
@@ -62,16 +62,19 @@ const BrowserTouchHandler = {
   },
 
   /*
    * Events
    */
 
   handleEvent: function handleEvent(aEvent) {
     // ignore content events we generate
+    if (aEvent.target == document)
+      return;
+
     if (this._debugEvents)
       Util.dumpLn("BrowserTouchHandler:", aEvent.type);
 
     switch (aEvent.type) {
       case "PopupChanged":
       case "CancelTouchSequence":
         if (!aEvent.detail)
           ContextMenuUI.reset();
--- a/browser/metro/base/content/WebProgress.js
+++ b/browser/metro/base/content/WebProgress.js
@@ -103,45 +103,31 @@ const WebProgress = {
     if (aTab == Browser.selectedTab) {
       BrowserUI.updateURI();
       BrowserUI.update();
     }
 
     let locationHasChanged = (location != aTab.browser.lastLocation);
     if (locationHasChanged) {
       Browser.getNotificationBox(aTab.browser).removeTransientNotifications();
-      aTab.resetZoomLevel();
       aTab.browser.lastLocation = location;
       aTab.browser.userTypedValue = "";
       aTab.browser.appIcon = { href: null, size:-1 };
 
 #ifdef MOZ_CRASHREPORTER
       if (CrashReporter.enabled)
         CrashReporter.annotateCrashReport("URL", spec);
 #endif
-      this._waitForLoad(aTab);
     }
 
     let event = document.createEvent("UIEvents");
     event.initUIEvent("URLChanged", true, false, window, locationHasChanged);
     aTab.browser.dispatchEvent(event);
   },
 
-  _waitForLoad: function _waitForLoad(aTab) {
-    let browser = aTab.browser;
-
-    aTab._firstPaint = false;
-
-    browser.messageManager.addMessageListener("Browser:FirstPaint", function firstPaintListener(aMessage) {
-      browser.messageManager.removeMessageListener(aMessage.name, arguments.callee);
-      aTab._firstPaint = true;
-      aTab.scrolledAreaChanged(true);
-    });
-  },
-
   _networkStart: function _networkStart(aJson, aTab) {
     aTab.startLoading();
 
     if (aTab == Browser.selectedTab) {
       // NO_STARTUI_VISIBILITY since the current uri for the tab has not
       // been updated yet. If we're coming off of the start page, this
       // would briefly show StartUI until _locationChange is called.
       BrowserUI.update(BrowserUI.NO_STARTUI_VISIBILITY);
--- a/browser/metro/base/content/browser.js
+++ b/browser/metro/base/content/browser.js
@@ -8,24 +8,20 @@ let Ci = Components.interfaces;
 let Cu = Components.utils;
 let Cr = Components.results;
 
 Cu.import("resource://gre/modules/PageThumbs.jsm");
 
 // Page for which the start UI is shown
 const kStartURI = "about:start";
 
-const kBrowserViewZoomLevelPrecision = 10000;
-
 // allow panning after this timeout on pages with registered touch listeners
 const kTouchTimeout = 300;
 const kSetInactiveStateTimeout = 100;
 
-const kDefaultMetadata = { autoSize: false, allowZoom: true, autoScale: true };
-
 const kTabThumbnailDelayCapture = 500;
 
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 // See grid.xml, we use this to cache style info across loads of the startui.
 var _richgridTileSizes = {};
 
 // Override sizeToContent in the main window. It breaks things (bug 565887)
@@ -63,37 +59,33 @@ var Browser = {
     try {
       messageManager.loadFrameScript("chrome://browser/content/Util.js", true);
       messageManager.loadFrameScript("chrome://browser/content/contenthandlers/Content.js", true);
       messageManager.loadFrameScript("chrome://browser/content/contenthandlers/FormHelper.js", true);
       messageManager.loadFrameScript("chrome://browser/content/library/SelectionPrototype.js", true);
       messageManager.loadFrameScript("chrome://browser/content/contenthandlers/SelectionHandler.js", true);
       messageManager.loadFrameScript("chrome://browser/content/contenthandlers/ContextMenuHandler.js", true);
       messageManager.loadFrameScript("chrome://browser/content/contenthandlers/FindHandler.js", true);
-      // XXX Viewport resizing disabled because of bug 766142
-      //messageManager.loadFrameScript("chrome://browser/content/contenthandlers/ViewportHandler.js", true);
       messageManager.loadFrameScript("chrome://browser/content/contenthandlers/ConsoleAPIObserver.js", true);
-      //messageManager.loadFrameScript("chrome://browser/content/contenthandlers/PluginCTPHandler.js", true);
     } catch (e) {
       // XXX whatever is calling startup needs to dump errors!
       dump("###########" + e + "\n");
     }
 
     /* handles dispatching clicks on browser into clicks in content or zooms */
     Elements.browsers.customDragger = new Browser.MainDragger();
 
     /* handles web progress management for open browsers */
     Elements.browsers.webProgress = WebProgress.init();
 
     // Call InputSourceHelper first so global listeners get called before
     // we start processing input in TouchModule.
     InputSourceHelper.init();
 
     TouchModule.init();
-    ScrollwheelModule.init(Elements.browsers);
     GestureModule.init();
     BrowserTouchHandler.init();
     PopupBlockerObserver.init();
     APZCObserver.init();
 
     // Init the touch scrollbox
     this.contentScrollbox = Elements.browsers;
     this.contentScrollboxScroller = {
@@ -151,27 +143,22 @@ var Browser = {
         // BrowserCLH paramerter
         commandURL = window.arguments[0];
       }
     } catch (ex) {
       Util.dumpLn(ex);
     }
 
     messageManager.addMessageListener("DOMLinkAdded", this);
-    messageManager.addMessageListener("MozScrolledAreaChanged", this);
-    messageManager.addMessageListener("Browser:ViewportMetadata", this);
     messageManager.addMessageListener("Browser:FormSubmit", this);
-    messageManager.addMessageListener("Browser:ZoomToPoint:Return", this);
     messageManager.addMessageListener("Browser:CanUnload:Return", this);
     messageManager.addMessageListener("scroll", this);
     messageManager.addMessageListener("Browser:CertException", this);
     messageManager.addMessageListener("Browser:BlockedSite", this);
-    messageManager.addMessageListener("Browser:ErrorPage", this);
     messageManager.addMessageListener("Browser:TapOnSelection", this);
-    messageManager.addMessageListener("Browser:PluginClickToPlayClicked", this);
 
     Task.spawn(function() {
       // Activation URIs come from protocol activations, secondary tiles, and file activations
       let activationURI = yield this.getShortcutOrURI(Services.metro.activationURI);
 
       let self = this;
       function loadStartupURI() {
         if (activationURI) {
@@ -224,25 +211,20 @@ var Browser = {
   },
 
   shutdown: function shutdown() {
     APZCObserver.shutdown();
     BrowserUI.uninit();
     ContentAreaObserver.shutdown();
     Appbar.shutdown();
 
-    messageManager.removeMessageListener("MozScrolledAreaChanged", this);
-    messageManager.removeMessageListener("Browser:ViewportMetadata", this);
     messageManager.removeMessageListener("Browser:FormSubmit", this);
-    messageManager.removeMessageListener("Browser:ZoomToPoint:Return", this);
     messageManager.removeMessageListener("scroll", this);
     messageManager.removeMessageListener("Browser:CertException", this);
     messageManager.removeMessageListener("Browser:BlockedSite", this);
-    messageManager.removeMessageListener("Browser:ErrorPage", this);
-    messageManager.removeMessageListener("Browser:PluginClickToPlayClicked", this);
     messageManager.removeMessageListener("Browser:TapOnSelection", this);
 
     Services.obs.removeObserver(SessionHistoryObserver, "browser:purge-session-history");
 
     window.controllers.removeController(this);
     window.controllers.removeController(BrowserUI);
   },
 
@@ -766,56 +748,23 @@ var Browser = {
     Bookmarks.removeForURI(uri, callback);
   },
 
   isSiteStarredAsync: function browser_isSiteStarredAsync(callback) {
     let uri = this.selectedBrowser.currentURI;
     Bookmarks.isURIBookmarked(uri, callback);
   },
 
-  /** Zoom one step in (negative) or out (positive). */
-  zoom: function zoom(aDirection) {
-    let tab = this.selectedTab;
-    if (!tab.allowZoom)
-      return;
-
-    let browser = tab.browser;
-    let oldZoomLevel = browser.scale;
-    let zoomLevel = oldZoomLevel;
-
-    let zoomValues = ZoomManager.zoomValues;
-    let i = zoomValues.indexOf(ZoomManager.snap(zoomLevel)) + (aDirection < 0 ? 1 : -1);
-    if (i >= 0 && i < zoomValues.length)
-      zoomLevel = zoomValues[i];
-
-    zoomLevel = tab.clampZoomLevel(zoomLevel);
-
-    let browserRect = browser.getBoundingClientRect();
-    let center = browser.ptClientToBrowser(browserRect.width / 2,
-                                           browserRect.height / 2);
-    let rect = this._getZoomRectForPoint(center.xPos, center.yPos, zoomLevel);
-    AnimatedZoom.animateTo(rect);
-  },
-
   /** Rect should be in browser coordinates. */
   _getZoomLevelForRect: function _getZoomLevelForRect(rect) {
     const margin = 15;
     return this.selectedTab.clampZoomLevel(ContentAreaObserver.width / (rect.width + margin * 2));
   },
 
   /**
-   * Find an appropriate zoom rect for an element bounding rect, if it exists.
-   * @return Rect in viewport coordinates, or null
-   */
-  _getZoomRectForRect: function _getZoomRectForRect(rect, y) {
-    let zoomLevel = this._getZoomLevelForRect(rect);
-    return this._getZoomRectForPoint(rect.center().x, y, zoomLevel);
-  },
-
-  /**
    * Find a good zoom rectangle for point that is specified in browser coordinates.
    * @return Rect in viewport coordinates
    */
   _getZoomRectForPoint: function _getZoomRectForPoint(x, y, zoomLevel) {
     let browser = getBrowser();
     x = x * browser.scale;
     y = y * browser.scale;
 
@@ -826,62 +775,16 @@ var Browser = {
     let newVisW = browserRect.width / zoomRatio, newVisH = browserRect.height / zoomRatio;
     let result = new Rect(x - newVisW / 2, y - newVisH / 2, newVisW, newVisH);
 
     // Make sure rectangle doesn't poke out of viewport
     return result.translateInside(new Rect(0, 0, browser.contentDocumentWidth * oldScale,
                                                  browser.contentDocumentHeight * oldScale));
   },
 
-  zoomToPoint: function zoomToPoint(cX, cY, aRect) {
-    let tab = this.selectedTab;
-    if (!tab.allowZoom)
-      return null;
-
-    let zoomRect = null;
-    if (aRect)
-      zoomRect = this._getZoomRectForRect(aRect, cY);
-
-    if (!zoomRect && tab.isDefaultZoomLevel()) {
-      let scale = tab.clampZoomLevel(tab.browser.scale * 2);
-      zoomRect = this._getZoomRectForPoint(cX, cY, scale);
-    }
-
-    if (zoomRect)
-      AnimatedZoom.animateTo(zoomRect);
-
-    return zoomRect;
-  },
-
-  zoomFromPoint: function zoomFromPoint(cX, cY) {
-    let tab = this.selectedTab;
-    if (tab.allowZoom && !tab.isDefaultZoomLevel()) {
-      let zoomLevel = tab.getDefaultZoomLevel();
-      let zoomRect = this._getZoomRectForPoint(cX, cY, zoomLevel);
-      AnimatedZoom.animateTo(zoomRect);
-    }
-  },
-
-  // The device-pixel-to-CSS-px ratio used to adjust meta viewport values.
-  // This is higher on higher-dpi displays, so pages stay about the same physical size.
-  getScaleRatio: function getScaleRatio() {
-    let prefValue = Services.prefs.getIntPref("browser.viewport.scaleRatio");
-    if (prefValue > 0)
-      return prefValue / 100;
-
-    let dpi = Util.displayDPI;
-    if (dpi < 200) // Includes desktop displays, and LDPI and MDPI Android devices
-      return 1;
-    else if (dpi < 300) // Includes Nokia N900, and HDPI Android devices
-      return 1.5;
-
-    // For very high-density displays like the iPhone 4, calculate an integer ratio.
-    return Math.floor(dpi / 150);
-  },
-
   /**
    * Convenience function for getting the scrollbox position off of a
    * scrollBoxObject interface.  Returns the actual values instead of the
    * wrapping objects.
    *
    * @param scroller a scrollBoxObject on which to call scroller.getPosition()
    */
   getScrollboxPosition: function getScrollboxPosition(scroller) {
@@ -925,83 +828,33 @@ var Browser = {
         else if ((rel.indexOf("apple-touch-icon") != -1) && (browser.appIcon.size < 57)) {
           // XXX should we support apple-touch-icon-precomposed ?
           // see http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/configuringwebapplications/configuringwebapplications.html
           browser.appIcon.href = json.href;
           browser.appIcon.size = 57;
         }
         break;
       }
-      case "MozScrolledAreaChanged": {
-        let tab = this.getTabForBrowser(browser);
-        if (tab)
-          tab.scrolledAreaChanged();
-        break;
-      }
-      case "Browser:ViewportMetadata": {
-        let tab = this.getTabForBrowser(browser);
-        // Some browser such as iframes loaded dynamically into the chrome UI
-        // does not have any assigned tab
-        if (tab)
-          tab.updateViewportMetadata(json);
-        break;
-      }
       case "Browser:FormSubmit":
         browser.lastLocation = null;
         break;
 
       case "Browser:CanUnload:Return": {
-	if (json.permit) {
-	  let tab = this.getTabForBrowser(browser);
-	  BrowserUI.animateClosingTab(tab);
-	}
-	break;
-      }
-      case "Browser:ZoomToPoint:Return":
-        if (json.zoomTo) {
-          let rect = Rect.fromRect(json.zoomTo);
-          this.zoomToPoint(json.x, json.y, rect);
-        } else {
-          this.zoomFromPoint(json.x, json.y);
+        if (json.permit) {
+          let tab = this.getTabForBrowser(browser);
+          BrowserUI.animateClosingTab(tab);
         }
         break;
+      }
       case "Browser:CertException":
         this._handleCertException(aMessage);
         break;
       case "Browser:BlockedSite":
         this._handleBlockedSite(aMessage);
         break;
-      case "Browser:ErrorPage":
-        break;
-      case "Browser:PluginClickToPlayClicked": {
-        // Save off session history
-        let parent = browser.parentNode;
-        let data = browser.__SS_data;
-        if (data.entries.length == 0)
-          return;
-
-        // Remove the browser from the DOM, effectively killing it's content
-        parent.removeChild(browser);
-
-        // Re-create the browser as non-remote, so plugins work
-        browser.setAttribute("remote", "false");
-        parent.appendChild(browser);
-
-        // Reload the content using session history
-        browser.__SS_data = data;
-        let json = {
-          uri: data.entries[data.index - 1].url,
-          flags: null,
-          entries: data.entries,
-          index: data.index
-        };
-        browser.messageManager.sendAsyncMessage("WebNavigation:LoadURI", json);
-        break;
-      }
-
       case "Browser:TapOnSelection":
         if (!InputSourceHelper.isPrecise) {
           if (SelectionHelperUI.isActive) {
             SelectionHelperUI.shutdown();
           }
           if (SelectionHelperUI.canHandle(aMessage)) {
             SelectionHelperUI.openEditSession(aMessage);
           }
@@ -1230,20 +1083,16 @@ nsBrowserAccess.prototype = {
     return browser ? browser.contentWindow : null;
   },
 
   openURIInFrame: function browser_openURIInFrame(aURI, aOpener, aWhere, aContext) {
     let browser = this._getBrowser(aURI, aOpener, aWhere, aContext);
     return browser ? browser.QueryInterface(Ci.nsIFrameLoaderOwner) : null;
   },
 
-  zoom: function browser_zoom(aAmount) {
-    Browser.zoom(aAmount);
-  },
-
   isTabContentWindow: function(aWindow) {
     return Browser.browsers.some(function (browser) browser.contentWindow == aWindow);
   },
 
   get contentWindow() {
     return Browser.selectedBrowser.contentWindow;
   }
 };
@@ -1389,17 +1238,16 @@ function showDownloadManager(aWindowCont
 }
 
 function Tab(aURI, aParams, aOwner) {
   this._id = null;
   this._browser = null;
   this._notification = null;
   this._loading = false;
   this._chromeTab = null;
-  this._metadata = null;
   this._eventDeferred = null;
   this._updateThumbnailTimeout = null;
 
   this.owner = aOwner || null;
 
   // Set to 0 since new tabs that have not been viewed yet are good tabs to
   // toss if app needs more memory.
   this.lastSelected = 0;
@@ -1420,106 +1268,20 @@ Tab.prototype = {
   get notification() {
     return this._notification;
   },
 
   get chromeTab() {
     return this._chromeTab;
   },
 
-  get metadata() {
-    return this._metadata || kDefaultMetadata;
-  },
-
   get pageShowPromise() {
     return this._eventDeferred ? this._eventDeferred.promise : null;
   },
 
-  /** Update browser styles when the viewport metadata changes. */
-  updateViewportMetadata: function updateViewportMetadata(aMetadata) {
-    if (aMetadata && aMetadata.autoScale) {
-      let scaleRatio = aMetadata.scaleRatio = Browser.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;
-    }
-    this._metadata = aMetadata;
-    this.updateViewportSize();
-  },
-
-  /**
-   * Update browser size when the metadata or the window size changes.
-   */
-  updateViewportSize: function updateViewportSize(width, height) {
-    /* XXX Viewport resizing disabled because of bug 766142
-
-    let browser = this._browser;
-    if (!browser)
-      return;
-
-    let screenW = width || ContentAreaObserver.width;
-    let screenH = height || ContentAreaObserver.height;
-    let viewportW, viewportH;
-
-    let metadata = this.metadata;
-    if (metadata.autoSize) {
-      if ("scaleRatio" in metadata) {
-        viewportW = screenW / metadata.scaleRatio;
-        viewportH = screenH / metadata.scaleRatio;
-      } else {
-        viewportW = screenW;
-        viewportH = screenH;
-      }
-    } else {
-      viewportW = metadata.width;
-      viewportH = metadata.height;
-
-      // If (scale * width) < device-width, increase the width (bug 561413).
-      let maxInitialZoom = metadata.defaultZoom || metadata.maxZoom;
-      if (maxInitialZoom && viewportW)
-        viewportW = Math.max(viewportW, screenW / maxInitialZoom);
-
-      let validW = viewportW > 0;
-      let validH = viewportH > 0;
-
-      if (!validW)
-        viewportW = validH ? (viewportH * (screenW / screenH)) : Browser.defaultBrowserWidth;
-      if (!validH)
-        viewportH = viewportW * (screenH / screenW);
-    }
-
-    // Make sure the viewport height is not shorter than the window when
-    // the page is zoomed out to show its full width.
-    let pageZoomLevel = this.getPageZoomLevel(screenW);
-    let minScale = this.clampZoomLevel(pageZoomLevel, pageZoomLevel);
-    viewportH = Math.max(viewportH, screenH / minScale);
-
-    if (browser.contentWindowWidth != viewportW || browser.contentWindowHeight != viewportH)
-      browser.setWindowSize(viewportW, viewportH);
-    */
-  },
-
-  restoreViewportPosition: function restoreViewportPosition(aOldWidth, aNewWidth) {
-    let browser = this._browser;
-
-    // zoom to keep the same portion of the document visible
-    let oldScale = browser.scale;
-    let newScale = this.clampZoomLevel(oldScale * aNewWidth / aOldWidth);
-    let scaleRatio = newScale / oldScale;
-
-    let view = browser.getRootView();
-    let pos = view.getPosition();
-    browser.fuzzyZoom(newScale, pos.x * scaleRatio, pos.y * scaleRatio);
-    browser.finishFuzzyZoom();
-  },
-
   startLoading: function startLoading() {
     if (this._loading) {
       let stack = new Error().stack;
       throw "Already Loading!\n" + stack;
     }
     this._loading = true;
   },
 
@@ -1692,118 +1454,19 @@ Tab.prototype = {
 
       Elements.browsers.removeChild(notification);
     }
   },
 
   /**
    * Takes a scale and restricts it based on this tab's zoom limits.
    * @param aScale The original scale.
-   * @param aPageZoomLevel (optional) The zoom-to-fit scale, if known.
-   *   This is a performance optimization to avoid extra calls.
    */
-  clampZoomLevel: function clampZoomLevel(aScale, aPageZoomLevel) {
-    let md = this.metadata;
-    if (!this.allowZoom) {
-      return (md && md.defaultZoom)
-        ? md.defaultZoom
-        : (aPageZoomLevel || this.getPageZoomLevel());
-    }
-
-    let browser = this._browser;
-    let bounded = Util.clamp(aScale, ZoomManager.MIN, ZoomManager.MAX);
-
-    if (md && md.minZoom)
-      bounded = Math.max(bounded, md.minZoom);
-    if (md && md.maxZoom)
-      bounded = Math.min(bounded, md.maxZoom);
-
-    bounded = Math.max(bounded, this.getPageZoomLevel());
-
-    let rounded = Math.round(bounded * kBrowserViewZoomLevelPrecision) / kBrowserViewZoomLevelPrecision;
-    return rounded || 1.0;
-  },
-
-  /** Record the initial zoom level when a page first loads. */
-  resetZoomLevel: function resetZoomLevel() {
-    this._defaultZoomLevel = this._browser.scale;
-  },
-
-  scrolledAreaChanged: function scrolledAreaChanged(firstPaint) {
-    if (!this._browser)
-      return;
-
-    if (firstPaint) {
-      // You only get one shot, do not miss your chance to reflow.
-      this.updateViewportSize();
-    }
-
-    this.updateDefaultZoomLevel();
-  },
-
-  /**
-   * Recalculate default zoom level when page size changes, and update zoom
-   * level if we are at default.
-   */
-  updateDefaultZoomLevel: function updateDefaultZoomLevel() {
-    let browser = this._browser;
-    if (!browser || !this._firstPaint)
-      return;
-
-    let isDefault = this.isDefaultZoomLevel();
-    this._defaultZoomLevel = this.getDefaultZoomLevel();
-    if (isDefault) {
-      if (browser.scale != this._defaultZoomLevel) {
-        browser.scale = this._defaultZoomLevel;
-      } else {
-        // If the scale level has not changed we want to be sure the content
-        // render correctly since the page refresh process could have been
-        // stalled during page load. In this case if the page has the exact
-        // same width (like the same page, so by doing 'refresh') and the
-        // page was scrolled the content is just checkerboard at this point
-        // and this call ensure we render it correctly.
-        browser.getRootView()._updateCacheViewport();
-      }
-    } else {
-      // if we are reloading, the page will retain its scale. if it is zoomed
-      // we need to refresh the viewport so that we do not show checkerboard
-      browser.getRootView()._updateCacheViewport();
-    }
-  },
-
-  isDefaultZoomLevel: function isDefaultZoomLevel() {
-    return this._browser.scale == this._defaultZoomLevel;
-  },
-
-  getDefaultZoomLevel: function getDefaultZoomLevel() {
-    let md = this.metadata;
-    if (md && md.defaultZoom)
-      return this.clampZoomLevel(md.defaultZoom);
-
-    let browserWidth = this._browser.getBoundingClientRect().width;
-    let defaultZoom = browserWidth / this._browser.contentWindowWidth;
-    return this.clampZoomLevel(defaultZoom);
-  },
-
-  /**
-   * @param aScreenWidth (optional) The width of the browser widget, if known.
-   *   This is a performance optimization to save extra calls to getBoundingClientRect.
-   * @return The scale at which the browser will be zoomed out to fit the document width.
-   */
-  getPageZoomLevel: function getPageZoomLevel(aScreenWidth) {
-    let browserW = this._browser.contentDocumentWidth;
-    if (browserW == 0)
-      return 1.0;
-
-    let screenW = aScreenWidth || this._browser.getBoundingClientRect().width;
-    return screenW / browserW;
-  },
-
-  get allowZoom() {
-    return this.metadata.allowZoom && !Util.isURLEmpty(this.browser.currentURI.spec);
+  clampZoomLevel: function clampZoomLevel(aScale) {
+    return Util.clamp(aScale, ZoomManager.MIN, ZoomManager.MAX);
   },
 
   updateThumbnail: function updateThumbnail() {
     PageThumbs.captureToCanvas(this.browser.contentWindow, this._chromeTab.thumbnailCanvas);
   },
 
   updateFavicon: function updateFavicon() {
     this._chromeTab.updateFavicon(this._browser.mIconURL);
deleted file mode 100644
--- a/browser/metro/base/content/contenthandlers/PluginCTPHandler.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-var PluginCTPHandler = {
-  init: function() {
-    addEventListener("PluginClickToPlay", this, false);
-  },
-
-  addLinkClickCallback: function (linkNode, callbackName /*callbackArgs...*/) {
-     // XXX just doing (callback)(arg) was giving a same-origin error. bug?
-     let self = this;
-     let callbackArgs = Array.prototype.slice.call(arguments).slice(2);
-     linkNode.addEventListener("click",
-                               function(evt) {
-                                 if (!evt.isTrusted)
-                                   return;
-                                 evt.preventDefault();
-                                 if (callbackArgs.length == 0)
-                                   callbackArgs = [ evt ];
-                                 (self[callbackName]).apply(self, callbackArgs);
-                               },
-                               true);
- 
-     linkNode.addEventListener("keydown",
-                               function(evt) {
-                                 if (!evt.isTrusted)
-                                   return;
-                                 if (evt.keyCode == evt.DOM_VK_RETURN) {
-                                   evt.preventDefault();
-                                   if (callbackArgs.length == 0)
-                                     callbackArgs = [ evt ];
-                                   evt.preventDefault();
-                                   (self[callbackName]).apply(self, callbackArgs);
-                                 }
-                               },
-                               true);
-   },
-
-  handleEvent : function(event) {
-    if (event.type != "PluginClickToPlay")
-      return;
-    let plugin = event.target;
-    PluginHandler.addLinkClickCallback(plugin, "reloadToEnablePlugin");
-  },
-
-  reloadToEnablePlugin: function() {
-    sendAsyncMessage("Browser:PluginClickToPlayClicked", { });
-  }
-};
-
-//PluginCTPHandler.init();
deleted file mode 100644
--- a/browser/metro/base/content/contenthandlers/ViewportHandler.js
+++ /dev/null
@@ -1,136 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-dump("### ViewportHandler.js loaded\n");
-
-// See getViewportMetadata. Blindly copied from Safari
-// documentation for now.
-const kViewportMinScale  = 0;
-const kViewportMaxScale  = 10;
-const kViewportMinWidth  = 200;
-const kViewportMaxWidth  = 10000;
-const kViewportMinHeight = 223;
-const kViewportMaxHeight = 10000;
-
-/*
- * ViewportHandler
- *
- * Plucks zoom info out of web page metadata and forwards it to the
- * browser.
- */ 
-
-let ViewportHandler = {
-  init: function init() {
-    addEventListener("DOMWindowCreated", this, false);
-    addEventListener("DOMMetaAdded", this, false);
-    addEventListener("DOMContentLoaded", this, false);
-    addEventListener("pageshow", this, false);
-  },
-
-  handleEvent: function handleEvent(aEvent) {
-    let target = aEvent.originalTarget;
-    let isRootDocument = (target == content.document || target.ownerDocument == content.document);
-    if (!isRootDocument)
-      return;
-
-    switch (aEvent.type) {
-      case "DOMWindowCreated":
-        this.resetMetadata();
-        break;
-
-      case "DOMMetaAdded":
-        if (target.name == "viewport")
-          this.updateMetadata();
-        break;
-
-      case "DOMContentLoaded":
-      case "pageshow":
-        this.updateMetadata();
-        break;
-    }
-  },
-
-  resetMetadata: function resetMetadata() {
-    sendAsyncMessage("Browser:ViewportMetadata", null);
-  },
-
-  updateMetadata: function updateMetadata() {
-    sendAsyncMessage("Browser:ViewportMetadata", this.getViewportMetadata());
-  },
-
-  /**
-   * 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() {
-    let doctype = content.document.doctype;
-    if (doctype && /(WAP|WML|Mobile)/.test(doctype.publicId))
-      return { defaultZoom: 1, autoSize: true, allowZoom: true, autoScale: true };
-
-    let windowUtils = Util.getWindowUtils(content);
-    let handheldFriendly = windowUtils.getDocumentMetadata("HandheldFriendly");
-    if (handheldFriendly == "true")
-      return { defaultZoom: 1, autoSize: true, allowZoom: true, autoScale: true };
-
-    if (content.document instanceof XULDocument)
-      return { defaultZoom: 1, autoSize: true, allowZoom: false, autoScale: false };
-
-    // HACK: Since we can't set the scale in local tabs (bug 597081), we force
-    // them to device-width and scale=1 so they will lay out reasonably.
-    if (Util.isLocalScheme(content.document.documentURI))
-      return { defaultZoom: 1, autoSize: true, allowZoom: false, autoScale: false };
-
-    // HACK: Since we can't set the scale correctly in frameset pages yet (bug 645756), we force
-    // them to device-width and scale=1 so they will lay out reasonably.
-    if (content.frames.length > 0 && (content.document.body instanceof HTMLFrameSetElement))
-      return { defaultZoom: 1, autoSize: true, allowZoom: false, autoScale: false };
-
-    // 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.
-    let scale = parseFloat(windowUtils.getDocumentMetadata("viewport-initial-scale"));
-    let minScale = parseFloat(windowUtils.getDocumentMetadata("viewport-minimum-scale"));
-    let maxScale = parseFloat(windowUtils.getDocumentMetadata("viewport-maximum-scale"));
-
-    let widthStr = windowUtils.getDocumentMetadata("viewport-width");
-    let heightStr = windowUtils.getDocumentMetadata("viewport-height");
-    let width = Util.clamp(parseInt(widthStr), kViewportMinWidth, kViewportMaxWidth);
-    let height = Util.clamp(parseInt(heightStr), kViewportMinHeight, kViewportMaxHeight);
-
-    let allowZoomStr = windowUtils.getDocumentMetadata("viewport-user-scalable");
-    let allowZoom = !/^(0|no|false)$/.test(allowZoomStr); // WebKit allows 0, "no", or "false"
-
-    scale = Util.clamp(scale, kViewportMinScale, kViewportMaxScale);
-    minScale = Util.clamp(minScale, kViewportMinScale, kViewportMaxScale);
-    maxScale = Util.clamp(maxScale, kViewportMinScale, kViewportMaxScale);
-
-    // If initial scale is 1.0 and width is not set, assume width=device-width
-    let autoSize = (widthStr == "device-width" ||
-                    (!widthStr && (heightStr == "device-height" || scale == 1.0)));
-
-    return {
-      defaultZoom: scale,
-      minZoom: minScale,
-      maxZoom: maxScale,
-      width: width,
-      height: height,
-      autoSize: autoSize,
-      allowZoom: allowZoom,
-      autoScale: true
-    };
-  }
-};
-
-ViewportHandler.init();
-
--- a/browser/metro/base/content/input.js
+++ b/browser/metro/base/content/input.js
@@ -966,85 +966,25 @@ KineticController.prototype = {
         this.end();
     }
 
     this.momentumBuffer.push({'t': now, 'dx' : dx, 'dy' : dy});
   }
 };
 
 
-/**
- * Input module for basic scrollwheel input.  Currently just zooms the browser
- * view accordingly.
- */
-var ScrollwheelModule = {
-  _pendingEvent : 0,
-  _container: null,
-  
-  init: function init(container) {
-    this._container = container;
-    window.addEventListener("MozPrecisePointer", this, true);
-    window.addEventListener("MozImprecisePointer", this, true);
-  },
-
-  handleEvent: function handleEvent(aEvent) {
-    switch(aEvent.type) {
-      case "DOMMouseScroll":
-      case "MozMousePixelScroll":
-        this._onScroll(aEvent);
-        break;
-      case "MozPrecisePointer":
-        this._container.removeEventListener("DOMMouseScroll", this, true);
-        this._container.removeEventListener("MozMousePixelScroll", this, true);
-        break;
-      case "MozImprecisePointer":
-        this._container.addEventListener("DOMMouseScroll", this, true);
-        this._container.addEventListener("MozMousePixelScroll", this, true);
-        break;
-    };
-  },
-
-  _onScroll: function _onScroll(aEvent) {
-    // If events come too fast we don't want their handling to lag the
-    // zoom in/zoom out execution. With the timeout the zoom is executed
-    // as we scroll.
-    if (this._pendingEvent)
-      clearTimeout(this._pendingEvent);
-
-    this._pendingEvent = setTimeout(function handleEventImpl(self) {
-      self._pendingEvent = 0;
-      Browser.zoom(aEvent.detail);
-    }, 0, this);
-
-    aEvent.stopPropagation();
-    aEvent.preventDefault();
-  },
-
-  /* We don't have much state to reset if we lose event focus */
-  cancelPending: function cancelPending() {}
-};
-
-
 /*
  * Simple gestures support
  */
 
 var GestureModule = {
   _debugEvents: false,
 
   init: function init() {
     window.addEventListener("MozSwipeGesture", this, true);
-    window.addEventListener("CancelTouchSequence", this, true);
-  },
-
-  _initMouseEventFromGestureEvent: function _initMouseEventFromGestureEvent(aDestEvent, aSrcEvent, aType, aCanBubble, aCancellable) {
-    aDestEvent.initMouseEvent(aType, aCanBubble, aCancellable, window, null,
-                              aSrcEvent.screenX, aSrcEvent.screenY, aSrcEvent.clientX, aSrcEvent.clientY,
-                              aSrcEvent.ctrlKey, aSrcEvent.altKey, aSrcEvent.shiftKey, aSrcEvent.metaKey,
-                              aSrcEvent.button, aSrcEvent.relatedTarget);
   },
 
   /*
    * Events
    *
    * Dispatch events based on the type of mouse gesture event. For now, make
    * sure to stop propagation of every gesture event so that web content cannot
    * receive gesture events.
@@ -1060,139 +1000,40 @@ var GestureModule = {
       switch (aEvent.type) {
         case "MozSwipeGesture":
           if (this._onSwipe(aEvent)) {
             let event = document.createEvent("Events");
             event.initEvent("CancelTouchSequence", true, true);
             aEvent.target.dispatchEvent(event);
           }
           break;
-
-        case "CancelTouchSequence":
-          this.cancelPending();
-          break;
       }
     } catch (e) {
       Util.dumpLn("Error while handling gesture event", aEvent.type,
                   "\nPlease report error at:", e);
       Cu.reportError(e);
     }
   },
 
-  /*
-   * Event handlers
-   */
-
-  cancelPending: function cancelPending() {
-    if (AnimatedZoom.isZooming())
-      AnimatedZoom.finish();
-  },
-
   _onSwipe: function _onSwipe(aEvent) {
     switch (aEvent.direction) {
       case Ci.nsIDOMSimpleGestureEvent.DIRECTION_LEFT:
         return this._tryCommand("cmd_forward");
       case Ci.nsIDOMSimpleGestureEvent.DIRECTION_RIGHT:
         return this._tryCommand("cmd_back");
     }
     return false;
   },
 
   _tryCommand: function _tryCommand(aId) {
      if (document.getElementById(aId).getAttribute("disabled") == "true")
        return false;
      CommandUpdater.doCommand(aId);
      return true;
   },
-
-  _pinchStart: function _pinchStart(aEvent) {
-    if (AnimatedZoom.isZooming())
-      return;
-    // Cancel other touch sequence events, and be courteous by allowing them
-    // to say no.
-    let event = document.createEvent("Events");
-    event.initEvent("CancelTouchSequence", true, true);
-    let success = aEvent.target.dispatchEvent(event);
-
-    if (!success || !Browser.selectedTab.allowZoom)
-      return;
-
-    AnimatedZoom.start();
-    this._pinchDelta = 0;
-
-    //this._ignoreNextUpdate = true; // first update gives useless, huge delta
-
-    // cache gesture limit values
-    this._maxGrowth = Services.prefs.getIntPref("browser.ui.pinch.maxGrowth");
-    this._maxShrink = Services.prefs.getIntPref("browser.ui.pinch.maxShrink");
-    this._scalingFactor = Services.prefs.getIntPref("browser.ui.pinch.scalingFactor");
-
-    // Adjust the client coordinates to be relative to the browser element's top left corner.
-    this._browserBCR = getBrowser().getBoundingClientRect();
-    this._pinchStartX = aEvent.clientX - this._browserBCR.left;
-    this._pinchStartY = aEvent.clientY - this._browserBCR.top;
-  },
-
-  _pinchUpdate: function _pinchUpdate(aEvent) {
-    if (!AnimatedZoom.isZooming() || !aEvent.delta)
-      return;
-
-    let delta = 0;
-    let browser = AnimatedZoom.browser;
-    let oldScale = browser.scale;
-    let bcr = this._browserBCR;
-
-    // Accumulate pinch delta. Small changes are just jitter.
-    this._pinchDelta += aEvent.delta;
-    if (Math.abs(this._pinchDelta) >= oldScale) {
-      delta = this._pinchDelta;
-      this._pinchDelta = 0;
-    }
-
-    // decrease the pinchDelta min/max values to limit zooming out/in speed
-    delta = Util.clamp(delta, -this._maxShrink, this._maxGrowth);
-
-    let newScale = Browser.selectedTab.clampZoomLevel(oldScale * (1 + delta / this._scalingFactor));
-    let startScale = AnimatedZoom.startScale;
-    let scaleRatio = startScale / newScale;
-    let cX = aEvent.clientX - bcr.left;
-    let cY = aEvent.clientY - bcr.top;
-
-    // Calculate the new zoom rect.
-    let rect = AnimatedZoom.zoomFrom.clone();
-    rect.translate(this._pinchStartX - cX + (1-scaleRatio) * cX * rect.width / bcr.width,
-                   this._pinchStartY - cY + (1-scaleRatio) * cY * rect.height / bcr.height);
-
-    rect.width *= scaleRatio;
-    rect.height *= scaleRatio;
-
-    this.translateInside(rect, new Rect(0, 0, browser.contentDocumentWidth * startScale,
-                                              browser.contentDocumentHeight * startScale));
-
-    // redraw zoom canvas according to new zoom rect
-    AnimatedZoom.updateTo(rect);
-  },
-
-  _pinchEnd: function _pinchEnd(aEvent) {
-    if (AnimatedZoom.isZooming())
-      AnimatedZoom.finish();
-  },
-
-  /**
-   * Ensure r0 is inside r1, if possible. Preserves w, h.
-   * Same as Rect.prototype.translateInside except it aligns the top left
-   * instead of the bottom right if r0 is bigger than r1.
-   */
-  translateInside: function translateInside(r0, r1) {
-    let offsetX = (r0.left < r1.left ? r1.left - r0.left :
-        (r0.right > r1.right ? Math.max(r1.left - r0.left, r1.right - r0.right) : 0));
-    let offsetY = (r0.top < r1.top ? r1.top - r0.top :
-        (r0.bottom > r1.bottom ? Math.max(r1.top - r0.top, r1.bottom - r0.bottom) : 0));
-    return r0.translate(offsetX, offsetY);
-  }
 };
 
 /**
  * Helper to track when the user is using a precise pointing device (pen/mouse)
  * versus an imprecise one (touch).
  */
 var InputSourceHelper = {
   isPrecise: false,
--- a/browser/metro/base/jar.mn
+++ b/browser/metro/base/jar.mn
@@ -41,21 +41,19 @@ chrome.jar:
   content/helperui/SelectHelperUI.js           (content/helperui/SelectHelperUI.js)
   content/helperui/SelectionHelperUI.js        (content/helperui/SelectionHelperUI.js)
   content/helperui/ChromeSelectionHandler.js   (content/helperui/ChromeSelectionHandler.js)
   content/helperui/FormHelperUI.js             (content/helperui/FormHelperUI.js)
   content/helperui/FindHelperUI.js             (content/helperui/FindHelperUI.js)
   content/helperui/ItemPinHelper.js            (content/helperui/ItemPinHelper.js)
 
   content/contenthandlers/ContextMenuHandler.js (content/contenthandlers/ContextMenuHandler.js)
-  content/contenthandlers/PluginCTPHandler.js  (content/contenthandlers/PluginCTPHandler.js)
   content/contenthandlers/SelectionHandler.js  (content/contenthandlers/SelectionHandler.js)
   content/contenthandlers/FormHelper.js        (content/contenthandlers/FormHelper.js)
   content/contenthandlers/FindHandler.js       (content/contenthandlers/FindHandler.js)
-  content/contenthandlers/ViewportHandler.js   (content/contenthandlers/ViewportHandler.js)
   content/contenthandlers/ConsoleAPIObserver.js (content/contenthandlers/ConsoleAPIObserver.js)
   content/contenthandlers/Content.js           (content/contenthandlers/Content.js)
 
   content/library/SelectionPrototype.js        (content/library/SelectionPrototype.js)
 
   content/ContentAreaObserver.js               (content/ContentAreaObserver.js)
   content/BrowserTouchHandler.js               (content/BrowserTouchHandler.js)
 * content/WebProgress.js                       (content/WebProgress.js)
--- a/browser/metro/profile/metro.js
+++ b/browser/metro/profile/metro.js
@@ -382,21 +382,16 @@ pref("browser.ui.snapped.maxWidth", 600)
 
 // 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("browser.ui.zoom.animationDuration", 200); // ms duration of double-tap zoom animation
 
-// 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
-
 pref("ui.mouse.radius.enabled", true);
 pref("ui.touch.radius.enabled", true);
 
 // plugins
 pref("plugin.disable", true);
 pref("dom.ipc.plugins.enabled", true);
 
 // process priority