| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/touch_emulator.h" | 5 #include "content/browser/renderer_host/input/touch_emulator.h" |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/input/motion_event_web.h" | 7 #include "content/browser/renderer_host/input/motion_event_web.h" |
| 8 #include "content/browser/renderer_host/input/web_input_event_util.h" | 8 #include "content/browser/renderer_host/input/web_input_event_util.h" |
| 9 #include "content/common/input/web_touch_event_traits.h" | 9 #include "content/common/input/web_touch_event_traits.h" |
| 10 #include "content/grit/content_resources.h" | 10 #include "content/grit/content_resources.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 if (is_sequence_start) | 210 if (is_sequence_start) |
| 211 native_stream_active_sequence_count_++; | 211 native_stream_active_sequence_count_++; |
| 212 return false; | 212 return false; |
| 213 } | 213 } |
| 214 | 214 |
| 215 void TouchEmulator::ForwardTouchEventToClient() { | 215 void TouchEmulator::ForwardTouchEventToClient() { |
| 216 const bool event_consumed = true; | 216 const bool event_consumed = true; |
| 217 // Block emulated event when emulated native stream is active. | 217 // Block emulated event when emulated native stream is active. |
| 218 if (native_stream_active_sequence_count_) { | 218 if (native_stream_active_sequence_count_) { |
| 219 gesture_provider_.OnTouchEventAck(event_consumed); | 219 gesture_provider_.OnAsyncTouchEventAck(event_consumed); |
| 220 return; | 220 return; |
| 221 } | 221 } |
| 222 | 222 |
| 223 bool is_sequence_start = | 223 bool is_sequence_start = |
| 224 WebTouchEventTraits::IsTouchSequenceStart(touch_event_); | 224 WebTouchEventTraits::IsTouchSequenceStart(touch_event_); |
| 225 // Do not allow middle-sequence event to pass through, if start was blocked. | 225 // Do not allow middle-sequence event to pass through, if start was blocked. |
| 226 if (!emulated_stream_active_sequence_count_ && !is_sequence_start) { | 226 if (!emulated_stream_active_sequence_count_ && !is_sequence_start) { |
| 227 gesture_provider_.OnTouchEventAck(event_consumed); | 227 gesture_provider_.OnAsyncTouchEventAck(event_consumed); |
| 228 return; | 228 return; |
| 229 } | 229 } |
| 230 | 230 |
| 231 if (is_sequence_start) | 231 if (is_sequence_start) |
| 232 emulated_stream_active_sequence_count_++; | 232 emulated_stream_active_sequence_count_++; |
| 233 client_->ForwardEmulatedTouchEvent(touch_event_); | 233 client_->ForwardEmulatedTouchEvent(touch_event_); |
| 234 } | 234 } |
| 235 | 235 |
| 236 bool TouchEmulator::HandleTouchEventAck( | 236 bool TouchEmulator::HandleTouchEventAck( |
| 237 const blink::WebTouchEvent& event, InputEventAckState ack_result) { | 237 const blink::WebTouchEvent& event, InputEventAckState ack_result) { |
| 238 bool is_sequence_end = WebTouchEventTraits::IsTouchSequenceEnd(event); | 238 bool is_sequence_end = WebTouchEventTraits::IsTouchSequenceEnd(event); |
| 239 if (emulated_stream_active_sequence_count_) { | 239 if (emulated_stream_active_sequence_count_) { |
| 240 if (is_sequence_end) | 240 if (is_sequence_end) |
| 241 emulated_stream_active_sequence_count_--; | 241 emulated_stream_active_sequence_count_--; |
| 242 | 242 |
| 243 const bool event_consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; | 243 const bool event_consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; |
| 244 gesture_provider_.OnTouchEventAck(event_consumed); | 244 gesture_provider_.OnAsyncTouchEventAck(event_consumed); |
| 245 return true; | 245 return true; |
| 246 } | 246 } |
| 247 | 247 |
| 248 // We may have not seen native touch sequence start (when created in the | 248 // We may have not seen native touch sequence start (when created in the |
| 249 // middle of a sequence), so don't decrement sequence count below zero. | 249 // middle of a sequence), so don't decrement sequence count below zero. |
| 250 if (is_sequence_end && native_stream_active_sequence_count_) | 250 if (is_sequence_end && native_stream_active_sequence_count_) |
| 251 native_stream_active_sequence_count_--; | 251 native_stream_active_sequence_count_--; |
| 252 return false; | 252 return false; |
| 253 } | 253 } |
| 254 | 254 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 point.screenPosition.y = mouse_event.globalY; | 432 point.screenPosition.y = mouse_event.globalY; |
| 433 | 433 |
| 434 return true; | 434 return true; |
| 435 } | 435 } |
| 436 | 436 |
| 437 bool TouchEmulator::InPinchGestureMode() const { | 437 bool TouchEmulator::InPinchGestureMode() const { |
| 438 return shift_pressed_; | 438 return shift_pressed_; |
| 439 } | 439 } |
| 440 | 440 |
| 441 } // namespace content | 441 } // namespace content |
| OLD | NEW |