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