| 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 A JavaScript class for walking lines consisting of one or more | 6 * @fileoverview A JavaScript class for walking lines consisting of one or more |
| 7 * clickable nodes. | 7 * clickable nodes. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 | 10 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 * ordering. | 207 * ordering. |
| 208 * @param {!cvox.CursorSelection} sel A selection that represents the location | 208 * @param {!cvox.CursorSelection} sel A selection that represents the location |
| 209 * of the braille cursor. | 209 * of the braille cursor. |
| 210 * @param {!cvox.CursorSelection} cur The specific selection to append. | 210 * @param {!cvox.CursorSelection} cur The specific selection to append. |
| 211 * @param {!cvox.NavBraille} braille Braille on which to append. | 211 * @param {!cvox.NavBraille} braille Braille on which to append. |
| 212 * @private | 212 * @private |
| 213 */ | 213 */ |
| 214 cvox.LayoutLineWalker.prototype.appendBraille_ = function( | 214 cvox.LayoutLineWalker.prototype.appendBraille_ = function( |
| 215 prevSel, sel, cur, braille) { | 215 prevSel, sel, cur, braille) { |
| 216 var item = this.subWalker_.getBraille(prevSel, cur).text; | 216 var item = this.subWalker_.getBraille(prevSel, cur).text; |
| 217 var valueSelectionSpan = item.getSpanInstanceOf( | 217 var valueSelectionSpan = item.getSpanInstanceOf(cvox.ValueSelectionSpan); |
| 218 cvox.BrailleUtil.ValueSelectionSpan); | |
| 219 | 218 |
| 220 if (braille.text.getLength() > 0) { | 219 if (braille.text.getLength() > 0) { |
| 221 braille.text.append(cvox.BrailleUtil.ITEM_SEPARATOR); | 220 braille.text.append(cvox.BrailleUtil.ITEM_SEPARATOR); |
| 222 } | 221 } |
| 223 | 222 |
| 224 // Find the surrounding logical "leaf node". | 223 // Find the surrounding logical "leaf node". |
| 225 // This prevents us from labelling the braille output with the wrong node, | 224 // This prevents us from labelling the braille output with the wrong node, |
| 226 // such as a text node child of a <textarea>. | 225 // such as a text node child of a <textarea>. |
| 227 var node = cur.start.node; | 226 var node = cur.start.node; |
| 228 while (node.parentNode && cvox.DomUtil.isLeafNode(node.parentNode)) { | 227 while (node.parentNode && cvox.DomUtil.isLeafNode(node.parentNode)) { |
| 229 node = node.parentNode; | 228 node = node.parentNode; |
| 230 } | 229 } |
| 231 | 230 |
| 232 var nodeStart = braille.text.getLength(); | 231 var nodeStart = braille.text.getLength(); |
| 233 var nodeEnd = nodeStart + item.getLength(); | 232 var nodeEnd = nodeStart + item.getLength(); |
| 234 braille.text.append(item); | 233 braille.text.append(item); |
| 235 braille.text.setSpan(node, nodeStart, nodeEnd); | 234 braille.text.setSpan(node, nodeStart, nodeEnd); |
| 236 | 235 |
| 237 if (sel && cur.absEquals(sel)) { | 236 if (sel && cur.absEquals(sel)) { |
| 238 if (valueSelectionSpan) { | 237 if (valueSelectionSpan) { |
| 239 braille.startIndex = nodeStart + item.getSpanStart(valueSelectionSpan); | 238 braille.startIndex = nodeStart + item.getSpanStart(valueSelectionSpan); |
| 240 braille.endIndex = nodeStart + item.getSpanEnd(valueSelectionSpan); | 239 braille.endIndex = nodeStart + item.getSpanEnd(valueSelectionSpan); |
| 241 } else { | 240 } else { |
| 242 braille.startIndex = nodeStart; | 241 braille.startIndex = nodeStart; |
| 243 braille.endIndex = nodeStart + 1; | 242 braille.endIndex = nodeStart + 1; |
| 244 } | 243 } |
| 245 } | 244 } |
| 246 }; | 245 }; |
| OLD | NEW |