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

Side by Side Diff: services/ui/ws/event_dispatcher.cc

Issue 2586333003: Make mash register initial batch of accelerators in single shot. (Closed)
Patch Set: remove unnecessary std::vector. Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "services/ui/ws/event_dispatcher.h" 5 #include "services/ui/ws/event_dispatcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 ? IsLocationInNonclientArea(mouse_cursor_source_window_, location) 247 ? IsLocationInNonclientArea(mouse_cursor_source_window_, location)
248 : false; 248 : false;
249 } 249 }
250 } 250 }
251 251
252 bool EventDispatcher::AddAccelerator(uint32_t id, 252 bool EventDispatcher::AddAccelerator(uint32_t id,
253 mojom::EventMatcherPtr event_matcher) { 253 mojom::EventMatcherPtr event_matcher) {
254 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); 254 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher));
255 // If an accelerator with the same id or matcher already exists, then abort. 255 // If an accelerator with the same id or matcher already exists, then abort.
256 for (const auto& pair : accelerators_) { 256 for (const auto& pair : accelerators_) {
257 if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get())) 257 if (pair.first == id) {
258 DVLOG(1) << "duplicate accelerator. Accelerator id=" << accelerator->id()
mfomitchev 2017/01/24 22:56:03 duplicate accelerator -> duplicate accelerator id
thanhph1 2017/01/25 20:12:37 Done.
259 << " type=" << event_matcher->type_matcher->type
260 << " flags=" << event_matcher->flags_matcher->flags;
258 return false; 261 return false;
262 } else if (accelerator->EqualEventMatcher(pair.second.get())) {
263 DVLOG(1) << "duplicate matcher. Accelerator id=" << accelerator->id()
mfomitchev 2017/01/24 22:56:03 duplicate matcher -> duplicate accelerator matcher
mfomitchev 2017/01/24 22:56:03 Can we get rid of the duplicate code here? The onl
thanhph1 2017/01/25 20:12:37 Done.
thanhph1 2017/01/25 20:12:37 Done.
264 << " type=" << event_matcher->type_matcher->type
265 << " flags=" << event_matcher->flags_matcher->flags;
266 return false;
267 }
259 } 268 }
260 accelerators_.insert(Entry(id, std::move(accelerator))); 269 accelerators_.insert(Entry(id, std::move(accelerator)));
261 return true; 270 return true;
262 } 271 }
263 272
264 void EventDispatcher::RemoveAccelerator(uint32_t id) { 273 void EventDispatcher::RemoveAccelerator(uint32_t id) {
265 auto it = accelerators_.find(id); 274 auto it = accelerators_.find(id);
266 // Clients may pass bogus ids. 275 // Clients may pass bogus ids.
267 if (it != accelerators_.end()) 276 if (it != accelerators_.end())
268 accelerators_.erase(it); 277 accelerators_.erase(it);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 if (mouse_cursor_source_window_ == window) 647 if (mouse_cursor_source_window_ == window)
639 mouse_cursor_source_window_ = nullptr; 648 mouse_cursor_source_window_ = nullptr;
640 } 649 }
641 650
642 void EventDispatcher::OnDragCursorUpdated() { 651 void EventDispatcher::OnDragCursorUpdated() {
643 delegate_->UpdateNativeCursorFromDispatcher(); 652 delegate_->UpdateNativeCursorFromDispatcher();
644 } 653 }
645 654
646 } // namespace ws 655 } // namespace ws
647 } // namespace ui 656 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698