Bug 1431255 - Part VI, Redirect target in ContextMenu.jsm to HTMLMediaElement
Set the referenced node to that of the containing media element so related
menu items will be shown in the context menu.
MozReview-Commit-ID: 4BKlINHmTSb
--- a/browser/actors/ContextMenuChild.jsm
+++ b/browser/actors/ContextMenuChild.jsm
@@ -686,17 +686,33 @@ class ContextMenuChild extends ActorChil
this.context = Object.create(null);
const context = this.context;
context.timeStamp = aEvent.timeStamp;
context.screenX = aEvent.screenX;
context.screenY = aEvent.screenY;
context.mozInputSource = aEvent.mozInputSource;
- const node = aEvent.composedTarget;
+ let node = aEvent.composedTarget;
+
+ // Set the node to containing <video>/<audio> if the node
+ // is in the videocontrols UA Widget.
+ if (this.content.ShadowRoot) {
+ let n = node;
+ while (n) {
+ if (n instanceof this.content.ShadowRoot) {
+ if (n.host instanceof this.content.HTMLMediaElement) {
+ node = n.host;
+ break;
+ }
+ break;
+ }
+ n = n.parentNode;
+ }
+ }
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
context.shouldDisplay = true;
if (node.nodeType == node.DOCUMENT_NODE ||
// Don't display for XUL element unless <label class="text-link">
(node.namespaceURI == XUL_NS && !this._isXULTextLinkLabel(node))) {