| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 Watches for events in the browser such as focus changes. | 6 * @fileoverview Watches for events in the browser such as focus changes. |
| 7 * | 7 * |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 goog.provide('cvox.ChromeVoxEventWatcher'); | 10 goog.provide('cvox.ChromeVoxEventWatcher'); |
| (...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 default: | 1110 default: |
| 1111 break; | 1111 break; |
| 1112 } | 1112 } |
| 1113 } | 1113 } |
| 1114 | 1114 |
| 1115 // Always announce changes for anything with an ARIA role. | 1115 // Always announce changes for anything with an ARIA role. |
| 1116 if (control.hasAttribute && control.hasAttribute('role')) { | 1116 if (control.hasAttribute && control.hasAttribute('role')) { |
| 1117 announceChange = true; | 1117 announceChange = true; |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 var activeDescendant = cvox.AriaUtil.getActiveDescendant(control); |
| 1120 if ((parentControl && | 1121 if ((parentControl && |
| 1121 parentControl != control && | 1122 parentControl != control && |
| 1122 document.activeElement == control)) { | 1123 document.activeElement == control)) { |
| 1123 // If focus has been set on a child of the parent control, we need to | 1124 // Sync ChromeVox to the newly selected control. |
| 1124 // sync to that node so that ChromeVox navigation will be in sync with | |
| 1125 // focus navigation. | |
| 1126 cvox.ApiImplementation.syncToNode( | 1125 cvox.ApiImplementation.syncToNode( |
| 1127 control, true, | 1126 activeDescendant || control, true, |
| 1128 cvox.ChromeVoxEventWatcher.queueMode_()); | 1127 cvox.ChromeVoxEventWatcher.queueMode_()); |
| 1129 announceChange = false; | 1128 announceChange = false; |
| 1130 } else if (cvox.AriaUtil.getActiveDescendant(control)) { | 1129 } else if (activeDescendant) { |
| 1131 cvox.ChromeVox.navigationManager.updateSelToArbitraryNode( | 1130 cvox.ChromeVox.navigationManager.updateSelToArbitraryNode( |
| 1132 cvox.AriaUtil.getActiveDescendant(control), | 1131 activeDescendant, |
| 1133 true); | 1132 true); |
| 1134 | 1133 |
| 1135 announceChange = true; | 1134 announceChange = true; |
| 1136 } | 1135 } |
| 1137 | 1136 |
| 1138 if (announceChange && !cvox.ChromeVoxEventSuspender.areEventsSuspended()) { | 1137 if (announceChange && !cvox.ChromeVoxEventSuspender.areEventsSuspended()) { |
| 1139 cvox.ChromeVox.tts.speak(newValue, | 1138 cvox.ChromeVox.tts.speak(newValue, |
| 1140 cvox.ChromeVoxEventWatcher.queueMode_(), | 1139 cvox.ChromeVoxEventWatcher.queueMode_(), |
| 1141 null); | 1140 null); |
| 1142 cvox.ChromeVox.braille.write(cvox.NavBraille.fromText(newValue)); | 1141 cvox.ChromeVox.braille.write(cvox.NavBraille.fromText(newValue)); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 ((currentFocus.type == 'date') || | 1506 ((currentFocus.type == 'date') || |
| 1508 (currentFocus.type == 'month') || | 1507 (currentFocus.type == 'month') || |
| 1509 (currentFocus.type == 'week'))) { | 1508 (currentFocus.type == 'week'))) { |
| 1510 cvox.ChromeVoxEventWatcher.currentDateHandler = | 1509 cvox.ChromeVoxEventWatcher.currentDateHandler = |
| 1511 new cvox.ChromeVoxHTMLDateWidget(currentFocus, cvox.ChromeVox.tts); | 1510 new cvox.ChromeVoxHTMLDateWidget(currentFocus, cvox.ChromeVox.tts); |
| 1512 } else { | 1511 } else { |
| 1513 cvox.ChromeVoxEventWatcher.currentDateHandler = null; | 1512 cvox.ChromeVoxEventWatcher.currentDateHandler = null; |
| 1514 } | 1513 } |
| 1515 return (null != cvox.ChromeVoxEventWatcher.currentDateHandler); | 1514 return (null != cvox.ChromeVoxEventWatcher.currentDateHandler); |
| 1516 }; | 1515 }; |
| OLD | NEW |