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

Side by Side Diff: chrome/browser/resources/shared/js/util.js

Issue 6574045: Merge 75149 - WebUI: Fix middle click link issue in click handler... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/648/src/
Patch Set: Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * The global object. 6 * The global object.
7 * @param {!Object} 7 * @param {!Object}
8 */ 8 */
9 const global = this; 9 const global = this;
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 var afterA = a.nextSibling; 101 var afterA = a.nextSibling;
102 if (afterA == b) { 102 if (afterA == b) {
103 swapDomNodes(b, a); 103 swapDomNodes(b, a);
104 return; 104 return;
105 } 105 }
106 var aParent = a.parentNode; 106 var aParent = a.parentNode;
107 b.parentNode.replaceChild(a, b); 107 b.parentNode.replaceChild(a, b);
108 aParent.insertBefore(b, afterA); 108 aParent.insertBefore(b, afterA);
109 } 109 }
110 110
111 /* 111 // Handle click on a link. If the link points to a chrome: or file: url, then
112 * Handles a click or mouseup on a link. If the link points to a chrome: or 112 // call into the browser to do the navigation.
113 * file: url, then call into the browser to do the navigation. 113 document.addEventListener('click', function(e) {
114 * @return {Object} e The click or mouseup event.
115 */
116 function handleLinkClickOrMouseUp(e) {
117 var el = e.target; 114 var el = e.target;
118 if (el.nodeType == Node.ELEMENT_NODE && 115 if (el.nodeType == Node.ELEMENT_NODE &&
119 el.webkitMatchesSelector('A, A *')) { 116 el.webkitMatchesSelector('A, A *')) {
120 while (el.tagName != 'A') { 117 while (el.tagName != 'A') {
121 el = el.parentElement; 118 el = el.parentElement;
122 } 119 }
123 120
124 if ((el.protocol == 'file:' || el.protocol == 'about:') && 121 if ((el.protocol == 'file:' || el.protocol == 'about:') &&
125 ((e.button == 0 && e.type == 'click') || 122 (e.button == 0 || e.button == 1)) {
126 (e.button == 1 && e.type == 'mouseup'))) {
127 chrome.send('navigateToUrl', 123 chrome.send('navigateToUrl',
128 [el.href, String(e.button), String(e.ctrlKey), String(e.shiftKey), 124 [el.href, e.button, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey]);
129 String(e.altKey)]);
130 e.preventDefault(); 125 e.preventDefault();
131 } 126 }
132 } 127 }
133 } 128 });
134
135 document.addEventListener('click', handleLinkClickOrMouseUp, true);
136 document.addEventListener('mouseup', handleLinkClickOrMouseUp, true);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698