| 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 // Synthetic flags should never be matched against. |
| 80 constexpr int kSyntheticFlags = EF_IS_SYNTHESIZED | EF_IS_REPEAT; |
| 81 int flags = event.flags() & ~(ignore_event_flags_ | kSyntheticFlags); |
| 80 if ((fields_to_match_ & FLAGS) && flags != event_flags_) | 82 if ((fields_to_match_ & FLAGS) && flags != event_flags_) |
| 81 return false; | 83 return false; |
| 82 if (fields_to_match_ & KEYBOARD_CODE) { | 84 if (fields_to_match_ & KEYBOARD_CODE) { |
| 83 if (!event.IsKeyEvent()) | 85 if (!event.IsKeyEvent()) |
| 84 return false; | 86 return false; |
| 85 if (keyboard_code_ != event.AsKeyEvent()->GetConflatedWindowsKeyCode()) | 87 if (keyboard_code_ != event.AsKeyEvent()->GetConflatedWindowsKeyCode()) |
| 86 return false; | 88 return false; |
| 87 } | 89 } |
| 88 if (fields_to_match_ & POINTER_KIND) { | 90 if (fields_to_match_ & POINTER_KIND) { |
| 89 if (!event.IsPointerEvent() || | 91 if (!event.IsPointerEvent() || |
| (...skipping 14 matching lines...) Expand all Loading... |
| 104 event_type_ == other.event_type_ && | 106 event_type_ == other.event_type_ && |
| 105 event_flags_ == other.event_flags_ && | 107 event_flags_ == other.event_flags_ && |
| 106 ignore_event_flags_ == other.ignore_event_flags_ && | 108 ignore_event_flags_ == other.ignore_event_flags_ && |
| 107 keyboard_code_ == other.keyboard_code_ && | 109 keyboard_code_ == other.keyboard_code_ && |
| 108 pointer_type_ == other.pointer_type_ && | 110 pointer_type_ == other.pointer_type_ && |
| 109 pointer_region_ == other.pointer_region_; | 111 pointer_region_ == other.pointer_region_; |
| 110 } | 112 } |
| 111 | 113 |
| 112 } // namespace ws | 114 } // namespace ws |
| 113 } // namespace ui | 115 } // namespace ui |
| OLD | NEW |