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

Side by Side Diff: third_party/WebKit/Source/core/events/PointerEventFactory.cpp

Issue 1635863006: Pointerevent capture APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 // 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/events/PointerEventFactory.h" 5 #include "core/events/PointerEventFactory.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 namespace { 9 namespace {
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 AtomicString pointerEventName = pointerEventNameForMouseEventName(mouseEvent Name); 83 AtomicString pointerEventName = pointerEventNameForMouseEventName(mouseEvent Name);
84 unsigned buttons = MouseEvent::platformModifiersToButtons(mouseEvent.getModi fiers()); 84 unsigned buttons = MouseEvent::platformModifiersToButtons(mouseEvent.getModi fiers());
85 PointerEventInit pointerEventInit; 85 PointerEventInit pointerEventInit;
86 86
87 setIdTypeButtons(pointerEventInit, mouseEvent.pointerProperties(), buttons); 87 setIdTypeButtons(pointerEventInit, mouseEvent.pointerProperties(), buttons);
88 88
89 pointerEventInit.setScreenX(mouseEvent.globalPosition().x()); 89 pointerEventInit.setScreenX(mouseEvent.globalPosition().x());
90 pointerEventInit.setScreenY(mouseEvent.globalPosition().y()); 90 pointerEventInit.setScreenY(mouseEvent.globalPosition().y());
91 pointerEventInit.setClientX(mouseEvent.position().x()); 91 pointerEventInit.setClientX(mouseEvent.position().x());
92 pointerEventInit.setClientY(mouseEvent.position().y()); 92 pointerEventInit.setClientY(mouseEvent.position().y());
93
93 if (pointerEventName == EventTypeNames::pointerdown 94 if (pointerEventName == EventTypeNames::pointerdown
94 || pointerEventName == EventTypeNames::pointerup) { 95 || pointerEventName == EventTypeNames::pointerup) {
95 pointerEventInit.setButton(mouseEvent.button()); 96 pointerEventInit.setButton(mouseEvent.button());
96 } else { 97 } else {
97 // TODO(crbug.com/587955): We are setting NoButton for transition 98 // TODO(crbug.com/587955): We are setting NoButton for transition
98 // pointerevents should be resolved as part of this bug 99 // pointerevents should be resolved as part of this bug
99 pointerEventInit.setButton(NoButton); 100 pointerEventInit.setButton(NoButton);
100 } 101 }
101 pointerEventInit.setPressure(getPointerEventPressure( 102 pointerEventInit.setPressure(getPointerEventPressure(
102 mouseEvent.pointerProperties().force, pointerEventInit.buttons())); 103 mouseEvent.pointerProperties().force, pointerEventInit.buttons()));
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // We do not handle the overflow of m_currentId as it should be very rare 260 // We do not handle the overflow of m_currentId as it should be very rare
260 int mappedId = m_currentId++; 261 int mappedId = m_currentId++;
261 if (!m_idCount[type]) 262 if (!m_idCount[type])
262 m_primaryId[type] = mappedId; 263 m_primaryId[type] = mappedId;
263 m_idCount[type]++; 264 m_idCount[type]++;
264 m_pointerIncomingIdMapping.add(p, mappedId); 265 m_pointerIncomingIdMapping.add(p, mappedId);
265 m_pointerIdMapping.add(mappedId, PointerAttributes(p, isActiveButtons)); 266 m_pointerIdMapping.add(mappedId, PointerAttributes(p, isActiveButtons));
266 return mappedId; 267 return mappedId;
267 } 268 }
268 269
269 void PointerEventFactory::remove( 270 bool PointerEventFactory::remove(
270 const PassRefPtrWillBeRawPtr<PointerEvent> pointerEvent) 271 const PassRefPtrWillBeRawPtr<PointerEvent> pointerEvent)
271 { 272 {
272 int mappedId = pointerEvent->pointerId(); 273 int mappedId = pointerEvent->pointerId();
273 // Do not remove mouse pointer id as it should always be there 274 // Do not remove mouse pointer id as it should always be there
274 if (mappedId == s_mouseId || !m_pointerIdMapping.contains(mappedId)) 275 if (mappedId == s_mouseId || !m_pointerIdMapping.contains(mappedId))
275 return; 276 return false;
276 277
277 IncomingId p = m_pointerIdMapping.get(mappedId).incomingId; 278 IncomingId p = m_pointerIdMapping.get(mappedId).incomingId;
278 int type = p.pointerType(); 279 int type = p.pointerType();
279 m_pointerIdMapping.remove(mappedId); 280 m_pointerIdMapping.remove(mappedId);
280 m_pointerIncomingIdMapping.remove(p); 281 m_pointerIncomingIdMapping.remove(p);
281 if (m_primaryId[type] == mappedId) 282 if (m_primaryId[type] == mappedId)
282 m_primaryId[type] = PointerEventFactory::s_invalidId; 283 m_primaryId[type] = PointerEventFactory::s_invalidId;
283 m_idCount[type]--; 284 m_idCount[type]--;
285 return true;
284 } 286 }
285 287
286 bool PointerEventFactory::isPrimary(int mappedId) const 288 bool PointerEventFactory::isPrimary(int mappedId) const
287 { 289 {
288 if (!m_pointerIdMapping.contains(mappedId)) 290 if (!m_pointerIdMapping.contains(mappedId))
289 return false; 291 return false;
290 292
291 IncomingId p = m_pointerIdMapping.get(mappedId).incomingId; 293 IncomingId p = m_pointerIdMapping.get(mappedId).incomingId;
292 return m_primaryId[p.pointerType()] == mappedId; 294 return m_primaryId[p.pointerType()] == mappedId;
293 } 295 }
294 296
295 bool PointerEventFactory::isActive(const int pointerId) 297 bool PointerEventFactory::isActive(const int pointerId)
296 { 298 {
297 return m_pointerIdMapping.contains(pointerId); 299 return m_pointerIdMapping.contains(pointerId);
298 } 300 }
299 301
300 bool PointerEventFactory::isActiveButtonsState(const int pointerId) 302 bool PointerEventFactory::isActiveButtonsState(const int pointerId)
301 { 303 {
302 return m_pointerIdMapping.contains(pointerId) 304 return m_pointerIdMapping.contains(pointerId)
303 && m_pointerIdMapping.get(pointerId).isActiveButtons; 305 && m_pointerIdMapping.get(pointerId).isActiveButtons;
304 } 306 }
305 307
306 } // namespace blink 308 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/PointerEventFactory.h ('k') | third_party/WebKit/Source/core/input/EventHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698