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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/common/focus_util.js

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 * @fileoverview A collection of JavaScript utilities used to manage focus 6 * @fileoverview A collection of JavaScript utilities used to manage focus
7 * within a document. 7 * within a document.
8 */ 8 */
9 9
10 10
11 goog.provide('cvox.FocusUtil'); 11 goog.provide('cvox.FocusUtil');
12 12
13 13
14 /** 14 /**
15 * Utilities for managing focus. 15 * Utilities for managing focus.
16 * @constructor 16 * @constructor
17 */ 17 */
18 cvox.FocusUtil = function() { 18 cvox.FocusUtil = function() {};
19 };
20 19
21 /** 20 /**
22 * Maps whether an input element of specified type accepts text selection or 21 * Maps whether an input element of specified type accepts text selection or
23 * not. True if the element does accept text selection, false if it does not. 22 * not. True if the element does accept text selection, false if it does not.
24 * This can be used to determine whether a visitor to that element should 23 * This can be used to determine whether a visitor to that element should
25 * provide interactive text editing to the user. 24 * provide interactive text editing to the user.
26 * From the W3C table of possible type keywords: 25 * From the W3C table of possible type keywords:
27 * http://www.w3.org/TR/html5/the-input-element.html#attr-input-type 26 * http://www.w3.org/TR/html5/the-input-element.html#attr-input-type
28 * 27 *
29 * TODO(dmazzoni): merge this with cvox.DomUtil.isInputTypeText 28 * TODO(dmazzoni): merge this with cvox.DomUtil.isInputTypeText
30 * 29 *
31 * @type {Object} 30 * @type {Object}
32 */ 31 */
33 cvox.FocusUtil.INPUT_TYPE_ACCEPTS_SELECTION_TABLE = { 32 cvox.FocusUtil.INPUT_TYPE_ACCEPTS_SELECTION_TABLE = {
34 'hidden' : false, 33 'hidden': false,
35 'text' : true, 34 'text': true,
36 'search' : true, 35 'search': true,
37 'tel' : true, 36 'tel': true,
38 'url' : true, 37 'url': true,
39 'email' : true, 38 'email': true,
40 'password' : true, 39 'password': true,
41 'datetime' : false, 40 'datetime': false,
42 'date' : false, 41 'date': false,
43 'month' : false, 42 'month': false,
44 'week' : false, 43 'week': false,
45 'time' : false, 44 'time': false,
46 'datetime-local' : false, 45 'datetime-local': false,
47 'number' : false, 46 'number': false,
48 'range' : false, 47 'range': false,
49 'color' : false, 48 'color': false,
50 'checkbox' : false, 49 'checkbox': false,
51 'radio' : false, 50 'radio': false,
52 'file' : false, 51 'file': false,
53 'submit' : false, 52 'submit': false,
54 'image' : false, 53 'image': false,
55 'reset' : false, 54 'reset': false,
56 'button' : false 55 'button': false
57 }; 56 };
58 57
59 /** 58 /**
60 * Checks if the currently focused element is a field that accepts text input 59 * Checks if the currently focused element is a field that accepts text input
61 * (This can include text fields and selectors) 60 * (This can include text fields and selectors)
62 * 61 *
63 * @return {boolean} True if the currently focused element accepts text input. 62 * @return {boolean} True if the currently focused element accepts text input.
64 */ 63 */
65 cvox.FocusUtil.isFocusInTextInputField = function() { 64 cvox.FocusUtil.isFocusInTextInputField = function() {
66 var activeElement = document.activeElement; 65 var activeElement = document.activeElement;
(...skipping 22 matching lines...) Expand all
89 if (activeElement.tagName === 'INPUT') { 88 if (activeElement.tagName === 'INPUT') {
90 if (!activeElement.hasAttribute('type')) { 89 if (!activeElement.hasAttribute('type')) {
91 return true; 90 return true;
92 } else { 91 } else {
93 var activeType = activeElement.getAttribute('type').toLowerCase(); 92 var activeType = activeElement.getAttribute('type').toLowerCase();
94 return cvox.FocusUtil.INPUT_TYPE_ACCEPTS_SELECTION_TABLE[activeType]; 93 return cvox.FocusUtil.INPUT_TYPE_ACCEPTS_SELECTION_TABLE[activeType];
95 } 94 }
96 } 95 }
97 return false; 96 return false;
98 }; 97 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698