| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/events/gestures/motion_event_aura.h" | 5 #include "ui/events/gestures/motion_event_aura.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/events/gesture_detection/gesture_configuration.h" | 8 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 9 | 9 |
| 10 namespace ui { | 10 namespace ui { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 MotionEventAura::MotionEventAura() {} | 58 MotionEventAura::MotionEventAura() {} |
| 59 | 59 |
| 60 MotionEventAura::~MotionEventAura() {} | 60 MotionEventAura::~MotionEventAura() {} |
| 61 | 61 |
| 62 bool MotionEventAura::OnTouch(const TouchEvent& touch) { | 62 bool MotionEventAura::OnTouch(const TouchEvent& touch) { |
| 63 int index = FindPointerIndexOfId(touch.touch_id()); | 63 int index = FindPointerIndexOfId(touch.touch_id()); |
| 64 bool pointer_id_is_active = index != -1; | 64 bool pointer_id_is_active = index != -1; |
| 65 | 65 |
| 66 if (touch.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { | 66 if (touch.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { |
| 67 // TODO(tdresser): This should return false (or NOTREACHED()), and | 67 // TODO(tdresser): This should be NOTREACHED() - crbug.com/610423. |
| 68 // ignore the touch; however, there is at least one case where we | 68 return false; |
| 69 // need to allow a touch press from a currently used touch id. See | |
| 70 // crbug.com/446852 for details. | |
| 71 | |
| 72 // Cancel the existing touch, before handling the touch press. | |
| 73 TouchEvent cancel(ET_TOUCH_CANCELLED, gfx::Point(), touch.touch_id(), | |
| 74 touch.time_stamp()); | |
| 75 cancel.set_location_f(touch.location_f()); | |
| 76 cancel.set_root_location_f(touch.location_f()); | |
| 77 OnTouch(cancel); | |
| 78 CleanupRemovedTouchPoints(cancel); | |
| 79 DCHECK_EQ(-1, FindPointerIndexOfId(touch.touch_id())); | |
| 80 } else if (touch.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { | 69 } else if (touch.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { |
| 81 // We could have an active touch stream transfered to us, resulting in touch | 70 // When a window begins capturing touch events, we could have an active |
| 82 // move or touch up events without associated touch down events. Ignore | 71 // touch stream transfered to us, resulting in touch move or touch up events |
| 83 // them. | 72 // without associated touch down events. Ignore them. |
| 84 return false; | 73 return false; |
| 85 } | 74 } |
| 86 | 75 |
| 87 if (touch.type() == ET_TOUCH_MOVED && touch.x() == GetX(index) && | 76 if (touch.type() == ET_TOUCH_MOVED && touch.x() == GetX(index) && |
| 88 touch.y() == GetY(index)) { | 77 touch.y() == GetY(index)) { |
| 89 return false; | 78 return false; |
| 90 } | 79 } |
| 91 | 80 |
| 92 switch (touch.type()) { | 81 switch (touch.type()) { |
| 93 case ET_TOUCH_PRESSED: | 82 case ET_TOUCH_PRESSED: |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 169 |
| 181 int MotionEventAura::GetIndexFromId(int id) const { | 170 int MotionEventAura::GetIndexFromId(int id) const { |
| 182 int index = FindPointerIndexOfId(id); | 171 int index = FindPointerIndexOfId(id); |
| 183 // TODO(tdresser): remove these checks once crbug.com/525189 is fixed. | 172 // TODO(tdresser): remove these checks once crbug.com/525189 is fixed. |
| 184 CHECK_GE(index, 0); | 173 CHECK_GE(index, 0); |
| 185 CHECK_LT(index, static_cast<int>(GetPointerCount())); | 174 CHECK_LT(index, static_cast<int>(GetPointerCount())); |
| 186 return index; | 175 return index; |
| 187 } | 176 } |
| 188 | 177 |
| 189 } // namespace ui | 178 } // namespace ui |
| OLD | NEW |