Bug 732564 - Get rid of the updateViewport function by inlining it into call sites. r=Cwiiis
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 12 Mar 2012 12:03:38 -0400
changeset 89323 32d74fbfbd8aca1a4588271a154c9688dc0beee3
parent 89322 8e0e446b7d67e09cc91131ede326ac5d7e8cd90b
child 89324 a5980ce21d40d091ed70e53809cf38e30d56abf7
push id22242
push userkgupta@mozilla.com
push dateWed, 14 Mar 2012 15:19:09 +0000
treeherdermozilla-central@936ef50fa498 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCwiiis
bugs732564
milestone13.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 732564 - Get rid of the updateViewport function by inlining it into call sites. r=Cwiiis
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -391,17 +391,17 @@ var BrowserApp = {
     if (this._selectedTab)
       this._selectedTab.setActive(false);
 
     this._selectedTab = aTab;
     if (!aTab)
       return;
 
     aTab.setActive(true);
-    aTab.updateViewport(false);
+    aTab.sendViewportUpdate();
     this.deck.selectedPanel = aTab.browser;
   },
 
   get selectedBrowser() {
     if (this._selectedTab)
       return this._selectedTab.browser;
     return null;
   },
@@ -1718,28 +1718,16 @@ Tab.prototype = {
         viewport.pageWidth = pageWidth;
         viewport.pageHeight = pageHeight;
       }
     }
 
     return viewport;
   },
 
-  updateViewport: function(aReset, aZoomLevel) {
-    dump("### JS side updateViewport " + aReset + " zoom " + aZoomLevel + "\n");
-
-    if (aReset) {
-      if (!aZoomLevel)
-        aZoomLevel = this.getDefaultZoomLevel();
-      this._zoom = aZoomLevel;
-    }
-
-    this.sendViewportUpdate();
-  },
-
   sendViewportUpdate: function() {
     if (BrowserApp.selectedTab != this)
       return;
     let displayPortMargins = sendMessageToJava({
       gecko: {
         type: "Viewport:Update"
       }
     });
@@ -1995,17 +1983,18 @@ Tab.prototype = {
         documentURI: documentURI,
         contentType: contentType
       }
     };
 
     sendMessageToJava(message);
 
     if ((aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) == 0) {
-      this.updateViewport(true);
+      this._zoom = this.getDefaultZoomLevel();
+      this.sendViewportUpdate();
     } else {
       this.sendViewportUpdate();
     }
   },
 
   onSecurityChange: function(aWebProgress, aRequest, aState) {
     let mode = "unknown";
     if (aState & Ci.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL)
@@ -2098,20 +2087,20 @@ Tab.prototype = {
     }
     ViewportHandler.setMetadataForDocument(this.browser.contentDocument, aMetadata);
     this.updateViewportSize();
   },
 
   /** Update viewport when the metadata or the window size changes. */
   updateViewportSize: function updateViewportSize() {
     // When this function gets called on window resize, we must execute
-    // this.updateViewport(true, ?) so that refreshDisplayPort is called.
+    // this.sendViewportUpdate() so that refreshDisplayPort is called.
     // Ensure that when making changes to this function that code path
-    // is not accidentally removed (the call to updateViewport is at the
-    // very end).
+    // is not accidentally removed (the call to sendViewportUpdate() is
+    // at the very end).
 
     if (window.outerWidth == 0 || window.outerHeight == 0) {
         // this happens sometimes when starting up fennec. we don't want zero
         // values corrupting our viewport numbers, so ignore this one.
         return;
     }
 
     gScreenWidth = window.outerWidth;
@@ -2160,18 +2149,18 @@ Tab.prototype = {
     let oldBrowserWidth = this.browserWidth;
     this.setBrowserSize(viewportW, viewportH);
 
     // Avoid having the scroll position jump around after device rotation.
     let win = this.browser.contentWindow;
     this.userScrollPos.x = win.scrollX;
     this.userScrollPos.y = win.scrollY;
 
-    let newZoom = oldBrowserWidth * this._zoom / viewportW;
-    this.updateViewport(true, newZoom);
+    this._zoom = oldBrowserWidth * this._zoom / viewportW;
+    this.sendViewportUpdate();
   },
 
   getDefaultZoomLevel: function getDefaultZoomLevel() {
     let md = this.metadata;
     if ("defaultZoom" in md && md.defaultZoom)
       return md.defaultZoom;
 
     dump("### getDefaultZoomLevel gScreenWidth=" + gScreenWidth);