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('{}'); | |
107 | |
108 this.embedElement_ = /** @type {!HTMLEmbedElement} */ (embed); | 103 this.embedElement_ = /** @type {!HTMLEmbedElement} */ (embed); |
109 this.instanceState_ = cvox.LibLouis.InstanceState.LOADING; | 104 this.instanceState_ = cvox.LibLouis.InstanceState.LOADING; |
110 }; | 105 }; |
111 | 106 |
112 | 107 |
113 /** | 108 /** |
114 * Detaches the Native Client instance from the DOM. | 109 * Detaches the Native Client instance from the DOM. |
115 */ | 110 */ |
116 cvox.LibLouis.prototype.detach = function() { | 111 cvox.LibLouis.prototype.detach = function() { |
117 if (!this.isAttached()) { | 112 if (!this.isAttached()) { |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 */ | 355 */ |
361 cvox.LibLouis.Translator.encodeHexString_ = function(arrayBuffer) { | 356 cvox.LibLouis.Translator.encodeHexString_ = function(arrayBuffer) { |
362 var array = new Uint8Array(arrayBuffer); | 357 var array = new Uint8Array(arrayBuffer); |
363 var hex = ''; | 358 var hex = ''; |
364 for (var i = 0; i < array.length; i++) { | 359 for (var i = 0; i < array.length; i++) { |
365 var b = array[i]; | 360 var b = array[i]; |
366 hex += (b < 0x10 ? '0' : '') + b.toString(16); | 361 hex += (b < 0x10 ? '0' : '') + b.toString(16); |
367 } | 362 } |
368 return hex; | 363 return hex; |
369 }; | 364 }; |
OLD | NEW |