| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 if (!evt.target.state.focused) | 319 if (!evt.target.state.focused) |
| 320 return; | 320 return; |
| 321 | 321 |
| 322 if (!ChromeVoxState.instance.currentRange) { | 322 if (!ChromeVoxState.instance.currentRange) { |
| 323 this.onEventDefault(evt); | 323 this.onEventDefault(evt); |
| 324 ChromeVoxState.instance.setCurrentRange( | 324 ChromeVoxState.instance.setCurrentRange( |
| 325 cursors.Range.fromNode(evt.target)); | 325 cursors.Range.fromNode(evt.target)); |
| 326 } | 326 } |
| 327 | 327 |
| 328 this.createTextEditHandlerIfNeeded_(evt.target); | 328 this.createTextEditHandlerIfNeeded_(evt.target); |
| 329 |
| 330 // Sync the ChromeVox range to the editable, if a selection exists. |
| 331 var anchorObject = evt.target.root.anchorObject; |
| 332 var anchorOffset = evt.target.root.anchorOffset; |
| 333 var focusObject = evt.target.root.focusObject; |
| 334 var focusOffset = evt.target.root.focusOffset; |
| 335 if (anchorObject && focusObject) { |
| 336 var selectedRange = new cursors.Range( |
| 337 new cursors.WrappingCursor(anchorObject, anchorOffset), |
| 338 new cursors.WrappingCursor(focusObject, focusOffset)); |
| 339 |
| 340 // Sync ChromeVox range with selection. |
| 341 ChromeVoxState.instance.setCurrentRange(selectedRange); |
| 342 } |
| 343 |
| 329 // TODO(plundblad): This can currently be null for contenteditables. | 344 // TODO(plundblad): This can currently be null for contenteditables. |
| 330 // Clean up when it can't. | 345 // Clean up when it can't. |
| 331 if (this.textEditHandler_) | 346 if (this.textEditHandler_) |
| 332 this.textEditHandler_.onEvent(evt); | 347 this.textEditHandler_.onEvent(evt); |
| 333 }, | 348 }, |
| 334 | 349 |
| 335 /** | 350 /** |
| 336 * Provides all feedback once a value changed event fires. | 351 * Provides all feedback once a value changed event fires. |
| 337 * @param {!AutomationEvent} evt | 352 * @param {!AutomationEvent} evt |
| 338 */ | 353 */ |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 DesktopAutomationHandler.init_ = function() { | 449 DesktopAutomationHandler.init_ = function() { |
| 435 chrome.automation.getDesktop(function(desktop) { | 450 chrome.automation.getDesktop(function(desktop) { |
| 436 ChromeVoxState.desktopAutomationHandler = | 451 ChromeVoxState.desktopAutomationHandler = |
| 437 new DesktopAutomationHandler(desktop); | 452 new DesktopAutomationHandler(desktop); |
| 438 }); | 453 }); |
| 439 }; | 454 }; |
| 440 | 455 |
| 441 DesktopAutomationHandler.init_(); | 456 DesktopAutomationHandler.init_(); |
| 442 | 457 |
| 443 }); // goog.scope | 458 }); // goog.scope |
| OLD | NEW |