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

Unified Diff: ui/base/accelerators/accelerator_history.cc

Issue 2792413002: Fix accelerator history tracking (Closed)
Patch Set: Add test Created 3 years, 8 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 | « ui/base/accelerators/accelerator_history.h ('k') | ui/base/accelerators/accelerator_history_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/accelerators/accelerator_history.cc
diff --git a/ui/base/accelerators/accelerator_history.cc b/ui/base/accelerators/accelerator_history.cc
index d356e3209146c77f2ca603cd4734abda3924a184..94e78da26927d3cca60b718d5c2ca74fefcfd1cd 100644
--- a/ui/base/accelerators/accelerator_history.cc
+++ b/ui/base/accelerators/accelerator_history.cc
@@ -4,24 +4,27 @@
#include "ui/base/accelerators/accelerator_history.h"
-#include "ui/events/event_constants.h"
-
namespace ui {
-// ----------------------------------------------------------------------
-// Public Methods
-// ----------------------------------------------------------------------
-
-AcceleratorHistory::AcceleratorHistory()
- : current_accelerator_(),
- previous_accelerator_() {
-}
+AcceleratorHistory::AcceleratorHistory() {}
-AcceleratorHistory::~AcceleratorHistory() {
-}
+AcceleratorHistory::~AcceleratorHistory() {}
void AcceleratorHistory::StoreCurrentAccelerator(
- const Accelerator& accelerator) {
+ const Accelerator& accelerator) {
+ // Track the currently pressed keys so that we don't mistakenly store an
+ // already pressed key as a new keypress after another key has been released.
+ // As an example, when the user presses and holds Alt+Search, then releases
+ // Alt but keeps holding the Search key down, at this point no new Search
+ // presses should be stored in the history after the Alt release, since Search
+ // was never released in the first place. crbug.com/704280.
+ if (accelerator.key_state() == Accelerator::KeyState::PRESSED) {
+ if (!currently_pressed_keys_.emplace(accelerator.key_code()).second)
sadrul 2017/04/07 05:43:39 What code is generating the second Accelerator? Is
afakhry 2017/04/07 15:42:57 Unfortunately, REPEAT is unreliable in this case.
+ return;
+ } else {
+ currently_pressed_keys_.erase(accelerator.key_code());
+ }
+
if (accelerator != current_accelerator_) {
previous_accelerator_ = current_accelerator_;
current_accelerator_ = accelerator;
« no previous file with comments | « ui/base/accelerators/accelerator_history.h ('k') | ui/base/accelerators/accelerator_history_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698