Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 * @param {Object} evt | 56 * @param {Object} evt |
| 57 */ | 57 */ |
| 58 onEventDefault: function(evt) { | 58 onEventDefault: function(evt) { |
| 59 var node = evt.target; | 59 var node = evt.target; |
| 60 | 60 |
| 61 if (!node) | 61 if (!node) |
| 62 return; | 62 return; |
| 63 | 63 |
| 64 var prevRange = global.backgroundObj.currentRange; | 64 var prevRange = global.backgroundObj.currentRange; |
| 65 | 65 |
| 66 global.backgroundObj.currentRange = cursors.Range.fromNode(node); | 66 global.backgroundObj.setCurrentRange(cursors.Range.fromNode(node)); |
|
David Tseng
2015/11/23 23:23:57
Chang this to ChromeVoxState.
dmazzoni
2015/11/23 23:51:02
Should Background pass ChromeVoxState to the Deskt
dmazzoni
2015/11/30 22:00:47
OK, I made ChromeVoxState a singleton for now beca
| |
| 67 | 67 |
| 68 // Check to see if we've crossed roots. Continue if we've crossed roots or | 68 // Check to see if we've crossed roots. Continue if we've crossed roots or |
| 69 // are not within web content. | 69 // are not within web content. |
| 70 if (node.root.role == RoleType.desktop || | 70 if (node.root.role == RoleType.desktop || |
| 71 !prevRange || | 71 !prevRange || |
| 72 prevRange.start.node.root != node.root) | 72 prevRange.start.node.root != node.root) |
| 73 global.backgroundObj.refreshMode(node.root.docUrl || ''); | 73 global.backgroundObj.refreshMode(node.root.docUrl || ''); |
| 74 | 74 |
| 75 // Don't process nodes inside of web content if ChromeVox Next is inactive. | 75 // Don't process nodes inside of web content if ChromeVox Next is inactive. |
| 76 if (node.root.role != RoleType.desktop && | 76 if (node.root.role != RoleType.desktop && |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 webView = webView.parent; | 175 webView = webView.parent; |
| 176 | 176 |
| 177 if (!webView || !webView.state.focused) | 177 if (!webView || !webView.state.focused) |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 var node = AutomationUtil.findNodePost(root, | 180 var node = AutomationUtil.findNodePost(root, |
| 181 Dir.FORWARD, | 181 Dir.FORWARD, |
| 182 AutomationPredicate.leaf); | 182 AutomationPredicate.leaf); |
| 183 | 183 |
| 184 if (node) | 184 if (node) |
| 185 global.backgroundObj.currentRange = cursors.Range.fromNode(node); | 185 global.backgroundObj.setCurrentRange(cursors.Range.fromNode(node)); |
| 186 | 186 |
| 187 if (global.backgroundObj.currentRange) | 187 if (global.backgroundObj.currentRange) |
| 188 new Output().withSpeechAndBraille( | 188 new Output().withSpeechAndBraille( |
| 189 global.backgroundObj.currentRange, null, evt.type) | 189 global.backgroundObj.currentRange, null, evt.type) |
| 190 .go(); | 190 .go(); |
| 191 }, | 191 }, |
| 192 | 192 |
| 193 /** | 193 /** |
| 194 * Provides all feedback once a text selection change event fires. | 194 * Provides all feedback once a text selection change event fires. |
| 195 * @param {Object} evt | 195 * @param {Object} evt |
| 196 */ | 196 */ |
| 197 onTextOrTextSelectionChanged: function(evt) { | 197 onTextOrTextSelectionChanged: function(evt) { |
| 198 if (!this.isEditable_(evt.target)) | 198 if (!this.isEditable_(evt.target)) |
| 199 return; | 199 return; |
| 200 | 200 |
| 201 // Don't process nodes inside of web content if ChromeVox Next is inactive. | 201 // Don't process nodes inside of web content if ChromeVox Next is inactive. |
| 202 if (evt.target.root.role != RoleType.desktop && | 202 if (evt.target.root.role != RoleType.desktop && |
| 203 global.backgroundObj.mode === ChromeVoxMode.CLASSIC) | 203 global.backgroundObj.mode === ChromeVoxMode.CLASSIC) |
| 204 return; | 204 return; |
| 205 | 205 |
| 206 if (!evt.target.state.focused) | 206 if (!evt.target.state.focused) |
| 207 return; | 207 return; |
| 208 | 208 |
| 209 if (!global.backgroundObj.currentRange) { | 209 if (!global.backgroundObj.currentRange) { |
| 210 this.onEventDefault(evt); | 210 this.onEventDefault(evt); |
| 211 global.backgroundObj.currentRange = cursors.Range.fromNode(evt.target); | 211 global.backgroundObj.setCurrentRange(cursors.Range.fromNode(evt.target)); |
| 212 } | 212 } |
| 213 | 213 |
| 214 this.createEditableTextHandlerIfNeeded_(evt.target); | 214 this.createEditableTextHandlerIfNeeded_(evt.target); |
| 215 | 215 |
| 216 var textChangeEvent = new cvox.TextChangeEvent( | 216 var textChangeEvent = new cvox.TextChangeEvent( |
| 217 evt.target.value, | 217 evt.target.value, |
| 218 evt.target.textSelStart, | 218 evt.target.textSelStart, |
| 219 evt.target.textSelEnd, | 219 evt.target.textSelEnd, |
| 220 true); // triggered by user | 220 true); // triggered by user |
| 221 | 221 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 235 if (evt.target.root.role != RoleType.desktop && | 235 if (evt.target.root.role != RoleType.desktop && |
| 236 global.backgroundObj.mode === ChromeVoxMode.CLASSIC) | 236 global.backgroundObj.mode === ChromeVoxMode.CLASSIC) |
| 237 return; | 237 return; |
| 238 | 238 |
| 239 if (!evt.target.state.focused) | 239 if (!evt.target.state.focused) |
| 240 return; | 240 return; |
| 241 | 241 |
| 242 // Value change events fire on web editables when typing. Suppress them. | 242 // Value change events fire on web editables when typing. Suppress them. |
| 243 if (!global.backgroundObj.currentRange || !this.isEditable_(evt.target)) { | 243 if (!global.backgroundObj.currentRange || !this.isEditable_(evt.target)) { |
| 244 this.onEventDefault(evt); | 244 this.onEventDefault(evt); |
| 245 global.backgroundObj.currentRange = cursors.Range.fromNode(evt.target); | 245 global.backgroundObj.setCurrentRange(cursors.Range.fromNode(evt.target)); |
| 246 } | 246 } |
| 247 }, | 247 }, |
| 248 | 248 |
| 249 /** | 249 /** |
| 250 * Handle updating the active indicator when the document scrolls. | 250 * Handle updating the active indicator when the document scrolls. |
| 251 * @override | 251 * @override |
| 252 */ | 252 */ |
| 253 onScrollPositionChanged: function(evt) { | 253 onScrollPositionChanged: function(evt) { |
| 254 var currentRange = global.backgroundObj.currentRange; | 254 var currentRange = global.backgroundObj.currentRange; |
| 255 if (currentRange) | 255 if (currentRange) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 if (cvox.ChromeVox.isMac) | 302 if (cvox.ChromeVox.isMac) |
| 303 return; | 303 return; |
| 304 chrome.automation.getDesktop(function(desktop) { | 304 chrome.automation.getDesktop(function(desktop) { |
| 305 global.desktopAutomationHandler = new DesktopAutomationHandler(desktop); | 305 global.desktopAutomationHandler = new DesktopAutomationHandler(desktop); |
| 306 }); | 306 }); |
| 307 }; | 307 }; |
| 308 | 308 |
| 309 DesktopAutomationHandler.init_(); | 309 DesktopAutomationHandler.init_(); |
| 310 | 310 |
| 311 }); // goog.scope | 311 }); // goog.scope |
| OLD | NEW |