Bug 1237025 - Stop using CPOWs for View Image Info context menu r=mconley

This commit is contained in:
George Wright 2016-01-19 19:21:49 -05:00
Родитель 666423b6d5
Коммит 3996b5e615
3 изменённых файлов: 27 добавлений и 12 удалений

Просмотреть файл

@ -1046,16 +1046,33 @@ var PageInfoListener = {
document = content.document;
}
let imageElement = message.objects.imageElement;
let pageInfoData = {metaViewRows: this.getMetaInfo(document),
docInfo: this.getDocumentInfo(document),
feeds: this.getFeedsInfo(document, strings),
windowInfo: this.getWindowInfo(window)};
windowInfo: this.getWindowInfo(window),
imageInfo: this.getImageInfo(imageElement)};
sendAsyncMessage("PageInfo:data", pageInfoData);
// Separate step so page info dialog isn't blank while waiting for this to finish.
this.getMediaInfo(document, window, strings);
},
getImageInfo: function(imageElement) {
let imageInfo = null;
if (imageElement) {
imageInfo = {
currentSrc: imageElement.currentSrc,
width: imageElement.width,
height: imageElement.height,
imageText: imageElement.title || imageElement.alt
};
}
return imageInfo;
},
getMetaInfo: function(document) {
let metaViewRows = [];

Просмотреть файл

@ -1069,6 +1069,9 @@ nsContextMenu.prototype = {
},
viewImageInfo: function() {
// Don't need to pass in ownerDocument.defaultView.top.document here;
// window.gBrowser.selectedBrowser.currentURI.spec does the job without
// using CPOWs
BrowserPageInfo(null, "mediaTab", this.target);
},

Просмотреть файл

@ -349,7 +349,7 @@ function onLoadPageInfo()
.notifyObservers(window, "page-info-dialog-loaded", null);
}
function loadPageInfo(frameOuterWindowID)
function loadPageInfo(frameOuterWindowID, imageElement)
{
let mm = window.opener.gBrowser.selectedBrowser.messageManager;
@ -361,7 +361,8 @@ function loadPageInfo(frameOuterWindowID)
// Look for pageInfoListener in content.js. Sends message to listener with arguments.
mm.sendAsyncMessage("PageInfo:getData", {strings: gStrings,
frameOuterWindowID: frameOuterWindowID});
frameOuterWindowID: frameOuterWindowID},
{ imageElement });
let pageInfoData;
@ -375,6 +376,8 @@ function loadPageInfo(frameOuterWindowID)
docInfo.documentURIObject.originCharset);
gDocInfo = docInfo;
gImageElement = pageInfoData.imageInfo;
var titleFormat = windowInfo.isTopWindow ? "pageInfo.page.title"
: "pageInfo.frame.title";
document.title = gBundle.getFormattedString(titleFormat, [docInfo.location]);
@ -478,19 +481,11 @@ function loadTab(args)
// If the "View Image Info" context menu item was used, the related image
// element is provided as an argument. This can't be a background image.
let imageElement = args && args.imageElement;
if (imageElement) {
gImageElement = {currentSrc: imageElement.currentSrc,
width: imageElement.width, height: imageElement.height,
imageText: imageElement.title || imageElement.alt};
}
else {
gImageElement = null;
}
let frameOuterWindowID = args && args.frameOuterWindowID;
/* Load the page info */
loadPageInfo(frameOuterWindowID);
loadPageInfo(frameOuterWindowID, imageElement);
var initialTab = (args && args.initialTab) || "generalTab";
var radioGroup = document.getElementById("viewGroup");