| 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 #ifndef CONTENT_PORT_BROWSER_EVENT_WITH_LATENCY_INFO_H_ | 5 #ifndef CONTENT_PORT_BROWSER_EVENT_WITH_LATENCY_INFO_H_ |
| 6 #define CONTENT_PORT_BROWSER_EVENT_WITH_LATENCY_INFO_H_ | 6 #define CONTENT_PORT_BROWSER_EVENT_WITH_LATENCY_INFO_H_ |
| 7 | 7 |
| 8 #include "ui/events/latency_info.h" | 8 #include "ui/events/latency_info.h" |
| 9 | 9 |
| 10 #include "content/common/input/web_input_event_traits.h" |
| 11 |
| 10 namespace WebKit { | 12 namespace WebKit { |
| 11 class WebGestureEvent; | 13 class WebGestureEvent; |
| 12 class WebMouseEvent; | 14 class WebMouseEvent; |
| 13 class WebMouseWheelEvent; | 15 class WebMouseWheelEvent; |
| 14 class WebTouchEvent; | 16 class WebTouchEvent; |
| 15 } | 17 } |
| 16 | 18 |
| 17 namespace content { | 19 namespace content { |
| 18 | 20 |
| 19 template <typename T> | 21 template <typename T> |
| 20 class EventWithLatencyInfo { | 22 class EventWithLatencyInfo { |
| 21 public: | 23 public: |
| 22 T event; | 24 T event; |
| 23 ui::LatencyInfo latency; | 25 ui::LatencyInfo latency; |
| 24 | 26 |
| 25 EventWithLatencyInfo(const T& e, const ui::LatencyInfo& l) | 27 EventWithLatencyInfo(const T& e, const ui::LatencyInfo& l) |
| 26 : event(e), latency(l) {} | 28 : event(e), latency(l) {} |
| 27 | 29 |
| 28 EventWithLatencyInfo() {} | 30 EventWithLatencyInfo() {} |
| 31 |
| 32 bool CanCoalesceWith(const EventWithLatencyInfo& other) |
| 33 const WARN_UNUSED_RESULT { |
| 34 return WebInputEventTraits::CanCoalesce(other.event, event); |
| 35 } |
| 36 |
| 37 void CoalesceWith(const EventWithLatencyInfo& other) { |
| 38 WebInputEventTraits::Coalesce(other.event, &event); |
| 39 latency.MergeWith(other.latency); |
| 40 } |
| 29 }; | 41 }; |
| 30 | 42 |
| 31 typedef EventWithLatencyInfo<WebKit::WebGestureEvent> | 43 typedef EventWithLatencyInfo<WebKit::WebGestureEvent> |
| 32 GestureEventWithLatencyInfo; | 44 GestureEventWithLatencyInfo; |
| 33 typedef EventWithLatencyInfo<WebKit::WebMouseWheelEvent> | 45 typedef EventWithLatencyInfo<WebKit::WebMouseWheelEvent> |
| 34 MouseWheelEventWithLatencyInfo; | 46 MouseWheelEventWithLatencyInfo; |
| 35 typedef EventWithLatencyInfo<WebKit::WebMouseEvent> | 47 typedef EventWithLatencyInfo<WebKit::WebMouseEvent> |
| 36 MouseEventWithLatencyInfo; | 48 MouseEventWithLatencyInfo; |
| 37 typedef EventWithLatencyInfo<WebKit::WebTouchEvent> | 49 typedef EventWithLatencyInfo<WebKit::WebTouchEvent> |
| 38 TouchEventWithLatencyInfo; | 50 TouchEventWithLatencyInfo; |
| 39 | 51 |
| 40 } // namespace content | 52 } // namespace content |
| 41 | 53 |
| 42 #endif // CONTENT_PORT_BROWSER_EVENT_WITH_LATENCY_INFO_H_ | 54 #endif // CONTENT_PORT_BROWSER_EVENT_WITH_LATENCY_INFO_H_ |
| OLD | NEW |