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 | |
1080 this.append_(buff, node.name, options); | 1063 this.append_(buff, node.name, options); |
1081 } else if (token == 'nameFromNode') { | 1064 } else if (token == 'nameFromNode') { |
1082 if (chrome.automation.NameFromType[node.nameFrom] == | 1065 if (chrome.automation.NameFromType[node.nameFrom] == |
1083 'contents') | 1066 'contents') |
1084 return; | 1067 return; |
1085 | 1068 |
1086 options.annotation.push('name'); | 1069 options.annotation.push('name'); |
1087 this.append_(buff, node.name, options); | 1070 this.append_(buff, node.name, options); |
1088 } else if (token == 'nameOrDescendants') { | 1071 } else if (token == 'nameOrDescendants') { |
1089 options.annotation.push(token); | 1072 options.annotation.push(token); |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 }); | 1650 }); |
1668 result.append(separator); | 1651 result.append(separator); |
1669 result.append(cur); | 1652 result.append(cur); |
1670 spansToExtend.forEach(function(elem) { | 1653 spansToExtend.forEach(function(elem) { |
1671 result.setSpan( | 1654 result.setSpan( |
1672 elem.span, | 1655 elem.span, |
1673 result.getSpanStart(elem.span), | 1656 result.getSpanStart(elem.span), |
1674 elem.end); | 1657 elem.end); |
1675 }); | 1658 }); |
1676 spansToRemove.forEach(result.removeSpan.bind(result)); | 1659 spansToRemove.forEach(result.removeSpan.bind(result)); |
1677 | 1660 separator = Output.SPACE; |
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; | |
1683 }); | 1661 }); |
1684 return result; | 1662 return result; |
1685 }, | 1663 }, |
1686 | 1664 |
1687 /** | 1665 /** |
1688 * Find the earcon for a given node (including ancestry). | 1666 * Find the earcon for a given node (including ancestry). |
1689 * @param {!AutomationNode} node | 1667 * @param {!AutomationNode} node |
1690 * @param {!AutomationNode=} opt_prevNode | 1668 * @param {!AutomationNode=} opt_prevNode |
1691 * @return {Output.Action} | 1669 * @return {Output.Action} |
1692 */ | 1670 */ |
(...skipping 16 matching lines...) Expand all Loading... |
1709 break; | 1687 break; |
1710 } | 1688 } |
1711 earconFinder = earconFinder.parent; | 1689 earconFinder = earconFinder.parent; |
1712 } | 1690 } |
1713 } | 1691 } |
1714 return null; | 1692 return null; |
1715 } | 1693 } |
1716 }; | 1694 }; |
1717 | 1695 |
1718 }); // goog.scope | 1696 }); // goog.scope |
OLD | NEW |