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