OLD | NEW |
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 Some utilities for defining what groups are. | 6 * @fileoverview Some utilities for defining what groups are. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 goog.provide('cvox.GroupUtil'); | 10 goog.provide('cvox.GroupUtil'); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 'input,' + | 53 'input,' + |
54 'object,' + | 54 'object,' + |
55 'ol,' + | 55 'ol,' + |
56 'p,' + | 56 'p,' + |
57 'pre,' + | 57 'pre,' + |
58 'select,' + | 58 'select,' + |
59 'table,' + | 59 'table,' + |
60 'tr,' + | 60 'tr,' + |
61 'ul,' + | 61 'ul,' + |
62 'math,' + | 62 'math,' + |
63 // This takes care of MathJax expressions. | 63 // This takes care of MathJax expressions. |
64 'span.math,' + | 64 'span.math,' + |
65 // TODO (sorge) Do we want to group all math or only display math? | 65 // TODO (sorge) Do we want to group all math or only display math? |
66 // '[mode="display"],' + | 66 // '[mode="display"],' + |
67 // Aria widget roles | 67 // Aria widget roles |
68 '[role~="alert ' + | 68 '[role~="alert ' + |
69 'alertdialog ' + | 69 'alertdialog ' + |
70 'button ' + | 70 'button ' + |
71 'checkbox ' + | 71 'checkbox ' + |
72 'combobox ' + | 72 'combobox ' + |
73 'dialog ' + | 73 'dialog ' + |
74 'log ' + | 74 'log ' + |
75 'marquee ' + | 75 'marquee ' + |
76 'menubar ' + | 76 'menubar ' + |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // TODO (stoarca): Write test to make sure that this function satisfies | 112 // TODO (stoarca): Write test to make sure that this function satisfies |
113 // the restriction given above. | 113 // the restriction given above. |
114 if (node.tagName == 'LABEL') { | 114 if (node.tagName == 'LABEL') { |
115 return cvox.DomUtil.isLeafNode(node); | 115 return cvox.DomUtil.isLeafNode(node); |
116 } | 116 } |
117 if (cvox.DomUtil.isLeafNode(node)) { | 117 if (cvox.DomUtil.isLeafNode(node)) { |
118 return true; | 118 return true; |
119 } | 119 } |
120 | 120 |
121 if (!cvox.DomUtil.isSemanticElt(node)) { | 121 if (!cvox.DomUtil.isSemanticElt(node)) { |
122 var breakingNodes = node.querySelectorAll( | 122 var breakingNodes = |
123 cvox.GroupUtil.BREAKOUT_SELECTOR_); | 123 node.querySelectorAll(cvox.GroupUtil.BREAKOUT_SELECTOR_); |
124 | 124 |
125 for (var i = 0; i < breakingNodes.length; ++i) { | 125 for (var i = 0; i < breakingNodes.length; ++i) { |
126 if (cvox.DomUtil.hasContent(breakingNodes[i])) { | 126 if (cvox.DomUtil.hasContent(breakingNodes[i])) { |
127 return false; | 127 return false; |
128 } | 128 } |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 if (cvox.AriaUtil.isCompositeControl(node) && | 132 if (cvox.AriaUtil.isCompositeControl(node) && |
133 !cvox.DomUtil.isFocusable(node)) { | 133 !cvox.DomUtil.isFocusable(node)) { |
134 return false; | 134 return false; |
135 } | 135 } |
136 | 136 |
137 var content = cvox.DomUtil.collapseWhitespace( | 137 var content = cvox.DomUtil.collapseWhitespace( |
138 cvox.DomUtil.getValue(node) + ' ' + | 138 cvox.DomUtil.getValue(node) + ' ' + cvox.DomUtil.getName(node)); |
139 cvox.DomUtil.getName(node)); | |
140 if (content.length > cvox.GroupUtil.MAX_CHARCOUNT_) { | 139 if (content.length > cvox.GroupUtil.MAX_CHARCOUNT_) { |
141 return false; | 140 return false; |
142 } | 141 } |
143 | 142 |
144 if (content.replace(/\s/g, '') === '') { | 143 if (content.replace(/\s/g, '') === '') { |
145 // Text only contains whitespace | 144 // Text only contains whitespace |
146 return false; | 145 return false; |
147 } | 146 } |
148 | 147 |
149 return true; | 148 return true; |
150 }; | 149 }; |
OLD | NEW |