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 var selStart, selEnd; | |
1065 if (node == node.root.anchorObject && node == node.root.focusObject) { | |
1066 selStart = node.root.anchorOffset; | |
1067 selEnd = node.root.focusOffset; | |
1068 } else if (node == node.root.anchorObject) { | |
1069 selStart = node.root.anchorOffset; | |
1070 selEnd = selStart; | |
1071 } else if (node == node.root.focusObject) { | |
1072 selStart = node.root.focusOffset; | |
1073 selEnd = selStart; | |
1074 } | |
1075 if (goog.isDef(selStart) && goog.isDef(selEnd)) | |
1076 options.annotation.push(new Output.SelectionSpan(selStart, selEnd)); | |
1063 this.append_(buff, node.name, options); | 1077 this.append_(buff, node.name, options); |
1064 } else if (token == 'nameFromNode') { | 1078 } else if (token == 'nameFromNode') { |
1065 if (chrome.automation.NameFromType[node.nameFrom] == | 1079 if (chrome.automation.NameFromType[node.nameFrom] == |
1066 'contents') | 1080 'contents') |
1067 return; | 1081 return; |
1068 | 1082 |
1069 options.annotation.push('name'); | 1083 options.annotation.push('name'); |
1070 this.append_(buff, node.name, options); | 1084 this.append_(buff, node.name, options); |
1071 } else if (token == 'nameOrDescendants') { | 1085 } else if (token == 'nameOrDescendants') { |
1072 options.annotation.push(token); | 1086 options.annotation.push(token); |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1650 }); | 1664 }); |
1651 result.append(separator); | 1665 result.append(separator); |
1652 result.append(cur); | 1666 result.append(cur); |
1653 spansToExtend.forEach(function(elem) { | 1667 spansToExtend.forEach(function(elem) { |
1654 result.setSpan( | 1668 result.setSpan( |
1655 elem.span, | 1669 elem.span, |
1656 result.getSpanStart(elem.span), | 1670 result.getSpanStart(elem.span), |
1657 elem.end); | 1671 elem.end); |
1658 }); | 1672 }); |
1659 spansToRemove.forEach(result.removeSpan.bind(result)); | 1673 spansToRemove.forEach(result.removeSpan.bind(result)); |
1660 separator = Output.SPACE; | 1674 |
1675 // No separator needed if the previous result did end with whitespace. | |
1676 if (cur.toString()[cur.length - 1] == Output.SPACE) | |
dmazzoni
2016/08/22 19:27:49
Do you want to test for other whitespace here? Or
| |
1677 separator = ''; | |
1678 else | |
1679 separator = Output.SPACE; | |
1661 }); | 1680 }); |
1662 return result; | 1681 return result; |
1663 }, | 1682 }, |
1664 | 1683 |
1665 /** | 1684 /** |
1666 * Find the earcon for a given node (including ancestry). | 1685 * Find the earcon for a given node (including ancestry). |
1667 * @param {!AutomationNode} node | 1686 * @param {!AutomationNode} node |
1668 * @param {!AutomationNode=} opt_prevNode | 1687 * @param {!AutomationNode=} opt_prevNode |
1669 * @return {Output.Action} | 1688 * @return {Output.Action} |
1670 */ | 1689 */ |
(...skipping 16 matching lines...) Expand all Loading... | |
1687 break; | 1706 break; |
1688 } | 1707 } |
1689 earconFinder = earconFinder.parent; | 1708 earconFinder = earconFinder.parent; |
1690 } | 1709 } |
1691 } | 1710 } |
1692 return null; | 1711 return null; |
1693 } | 1712 } |
1694 }; | 1713 }; |
1695 | 1714 |
1696 }); // goog.scope | 1715 }); // goog.scope |
OLD | NEW |