| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 ChromeVox commands. | 6 * @fileoverview ChromeVox commands. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('CommandHandler'); | 9 goog.provide('CommandHandler'); |
| 10 | 10 |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 output.withString(target.name || ''); | 515 output.withString(target.name || ''); |
| 516 } | 516 } |
| 517 output.go(); | 517 output.go(); |
| 518 return false; | 518 return false; |
| 519 case 'readCurrentURL': | 519 case 'readCurrentURL': |
| 520 var output = new Output(); | 520 var output = new Output(); |
| 521 var target = ChromeVoxState.instance.currentRange_.start.node.root; | 521 var target = ChromeVoxState.instance.currentRange_.start.node.root; |
| 522 output.withString(target.docUrl || '').go(); | 522 output.withString(target.docUrl || '').go(); |
| 523 return false; | 523 return false; |
| 524 case 'copy': | 524 case 'copy': |
| 525 var textarea = document.createElement('textarea'); | 525 window.setTimeout(function() { |
| 526 document.body.appendChild(textarea); | 526 var textarea = document.createElement('textarea'); |
| 527 textarea.focus(); | 527 document.body.appendChild(textarea); |
| 528 document.execCommand('paste'); | 528 textarea.focus(); |
| 529 var clipboardContent = textarea.value; | 529 document.execCommand('paste'); |
| 530 textarea.remove(); | 530 var clipboardContent = textarea.value; |
| 531 cvox.ChromeVox.tts.speak( | 531 textarea.remove(); |
| 532 Msgs.getMsg('copy', [clipboardContent]), cvox.QueueMode.FLUSH); | 532 cvox.ChromeVox.tts.speak( |
| 533 ChromeVoxState.instance.pageSel_ = null; | 533 Msgs.getMsg('copy', [clipboardContent]), cvox.QueueMode.FLUSH); |
| 534 ChromeVoxState.instance.pageSel_ = null; |
| 535 }, 20); |
| 534 return true; | 536 return true; |
| 535 case 'toggleSelection': | 537 case 'toggleSelection': |
| 536 if (!ChromeVoxState.instance.pageSel_) { | 538 if (!ChromeVoxState.instance.pageSel_) { |
| 537 ChromeVoxState.instance.pageSel_ = ChromeVoxState.instance.currentRange; | 539 ChromeVoxState.instance.pageSel_ = ChromeVoxState.instance.currentRange; |
| 538 } else { | 540 } else { |
| 539 var root = ChromeVoxState.instance.currentRange_.start.node.root; | 541 var root = ChromeVoxState.instance.currentRange_.start.node.root; |
| 540 if (root && root.anchorObject && root.focusObject) { | 542 if (root && root.anchorObject && root.focusObject) { |
| 541 var sel = new cursors.Range( | 543 var sel = new cursors.Range( |
| 542 new cursors.Cursor(root.anchorObject, root.anchorOffset), | 544 new cursors.Cursor(root.anchorObject, root.anchorOffset), |
| 543 new cursors.Cursor(root.focusObject, root.focusOffset)); | 545 new cursors.Cursor(root.focusObject, root.focusOffset)); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 break; | 743 break; |
| 742 } | 744 } |
| 743 if (announcement) { | 745 if (announcement) { |
| 744 cvox.ChromeVox.tts.speak( | 746 cvox.ChromeVox.tts.speak( |
| 745 announcement, cvox.QueueMode.FLUSH, | 747 announcement, cvox.QueueMode.FLUSH, |
| 746 cvox.AbstractTts.PERSONALITY_ANNOTATION); | 748 cvox.AbstractTts.PERSONALITY_ANNOTATION); |
| 747 } | 749 } |
| 748 }; | 750 }; |
| 749 | 751 |
| 750 }); // goog.scope | 752 }); // goog.scope |
| OLD | NEW |