OLD | NEW |
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/PointerEventManager.h" | 5 #include "core/input/PointerEventManager.h" |
6 | 6 |
7 #include "core/dom/shadow/FlatTreeTraversal.h" | 7 #include "core/dom/shadow/FlatTreeTraversal.h" |
8 #include "core/events/MouseEvent.h" | 8 #include "core/events/MouseEvent.h" |
9 #include "core/input/EventHandler.h" | 9 #include "core/input/EventHandler.h" |
10 | 10 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = m_pointerEventFactory.create
PointerCancelEvent(point); | 300 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = m_pointerEventFactory.create
PointerCancelEvent(point); |
301 | 301 |
302 | 302 |
303 processCaptureAndPositionOfPointerEvent(pointerEvent, target); | 303 processCaptureAndPositionOfPointerEvent(pointerEvent, target); |
304 | 304 |
305 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturing v
s pointer event capturing | 305 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturing v
s pointer event capturing |
306 dispatchPointerEvent( | 306 dispatchPointerEvent( |
307 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()), | 307 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()), |
308 pointerEvent.get()); | 308 pointerEvent.get()); |
309 | 309 |
310 setNodeUnderPointer(pointerEvent, nullptr); | 310 releasePointerCapture(pointerEvent->pointerId()); |
| 311 |
| 312 // Sending the leave/out events and lostpointercapture |
| 313 // because the next touch event will have a different id. So delayed |
| 314 // sending of lostpointercapture won't work here. |
| 315 processCaptureAndPositionOfPointerEvent(pointerEvent, nullptr); |
311 | 316 |
312 removePointer(pointerEvent); | 317 removePointer(pointerEvent); |
313 } | 318 } |
314 | 319 |
315 WebInputEventResult PointerEventManager::sendTouchPointerEvent( | 320 WebInputEventResult PointerEventManager::sendTouchPointerEvent( |
316 PassRefPtrWillBeRawPtr<EventTarget> prpTarget, | 321 PassRefPtrWillBeRawPtr<EventTarget> prpTarget, |
317 const PlatformTouchPoint& touchPoint, PlatformEvent::Modifiers modifiers, | 322 const PlatformTouchPoint& touchPoint, PlatformEvent::Modifiers modifiers, |
318 const double width, const double height, | 323 const double width, const double height, |
319 const double clientX, const double clientY) | 324 const double clientX, const double clientY) |
320 { | 325 { |
321 RefPtrWillBeRawPtr<EventTarget> target = prpTarget; | 326 RefPtrWillBeRawPtr<EventTarget> target = prpTarget; |
322 | 327 |
323 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = | 328 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = |
324 m_pointerEventFactory.create( | 329 m_pointerEventFactory.create( |
325 pointerEventNameForTouchPointState(touchPoint.state()), | 330 pointerEventNameForTouchPointState(touchPoint.state()), |
326 touchPoint, modifiers, width, height, clientX, clientY); | 331 touchPoint, modifiers, width, height, clientX, clientY); |
327 | 332 |
328 processCaptureAndPositionOfPointerEvent(pointerEvent, target); | 333 processCaptureAndPositionOfPointerEvent(pointerEvent, target); |
329 | 334 |
330 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturing v
s pointer event capturing | 335 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturing v
s pointer event capturing |
331 WebInputEventResult result = dispatchPointerEvent( | 336 WebInputEventResult result = dispatchPointerEvent( |
332 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()), | 337 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()), |
333 pointerEvent.get()); | 338 pointerEvent.get()); |
334 | 339 |
| 340 // Setting the implicit capture for touch |
| 341 if (touchPoint.state() == PlatformTouchPoint::TouchPressed) |
| 342 setPointerCapture(pointerEvent->pointerId(), target); |
| 343 |
335 if (touchPoint.state() == PlatformTouchPoint::TouchReleased | 344 if (touchPoint.state() == PlatformTouchPoint::TouchReleased |
336 || touchPoint.state() == PlatformTouchPoint::TouchCancelled) { | 345 || touchPoint.state() == PlatformTouchPoint::TouchCancelled) { |
337 setNodeUnderPointer(pointerEvent, nullptr); | 346 releasePointerCapture(pointerEvent->pointerId()); |
| 347 |
| 348 // Sending the leave/out events and lostpointercapture |
| 349 // because the next touch event will have a different id. So delayed |
| 350 // sending of lostpointercapture won't work here. |
| 351 processCaptureAndPositionOfPointerEvent(pointerEvent, nullptr); |
| 352 |
338 removePointer(pointerEvent); | 353 removePointer(pointerEvent); |
339 } | 354 } |
340 | 355 |
341 return result; | 356 return result; |
342 } | 357 } |
343 | 358 |
344 WebInputEventResult PointerEventManager::sendMousePointerEvent( | 359 WebInputEventResult PointerEventManager::sendMousePointerEvent( |
345 PassRefPtrWillBeRawPtr<Node> prpTarget, const AtomicString& mouseEventType, | 360 PassRefPtrWillBeRawPtr<Node> prpTarget, const AtomicString& mouseEventType, |
346 int clickCount, const PlatformMouseEvent& mouseEvent, | 361 int clickCount, const PlatformMouseEvent& mouseEvent, |
347 PassRefPtrWillBeRawPtr<Node> relatedTarget, | 362 PassRefPtrWillBeRawPtr<Node> relatedTarget, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 409 |
395 PointerEventManager::~PointerEventManager() | 410 PointerEventManager::~PointerEventManager() |
396 { | 411 { |
397 } | 412 } |
398 | 413 |
399 void PointerEventManager::clear() | 414 void PointerEventManager::clear() |
400 { | 415 { |
401 m_preventMouseEventForPointerTypeMouse = false; | 416 m_preventMouseEventForPointerTypeMouse = false; |
402 m_pointerEventFactory.clear(); | 417 m_pointerEventFactory.clear(); |
403 m_nodeUnderPointer.clear(); | 418 m_nodeUnderPointer.clear(); |
| 419 m_pointerCaptureTarget.clear(); |
| 420 m_pendingPointerCaptureTarget.clear(); |
404 } | 421 } |
405 | 422 |
406 void PointerEventManager::processCaptureAndPositionOfPointerEvent( | 423 void PointerEventManager::processCaptureAndPositionOfPointerEvent( |
407 const PassRefPtrWillBeRawPtr<PointerEvent> prpPointerEvent, | 424 const PassRefPtrWillBeRawPtr<PointerEvent> prpPointerEvent, |
408 const PassRefPtrWillBeRawPtr<EventTarget> prpHitTestTarget, | 425 const PassRefPtrWillBeRawPtr<EventTarget> prpHitTestTarget, |
409 const PassRefPtrWillBeRawPtr<EventTarget> lastNodeUnderMouse, | 426 const PassRefPtrWillBeRawPtr<EventTarget> lastNodeUnderMouse, |
410 const PlatformMouseEvent& mouseEvent, | 427 const PlatformMouseEvent& mouseEvent, |
411 bool sendMouseEvent, bool setPointerPosition) | 428 bool sendMouseEvent, bool setPointerPosition) |
412 { | 429 { |
413 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = prpPointerEvent; | 430 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = prpPointerEvent; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 void PointerEventManager::releasePointerCapture(int pointerId) | 576 void PointerEventManager::releasePointerCapture(int pointerId) |
560 { | 577 { |
561 m_pendingPointerCaptureTarget.remove(pointerId); | 578 m_pendingPointerCaptureTarget.remove(pointerId); |
562 } | 579 } |
563 | 580 |
564 bool PointerEventManager::isActive(const int pointerId) | 581 bool PointerEventManager::isActive(const int pointerId) |
565 { | 582 { |
566 return m_pointerEventFactory.isActive(pointerId); | 583 return m_pointerEventFactory.isActive(pointerId); |
567 } | 584 } |
568 | 585 |
| 586 WebPointerProperties::PointerType PointerEventManager::getPointerEventType( |
| 587 const int pointerId) |
| 588 { |
| 589 return m_pointerEventFactory.getPointerType(pointerId); |
| 590 } |
| 591 |
569 DEFINE_TRACE(PointerEventManager) | 592 DEFINE_TRACE(PointerEventManager) |
570 { | 593 { |
571 #if ENABLE(OILPAN) | 594 #if ENABLE(OILPAN) |
572 visitor->trace(m_nodeUnderPointer); | 595 visitor->trace(m_nodeUnderPointer); |
573 visitor->trace(m_pointerCaptureTarget); | 596 visitor->trace(m_pointerCaptureTarget); |
574 visitor->trace(m_pendingPointerCaptureTarget); | 597 visitor->trace(m_pendingPointerCaptureTarget); |
575 #endif | 598 #endif |
576 } | 599 } |
577 | 600 |
578 | 601 |
579 } // namespace blink | 602 } // namespace blink |
OLD | NEW |