Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js

Issue 2544203004: Display images in multiline Braille
Patch Set: Rebased back onto Master Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 * @type {cvox.QueueMode} 87 * @type {cvox.QueueMode}
88 * @private 88 * @private
89 */ 89 */
90 this.queueMode_ = cvox.QueueMode.QUEUE; 90 this.queueMode_ = cvox.QueueMode.QUEUE;
91 91
92 /** 92 /**
93 * @type {boolean} 93 * @type {boolean}
94 * @private 94 * @private
95 */ 95 */
96 this.outputContextFirst_ = false; 96 this.outputContextFirst_ = false;
97
98 /**
99 * @type {string}
100 * @private
101 */
102 this.imageDataUrl_ = '';
97 }; 103 };
98 104
99 /** 105 /**
100 * Delimiter to use between output values. 106 * Delimiter to use between output values.
101 * @type {string} 107 * @type {string}
102 */ 108 */
103 Output.SPACE = ' '; 109 Output.SPACE = ' ';
104 110
105 /** 111 /**
106 * Metadata about supported automation roles. 112 * Metadata about supported automation roles.
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 var startIndex = -1, endIndex = -1; 940 var startIndex = -1, endIndex = -1;
935 if (selSpan) { 941 if (selSpan) {
936 var valueStart = buff.getSpanStart(selSpan); 942 var valueStart = buff.getSpanStart(selSpan);
937 var valueEnd = buff.getSpanEnd(selSpan); 943 var valueEnd = buff.getSpanEnd(selSpan);
938 startIndex = valueStart + selSpan.startIndex; 944 startIndex = valueStart + selSpan.startIndex;
939 endIndex = valueStart + selSpan.endIndex; 945 endIndex = valueStart + selSpan.endIndex;
940 buff.setSpan(new cvox.ValueSpan(0), valueStart, valueEnd); 946 buff.setSpan(new cvox.ValueSpan(0), valueStart, valueEnd);
941 buff.setSpan(new cvox.ValueSelectionSpan(), startIndex, endIndex); 947 buff.setSpan(new cvox.ValueSelectionSpan(), startIndex, endIndex);
942 } 948 }
943 949
944 var output = new cvox.NavBraille({ 950 if (this.imageDataUrl_) {
945 text: buff, 951 cvox.ChromeVox.braille.writeRawImage(this.imageDataUrl_);
946 startIndex: startIndex, 952 } else {
947 endIndex: endIndex 953 var output = new cvox.NavBraille({
948 }); 954 text: buff,
949 955 startIndex: startIndex,
950 cvox.ChromeVox.braille.write(output); 956 endIndex: endIndex
957 });
958 cvox.ChromeVox.braille.write(output);
959 }
951 } 960 }
952 961
953 // Display. 962 // Display.
954 if (this.speechCategory_ != cvox.TtsCategory.LIVE) 963 if (this.speechCategory_ != cvox.TtsCategory.LIVE)
955 chrome.accessibilityPrivate.setFocusRing(this.locations_); 964 chrome.accessibilityPrivate.setFocusRing(this.locations_);
956 }, 965 },
957 966
958 /** 967 /**
959 * Renders the given range using optional context previous range and event 968 * Renders the given range using optional context previous range and event
960 * type. 969 * type.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 * @param {string|!Object} format The output format either specified as an 1005 * @param {string|!Object} format The output format either specified as an
997 * output template string or a parsed output format tree. 1006 * output template string or a parsed output format tree.
998 * @param {!Array<Spannable>} buff Buffer to receive rendered output. 1007 * @param {!Array<Spannable>} buff Buffer to receive rendered output.
999 * @param {!AutomationNode=} opt_prevNode 1008 * @param {!AutomationNode=} opt_prevNode
1000 * @private 1009 * @private
1001 */ 1010 */
1002 format_: function(node, format, buff, opt_prevNode) { 1011 format_: function(node, format, buff, opt_prevNode) {
1003 var tokens = []; 1012 var tokens = [];
1004 var args = null; 1013 var args = null;
1005 1014
1015 if (node != null &&
1016 (node.role == RoleType.canvas || node.role == RoleType.image)) {
1017 if (node.imageDataUrl)
1018 this.imageDataUrl_ = node.imageDataUrl;
1019 else
1020 node.getImageData(0, 0);
David Tseng 2016/12/08 17:09:21 This is going to be pretty strange in terms of fee
1021 }
1022
1006 // Hacky way to support args. 1023 // Hacky way to support args.
1007 if (typeof(format) == 'string') { 1024 if (typeof(format) == 'string') {
1008 format = format.replace(/([,:])\W/g, '$1'); 1025 format = format.replace(/([,:])\W/g, '$1');
1009 tokens = format.split(' '); 1026 tokens = format.split(' ');
1010 } else { 1027 } else {
1011 tokens = [format]; 1028 tokens = [format];
1012 } 1029 }
1013 1030
1014 var speechProps = null; 1031 var speechProps = null;
1015 tokens.forEach(function(token) { 1032 tokens.forEach(function(token) {
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 /** 1846 /**
1830 * Gets the output buffer for braille. 1847 * Gets the output buffer for braille.
1831 * @return {!Spannable} 1848 * @return {!Spannable}
1832 */ 1849 */
1833 get brailleOutputForTest() { 1850 get brailleOutputForTest() {
1834 return this.mergeBraille_(this.brailleBuffer_); 1851 return this.mergeBraille_(this.brailleBuffer_);
1835 } 1852 }
1836 }; 1853 };
1837 1854
1838 }); // goog.scope 1855 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698