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 "content/browser/renderer_host/ui_events_helper.h" | 5 #include "content/browser/renderer_host/ui_events_helper.h" |
6 | 6 |
7 #include "content/common/input/web_touch_event_traits.h" | 7 #include "content/common/input/web_touch_event_traits.h" |
8 #include "third_party/WebKit/public/web/WebInputEvent.h" | 8 #include "third_party/WebKit/public/web/WebInputEvent.h" |
9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
10 #include "ui/events/event_constants.h" | 10 #include "ui/events/event_constants.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 return NULL; | 303 return NULL; |
304 | 304 |
305 // The spec requires the radii values to be positive (and 1 when unknown). | 305 // The spec requires the radii values to be positive (and 1 when unknown). |
306 point->radiusX = std::max(1.f, event.radius_x()); | 306 point->radiusX = std::max(1.f, event.radius_x()); |
307 point->radiusY = std::max(1.f, event.radius_y()); | 307 point->radiusY = std::max(1.f, event.radius_y()); |
308 point->rotationAngle = event.rotation_angle(); | 308 point->rotationAngle = event.rotation_angle(); |
309 point->force = event.force(); | 309 point->force = event.force(); |
310 | 310 |
311 // Update the location and state of the point. | 311 // Update the location and state of the point. |
312 point->state = TouchPointStateFromEvent(event); | 312 point->state = TouchPointStateFromEvent(event); |
313 if (point->state == blink::WebTouchPoint::StateMoved) { | |
314 // It is possible for badly written touch drivers to emit Move events even | |
315 // when the touch location hasn't changed. In such cases, consume the event | |
316 // and pretend nothing happened. | |
317 if (point->position.x == event.x() && point->position.y == event.y()) | |
318 return NULL; | |
319 } | |
320 point->position.x = event.x(); | 313 point->position.x = event.x(); |
321 point->position.y = event.y(); | 314 point->position.y = event.y(); |
322 | 315 |
323 const gfx::PointF& root_point = event.root_location_f(); | 316 const gfx::PointF& root_point = event.root_location_f(); |
324 point->screenPosition.x = root_point.x(); | 317 point->screenPosition.x = root_point.x(); |
325 point->screenPosition.y = root_point.y(); | 318 point->screenPosition.y = root_point.y(); |
326 | 319 |
327 // Mark the rest of the points as stationary. | 320 // Mark the rest of the points as stationary. |
328 for (unsigned i = 0; i < web_event->touchesLength; ++i) { | 321 for (unsigned i = 0; i < web_event->touchesLength; ++i) { |
329 blink::WebTouchPoint* iter = web_event->touches + i; | 322 blink::WebTouchPoint* iter = web_event->touches + i; |
330 if (iter != point) | 323 if (iter != point) |
331 iter->state = blink::WebTouchPoint::StateStationary; | 324 iter->state = blink::WebTouchPoint::StateStationary; |
332 } | 325 } |
333 | 326 |
334 // Update the type of the touch event. | 327 // Update the type of the touch event. |
335 WebTouchEventTraits::ResetType(TouchEventTypeFromEvent(event), | 328 WebTouchEventTraits::ResetType(TouchEventTypeFromEvent(event), |
336 event.time_stamp().InSecondsF(), | 329 event.time_stamp().InSecondsF(), |
337 web_event); | 330 web_event); |
338 web_event->modifiers = EventFlagsToWebEventModifiers(event.flags()); | 331 web_event->modifiers = EventFlagsToWebEventModifiers(event.flags()); |
339 | 332 |
340 return point; | 333 return point; |
341 } | 334 } |
342 | 335 |
343 } // namespace content | 336 } // namespace content |
OLD | NEW |