| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "content/browser/renderer_host/input/motion_event_web.h" | 8 #include "content/browser/renderer_host/input/motion_event_web.h" |
| 9 #include "content/browser/renderer_host/ui_events_helper.h" |
| 9 #include "content/common/input/web_touch_event_traits.h" | 10 #include "content/common/input/web_touch_event_traits.h" |
| 10 #include "content/grit/content_resources.h" | 11 #include "content/grit/content_resources.h" |
| 11 #include "content/public/common/content_client.h" | 12 #include "content/public/common/content_client.h" |
| 12 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 13 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | 14 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
| 14 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" | 15 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" |
| 15 #include "third_party/WebKit/public/platform/WebMouseEvent.h" | 16 #include "third_party/WebKit/public/platform/WebMouseEvent.h" |
| 16 #include "ui/events/base_event_utils.h" | 17 #include "ui/events/base_event_utils.h" |
| 17 #include "ui/events/blink/blink_event_util.h" | 18 #include "ui/events/blink/blink_event_util.h" |
| 18 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 19 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 249 } |
| 249 | 250 |
| 250 void TouchEmulator::HandleEmulatedTouchEvent(blink::WebTouchEvent event) { | 251 void TouchEmulator::HandleEmulatedTouchEvent(blink::WebTouchEvent event) { |
| 251 DCHECK(gesture_provider_); | 252 DCHECK(gesture_provider_); |
| 252 event.unique_touch_event_id = ui::GetNextTouchEventId(); | 253 event.unique_touch_event_id = ui::GetNextTouchEventId(); |
| 253 auto result = gesture_provider_->OnTouchEvent(MotionEventWeb(event)); | 254 auto result = gesture_provider_->OnTouchEvent(MotionEventWeb(event)); |
| 254 if (!result.succeeded) | 255 if (!result.succeeded) |
| 255 return; | 256 return; |
| 256 | 257 |
| 257 const bool event_consumed = true; | 258 const bool event_consumed = true; |
| 259 const bool is_source_touch_event_set_non_blocking = false; |
| 258 // Block emulated event when emulated native stream is active. | 260 // Block emulated event when emulated native stream is active. |
| 259 if (native_stream_active_sequence_count_) { | 261 if (native_stream_active_sequence_count_) { |
| 260 gesture_provider_->OnTouchEventAck(event.unique_touch_event_id, | 262 gesture_provider_->OnTouchEventAck(event.unique_touch_event_id, |
| 261 event_consumed); | 263 event_consumed, |
| 264 is_source_touch_event_set_non_blocking); |
| 262 return; | 265 return; |
| 263 } | 266 } |
| 264 | 267 |
| 265 bool is_sequence_start = WebTouchEventTraits::IsTouchSequenceStart(event); | 268 bool is_sequence_start = WebTouchEventTraits::IsTouchSequenceStart(event); |
| 266 // Do not allow middle-sequence event to pass through, if start was blocked. | 269 // Do not allow middle-sequence event to pass through, if start was blocked. |
| 267 if (!emulated_stream_active_sequence_count_ && !is_sequence_start) { | 270 if (!emulated_stream_active_sequence_count_ && !is_sequence_start) { |
| 268 gesture_provider_->OnTouchEventAck(event.unique_touch_event_id, | 271 gesture_provider_->OnTouchEventAck(event.unique_touch_event_id, |
| 269 event_consumed); | 272 event_consumed, |
| 273 is_source_touch_event_set_non_blocking); |
| 270 return; | 274 return; |
| 271 } | 275 } |
| 272 | 276 |
| 273 if (is_sequence_start) | 277 if (is_sequence_start) |
| 274 emulated_stream_active_sequence_count_++; | 278 emulated_stream_active_sequence_count_++; |
| 275 | 279 |
| 276 event.moved_beyond_slop_region = result.moved_beyond_slop_region; | 280 event.moved_beyond_slop_region = result.moved_beyond_slop_region; |
| 277 client_->ForwardEmulatedTouchEvent(event); | 281 client_->ForwardEmulatedTouchEvent(event); |
| 278 } | 282 } |
| 279 | 283 |
| 280 bool TouchEmulator::HandleTouchEventAck( | 284 bool TouchEmulator::HandleTouchEventAck( |
| 281 const blink::WebTouchEvent& event, InputEventAckState ack_result) { | 285 const blink::WebTouchEvent& event, InputEventAckState ack_result) { |
| 282 bool is_sequence_end = WebTouchEventTraits::IsTouchSequenceEnd(event); | 286 bool is_sequence_end = WebTouchEventTraits::IsTouchSequenceEnd(event); |
| 283 if (emulated_stream_active_sequence_count_) { | 287 if (emulated_stream_active_sequence_count_) { |
| 284 if (is_sequence_end) | 288 if (is_sequence_end) |
| 285 emulated_stream_active_sequence_count_--; | 289 emulated_stream_active_sequence_count_--; |
| 286 | 290 |
| 287 const bool event_consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; | 291 const bool event_consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; |
| 288 if (gesture_provider_) | 292 if (gesture_provider_) |
| 289 gesture_provider_->OnTouchEventAck(event.unique_touch_event_id, | 293 gesture_provider_->OnTouchEventAck( |
| 290 event_consumed); | 294 event.unique_touch_event_id, event_consumed, |
| 295 InputEventAckStateIsSetNonBlocking(ack_result)); |
| 291 return true; | 296 return true; |
| 292 } | 297 } |
| 293 | 298 |
| 294 // We may have not seen native touch sequence start (when created in the | 299 // We may have not seen native touch sequence start (when created in the |
| 295 // middle of a sequence), so don't decrement sequence count below zero. | 300 // middle of a sequence), so don't decrement sequence count below zero. |
| 296 if (is_sequence_end && native_stream_active_sequence_count_) | 301 if (is_sequence_end && native_stream_active_sequence_count_) |
| 297 native_stream_active_sequence_count_--; | 302 native_stream_active_sequence_count_--; |
| 298 return false; | 303 return false; |
| 299 } | 304 } |
| 300 | 305 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 point.tilt_x = 0; | 479 point.tilt_x = 0; |
| 475 point.tilt_y = 0; | 480 point.tilt_y = 0; |
| 476 point.pointer_type = blink::WebPointerProperties::PointerType::kTouch; | 481 point.pointer_type = blink::WebPointerProperties::PointerType::kTouch; |
| 477 } | 482 } |
| 478 | 483 |
| 479 bool TouchEmulator::InPinchGestureMode() const { | 484 bool TouchEmulator::InPinchGestureMode() const { |
| 480 return shift_pressed_; | 485 return shift_pressed_; |
| 481 } | 486 } |
| 482 | 487 |
| 483 } // namespace content | 488 } // namespace content |
| OLD | NEW |