Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 mouse_cursor_in_non_client_area_ = | 245 mouse_cursor_in_non_client_area_ = |
| 246 mouse_cursor_source_window_ | 246 mouse_cursor_source_window_ |
| 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 bool is_duplicate; | |
|
mfomitchev
2017/01/26 16:03:36
Nit: Move the declarations below the comment.
thanhph1
2017/01/26 19:33:38
Done.
| |
| 256 std::string error_message; | |
| 257 | |
| 255 // If an accelerator with the same id or matcher already exists, then abort. | 258 // If an accelerator with the same id or matcher already exists, then abort. |
| 256 for (const auto& pair : accelerators_) { | 259 for (const auto& pair : accelerators_) { |
| 257 if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get())) | 260 if (pair.first == id) { |
| 261 error_message = "duplicate accelerator id."; | |
|
mfomitchev
2017/01/26 16:03:36
Nit: Capitalize the first letter. Same for below e
thanhph1
2017/01/26 19:33:38
Done.
| |
| 262 is_duplicate = true; | |
| 263 } else if (accelerator->EqualEventMatcher(pair.second.get())) { | |
| 264 error_message = "duplicate accelerator matcher."; | |
| 265 is_duplicate = true; | |
| 266 } | |
| 267 if (is_duplicate) { | |
| 268 DVLOG(1) << error_message << " accelerator id=" << accelerator->id() | |
|
mfomitchev
2017/01/26 16:03:36
Maybe use LOG(ERROR) instead of DVLOG(1) - we prob
thanhph1
2017/01/26 19:33:38
Done.
| |
| 269 << " type=" << event_matcher->type_matcher->type | |
| 270 << " flags=" << event_matcher->flags_matcher->flags; | |
| 258 return false; | 271 return false; |
| 272 } | |
| 259 } | 273 } |
| 260 accelerators_.insert(Entry(id, std::move(accelerator))); | 274 accelerators_.insert(Entry(id, std::move(accelerator))); |
| 261 return true; | 275 return true; |
| 262 } | 276 } |
| 263 | 277 |
| 264 void EventDispatcher::RemoveAccelerator(uint32_t id) { | 278 void EventDispatcher::RemoveAccelerator(uint32_t id) { |
| 265 auto it = accelerators_.find(id); | 279 auto it = accelerators_.find(id); |
| 266 // Clients may pass bogus ids. | 280 // Clients may pass bogus ids. |
| 267 if (it != accelerators_.end()) | 281 if (it != accelerators_.end()) |
| 268 accelerators_.erase(it); | 282 accelerators_.erase(it); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 if (mouse_cursor_source_window_ == window) | 652 if (mouse_cursor_source_window_ == window) |
| 639 mouse_cursor_source_window_ = nullptr; | 653 mouse_cursor_source_window_ = nullptr; |
| 640 } | 654 } |
| 641 | 655 |
| 642 void EventDispatcher::OnDragCursorUpdated() { | 656 void EventDispatcher::OnDragCursorUpdated() { |
| 643 delegate_->UpdateNativeCursorFromDispatcher(); | 657 delegate_->UpdateNativeCursorFromDispatcher(); |
| 644 } | 658 } |
| 645 | 659 |
| 646 } // namespace ws | 660 } // namespace ws |
| 647 } // namespace ui | 661 } // namespace ui |
| OLD | NEW |