| Index: third_party/WebKit/Source/core/input/TouchEventManager.cpp
|
| diff --git a/third_party/WebKit/Source/core/input/TouchEventManager.cpp b/third_party/WebKit/Source/core/input/TouchEventManager.cpp
|
| index e101550859301d2968755b430569dfd744e398aa..209fc7cfdb5dbbadfd4f0daf996ff1176e509258 100644
|
| --- a/third_party/WebKit/Source/core/input/TouchEventManager.cpp
|
| +++ b/third_party/WebKit/Source/core/input/TouchEventManager.cpp
|
| @@ -61,13 +61,12 @@ enum TouchEventDispatchResultType {
|
| kTouchEventDispatchResultTypeMax,
|
| };
|
|
|
| -bool IsTouchSequenceStart(const WebTouchEvent& event) {
|
| - if (!event.touches_length)
|
| +bool IsTouchSequenceStart(const Vector<WebCoalescedPointerEvent>& event) {
|
| + if (!event.size())
|
| return false;
|
| - if (event.GetType() != WebInputEvent::kTouchStart)
|
| - return false;
|
| - for (size_t i = 0; i < event.touches_length; ++i) {
|
| - if (event.touches[i].state != blink::WebTouchPoint::kStatePressed)
|
| + for (size_t i = 0; i < event.size(); ++i) {
|
| + if (event[i].first.action !=
|
| + WebPointerProperties::PointerAction::kPointerDown)
|
| return false;
|
| }
|
| return true;
|
| @@ -117,7 +116,7 @@ DEFINE_TRACE(TouchEventManager) {
|
| }
|
|
|
| WebInputEventResult TouchEventManager::DispatchTouchEvents(
|
| - const WebTouchEvent& event,
|
| + const Vector<WebCoalescedPointerEvent>& event,
|
| const HeapVector<TouchInfo>& touch_infos,
|
| bool all_touches_released) {
|
| // Build up the lists to use for the |touches|, |targetTouches| and
|
| @@ -125,15 +124,18 @@ WebInputEventResult TouchEventManager::DispatchTouchEvents(
|
| // http://www.w3.org/TR/touch-events/#touchevent-interface for how these
|
| // lists fit together.
|
|
|
| - if (event.GetType() == WebInputEvent::kTouchEnd ||
|
| - event.GetType() == WebInputEvent::kTouchCancel ||
|
| - event.touches_length > 1) {
|
| + if (event.size() > 1 ||
|
| + event[0].first.action ==
|
| + WebPointerProperties::PointerAction::kPointerUp ||
|
| + event[0].first.action ==
|
| + WebPointerProperties::PointerAction::kPointerCancel) {
|
| suppressing_touchmoves_within_slop_ = false;
|
| }
|
|
|
| if (suppressing_touchmoves_within_slop_ &&
|
| - event.GetType() == WebInputEvent::kTouchMove) {
|
| - if (!event.moved_beyond_slop_region)
|
| + event[0].first.action ==
|
| + WebPointerProperties::PointerAction::kPointerMove) {
|
| + if (!event[0].first.moved_beyond_slop_region)
|
| return WebInputEventResult::kHandledSuppressed;
|
| suppressing_touchmoves_within_slop_ = false;
|
| }
|
| @@ -202,6 +204,40 @@ WebInputEventResult TouchEventManager::DispatchTouchEvents(
|
|
|
| WebInputEventResult event_result = WebInputEventResult::kNotHandled;
|
|
|
| + // Only for setting it inside TouchEvent for compatibility.
|
| + WebTouchEvent web_touch_event;
|
| + for (size_t i = 0; i < event.size(); i++) {
|
| + const auto& touch_pointer_event = event[0].first;
|
| + WebTouchPoint touch_point;
|
| + // WebPointerProperties attributes
|
| + touch_point.id = touch_pointer_event.id;
|
| + touch_point.force = touch_pointer_event.force;
|
| + touch_point.tilt_x = touch_pointer_event.tilt_x;
|
| + touch_point.tilt_y = touch_pointer_event.tilt_y;
|
| + touch_point.tangential_pressure = touch_pointer_event.tangential_pressure;
|
| + touch_point.twist = touch_pointer_event.twist;
|
| + touch_point.button = touch_pointer_event.button;
|
| + touch_point.pointer_type = touch_pointer_event.pointer_type;
|
| + touch_point.movement_x = touch_pointer_event.movement_x;
|
| + touch_point.movement_y = touch_pointer_event.movement_y;
|
| + // WebTouchPoint attributes
|
| + touch_point.rotation_angle = touch_pointer_event.rotation_angle;
|
| +
|
| + web_touch_event.touches[web_touch_event.touches_length++] = touch_point;
|
| + }
|
| + // WebInutEvent attributes
|
| + web_touch_event.SetFrameScale(event[0].first.FrameScale());
|
| + web_touch_event.SetFrameTranslate(event[0].first.FrameTranslate());
|
| + web_touch_event.SetTimeStampSeconds(event[0].first.TimeStampSeconds());
|
| + web_touch_event.SetType(event[0].first.GetType());
|
| + web_touch_event.SetModifiers(event[0].first.GetModifiers());
|
| + // WebTouchEvent attributes
|
| + web_touch_event.dispatch_type = event[0].first.dispatch_type;
|
| + web_touch_event.moved_beyond_slop_region =
|
| + event[0].first.moved_beyond_slop_region;
|
| + web_touch_event.touch_start_or_first_touch_move =
|
| + event[0].first.touch_start_or_first_touch_move;
|
| +
|
| // Now iterate through the |changedTouches| list and |m_targets| within it,
|
| // sending TouchEvents to the targets as required.
|
| for (unsigned state = 0; state <= WebTouchPoint::kStateMax; ++state) {
|
| @@ -210,10 +246,11 @@ WebInputEventResult TouchEventManager::DispatchTouchEvents(
|
|
|
| const AtomicString& event_name(TouchEventNameForTouchPointState(
|
| static_cast<WebTouchPoint::State>(state)));
|
| +
|
| for (const auto& event_target : changed_touches[state].targets_) {
|
| EventTarget* touch_event_target = event_target;
|
| TouchEvent* touch_event = TouchEvent::Create(
|
| - event, touches, touches_by_target.at(touch_event_target),
|
| + web_touch_event, touches, touches_by_target.at(touch_event_target),
|
| changed_touches[state].touches_.Get(), event_name,
|
| touch_event_target->ToNode()->GetDocument().domWindow(),
|
| current_touch_action_);
|
| @@ -223,15 +260,16 @@ WebInputEventResult TouchEventManager::DispatchTouchEvents(
|
|
|
| // Only report for top level documents with a single touch on
|
| // touch-start or the first touch-move.
|
| - if (event.touch_start_or_first_touch_move && touch_infos.size() == 1 &&
|
| + if (touch_infos.size() == 1 &&
|
| + event[0].first.touch_start_or_first_touch_move &&
|
| frame_->IsMainFrame()) {
|
| // Record the disposition and latency of touch starts and first touch
|
| // moves before and after the page is fully loaded respectively.
|
| int64_t latency_in_micros =
|
| (TimeTicks::Now() -
|
| - TimeTicks::FromSeconds(event.TimeStampSeconds()))
|
| + TimeTicks::FromSeconds(event[0].first.TimeStampSeconds()))
|
| .InMicroseconds();
|
| - if (event.IsCancelable()) {
|
| + if (event[0].first.IsCancelable()) {
|
| if (frame_->GetDocument()->IsLoadCompleted()) {
|
| DEFINE_STATIC_LOCAL(EnumerationHistogram,
|
| touch_dispositions_after_page_load_histogram,
|
| @@ -273,7 +311,7 @@ WebInputEventResult TouchEventManager::DispatchTouchEvents(
|
| }
|
|
|
| // Report the touch disposition when there is an active fling animation.
|
| - if (event.dispatch_type ==
|
| + if (event[0].first.dispatch_type ==
|
| WebInputEvent::kListenersForcedNonBlockingDueToFling) {
|
| DEFINE_STATIC_LOCAL(EnumerationHistogram,
|
| touch_dispositions_during_fling_histogram,
|
| @@ -450,17 +488,17 @@ void TouchEventManager::SetAllPropertiesOfTouchInfos(
|
| }
|
|
|
| bool TouchEventManager::ReHitTestTouchPointsIfNeeded(
|
| - const WebTouchEvent& event,
|
| + const Vector<WebCoalescedPointerEvent>& event,
|
| HeapVector<TouchInfo>& touch_infos) {
|
| bool new_touch_sequence = true;
|
| bool all_touches_released = true;
|
|
|
| - for (unsigned i = 0; i < event.touches_length; ++i) {
|
| - WebTouchPoint::State state = event.touches[i].state;
|
| - if (state != WebTouchPoint::kStatePressed)
|
| + for (size_t i = 0; i < event.size(); ++i) {
|
| + WebPointerProperties::PointerAction action = event[i].first.action;
|
| + if (action != WebPointerProperties::PointerAction::kPointerDown)
|
| new_touch_sequence = false;
|
| - if (state != WebTouchPoint::kStateReleased &&
|
| - state != WebTouchPoint::kStateCancelled)
|
| + if (action != WebPointerProperties::PointerAction::kPointerUp &&
|
| + action != WebPointerProperties::PointerAction::kPointerCancel)
|
| all_touches_released = false;
|
| }
|
| if (new_touch_sequence) {
|
| @@ -504,16 +542,16 @@ bool TouchEventManager::ReHitTestTouchPointsIfNeeded(
|
| }
|
|
|
| WebInputEventResult TouchEventManager::HandleTouchEvent(
|
| - const WebTouchEvent& event,
|
| + const Vector<WebCoalescedPointerEvent>& event,
|
| HeapVector<TouchInfo>& touch_infos) {
|
| if (!ReHitTestTouchPointsIfNeeded(event, touch_infos))
|
| return WebInputEventResult::kNotHandled;
|
|
|
| bool all_touches_released = true;
|
| - for (unsigned i = 0; i < event.touches_length; ++i) {
|
| - WebTouchPoint::State state = event.touches[i].state;
|
| - if (state != WebTouchPoint::kStateReleased &&
|
| - state != WebTouchPoint::kStateCancelled)
|
| + for (size_t i = 0; i < event.size(); ++i) {
|
| + WebPointerProperties::PointerAction action = event[i].first.action;
|
| + if (action != WebPointerProperties::PointerAction::kPointerUp &&
|
| + action != WebPointerProperties::PointerAction::kPointerCancel)
|
| all_touches_released = false;
|
| }
|
|
|
|
|