mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1156615 - (Browser API) ctrl/cmd/middle-click doesn't work if <a> element has children. r=kchen
This commit is contained in:
parent
cebfaf9b82
commit
f7a3bfe4d5
@ -585,13 +585,25 @@ BrowserElementChild.prototype = {
|
||||
},
|
||||
|
||||
_ClickHandler: function(e) {
|
||||
let elem = e.target;
|
||||
if (elem instanceof Ci.nsIDOMHTMLAnchorElement && elem.href) {
|
||||
// Open in a new tab if middle click or ctrl/cmd-click.
|
||||
if ((Services.appinfo.OS == 'Darwin' && e.metaKey) ||
|
||||
(Services.appinfo.OS != 'Darwin' && e.ctrlKey) ||
|
||||
e.button == 1) {
|
||||
sendAsyncMsg('opentab', {url: elem.href});
|
||||
|
||||
let isHTMLLink = node =>
|
||||
((node instanceof Ci.nsIDOMHTMLAnchorElement && node.href) ||
|
||||
(node instanceof Ci.nsIDOMHTMLAreaElement && node.href) ||
|
||||
node instanceof Ci.nsIDOMHTMLLinkElement);
|
||||
|
||||
// Open in a new tab if middle click or ctrl/cmd-click,
|
||||
// and e.target is a link or inside a link.
|
||||
if ((Services.appinfo.OS == 'Darwin' && e.metaKey) ||
|
||||
(Services.appinfo.OS != 'Darwin' && e.ctrlKey) ||
|
||||
e.button == 1) {
|
||||
|
||||
let node = e.target;
|
||||
while (node && !isHTMLLink(node)) {
|
||||
node = node.parentNode;
|
||||
}
|
||||
|
||||
if (node) {
|
||||
sendAsyncMsg('opentab', {url: node.href});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -51,7 +51,7 @@ function runTest() {
|
||||
iframe.sendMouseEvent('mouseup', x, y, 1, 1, 0);
|
||||
}
|
||||
|
||||
let onMiddleClick= e => {
|
||||
let onMiddleClick = e => {
|
||||
is(e.detail.url, 'http://example.com/', 'URL matches');
|
||||
iframe.removeEventListener('mozbrowseropentab', onMiddleClick);
|
||||
SimpleTest.finish();
|
||||
@ -63,7 +63,7 @@ function runTest() {
|
||||
});
|
||||
|
||||
|
||||
iframe.src = 'data:text/html,<body style="margin:0"><a href="http://example.com">click here</a></body>';
|
||||
iframe.src = 'data:text/html,<body style="margin:0"><a href="http://example.com"><span>click here</span></a></body>';
|
||||
}
|
||||
|
||||
addEventListener('testready', runTest);
|
||||
|
Loading…
Reference in New Issue
Block a user