Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Unified Diff: ui/webui/resources/js/util.js

Issue 2163893003: Start sending auxclick instead of click for non-primary buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/util.js
diff --git a/ui/webui/resources/js/util.js b/ui/webui/resources/js/util.js
index ee6cd40a7d9d28df6767e7bfba459fa9ae68186b..759bfbbf308ac232374ffec3e12436f68882fbee 100644
--- a/ui/webui/resources/js/util.js
+++ b/ui/webui/resources/js/util.js
@@ -212,49 +212,51 @@ function queryRequiredElement(selectors, opt_context) {
// Handle click on a link. If the link points to a chrome: or file: url, then
// call into the browser to do the navigation.
-document.addEventListener('click', function(e) {
- if (e.defaultPrevented)
- return;
-
- var eventPath = e.path;
- var anchor = null;
- if (eventPath) {
- for (var i = 0; i < eventPath.length; i++) {
- var element = eventPath[i];
- if (element.tagName === 'A' && element.href) {
- anchor = element;
- break;
+['click', 'auxclick'].forEach(function(eventName) {
+ document.addEventListener(eventName, function(e) {
+ if (e.defaultPrevented)
+ return;
+
+ var eventPath = e.path;
+ var anchor = null;
+ if (eventPath) {
+ for (var i = 0; i < eventPath.length; i++) {
+ var element = eventPath[i];
+ if (element.tagName === 'A' && element.href) {
+ anchor = element;
+ break;
+ }
}
}
- }
- // Fallback if Event.path is not available.
- var el = e.target;
- if (!anchor && el.nodeType == Node.ELEMENT_NODE &&
- el.webkitMatchesSelector('A, A *')) {
- while (el.tagName != 'A') {
- el = el.parentElement;
+ // Fallback if Event.path is not available.
+ var el = e.target;
+ if (!anchor && el.nodeType == Node.ELEMENT_NODE &&
+ el.webkitMatchesSelector('A, A *')) {
+ while (el.tagName != 'A') {
+ el = el.parentElement;
+ }
+ anchor = el;
}
- anchor = el;
- }
- if (!anchor)
- return;
-
- anchor = /** @type {!HTMLAnchorElement} */(anchor);
- if ((anchor.protocol == 'file:' || anchor.protocol == 'about:') &&
- (e.button == 0 || e.button == 1)) {
- chrome.send('navigateToUrl', [
- anchor.href,
- anchor.target,
- e.button,
- e.altKey,
- e.ctrlKey,
- e.metaKey,
- e.shiftKey
- ]);
- e.preventDefault();
- }
+ if (!anchor)
+ return;
+
+ anchor = /** @type {!HTMLAnchorElement} */(anchor);
+ if ((anchor.protocol == 'file:' || anchor.protocol == 'about:') &&
+ (e.button == 0 || e.button == 1)) {
+ chrome.send('navigateToUrl', [
+ anchor.href,
+ anchor.target,
+ e.button,
+ e.altKey,
+ e.ctrlKey,
+ e.metaKey,
+ e.shiftKey
+ ]);
+ e.preventDefault();
+ }
+ });
});
/**
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698