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

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

Issue 917793003: Actual fix for braille translation initialization race. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/braille/liblouis.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager.js
diff --git a/chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager.js b/chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager.js
index a0ac7670ee9994fcb8c2c0d7ee056a4393a3fe5d..bc76d92d6ef54d47a1ff1bef47c8c953f49bbecc 100644
--- a/chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager.js
+++ b/chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager.js
@@ -62,7 +62,8 @@ cvox.BrailleTranslatorManager = function(opt_liblouisForTest) {
this.uncontractedTableId_ = null;
this.fetchTables_();
- this.loadLiblouis_(0);
+ document.addEventListener('DOMContentLoaded', this.loadLiblouis_.bind(this),
+ false);
};
cvox.BrailleTranslatorManager.prototype = {
@@ -203,22 +204,13 @@ cvox.BrailleTranslatorManager.prototype = {
/**
* Loads the liblouis instance by attaching it to the document.
- * Retries a few times if the document doesn't yet have a body.
- * @param {number} tries Number of attempts made so far.
* @private
*/
- loadLiblouis_: function(tries) {
- if (!document.body) {
- if (tries <= 5) {
- window.setTimeout(this.loadLiblouis_.bind(this, tries + 1), 500);
- } else {
- console.error(
- 'Timeout waiting for document.body; not initializing braille.');
- }
- return;
- }
-
- this.liblouis_.attachToElement(document.body);
+ loadLiblouis_: function() {
+ // Cast away nullability. When the document is loaded, it will always
+ // have a body.
+ this.liblouis_.attachToElement(
+ /** @type {!HTMLBodyElement} */ (document.body));
},
/**
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/braille/liblouis.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698