| 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/input_router_impl.h" | 5 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 touch_scroll_started_sent_ = true; | 179 touch_scroll_started_sent_ = true; |
| 180 } | 180 } |
| 181 touch_event_queue_->OnGestureScrollEvent(gesture_event); | 181 touch_event_queue_->OnGestureScrollEvent(gesture_event); |
| 182 } | 182 } |
| 183 | 183 |
| 184 gesture_event_queue_.QueueEvent(gesture_event); | 184 gesture_event_queue_.QueueEvent(gesture_event); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void InputRouterImpl::SendTouchEvent( | 187 void InputRouterImpl::SendTouchEvent( |
| 188 const TouchEventWithLatencyInfo& touch_event) { | 188 const TouchEventWithLatencyInfo& touch_event) { |
| 189 input_stream_validator_.Validate(touch_event.event); | 189 TouchEventWithLatencyInfo updatd_touch_event = touch_event; |
| 190 touch_event_queue_->QueueEvent(touch_event); | 190 SetMovementXYForTouchPoints(&updatd_touch_event.event); |
| 191 input_stream_validator_.Validate(updatd_touch_event.event); |
| 192 touch_event_queue_->QueueEvent(updatd_touch_event); |
| 191 } | 193 } |
| 192 | 194 |
| 193 // Forwards MouseEvent without passing it through | 195 // Forwards MouseEvent without passing it through |
| 194 // TouchpadTapSuppressionController. | 196 // TouchpadTapSuppressionController. |
| 195 void InputRouterImpl::SendMouseEventImmediately( | 197 void InputRouterImpl::SendMouseEventImmediately( |
| 196 const MouseEventWithLatencyInfo& mouse_event) { | 198 const MouseEventWithLatencyInfo& mouse_event) { |
| 197 if (mouse_event.event.type() == blink::WebInputEvent::MouseMove) | 199 if (mouse_event.event.type() == blink::WebInputEvent::MouseMove) |
| 198 mouse_move_queue_.push_back(mouse_event); | 200 mouse_move_queue_.push_back(mouse_event); |
| 199 | 201 |
| 200 FilterAndSendWebInputEvent(mouse_event.event, mouse_event.latency); | 202 FilterAndSendWebInputEvent(mouse_event.event, mouse_event.latency); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 return; | 633 return; |
| 632 | 634 |
| 633 flush_requested_ = false; | 635 flush_requested_ = false; |
| 634 client_->DidFlush(); | 636 client_->DidFlush(); |
| 635 } | 637 } |
| 636 | 638 |
| 637 void InputRouterImpl::SetFrameTreeNodeId(int frameTreeNodeId) { | 639 void InputRouterImpl::SetFrameTreeNodeId(int frameTreeNodeId) { |
| 638 frame_tree_node_id_ = frameTreeNodeId; | 640 frame_tree_node_id_ = frameTreeNodeId; |
| 639 } | 641 } |
| 640 | 642 |
| 643 void InputRouterImpl::SetMovementXYForTouchPoints(blink::WebTouchEvent* event) { |
| 644 for (size_t i = 0; i < event->touchesLength; ++i) { |
| 645 blink::WebTouchPoint* touch_point = &event->touches[i]; |
| 646 if (touch_point->state == blink::WebTouchPoint::StateMoved) { |
| 647 const gfx::Point& last_position = global_touch_position_[touch_point->id]; |
| 648 touch_point->movementX = |
| 649 touch_point->screenPosition.x - last_position.x(); |
| 650 touch_point->movementY = |
| 651 touch_point->screenPosition.y - last_position.y(); |
| 652 global_touch_position_[touch_point->id].SetPoint( |
| 653 touch_point->screenPosition.x, touch_point->screenPosition.y); |
| 654 } else { |
| 655 touch_point->movementX = 0; |
| 656 touch_point->movementY = 0; |
| 657 if (touch_point->state == blink::WebTouchPoint::StateReleased || |
| 658 touch_point->state == blink::WebTouchPoint::StateCancelled) { |
| 659 global_touch_position_.erase(touch_point->id); |
| 660 } else if (touch_point->state == blink::WebTouchPoint::StatePressed) { |
| 661 DCHECK(global_touch_position_.find(touch_point->id) == |
| 662 global_touch_position_.end()); |
| 663 global_touch_position_[touch_point->id] = gfx::Point( |
| 664 touch_point->screenPosition.x, touch_point->screenPosition.y); |
| 665 } |
| 666 } |
| 667 } |
| 668 } |
| 669 |
| 641 } // namespace content | 670 } // namespace content |
| OLD | NEW |