| 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/common/input/web_input_event_traits.h" | 5 #include "content/common/input/web_input_event_traits.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 using WebKit::WebGestureEvent; | 9 using blink::WebGestureEvent; |
| 10 using WebKit::WebInputEvent; | 10 using blink::WebInputEvent; |
| 11 using WebKit::WebKeyboardEvent; | 11 using blink::WebKeyboardEvent; |
| 12 using WebKit::WebMouseEvent; | 12 using blink::WebMouseEvent; |
| 13 using WebKit::WebMouseWheelEvent; | 13 using blink::WebMouseWheelEvent; |
| 14 using WebKit::WebTouchEvent; | 14 using blink::WebTouchEvent; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 bool CanCoalesce(const WebKeyboardEvent& event_to_coalesce, | 19 bool CanCoalesce(const WebKeyboardEvent& event_to_coalesce, |
| 20 const WebKeyboardEvent& event) { | 20 const WebKeyboardEvent& event) { |
| 21 return false; | 21 return false; |
| 22 } | 22 } |
| 23 | 23 |
| 24 void Coalesce(const WebKeyboardEvent& event_to_coalesce, | 24 void Coalesce(const WebKeyboardEvent& event_to_coalesce, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 DCHECK(CanCoalesce(event_to_coalesce, *event)); | 99 DCHECK(CanCoalesce(event_to_coalesce, *event)); |
| 100 // The WebTouchPoints include absolute position information. So it is | 100 // The WebTouchPoints include absolute position information. So it is |
| 101 // sufficient to simply replace the previous event with the new event-> | 101 // sufficient to simply replace the previous event with the new event-> |
| 102 // However, it is necessary to make sure that all the points have the | 102 // However, it is necessary to make sure that all the points have the |
| 103 // correct state, i.e. the touch-points that moved in the last event, but | 103 // correct state, i.e. the touch-points that moved in the last event, but |
| 104 // didn't change in the current event, will have Stationary state. It is | 104 // didn't change in the current event, will have Stationary state. It is |
| 105 // necessary to change them back to Moved state. | 105 // necessary to change them back to Moved state. |
| 106 WebTouchEvent old_event = *event; | 106 WebTouchEvent old_event = *event; |
| 107 *event = event_to_coalesce; | 107 *event = event_to_coalesce; |
| 108 for (unsigned i = 0; i < event->touchesLength; ++i) { | 108 for (unsigned i = 0; i < event->touchesLength; ++i) { |
| 109 if (old_event.touches[i].state == WebKit::WebTouchPoint::StateMoved) | 109 if (old_event.touches[i].state == blink::WebTouchPoint::StateMoved) |
| 110 event->touches[i].state = WebKit::WebTouchPoint::StateMoved; | 110 event->touches[i].state = blink::WebTouchPoint::StateMoved; |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool CanCoalesce(const WebGestureEvent& event_to_coalesce, | 114 bool CanCoalesce(const WebGestureEvent& event_to_coalesce, |
| 115 const WebGestureEvent& event) { | 115 const WebGestureEvent& event) { |
| 116 return event.type == event_to_coalesce.type && | 116 return event.type == event_to_coalesce.type && |
| 117 event.type == WebInputEvent::GestureScrollUpdate && | 117 event.type == WebInputEvent::GestureScrollUpdate && |
| 118 event.modifiers == event_to_coalesce.modifiers; | 118 event.modifiers == event_to_coalesce.modifiers; |
| 119 } | 119 } |
| 120 | 120 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 CASE_TYPE(GestureLongPress); | 230 CASE_TYPE(GestureLongPress); |
| 231 CASE_TYPE(GestureLongTap); | 231 CASE_TYPE(GestureLongTap); |
| 232 CASE_TYPE(GesturePinchBegin); | 232 CASE_TYPE(GesturePinchBegin); |
| 233 CASE_TYPE(GesturePinchEnd); | 233 CASE_TYPE(GesturePinchEnd); |
| 234 CASE_TYPE(GesturePinchUpdate); | 234 CASE_TYPE(GesturePinchUpdate); |
| 235 CASE_TYPE(TouchStart); | 235 CASE_TYPE(TouchStart); |
| 236 CASE_TYPE(TouchMove); | 236 CASE_TYPE(TouchMove); |
| 237 CASE_TYPE(TouchEnd); | 237 CASE_TYPE(TouchEnd); |
| 238 CASE_TYPE(TouchCancel); | 238 CASE_TYPE(TouchCancel); |
| 239 default: | 239 default: |
| 240 // Must include default to let WebKit::WebInputEvent add new event types | 240 // Must include default to let blink::WebInputEvent add new event types |
| 241 // before they're added here. | 241 // before they're added here. |
| 242 DLOG(WARNING) << | 242 DLOG(WARNING) << |
| 243 "Unhandled WebInputEvent type in WebInputEventTraits::GetName.\n"; | 243 "Unhandled WebInputEvent type in WebInputEventTraits::GetName.\n"; |
| 244 break; | 244 break; |
| 245 } | 245 } |
| 246 #undef CASE_TYPE | 246 #undef CASE_TYPE |
| 247 return ""; | 247 return ""; |
| 248 } | 248 } |
| 249 | 249 |
| 250 size_t WebInputEventTraits::GetSize(WebInputEvent::Type type) { | 250 size_t WebInputEventTraits::GetSize(WebInputEvent::Type type) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 277 &event); | 277 &event); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void WebInputEventTraits::Coalesce(const WebInputEvent& event_to_coalesce, | 280 void WebInputEventTraits::Coalesce(const WebInputEvent& event_to_coalesce, |
| 281 WebInputEvent* event) { | 281 WebInputEvent* event) { |
| 282 DCHECK(event); | 282 DCHECK(event); |
| 283 Apply(WebInputEventCoalesce(), event->type, event_to_coalesce, event); | 283 Apply(WebInputEventCoalesce(), event->type, event_to_coalesce, event); |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace content | 286 } // namespace content |
| OLD | NEW |