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

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

Issue 2008773002: Begin using ChromeVox Next to read tab and window titles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a bunch of tests. Created 4 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 Handles automation from a desktop automation node. 6 * @fileoverview Handles automation from a desktop automation node.
7 */ 7 */
8 8
9 goog.provide('DesktopAutomationHandler'); 9 goog.provide('DesktopAutomationHandler');
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 this.addListener_(e.alert, this.onAlert); 46 this.addListener_(e.alert, this.onAlert);
47 this.addListener_(e.ariaAttributeChanged, this.onEventIfInRange); 47 this.addListener_(e.ariaAttributeChanged, this.onEventIfInRange);
48 this.addListener_(e.checkedStateChanged, this.onEventIfInRange); 48 this.addListener_(e.checkedStateChanged, this.onEventIfInRange);
49 this.addListener_(e.focus, this.onFocus); 49 this.addListener_(e.focus, this.onFocus);
50 this.addListener_(e.hover, this.onEventWithFlushedOutput); 50 this.addListener_(e.hover, this.onEventWithFlushedOutput);
51 this.addListener_(e.loadComplete, this.onLoadComplete); 51 this.addListener_(e.loadComplete, this.onLoadComplete);
52 this.addListener_(e.menuEnd, this.onMenuEnd); 52 this.addListener_(e.menuEnd, this.onMenuEnd);
53 this.addListener_(e.menuListItemSelected, this.onEventIfSelected); 53 this.addListener_(e.menuListItemSelected, this.onEventIfSelected);
54 this.addListener_(e.menuStart, this.onMenuStart); 54 this.addListener_(e.menuStart, this.onMenuStart);
55 this.addListener_(e.scrollPositionChanged, this.onScrollPositionChanged); 55 this.addListener_(e.scrollPositionChanged, this.onScrollPositionChanged);
56 this.addListener_(e.selection, this.onEventWithFlushedOutput); 56 this.addListener_(e.selection, this.onSelection);
57 this.addListener_(e.textChanged, this.onTextChanged); 57 this.addListener_(e.textChanged, this.onTextChanged);
58 this.addListener_(e.textSelectionChanged, this.onTextSelectionChanged); 58 this.addListener_(e.textSelectionChanged, this.onTextSelectionChanged);
59 this.addListener_(e.valueChanged, this.onValueChanged); 59 this.addListener_(e.valueChanged, this.onValueChanged);
60 60
61 AutomationObjectConstructorInstaller.init(node, function() { 61 AutomationObjectConstructorInstaller.init(node, function() {
62 chrome.automation.getFocus((function(focus) { 62 chrome.automation.getFocus((function(focus) {
63 if (ChromeVoxState.instance.mode != ChromeVoxMode.FORCE_NEXT) 63 if (ChromeVoxState.instance.mode != ChromeVoxMode.FORCE_NEXT)
64 return; 64 return;
65 65
66 if (focus) { 66 if (focus) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 * @param {!AutomationEvent} evt 221 * @param {!AutomationEvent} evt
222 */ 222 */
223 onLoadComplete: function(evt) { 223 onLoadComplete: function(evt) {
224 ChromeVoxState.instance.refreshMode(evt.target); 224 ChromeVoxState.instance.refreshMode(evt.target);
225 225
226 // Don't process nodes inside of web content if ChromeVox Next is inactive. 226 // Don't process nodes inside of web content if ChromeVox Next is inactive.
227 if (evt.target.root.role != RoleType.desktop && 227 if (evt.target.root.role != RoleType.desktop &&
228 ChromeVoxState.instance.mode === ChromeVoxMode.CLASSIC) 228 ChromeVoxState.instance.mode === ChromeVoxMode.CLASSIC)
229 return; 229 return;
230 230
231 chrome.automation.getFocus((function(focus) { 231 chrome.automation.getFocus(function(focus) {
232 if (!focus) 232 if (!focus || !AutomationUtil.isDescendantOf(focus, evt.target))
233 return; 233 return;
234 234
235 // If initial focus was already placed on this page (e.g. if a user starts 235 // If initial focus was already placed on this page (e.g. if a user starts
236 // tabbing before load complete), then don't move ChromeVox's position on 236 // tabbing before load complete), then don't move ChromeVox's position on
237 // the page. 237 // the page.
238 if (ChromeVoxState.instance.currentRange && 238 if (ChromeVoxState.instance.currentRange &&
239 ChromeVoxState.instance.currentRange.start.node.root == focus.root) 239 ChromeVoxState.instance.currentRange.start.node.root == focus.root)
240 return; 240 return;
241 241
242 ChromeVoxState.instance.setCurrentRange(cursors.Range.fromNode(focus)); 242 ChromeVoxState.instance.setCurrentRange(cursors.Range.fromNode(focus));
243 new Output().withRichSpeechAndBraille( 243 new Output().withRichSpeechAndBraille(
244 ChromeVoxState.instance.currentRange, null, evt.type).go(); 244 ChromeVoxState.instance.currentRange, null, evt.type).go();
245 }).bind(this)); 245 }.bind(this));
246 }, 246 },
247 247
248 248 /**
249 /**
250 * Provides all feedback once a text changed event fires. 249 * Provides all feedback once a text changed event fires.
251 * @param {!AutomationEvent} evt 250 * @param {!AutomationEvent} evt
252 */ 251 */
253 onTextChanged: function(evt) { 252 onTextChanged: function(evt) {
254 if (evt.target.state.editable) 253 if (evt.target.state.editable)
255 this.onEditableChanged_(evt); 254 this.onEditableChanged_(evt);
256 }, 255 },
257 256
258 /** 257 /**
259 * Provides all feedback once a text selection changed event fires. 258 * Provides all feedback once a text selection changed event fires.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 onScrollPositionChanged: function(evt) { 329 onScrollPositionChanged: function(evt) {
331 if (ChromeVoxState.instance.mode === ChromeVoxMode.CLASSIC) 330 if (ChromeVoxState.instance.mode === ChromeVoxMode.CLASSIC)
332 return; 331 return;
333 332
334 var currentRange = ChromeVoxState.instance.currentRange; 333 var currentRange = ChromeVoxState.instance.currentRange;
335 if (currentRange) 334 if (currentRange)
336 new Output().withLocation(currentRange, null, evt.type).go(); 335 new Output().withLocation(currentRange, null, evt.type).go();
337 }, 336 },
338 337
339 /** 338 /**
339 * @param {!AutomationEvent} evt
340 */
341 onSelection: function(evt) {
342 chrome.automation.getFocus(function(focus) {
343 // Some cases (e.g. in overview mode), require overriding the assumption
344 // that focus is an ancestor of a selection target.
345 var override =
346 evt.target.root == focus.root && focus.root.role == RoleType.desktop;
347 if (override || AutomationUtil.isDescendantOf(evt.target, focus))
348 this.onEventDefault(evt);
349 }.bind(this));
350 },
351
352 /**
340 * Provides all feedback once a menu start event fires. 353 * Provides all feedback once a menu start event fires.
341 * @param {!AutomationEvent} evt 354 * @param {!AutomationEvent} evt
342 */ 355 */
343 onMenuStart: function(evt) { 356 onMenuStart: function(evt) {
344 global.backgroundObj.startExcursion(); 357 global.backgroundObj.startExcursion();
345 this.onEventDefault(evt); 358 this.onEventDefault(evt);
346 }, 359 },
347 360
348 /** 361 /**
349 * Provides all feedback once a menu end event fires. 362 * Provides all feedback once a menu end event fires.
(...skipping 24 matching lines...) Expand all
374 if (cvox.ChromeVox.isMac) 387 if (cvox.ChromeVox.isMac)
375 return; 388 return;
376 chrome.automation.getDesktop(function(desktop) { 389 chrome.automation.getDesktop(function(desktop) {
377 global.desktopAutomationHandler = new DesktopAutomationHandler(desktop); 390 global.desktopAutomationHandler = new DesktopAutomationHandler(desktop);
378 }); 391 });
379 }; 392 };
380 393
381 DesktopAutomationHandler.init_(); 394 DesktopAutomationHandler.init_();
382 395
383 }); // goog.scope 396 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698