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

Unified Diff: ui/webui/resources/js/cr/ui/focus_manager.js

Issue 18593003: Disable mouse-focus of buttons in some WebUI pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a public function to FocusManager Created 7 years, 5 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 | « chrome/browser/resources/uber/uber_frame.js ('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/cr/ui/focus_manager.js
diff --git a/ui/webui/resources/js/cr/ui/focus_manager.js b/ui/webui/resources/js/cr/ui/focus_manager.js
index e7ba2a8aca0d87252e9aafca5e41316a86a139ee..270e267d7ab78d22a2f9b97f8b84232c1def7df3 100644
--- a/ui/webui/resources/js/cr/ui/focus_manager.js
+++ b/ui/webui/resources/js/cr/ui/focus_manager.js
@@ -177,20 +177,35 @@ cr.define('cr.ui', function() {
true);
document.addEventListener('keydown', this.onDocumentKeyDown_.bind(this),
true);
-
- document.addEventListener('mousedown', function(event) {
- var tagName = event.target.tagName;
- if (tagName != 'BUTTON' && tagName != 'INPUT')
- return;
- var type = event.target.type;
- if (type == 'button' || type == 'reset' || type == 'submit' ||
- type == 'radio' || type == 'checkbox') {
- event.preventDefault();
- }
- }, false);
},
};
+ /**
+ * Disable mouse-focus for button controls.
+ * Button form controls are mouse-focusable since Chromium 30. We want the
+ * old behavior in some WebUI pages.
+ */
+ FocusManager.disableMouseFocusOnButtons = function() {
+ document.addEventListener('mousedown', function(event) {
+ if (event.button != 0)
+ return;
+ var node = event.target;
+ var tagName = node.tagName;
+ if (tagName != 'BUTTON' && tagName != 'INPUT') {
+ do {
+ node = node.parentNode;
+ if (!node || node.nodeType != Node.ELEMENT_NODE)
+ return;
+ } while (node.tagName != 'BUTTON');
+ }
+ var type = node.type;
+ if (type == 'button' || type == 'reset' || type == 'submit' ||
+ type == 'radio' || type == 'checkbox') {
+ event.preventDefault();
+ }
+ }, false);
+ };
+
return {
FocusManager: FocusManager,
};
« no previous file with comments | « chrome/browser/resources/uber/uber_frame.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698