Index: third_party/WebKit/Source/core/input/PointerEventManager.cpp |
diff --git a/third_party/WebKit/Source/core/input/PointerEventManager.cpp b/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
index 3008398da7fec124070ee00ff75e309bcb4053fd..7fccf4532bf569168c7cd949a068d137e8c6334e 100644 |
--- a/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
+++ b/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
@@ -29,6 +29,78 @@ size_t ToPointerTypeIndex(WebPointerProperties::PointerType t) { |
return static_cast<size_t>(t); |
} |
+WebPointerProperties::PointerAction PointerEventActionForTouchPointState( |
+ WebTouchPoint::State state) { |
+ switch (state) { |
+ case WebTouchPoint::kStateReleased: |
+ return WebPointerProperties::PointerAction::kPointerUp; |
+ case WebTouchPoint::kStateCancelled: |
+ return WebPointerProperties::PointerAction::kPointerCancel; |
+ case WebTouchPoint::kStatePressed: |
+ return WebPointerProperties::PointerAction::kPointerDown; |
+ case WebTouchPoint::kStateMoved: |
+ return WebPointerProperties::PointerAction::kPointerMove; |
+ case WebTouchPoint::kStateStationary: |
+ return WebPointerProperties::PointerAction::kPointerUndefined; |
+ default: |
+ NOTREACHED(); |
+ return WebPointerProperties::PointerAction::kPointerUndefined; |
+ } |
+} |
+ |
+WebPointerEvent CreateWebPointerEventFromTouchPoint( |
use mustaq_at_chromium.org
2017/05/08 17:07:30
We will ultimately need conversion methods from/to
Navid Zolghadr
2017/06/08 16:38:26
I moved it to the WebPointerEvent constructor.
|
+ const WebTouchEvent& touch_event, |
+ size_t point_index) { |
+ const auto& touch_point = touch_event.touches[point_index]; |
+ WebPointerEvent touch_pointer_event( |
+ PointerEventActionForTouchPointState(touch_point.state), |
+ touch_point.screen_position, touch_point.position, touch_point.radius_x, |
+ touch_point.radius_y); |
+ // WebPointerProperties attributes |
+ touch_pointer_event.id = touch_point.id; |
+ touch_pointer_event.force = touch_point.force; |
+ touch_pointer_event.tilt_x = touch_point.tilt_x; |
+ touch_pointer_event.tilt_y = touch_point.tilt_y; |
+ touch_pointer_event.tangential_pressure = touch_point.tangential_pressure; |
+ touch_pointer_event.twist = touch_point.twist; |
+ touch_pointer_event.button = touch_point.button; |
+ touch_pointer_event.pointer_type = touch_point.pointer_type; |
+ touch_pointer_event.movement_x = touch_point.movement_x; |
+ touch_pointer_event.movement_y = touch_point.movement_y; |
+ // WebInutEvent attributes |
+ touch_pointer_event.SetFrameScale(touch_event.FrameScale()); |
+ touch_pointer_event.SetFrameTranslate(touch_event.FrameTranslate()); |
+ touch_pointer_event.SetTimeStampSeconds(touch_event.TimeStampSeconds()); |
+ touch_pointer_event.SetType(touch_event.GetType()); |
+ touch_pointer_event.SetModifiers(touch_event.GetModifiers()); |
+ // WebTouchEvent attributes |
+ touch_pointer_event.dispatch_type = touch_event.dispatch_type; |
+ touch_pointer_event.moved_beyond_slop_region = |
+ touch_event.moved_beyond_slop_region; |
+ touch_pointer_event.touch_start_or_first_touch_move = |
+ touch_event.touch_start_or_first_touch_move; |
+ // WebTouchPoint attributes |
+ touch_pointer_event.rotation_angle = touch_point.rotation_angle; |
+ |
+ return touch_pointer_event; |
+} |
+ |
+Vector<WebPointerEvent> GetCoalescedWebPointerEventsWithNoTransformation( |
+ const Vector<WebTouchEvent>& coalesced_events, |
+ int id) { |
+ Vector<WebPointerEvent> related_pointer_events; |
+ for (const auto& touch_event : coalesced_events) { |
+ for (unsigned i = 0; i < touch_event.touches_length; ++i) { |
+ if (touch_event.touches[i].id == id && |
+ touch_event.touches[i].state != WebTouchPoint::kStateStationary) { |
+ related_pointer_events.push_back( |
+ CreateWebPointerEventFromTouchPoint(touch_event, i)); |
+ } |
+ } |
+ } |
+ return related_pointer_events; |
+} |
+ |
Vector<std::pair<WebTouchPoint, TimeTicks>> GetCoalescedPoints( |
const Vector<WebTouchEvent>& coalesced_events, |
int id) { |
@@ -318,7 +390,16 @@ WebInputEventResult PointerEventManager::HandleTouchEvents( |
DispatchTouchPointerEvents(event, coalesced_events, touch_infos); |
- return touch_event_manager_->HandleTouchEvent(event, touch_infos); |
+ Vector<WebCoalescedPointerEvent> touch_pointer_events; |
+ for (size_t i = 0; i < event.touches_length; ++i) { |
+ Vector<WebPointerEvent> coalesced_pointer_events; |
+ touch_pointer_events.push_back(WebCoalescedPointerEvent( |
+ CreateWebPointerEventFromTouchPoint(event, i), |
+ GetCoalescedWebPointerEventsWithNoTransformation(coalesced_events, |
+ event.touches[i].id))); |
+ } |
+ return touch_event_manager_->HandleTouchEvent(touch_pointer_events, |
+ touch_infos); |
} |
void PointerEventManager::ComputeTouchTargets( |