mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 708048 - Use highlight element for context menu title. r=kats
This commit is contained in:
parent
d12cac07ea
commit
e5f624e686
@ -1426,15 +1426,30 @@ var NativeWindow = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get _target() {
|
||||||
|
if (this._targetRef)
|
||||||
|
return this._targetRef.get();
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
|
||||||
|
set _target(aTarget) {
|
||||||
|
if (aTarget)
|
||||||
|
this._targetRef = Cu.getWeakReference(aTarget);
|
||||||
|
else this._targetRef = null;
|
||||||
|
},
|
||||||
|
|
||||||
_sendToContent: function(aX, aY) {
|
_sendToContent: function(aX, aY) {
|
||||||
// _highlightElement should already be fluffed to find nearby clickable elements
|
// _highlightElement should already be fluffed to find nearby clickable elements
|
||||||
let rootElement = BrowserEventHandler._highlightElement;
|
let target = BrowserEventHandler._highlightElement;
|
||||||
|
if (!target)
|
||||||
|
return;
|
||||||
|
|
||||||
this.menuitems = {};
|
this.menuitems = {};
|
||||||
let menuitemsSet = false;
|
let menuitemsSet = false;
|
||||||
let element = rootElement;
|
this._target = target;
|
||||||
if (!element)
|
|
||||||
return;
|
// now walk up the tree and for each node look for any context menu items that apply
|
||||||
|
let element = target;
|
||||||
|
|
||||||
while (element) {
|
while (element) {
|
||||||
for each (let item in this.items) {
|
for each (let item in this.items) {
|
||||||
@ -1451,36 +1466,46 @@ var NativeWindow = {
|
|||||||
|
|
||||||
// only send the contextmenu event to content if we are planning to show a context menu (i.e. not on every long tap)
|
// only send the contextmenu event to content if we are planning to show a context menu (i.e. not on every long tap)
|
||||||
if (menuitemsSet) {
|
if (menuitemsSet) {
|
||||||
let event = rootElement.ownerDocument.createEvent("MouseEvent");
|
let event = target.ownerDocument.createEvent("MouseEvent");
|
||||||
event.initMouseEvent("contextmenu", true, true, content,
|
event.initMouseEvent("contextmenu", true, true, content,
|
||||||
0, aX, aY, aX, aY, false, false, false, false,
|
0, aX, aY, aX, aY, false, false, false, false,
|
||||||
0, null);
|
0, null);
|
||||||
rootElement.ownerDocument.defaultView.addEventListener("contextmenu", this, false);
|
target.ownerDocument.defaultView.addEventListener("contextmenu", this, false);
|
||||||
rootElement.dispatchEvent(event);
|
target.dispatchEvent(event);
|
||||||
} else if (SelectionHandler.canSelect(rootElement)) {
|
} else {
|
||||||
|
this._target = null;
|
||||||
BrowserEventHandler._cancelTapHighlight();
|
BrowserEventHandler._cancelTapHighlight();
|
||||||
SelectionHandler.startSelection(rootElement, aX, aY);
|
|
||||||
|
if (SelectionHandler.canSelect(target))
|
||||||
|
SelectionHandler.startSelection(target, aX, aY);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_show: function(aEvent) {
|
_show: function(aEvent) {
|
||||||
BrowserEventHandler._cancelTapHighlight();
|
BrowserEventHandler._cancelTapHighlight();
|
||||||
if (aEvent.defaultPrevented)
|
let popupNode = this._target;
|
||||||
|
this._target = null;
|
||||||
|
if (aEvent.defaultPrevented || !popupNode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Haptic.performSimpleAction(Haptic.LongPress);
|
Haptic.performSimpleAction(Haptic.LongPress);
|
||||||
|
|
||||||
let popupNode = aEvent.originalTarget;
|
|
||||||
let title = "";
|
let title = "";
|
||||||
if (popupNode.hasAttribute("title")) {
|
|
||||||
title = popupNode.getAttribute("title")
|
// spin through the tree looking for a title for this context menu
|
||||||
} else if ((popupNode instanceof Ci.nsIDOMHTMLAnchorElement && popupNode.href) ||
|
let node = popupNode;
|
||||||
(popupNode instanceof Ci.nsIDOMHTMLAreaElement && popupNode.href)) {
|
while(node && !title) {
|
||||||
title = this._getLinkURL(popupNode);
|
if (node.hasAttribute("title")) {
|
||||||
} else if (popupNode instanceof Ci.nsIImageLoadingContent && popupNode.currentURI) {
|
title = node.getAttribute("title")
|
||||||
title = popupNode.currentURI.spec;
|
} else if ((node instanceof Ci.nsIDOMHTMLAnchorElement && node.href) ||
|
||||||
} else if (popupNode instanceof Ci.nsIDOMHTMLMediaElement) {
|
(node instanceof Ci.nsIDOMHTMLAreaElement && node.href)) {
|
||||||
title = (popupNode.currentSrc || popupNode.src);
|
title = this._getLinkURL(node);
|
||||||
|
} else if (node instanceof Ci.nsIImageLoadingContent && node.currentURI) {
|
||||||
|
title = node.currentURI.spec;
|
||||||
|
} else if (node instanceof Ci.nsIDOMHTMLMediaElement) {
|
||||||
|
title = (node.currentSrc || node.src);
|
||||||
|
}
|
||||||
|
node = node.parentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert this.menuitems object to an array for sending to native code
|
// convert this.menuitems object to an array for sending to native code
|
||||||
|
Loading…
Reference in New Issue
Block a user