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

Side by Side Diff: ash/mus/accelerators/accelerator_controller_registrar.cc

Issue 2751323002: Converts ui::Accelerator::type to an enum (Closed)
Patch Set: remove dcheck Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ash/mus/accelerators/accelerator_controller_registrar.h" 5 #include "ash/mus/accelerators/accelerator_controller_registrar.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "ash/common/accelerators/accelerator_controller.h" 9 #include "ash/common/accelerators/accelerator_controller.h"
10 #include "ash/common/accelerators/accelerator_router.h" 10 #include "ash/common/accelerators/accelerator_router.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 DCHECK_EQ(0u, accelerator_to_ids_.count(accelerator)); 136 DCHECK_EQ(0u, accelerator_to_ids_.count(accelerator));
137 accelerator_to_ids_[accelerator] = ids; 137 accelerator_to_ids_[accelerator] = ids;
138 DCHECK_EQ(accelerator_to_ids_.size() * 2, ids_.size()); 138 DCHECK_EQ(accelerator_to_ids_.size() * 2, ids_.size());
139 139
140 ui::mojom::EventMatcherPtr pre_event_matcher = ui::CreateKeyMatcher( 140 ui::mojom::EventMatcherPtr pre_event_matcher = ui::CreateKeyMatcher(
141 static_cast<ui::mojom::KeyboardCode>(accelerator.key_code()), 141 static_cast<ui::mojom::KeyboardCode>(accelerator.key_code()),
142 accelerator.modifiers()); 142 accelerator.modifiers());
143 pre_event_matcher->accelerator_phase = 143 pre_event_matcher->accelerator_phase =
144 ui::mojom::AcceleratorPhase::PRE_TARGET; 144 ui::mojom::AcceleratorPhase::PRE_TARGET;
145 DCHECK(accelerator.type() == ui::ET_KEY_PRESSED ||
146 accelerator.type() == ui::ET_KEY_RELEASED);
147 pre_event_matcher->type_matcher->type = 145 pre_event_matcher->type_matcher->type =
148 accelerator.type() == ui::ET_KEY_PRESSED 146 accelerator.key_state() == ui::Accelerator::KeyState::PRESSED
149 ? ui::mojom::EventType::KEY_PRESSED 147 ? ui::mojom::EventType::KEY_PRESSED
150 : ui::mojom::EventType::KEY_RELEASED; 148 : ui::mojom::EventType::KEY_RELEASED;
151 149
152 ui::mojom::EventMatcherPtr post_event_matcher = pre_event_matcher.Clone(); 150 ui::mojom::EventMatcherPtr post_event_matcher = pre_event_matcher.Clone();
153 post_event_matcher->accelerator_phase = 151 post_event_matcher->accelerator_phase =
154 ui::mojom::AcceleratorPhase::POST_TARGET; 152 ui::mojom::AcceleratorPhase::POST_TARGET;
155 153
156 accelerator_vector.push_back( 154 accelerator_vector.push_back(
157 ui::CreateAccelerator(ComputeAcceleratorId(id_namespace_, ids.pre_id), 155 ui::CreateAccelerator(ComputeAcceleratorId(id_namespace_, ids.pre_id),
158 std::move(pre_event_matcher))); 156 std::move(pre_event_matcher)));
(...skipping 16 matching lines...) Expand all
175 // Common case is we never wrap once, so this is typically cheap. Additionally 173 // Common case is we never wrap once, so this is typically cheap. Additionally
176 // we expect there not to be too many accelerators. 174 // we expect there not to be too many accelerators.
177 while (ids_.count(next_id_) > 0) 175 while (ids_.count(next_id_) > 0)
178 ++next_id_; 176 ++next_id_;
179 ids_.insert(next_id_); 177 ids_.insert(next_id_);
180 return next_id_++; 178 return next_id_++;
181 } 179 }
182 180
183 } // namespace mus 181 } // namespace mus
184 } // namespace ash 182 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698