| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 this.node_.textSelEnd, | 126 this.node_.textSelEnd, |
| 127 true /* triggered by user */); | 127 true /* triggered by user */); |
| 128 this.changed(textChangeEvent); | 128 this.changed(textChangeEvent); |
| 129 this.outputBraille_(); | 129 this.outputBraille_(); |
| 130 }, | 130 }, |
| 131 | 131 |
| 132 /** @override */ | 132 /** @override */ |
| 133 getLineIndex: function(charIndex) { | 133 getLineIndex: function(charIndex) { |
| 134 if (!this.multiline) | 134 if (!this.multiline) |
| 135 return 0; | 135 return 0; |
| 136 var breaks = this.node_.lineBreaks || []; | 136 var breaks = this.node_.lineStartOffsets || []; |
| 137 var index = 0; | 137 var index = 0; |
| 138 while (index < breaks.length && breaks[index] <= charIndex) | 138 while (index < breaks.length && breaks[index] <= charIndex) |
| 139 ++index; | 139 ++index; |
| 140 return index; | 140 return index; |
| 141 }, | 141 }, |
| 142 | 142 |
| 143 /** @override */ | 143 /** @override */ |
| 144 getLineStart: function(lineIndex) { | 144 getLineStart: function(lineIndex) { |
| 145 if (!this.multiline || lineIndex == 0) | 145 if (!this.multiline || lineIndex == 0) |
| 146 return 0; | 146 return 0; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 159 if (0 < end && value[end - 1] == '\n') | 159 if (0 < end && value[end - 1] == '\n') |
| 160 return end - 1; | 160 return end - 1; |
| 161 return end; | 161 return end; |
| 162 }, | 162 }, |
| 163 | 163 |
| 164 /** | 164 /** |
| 165 * @return {Array<number>} | 165 * @return {Array<number>} |
| 166 * @private | 166 * @private |
| 167 */ | 167 */ |
| 168 getLineBreaks_: function() { | 168 getLineBreaks_: function() { |
| 169 // node.lineBreaks is undefined when the multiline field has no line | 169 // node.lineStartOffsets is undefined when the multiline field has no line |
| 170 // breaks. | 170 // breaks. |
| 171 return this.node_.lineBreaks || []; | 171 return this.node_.lineStartOffsets || []; |
| 172 }, | 172 }, |
| 173 | 173 |
| 174 /** @private */ | 174 /** @private */ |
| 175 outputBraille_: function() { | 175 outputBraille_: function() { |
| 176 var isFirstLine = false; // First line in a multiline field. | 176 var isFirstLine = false; // First line in a multiline field. |
| 177 var output = new Output(); | 177 var output = new Output(); |
| 178 var range; | 178 var range; |
| 179 if (this.multiline) { | 179 if (this.multiline) { |
| 180 var lineIndex = this.getLineIndex(this.start); | 180 var lineIndex = this.getLineIndex(this.start); |
| 181 if (lineIndex == 0) { | 181 if (lineIndex == 0) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 210 testNode = testNode.parent; | 210 testNode = testNode.parent; |
| 211 } while (testNode); | 211 } while (testNode); |
| 212 | 212 |
| 213 if (rootFocusedEditable) | 213 if (rootFocusedEditable) |
| 214 return new TextFieldTextEditHandler(rootFocusedEditable); | 214 return new TextFieldTextEditHandler(rootFocusedEditable); |
| 215 | 215 |
| 216 return null; | 216 return null; |
| 217 }; | 217 }; |
| 218 | 218 |
| 219 }); | 219 }); |
| OLD | NEW |