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

Unified Diff: chrome/browser/resources/chromeos/braille_ime/braille_ime.js

Issue 348533003: Send backspace to ChromeVox from Braille IME. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Created 6 years, 6 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
Index: chrome/browser/resources/chromeos/braille_ime/braille_ime.js
diff --git a/chrome/browser/resources/chromeos/braille_ime/braille_ime.js b/chrome/browser/resources/chromeos/braille_ime/braille_ime.js
index 0be3b4ca249677e03205a2243d42d913084b31a7..cc4c5f216b4fdd87b631536ca3466bf6cc735506 100644
--- a/chrome/browser/resources/chromeos/braille_ime/braille_ime.js
+++ b/chrome/browser/resources/chromeos/braille_ime/braille_ime.js
@@ -23,6 +23,10 @@
* Sent when the user typed a braille cell using the standard keyboard.
* ChromeVox treats this similarly to entering braille input using the
* braille display.
+ * {type: 'backspace', requestId: string}
+ * Sent when the user presses the backspace key.
+ * ChromeVox must respond with a {@code keyEventHandled} message
+ * with the same request id.
*
* Sent from ChromeVox to this IME:
* {type: 'replaceText', contextID: number, deleteBefore: number,
@@ -31,6 +35,10 @@
* 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: '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
+ * through the normal event handling pipeline.
*/
/**
@@ -132,7 +140,8 @@ BrailleIme.prototype = {
chrome.input.ime.onBlur.addListener(this.onBlur_.bind(this));
chrome.input.ime.onInputContextUpdate.addListener(
this.onInputContextUpdate_.bind(this));
- chrome.input.ime.onKeyEvent.addListener(this.onKeyEvent_.bind(this));
+ chrome.input.ime.onKeyEvent.addListener(this.onKeyEvent_.bind(this),
+ ['async']);
chrome.input.ime.onReset.addListener(this.onReset_.bind(this));
chrome.input.ime.onMenuItemActivated.addListener(
this.onMenuItemActivated_.bind(this));
@@ -203,13 +212,14 @@ BrailleIme.prototype = {
* Called by the system when this IME is active and a key event is generated.
* @param {string} engineID Engine ID, should be 'braille'.
* @param {!ChromeKeyboardEvent} event The keyboard event.
- * @return {boolean} Whether the event was handled by this IME (true) or
- * should be allowed to propagate.
* @private
*/
onKeyEvent_: function(engineID, event) {
this.log_('onKeyEvent', engineID + ', ' + JSON.stringify(event));
- return this.processKey_(event);
+ var result = this.processKey_(event);
+ if (result !== undefined) {
+ chrome.input.ime.keyEventHandled(event.requestId, result);
+ }
},
/**
@@ -262,13 +272,21 @@ BrailleIme.prototype = {
/**
* Handles a qwerty key on the home row as a braille key.
* @param {!ChromeKeyboardEvent} event Keyboard event.
- * @return {boolean} Whether the key event was handled or not.
+ * @return {boolean|undefined} Whether the event was handled, or
+ * {@code undefined} if handling was delegated to ChromeVox.
* @private
*/
processKey_: function(event) {
if (!this.useStandardKeyboard_) {
return false;
}
+ if (event.code === 'Backspace' && event.type === 'keydown') {
+ this.pressed_ = 0;
+ this.accumulated_ = 0;
+ this.sendToChromeVox_(
+ {type: 'backspace', requestId: event.requestId});
+ return undefined;
+ }
var dot = this.CODE_TO_DOT_[event.code];
if (!dot || event.altKey || event.ctrlKey || event.shiftKey ||
event.capsLock) {
@@ -336,6 +354,15 @@ BrailleIme.prototype = {
this.replaceText_(message.contextID, message.deleteBefore,
message.newText);
break;
+ case 'keyEventHandled':
+ message =
+ /** @type {{requestId: string, result: boolean}} */ (message);
+ chrome.input.ime.keyEventHandled(message.requestId, message.result);
+ break;
+ default:
+ console.error('Unknown message from ChromeVox: ' +
+ JSON.stringify(message));
+ break;
}
},
@@ -388,6 +415,7 @@ BrailleIme.prototype = {
* @param {string} toInsert Text to insert at the cursor.
*/
replaceText_: function(contextID, deleteBefore, toInsert) {
+ console.log('replaceText: ' + deleteBefore + ',' + toInsert);
David Tseng 2014/06/19 21:30:16 nit: Remove
var addText = function() {
chrome.input.ime.commitText(
{contextID: contextID, text: toInsert});

Powered by Google App Engine
This is Rietveld 408576698