| 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 Handles braille input keys when the user is typing or editing | 6 * @fileoverview Handles braille input keys when the user is typing or editing |
| 7 * text in an input field. This class cooperates with the Braille IME | 7 * text in an input field. This class cooperates with the Braille IME |
| 8 * that is built into Chrome OS to do the actual text editing. | 8 * that is built into Chrome OS to do the actual text editing. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 this.translatorManager_ = translatorManager; | 48 this.translatorManager_ = translatorManager; |
| 49 /** | 49 /** |
| 50 * The translator currently used for typing, if | 50 * The translator currently used for typing, if |
| 51 * {@code this.cells_.length > 0}. | 51 * {@code this.cells_.length > 0}. |
| 52 * @type {cvox.LibLouis.Translator} | 52 * @type {cvox.LibLouis.Translator} |
| 53 * @private | 53 * @private |
| 54 */ | 54 */ |
| 55 this.activeTranslator_ = null; | 55 this.activeTranslator_ = null; |
| 56 /** | 56 /** |
| 57 * Braille cells that have been typed by the user so far. | 57 * Braille cells that have been typed by the user so far. |
| 58 * @type {Array.<number>} | 58 * @type {Array<number>} |
| 59 * @private | 59 * @private |
| 60 */ | 60 */ |
| 61 this.cells_ = []; | 61 this.cells_ = []; |
| 62 /** | 62 /** |
| 63 * Text resulting from translating {@code this.cells_}. | 63 * Text resulting from translating {@code this.cells_}. |
| 64 * @type {string} | 64 * @type {string} |
| 65 * @private | 65 * @private |
| 66 */ | 66 */ |
| 67 this.text_ = ''; | 67 this.text_ = ''; |
| 68 /** | 68 /** |
| 69 * Text that currently precedes the first selection end-point. | 69 * Text that currently precedes the first selection end-point. |
| 70 * @type {string} | 70 * @type {string} |
| 71 * @private | 71 * @private |
| 72 */ | 72 */ |
| 73 this.currentTextBefore_ = ''; | 73 this.currentTextBefore_ = ''; |
| 74 /** | 74 /** |
| 75 * Text that currently follows the last selection end-point. | 75 * Text that currently follows the last selection end-point. |
| 76 * @type {string} | 76 * @type {string} |
| 77 * @private | 77 * @private |
| 78 */ | 78 */ |
| 79 this.currentTextAfter_ = ''; | 79 this.currentTextAfter_ = ''; |
| 80 /** | 80 /** |
| 81 * List of strings that we expect to be set as preceding text of the | 81 * List of strings that we expect to be set as preceding text of the |
| 82 * selection. This is populated when we send text changes to the IME so that | 82 * selection. This is populated when we send text changes to the IME so that |
| 83 * our own changes don't reset the pending cells. | 83 * our own changes don't reset the pending cells. |
| 84 * @type {Array.<string>} | 84 * @type {Array<string>} |
| 85 * @private | 85 * @private |
| 86 */ | 86 */ |
| 87 this.pendingTextsBefore_ = []; | 87 this.pendingTextsBefore_ = []; |
| 88 /** | 88 /** |
| 89 * Cells that were entered while the IME wasn't active. These will be | 89 * Cells that were entered while the IME wasn't active. These will be |
| 90 * submitted once the IME becomes active and reports the current input field. | 90 * submitted once the IME becomes active and reports the current input field. |
| 91 * This is necessary because the IME is activated on the first braille | 91 * This is necessary because the IME is activated on the first braille |
| 92 * dots command, but we'll receive the command in parallel. To work around | 92 * dots command, but we'll receive the command in parallel. To work around |
| 93 * the race, we store the cell entered until we can submit it to the IME. | 93 * the race, we store the cell entered until we can submit it to the IME. |
| 94 * @type {Array.<number>} | 94 * @type {Array<number>} |
| 95 * @private | 95 * @private |
| 96 */ | 96 */ |
| 97 this.pendingCells_ = []; | 97 this.pendingCells_ = []; |
| 98 | 98 |
| 99 this.translatorManager_.addChangeListener(this.resetText_.bind(this)); | 99 this.translatorManager_.addChangeListener(this.resetText_.bind(this)); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 | 102 |
| 103 /** | 103 /** |
| 104 * The ID of the Braille IME extension built into Chrome OS. | 104 * The ID of the Braille IME extension built into Chrome OS. |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 first, second) { | 499 first, second) { |
| 500 var limit = Math.min(first.length, second.length); | 500 var limit = Math.min(first.length, second.length); |
| 501 var i; | 501 var i; |
| 502 for (i = 0; i < limit; ++i) { | 502 for (i = 0; i < limit; ++i) { |
| 503 if (first.charAt(i) != second.charAt(i)) { | 503 if (first.charAt(i) != second.charAt(i)) { |
| 504 break; | 504 break; |
| 505 } | 505 } |
| 506 } | 506 } |
| 507 return i; | 507 return i; |
| 508 }; | 508 }; |
| OLD | NEW |