Bug 1799764 - Remove messenger, msgWindow and MsgStatusFeedback objects from about:message. r=aleca
These objects don't work quite right in this context, so I'm removing them and changing all references to use the top-level window instance, provided by mailWindow.js. Differential Revision: https://phabricator.services.mozilla.com/D161655 --HG-- extra : rebase_source : acee360a4b0a3c6c47568b958396a08b61df2426
This commit is contained in:
Родитель
38d6651d72
Коммит
faf0660c95
|
@ -5,8 +5,6 @@
|
|||
/* import-globals-from ../../../mail/base/content/msgHdrView.js */
|
||||
/* import-globals-from item-editing/calendar-item-editing.js */
|
||||
|
||||
/* globals msgWindow */
|
||||
|
||||
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
/**
|
||||
|
@ -93,7 +91,7 @@ var calImipBar = {
|
|||
let itipItem = null;
|
||||
try {
|
||||
if (!subject) {
|
||||
let sinkProps = msgWindow.msgHeaderSink.properties;
|
||||
let sinkProps = top.msgWindow.msgHeaderSink.properties;
|
||||
// This property was set by CalMimeConverter.jsm.
|
||||
itipItem = sinkProps.getPropertyAsInterface("itipItem", Ci.calIItipItem);
|
||||
}
|
||||
|
|
|
@ -111,25 +111,13 @@ function MailSetCharacterSet() {
|
|||
messageService.DisplayMessage(
|
||||
gMessageURI,
|
||||
content.docShell,
|
||||
msgWindow,
|
||||
top.msgWindow,
|
||||
null,
|
||||
true,
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
var messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
|
||||
var MsgStatusFeedback =
|
||||
window.browsingContext.topChromeWindow.MsgStatusFeedback;
|
||||
var msgWindow = Cc["@mozilla.org/messenger/msgwindow;1"].createInstance(
|
||||
Ci.nsIMsgWindow
|
||||
);
|
||||
msgWindow.domWindow = window;
|
||||
msgWindow.msgHeaderSink = window.messageHeaderSink;
|
||||
msgWindow.statusFeedback = Cc[
|
||||
"@mozilla.org/messenger/statusfeedback;1"
|
||||
].createInstance(Ci.nsIMsgStatusFeedback);
|
||||
|
||||
window.addEventListener("DOMContentLoaded", event => {
|
||||
if (event.target != document) {
|
||||
return;
|
||||
|
@ -148,16 +136,6 @@ window.addEventListener("DOMContentLoaded", event => {
|
|||
}
|
||||
|
||||
preferenceObserver.init();
|
||||
|
||||
// TODO: I really don't understand what's going on here. The messenger.xhtml
|
||||
// sink needs to be set or images in messageWindow.xhtml don't display.
|
||||
if (
|
||||
window.browsingContext.topChromeWindow.location.href ==
|
||||
"chrome://messenger/content/messenger.xhtml"
|
||||
) {
|
||||
window.browsingContext.topChromeWindow.msgWindow.msgHeaderSink =
|
||||
window.messageHeaderSink;
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener("unload", () => {
|
||||
|
@ -165,11 +143,7 @@ window.addEventListener("unload", () => {
|
|||
OnUnloadMsgHeaderPane();
|
||||
MailServices.mailSession.RemoveFolderListener(folderListener);
|
||||
preferenceObserver.cleanUp();
|
||||
msgWindow.msgHeaderSink = null;
|
||||
msgWindow.closeWindow();
|
||||
msgWindow = null;
|
||||
gViewWrapper?.close();
|
||||
window.browsingContext.topChromeWindow.msgWindow.msgHeaderSink = null;
|
||||
});
|
||||
|
||||
window.addEventListener("keypress", event => {
|
||||
|
@ -190,10 +164,16 @@ function displayExternalMessage(uri) {
|
|||
gViewWrapper.openSearchView();
|
||||
gDBView = gViewWrapper.dbView;
|
||||
|
||||
messenger.setWindow(window, msgWindow);
|
||||
messenger.loadURL(null, uri);
|
||||
|
||||
gMessage = messageHeaderSink.dummyMsgHeader;
|
||||
let messageService = MailServices.messageServiceFromURI(uri);
|
||||
messageService.DisplayMessage(
|
||||
uri,
|
||||
content.docShell,
|
||||
top.msgWindow,
|
||||
null,
|
||||
null,
|
||||
{}
|
||||
);
|
||||
gMessage = top.msgWindow.msgHeaderSink.dummyMsgHeader;
|
||||
}
|
||||
|
||||
function displayMessage(uri, viewWrapper) {
|
||||
|
@ -235,8 +215,6 @@ function displayMessage(uri, viewWrapper) {
|
|||
gViewWrapper.dbView.findIndexOfMsgHdr(gMessage, true)
|
||||
);
|
||||
gDBView = gViewWrapper.dbView;
|
||||
} else {
|
||||
gMessage = messageHeaderSink.dummyMsgHeader;
|
||||
}
|
||||
|
||||
MailE10SUtils.changeRemoteness(content, null);
|
||||
|
@ -245,20 +223,21 @@ function displayMessage(uri, viewWrapper) {
|
|||
content.docShell
|
||||
?.QueryInterface(Ci.nsIWebProgress)
|
||||
.addProgressListener(
|
||||
msgWindow.statusFeedback,
|
||||
top.msgWindow.statusFeedback,
|
||||
Ci.nsIWebProgress.NOTIFY_ALL
|
||||
);
|
||||
|
||||
// Ideally we'd do this without creating a msgWindow, and just pass the
|
||||
// docShell to the message service, but that's not easy yet.
|
||||
messageService.DisplayMessage(
|
||||
uri,
|
||||
content.docShell,
|
||||
msgWindow,
|
||||
top.msgWindow,
|
||||
null,
|
||||
null,
|
||||
{}
|
||||
);
|
||||
if (!gMessage) {
|
||||
gMessage = top.msgWindow.msgHeaderSink.dummyMsgHeader;
|
||||
}
|
||||
|
||||
if (gMessage.flags & Ci.nsMsgMessageFlags.HasRe) {
|
||||
document.title = `Re: ${gMessage.mime2DecodedSubject}`;
|
||||
|
|
|
@ -166,7 +166,7 @@ var commandController = {
|
|||
* @param {nsIMsgFolder} destFolder - the destination folder
|
||||
*/
|
||||
cmd_copyMessage(destFolder) {
|
||||
if (window.messageHeaderSink?.dummyMsgHeader) {
|
||||
if (window.gMessageURI.startsWith("file:")) {
|
||||
let file = Services.io
|
||||
.newURI(window.gMessageURI)
|
||||
.QueryInterface(Ci.nsIFileURL).file;
|
||||
|
@ -178,7 +178,7 @@ var commandController = {
|
|||
Ci.nsMsgMessageFlags.Read,
|
||||
"",
|
||||
null,
|
||||
window.msgWindow
|
||||
top.msgWindow
|
||||
);
|
||||
} else {
|
||||
gViewWrapper.dbView.doCommandWithFolder(
|
||||
|
@ -242,7 +242,7 @@ var commandController = {
|
|||
top.SaveAsTemplate(gDBView.getURIsForSelection()[0]);
|
||||
},
|
||||
cmd_applyFilters() {
|
||||
let curFilterList = gFolder.getFilterList(window.msgWindow);
|
||||
let curFilterList = gFolder.getFilterList(top.msgWindow);
|
||||
// Create a new filter list and copy over the enabled filters to it.
|
||||
// We do this instead of having the filter after the fact code ignore
|
||||
// disabled filters because the Filter Dialog filter after the fact
|
||||
|
@ -269,7 +269,7 @@ var commandController = {
|
|||
MailServices.filters.applyFiltersToFolders(
|
||||
tempFilterList,
|
||||
[gFolder],
|
||||
window.msgWindow
|
||||
top.msgWindow
|
||||
);
|
||||
},
|
||||
cmd_applyFiltersToSelection() {
|
||||
|
@ -279,7 +279,7 @@ var commandController = {
|
|||
Ci.nsMsgFilterType.Manual,
|
||||
selectedMessages,
|
||||
gFolder,
|
||||
window.msgWindow
|
||||
top.msgWindow
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -538,7 +538,7 @@ var commandController = {
|
|||
// If we're the hidden window, then we're not going to have a gFolderDisplay
|
||||
// to work out existing folders, so just use null.
|
||||
let msgFolder = gFolder;
|
||||
let msgUris = window.messageHeaderSink?.dummyMsgHeader
|
||||
let msgUris = top.msgWindow.msgHeaderSink.dummyMsgHeader
|
||||
? [window.gMessageURI]
|
||||
: gDBView?.getURIsForSelection();
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ var mailContextMenu = {
|
|||
);
|
||||
let isDummyMessage = !gFolder;
|
||||
let message = isDummyMessage
|
||||
? window.messageHeaderSink.dummyMsgHeader
|
||||
? top.msgWindow.msgHeaderSink.dummyMsgHeader
|
||||
: gDBView.hdrForFirstSelectedMessage;
|
||||
let folder = gViewWrapper.displayedFolder;
|
||||
let numSelectedMessages = isDummyMessage ? 1 : gDBView.numSelected;
|
||||
|
|
|
@ -178,6 +178,7 @@ function CreateMailWindowGlobals() {
|
|||
// get the messenger instance
|
||||
// eslint-disable-next-line no-global-assign
|
||||
messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
|
||||
messenger.setWindow(window, msgWindow);
|
||||
|
||||
window.addEventListener("blur", appIdleManager.onBlur);
|
||||
window.addEventListener("focus", appIdleManager.onFocus);
|
||||
|
@ -209,8 +210,87 @@ function CreateMailWindowGlobals() {
|
|||
msgWindow = Cc["@mozilla.org/messenger/msgwindow;1"].createInstance(
|
||||
Ci.nsIMsgWindow
|
||||
);
|
||||
msgWindow.msgHeaderSink = {
|
||||
processHeaders(headerNames, headerValues, dontCollectAddress) {},
|
||||
handleAttachment(contentType, url, displayName, uri, notDownloaded) {},
|
||||
addAttachmentField(field, value) {},
|
||||
onEndAllAttachments() {},
|
||||
onEndMsgHeaders(url) {},
|
||||
onEndMsgDownload(url) {},
|
||||
onMsgHasRemoteContent(msgHdr, contentURI, canOverride) {},
|
||||
resetProperties() {
|
||||
delete this.mProperties;
|
||||
},
|
||||
securityInfo: null,
|
||||
get dummyMsgHeader() {
|
||||
if (!this.mDummyMsgHeader) {
|
||||
this.mDummyMsgHeader = new nsDummyMsgHeader();
|
||||
}
|
||||
return this.mDummyMsgHeader;
|
||||
},
|
||||
get properties() {
|
||||
if (!this.mProperties) {
|
||||
this.mProperties = Cc[
|
||||
"@mozilla.org/hash-property-bag;1"
|
||||
].createInstance(Ci.nsIWritablePropertyBag2);
|
||||
}
|
||||
return this.mProperties;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function nsDummyMsgHeader() {}
|
||||
nsDummyMsgHeader.prototype = {
|
||||
mProperties: [],
|
||||
getProperty(aProperty) {
|
||||
return this.getStringProperty(aProperty);
|
||||
},
|
||||
setProperty(aProperty, aVal) {
|
||||
return this.setStringProperty(aProperty, aVal);
|
||||
},
|
||||
getStringProperty(aProperty) {
|
||||
if (aProperty in this.mProperties) {
|
||||
return this.mProperties[aProperty];
|
||||
}
|
||||
return "";
|
||||
},
|
||||
setStringProperty(aProperty, aVal) {
|
||||
this.mProperties[aProperty] = aVal;
|
||||
},
|
||||
getUint32Property(aProperty) {
|
||||
if (aProperty in this.mProperties) {
|
||||
return parseInt(this.mProperties[aProperty]);
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
setUint32Property(aProperty, aVal) {
|
||||
this.mProperties[aProperty] = aVal.toString();
|
||||
},
|
||||
markHasAttachments(hasAttachments) {},
|
||||
messageSize: 0,
|
||||
author: null,
|
||||
get mime2DecodedAuthor() {
|
||||
return this.author;
|
||||
},
|
||||
subject: "",
|
||||
get mime2DecodedSubject() {
|
||||
return this.subject;
|
||||
},
|
||||
recipients: null,
|
||||
get mime2DecodedRecipients() {
|
||||
return this.recipients;
|
||||
},
|
||||
ccList: null,
|
||||
listPost: null,
|
||||
messageId: null,
|
||||
date: 0,
|
||||
accountKey: "",
|
||||
flags: 0,
|
||||
// If you change us to return a fake folder, please update
|
||||
// folderDisplay.js's FolderDisplayWidget's selectedMessageIsExternal getter.
|
||||
folder: null,
|
||||
};
|
||||
|
||||
function toggleCaretBrowsing() {
|
||||
const enabledPref = "accessibility.browsewithcaret_shortcut.enabled";
|
||||
const warnPref = "accessibility.warn_on_browsewithcaret";
|
||||
|
|
|
@ -121,9 +121,6 @@ function delayedOnLoadMessageWindow() {
|
|||
|
||||
InitMsgWindow();
|
||||
|
||||
msgWindow.msgHeaderSink = messageBrowser.contentWindow.messageHeaderSink;
|
||||
messenger.setWindow(window, msgWindow);
|
||||
|
||||
// initialize the customizeDone method on the customizeable toolbar
|
||||
var toolbox = document.getElementById("mail-toolbox");
|
||||
toolbox.customizeDone = function(aEvent) {
|
||||
|
|
|
@ -516,6 +516,7 @@ var MsgHdrViewObserver = {
|
|||
*/
|
||||
var messageHeaderSink = {
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIMsgHeaderSink"]),
|
||||
|
||||
onStartHeaders() {
|
||||
this.mSaveHdr = null;
|
||||
// Every time we start to redisplay a message, check the view all headers
|
||||
|
@ -836,7 +837,7 @@ var messageHeaderSink = {
|
|||
|
||||
if (!this.mSaveHdr) {
|
||||
var messageUrl = url.QueryInterface(Ci.nsIMsgMessageUrl);
|
||||
this.mSaveHdr = messenger.msgHdrFromURI(messageUrl.uri);
|
||||
this.mSaveHdr = top.messenger.msgHdrFromURI(messageUrl.uri);
|
||||
}
|
||||
|
||||
// If we have no attachments, we hide the attachment icon in the message
|
||||
|
@ -1499,7 +1500,7 @@ AttachmentInfo.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
messenger.saveAttachment(
|
||||
top.messenger.saveAttachment(
|
||||
this.contentType,
|
||||
this.url,
|
||||
encodeURIComponent(this.name),
|
||||
|
@ -1524,7 +1525,7 @@ AttachmentInfo.prototype = {
|
|||
? "externalAttachmentNotFound"
|
||||
: "emptyAttachment"
|
||||
);
|
||||
msgWindow.promptDialog.alert(null, prompt);
|
||||
top.msgWindow.promptDialog.alert(null, prompt);
|
||||
} else {
|
||||
// @see MsgComposeCommands.js which has simililar opening functionality
|
||||
let dotPos = this.name.lastIndexOf(".");
|
||||
|
@ -1570,7 +1571,7 @@ AttachmentInfo.prototype = {
|
|||
// Just use the old method for handling messages, it works.
|
||||
|
||||
if (this.contentType == "message/rfc822") {
|
||||
window.browsingContext.topChromeWindow.messenger.openAttachment(
|
||||
top.messenger.openAttachment(
|
||||
this.contentType,
|
||||
this.url,
|
||||
encodeURIComponent(this.name),
|
||||
|
@ -1774,7 +1775,7 @@ AttachmentInfo.prototype = {
|
|||
* before detaching, false otherwise.
|
||||
*/
|
||||
detach(aSaveFirst) {
|
||||
messenger.detachAttachment(
|
||||
top.messenger.detachAttachment(
|
||||
this.contentType,
|
||||
this.url,
|
||||
encodeURIComponent(this.name),
|
||||
|
@ -2386,19 +2387,18 @@ function displayAttachmentsForExpandedViewExternal() {
|
|||
"tooltiptextexternalnotfound",
|
||||
externalAttachmentNotFound
|
||||
);
|
||||
attachmentName.setAttribute(
|
||||
"onmouseover",
|
||||
`MsgStatusFeedback.setOverLink("${displayUrl}")`
|
||||
attachmentName.addEventListener("mouseover", () =>
|
||||
top.MsgStatusFeedback.setOverLink(displayUrl)
|
||||
);
|
||||
attachmentName.setAttribute(
|
||||
"onmouseout",
|
||||
"MsgStatusFeedback.setOverLink('')"
|
||||
attachmentName.addEventListener("mouseout", () =>
|
||||
top.MsgStatusFeedback.setOverLink("")
|
||||
);
|
||||
attachmentName.setAttribute(
|
||||
"onfocus",
|
||||
`MsgStatusFeedback.setOverLink("${displayUrl}")`
|
||||
attachmentName.addEventListener("focus", () =>
|
||||
top.MsgStatusFeedback.setOverLink(displayUrl)
|
||||
);
|
||||
attachmentName.addEventListener("blur", () =>
|
||||
top.MsgStatusFeedback.setOverLink("")
|
||||
);
|
||||
attachmentName.setAttribute("onblur", "MsgStatusFeedback.setOverLink('')");
|
||||
attachmentName.classList.remove("text-link");
|
||||
attachmentName.classList.remove("notfound");
|
||||
|
||||
|
@ -2426,21 +2426,17 @@ function displayAttachmentsForExpandedViewExternal() {
|
|||
if (attachment.isExternalAttachment) {
|
||||
displayUrl = attachment.displayUrl;
|
||||
attachmentitem.setAttribute("tooltiptext", "");
|
||||
attachmentitem.setAttribute(
|
||||
"onmouseover",
|
||||
`MsgStatusFeedback.setOverLink("${displayUrl}")`
|
||||
attachmentitem.addEventListener("mouseover", () =>
|
||||
top.MsgStatusFeedback.setOverLink(displayUrl)
|
||||
);
|
||||
attachmentitem.setAttribute(
|
||||
"onmouseout",
|
||||
"MsgStatusFeedback.setOverLink('')"
|
||||
attachmentitem.addEventListener("mouseout", () =>
|
||||
top.MsgStatusFeedback.setOverLink("")
|
||||
);
|
||||
attachmentitem.setAttribute(
|
||||
"onfocus",
|
||||
`MsgStatusFeedback.setOverLink("${displayUrl}")`
|
||||
attachmentitem.addEventListener("focus", () =>
|
||||
top.MsgStatusFeedback.setOverLink(displayUrl)
|
||||
);
|
||||
attachmentitem.setAttribute(
|
||||
"onblur",
|
||||
"MsgStatusFeedback.setOverLink('')"
|
||||
attachmentitem.addEventListener("blur", () =>
|
||||
top.MsgStatusFeedback.setOverLink("")
|
||||
);
|
||||
|
||||
attachmentitem
|
||||
|
@ -2539,7 +2535,7 @@ function updateAttachmentsDisplay(attachmentInfo, isFetching) {
|
|||
if (attachmentInfo.size < 1) {
|
||||
sizeStr = bundle.getString("attachmentSizeUnknown");
|
||||
} else {
|
||||
sizeStr = messenger.formatFileSize(attachmentInfo.size);
|
||||
sizeStr = top.messenger.formatFileSize(attachmentInfo.size);
|
||||
}
|
||||
|
||||
// The attachment listitem.
|
||||
|
@ -2611,7 +2607,7 @@ function getAttachmentsTotalSizeStr() {
|
|||
}
|
||||
}
|
||||
|
||||
let sizeStr = messenger.formatFileSize(totalSize);
|
||||
let sizeStr = top.messenger.formatFileSize(totalSize);
|
||||
if (unknownSize) {
|
||||
if (totalSize == 0) {
|
||||
sizeStr = bundle.getString("attachmentSizeUnknown");
|
||||
|
@ -2964,7 +2960,7 @@ function HandleMultipleAttachments(attachments, action) {
|
|||
// The list has been built. Now call our action code...
|
||||
switch (action) {
|
||||
case "save":
|
||||
messenger.saveAllAttachments(
|
||||
top.messenger.saveAllAttachments(
|
||||
attachmentContentTypeArray,
|
||||
attachmentUrlArray,
|
||||
attachmentDisplayNameArray,
|
||||
|
@ -2978,7 +2974,7 @@ function HandleMultipleAttachments(attachments, action) {
|
|||
if (attachments.length == 1) {
|
||||
attachments[0].detach(true);
|
||||
} else {
|
||||
messenger.detachAllAttachments(
|
||||
top.messenger.detachAllAttachments(
|
||||
attachmentContentTypeArray,
|
||||
attachmentUrlArray,
|
||||
attachmentDisplayNameArray,
|
||||
|
@ -2988,7 +2984,7 @@ function HandleMultipleAttachments(attachments, action) {
|
|||
}
|
||||
return;
|
||||
case "delete":
|
||||
messenger.detachAllAttachments(
|
||||
top.messenger.detachAllAttachments(
|
||||
attachmentContentTypeArray,
|
||||
attachmentUrlArray,
|
||||
attachmentDisplayNameArray,
|
||||
|
@ -3884,7 +3880,7 @@ function OpenBrowserWithMessageId(messageId) {
|
|||
).data;
|
||||
browserURL = browserURL.replace(/%mid/, messageId);
|
||||
try {
|
||||
messenger.launchExternalURL(browserURL);
|
||||
top.messenger.launchExternalURL(browserURL);
|
||||
} catch (ex) {
|
||||
Cu.reportError(
|
||||
"Failed to open message-id in browser; browserURL=" + browserURL
|
||||
|
@ -3900,7 +3896,7 @@ function OpenBrowserWithMessageId(messageId) {
|
|||
* @param messageId the message id to open
|
||||
*/
|
||||
function OpenMessageForMessageId(messageId) {
|
||||
let startServer = msgWindow.openFolder.server;
|
||||
let startServer = gFolder?.server;
|
||||
|
||||
window.setCursor("wait");
|
||||
let { MailUtils } = ChromeUtils.import("resource:///modules/MailUtils.jsm");
|
||||
|
@ -4174,7 +4170,7 @@ function MsgReplyToListMessage(event) {
|
|||
function MsgArchiveSelectedMessages(event) {
|
||||
let archiver = new MessageArchiver();
|
||||
archiver.folderDisplay = gFolderDisplay;
|
||||
archiver.msgWindow = msgWindow;
|
||||
archiver.msgWindow = top.msgWindow;
|
||||
archiver.archiveMessages(gFolderDisplay.selectedMessages);
|
||||
}
|
||||
|
||||
|
@ -4845,7 +4841,7 @@ function OnMsgParsed(aUrl) {
|
|||
let selectedMessageUris = gFolderDisplay.selectedMessageUris;
|
||||
let msgURI = selectedMessageUris ? selectedMessageUris[0] : null;
|
||||
Services.obs.notifyObservers(
|
||||
msgWindow.msgHeaderSink,
|
||||
top.msgWindow.msgHeaderSink,
|
||||
"MsgMsgDisplayed",
|
||||
msgURI
|
||||
);
|
||||
|
@ -5036,7 +5032,7 @@ function HandleMDNResponse(aUrl) {
|
|||
const MDN_DISPOSE_TYPE_DISPLAYED = 0;
|
||||
let askUser = mdnGenerator.process(
|
||||
MDN_DISPOSE_TYPE_DISPLAYED,
|
||||
msgWindow,
|
||||
top.msgWindow,
|
||||
msgFolder,
|
||||
msgHdr.messageKey,
|
||||
mimeHdr,
|
||||
|
|
Загрузка…
Ссылка в новой задаче