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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/keyboard_handler.js

Issue 2552013003: Ensure spoken feedback keyboard hooks prevent re-injection of key up events (Closed)
Patch Set: Created 4 years 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/keyboard_handler.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/keyboard_handler.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/keyboard_handler.js
index 8d4990f33f33e159adff7918c48b22f46f78dc87..bed8ddb181fce284e0b511239c72bb475e5c7dc7 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/keyboard_handler.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/keyboard_handler.js
@@ -18,6 +18,9 @@ BackgroundKeyboardHandler = function() {
/** @type {number} @private */
this.passThroughKeyUpCount_ = 0;
+ /** @type {Array<number>} @private */
+ this.preventedKeys_ = [];
+
document.addEventListener('keydown', this.onKeyDown.bind(this), false);
document.addEventListener('keyup', this.onKeyUp.bind(this), false);
};
@@ -38,6 +41,7 @@ BackgroundKeyboardHandler.prototype = {
!cvox.ChromeVoxKbHandler.basicKeyDownActionsListener(evt)) {
evt.preventDefault();
evt.stopPropagation();
+ this.preventedKeys_.push(evt.keyCode);
}
Output.forceModeForNextSpeechUtterance(cvox.QueueMode.FLUSH);
return false;
@@ -59,6 +63,22 @@ BackgroundKeyboardHandler.prototype = {
this.passThroughKeyUpCount_++;
}
}
+
+ var wasDown = false;
+ var updatedKeys = [];
+ for (var i = 0; i < this.preventedKeys_.length; i++) {
dmazzoni 2016/12/06 07:25:22 If you make preventedKeys_ a Set(), I think you ca
David Tseng 2016/12/06 16:55:53 Sure. Was storing the entire event before. Changed
+ var otherKeyCode = this.preventedKeys_[i];
+ if (otherKeyCode == evt.keyCode)
+ wasDown = true;
+ else
+ updatedKeys.push(otherKeyCode);
+ }
+ this.preventedKeys_ = updatedKeys;
+
+ if (wasDown) {
+ evt.preventDefault();
+ evt.stopPropagation();
+ }
return false;
},
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698