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 Processes events related to editing text and emits the | 6 * @fileoverview Processes events related to editing text and emits the |
7 * appropriate spoken and braille feedback. | 7 * appropriate spoken and braille feedback. |
8 */ | 8 */ |
9 | 9 |
10 goog.provide('editing.TextEditHandler'); | 10 goog.provide('editing.TextEditHandler'); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 TextFieldTextEditHandler.prototype = { | 72 TextFieldTextEditHandler.prototype = { |
73 __proto__: editing.TextEditHandler.prototype, | 73 __proto__: editing.TextEditHandler.prototype, |
74 | 74 |
75 /** @override */ | 75 /** @override */ |
76 onEvent: function(evt) { | 76 onEvent: function(evt) { |
77 if (evt.type !== EventType.TEXT_CHANGED && | 77 if (evt.type !== EventType.TEXT_CHANGED && |
78 evt.type !== EventType.TEXT_SELECTION_CHANGED && | 78 evt.type !== EventType.TEXT_SELECTION_CHANGED && |
79 evt.type !== EventType.VALUE_CHANGED && | 79 evt.type !== EventType.VALUE_CHANGED && |
80 evt.type !== EventType.FOCUS) | 80 evt.type !== EventType.FOCUS) |
81 return; | 81 return; |
82 if (!evt.target.state.focused || | 82 if (!evt.target.state.editable || |
83 !evt.target.state.editable || | |
84 evt.target != this.node_) | 83 evt.target != this.node_) |
85 return; | 84 return; |
86 | 85 |
87 this.editableText_.onUpdate(); | 86 this.editableText_.onUpdate(); |
88 }, | 87 }, |
89 }; | 88 }; |
90 | 89 |
91 /** | 90 /** |
92 * A |ChromeVoxEditableTextBase| that implements text editing feedback | 91 * A |ChromeVoxEditableTextBase| that implements text editing feedback |
93 * for automation tree text fields. | 92 * for automation tree text fields. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 /** | 200 /** |
202 * @param {!AutomationNode} node The root editable node, i.e. the root of a | 201 * @param {!AutomationNode} node The root editable node, i.e. the root of a |
203 * contenteditable subtree or a text field. | 202 * contenteditable subtree or a text field. |
204 * @return {editing.TextEditHandler} | 203 * @return {editing.TextEditHandler} |
205 */ | 204 */ |
206 editing.TextEditHandler.createForNode = function(node) { | 205 editing.TextEditHandler.createForNode = function(node) { |
207 var rootFocusedEditable = null; | 206 var rootFocusedEditable = null; |
208 var testNode = node; | 207 var testNode = node; |
209 | 208 |
210 do { | 209 do { |
211 if (testNode.state[StateType.FOCUSED] && testNode.state[StateType.EDITABLE]) | 210 if (testNode.state[StateType.EDITABLE]) |
212 rootFocusedEditable = testNode; | 211 rootFocusedEditable = testNode; |
213 testNode = testNode.parent; | 212 testNode = testNode.parent; |
214 } while (testNode); | 213 } while (testNode); |
215 | 214 |
216 if (rootFocusedEditable) | 215 if (rootFocusedEditable) |
217 return new TextFieldTextEditHandler(rootFocusedEditable); | 216 return new TextFieldTextEditHandler(rootFocusedEditable); |
218 | 217 |
219 return null; | 218 return null; |
220 }; | 219 }; |
221 | 220 |
222 }); | 221 }); |
OLD | NEW |