-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚧 WIP: Begin rework of context menu actors
- Loading branch information
1 parent
1763691
commit 5b6579b
Showing
6 changed files
with
237 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,43 @@ | ||
/* 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/. */ | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const { ContentDOMReference } = ChromeUtils.importESModule( | ||
"resource://gre/modules/ContentDOMReference.sys.mjs" | ||
); | ||
|
||
export class DotContextMenuParent extends JSWindowActorParent { | ||
/** @param {import("third_party/dothq/gecko-types/lib").ReceiveMessageArgument<>} message */ | ||
/** | ||
* Handles incoming messages to the context menu parent | ||
* @param {import("third_party/dothq/gecko-types/lib").ReceiveMessageArgument} message | ||
*/ | ||
receiveMessage(message) { | ||
if (message.name !== "contextmenu") return; | ||
// Attempt to resolve the target in the event, | ||
// otherwise, check if we're inside a browser, | ||
// otehrwise, use the top chrome window. | ||
const target = /** @type {Element} */ ( | ||
ContentDOMReference.resolve(message.data.target) || | ||
this.browsingContext.embedderElement || | ||
this.browsingContext.topChromeWindow | ||
); | ||
|
||
const browser = this.manager.rootFrameLoader.ownerElement; | ||
const win = browser.ownerGlobal; | ||
const win = target.ownerGlobal; | ||
const doc = target.ownerDocument; | ||
|
||
// Make sure this browser belongs to us before we open the panel | ||
if (win.gDot && win.gDot.tabs.getTabForWebContents(browser)) { | ||
const { x, y, context } = message.data; | ||
console.log("ParentReceive", target, message.data.context); | ||
|
||
console.log(x, y, context); | ||
} | ||
} | ||
const menuEvent = new /** @type {any} */ (win).CustomEvent( | ||
"ContextMenu::Launch", | ||
{ | ||
detail: message.data, | ||
composed: true, | ||
bubbles: true | ||
} | ||
); | ||
|
||
console.log("ParentSend", target, menuEvent); | ||
|
||
target.dispatchEvent(menuEvent); | ||
|
||
hiding() { | ||
try { | ||
this.sendAsyncMessage("ContextMenu:Hiding", {}); | ||
} catch (e) { | ||
// This will throw if the content goes away while the | ||
// context menu is still open. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters