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 Provides output services for ChromeVox. | 6 * @fileoverview Provides output services for ChromeVox. |
7 */ | 7 */ |
8 | 8 |
9 goog.provide('Output'); | 9 goog.provide('Output'); |
10 goog.provide('Output.EventType'); | 10 goog.provide('Output.EventType'); |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 node.textSelEnd)); | 1053 node.textSelEnd)); |
1054 } | 1054 } |
1055 } | 1055 } |
1056 options.annotation.push(token); | 1056 options.annotation.push(token); |
1057 this.append_(buff, text, options); | 1057 this.append_(buff, text, options); |
1058 } else if (token == 'name') { | 1058 } else if (token == 'name') { |
1059 options.annotation.push(token); | 1059 options.annotation.push(token); |
1060 var earcon = node ? this.findEarcon_(node, opt_prevNode) : null; | 1060 var earcon = node ? this.findEarcon_(node, opt_prevNode) : null; |
1061 if (earcon) | 1061 if (earcon) |
1062 options.annotation.push(earcon); | 1062 options.annotation.push(earcon); |
| 1063 |
| 1064 // Reflect the selection here except when we're dealing with a node |
| 1065 // that has a value. |
| 1066 var selStart, selEnd; |
| 1067 if (node == node.root.anchorObject && node == node.root.focusObject) { |
| 1068 selStart = node.root.anchorOffset; |
| 1069 selEnd = node.root.focusOffset; |
| 1070 } else if (node == node.root.anchorObject) { |
| 1071 selStart = node.root.anchorOffset; |
| 1072 selEnd = selStart; |
| 1073 } else if (node == node.root.focusObject) { |
| 1074 selStart = node.root.focusOffset; |
| 1075 selEnd = selStart; |
| 1076 } |
| 1077 if (!node.value && goog.isDef(selStart) && goog.isDef(selEnd)) |
| 1078 options.annotation.push(new Output.SelectionSpan(selStart, selEnd)); |
| 1079 |
1063 this.append_(buff, node.name, options); | 1080 this.append_(buff, node.name, options); |
1064 } else if (token == 'nameFromNode') { | 1081 } else if (token == 'nameFromNode') { |
1065 if (chrome.automation.NameFromType[node.nameFrom] == | 1082 if (chrome.automation.NameFromType[node.nameFrom] == |
1066 'contents') | 1083 'contents') |
1067 return; | 1084 return; |
1068 | 1085 |
1069 options.annotation.push('name'); | 1086 options.annotation.push('name'); |
1070 this.append_(buff, node.name, options); | 1087 this.append_(buff, node.name, options); |
1071 } else if (token == 'nameOrDescendants') { | 1088 } else if (token == 'nameOrDescendants') { |
1072 options.annotation.push(token); | 1089 options.annotation.push(token); |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1650 }); | 1667 }); |
1651 result.append(separator); | 1668 result.append(separator); |
1652 result.append(cur); | 1669 result.append(cur); |
1653 spansToExtend.forEach(function(elem) { | 1670 spansToExtend.forEach(function(elem) { |
1654 result.setSpan( | 1671 result.setSpan( |
1655 elem.span, | 1672 elem.span, |
1656 result.getSpanStart(elem.span), | 1673 result.getSpanStart(elem.span), |
1657 elem.end); | 1674 elem.end); |
1658 }); | 1675 }); |
1659 spansToRemove.forEach(result.removeSpan.bind(result)); | 1676 spansToRemove.forEach(result.removeSpan.bind(result)); |
1660 separator = Output.SPACE; | 1677 |
| 1678 // No separator needed if the previous result did end with our separator. |
| 1679 if (cur.toString()[cur.length - 1] == Output.SPACE || result.length == 0) |
| 1680 separator = ''; |
| 1681 else |
| 1682 separator = Output.SPACE; |
1661 }); | 1683 }); |
1662 return result; | 1684 return result; |
1663 }, | 1685 }, |
1664 | 1686 |
1665 /** | 1687 /** |
1666 * Find the earcon for a given node (including ancestry). | 1688 * Find the earcon for a given node (including ancestry). |
1667 * @param {!AutomationNode} node | 1689 * @param {!AutomationNode} node |
1668 * @param {!AutomationNode=} opt_prevNode | 1690 * @param {!AutomationNode=} opt_prevNode |
1669 * @return {Output.Action} | 1691 * @return {Output.Action} |
1670 */ | 1692 */ |
(...skipping 16 matching lines...) Expand all Loading... |
1687 break; | 1709 break; |
1688 } | 1710 } |
1689 earconFinder = earconFinder.parent; | 1711 earconFinder = earconFinder.parent; |
1690 } | 1712 } |
1691 } | 1713 } |
1692 return null; | 1714 return null; |
1693 } | 1715 } |
1694 }; | 1716 }; |
1695 | 1717 |
1696 }); // goog.scope | 1718 }); // goog.scope |
OLD | NEW |