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