summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authormiletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-07 20:13:15 +0000
committermiletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-07 20:13:15 +0000
commitea220a6ffc300f5b1f3e1826e00f362b5c591e88 (patch)
tree40bec669ff8b8a7dc01e7d7be6a45142d34b08bf /ui
parentb6a72aeee04efe9e9a67b1b31a3684e7e674931b (diff)
downloadchromium_src-ea220a6ffc300f5b1f3e1826e00f362b5c591e88.zip
chromium_src-ea220a6ffc300f5b1f3e1826e00f362b5c591e88.tar.gz
chromium_src-ea220a6ffc300f5b1f3e1826e00f362b5c591e88.tar.bz2
Always copy touch event's LatencyInfo into gesture event's LatencyInfo
Previously we only copy touch event's LatencyInfo into gesture event's LatencyInfo when the touch event does not cause any rendering. This is based on the assumption that if the touch event causes any rendering, it should be consumed so no gesture event is actually generated. This could be wrong that touch event is not prevented default, but it still causes rendering and turns into gesture event. So the simple solution is we always copy some of the touch event's LatencyInfo that we are interested in into gesture event's LatencyInfo, regardless of whether the touch event causes rendering or not. BUG=338819 TEST=Follow the test in the bug and make sure the first GestureScrollUpdate contains the some key latency components from the TouchMove's LatencyInfo. Review URL: https://codereview.chromium.org/146303004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/events/gestures/gesture_sequence.cc34
-rw-r--r--ui/events/latency_info.cc15
-rw-r--r--ui/events/latency_info.h3
3 files changed, 30 insertions, 22 deletions
diff --git a/ui/events/gestures/gesture_sequence.cc b/ui/events/gestures/gesture_sequence.cc
index 95e48d9..6427c17 100644
--- a/ui/events/gestures/gesture_sequence.cc
+++ b/ui/events/gestures/gesture_sequence.cc
@@ -457,28 +457,18 @@ float CalibrateFlingVelocity(float velocity) {
void UpdateGestureEventLatencyInfo(const TouchEvent& event,
GestureSequence::Gestures* gestures) {
- // If the touch event does not cause any rendering scheduled, we first
- // end the touch event's LatencyInfo. Then we copy the touch event's
- // LatencyInfo into the generated gesture's LatencyInfo. Since one touch
- // event can generate multiple gesture events, we have to clear the gesture
- // event's trace_id, remove its ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
- // so when the gesture event passes through RWHI, a new trace_id will be
- // assigned and new ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will be added.
- if (!event.latency()->FindLatency(
- ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) {
- ui::LatencyInfo* touch_latency =
- const_cast<ui::LatencyInfo*>(event.latency());
- touch_latency->AddLatencyNumber(
- ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0);
- GestureSequence::Gestures::iterator it = gestures->begin();
- for (; it != gestures->end(); it++) {
- ui::LatencyInfo* gesture_latency = (*it)->latency();
- *gesture_latency = *touch_latency;
- gesture_latency->trace_id = -1;
- gesture_latency->terminated = false;
- gesture_latency->RemoveLatency(
- ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT);
- }
+ // Copy some of the touch event's LatencyInfo into the generated gesture's
+ // LatencyInfo so we can compute touch to scroll latency from gesture
+ // event's LatencyInfo.
+ GestureSequence::Gestures::iterator it = gestures->begin();
+ for (; it != gestures->end(); it++) {
+ ui::LatencyInfo* gesture_latency = (*it)->latency();
+ gesture_latency->CopyLatencyFrom(
+ *event.latency(), ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT);
+ gesture_latency->CopyLatencyFrom(
+ *event.latency(), ui::INPUT_EVENT_LATENCY_UI_COMPONENT);
+ gesture_latency->CopyLatencyFrom(
+ *event.latency(), ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT);
}
}
diff --git a/ui/events/latency_info.cc b/ui/events/latency_info.cc
index 5c9f8c8..0e38f20 100644
--- a/ui/events/latency_info.cc
+++ b/ui/events/latency_info.cc
@@ -132,6 +132,21 @@ bool LatencyInfo::Verify(const std::vector<LatencyInfo>& latency_info,
return true;
}
+void LatencyInfo::CopyLatencyFrom(const LatencyInfo& other,
+ LatencyComponentType type) {
+ for (LatencyMap::const_iterator it = other.latency_components.begin();
+ it != other.latency_components.end();
+ ++it) {
+ if (it->first.first == type) {
+ AddLatencyNumberWithTimestamp(it->first.first,
+ it->first.second,
+ it->second.sequence_number,
+ it->second.event_time,
+ it->second.event_count);
+ }
+ }
+}
+
void LatencyInfo::AddNewLatencyFrom(const LatencyInfo& other) {
for (LatencyMap::const_iterator it = other.latency_components.begin();
it != other.latency_components.end();
diff --git a/ui/events/latency_info.h b/ui/events/latency_info.h
index 86ce7ec..332b8ff 100644
--- a/ui/events/latency_info.h
+++ b/ui/events/latency_info.h
@@ -98,6 +98,9 @@ struct EVENTS_BASE_EXPORT LatencyInfo {
static bool Verify(const std::vector<LatencyInfo>& latency_info,
const char* referring_msg);
+ // Copy LatencyComponents with type |type| from |other| into |this|.
+ void CopyLatencyFrom(const LatencyInfo& other, LatencyComponentType type);
+
// Add LatencyComponents that are in |other| but not in |this|.
void AddNewLatencyFrom(const LatencyInfo& other);