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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/braille/braille_display_manager.js

Issue 2401393003: Add multiline braille support. (Closed)
Patch Set: more tests Created 4 years, 1 month 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 Puts text on a braille display. 6 * @fileoverview Puts text on a braille display.
7 * 7 *
8 */ 8 */
9 9
10 goog.provide('cvox.BrailleDisplayManager'); 10 goog.provide('cvox.BrailleDisplayManager');
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 */ 60 */
61 this.commandListener_ = function() {}; 61 this.commandListener_ = function() {};
62 /** 62 /**
63 * Current display state used for width calculations. This is different from 63 * Current display state used for width calculations. This is different from
64 * realDisplayState_ if the braille captions feature is enabled and there is 64 * realDisplayState_ if the braille captions feature is enabled and there is
65 * no hardware display connected. Otherwise, it is the same object 65 * no hardware display connected. Otherwise, it is the same object
66 * as realDisplayState_. 66 * as realDisplayState_.
67 * @type {!cvox.BrailleDisplayState} 67 * @type {!cvox.BrailleDisplayState}
68 * @private 68 * @private
69 */ 69 */
70 this.displayState_ = {available: false, textCellCount: undefined}; 70 this.displayState_ = {available: false, textRowCount: undefined,
71 textColumnCount: undefined};
71 /** 72 /**
72 * State reported from the chrome api, reflecting a real hardware 73 * State reported from the chrome api, reflecting a real hardware
73 * display. 74 * display.
74 * @type {!cvox.BrailleDisplayState} 75 * @type {!cvox.BrailleDisplayState}
75 * @private 76 * @private
76 */ 77 */
77 this.realDisplayState_ = this.displayState_; 78 this.realDisplayState_ = this.displayState_;
78 /** 79 /**
79 * @type {!Array<number>} 80 * @type {!Array<number>}
80 * @private 81 * @private
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 }; 151 };
151 152
152 153
153 /** 154 /**
154 * @param {!cvox.BrailleDisplayState} newState Display state reported 155 * @param {!cvox.BrailleDisplayState} newState Display state reported
155 * by the extension API. 156 * by the extension API.
156 * @private 157 * @private
157 */ 158 */
158 cvox.BrailleDisplayManager.prototype.refreshDisplayState_ = function( 159 cvox.BrailleDisplayManager.prototype.refreshDisplayState_ = function(
159 newState) { 160 newState) {
160 var oldSize = this.displayState_.textCellCount || 0; 161 var oldSize = this.displayState_.textColumnCount *
162 this.displayState_.textRowCount || 0;
161 this.realDisplayState_ = newState; 163 this.realDisplayState_ = newState;
162 if (newState.available) { 164 if (newState.available) {
163 this.displayState_ = newState; 165 this.displayState_ = newState;
164 } else { 166 } else {
165 this.displayState_ = 167 this.displayState_ =
166 cvox.BrailleCaptionsBackground.getVirtualDisplayState(); 168 cvox.BrailleCaptionsBackground.getVirtualDisplayState();
167 } 169 }
168 var newSize = this.displayState_.textCellCount || 0; 170 var newSize = this.displayState_.textColumnCount *
171 this.displayState_.textRowCount || 0;
169 if (oldSize != newSize) { 172 if (oldSize != newSize) {
170 this.panStrategy_.setDisplaySize(newSize); 173 this.panStrategy_.setDisplaySize(newSize);
171 } 174 }
172 this.refresh_(); 175 this.refresh_();
173 }; 176 };
174 177
175 178
176 /** 179 /**
177 * Called when the state of braille captions changes. 180 * Called when the state of braille captions changes.
178 * @private 181 * @private
179 */ 182 */
180 cvox.BrailleDisplayManager.prototype.onCaptionsStateChanged_ = function() { 183 cvox.BrailleDisplayManager.prototype.onCaptionsStateChanged_ = function() {
181 // Force reevaluation of the display state based on our stored real 184 // Force reevaluation of the display state based on our stored real
182 // hardware display state, meaning that if a real display is connected, 185 // hardware display state, meaning that if a real display is connected,
183 // that takes precedence over the state from the captions 'virtual' display. 186 // that takes precedence over the state from the captions 'virtual' display.
184 this.refreshDisplayState_(this.realDisplayState_); 187 this.refreshDisplayState_(this.realDisplayState_);
185 }; 188 };
186 189
187 190
188 /** @private */ 191 /** @private */
189 cvox.BrailleDisplayManager.prototype.refresh_ = function() { 192 cvox.BrailleDisplayManager.prototype.refresh_ = function() {
190 if (!this.displayState_.available) { 193 if (!this.displayState_.available) {
191 return; 194 return;
192 } 195 }
193 var viewPort = this.panStrategy_.viewPort; 196 var viewPort = this.panStrategy_.viewPort;
194 var buf = this.displayedContent_.slice(viewPort.start, viewPort.end); 197 var buf = this.displayedContent_.slice(viewPort.start, viewPort.end);
195 if (this.realDisplayState_.available) { 198 if (this.realDisplayState_.available) {
196 chrome.brailleDisplayPrivate.writeDots(buf); 199 chrome.brailleDisplayPrivate.writeDots(buf, buf.byteLength, 1);
197 } 200 }
198 if (cvox.BrailleCaptionsBackground.isEnabled()) { 201 if (cvox.BrailleCaptionsBackground.isEnabled()) {
199 var start = this.brailleToTextPosition_(viewPort.start); 202 var start = this.brailleToTextPosition_(viewPort.start);
200 var end = this.brailleToTextPosition_(viewPort.end); 203 var end = this.brailleToTextPosition_(viewPort.end);
201 cvox.BrailleCaptionsBackground.setContent( 204 cvox.BrailleCaptionsBackground.setContent(
202 this.content_.text.toString().substring(start, end), buf, 205 this.content_.text.toString().substring(start, end), buf,
203 this.brailleToText_); 206 this.brailleToText_);
204 } 207 }
205 }; 208 };
206 209
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 }; 384 };
382 385
383 386
384 /** 387 /**
385 * @param {boolean} wordWrap 388 * @param {boolean} wordWrap
386 * @private 389 * @private
387 */ 390 */
388 cvox.BrailleDisplayManager.prototype.updatePanStrategy_ = function(wordWrap) { 391 cvox.BrailleDisplayManager.prototype.updatePanStrategy_ = function(wordWrap) {
389 var newStrategy = wordWrap ? new cvox.WrappingPanStrategy() : 392 var newStrategy = wordWrap ? new cvox.WrappingPanStrategy() :
390 new cvox.FixedPanStrategy(); 393 new cvox.FixedPanStrategy();
391 newStrategy.setDisplaySize(this.displayState_.textCellCount || 0); 394 newStrategy.setDisplaySize(this.displayState_.textColumnCount || 0);
392 newStrategy.setContent(this.translatedContent_, 395 newStrategy.setContent(this.translatedContent_,
393 this.panStrategy_.viewPort.start); 396 this.panStrategy_.viewPort.start);
394 this.panStrategy_ = newStrategy; 397 this.panStrategy_ = newStrategy;
395 this.refresh_(); 398 this.refresh_();
396 }; 399 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698