Bug 1175794 - Remove use of variables on this for pageinfo. r=florian, a=sledru
authorJimmy Wang <jiwang@mozilla.com>
Thu, 13 Aug 2015 03:37:02 -0400
changeset 289038 23d7dfbc4e1d8527d06436cdc408a91487a1e504
parent 289037 5fef83dfe7b0a4dc73ed29e23ac955341eb01b71
child 289039 1c4c3d6c5fd36a066aba81b11b01ceb58f95e461
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian, sledru
bugs1175794
milestone42.0a2
Bug 1175794 - Remove use of variables on this for pageinfo. r=florian, a=sledru
browser/base/content/content.js
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -851,115 +851,114 @@ addMessageListener("ContextMenu:SetAsDes
 
 let pageInfoListener = {
 
   init: function(chromeGlobal) {
     chromeGlobal.addMessageListener("PageInfo:getData", this, false, true);
   },
 
   receiveMessage: function(message) {
-    this.strings = message.data.strings;
+    let strings = message.data.strings;
+    let window;
+    let document;
 
     let frameOuterWindowID = message.data.frameOuterWindowID;
 
     // If inside frame then get the frame's window and document.
     if (frameOuterWindowID) {
-      this.window = Services.wm.getOuterWindowWithId(frameOuterWindowID);
-      this.document = this.window.document;
+      window = Services.wm.getOuterWindowWithId(frameOuterWindowID);
+      document = window.document;
     }
     else {
-      this.document = content.document;
-      this.window = content.window;
+      window = content.window;
+      document = content.document;
     }
 
-    let pageInfoData = {metaViewRows: this.getMetaInfo(), docInfo: this.getDocumentInfo(),
-                        feeds: this.getFeedsInfo(), windowInfo: this.getWindowInfo()};
+    let pageInfoData = {metaViewRows: this.getMetaInfo(document),
+                        docInfo: this.getDocumentInfo(document),
+                        feeds: this.getFeedsInfo(document, strings),
+                        windowInfo: this.getWindowInfo(window)};
     sendAsyncMessage("PageInfo:data", pageInfoData);
 
     // Separate step so page info dialog isn't blank while waiting for this to finish.
-    let pageInfoMediaData = {imageViewRows: this.getMediaInfo(this.document, this.window, this.strings)};
-
-    this.strings = null;
-    this.window = null;
-    this.document = null;
-
+    let pageInfoMediaData = {imageViewRows: this.getMediaInfo(document, window, strings)};
     sendAsyncMessage("PageInfo:mediaData", pageInfoMediaData);
   },
 
-  getMetaInfo: function() {
+  getMetaInfo: function(document) {
     let metaViewRows = [];
 
     // Get the meta tags from the page.
-    let metaNodes = this.document.getElementsByTagName("meta");
+    let metaNodes = document.getElementsByTagName("meta");
 
     for (let metaNode of metaNodes) {
       metaViewRows.push([metaNode.name || metaNode.httpEquiv || metaNode.getAttribute("property"),
                         metaNode.content]);
     }
 
     return metaViewRows;
   },
 
-  getWindowInfo: function() {
+  getWindowInfo: function(window) {
     let windowInfo = {};
-    windowInfo.isTopWindow = this.window == this.window.top;
+    windowInfo.isTopWindow = window == window.top;
 
     let hostName = null;
     try {
-      hostName = this.window.location.host;
+      hostName = window.location.host;
     }
     catch (exception) { }
 
     windowInfo.hostName = hostName;
     return windowInfo;
   },
 
-  getDocumentInfo: function() {
+  getDocumentInfo: function(document) {
     let docInfo = {};
-    docInfo.title = this.document.title;
-    docInfo.location = this.document.location.toString();
-    docInfo.referrer = this.document.referrer;
-    docInfo.compatMode = this.document.compatMode;
-    docInfo.contentType = this.document.contentType;
-    docInfo.characterSet = this.document.characterSet;
-    docInfo.lastModified = this.document.lastModified;
+    docInfo.title = document.title;
+    docInfo.location = document.location.toString();
+    docInfo.referrer = document.referrer;
+    docInfo.compatMode = document.compatMode;
+    docInfo.contentType = document.contentType;
+    docInfo.characterSet = document.characterSet;
+    docInfo.lastModified = document.lastModified;
 
     let documentURIObject = {};
-    documentURIObject.spec = this.document.documentURIObject.spec;
-    documentURIObject.originCharset = this.document.documentURIObject.originCharset;
+    documentURIObject.spec = document.documentURIObject.spec;
+    documentURIObject.originCharset = document.documentURIObject.originCharset;
     docInfo.documentURIObject = documentURIObject;
 
     docInfo.isContentWindowPrivate = PrivateBrowsingUtils.isContentWindowPrivate(content);
 
     return docInfo;
   },
 
-  getFeedsInfo: function() {
+  getFeedsInfo: function(document, strings) {
     let feeds = [];
     // Get the feeds from the page.
-    let linkNodes = this.document.getElementsByTagName("link");
+    let linkNodes = document.getElementsByTagName("link");
     let length = linkNodes.length;
     for (let i = 0; i < length; i++) {
       let link = linkNodes[i];
       if (!link.href) {
         continue;
       }
       let rel = link.rel && link.rel.toLowerCase();
       let rels = {};
 
       if (rel) {
         for each (let relVal in rel.split(/\s+/)) {
           rels[relVal] = true;
         }
       }
 
       if (rels.feed || (link.type && rels.alternate && !rels.stylesheet)) {
-        let type = Feeds.isValidFeed(link, this.document.nodePrincipal, "feed" in rels);
+        let type = Feeds.isValidFeed(link, document.nodePrincipal, "feed" in rels);
         if (type) {
-          type = this.strings[type] || this.strings["application/rss+xml"];
+          type = strings[type] || strings["application/rss+xml"];
           feeds.push([link.title, type, link.href]);
         }
       }
     }
     return feeds;
   },
 
   // Only called once to get the media tab's media elements from the content page.