Bug 1459284 - Ensure GeckoView context menus work with ShadowDOM. r?snorp
MozReview-Commit-ID: 5XrGRgSvh0g
--- a/mobile/android/chrome/geckoview/GeckoViewContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewContent.js
@@ -200,17 +200,17 @@ class GeckoViewContent extends GeckoView
case "contextmenu":
function nearestParentHref(node) {
while (node && !node.href) {
node = node.parentNode;
}
return node && node.href;
}
- const node = aEvent.target;
+ const node = aEvent.composedTarget;
const hrefNode = nearestParentHref(node);
const elementType = ChromeUtils.getClassName(node);
const isImage = elementType === "HTMLImageElement";
const isMedia = elementType === "HTMLVideoElement" ||
elementType === "HTMLAudioElement";
if (hrefNode || isImage || isMedia) {
this.eventDispatcher.sendRequest({
--- a/mobile/android/components/geckoview/GeckoViewPrompt.js
+++ b/mobile/android/components/geckoview/GeckoViewPrompt.js
@@ -158,17 +158,17 @@ PromptFactory.prototype = {
_dispatchEvents: function(aElement) {
// Fire both "input" and "change" events for <select> and <input>.
aElement.dispatchEvent(new aElement.ownerGlobal.Event("input", { bubbles: true }));
aElement.dispatchEvent(new aElement.ownerGlobal.Event("change", { bubbles: true }));
},
_handleContextMenu: function(aEvent) {
- let target = aEvent.target;
+ let target = aEvent.composedTarget;
if (aEvent.defaultPrevented || target.isContentEditable) {
return;
}
// Look through all ancestors for a context menu per spec.
let parent = target;
let menu = target.contextMenu;
while (!menu && parent) {