Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: third_party/WebKit/Source/platform/WebPointerEvent.cpp

Issue 2860663006: Remove WebTouchEvent from TouchEventManager APIs (Closed)
Patch Set: Add TODO for clarification of the fields Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "public/platform/WebPointerEvent.h"
6
7 #include "public/platform/WebFloatPoint.h"
8
9 namespace blink {
10
11 namespace {
12
13 WebInputEvent::Type PointerEventTypeForTouchPointState(
14 WebTouchPoint::State state) {
15 switch (state) {
16 case WebTouchPoint::kStateReleased:
17 return WebInputEvent::Type::kPointerUp;
18 case WebTouchPoint::kStateCancelled:
19 return WebInputEvent::Type::kPointerCancel;
20 case WebTouchPoint::kStatePressed:
21 return WebInputEvent::Type::kPointerDown;
22 case WebTouchPoint::kStateMoved:
23 return WebInputEvent::Type::kPointerMove;
24 case WebTouchPoint::kStateStationary:
25 default:
26 NOTREACHED();
27 return WebInputEvent::Type::kUndefined;
28 }
29 }
30 } // namespace
31
32 WebPointerEvent::WebPointerEvent(const WebTouchEvent& touch_event,
33 const WebTouchPoint& touch_point)
34 : WebInputEvent(sizeof(WebPointerEvent)),
35 WebPointerProperties(touch_point),
36 // TODO(crbug.com/731725): This mapping needs a times by 2.
37 width(touch_point.radius_x),
38 height(touch_point.radius_y) {
39 // WebInutEvent attributes
40 SetFrameScale(touch_event.FrameScale());
41 SetFrameTranslate(touch_event.FrameTranslate());
42 SetTimeStampSeconds(touch_event.TimeStampSeconds());
43 SetType(PointerEventTypeForTouchPointState(touch_point.state));
44 SetModifiers(touch_event.GetModifiers());
45 // WebTouchEvent attributes
46 dispatch_type = touch_event.dispatch_type;
47 moved_beyond_slop_region = touch_event.moved_beyond_slop_region;
48 touch_start_or_first_touch_move = touch_event.touch_start_or_first_touch_move;
49 // WebTouchPoint attributes
50 rotation_angle = touch_point.rotation_angle;
51 }
52
53 WebPointerEvent WebPointerEvent::WebPointerEventInRootFrame() const {
54 WebPointerEvent transformed_event = *this;
55 transformed_event.width /= frame_scale_;
56 transformed_event.height /= frame_scale_;
57 transformed_event.movement_x /= frame_scale_;
58 transformed_event.movement_y /= frame_scale_;
59 transformed_event.position_in_widget_ =
60 WebFloatPoint((transformed_event.PositionInWidget().x / frame_scale_) +
61 frame_translate_.x,
62 (transformed_event.PositionInWidget().y / frame_scale_) +
63 frame_translate_.y);
64 return transformed_event;
65 }
66
67 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698