Chromium Code Reviews| Index: third_party/WebKit/Source/platform/WebPointerEvent.cpp |
| diff --git a/third_party/WebKit/Source/platform/WebPointerEvent.cpp b/third_party/WebKit/Source/platform/WebPointerEvent.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2363cab86c50eda2e13d82871664636a907b214d |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/WebPointerEvent.cpp |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "public/platform/WebPointerEvent.h" |
| + |
| +#include "public/platform/WebFloatPoint.h" |
| + |
| +namespace blink { |
| + |
| +namespace { |
| + |
| +WebInputEvent::Type PointerEventActionForTouchPointState( |
|
mustaq
2017/06/08 20:02:52
Again, why "Action" instead of "Type"?
Navid Zolghadr
2017/06/08 21:18:41
I wanted to avoid the confusion with PointerType (
|
| + WebTouchPoint::State state) { |
| + switch (state) { |
| + case WebTouchPoint::kStateReleased: |
| + return WebInputEvent::Type::kPointerUp; |
| + case WebTouchPoint::kStateCancelled: |
| + return WebInputEvent::Type::kPointerCancel; |
| + case WebTouchPoint::kStatePressed: |
| + return WebInputEvent::Type::kPointerDown; |
| + case WebTouchPoint::kStateMoved: |
| + return WebInputEvent::Type::kPointerMove; |
| + case WebTouchPoint::kStateStationary: |
| + default: |
| + NOTREACHED(); |
| + return WebInputEvent::Type::kUndefined; |
| + } |
| +} |
| +} |
| + |
| +WebPointerEvent::WebPointerEvent(const WebTouchEvent& touch_event, |
| + const WebTouchPoint& touch_point) |
| + : WebInputEvent(sizeof(WebPointerEvent)), |
| + WebPointerProperties(touch_point), |
| + width(touch_point.radius_x), |
|
mustaq
2017/06/08 20:02:52
Width/height should be radius*2.
Navid Zolghadr
2017/06/08 21:18:41
I commented about this in another reply. Let me kn
|
| + height(touch_point.radius_y) { |
| + // WebInutEvent attributes |
| + SetFrameScale(touch_event.FrameScale()); |
| + SetFrameTranslate(touch_event.FrameTranslate()); |
| + SetTimeStampSeconds(touch_event.TimeStampSeconds()); |
| + SetType(PointerEventActionForTouchPointState(touch_point.state)); |
| + SetModifiers(touch_event.GetModifiers()); |
| + // WebTouchEvent attributes |
| + dispatch_type = touch_event.dispatch_type; |
| + moved_beyond_slop_region = touch_event.moved_beyond_slop_region; |
| + touch_start_or_first_touch_move = touch_event.touch_start_or_first_touch_move; |
| + // WebTouchPoint attributes |
| + rotation_angle = touch_point.rotation_angle; |
| +} |
| + |
| +WebPointerEvent WebPointerEvent::WebPointerEventInRootFrame() const { |
| + WebPointerEvent transformed_event = *this; |
| + transformed_event.width /= frame_scale_; |
| + transformed_event.height /= frame_scale_; |
| + transformed_event.movement_x /= frame_scale_; |
| + transformed_event.movement_y /= frame_scale_; |
| + transformed_event.position_in_widget_ = |
| + WebFloatPoint((transformed_event.PositionInWidget().x / frame_scale_) + |
| + frame_translate_.x, |
| + (transformed_event.PositionInWidget().y / frame_scale_) + |
| + frame_translate_.y); |
| + return transformed_event; |
| +} |
| + |
| +} // namespace blink |