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

Side by Side Diff: third_party/WebKit/Source/core/events/TouchEvent.h

Issue 2646163002: Remove PlatformTouchEvent/Point and use WebTouchEvent/Point instead (Closed)
Patch Set: Fix nit Created 3 years, 10 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
1 /* 1 /*
2 * Copyright 2008, The Android Open Source Project 2 * Copyright 2008, The Android Open Source Project
3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright 10 * * Redistributions in binary form must reproduce the above copyright
(...skipping 14 matching lines...) Expand all
25 */ 25 */
26 26
27 #ifndef TouchEvent_h 27 #ifndef TouchEvent_h
28 #define TouchEvent_h 28 #define TouchEvent_h
29 29
30 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
31 #include "core/dom/TouchList.h" 31 #include "core/dom/TouchList.h"
32 #include "core/events/EventDispatchMediator.h" 32 #include "core/events/EventDispatchMediator.h"
33 #include "core/events/TouchEventInit.h" 33 #include "core/events/TouchEventInit.h"
34 #include "core/events/UIEventWithKeyState.h" 34 #include "core/events/UIEventWithKeyState.h"
35 #include "public/platform/WebPointerProperties.h" 35 #include "public/platform/WebTouchEvent.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 class CORE_EXPORT TouchEvent final : public UIEventWithKeyState { 39 class CORE_EXPORT TouchEvent final : public UIEventWithKeyState {
40 DEFINE_WRAPPERTYPEINFO(); 40 DEFINE_WRAPPERTYPEINFO();
41 41
42 public: 42 public:
43 ~TouchEvent() override; 43 ~TouchEvent() override;
44 44
45 // We only initialize sourceCapabilities when we create TouchEvent from 45 // We only initialize sourceCapabilities when we create TouchEvent from
46 // EventHandler, null if it is from JavaScript. 46 // EventHandler, null if it is from JavaScript.
47 static TouchEvent* create() { return new TouchEvent; } 47 static TouchEvent* create() { return new TouchEvent; }
48 static TouchEvent* create(TouchList* touches, 48 static TouchEvent* create(const WebTouchEvent& event,
49 TouchList* touches,
49 TouchList* targetTouches, 50 TouchList* targetTouches,
50 TouchList* changedTouches, 51 TouchList* changedTouches,
51 const AtomicString& type, 52 const AtomicString& type,
52 AbstractView* view, 53 AbstractView* view,
53 PlatformEvent::Modifiers modifiers, 54 TouchAction currentTouchAction) {
54 bool cancelable, 55 return new TouchEvent(event, touches, targetTouches, changedTouches, type,
55 bool causesScrollingIfUncanceled, 56 view, currentTouchAction);
56 bool firstTouchMoveOrStart,
57 TimeTicks platformTimeStamp,
58 TouchAction currentTouchAction,
59 WebPointerProperties::PointerType pointerType) {
60 return new TouchEvent(touches, targetTouches, changedTouches, type, view,
61 modifiers, cancelable, causesScrollingIfUncanceled,
62 firstTouchMoveOrStart, platformTimeStamp,
63 currentTouchAction, pointerType);
64 } 57 }
65 58
66 static TouchEvent* create(const AtomicString& type, 59 static TouchEvent* create(const AtomicString& type,
67 const TouchEventInit& initializer) { 60 const TouchEventInit& initializer) {
68 return new TouchEvent(type, initializer); 61 return new TouchEvent(type, initializer);
69 } 62 }
70 63
71 TouchList* touches() const { return m_touches.get(); } 64 TouchList* touches() const { return m_touches.get(); }
72 TouchList* targetTouches() const { return m_targetTouches.get(); } 65 TouchList* targetTouches() const { return m_targetTouches.get(); }
73 TouchList* changedTouches() const { return m_changedTouches.get(); } 66 TouchList* changedTouches() const { return m_changedTouches.get(); }
74 67
75 void setTouches(TouchList* touches) { m_touches = touches; } 68 void setTouches(TouchList* touches) { m_touches = touches; }
76 void setTargetTouches(TouchList* targetTouches) { 69 void setTargetTouches(TouchList* targetTouches) {
77 m_targetTouches = targetTouches; 70 m_targetTouches = targetTouches;
78 } 71 }
79 void setChangedTouches(TouchList* changedTouches) { 72 void setChangedTouches(TouchList* changedTouches) {
80 m_changedTouches = changedTouches; 73 m_changedTouches = changedTouches;
81 } 74 }
82 75
83 bool causesScrollingIfUncanceled() const {
84 return m_causesScrollingIfUncanceled;
85 }
86
87 bool isTouchEvent() const override; 76 bool isTouchEvent() const override;
88 77
89 const AtomicString& interfaceName() const override; 78 const AtomicString& interfaceName() const override;
90 79
91 void preventDefault() override; 80 void preventDefault() override;
92 81
93 void doneDispatchingEventAtCurrentTarget() override; 82 void doneDispatchingEventAtCurrentTarget() override;
94 83
95 EventDispatchMediator* createMediator() override; 84 EventDispatchMediator* createMediator() override;
96 85
97 // Transient property to inform PPAPI of touch pointer types. Will be replaced 86 const WebTouchEvent* nativeEvent() const { return m_nativeEvent.get(); }
98 // when blink transitions to handling end-to-end pointer events.
99 WebPointerProperties::PointerType pointerType() const {
100 return m_pointerType;
101 }
102 87
103 DECLARE_VIRTUAL_TRACE(); 88 DECLARE_VIRTUAL_TRACE();
104 89
105 private: 90 private:
106 TouchEvent(); 91 TouchEvent();
107 TouchEvent(TouchList* touches, 92 TouchEvent(const WebTouchEvent&,
93 TouchList* touches,
108 TouchList* targetTouches, 94 TouchList* targetTouches,
109 TouchList* changedTouches, 95 TouchList* changedTouches,
110 const AtomicString& type, 96 const AtomicString& type,
111 AbstractView*, 97 AbstractView*,
112 PlatformEvent::Modifiers, 98 TouchAction currentTouchAction);
113 bool cancelable,
114 bool causesScrollingIfUncanceled,
115 bool firstTouchMoveOrStart,
116 TimeTicks platformTimeStamp,
117 TouchAction currentTouchAction,
118 WebPointerProperties::PointerType);
119 TouchEvent(const AtomicString&, const TouchEventInit&); 99 TouchEvent(const AtomicString&, const TouchEventInit&);
100 bool isTouchStartOrFirstTouchMove() const;
120 101
121 Member<TouchList> m_touches; 102 Member<TouchList> m_touches;
122 Member<TouchList> m_targetTouches; 103 Member<TouchList> m_targetTouches;
123 Member<TouchList> m_changedTouches; 104 Member<TouchList> m_changedTouches;
124 bool m_causesScrollingIfUncanceled; 105
125 bool m_firstTouchMoveOrStart;
126 bool m_defaultPreventedBeforeCurrentTarget; 106 bool m_defaultPreventedBeforeCurrentTarget;
127 107
128 // The current effective touch action computed before each 108 // The current effective touch action computed before each
129 // touchstart event is generated. It is used for UMA histograms. 109 // touchstart event is generated. It is used for UMA histograms.
130 TouchAction m_currentTouchAction; 110 TouchAction m_currentTouchAction;
131 111
132 WebPointerProperties::PointerType m_pointerType; 112 std::unique_ptr<WebTouchEvent> m_nativeEvent;
133 }; 113 };
134 114
135 class TouchEventDispatchMediator final : public EventDispatchMediator { 115 class TouchEventDispatchMediator final : public EventDispatchMediator {
136 public: 116 public:
137 static TouchEventDispatchMediator* create(TouchEvent*); 117 static TouchEventDispatchMediator* create(TouchEvent*);
138 118
139 private: 119 private:
140 explicit TouchEventDispatchMediator(TouchEvent*); 120 explicit TouchEventDispatchMediator(TouchEvent*);
141 TouchEvent& event() const; 121 TouchEvent& event() const;
142 DispatchEventResult dispatchEvent(EventDispatcher&) const override; 122 DispatchEventResult dispatchEvent(EventDispatcher&) const override;
143 }; 123 };
144 124
145 DEFINE_EVENT_TYPE_CASTS(TouchEvent); 125 DEFINE_EVENT_TYPE_CASTS(TouchEvent);
146 126
147 } // namespace blink 127 } // namespace blink
148 128
149 #endif // TouchEvent_h 129 #endif // TouchEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698