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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js

Issue 1181333005: Convert some ChromeVox functional getters to properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@traversal_root
Patch Set: Rebase Created 5 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.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 The entry point for all ChromeVox2 related code for the 6 * @fileoverview The entry point for all ChromeVox2 related code for the
7 * background page. 7 * background page.
8 */ 8 */
9 9
10 goog.provide('Background'); 10 goog.provide('Background');
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 predErrorMsg = 'no_previous_visited_link'; 250 predErrorMsg = 'no_previous_visited_link';
251 break; 251 break;
252 case 'nextElement': 252 case 'nextElement':
253 current = current.move(cursors.Unit.NODE, Dir.FORWARD); 253 current = current.move(cursors.Unit.NODE, Dir.FORWARD);
254 break; 254 break;
255 case 'previousElement': 255 case 'previousElement':
256 current = current.move(cursors.Unit.NODE, Dir.BACKWARD); 256 current = current.move(cursors.Unit.NODE, Dir.BACKWARD);
257 break; 257 break;
258 case 'goToBeginning': 258 case 'goToBeginning':
259 var node = 259 var node =
260 AutomationUtil.findNodePost(current.getStart().getNode().root, 260 AutomationUtil.findNodePost(current.start.node.root,
261 Dir.FORWARD, 261 Dir.FORWARD,
262 AutomationPredicate.leaf); 262 AutomationPredicate.leaf);
263 if (node) 263 if (node)
264 current = cursors.Range.fromNode(node); 264 current = cursors.Range.fromNode(node);
265 break; 265 break;
266 case 'goToEnd': 266 case 'goToEnd':
267 var node = 267 var node =
268 AutomationUtil.findNodePost(current.getStart().getNode().root, 268 AutomationUtil.findNodePost(current.start.node.root,
269 Dir.BACKWARD, 269 Dir.BACKWARD,
270 AutomationPredicate.leaf); 270 AutomationPredicate.leaf);
271 if (node) 271 if (node)
272 current = cursors.Range.fromNode(node); 272 current = cursors.Range.fromNode(node);
273 break; 273 break;
274 case 'doDefault': 274 case 'doDefault':
275 if (this.currentRange_) { 275 if (this.currentRange_) {
276 var actionNode = this.currentRange_.getStart().getNode(); 276 var actionNode = this.currentRange_.start.node;
277 if (actionNode.role == chrome.automation.RoleType.inlineTextBox) 277 if (actionNode.role == chrome.automation.RoleType.inlineTextBox)
278 actionNode = actionNode.parent; 278 actionNode = actionNode.parent;
279 actionNode.doDefault(); 279 actionNode.doDefault();
280 } 280 }
281 // Skip all other processing; if focus changes, we should get an event 281 // Skip all other processing; if focus changes, we should get an event
282 // for that. 282 // for that.
283 return; 283 return;
284 case 'continuousRead': 284 case 'continuousRead':
285 global.isReadingContinuously = true; 285 global.isReadingContinuously = true;
286 var continueReading = function(prevRange) { 286 var continueReading = function(prevRange) {
287 if (!global.isReadingContinuously || !this.currentRange_) 287 if (!global.isReadingContinuously || !this.currentRange_)
288 return; 288 return;
289 289
290 new Output().withSpeechAndBraille( 290 new Output().withSpeechAndBraille(
291 this.currentRange_, prevRange, Output.EventType.NAVIGATE) 291 this.currentRange_, prevRange, Output.EventType.NAVIGATE)
292 .onSpeechEnd(function() { continueReading(prevRange); }) 292 .onSpeechEnd(function() { continueReading(prevRange); })
293 .go(); 293 .go();
294 prevRange = this.currentRange_; 294 prevRange = this.currentRange_;
295 this.currentRange_ = 295 this.currentRange_ =
296 this.currentRange_.move(cursors.Unit.NODE, Dir.FORWARD); 296 this.currentRange_.move(cursors.Unit.NODE, Dir.FORWARD);
297 297
298 if (!this.currentRange_ || this.currentRange_.equals(prevRange)) 298 if (!this.currentRange_ || this.currentRange_.equals(prevRange))
299 global.isReadingContinuously = false; 299 global.isReadingContinuously = false;
300 }.bind(this); 300 }.bind(this);
301 301
302 continueReading(null); 302 continueReading(null);
303 return; 303 return;
304 case 'showContextMenu': 304 case 'showContextMenu':
305 if (this.currentRange_) { 305 if (this.currentRange_) {
306 var actionNode = this.currentRange_.getStart().getNode(); 306 var actionNode = this.currentRange_.start.node;
307 if (actionNode.role == chrome.automation.RoleType.inlineTextBox) 307 if (actionNode.role == chrome.automation.RoleType.inlineTextBox)
308 actionNode = actionNode.parent; 308 actionNode = actionNode.parent;
309 actionNode.showContextMenu(); 309 actionNode.showContextMenu();
310 return; 310 return;
311 } 311 }
312 break; 312 break;
313 case 'showOptionsPage': 313 case 'showOptionsPage':
314 var optionsPage = {url: 'chromevox/background/options.html'}; 314 var optionsPage = {url: 'chromevox/background/options.html'};
315 chrome.tabs.create(optionsPage); 315 chrome.tabs.create(optionsPage);
316 break; 316 break;
317 } 317 }
318 318
319 if (pred) { 319 if (pred) {
320 var node = AutomationUtil.findNextNode( 320 var node = AutomationUtil.findNextNode(
321 current.getBound(dir).getNode(), dir, pred); 321 current.getBound(dir).node, dir, pred);
322 322
323 if (node) { 323 if (node) {
324 current = cursors.Range.fromNode(node); 324 current = cursors.Range.fromNode(node);
325 } else { 325 } else {
326 if (predErrorMsg) { 326 if (predErrorMsg) {
327 cvox.ChromeVox.tts.speak(cvox.ChromeVox.msgs.getMsg(predErrorMsg), 327 cvox.ChromeVox.tts.speak(cvox.ChromeVox.msgs.getMsg(predErrorMsg),
328 cvox.QueueMode.FLUSH); 328 cvox.QueueMode.FLUSH);
329 } 329 }
330 return; 330 return;
331 } 331 }
332 } 332 }
333 333
334 if (current) { 334 if (current) {
335 // TODO(dtseng): Figure out what it means to focus a range. 335 // TODO(dtseng): Figure out what it means to focus a range.
336 var actionNode = current.getStart().getNode(); 336 var actionNode = current.start.node;
337 if (actionNode.role == chrome.automation.RoleType.inlineTextBox) 337 if (actionNode.role == chrome.automation.RoleType.inlineTextBox)
338 actionNode = actionNode.parent; 338 actionNode = actionNode.parent;
339 actionNode.focus(); 339 actionNode.focus();
340 340
341 var prevRange = this.currentRange_; 341 var prevRange = this.currentRange_;
342 this.currentRange_ = current; 342 this.currentRange_ = current;
343 343
344 new Output().withSpeechAndBraille( 344 new Output().withSpeechAndBraille(
345 this.currentRange_, prevRange, Output.EventType.NAVIGATE) 345 this.currentRange_, prevRange, Output.EventType.NAVIGATE)
346 .go(); 346 .go();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 return; 392 return;
393 393
394 var prevRange = this.currentRange_; 394 var prevRange = this.currentRange_;
395 395
396 this.currentRange_ = cursors.Range.fromNode(node); 396 this.currentRange_ = cursors.Range.fromNode(node);
397 397
398 // Check to see if we've crossed roots. Continue if we've crossed roots or 398 // Check to see if we've crossed roots. Continue if we've crossed roots or
399 // are not within web content. 399 // are not within web content.
400 if (node.root.role == 'desktop' || 400 if (node.root.role == 'desktop' ||
401 !prevRange || 401 !prevRange ||
402 (prevRange.getStart().getNode().root != node.root && 402 (prevRange.start.node.root != node.root &&
403 node.state.focused)) 403 node.state.focused))
404 this.setupChromeVoxVariants_(node.root.docUrl || ''); 404 this.setupChromeVoxVariants_(node.root.docUrl || '');
405 405
406 // Don't process nodes inside of web content if ChromeVox Next is inactive. 406 // Don't process nodes inside of web content if ChromeVox Next is inactive.
407 if (node.root.role != chrome.automation.RoleType.desktop && 407 if (node.root.role != chrome.automation.RoleType.desktop &&
408 this.mode_ === ChromeVoxMode.CLASSIC) { 408 this.mode_ === ChromeVoxMode.CLASSIC) {
409 chrome.accessibilityPrivate.setFocusRing([]); 409 chrome.accessibilityPrivate.setFocusRing([]);
410 return; 410 return;
411 } 411 }
412 412
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 this.onEventDefault(evt); 496 this.onEventDefault(evt);
497 this.currentRange_ = cursors.Range.fromNode(evt.target); 497 this.currentRange_ = cursors.Range.fromNode(evt.target);
498 } 498 }
499 499
500 var textChangeEvent = new cvox.TextChangeEvent( 500 var textChangeEvent = new cvox.TextChangeEvent(
501 evt.target.value, 501 evt.target.value,
502 evt.target.textSelStart, 502 evt.target.textSelStart,
503 evt.target.textSelEnd, 503 evt.target.textSelEnd,
504 true); // triggered by user 504 true); // triggered by user
505 if (!this.editableTextHandler || 505 if (!this.editableTextHandler ||
506 evt.target != this.currentRange_.getStart().getNode()) { 506 evt.target != this.currentRange_.start.node) {
507 this.editableTextHandler = 507 this.editableTextHandler =
508 new cvox.ChromeVoxEditableTextBase( 508 new cvox.ChromeVoxEditableTextBase(
509 textChangeEvent.value, 509 textChangeEvent.value,
510 textChangeEvent.start, 510 textChangeEvent.start,
511 textChangeEvent.end, 511 textChangeEvent.end,
512 evt.target.state['protected'], 512 evt.target.state['protected'],
513 cvox.ChromeVox.tts); 513 cvox.ChromeVox.tts);
514 } 514 }
515 515
516 this.editableTextHandler.changed(textChangeEvent); 516 this.editableTextHandler.changed(textChangeEvent);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 649
650 chrome.tabs.query({active: true}, function(tabs) { 650 chrome.tabs.query({active: true}, function(tabs) {
651 if (mode === ChromeVoxMode.CLASSIC) { 651 if (mode === ChromeVoxMode.CLASSIC) {
652 // This case should do nothing because Classic gets injected by the 652 // This case should do nothing because Classic gets injected by the
653 // extension system via our manifest. Once ChromeVox Next is enabled 653 // extension system via our manifest. Once ChromeVox Next is enabled
654 // for tabs, re-enable. 654 // for tabs, re-enable.
655 // cvox.ChromeVox.injectChromeVoxIntoTabs(tabs); 655 // cvox.ChromeVox.injectChromeVoxIntoTabs(tabs);
656 } else { 656 } else {
657 // When in compat mode, if the focus is within the desktop tree proper, 657 // When in compat mode, if the focus is within the desktop tree proper,
658 // then do not disable content scripts. 658 // then do not disable content scripts.
659 if (this.currentRange_.getStart().getNode().root.role == 'desktop') 659 if (this.currentRange_.start.node.root.role == 'desktop')
660 return; 660 return;
661 661
662 this.disableClassicChromeVox_(); 662 this.disableClassicChromeVox_();
663 } 663 }
664 }.bind(this)); 664 }.bind(this));
665 665
666 this.mode_ = mode; 666 this.mode_ = mode;
667 } 667 }
668 }; 668 };
669 669
670 /** @type {Background} */ 670 /** @type {Background} */
671 global.backgroundObj = new Background(); 671 global.backgroundObj = new Background();
672 672
673 }); // goog.scope 673 }); // goog.scope
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698