Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "services/ui/ws/event_matcher.h" | 5 #include "services/ui/ws/event_matcher.h" |
| 6 | 6 |
| 7 namespace ui { | 7 namespace ui { |
| 8 namespace ws { | 8 namespace ws { |
| 9 | 9 |
| 10 EventMatcher::EventMatcher(const mojom::EventMatcher& matcher) | 10 EventMatcher::EventMatcher(const mojom::EventMatcher& matcher) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 fields_to_match_ |= POINTER_LOCATION; | 69 fields_to_match_ |= POINTER_LOCATION; |
| 70 pointer_region_ = matcher.pointer_location_matcher->region; | 70 pointer_region_ = matcher.pointer_location_matcher->region; |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 EventMatcher::~EventMatcher() {} | 74 EventMatcher::~EventMatcher() {} |
| 75 | 75 |
| 76 bool EventMatcher::MatchesEvent(const ui::Event& event) const { | 76 bool EventMatcher::MatchesEvent(const ui::Event& event) const { |
| 77 if ((fields_to_match_ & TYPE) && event.type() != event_type_) | 77 if ((fields_to_match_ & TYPE) && event.type() != event_type_) |
| 78 return false; | 78 return false; |
| 79 int flags = event.flags() & ~ignore_event_flags_; | 79 constexpr int kIgnoreFlags = EF_IS_SYNTHESIZED | EF_IS_REPEAT; |
|
sky
2017/03/30 23:44:43
Please add a comment here. Also, I would name this
Peng
2017/03/31 14:09:22
Done.
| |
| 80 int flags = event.flags() & ~(ignore_event_flags_ | kIgnoreFlags); | |
| 80 if ((fields_to_match_ & FLAGS) && flags != event_flags_) | 81 if ((fields_to_match_ & FLAGS) && flags != event_flags_) |
| 81 return false; | 82 return false; |
| 82 if (fields_to_match_ & KEYBOARD_CODE) { | 83 if (fields_to_match_ & KEYBOARD_CODE) { |
| 83 if (!event.IsKeyEvent()) | 84 if (!event.IsKeyEvent()) |
| 84 return false; | 85 return false; |
| 85 if (keyboard_code_ != event.AsKeyEvent()->GetConflatedWindowsKeyCode()) | 86 if (keyboard_code_ != event.AsKeyEvent()->GetConflatedWindowsKeyCode()) |
| 86 return false; | 87 return false; |
| 87 } | 88 } |
| 88 if (fields_to_match_ & POINTER_KIND) { | 89 if (fields_to_match_ & POINTER_KIND) { |
| 89 if (!event.IsPointerEvent() || | 90 if (!event.IsPointerEvent() || |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 104 event_type_ == other.event_type_ && | 105 event_type_ == other.event_type_ && |
| 105 event_flags_ == other.event_flags_ && | 106 event_flags_ == other.event_flags_ && |
| 106 ignore_event_flags_ == other.ignore_event_flags_ && | 107 ignore_event_flags_ == other.ignore_event_flags_ && |
| 107 keyboard_code_ == other.keyboard_code_ && | 108 keyboard_code_ == other.keyboard_code_ && |
| 108 pointer_type_ == other.pointer_type_ && | 109 pointer_type_ == other.pointer_type_ && |
| 109 pointer_region_ == other.pointer_region_; | 110 pointer_region_ == other.pointer_region_; |
| 110 } | 111 } |
| 111 | 112 |
| 112 } // namespace ws | 113 } // namespace ws |
| 113 } // namespace ui | 114 } // namespace ui |
| OLD | NEW |