Chromium Code Reviews| 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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
| 6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
| 7 | 7 |
| 8 #include "ui/events/gestures/motion_event_aura.h" | 8 #include "ui/events/gestures/motion_event_aura.h" |
| 9 | 9 |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 | 62 |
| 63 } // namespace | 63 } // namespace |
| 64 | 64 |
| 65 MotionEventAura::MotionEventAura() { | 65 MotionEventAura::MotionEventAura() { |
| 66 set_action_index(-1); | 66 set_action_index(-1); |
| 67 } | 67 } |
| 68 | 68 |
| 69 MotionEventAura::~MotionEventAura() { | 69 MotionEventAura::~MotionEventAura() { |
| 70 } | 70 } |
| 71 | 71 |
| 72 void MotionEventAura::OnTouch(const TouchEvent& touch) { | 72 bool MotionEventAura::OnTouch(const TouchEvent& touch) { |
| 73 int index = FindPointerIndexOfId(touch.touch_id()); | |
| 74 bool pointer_id_is_active = index != -1; | |
| 75 | |
| 76 if (touch.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { | |
| 77 // Ignore touch press events if we already believe the pointer is down. | |
| 78 | |
| 79 // FIXME(tdresser): this should return false (or NOTREACHED()); | |
|
jdduke (slow)
2015/01/05 22:35:14
Nit: TODO is more common in chromium (vs blink).
tdresser
2015/01/06 14:20:16
Done.
| |
| 80 // however, there is at least one case where we need to allow a | |
| 81 // touch press from a currently used touch id. See | |
|
jdduke (slow)
2015/01/05 22:35:14
Will the drag/drop case only occur when the touch
tdresser
2015/01/06 14:20:16
In the drag and drop case, there are two windows i
jdduke (slow)
2015/01/06 16:49:54
OK, I just want to make sure we don't get into a s
tdresser
2015/01/07 17:01:15
That can happen, both with this patch, and on mast
| |
| 82 // crbug.com/373125 for details. | |
| 83 | |
|
jdduke (slow)
2015/01/05 22:35:14
No need to include the commented out code.
tdresser
2015/01/06 14:20:16
Done.
| |
| 84 // return false; | |
| 85 } else if (touch.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { | |
| 86 // We could have an active touch stream transfered to us, resulting in touch | |
| 87 // move or touch up events without associated touch down events. Ignore | |
| 88 // them. | |
| 89 return false; | |
| 90 } | |
| 91 | |
| 92 // If this is a touchmove event, and it isn't different from the last | |
|
jdduke (slow)
2015/01/06 16:49:54
Nit: This comment is somewhat redundant. Or maybe
tdresser
2015/01/07 17:01:15
Removed comment.
| |
| 93 // event, ignore it. | |
| 94 if (touch.type() == ET_TOUCH_MOVED && touch.x() == GetX(index) && | |
| 95 touch.y() == GetY(index)) { | |
| 96 return false; | |
| 97 } | |
| 98 | |
| 73 switch (touch.type()) { | 99 switch (touch.type()) { |
| 74 case ET_TOUCH_PRESSED: | 100 case ET_TOUCH_PRESSED: |
| 75 AddTouch(touch); | 101 AddTouch(touch); |
| 76 break; | 102 break; |
| 77 case ET_TOUCH_RELEASED: | 103 case ET_TOUCH_RELEASED: |
| 78 case ET_TOUCH_CANCELLED: | 104 case ET_TOUCH_CANCELLED: |
| 79 // Removing these touch points needs to be postponed until after the | 105 // Removing these touch points needs to be postponed until after the |
| 80 // MotionEvent has been dispatched. This cleanup occurs in | 106 // MotionEvent has been dispatched. This cleanup occurs in |
| 81 // CleanupRemovedTouchPoints. | 107 // CleanupRemovedTouchPoints. |
| 82 UpdateTouch(touch); | 108 UpdateTouch(touch); |
| 83 break; | 109 break; |
| 84 case ET_TOUCH_MOVED: | 110 case ET_TOUCH_MOVED: |
| 85 UpdateTouch(touch); | 111 UpdateTouch(touch); |
| 86 break; | 112 break; |
| 87 default: | 113 default: |
| 88 NOTREACHED(); | 114 NOTREACHED(); |
| 89 break; | 115 return false; |
| 90 } | 116 } |
| 91 | 117 |
| 92 UpdateCachedAction(touch); | 118 UpdateCachedAction(touch); |
| 93 set_flags(touch.flags()); | 119 set_flags(touch.flags()); |
| 94 set_event_time(touch.time_stamp() + base::TimeTicks()); | 120 set_event_time(touch.time_stamp() + base::TimeTicks()); |
| 121 return true; | |
| 95 } | 122 } |
| 96 | 123 |
| 97 int MotionEventAura::GetId() const { | 124 int MotionEventAura::GetId() const { |
| 98 return GetPointerId(0); | 125 return GetPointerId(0); |
| 99 } | 126 } |
| 100 | 127 |
| 101 void MotionEventAura::CleanupRemovedTouchPoints(const TouchEvent& event) { | 128 void MotionEventAura::CleanupRemovedTouchPoints(const TouchEvent& event) { |
| 102 if (event.type() != ET_TOUCH_RELEASED && | 129 if (event.type() != ET_TOUCH_RELEASED && |
| 103 event.type() != ET_TOUCH_CANCELLED) { | 130 event.type() != ET_TOUCH_CANCELLED) { |
| 104 return; | 131 return; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 } | 187 } |
| 161 | 188 |
| 162 int MotionEventAura::GetIndexFromId(int id) const { | 189 int MotionEventAura::GetIndexFromId(int id) const { |
| 163 int index = FindPointerIndexOfId(id); | 190 int index = FindPointerIndexOfId(id); |
| 164 DCHECK_GE(index, 0); | 191 DCHECK_GE(index, 0); |
| 165 DCHECK_LT(index, static_cast<int>(GetPointerCount())); | 192 DCHECK_LT(index, static_cast<int>(GetPointerCount())); |
| 166 return index; | 193 return index; |
| 167 } | 194 } |
| 168 | 195 |
| 169 } // namespace ui | 196 } // namespace ui |
| OLD | NEW |