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

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

Issue 2943193002: Run clang-format on .js files in c/b/r/chromeos/chromevox (Closed)
Patch Set: Created 3 years, 6 months 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 Keeps track of the current braille translators. 6 * @fileoverview Keeps track of the current braille translators.
7 */ 7 */
8 8
9 goog.provide('cvox.BrailleTranslatorManager'); 9 goog.provide('cvox.BrailleTranslatorManager');
10 10
11 goog.require('cvox.BrailleTable'); 11 goog.require('cvox.BrailleTable');
12 goog.require('cvox.ExpandingBrailleTranslator'); 12 goog.require('cvox.ExpandingBrailleTranslator');
13 goog.require('cvox.LibLouis'); 13 goog.require('cvox.LibLouis');
14 14
15 /** 15 /**
16 * @param {cvox.LibLouis=} opt_liblouisForTest Liblouis instance to use 16 * @param {cvox.LibLouis=} opt_liblouisForTest Liblouis instance to use
17 * for testing. 17 * for testing.
18 * @constructor 18 * @constructor
19 */ 19 */
20 cvox.BrailleTranslatorManager = function(opt_liblouisForTest) { 20 cvox.BrailleTranslatorManager = function(opt_liblouisForTest) {
21 /** 21 /**
22 * @type {!cvox.LibLouis} 22 * @type {!cvox.LibLouis}
23 * @private 23 * @private
24 */ 24 */
25 this.liblouis_ = opt_liblouisForTest || new cvox.LibLouis( 25 this.liblouis_ = opt_liblouisForTest ||
26 chrome.extension.getURL('braille/liblouis_nacl.nmf'), 26 new cvox.LibLouis(
27 chrome.extension.getURL('braille/tables')); 27 chrome.extension.getURL('braille/liblouis_nacl.nmf'),
28 chrome.extension.getURL('braille/tables'));
28 /** 29 /**
29 * @type {!Array<function()>} 30 * @type {!Array<function()>}
30 * @private 31 * @private
31 */ 32 */
32 this.changeListeners_ = []; 33 this.changeListeners_ = [];
33 /** 34 /**
34 * @type {!Array<cvox.BrailleTable.Table>} 35 * @type {!Array<cvox.BrailleTable.Table>}
35 * @private 36 * @private
36 */ 37 */
37 this.tables_ = []; 38 this.tables_ = [];
(...skipping 17 matching lines...) Expand all
55 * @private 56 * @private
56 */ 57 */
57 this.uncontractedTranslator_ = null; 58 this.uncontractedTranslator_ = null;
58 /** 59 /**
59 * @type {string?} 60 * @type {string?}
60 * @private 61 * @private
61 */ 62 */
62 this.uncontractedTableId_ = null; 63 this.uncontractedTableId_ = null;
63 64
64 if (!opt_liblouisForTest) { 65 if (!opt_liblouisForTest) {
65 document.addEventListener('DOMContentLoaded', 66 document.addEventListener(
66 this.loadLiblouis_.bind(this), 67 'DOMContentLoaded', this.loadLiblouis_.bind(this), false);
67 false);
68 } 68 }
69 }; 69 };
70 70
71 cvox.BrailleTranslatorManager.prototype = { 71 cvox.BrailleTranslatorManager.prototype = {
72 /** 72 /**
73 * Adds a listener to be called whenever there is a change in the 73 * Adds a listener to be called whenever there is a change in the
74 * translator(s) returned by other methods of this instance. 74 * translator(s) returned by other methods of this instance.
75 * @param {function()} listener The listener. 75 * @param {function()} listener The listener.
76 */ 76 */
77 addChangeListener: function(listener) { 77 addChangeListener: function(listener) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 } 117 }
118 } 118 }
119 if (!table) 119 if (!table)
120 table = cvox.BrailleTable.forId(tables, 'en-US-comp8'); 120 table = cvox.BrailleTable.forId(tables, 'en-US-comp8');
121 121
122 // If the user explicitly set an 8 dot table, use that when looking 122 // If the user explicitly set an 8 dot table, use that when looking
123 // for an uncontracted table. Otherwise, use the current table and let 123 // for an uncontracted table. Otherwise, use the current table and let
124 // getUncontracted find an appropriate corresponding table. 124 // getUncontracted find an appropriate corresponding table.
125 var table8Dot = opt_brailleTable8 ? 125 var table8Dot = opt_brailleTable8 ?
126 cvox.BrailleTable.forId(tables, opt_brailleTable8) : null; 126 cvox.BrailleTable.forId(tables, opt_brailleTable8) :
127 var uncontractedTable = cvox.BrailleTable.getUncontracted( 127 null;
128 tables, table8Dot || table); 128 var uncontractedTable =
129 cvox.BrailleTable.getUncontracted(tables, table8Dot || table);
129 var newDefaultTableId = table.id; 130 var newDefaultTableId = table.id;
130 var newUncontractedTableId = table.id === uncontractedTable.id ? 131 var newUncontractedTableId =
131 null : uncontractedTable.id; 132 table.id === uncontractedTable.id ? null : uncontractedTable.id;
132 if (newDefaultTableId === this.defaultTableId_ && 133 if (newDefaultTableId === this.defaultTableId_ &&
133 newUncontractedTableId === this.uncontractedTableId_) { 134 newUncontractedTableId === this.uncontractedTableId_) {
134 return; 135 return;
135 } 136 }
136 137
137 var finishRefresh = function(defaultTranslator, uncontractedTranslator) { 138 var finishRefresh = function(defaultTranslator, uncontractedTranslator) {
138 this.defaultTableId_ = newDefaultTableId; 139 this.defaultTableId_ = newDefaultTableId;
139 this.uncontractedTableId_ = newUncontractedTableId; 140 this.uncontractedTableId_ = newUncontractedTableId;
140 this.expandingTranslator_ = new cvox.ExpandingBrailleTranslator( 141 this.expandingTranslator_ = new cvox.ExpandingBrailleTranslator(
141 defaultTranslator, uncontractedTranslator); 142 defaultTranslator, uncontractedTranslator);
142 this.defaultTranslator_ = defaultTranslator; 143 this.defaultTranslator_ = defaultTranslator;
143 this.uncontractedTranslator_ = uncontractedTranslator; 144 this.uncontractedTranslator_ = uncontractedTranslator;
144 this.changeListeners_.forEach(function(listener) { listener(); }); 145 this.changeListeners_.forEach(function(listener) {
146 listener();
147 });
145 }.bind(this); 148 }.bind(this);
146 149
147 this.liblouis_.getTranslator(table.fileNames, function(translator) { 150 this.liblouis_.getTranslator(table.fileNames, function(translator) {
148 if (!newUncontractedTableId) { 151 if (!newUncontractedTableId) {
149 finishRefresh(translator, null); 152 finishRefresh(translator, null);
150 } else { 153 } else {
151 this.liblouis_.getTranslator( 154 this.liblouis_.getTranslator(
152 uncontractedTable.fileNames, 155 uncontractedTable.fileNames, function(uncontractedTranslator) {
153 function(uncontractedTranslator) {
154 finishRefresh(translator, uncontractedTranslator); 156 finishRefresh(translator, uncontractedTranslator);
155 }); 157 });
156 } 158 }
157 }.bind(this)); 159 }.bind(this));
158 }, 160 },
159 161
160 /** 162 /**
161 * @return {cvox.ExpandingBrailleTranslator} The current expanding braille 163 * @return {cvox.ExpandingBrailleTranslator} The current expanding braille
162 * translator, or {@code null} if none is available. 164 * translator, or {@code null} if none is available.
163 */ 165 */
164 getExpandingTranslator: function() { 166 getExpandingTranslator: function() {
165 return this.expandingTranslator_; 167 return this.expandingTranslator_;
166 }, 168 },
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 }, 218 },
217 219
218 /** 220 /**
219 * @return {!Array<cvox.BrailleTable.Table>} The currently loaded braille 221 * @return {!Array<cvox.BrailleTable.Table>} The currently loaded braille
220 * tables, or an empty array if they are not yet loaded. 222 * tables, or an empty array if they are not yet loaded.
221 */ 223 */
222 getTablesForTest: function() { 224 getTablesForTest: function() {
223 return this.tables_; 225 return this.tables_;
224 } 226 }
225 }; 227 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698