summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/chromeos/braille_ime/braille_ime.js
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-14 11:38:45 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-14 17:16:47 +0000
commit3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859 (patch)
tree43cc572ba067417c7341db81f71ae7cc6e0fcc3e /chromium/chrome/browser/resources/chromeos/braille_ime/braille_ime.js
parentf61ab1ac7f855cd281809255c0aedbb1895e1823 (diff)
downloadqtwebengine-chromium-3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859.tar.gz
BASELINE: Update chromium to 45.0.2454.40
Change-Id: Id2121d9f11a8fc633677236c65a3e41feef589e4 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/chrome/browser/resources/chromeos/braille_ime/braille_ime.js')
-rw-r--r--chromium/chrome/browser/resources/chromeos/braille_ime/braille_ime.js74
1 files changed, 68 insertions, 6 deletions
diff --git a/chromium/chrome/browser/resources/chromeos/braille_ime/braille_ime.js b/chromium/chrome/browser/resources/chromeos/braille_ime/braille_ime.js
index deed955617b..c91257446db 100644
--- a/chromium/chrome/browser/resources/chromeos/braille_ime/braille_ime.js
+++ b/chromium/chrome/browser/resources/chromeos/braille_ime/braille_ime.js
@@ -18,7 +18,9 @@
* Sent on focus/blur to inform ChromeVox of the type of the current field.
* In the latter case (blur), context is null.
* {type: 'reset'}
- * Sent when the {@code onReset} IME event fires.
+ * Sent when the {@code onReset} IME event fires or uncommitted text is
+ * committed without being triggered by ChromeVox (e.g. because of a
+ * key press).
* {type: 'brailleDots', dots: number}
* Sent when the user typed a braille cell using the standard keyboard.
* ChromeVox treats this similarly to entering braille input using the
@@ -35,6 +37,14 @@
* and inserts {@code newText}. {@code contextID} identifies the text field
* to apply the update to (no change will happen if focus has moved to a
* different field).
+ * {type: 'setUncommitted', contextID: number, text: string}
+ * Stores text for the field identified by contextID to be committed
+ * either as a result of a 'commitUncommitted' message or a by the IME
+ * unhandled key press event. Unlike 'replaceText', this does not send the
+ * uncommitted text to the input field, but instead stores it in the IME.
+ * {type: 'commitUncommitted', contextID: number}
+ * Commits any uncommitted text if it matches the given context ID.
+ * See 'setUncommitted' above.
* {type: 'keyEventHandled', requestId: string, result: boolean}
* Response to a {@code backspace} message indicating whether the
* backspace was handled by ChromeVox or should be allowed to propagate
@@ -108,7 +118,7 @@ BrailleIme.prototype = {
* Note that the mapping below is arranged like the dots in a braille cell.
* Only 6 dot input is supported.
* @private
- * @const {Object<string, number>}
+ * @const {Object<number>}
*/
CODE_TO_DOT_: {'KeyF': 0x01, 'KeyJ': 0x08,
'KeyD': 0x02, 'KeyK': 0x10,
@@ -131,6 +141,13 @@ BrailleIme.prototype = {
port_: null,
/**
+ * Uncommitted text and context ID.
+ * @type {?{contextID: number, text: string}}
+ * @private
+ */
+ uncommitted_: null,
+
+ /**
* Registers event listeners in the chrome IME API.
*/
init: function() {
@@ -216,9 +233,8 @@ BrailleIme.prototype = {
*/
onKeyEvent_: function(engineID, event) {
var result = this.processKey_(event);
- if (result !== undefined) {
- chrome.input.ime.keyEventHandled(event.requestId, result);
- }
+ if (result !== undefined)
+ this.keyEventHandled_(event.requestId, event.type, result);
},
/**
@@ -356,7 +372,17 @@ BrailleIme.prototype = {
case 'keyEventHandled':
message =
/** @type {{requestId: string, result: boolean}} */ (message);
- chrome.input.ime.keyEventHandled(message.requestId, message.result);
+ this.keyEventHandled_(message.requestId, 'keydown', message.result);
+ break;
+ case 'setUncommitted':
+ message =
+ /** @type {{contextID: number, text: string}} */ (message);
+ this.setUncommitted_(message.contextID, message.text);
+ break;
+ case 'commitUncommitted':
+ message =
+ /** @type {{contextID: number}} */ (message);
+ this.commitUncommitted_(message.contextID);
break;
default:
console.error('Unknown message from ChromeVox: ' +
@@ -430,6 +456,42 @@ BrailleIme.prototype = {
},
/**
+ * Responds to an asynchronous key event, indicating whether it was handled
+ * or not. If it wasn't handled, any uncommitted text is committed
+ * before sending the response to the IME API.
+ * @param {string} requestId Key event request id.
+ * @param {string} type Type of key event being responded to.
+ * @param {boolean} response Whether the IME handled the event.
+ */
+ keyEventHandled_: function(requestId, type, response) {
+ if (!response && type === 'keydown' && this.uncommitted_) {
+ this.commitUncommitted_(this.uncommitted_.contextID);
+ this.sendToChromeVox_({type: 'reset'});
+ }
+ chrome.input.ime.keyEventHandled(requestId, response);
+ },
+
+ /**
+ * Stores uncommitted text that will be committed on any key press or
+ * when {@code commitUncommitted_} is called.
+ * @param {number} contextID of the current field.
+ * @param {string} text to store.
+ */
+ setUncommitted_: function(contextID, text) {
+ this.uncommitted_ = {contextID: contextID, text: text};
+ },
+
+ /**
+ * Commits the last set uncommitted text if it matches the given context id.
+ * @param {number} contextID
+ */
+ commitUncommitted_: function(contextID) {
+ if (this.uncommitted_ && contextID === this.uncommitted_.contextID)
+ chrome.input.ime.commitText(this.uncommitted_);
+ this.uncommitted_ = null;
+ },
+
+ /**
* Updates the menu items for this IME.
*/
updateMenuItems_: function() {