| 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/touch_event_queue.h" | 5 #include "content/browser/renderer_host/touch_event_queue.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_impl.h" | 8 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 9 #include "content/public/browser/render_widget_host_view.h" | 9 #include "content/public/browser/render_widget_host_view.h" |
| 10 #include "content/port/browser/render_widget_host_view_port.h" | 10 #include "content/port/browser/render_widget_host_view_port.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 const WebKit::WebTouchEvent& TouchEventQueue::GetLatestEvent() const { | 162 const WebKit::WebTouchEvent& TouchEventQueue::GetLatestEvent() const { |
| 163 return touch_queue_.back()->coalesced_event(); | 163 return touch_queue_.back()->coalesced_event(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void TouchEventQueue::PopTouchEventToView(InputEventAckState ack_result) { | 166 void TouchEventQueue::PopTouchEventToView(InputEventAckState ack_result) { |
| 167 if (touch_queue_.empty()) | 167 if (touch_queue_.empty()) |
| 168 return; | 168 return; |
| 169 scoped_ptr<CoalescedWebTouchEvent> acked_event(touch_queue_.front()); | 169 scoped_ptr<CoalescedWebTouchEvent> acked_event(touch_queue_.front()); |
| 170 touch_queue_.pop_front(); | 170 touch_queue_.pop_front(); |
| 171 | 171 |
| 172 WebKit::WebInputEvent::Type event_type = acked_event->coalesced_event().type; |
| 173 if (event_type == WebKit::WebInputEvent::TouchCancel && |
| 174 render_widget_host_->skip_next_acked_touch_cancel()) { |
| 175 render_widget_host_->skip_next_acked_touch_cancel() = false; |
| 176 return; |
| 177 } |
| 178 |
| 172 // Note that acking the touch-event may result in multiple gestures being sent | 179 // Note that acking the touch-event may result in multiple gestures being sent |
| 173 // to the renderer. | 180 // to the renderer. |
| 174 RenderWidgetHostViewPort* view = RenderWidgetHostViewPort::FromRWHV( | 181 RenderWidgetHostViewPort* view = RenderWidgetHostViewPort::FromRWHV( |
| 175 render_widget_host_->GetView()); | 182 render_widget_host_->GetView()); |
| 176 for (WebTouchEventList::const_iterator iter = acked_event->begin(), | 183 for (WebTouchEventList::const_iterator iter = acked_event->begin(), |
| 177 end = acked_event->end(); | 184 end = acked_event->end(); |
| 178 iter != end; ++iter) { | 185 iter != end; ++iter) { |
| 179 view->ProcessAckedTouchEvent((*iter), ack_result); | 186 view->ProcessAckedTouchEvent((*iter), ack_result); |
| 180 } | 187 } |
| 181 } | 188 } |
| 182 | 189 |
| 183 bool TouchEventQueue::ShouldForwardToRenderer( | 190 bool TouchEventQueue::ShouldForwardToRenderer( |
| 184 const WebKit::WebTouchEvent& event) const { | 191 const WebKit::WebTouchEvent& event) const { |
| 185 // Touch press events should always be forwarded to the renderer. | 192 // Touch press events should always be forwarded to the renderer. |
| 186 if (event.type == WebKit::WebInputEvent::TouchStart) | 193 if (event.type == WebKit::WebInputEvent::TouchStart) |
| 187 return true; | 194 return true; |
| 188 | 195 |
| 196 // If scrolling is in progress, don't sned touch moves to renderer. |
| 197 if (render_widget_host_->scroll_update_in_progress() && |
| 198 event.type == WebKit::WebInputEvent::TouchMove) |
| 199 return false; |
| 200 |
| 189 for (unsigned int i = 0; i < event.touchesLength; ++i) { | 201 for (unsigned int i = 0; i < event.touchesLength; ++i) { |
| 190 const WebKit::WebTouchPoint& point = event.touches[i]; | 202 const WebKit::WebTouchPoint& point = event.touches[i]; |
| 191 // If a point has been stationary, then don't take it into account. | 203 // If a point has been stationary, then don't take it into account. |
| 192 if (point.state == WebKit::WebTouchPoint::StateStationary) | 204 if (point.state == WebKit::WebTouchPoint::StateStationary) |
| 193 continue; | 205 continue; |
| 194 | 206 |
| 195 if (touch_ack_states_.count(point.id) > 0) { | 207 if (touch_ack_states_.count(point.id) > 0) { |
| 196 if (touch_ack_states_.find(point.id)->second != | 208 if (touch_ack_states_.find(point.id)->second != |
| 197 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) | 209 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) |
| 198 return true; | 210 return true; |
| 199 } else { | 211 } else { |
| 200 // If the ACK status of a point is unknown, then the event should be | 212 // If the ACK status of a point is unknown, then the event should be |
| 201 // forwarded to the renderer. | 213 // forwarded to the renderer. |
| 202 return true; | 214 return true; |
| 203 } | 215 } |
| 204 } | 216 } |
| 205 | 217 |
| 206 return false; | 218 return false; |
| 207 } | 219 } |
| 208 | 220 |
| 209 } // namespace content | 221 } // namespace content |
| OLD | NEW |