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

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

Issue 2092743002: Revert of Make ChromeVox Next a setting in options page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 */ 91 */
92 onEventDefault: function(evt) { 92 onEventDefault: function(evt) {
93 var node = evt.target; 93 var node = evt.target;
94 if (!node) 94 if (!node)
95 return; 95 return;
96 96
97 var prevRange = ChromeVoxState.instance.currentRange; 97 var prevRange = ChromeVoxState.instance.currentRange;
98 98
99 ChromeVoxState.instance.setCurrentRange(cursors.Range.fromNode(node)); 99 ChromeVoxState.instance.setCurrentRange(cursors.Range.fromNode(node));
100 100
101 // Check to see if we've crossed roots. Continue if we've crossed roots or
102 // are not within web content.
103 if (node.root.role == RoleType.desktop ||
104 !prevRange ||
105 prevRange.start.node.root != node.root)
106 ChromeVoxState.instance.refreshMode(node.root);
107
101 // Don't process nodes inside of web content if ChromeVox Next is inactive. 108 // Don't process nodes inside of web content if ChromeVox Next is inactive.
102 if (node.root.role != RoleType.desktop && 109 if (node.root.role != RoleType.desktop &&
103 ChromeVoxState.instance.mode === ChromeVoxMode.CLASSIC) { 110 ChromeVoxState.instance.mode === ChromeVoxMode.CLASSIC) {
104 if (cvox.ChromeVox.isChromeOS) 111 if (cvox.ChromeVox.isChromeOS)
105 chrome.accessibilityPrivate.setFocusRing([]); 112 chrome.accessibilityPrivate.setFocusRing([]);
106 return; 113 return;
107 } 114 }
108 115
109 // Don't output if focused node hasn't changed. 116 // Don't output if focused node hasn't changed.
110 if (prevRange && 117 if (prevRange &&
(...skipping 13 matching lines...) Expand all
124 } 131 }
125 output.go(); 132 output.go();
126 }, 133 },
127 134
128 /** 135 /**
129 * @param {!AutomationEvent} evt 136 * @param {!AutomationEvent} evt
130 */ 137 */
131 onEventIfInRange: function(evt) { 138 onEventIfInRange: function(evt) {
132 // TODO(dtseng): Consider the end of the current range as well. 139 // TODO(dtseng): Consider the end of the current range as well.
133 if (AutomationUtil.isDescendantOf( 140 if (AutomationUtil.isDescendantOf(
134 ChromeVoxState.instance.currentRange.start.node, evt.target) || 141 global.backgroundObj.currentRange.start.node, evt.target) ||
135 evt.target.state.focused) 142 evt.target.state.focused)
136 this.onEventDefault(evt); 143 this.onEventDefault(evt);
137 }, 144 },
138 145
139 /** 146 /**
140 * @param {!AutomationEvent} evt 147 * @param {!AutomationEvent} evt
141 */ 148 */
142 onEventIfSelected: function(evt) { 149 onEventIfSelected: function(evt) {
143 if (evt.target.state.selected) 150 if (evt.target.state.selected)
144 this.onEventDefault(evt); 151 this.onEventDefault(evt);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 225
219 this.onEventDefault( 226 this.onEventDefault(
220 new chrome.automation.AutomationEvent(EventType.focus, node)); 227 new chrome.automation.AutomationEvent(EventType.focus, node));
221 }, 228 },
222 229
223 /** 230 /**
224 * Provides all feedback once a load complete event fires. 231 * Provides all feedback once a load complete event fires.
225 * @param {!AutomationEvent} evt 232 * @param {!AutomationEvent} evt
226 */ 233 */
227 onLoadComplete: function(evt) { 234 onLoadComplete: function(evt) {
235 ChromeVoxState.instance.refreshMode(evt.target);
236
228 // Don't process nodes inside of web content if ChromeVox Next is inactive. 237 // Don't process nodes inside of web content if ChromeVox Next is inactive.
229 if (evt.target.root.role != RoleType.desktop && 238 if (evt.target.root.role != RoleType.desktop &&
230 ChromeVoxState.instance.mode === ChromeVoxMode.CLASSIC) 239 ChromeVoxState.instance.mode === ChromeVoxMode.CLASSIC)
231 return; 240 return;
232 241
233 chrome.automation.getFocus(function(focus) { 242 chrome.automation.getFocus(function(focus) {
234 if (!focus || !AutomationUtil.isDescendantOf(focus, evt.target)) 243 if (!focus || !AutomationUtil.isDescendantOf(focus, evt.target))
235 return; 244 return;
236 245
237 // If initial focus was already placed on this page (e.g. if a user starts 246 // If initial focus was already placed on this page (e.g. if a user starts
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 326
318 // Don't process nodes inside of web content if ChromeVox Next is inactive. 327 // Don't process nodes inside of web content if ChromeVox Next is inactive.
319 if (evt.target.root.role != RoleType.desktop && 328 if (evt.target.root.role != RoleType.desktop &&
320 ChromeVoxState.instance.mode === ChromeVoxMode.CLASSIC) 329 ChromeVoxState.instance.mode === ChromeVoxMode.CLASSIC)
321 return; 330 return;
322 331
323 var t = evt.target; 332 var t = evt.target;
324 if (t.state.focused || 333 if (t.state.focused ||
325 t.root.role == RoleType.desktop || 334 t.root.role == RoleType.desktop ||
326 AutomationUtil.isDescendantOf( 335 AutomationUtil.isDescendantOf(
327 ChromeVoxState.instance.currentRange.start.node, t)) { 336 global.backgroundObj.currentRange.start.node, t)) {
328 if (new Date() - this.lastValueChanged_ <= 337 if (new Date() - this.lastValueChanged_ <=
329 DesktopAutomationHandler.VMIN_VALUE_CHANGE_DELAY_MS) 338 DesktopAutomationHandler.VMIN_VALUE_CHANGE_DELAY_MS)
330 return; 339 return;
331 340
332 this.lastValueChanged_ = new Date(); 341 this.lastValueChanged_ = new Date();
333 342
334 new Output().format('$value', evt.target) 343 new Output().format('$value', evt.target)
335 .go(); 344 .go();
336 } 345 }
337 }, 346 },
(...skipping 25 matching lines...) Expand all
363 if (override || AutomationUtil.isDescendantOf(evt.target, focus)) 372 if (override || AutomationUtil.isDescendantOf(evt.target, focus))
364 this.onEventDefault(evt); 373 this.onEventDefault(evt);
365 }.bind(this)); 374 }.bind(this));
366 }, 375 },
367 376
368 /** 377 /**
369 * Provides all feedback once a menu start event fires. 378 * Provides all feedback once a menu start event fires.
370 * @param {!AutomationEvent} evt 379 * @param {!AutomationEvent} evt
371 */ 380 */
372 onMenuStart: function(evt) { 381 onMenuStart: function(evt) {
373 ChromeVoxState.instance.startExcursion(); 382 global.backgroundObj.startExcursion();
374 this.onEventDefault(evt); 383 this.onEventDefault(evt);
375 }, 384 },
376 385
377 /** 386 /**
378 * Provides all feedback once a menu end event fires. 387 * Provides all feedback once a menu end event fires.
379 * @param {!AutomationEvent} evt 388 * @param {!AutomationEvent} evt
380 */ 389 */
381 onMenuEnd: function(evt) { 390 onMenuEnd: function(evt) {
382 this.onEventDefault(evt); 391 this.onEventDefault(evt);
383 ChromeVoxState.instance.endExcursion(); 392 global.backgroundObj.endExcursion();
384 }, 393 },
385 394
386 /** 395 /**
387 * Create an editable text handler for the given node if needed. 396 * Create an editable text handler for the given node if needed.
388 * @param {!AutomationNode} node 397 * @param {!AutomationNode} node
389 */ 398 */
390 createTextEditHandlerIfNeeded_: function(node) { 399 createTextEditHandlerIfNeeded_: function(node) {
391 if (!this.textEditHandler_ || 400 if (!this.textEditHandler_ ||
392 this.textEditHandler_.node !== node) { 401 this.textEditHandler_.node !== node) {
393 this.textEditHandler_ = editing.TextEditHandler.createForNode(node); 402 this.textEditHandler_ = editing.TextEditHandler.createForNode(node);
394 } 403 }
395 } 404 }
396 }; 405 };
397 406
398 /** 407 /**
399 * Initializes global state for DesktopAutomationHandler. 408 * Initializes global state for DesktopAutomationHandler.
400 * @private 409 * @private
401 */ 410 */
402 DesktopAutomationHandler.init_ = function() { 411 DesktopAutomationHandler.init_ = function() {
403 if (cvox.ChromeVox.isMac) 412 if (cvox.ChromeVox.isMac)
404 return; 413 return;
405 chrome.automation.getDesktop(function(desktop) { 414 chrome.automation.getDesktop(function(desktop) {
406 ChromeVoxState.desktopAutomationHandler = 415 global.desktopAutomationHandler = new DesktopAutomationHandler(desktop);
407 new DesktopAutomationHandler(desktop);
408 }); 416 });
409 }; 417 };
410 418
411 DesktopAutomationHandler.init_(); 419 DesktopAutomationHandler.init_();
412 420
413 }); // goog.scope 421 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698