Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gesture_sequence.h" | 5 #include "ui/events/gestures/gesture_sequence.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 point.Reset(); | 589 point.Reset(); |
| 590 --point_count_; | 590 --point_count_; |
| 591 CHECK_GE(point_count_, 0); | 591 CHECK_GE(point_count_, 0); |
| 592 RecreateBoundingBox(); | 592 RecreateBoundingBox(); |
| 593 if (state_ == GS_PINCH) { | 593 if (state_ == GS_PINCH) { |
| 594 pinch_distance_current_ = BoundingBoxDiagonal(bounding_box_); | 594 pinch_distance_current_ = BoundingBoxDiagonal(bounding_box_); |
| 595 pinch_distance_start_ = pinch_distance_current_; | 595 pinch_distance_start_ = pinch_distance_current_; |
| 596 } | 596 } |
| 597 } | 597 } |
| 598 | 598 |
| 599 const ui::LatencyInfo* touch_latency = event.latency(); | 599 UpdateGestureEventLatencyInfo(event, gestures.get()); |
| 600 Gestures::iterator it = gestures->begin(); | |
| 601 for (; it != gestures->end(); it++) { | |
| 602 (*it)->latency()->MergeWith(*touch_latency); | |
| 603 } | |
| 604 | |
| 605 return gestures.release(); | 600 return gestures.release(); |
| 606 } | 601 } |
| 607 | 602 |
| 608 void GestureSequence::RecreateBoundingBox() { | 603 void GestureSequence::RecreateBoundingBox() { |
| 609 // TODO(sad): Recreating the bounding box at every touch-event is not very | 604 // TODO(sad): Recreating the bounding box at every touch-event is not very |
| 610 // efficient. This should be made better. | 605 // efficient. This should be made better. |
| 611 if (point_count_ == 0) { | 606 if (point_count_ == 0) { |
| 612 bounding_box_.SetRect(0, 0, 0, 0); | 607 bounding_box_.SetRect(0, 0, 0, 0); |
| 613 } else if (point_count_ == 1) { | 608 } else if (point_count_ == 1) { |
| 614 bounding_box_ = GetPointByPointId(0)->enclosing_rectangle(); | 609 bounding_box_ = GetPointByPointId(0)->enclosing_rectangle(); |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1228 event.type() != ui::ET_TOUCH_MOVED) | 1223 event.type() != ui::ET_TOUCH_MOVED) |
| 1229 return; | 1224 return; |
| 1230 | 1225 |
| 1231 // Since long press timer has been started, there should be a non-NULL point. | 1226 // Since long press timer has been started, there should be a non-NULL point. |
| 1232 const GesturePoint* point = GetPointByPointId(0); | 1227 const GesturePoint* point = GetPointByPointId(0); |
| 1233 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), | 1228 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), |
| 1234 event.location())) | 1229 event.location())) |
| 1235 GetLongPressTimer()->Stop(); | 1230 GetLongPressTimer()->Stop(); |
| 1236 } | 1231 } |
| 1237 | 1232 |
| 1233 void GestureSequence::UpdateGestureEventLatencyInfo(const TouchEvent& event, | |
|
sadrul
2013/10/10 21:58:38
Move this into an independent function in the anon
Yufeng Shen (Slow to review)
2013/10/10 22:52:15
Done.
| |
| 1234 Gestures* gestures) { | |
| 1235 // If the touch event does not cause any rendering scheduled, then | |
| 1236 // 1) If the touch event does not generate any gesture event, its | |
| 1237 // LatencyInfo ends here. | |
| 1238 // 2) If the touch event generates gesture events, its latencyinfo | |
| 1239 // is copied into the gesture events. | |
| 1240 if (!event.latency()->FindLatency( | |
| 1241 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { | |
| 1242 if (gestures->empty()) { | |
| 1243 ui::LatencyInfo* touch_latency = | |
| 1244 const_cast<ui::LatencyInfo*>(event.latency()); | |
| 1245 touch_latency->AddLatencyNumber( | |
| 1246 ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0); | |
| 1247 } else { | |
| 1248 Gestures::iterator it = gestures->begin(); | |
| 1249 for (; it != gestures->end(); it++) { | |
| 1250 (*it)->latency()->MergeWith(*event.latency()); | |
| 1251 // Inheriting the trace_id from the touch event's LatencyInfo | |
| 1252 (*it)->latency()->trace_id = event.latency()->trace_id; | |
| 1253 } | |
| 1254 } | |
| 1255 } | |
| 1256 } | |
| 1257 | |
| 1238 } // namespace ui | 1258 } // namespace ui |
| OLD | NEW |