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