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 JavaScript shim for the liblouis Native Client wrapper. | 6 * @fileoverview JavaScript shim for the liblouis Native Client wrapper. |
7 */ | 7 */ |
8 | 8 |
9 goog.provide('cvox.LibLouis'); | 9 goog.provide('cvox.LibLouis'); |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 if (!goog.isNull(this.tablesDir_)) { | 93 if (!goog.isNull(this.tablesDir_)) { |
94 embed.setAttribute('tablesdir', this.tablesDir_); | 94 embed.setAttribute('tablesdir', this.tablesDir_); |
95 } | 95 } |
96 embed.addEventListener('load', goog.bind(this.onInstanceLoad_, this), | 96 embed.addEventListener('load', goog.bind(this.onInstanceLoad_, this), |
97 false /* useCapture */); | 97 false /* useCapture */); |
98 embed.addEventListener('error', goog.bind(this.onInstanceError_, this), | 98 embed.addEventListener('error', goog.bind(this.onInstanceError_, this), |
99 false /* useCapture */); | 99 false /* useCapture */); |
100 embed.addEventListener('message', goog.bind(this.onInstanceMessage_, this), | 100 embed.addEventListener('message', goog.bind(this.onInstanceMessage_, this), |
101 false /* useCapture */); | 101 false /* useCapture */); |
102 elem.appendChild(embed); | 102 elem.appendChild(embed); |
| 103 // TODO(plundblad): Remove when the real cause of crbug.com/455889 |
| 104 // is fixed. Sending this empty message will cause the nacl component |
| 105 // to load and fire the load event properly. |
| 106 embed.postMessage('{}'); |
103 | 107 |
104 this.embedElement_ = /** @type {!HTMLEmbedElement} */ (embed); | 108 this.embedElement_ = /** @type {!HTMLEmbedElement} */ (embed); |
105 this.instanceState_ = cvox.LibLouis.InstanceState.LOADING; | 109 this.instanceState_ = cvox.LibLouis.InstanceState.LOADING; |
106 }; | 110 }; |
107 | 111 |
108 | 112 |
109 /** | 113 /** |
110 * Detaches the Native Client instance from the DOM. | 114 * Detaches the Native Client instance from the DOM. |
111 */ | 115 */ |
112 cvox.LibLouis.prototype.detach = function() { | 116 cvox.LibLouis.prototype.detach = function() { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 */ | 360 */ |
357 cvox.LibLouis.Translator.encodeHexString_ = function(arrayBuffer) { | 361 cvox.LibLouis.Translator.encodeHexString_ = function(arrayBuffer) { |
358 var array = new Uint8Array(arrayBuffer); | 362 var array = new Uint8Array(arrayBuffer); |
359 var hex = ''; | 363 var hex = ''; |
360 for (var i = 0; i < array.length; i++) { | 364 for (var i = 0; i < array.length; i++) { |
361 var b = array[i]; | 365 var b = array[i]; |
362 hex += (b < 0x10 ? '0' : '') + b.toString(16); | 366 hex += (b < 0x10 ? '0' : '') + b.toString(16); |
363 } | 367 } |
364 return hex; | 368 return hex; |
365 }; | 369 }; |
OLD | NEW |