| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 3430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3441 return result; | 3441 return result; |
| 3442 if (frame->view()) { | 3442 if (frame->view()) { |
| 3443 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars); | 3443 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars); |
| 3444 if (!rect.contains(roundedIntPoint(point))) | 3444 if (!rect.contains(roundedIntPoint(point))) |
| 3445 return result; | 3445 return result; |
| 3446 } | 3446 } |
| 3447 frame->contentLayoutObject()->hitTest(result); | 3447 frame->contentLayoutObject()->hitTest(result); |
| 3448 return result; | 3448 return result; |
| 3449 } | 3449 } |
| 3450 | 3450 |
| 3451 void EventHandler::dispatchPointerEventsForTouchEvent(const PlatformTouchEvent&
event, Vector<TouchInfo>& touchInfos) | 3451 void EventHandler::dispatchPointerEventsForTouchEvent(const PlatformTouchEvent&
event, WillBeHeapVector<TouchInfo>& touchInfos) |
| 3452 { | 3452 { |
| 3453 const String& PointerTypeStrForTouch("touch"); | 3453 const String& PointerTypeStrForTouch("touch"); |
| 3454 | 3454 |
| 3455 // Iterate through the touch points, sending PointerEvents to the targets as
required. | 3455 // Iterate through the touch points, sending PointerEvents to the targets as
required. |
| 3456 for (unsigned i = 0; i < touchInfos.size(); ++i) { | 3456 for (unsigned i = 0; i < touchInfos.size(); ++i) { |
| 3457 TouchInfo& touchInfo = touchInfos[i]; | 3457 TouchInfo& touchInfo = touchInfos[i]; |
| 3458 const PlatformTouchPoint& point = touchInfo.point; | 3458 const PlatformTouchPoint& point = touchInfo.point; |
| 3459 const unsigned& pointerId = point.id(); | 3459 const unsigned& pointerId = point.id(); |
| 3460 const PlatformTouchPoint::State pointState = point.state(); | 3460 const PlatformTouchPoint::State pointState = point.state(); |
| 3461 | 3461 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3496 touchInfo.touchTarget->toNode()->dispatchPointerEvent(pointerEvent.get()
); | 3496 touchInfo.touchTarget->toNode()->dispatchPointerEvent(pointerEvent.get()
); |
| 3497 touchInfo.consumed = pointerEvent->defaultPrevented() || pointerEvent->d
efaultHandled(); | 3497 touchInfo.consumed = pointerEvent->defaultPrevented() || pointerEvent->d
efaultHandled(); |
| 3498 | 3498 |
| 3499 // Remove the released/cancelled id at the end to correctly determine pr
imary id above. | 3499 // Remove the released/cancelled id at the end to correctly determine pr
imary id above. |
| 3500 if (pointerReleasedOrCancelled) | 3500 if (pointerReleasedOrCancelled) |
| 3501 m_pointerIdManager.remove(PointerIdManager::PointerTypeTouch, pointe
rId); | 3501 m_pointerIdManager.remove(PointerIdManager::PointerTypeTouch, pointe
rId); |
| 3502 } | 3502 } |
| 3503 } | 3503 } |
| 3504 | 3504 |
| 3505 bool EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event, | 3505 bool EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event, |
| 3506 Vector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouchReleased) | 3506 WillBeHeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouc
hReleased) |
| 3507 { | 3507 { |
| 3508 bool swallowedEvent = false; | 3508 bool swallowedEvent = false; |
| 3509 | 3509 |
| 3510 // Build up the lists to use for the 'touches', 'targetTouches' and | 3510 // Build up the lists to use for the 'touches', 'targetTouches' and |
| 3511 // 'changedTouches' attributes in the JS event. See | 3511 // 'changedTouches' attributes in the JS event. See |
| 3512 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these | 3512 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these |
| 3513 // lists fit together. | 3513 // lists fit together. |
| 3514 | 3514 |
| 3515 // Holds the complete set of touches on the screen. | 3515 // Holds the complete set of touches on the screen. |
| 3516 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create(); | 3516 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3532 | 3532 |
| 3533 for (unsigned i = 0; i < touchInfos.size(); ++i) { | 3533 for (unsigned i = 0; i < touchInfos.size(); ++i) { |
| 3534 const TouchInfo& touchInfo = touchInfos[i]; | 3534 const TouchInfo& touchInfo = touchInfos[i]; |
| 3535 const PlatformTouchPoint& point = touchInfo.point; | 3535 const PlatformTouchPoint& point = touchInfo.point; |
| 3536 PlatformTouchPoint::State pointState = point.state(); | 3536 PlatformTouchPoint::State pointState = point.state(); |
| 3537 | 3537 |
| 3538 if (touchInfo.consumed) | 3538 if (touchInfo.consumed) |
| 3539 continue; | 3539 continue; |
| 3540 | 3540 |
| 3541 RefPtrWillBeRawPtr<Touch> touch = Touch::create( | 3541 RefPtrWillBeRawPtr<Touch> touch = Touch::create( |
| 3542 touchInfo.targetFrame, | 3542 touchInfo.targetFrame.get(), |
| 3543 touchInfo.touchTarget, | 3543 touchInfo.touchTarget.get(), |
| 3544 point.id(), | 3544 point.id(), |
| 3545 point.screenPos(), | 3545 point.screenPos(), |
| 3546 touchInfo.adjustedPagePoint, | 3546 touchInfo.adjustedPagePoint, |
| 3547 touchInfo.adjustedRadius, | 3547 touchInfo.adjustedRadius, |
| 3548 point.rotationAngle(), | 3548 point.rotationAngle(), |
| 3549 point.force()); | 3549 point.force()); |
| 3550 | 3550 |
| 3551 // Ensure this target's touch list exists, even if it ends up empty, so | 3551 // Ensure this target's touch list exists, even if it ends up empty, so |
| 3552 // it can always be passed to TouchEvent::Create below. | 3552 // it can always be passed to TouchEvent::Create below. |
| 3553 TargetTouchesHeapMap::iterator targetTouchesIterator = touchesByTarget.f
ind(touchInfo.touchTarget); | 3553 TargetTouchesHeapMap::iterator targetTouchesIterator = touchesByTarget.f
ind(touchInfo.touchTarget.get()); |
| 3554 if (targetTouchesIterator == touchesByTarget.end()) { | 3554 if (targetTouchesIterator == touchesByTarget.end()) { |
| 3555 touchesByTarget.set(touchInfo.touchTarget, TouchList::create()); | 3555 touchesByTarget.set(touchInfo.touchTarget.get(), TouchList::create()
); |
| 3556 targetTouchesIterator = touchesByTarget.find(touchInfo.touchTarget); | 3556 targetTouchesIterator = touchesByTarget.find(touchInfo.touchTarget.g
et()); |
| 3557 } | 3557 } |
| 3558 | 3558 |
| 3559 // touches and targetTouches should only contain information about | 3559 // touches and targetTouches should only contain information about |
| 3560 // touches still on the screen, so if this point is released or | 3560 // touches still on the screen, so if this point is released or |
| 3561 // cancelled it will only appear in the changedTouches list. | 3561 // cancelled it will only appear in the changedTouches list. |
| 3562 if (pointState != PlatformTouchPoint::TouchReleased && pointState != Pla
tformTouchPoint::TouchCancelled) { | 3562 if (pointState != PlatformTouchPoint::TouchReleased && pointState != Pla
tformTouchPoint::TouchCancelled) { |
| 3563 touches->append(touch); | 3563 touches->append(touch); |
| 3564 targetTouchesIterator->value->append(touch); | 3564 targetTouchesIterator->value->append(touch); |
| 3565 } | 3565 } |
| 3566 | 3566 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3704 // this work. | 3704 // this work. |
| 3705 if (!m_touchSequenceDocument || !m_touchSequenceDocument->frameHost() || !m_
touchSequenceDocument->frameHost()->eventHandlerRegistry().hasEventHandlers(Even
tHandlerRegistry::TouchEvent) || !m_touchSequenceDocument->frame()) { | 3705 if (!m_touchSequenceDocument || !m_touchSequenceDocument->frameHost() || !m_
touchSequenceDocument->frameHost()->eventHandlerRegistry().hasEventHandlers(Even
tHandlerRegistry::TouchEvent) || !m_touchSequenceDocument->frame()) { |
| 3706 if (allTouchReleased) { | 3706 if (allTouchReleased) { |
| 3707 m_touchSequenceDocument.clear(); | 3707 m_touchSequenceDocument.clear(); |
| 3708 m_touchSequenceUserGestureToken.clear(); | 3708 m_touchSequenceUserGestureToken.clear(); |
| 3709 } | 3709 } |
| 3710 return false; | 3710 return false; |
| 3711 } | 3711 } |
| 3712 | 3712 |
| 3713 // Compute and store the common info used by both PointerEvent and TouchEven
t. | 3713 // Compute and store the common info used by both PointerEvent and TouchEven
t. |
| 3714 Vector<TouchInfo> touchInfos(points.size()); | 3714 WillBeHeapVector<TouchInfo> touchInfos(points.size()); |
| 3715 | 3715 |
| 3716 for (unsigned i = 0; i < points.size(); ++i) { | 3716 for (unsigned i = 0; i < points.size(); ++i) { |
| 3717 const PlatformTouchPoint& point = points[i]; | 3717 const PlatformTouchPoint& point = points[i]; |
| 3718 PlatformTouchPoint::State pointState = point.state(); | 3718 PlatformTouchPoint::State pointState = point.state(); |
| 3719 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; | 3719 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; |
| 3720 | 3720 |
| 3721 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla
tformTouchPoint::TouchCancelled) { | 3721 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla
tformTouchPoint::TouchCancelled) { |
| 3722 // The target should be the original target for this touch, so get | 3722 // The target should be the original target for this touch, so get |
| 3723 // it from the hashmap. As it's a release or cancel we also remove | 3723 // it from the hashmap. As it's a release or cancel we also remove |
| 3724 // it from the map. | 3724 // it from the map. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3759 targetFrame = m_touchSequenceDocument->frame(); | 3759 targetFrame = m_touchSequenceDocument->frame(); |
| 3760 } | 3760 } |
| 3761 ASSERT(targetFrame); | 3761 ASSERT(targetFrame); |
| 3762 | 3762 |
| 3763 // pagePoint should always be in the target element's document coordinat
es. | 3763 // pagePoint should always be in the target element's document coordinat
es. |
| 3764 FloatPoint pagePoint = targetFrame->view()->rootFrameToContents(point.po
s()); | 3764 FloatPoint pagePoint = targetFrame->view()->rootFrameToContents(point.po
s()); |
| 3765 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); | 3765 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); |
| 3766 | 3766 |
| 3767 TouchInfo& touchInfo = touchInfos[i]; | 3767 TouchInfo& touchInfo = touchInfos[i]; |
| 3768 touchInfo.point = point; | 3768 touchInfo.point = point; |
| 3769 touchInfo.touchTarget = touchTarget.get(); | 3769 touchInfo.touchTarget = touchTarget; |
| 3770 touchInfo.targetFrame = targetFrame; | 3770 touchInfo.targetFrame = targetFrame; |
| 3771 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); | 3771 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); |
| 3772 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); | 3772 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); |
| 3773 touchInfo.knownTarget = knownTarget; | 3773 touchInfo.knownTarget = knownTarget; |
| 3774 touchInfo.consumed = false; | 3774 touchInfo.consumed = false; |
| 3775 } | 3775 } |
| 3776 | 3776 |
| 3777 if (RuntimeEnabledFeatures::pointerEventEnabled()) { | 3777 if (RuntimeEnabledFeatures::pointerEventEnabled()) { |
| 3778 dispatchPointerEventsForTouchEvent(event, touchInfos); | 3778 dispatchPointerEventsForTouchEvent(event, touchInfos); |
| 3779 // TODO(mustaq): This needs attention. | 3779 // Note that the disposition of any pointer events affects only the gene
ration of touch |
| 3780 // From CL discussion: The disposition of any pointer events affects onl
y the generation of | 3780 // events. If all pointer events were handled (and hence no touch events
were fired), that |
| 3781 // touch events. If pointer events were handled (and hence no touch even
ts generated) that is | 3781 // is still equivalent to the touch events going unhandled because point
er event handler |
| 3782 // still equivalent to the touch events going unhandled because pointer
event handler don't | 3782 // don't block scroll gesture generation. |
| 3783 // block scroll gesture generation. | |
| 3784 } | 3783 } |
| 3785 | 3784 |
| 3786 return dispatchTouchEvents(event, touchInfos, freshTouchEvents, allTouchRele
ased); | 3785 return dispatchTouchEvents(event, touchInfos, freshTouchEvents, allTouchRele
ased); |
| 3787 } | 3786 } |
| 3788 | 3787 |
| 3789 TouchAction EventHandler::intersectTouchAction(TouchAction action1, TouchAction
action2) | 3788 TouchAction EventHandler::intersectTouchAction(TouchAction action1, TouchAction
action2) |
| 3790 { | 3789 { |
| 3791 if (action1 == TouchActionNone || action2 == TouchActionNone) | 3790 if (action1 == TouchActionNone || action2 == TouchActionNone) |
| 3792 return TouchActionNone; | 3791 return TouchActionNone; |
| 3793 if (action1 == TouchActionAuto) | 3792 if (action1 == TouchActionAuto) |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3890 unsigned EventHandler::accessKeyModifiers() | 3889 unsigned EventHandler::accessKeyModifiers() |
| 3891 { | 3890 { |
| 3892 #if OS(MACOSX) | 3891 #if OS(MACOSX) |
| 3893 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3892 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 3894 #else | 3893 #else |
| 3895 return PlatformEvent::AltKey; | 3894 return PlatformEvent::AltKey; |
| 3896 #endif | 3895 #endif |
| 3897 } | 3896 } |
| 3898 | 3897 |
| 3899 } // namespace blink | 3898 } // namespace blink |
| OLD | NEW |