diff options
Diffstat (limited to 'comm/mail/actors/ContextMenuParent.sys.mjs')
-rw-r--r-- | comm/mail/actors/ContextMenuParent.sys.mjs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/comm/mail/actors/ContextMenuParent.sys.mjs b/comm/mail/actors/ContextMenuParent.sys.mjs new file mode 100644 index 0000000000..5cf1d5dbe2 --- /dev/null +++ b/comm/mail/actors/ContextMenuParent.sys.mjs @@ -0,0 +1,45 @@ +/* vim: set ts=2 sw=2 et tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. */ + +export class ContextMenuParent extends JSWindowActorParent { + receiveMessage(message) { + if (message.name != "contextmenu") { + return; + } + + let browser = this.manager.rootFrameLoader.ownerElement; + let win = browser.ownerGlobal.top; + + // Send events from a message display browser to about:3pane or + // about:message if possible. + let tabmail = win.document.getElementById("tabmail"); + if (tabmail) { + let chromeBrowser = tabmail.currentTabInfo.chromeBrowser; + if ( + chromeBrowser?.contentWindow.openContextMenu(message, browser, this) + ) { + return; + } + } + let messageBrowser = win.document.getElementById("messageBrowser"); + if (messageBrowser?.contentWindow.openContextMenu(message, browser, this)) { + return; + } + + // Otherwise, send them to the outer window. + if ("openContextMenu" in win) { + win.openContextMenu(message, browser, this); + } + } + + hiding() { + try { + this.sendAsyncMessage("ContextMenu:Hiding", {}); + } catch (e) { + // This will throw if the content goes away while the + // context menu is still open. + } + } +} |