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

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

Issue 517853002: ChromeVox should not speak live regions that aren't in the document. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 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 | chrome/browser/resources/chromeos/chromevox/common/dom_util_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 simplify working 6 * @fileoverview A collection of JavaScript utilities used to simplify working
7 * with the DOM. 7 * with the DOM.
8 */ 8 */
9 9
10 10
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 return true; 186 return true;
187 } 187 }
188 188
189 return false; 189 return false;
190 }; 190 };
191 191
192 192
193 /** 193 /**
194 * Checks the ancestor chain for the given node for invisibility. If an 194 * Checks the ancestor chain for the given node for invisibility. If an
195 * ancestor is invisible and this cannot be overriden by a descendant, 195 * ancestor is invisible and this cannot be overriden by a descendant,
196 * we return true. 196 * we return true. If the element is not a descendant of the document
197 * element it will return true (invisible).
197 * @param {Node} node The node to check the ancestor chain for. 198 * @param {Node} node The node to check the ancestor chain for.
198 * @return {boolean} True if a descendant is invisible. 199 * @return {boolean} True if a descendant is invisible.
199 * @private 200 * @private
200 */ 201 */
201 cvox.DomUtil.hasInvisibleAncestor_ = function(node) { 202 cvox.DomUtil.hasInvisibleAncestor_ = function(node) {
202 var ancestor = node; 203 var ancestor = node;
203 while (ancestor = ancestor.parentElement) { 204 while (ancestor = ancestor.parentElement) {
204 var style = document.defaultView.getComputedStyle(ancestor, null); 205 var style = document.defaultView.getComputedStyle(ancestor, null);
205 if (cvox.DomUtil.isInvisibleStyle(style, true)) { 206 if (cvox.DomUtil.isInvisibleStyle(style, true)) {
206 return true; 207 return true;
207 } 208 }
209 // Once we reach the document element and we haven't found anything
210 // invisible yet, we're done. If we exit the while loop and never found
211 // the document element, the element wasn't part of the DOM and thus it's
212 // invisible.
213 if (ancestor == document.documentElement) {
214 return false;
215 }
208 } 216 }
209 return false; 217 return true;
210 }; 218 };
211 219
212 220
213 /** 221 /**
214 * Checks for a visible node in the subtree defined by root. 222 * Checks for a visible node in the subtree defined by root.
215 * @param {Node} root The root of the subtree to check. 223 * @param {Node} root The root of the subtree to check.
216 * @param {boolean} recursive Whether or not to check beyond the root of the 224 * @param {boolean} recursive Whether or not to check beyond the root of the
217 * subtree for visible nodes. This option exists for performance tuning. 225 * subtree for visible nodes. This option exists for performance tuning.
218 * Sometimes we already have information about the descendants, and we do 226 * Sometimes we already have information about the descendants, and we do
219 * not need to check them again. 227 * not need to check them again.
(...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 var describedNode = document.getElementById(describedById); 2593 var describedNode = document.getElementById(describedById);
2586 if (describedNode) { 2594 if (describedNode) {
2587 desc += ' ' + cvox.DomUtil.getName( 2595 desc += ' ' + cvox.DomUtil.getName(
2588 describedNode, true, true, true); 2596 describedNode, true, true, true);
2589 } 2597 }
2590 } 2598 }
2591 } 2599 }
2592 } 2600 }
2593 return desc; 2601 return desc;
2594 }; 2602 };
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/common/dom_util_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698