Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/input/PointerEventManager.h" | 5 #include "core/input/PointerEventManager.h" |
| 6 | 6 |
| 7 #include "core/dom/ElementTraversal.h" | 7 #include "core/dom/ElementTraversal.h" |
| 8 #include "core/dom/UserGestureIndicator.h" | 8 #include "core/dom/UserGestureIndicator.h" |
| 9 #include "core/dom/shadow/FlatTreeTraversal.h" | 9 #include "core/dom/shadow/FlatTreeTraversal.h" |
| 10 #include "core/events/MouseEvent.h" | 10 #include "core/events/MouseEvent.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "public/platform/WebTouchEvent.h" | 22 #include "public/platform/WebTouchEvent.h" |
| 23 | 23 |
| 24 namespace blink { | 24 namespace blink { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 size_t ToPointerTypeIndex(WebPointerProperties::PointerType t) { | 28 size_t ToPointerTypeIndex(WebPointerProperties::PointerType t) { |
| 29 return static_cast<size_t>(t); | 29 return static_cast<size_t>(t); |
| 30 } | 30 } |
| 31 | 31 |
| 32 Vector<WebPointerEvent> GetCoalescedWebPointerEventsWithNoTransformation( | |
| 33 const Vector<WebTouchEvent>& coalesced_events, | |
| 34 int id) { | |
| 35 Vector<WebPointerEvent> related_pointer_events; | |
| 36 for (const auto& touch_event : coalesced_events) { | |
| 37 for (unsigned i = 0; i < touch_event.touches_length; ++i) { | |
| 38 if (touch_event.touches[i].id == id && | |
| 39 touch_event.touches[i].state != WebTouchPoint::kStateStationary) { | |
| 40 related_pointer_events.push_back( | |
| 41 WebPointerEvent(touch_event, touch_event.touches[i])); | |
| 42 } | |
| 43 } | |
| 44 } | |
| 45 return related_pointer_events; | |
| 46 } | |
| 47 | |
| 32 Vector<std::pair<WebTouchPoint, TimeTicks>> GetCoalescedPoints( | 48 Vector<std::pair<WebTouchPoint, TimeTicks>> GetCoalescedPoints( |
| 33 const Vector<WebTouchEvent>& coalesced_events, | 49 const Vector<WebTouchEvent>& coalesced_events, |
| 34 int id) { | 50 int id) { |
| 35 Vector<std::pair<WebTouchPoint, TimeTicks>> related_points; | 51 Vector<std::pair<WebTouchPoint, TimeTicks>> related_points; |
| 36 for (const auto& touch_event : coalesced_events) { | 52 for (const auto& touch_event : coalesced_events) { |
| 37 for (unsigned i = 0; i < touch_event.touches_length; ++i) { | 53 for (unsigned i = 0; i < touch_event.touches_length; ++i) { |
| 38 if (touch_event.touches[i].id == id && | 54 if (touch_event.touches[i].id == id && |
| 39 touch_event.touches[i].state != WebTouchPoint::kStateStationary) { | 55 touch_event.touches[i].state != WebTouchPoint::kStateStationary) { |
| 40 related_points.push_back(std::pair<WebTouchPoint, TimeTicks>( | 56 related_points.push_back(std::pair<WebTouchPoint, TimeTicks>( |
| 41 touch_event.TouchPointInRootFrame(i), | 57 touch_event.TouchPointInRootFrame(i), |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 // associated with so just pick the first finger. | 327 // associated with so just pick the first finger. |
| 312 RefPtr<UserGestureToken> possible_gesture_token; | 328 RefPtr<UserGestureToken> possible_gesture_token; |
| 313 if (event.GetType() == WebInputEvent::kTouchEnd && | 329 if (event.GetType() == WebInputEvent::kTouchEnd && |
| 314 !in_canceled_state_for_pointer_type_touch_ && event.touches_length && | 330 !in_canceled_state_for_pointer_type_touch_ && event.touches_length && |
| 315 first_pointer_event_target.target_frame) { | 331 first_pointer_event_target.target_frame) { |
| 316 possible_gesture_token = UserGestureToken::Create( | 332 possible_gesture_token = UserGestureToken::Create( |
| 317 first_pointer_event_target.target_frame->GetDocument()); | 333 first_pointer_event_target.target_frame->GetDocument()); |
| 318 } | 334 } |
| 319 UserGestureIndicator holder(possible_gesture_token); | 335 UserGestureIndicator holder(possible_gesture_token); |
| 320 | 336 |
| 321 HeapVector<EventHandlingUtil::PointerEventTarget> pointer_event_targets; | |
| 322 | 337 |
| 323 for (unsigned touch_point_idx = 0; touch_point_idx < event.touches_length; | 338 for (unsigned touch_point_idx = 0; touch_point_idx < event.touches_length; |
| 324 ++touch_point_idx) { | 339 ++touch_point_idx) { |
| 325 // Do any necessary hit-tests and compute the event targets for all pointers | 340 // Do any necessary hit-tests and compute the event targets for all pointers |
| 326 // in the event. | 341 // in the event. |
| 327 const auto& touch_point = event.TouchPointInRootFrame(touch_point_idx); | 342 const auto& touch_point = event.TouchPointInRootFrame(touch_point_idx); |
| 328 EventHandlingUtil::PointerEventTarget pointer_event_target = | 343 EventHandlingUtil::PointerEventTarget pointer_event_target = |
| 329 touch_point_idx ? ComputePointerEventTarget(touch_point) | 344 touch_point_idx ? ComputePointerEventTarget(touch_point) |
| 330 : first_pointer_event_target; | 345 : first_pointer_event_target; |
| 331 pointer_event_targets.push_back(pointer_event_target); | |
| 332 | 346 |
| 333 DispatchTouchPointerEvent( | 347 if (touch_point.state != blink::WebTouchPoint::kStateStationary) { |
| 334 touch_point, pointer_event_target, | 348 DispatchTouchPointerEvent( |
| 335 GetCoalescedPoints(coalesced_events, touch_point.id), | 349 touch_point, pointer_event_target, |
| 336 static_cast<WebInputEvent::Modifiers>(event.GetModifiers()), | 350 GetCoalescedPoints(coalesced_events, touch_point.id), |
| 337 event.TimeStampSeconds(), event.unique_touch_event_id); | 351 static_cast<WebInputEvent::Modifiers>(event.GetModifiers()), |
| 352 event.TimeStampSeconds(), event.unique_touch_event_id); | |
| 353 | |
| 354 touch_event_manager_->HandleTouchPoint( | |
| 355 WebPointerEvent(event, event.touches[touch_point_idx]), | |
| 356 GetCoalescedWebPointerEventsWithNoTransformation( | |
| 357 coalesced_events, event.touches[touch_point_idx].id), | |
| 358 pointer_event_target); | |
| 359 } | |
| 338 } | 360 } |
| 339 | 361 |
| 340 return touch_event_manager_->HandleTouchEvent(event, coalesced_events, | 362 return touch_event_manager_->HandleVSyncSignal(); |
| 341 pointer_event_targets); | |
| 342 } | 363 } |
| 343 | 364 |
| 344 EventHandlingUtil::PointerEventTarget | 365 EventHandlingUtil::PointerEventTarget |
| 345 PointerEventManager::ComputePointerEventTarget( | 366 PointerEventManager::ComputePointerEventTarget( |
| 346 const WebTouchPoint& touch_point) { | 367 const WebTouchPoint& touch_point) { |
| 347 EventHandlingUtil::PointerEventTarget pointer_event_target; | 368 EventHandlingUtil::PointerEventTarget pointer_event_target; |
| 348 | 369 |
| 349 int pointer_id = pointer_event_factory_.GetPointerEventId(touch_point); | 370 int pointer_id = pointer_event_factory_.GetPointerEventId(touch_point); |
| 350 // Do the hit test either when the touch first starts or when the touch | 371 // Do the hit test either when the touch first starts or when the touch |
| 351 // is not captured. |m_pendingPointerCaptureTarget| indicates the target | 372 // is not captured. |m_pendingPointerCaptureTarget| indicates the target |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 void PointerEventManager::DispatchTouchPointerEvent( | 417 void PointerEventManager::DispatchTouchPointerEvent( |
| 397 const WebTouchPoint& touch_point, | 418 const WebTouchPoint& touch_point, |
| 398 const EventHandlingUtil::PointerEventTarget& pointer_event_target, | 419 const EventHandlingUtil::PointerEventTarget& pointer_event_target, |
| 399 const Vector<std::pair<WebTouchPoint, TimeTicks>>& coalesced_events, | 420 const Vector<std::pair<WebTouchPoint, TimeTicks>>& coalesced_events, |
| 400 WebInputEvent::Modifiers modifiers, | 421 WebInputEvent::Modifiers modifiers, |
| 401 double timestamp, | 422 double timestamp, |
| 402 uint32_t unique_touch_event_id) { | 423 uint32_t unique_touch_event_id) { |
| 403 // Iterate through the touch points, sending PointerEvents to the targets as | 424 // Iterate through the touch points, sending PointerEvents to the targets as |
| 404 // required. | 425 // required. |
| 405 // Do not send pointer events for stationary touches or null targetFrame | 426 // Do not send pointer events for stationary touches or null targetFrame |
| 406 if (pointer_event_target.target_node && pointer_event_target.target_frame && | 427 if (pointer_event_target.target_node && pointer_event_target.target_frame && |
|
mustaq
2017/06/08 20:02:52
Why are you not skipping the stationary points her
Navid Zolghadr
2017/06/08 21:18:40
I have moved the check outside of the function and
mustaq
2017/06/09 16:12:26
Sg, thanks.
Please check the comments about stati
| |
| 407 touch_point.state != WebTouchPoint::kStateStationary && | |
| 408 !in_canceled_state_for_pointer_type_touch_) { | 428 !in_canceled_state_for_pointer_type_touch_) { |
| 409 PointerEvent* pointer_event = pointer_event_factory_.Create( | 429 PointerEvent* pointer_event = pointer_event_factory_.Create( |
| 410 touch_point, coalesced_events, | 430 touch_point, coalesced_events, |
| 411 static_cast<WebInputEvent::Modifiers>(modifiers), | 431 static_cast<WebInputEvent::Modifiers>(modifiers), |
| 412 TimeTicks::FromSeconds(timestamp), pointer_event_target.target_frame, | 432 TimeTicks::FromSeconds(timestamp), pointer_event_target.target_frame, |
| 413 pointer_event_target.target_node | 433 pointer_event_target.target_node |
| 414 ? pointer_event_target.target_node->GetDocument().domWindow() | 434 ? pointer_event_target.target_node->GetDocument().domWindow() |
| 415 : nullptr); | 435 : nullptr); |
| 416 | 436 |
| 417 WebInputEventResult result = | 437 WebInputEventResult result = |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 if (first_id > unique_touch_event_id) | 765 if (first_id > unique_touch_event_id) |
| 746 return false; | 766 return false; |
| 747 touch_ids_for_canceled_pointerdowns_.TakeFirst(); | 767 touch_ids_for_canceled_pointerdowns_.TakeFirst(); |
| 748 if (first_id == unique_touch_event_id) | 768 if (first_id == unique_touch_event_id) |
| 749 return true; | 769 return true; |
| 750 } | 770 } |
| 751 return false; | 771 return false; |
| 752 } | 772 } |
| 753 | 773 |
| 754 } // namespace blink | 774 } // namespace blink |
| OLD | NEW |