OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/renderer_host/input/touch_event_queue.h" | 5 #include "content/browser/renderer_host/input/touch_event_queue.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "content/browser/renderer_host/input/timeout_monitor.h" | 11 #include "content/browser/renderer_host/input/timeout_monitor.h" |
12 #include "content/browser/renderer_host/input/web_touch_event_traits.h" | 12 #include "content/common/input/web_touch_event_traits.h" |
13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
14 #include "ui/gfx/geometry/point_f.h" | 14 #include "ui/gfx/geometry/point_f.h" |
15 | 15 |
16 using blink::WebInputEvent; | 16 using blink::WebInputEvent; |
17 using blink::WebTouchEvent; | 17 using blink::WebTouchEvent; |
18 using blink::WebTouchPoint; | 18 using blink::WebTouchPoint; |
19 using ui::LatencyInfo; | 19 using ui::LatencyInfo; |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 namespace { | 22 namespace { |
23 | 23 |
24 // Using a small epsilon when comparing slop distances allows pixel perfect | 24 // Using a small epsilon when comparing slop distances allows pixel perfect |
25 // slop determination when using fractional DIP coordinates (assuming the slop | 25 // slop determination when using fractional DIP coordinates (assuming the slop |
26 // region and DPI scale are reasonably proportioned). | 26 // region and DPI scale are reasonably proportioned). |
27 const float kSlopEpsilon = .05f; | 27 const float kSlopEpsilon = .05f; |
28 | 28 |
29 typedef std::vector<TouchEventWithLatencyInfo> WebTouchEventWithLatencyList; | 29 typedef std::vector<TouchEventWithLatencyInfo> WebTouchEventWithLatencyList; |
30 | 30 |
31 TouchEventWithLatencyInfo ObtainCancelEventForTouchEvent( | 31 TouchEventWithLatencyInfo ObtainCancelEventForTouchEvent( |
32 const TouchEventWithLatencyInfo& event_to_cancel) { | 32 const TouchEventWithLatencyInfo& event_to_cancel) { |
33 TouchEventWithLatencyInfo event = event_to_cancel; | 33 TouchEventWithLatencyInfo event = event_to_cancel; |
34 event.event.type = WebInputEvent::TouchCancel; | 34 WebTouchEventTraits::ResetType(&event.event, |
35 for (size_t i = 0; i < event.event.touchesLength; i++) | 35 WebInputEvent::TouchCancel, |
36 event.event.touches[i].state = WebTouchPoint::StateCancelled; | 36 // FIXME: Shouldn't we use a fresh timestamp? |
37 event.event.timeStampSeconds, | |
jdduke (slow)
2014/04/23 21:55:47
Nah, I don't think it matters at this point.
Rick Byers
2014/04/23 23:15:35
Why? Shouldn't an app be able to see that a timeo
jdduke (slow)
2014/04/23 23:29:49
I think we're monotonically non-decreasing, and I
| |
38 WebTouchEventTraits::RESET_TOUCHES_STATE); | |
37 return event; | 39 return event; |
38 } | 40 } |
39 | 41 |
40 bool ShouldTouchTypeTriggerTimeout(WebInputEvent::Type type) { | 42 bool ShouldTouchTypeTriggerTimeout(WebInputEvent::Type type) { |
41 return type == WebInputEvent::TouchStart || | 43 return type == WebInputEvent::TouchStart || |
42 type == WebInputEvent::TouchMove; | 44 type == WebInputEvent::TouchMove; |
43 } | 45 } |
44 | 46 |
45 } // namespace | 47 } // namespace |
46 | 48 |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 } else if (event.type == WebInputEvent::TouchStart) { | 637 } else if (event.type == WebInputEvent::TouchStart) { |
636 for (unsigned i = 0; i < event.touchesLength; ++i) { | 638 for (unsigned i = 0; i < event.touchesLength; ++i) { |
637 const WebTouchPoint& point = event.touches[i]; | 639 const WebTouchPoint& point = event.touches[i]; |
638 if (point.state == WebTouchPoint::StatePressed) | 640 if (point.state == WebTouchPoint::StatePressed) |
639 touch_ack_states_[point.id] = ack_result; | 641 touch_ack_states_[point.id] = ack_result; |
640 } | 642 } |
641 } | 643 } |
642 } | 644 } |
643 | 645 |
644 } // namespace content | 646 } // namespace content |
OLD | NEW |