Chromium Code Reviews| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 * @type {cvox.QueueMode} | 88 * @type {cvox.QueueMode} |
| 89 * @private | 89 * @private |
| 90 */ | 90 */ |
| 91 this.queueMode_ = cvox.QueueMode.QUEUE; | 91 this.queueMode_ = cvox.QueueMode.QUEUE; |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * @type {boolean} | 94 * @type {boolean} |
| 95 * @private | 95 * @private |
| 96 */ | 96 */ |
| 97 this.outputContextFirst_ = false; | 97 this.outputContextFirst_ = false; |
| 98 | |
| 99 /** | |
| 100 * @type {string} | |
| 101 * @private | |
| 102 */ | |
| 103 this.imageDataUrl_ = ''; | |
| 98 }; | 104 }; |
| 99 | 105 |
| 100 /** | 106 /** |
| 101 * Delimiter to use between output values. | 107 * Delimiter to use between output values. |
| 102 * @type {string} | 108 * @type {string} |
| 103 */ | 109 */ |
| 104 Output.SPACE = ' '; | 110 Output.SPACE = ' '; |
| 105 | 111 |
| 106 /** | 112 /** |
| 107 * Metadata about supported automation roles. | 113 * Metadata about supported automation roles. |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 963 var startIndex = -1, endIndex = -1; | 969 var startIndex = -1, endIndex = -1; |
| 964 if (selSpan) { | 970 if (selSpan) { |
| 965 var valueStart = buff.getSpanStart(selSpan); | 971 var valueStart = buff.getSpanStart(selSpan); |
| 966 var valueEnd = buff.getSpanEnd(selSpan); | 972 var valueEnd = buff.getSpanEnd(selSpan); |
| 967 startIndex = valueStart + selSpan.startIndex; | 973 startIndex = valueStart + selSpan.startIndex; |
| 968 endIndex = valueStart + selSpan.endIndex; | 974 endIndex = valueStart + selSpan.endIndex; |
| 969 buff.setSpan(new cvox.ValueSpan(0), valueStart, valueEnd); | 975 buff.setSpan(new cvox.ValueSpan(0), valueStart, valueEnd); |
| 970 buff.setSpan(new cvox.ValueSelectionSpan(), startIndex, endIndex); | 976 buff.setSpan(new cvox.ValueSelectionSpan(), startIndex, endIndex); |
| 971 } | 977 } |
| 972 | 978 |
| 973 var output = new cvox.NavBraille({ | 979 var brailleDisplayState = cvox.ChromeVox.braille.getDisplayState(); |
| 974 text: buff, | 980 if (this.imageDataUrl_ && brailleDisplayState.textRowCount >= 2) { |
|
David Tseng
2017/02/22 18:15:24
I don't think we should hack in the image display
| |
| 975 startIndex: startIndex, | 981 cvox.ChromeVox.braille.writeRawImage(this.imageDataUrl_); |
| 976 endIndex: endIndex | 982 } else { |
| 977 }); | 983 var output = new cvox.NavBraille({ |
| 978 | 984 text: buff, |
| 979 cvox.ChromeVox.braille.write(output); | 985 startIndex: startIndex, |
| 986 endIndex: endIndex | |
| 987 }); | |
| 988 cvox.ChromeVox.braille.write(output); | |
| 989 } | |
| 980 } | 990 } |
| 981 | 991 |
| 982 // Display. | 992 // Display. |
| 983 if (this.speechCategory_ != cvox.TtsCategory.LIVE) | 993 if (this.speechCategory_ != cvox.TtsCategory.LIVE) |
| 984 chrome.accessibilityPrivate.setFocusRing(this.locations_); | 994 chrome.accessibilityPrivate.setFocusRing(this.locations_); |
| 985 }, | 995 }, |
| 986 | 996 |
| 987 /** | 997 /** |
| 988 * Renders the given range using optional context previous range and event | 998 * Renders the given range using optional context previous range and event |
| 989 * type. | 999 * type. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1025 * @param {string|!Object} format The output format either specified as an | 1035 * @param {string|!Object} format The output format either specified as an |
| 1026 * output template string or a parsed output format tree. | 1036 * output template string or a parsed output format tree. |
| 1027 * @param {!Array<Spannable>} buff Buffer to receive rendered output. | 1037 * @param {!Array<Spannable>} buff Buffer to receive rendered output. |
| 1028 * @param {!AutomationNode=} opt_prevNode | 1038 * @param {!AutomationNode=} opt_prevNode |
| 1029 * @private | 1039 * @private |
| 1030 */ | 1040 */ |
| 1031 format_: function(node, format, buff, opt_prevNode) { | 1041 format_: function(node, format, buff, opt_prevNode) { |
| 1032 var tokens = []; | 1042 var tokens = []; |
| 1033 var args = null; | 1043 var args = null; |
| 1034 | 1044 |
| 1045 if (node != null && | |
| 1046 (node.role == RoleType.CANVAS || node.role == RoleType.IMAGE)) { | |
| 1047 if (node.imageDataUrl) | |
| 1048 this.imageDataUrl_ = node.imageDataUrl; | |
| 1049 node.getImageData(0, 0); | |
| 1050 } | |
| 1051 | |
| 1035 // Hacky way to support args. | 1052 // Hacky way to support args. |
| 1036 if (typeof(format) == 'string') { | 1053 if (typeof(format) == 'string') { |
| 1037 format = format.replace(/([,:])\W/g, '$1'); | 1054 format = format.replace(/([,:])\W/g, '$1'); |
| 1038 tokens = format.split(' '); | 1055 tokens = format.split(' '); |
| 1039 } else { | 1056 } else { |
| 1040 tokens = [format]; | 1057 tokens = [format]; |
| 1041 } | 1058 } |
| 1042 | 1059 |
| 1043 var speechProps = null; | 1060 var speechProps = null; |
| 1044 tokens.forEach(function(token) { | 1061 tokens.forEach(function(token) { |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1876 /** | 1893 /** |
| 1877 * Gets the output buffer for braille. | 1894 * Gets the output buffer for braille. |
| 1878 * @return {!Spannable} | 1895 * @return {!Spannable} |
| 1879 */ | 1896 */ |
| 1880 get brailleOutputForTest() { | 1897 get brailleOutputForTest() { |
| 1881 return this.mergeBraille_(this.brailleBuffer_); | 1898 return this.mergeBraille_(this.brailleBuffer_); |
| 1882 } | 1899 } |
| 1883 }; | 1900 }; |
| 1884 | 1901 |
| 1885 }); // goog.scope | 1902 }); // goog.scope |
| OLD | NEW |