Bug 598675 - Error: this.metaData is null [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 22 Sep 2010 10:31:11 -0700
changeset 66678 cc711fae990718121ecc42442bcb9f719a52403f
parent 66677 ffe66df487359a3a27b1ff6d6adcb38c2817b4da
child 66679 955a75a5ba25b0858e1c992df36fca037ca923c7
push id19389
push userffxbld
push dateWed, 06 Apr 2011 21:33:21 +0000
treeherdermozilla-central@8e9f90073a20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs598675
Bug 598675 - Error: this.metaData is null [r=mfinkle]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -2193,16 +2193,17 @@ var OfflineApps = {
 
 function Tab(aURI, aParams) {
   this._id = null;
   this._browser = null;
   this._state = null;
   this._listener = null;
   this._loading = false;
   this._chromeTab = null;
+  this._metadata = null;
   this.owner = 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;
 
   // aParams is an object that contains some properties for the initial tab
   // loading like flags, a referrerURI, a charset or even a postData.
@@ -2213,41 +2214,41 @@ Tab.prototype = {
   get browser() {
     return this._browser;
   },
 
   get chromeTab() {
     return this._chromeTab;
   },
 
+  get metadata() {
+    return this._metadata || kDefaultMetadata;
+  },
+
   /** Update browser styles when the viewport metadata changes. */
-  updateViewportMetadata: function updateViewportMetadata(metaData) {
-    let browser = this._browser;
-    if (!browser)
-      return;
-
-    this.metaData = metaData;
+  updateViewportMetadata: function updateViewportMetadata(aMetadata) {
+    this._metadata = aMetadata;
     this.updateViewportSize();
   },
 
   /** Update browser size when the metadata or the window size changes. */
   updateViewportSize: function updateViewportSize() {
     let browser = this._browser;
     if (!browser)
       return;
 
-    let metaData = this.metaData || kDefaultMetadata;
-    if (!metaData.autoSize) {
+    let metadata = this.metadata;
+    if (!metadata.autoSize) {
       let screenW = window.innerWidth;
       let screenH = window.innerHeight;
-      let viewportW = metaData.width;
-      let viewportH = metaData.height;
+      let viewportW = metadata.width;
+      let viewportH = metadata.height;
 
       // If (scale * width) < device-width, increase the width (bug 561413).
-      let maxInitialZoom = metaData.defaultZoom || metaData.maxZoom;
+      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 && !validH) {
         viewportH = viewportW * (screenH / screenW);
@@ -2259,17 +2260,17 @@ Tab.prototype = {
       }
 
       browser.setWindowSize(viewportW, viewportH);
     }
     else {
       let browserBCR = browser.getBoundingClientRect();
       let w = browserBCR.width;
       let h = browserBCR.height;
-      if (metaData.defaultZoom != 1.0) {
+      if (metadata.defaultZoom != 1.0) {
         let dpiScale = Services.prefs.getIntPref("zoom.dpiScale") / 100;
         w /= dpiScale;
         h /= dpiScale;
       }
 
       browser.setWindowSize(w, h);
     }
   },
@@ -2355,17 +2356,17 @@ Tab.prototype = {
       });
     }
   },
 
   clampZoomLevel: function clampZoomLevel(zl) {
     let browser = this._browser;
     let bounded = Math.min(Math.max(ZoomManager.MIN, zl), ZoomManager.MAX);
 
-    let md = this.metaData;
+    let md = this.metadata;
     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;
@@ -2389,17 +2390,17 @@ Tab.prototype = {
       browser.scale = this._defaultZoomLevel;
   },
 
   isDefaultZoomLevel: function isDefaultZoomLevel() {
     return this._browser.scale == this._defaultZoomLevel;
   },
 
   getDefaultZoomLevel: function getDefaultZoomLevel() {
-    let md = this.metaData;
+    let md = this.metadata;
     if (md && md.defaultZoom)
       return this.clampZoomLevel(md.defaultZoom);
 
     let pageZoom = this.getPageZoomLevel();
 
     // If pageZoom is "almost" 100%, zoom in to exactly 100% (bug 454456).
     let granularity = Services.prefs.getIntPref("browser.ui.zoom.pageFitGranularity");
     let threshold = 1 - 1 / granularity;
@@ -2410,17 +2411,17 @@ Tab.prototype = {
   },
 
   getPageZoomLevel: function getPageZoomLevel() {
     let browserW = this._browser.contentDocumentWidth;
     return this._browser.getBoundingClientRect().width / browserW;
   },
 
   get allowZoom() {
-    return this.metaData.allowZoom;
+    return this.metadata.allowZoom;
   },
 
   updateThumbnail: function updateThumbnail() {
     if (!this._browser)
       return;
 
     // XXX: We don't know the size of the browser at this time and we can't fallback
     // to contentWindow.innerWidth and .innerHeight. The viewport meta data is not