Bug 1175794 - Rename and cleanup pageinfo code. r=florian
authorJimmy Wang <jiwang@mozilla.com>
Thu, 13 Aug 2015 03:37:02 -0400
changeset 258168 47b1d38a23f535775a03fcdf0749e295c473e6f0
parent 258167 d6d3b2e8dfc77e95a4c3c6339724464b425b4fc7
child 258169 40b5df5cdc590a00c484033dd253e2be3a76249e
push id63843
push userryanvm@gmail.com
push dateTue, 18 Aug 2015 14:58:06 +0000
treeherdermozilla-inbound@d55e24c983aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1175794
milestone43.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 1175794 - Rename and cleanup pageinfo code. r=florian
browser/base/content/browser.js
browser/base/content/content.js
browser/base/content/pageinfo/pageInfo.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2408,17 +2408,17 @@ function BrowserViewSource(browser) {
 // initialTab - name of the initial tab to display, or null for the first tab
 // imageElement - image to load in the Media Tab of the Page Info window; can be null/omitted
 // frameOuterWindowID - the id of the frame that the context menu opened in; can be null/omitted
 function BrowserPageInfo(doc, initialTab, imageElement, frameOuterWindowID) {
   var args = {doc: doc, initialTab: initialTab, imageElement: imageElement,
               frameOuterWindowID: frameOuterWindowID};
   var windows = Services.wm.getEnumerator("Browser:page-info");
 
-  var documentURL = doc ? doc.location : window.gBrowser.selectedBrowser.contentDocumentAsCPOW.location;
+  var documentURL = doc ? doc.location : window.gBrowser.selectedBrowser.currentURI.spec;
 
   // Check for windows matching the url
   while (windows.hasMoreElements()) {
     var currentWindow = windows.getNext();
     if (currentWindow.closed) {
       continue;
     }
     if (currentWindow.document.documentElement.getAttribute("relatedUrl") == documentURL) {
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -33,18 +33,18 @@ XPCOMUtils.defineLazyModuleGetter(this, 
   "resource://gre/modules/PageMetadata.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUIUtils",
   "resource:///modules/PlacesUIUtils.jsm");
 XPCOMUtils.defineLazyGetter(this, "PageMenuChild", function() {
   let tmp = {};
   Cu.import("resource://gre/modules/PageMenu.jsm", tmp);
   return new tmp.PageMenuChild();
 });
-
-XPCOMUtils.defineLazyModuleGetter(this, "Feeds", "resource:///modules/Feeds.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Feeds",
+  "resource:///modules/Feeds.jsm");
 
 // TabChildGlobal
 var global = this;
 
 // Load the form validation popup handler
 var formSubmitObserver = new FormSubmitObserver(content, this);
 
 addMessageListener("ContextMenu:DoCustomCommand", function(message) {
@@ -844,20 +844,20 @@ addMessageListener("ContextMenu:SetAsDes
       disable = true;
     }
   }
 
   if (disable)
     sendAsyncMessage("ContextMenu:SetAsDesktopBackground:Result", { disable });
 });
 
-let pageInfoListener = {
+let PageInfoListener = {
 
-  init: function(chromeGlobal) {
-    chromeGlobal.addMessageListener("PageInfo:getData", this, false, true);
+  init: function() {
+    addMessageListener("PageInfo:getData", this);
   },
 
   receiveMessage: function(message) {
     let strings = message.data.strings;
     let window;
     let document;
 
     let frameOuterWindowID = message.data.frameOuterWindowID;
@@ -969,17 +969,17 @@ let pageInfoListener = {
   },
 
   goThroughFrames: function(document, window)
   {
     let frameList = [document];
     if (window && window.frames.length > 0) {
       let num = window.frames.length;
       for (let i = 0; i < num; i++) {
-        // recurse through the frames
+        // Recurse through the frames.
         frameList.concat(this.goThroughFrames(window.frames[i].document,
                                               window.frames[i]));
       }
     }
     return frameList;
   },
 
   processFrames: function(document, frameList, strings)
@@ -1119,17 +1119,17 @@ let pageInfoListener = {
         result.mimeType = imageRequest.mimeType;
         let image = !(imageRequest.imageStatus & imageRequest.STATUS_ERROR) && imageRequest.image;
         if (image) {
           result.numFrames = image.numFrames;
         }
       }
     }
 
-    // if we have a data url, get the MIME type from the url
+    // If we have a data url, get the MIME type from the url.
     if (!result.mimeType && url.startsWith("data:")) {
       let dataMimeType = /^data:(image\/[^;,]+)/i.exec(url);
       if (dataMimeType)
         result.mimeType = dataMimeType[1].toLowerCase();
     }
 
     result.HTMLLinkElement = item instanceof content.HTMLLinkElement;
     result.HTMLInputElement = item instanceof content.HTMLInputElement;
@@ -1219,9 +1219,9 @@ let pageInfoListener = {
   {
     let middleRE = /\s+/g;
     let endRE = /(^\s+)|(\s+$)/g;
 
     text = text.replace(middleRE, " ");
     return text.replace(endRE, "");
   }
 };
-pageInfoListener.init(this);
\ No newline at end of file
+PageInfoListener.init();
\ No newline at end of file
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -371,18 +371,18 @@ function loadPageInfo(frameOuterWindowID
     mm.removeMessageListener("PageInfo:data", onmessage);
     pageInfoData = message.data;
     let docInfo = pageInfoData.docInfo;
     let windowInfo = pageInfoData.windowInfo;
     let uri = makeURI(docInfo.documentURIObject.spec,
                       docInfo.documentURIObject.originCharset);
     gDocInfo = docInfo;
 
-    var titleFormat = windowInfo.isTopWindow ? "pageInfo.frame.title"
-                                             : "pageInfo.page.title";
+    var titleFormat = windowInfo.isTopWindow ? "pageInfo.page.title"
+                                             : "pageInfo.frame.title";
     document.title = gBundle.getFormattedString(titleFormat, [docInfo.location]);
 
     document.getElementById("main-window").setAttribute("relatedUrl", docInfo.location);
 
     makeGeneralTab(pageInfoData.metaViewRows, docInfo);
     initFeedTab(pageInfoData.feeds);
     onLoadPermission(uri);
     securityOnLoad(uri, windowInfo);