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

Side by Side Diff: third_party/WebKit/Source/core/input/TouchEventManager.cpp

Issue 2507503002: Use touch events to report stylus events (Closed)
Patch Set: I should pay attention... Created 4 years 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/input/TouchEventManager.h" 5 #include "core/input/TouchEventManager.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/events/TouchEvent.h" 8 #include "core/events/TouchEvent.h"
9 #include "core/frame/Deprecation.h" 9 #include "core/frame/Deprecation.h"
10 #include "core/frame/EventHandlerRegistry.h" 10 #include "core/frame/EventHandlerRegistry.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 STACK_ALLOCATED(); 74 STACK_ALLOCATED();
75 75
76 public: 76 public:
77 // The touches corresponding to the particular change state this struct 77 // The touches corresponding to the particular change state this struct
78 // instance represents. 78 // instance represents.
79 Member<TouchList> m_touches; 79 Member<TouchList> m_touches;
80 80
81 using EventTargetSet = HeapHashSet<Member<EventTarget>>; 81 using EventTargetSet = HeapHashSet<Member<EventTarget>>;
82 // Set of targets involved in m_touches. 82 // Set of targets involved in m_touches.
83 EventTargetSet m_targets; 83 EventTargetSet m_targets;
84
85 WebPointerProperties::PointerType m_pointerType;
84 }; 86 };
85 87
86 } // namespace 88 } // namespace
87 89
88 TouchEventManager::TouchEventManager(LocalFrame* frame) : m_frame(frame) { 90 TouchEventManager::TouchEventManager(LocalFrame* frame) : m_frame(frame) {
89 clear(); 91 clear();
90 } 92 }
91 93
92 void TouchEventManager::clear() { 94 void TouchEventManager::clear() {
93 m_touchSequenceDocument.clear(); 95 m_touchSequenceDocument.clear();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // never be in the |changedTouches| list so we do not handle them 159 // never be in the |changedTouches| list so we do not handle them
158 // explicitly here. See https://bugs.webkit.org/show_bug.cgi?id=37609 160 // explicitly here. See https://bugs.webkit.org/show_bug.cgi?id=37609
159 // for further discussion about the TouchStationary state. 161 // for further discussion about the TouchStationary state.
160 if (pointState != PlatformTouchPoint::TouchStationary && 162 if (pointState != PlatformTouchPoint::TouchStationary &&
161 touchInfo.knownTarget) { 163 touchInfo.knownTarget) {
162 ASSERT(pointState < PlatformTouchPoint::TouchStateEnd); 164 ASSERT(pointState < PlatformTouchPoint::TouchStateEnd);
163 if (!changedTouches[pointState].m_touches) 165 if (!changedTouches[pointState].m_touches)
164 changedTouches[pointState].m_touches = TouchList::create(); 166 changedTouches[pointState].m_touches = TouchList::create();
165 changedTouches[pointState].m_touches->append(touch); 167 changedTouches[pointState].m_touches->append(touch);
166 changedTouches[pointState].m_targets.add(touchInfo.touchNode); 168 changedTouches[pointState].m_targets.add(touchInfo.touchNode);
169 changedTouches[pointState].m_pointerType =
170 point.pointerProperties().pointerType;
167 } 171 }
168 } 172 }
169 173
170 if (allTouchesReleased) { 174 if (allTouchesReleased) {
171 m_touchSequenceDocument.clear(); 175 m_touchSequenceDocument.clear();
172 m_currentTouchAction = TouchActionAuto; 176 m_currentTouchAction = TouchActionAuto;
173 } 177 }
174 178
175 WebInputEventResult eventResult = WebInputEventResult::NotHandled; 179 WebInputEventResult eventResult = WebInputEventResult::NotHandled;
176 180
177 // Now iterate through the |changedTouches| list and |m_targets| within it, 181 // Now iterate through the |changedTouches| list and |m_targets| within it,
178 // sending TouchEvents to the targets as required. 182 // sending TouchEvents to the targets as required.
179 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; 183 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd;
180 ++state) { 184 ++state) {
181 if (!changedTouches[state].m_touches) 185 if (!changedTouches[state].m_touches)
182 continue; 186 continue;
183 187
184 const AtomicString& eventName(touchEventNameForTouchPointState( 188 const AtomicString& eventName(touchEventNameForTouchPointState(
185 static_cast<PlatformTouchPoint::TouchState>(state))); 189 static_cast<PlatformTouchPoint::TouchState>(state)));
186 for (const auto& eventTarget : changedTouches[state].m_targets) { 190 for (const auto& eventTarget : changedTouches[state].m_targets) {
187 EventTarget* touchEventTarget = eventTarget; 191 EventTarget* touchEventTarget = eventTarget;
188 TouchEvent* touchEvent = 192 TouchEvent* touchEvent = TouchEvent::create(
189 TouchEvent::create(touches, touchesByTarget.get(touchEventTarget), 193 touches, touchesByTarget.get(touchEventTarget),
190 changedTouches[state].m_touches.get(), eventName, 194 changedTouches[state].m_touches.get(), eventName,
191 touchEventTarget->toNode()->document().domWindow(), 195 touchEventTarget->toNode()->document().domWindow(),
192 event.getModifiers(), event.cancelable(), 196 event.getModifiers(), event.cancelable(),
193 event.causesScrollingIfUncanceled(), 197 event.causesScrollingIfUncanceled(),
194 event.touchStartOrFirstTouchMove(), 198 event.touchStartOrFirstTouchMove(), event.timestamp(),
195 event.timestamp(), m_currentTouchAction); 199 m_currentTouchAction, changedTouches[state].m_pointerType);
196 200
197 DispatchEventResult domDispatchResult = 201 DispatchEventResult domDispatchResult =
198 touchEventTarget->dispatchEvent(touchEvent); 202 touchEventTarget->dispatchEvent(touchEvent);
199 203
200 // Only report for top level documents with a single touch on 204 // Only report for top level documents with a single touch on
201 // touch-start or the first touch-move. 205 // touch-start or the first touch-move.
202 if (event.touchStartOrFirstTouchMove() && touchInfos.size() == 1 && 206 if (event.touchStartOrFirstTouchMove() && touchInfos.size() == 1 &&
203 m_frame->isMainFrame()) { 207 m_frame->isMainFrame()) {
204 // Record the disposition and latency of touch starts and first touch 208 // Record the disposition and latency of touch starts and first touch
205 // moves before and after the page is fully loaded respectively. 209 // moves before and after the page is fully loaded respectively.
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 } 507 }
504 508
505 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); 509 return dispatchTouchEvents(event, touchInfos, allTouchesReleased);
506 } 510 }
507 511
508 bool TouchEventManager::isAnyTouchActive() const { 512 bool TouchEventManager::isAnyTouchActive() const {
509 return m_touchPressed; 513 return m_touchPressed;
510 } 514 }
511 515
512 } // namespace blink 516 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/TouchEvent.cpp ('k') | third_party/WebKit/Source/web/WebInputEventConversion.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698