Chromium Code Reviews| 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 #include "ui/base/accelerators/accelerator_history.h" | 5 #include "ui/base/accelerators/accelerator_history.h" |
| 6 | 6 |
| 7 #include "ui/events/event_constants.h" | |
| 8 | |
| 9 namespace ui { | 7 namespace ui { |
| 10 | 8 |
| 11 // ---------------------------------------------------------------------- | 9 AcceleratorHistory::AcceleratorHistory() {} |
| 12 // Public Methods | |
| 13 // ---------------------------------------------------------------------- | |
| 14 | 10 |
| 15 AcceleratorHistory::AcceleratorHistory() | 11 AcceleratorHistory::~AcceleratorHistory() {} |
| 16 : current_accelerator_(), | |
| 17 previous_accelerator_() { | |
| 18 } | |
| 19 | |
| 20 AcceleratorHistory::~AcceleratorHistory() { | |
| 21 } | |
| 22 | 12 |
| 23 void AcceleratorHistory::StoreCurrentAccelerator( | 13 void AcceleratorHistory::StoreCurrentAccelerator( |
| 24 const Accelerator& accelerator) { | 14 const Accelerator& accelerator) { |
| 15 // Track the currently pressed keys so that we don't mistakenly store an | |
| 16 // already pressed key as a new keypress after another key has been released. | |
| 17 // As an example, when the user presses and holds Alt+Search, then releases | |
| 18 // Alt but keeps holding the Search key down, at this point no new Search | |
| 19 // presses should be stored in the history after the Alt release, since Search | |
| 20 // was never released in the first place. crbug.com/704280. | |
| 21 if (accelerator.key_state() == Accelerator::KeyState::PRESSED) { | |
| 22 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.
| |
| 23 return; | |
| 24 } else { | |
| 25 currently_pressed_keys_.erase(accelerator.key_code()); | |
| 26 } | |
| 27 | |
| 25 if (accelerator != current_accelerator_) { | 28 if (accelerator != current_accelerator_) { |
| 26 previous_accelerator_ = current_accelerator_; | 29 previous_accelerator_ = current_accelerator_; |
| 27 current_accelerator_ = accelerator; | 30 current_accelerator_ = accelerator; |
| 28 } | 31 } |
| 29 } | 32 } |
| 30 | 33 |
| 31 } // namespace ui | 34 } // namespace ui |
| OLD | NEW |