Chromium Code Reviews| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 , m_mouseDownWasInSubframe(false) | 215 , m_mouseDownWasInSubframe(false) |
| 216 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) | 216 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) |
| 217 , m_svgPan(false) | 217 , m_svgPan(false) |
| 218 , m_resizeScrollableArea(0) | 218 , m_resizeScrollableArea(0) |
| 219 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 219 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
| 220 , m_clickCount(0) | 220 , m_clickCount(0) |
| 221 , m_shouldOnlyFireDragOverEvent(false) | 221 , m_shouldOnlyFireDragOverEvent(false) |
| 222 , m_mousePositionIsUnknown(true) | 222 , m_mousePositionIsUnknown(true) |
| 223 , m_mouseDownTimestamp(0) | 223 , m_mouseDownTimestamp(0) |
| 224 , m_widgetIsLatched(false) | 224 , m_widgetIsLatched(false) |
| 225 , m_originatingTouchPointTargetKey(0) | |
| 226 , m_touchPressed(false) | 225 , m_touchPressed(false) |
| 227 , m_scrollGestureHandlingNode(nullptr) | 226 , m_scrollGestureHandlingNode(nullptr) |
| 228 , m_lastHitTestResultOverWidget(false) | 227 , m_lastHitTestResultOverWidget(false) |
| 229 , m_maxMouseMovedDuration(0) | 228 , m_maxMouseMovedDuration(0) |
| 230 , m_baseEventType(PlatformEvent::NoType) | 229 , m_baseEventType(PlatformEvent::NoType) |
| 231 , m_didStartDrag(false) | 230 , m_didStartDrag(false) |
| 232 , m_longTapShouldInvokeContextMenu(false) | 231 , m_longTapShouldInvokeContextMenu(false) |
| 233 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 232 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 234 , m_lastShowPressTimestamp(0) | 233 , m_lastShowPressTimestamp(0) |
| 235 { | 234 { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 m_mousePositionIsUnknown = true; | 271 m_mousePositionIsUnknown = true; |
| 273 m_lastKnownMousePosition = IntPoint(); | 272 m_lastKnownMousePosition = IntPoint(); |
| 274 m_lastKnownMouseGlobalPosition = IntPoint(); | 273 m_lastKnownMouseGlobalPosition = IntPoint(); |
| 275 m_lastMouseDownUserGestureToken.clear(); | 274 m_lastMouseDownUserGestureToken.clear(); |
| 276 m_mousePressNode = nullptr; | 275 m_mousePressNode = nullptr; |
| 277 m_mousePressed = false; | 276 m_mousePressed = false; |
| 278 m_capturesDragging = false; | 277 m_capturesDragging = false; |
| 279 m_capturingMouseEventsNode = nullptr; | 278 m_capturingMouseEventsNode = nullptr; |
| 280 m_latchedWheelEventNode = nullptr; | 279 m_latchedWheelEventNode = nullptr; |
| 281 m_previousWheelScrolledNode = nullptr; | 280 m_previousWheelScrolledNode = nullptr; |
| 282 m_originatingTouchPointTargets.clear(); | 281 m_targetForTouchID.clear(); |
| 283 m_originatingTouchPointDocument.clear(); | 282 m_touchSequenceDocument.clear(); |
| 284 m_originatingTouchPointTargetKey = 0; | |
| 285 m_scrollGestureHandlingNode = nullptr; | 283 m_scrollGestureHandlingNode = nullptr; |
| 286 m_lastHitTestResultOverWidget = false; | 284 m_lastHitTestResultOverWidget = false; |
| 287 m_previousGestureScrolledNode = nullptr; | 285 m_previousGestureScrolledNode = nullptr; |
| 288 m_scrollbarHandlingScrollGesture = nullptr; | 286 m_scrollbarHandlingScrollGesture = nullptr; |
| 289 m_maxMouseMovedDuration = 0; | 287 m_maxMouseMovedDuration = 0; |
| 290 m_baseEventType = PlatformEvent::NoType; | 288 m_baseEventType = PlatformEvent::NoType; |
| 291 m_didStartDrag = false; | 289 m_didStartDrag = false; |
| 292 m_touchPressed = false; | 290 m_touchPressed = false; |
| 293 m_mouseDownMayStartSelect = false; | 291 m_mouseDownMayStartSelect = false; |
| 294 m_mouseDownMayStartDrag = false; | 292 m_mouseDownMayStartDrag = false; |
| (...skipping 3156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3451 return result; | 3449 return result; |
| 3452 } | 3450 } |
| 3453 frame->contentRenderer()->hitTest(HitTestRequest(hitType), result); | 3451 frame->contentRenderer()->hitTest(HitTestRequest(hitType), result); |
| 3454 return result; | 3452 return result; |
| 3455 } | 3453 } |
| 3456 | 3454 |
| 3457 bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) | 3455 bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) |
| 3458 { | 3456 { |
| 3459 TRACE_EVENT0("webkit", "EventHandler::handleTouchEvent"); | 3457 TRACE_EVENT0("webkit", "EventHandler::handleTouchEvent"); |
| 3460 | 3458 |
| 3461 // First build up the lists to use for the 'touches', 'targetTouches' and 'c hangedTouches' attributes | |
| 3462 // in the JS event. See http://www.sitepen.com/blog/2008/07/10/touching-and- gesturing-on-the-iphone/ | |
| 3463 // for an overview of how these lists fit together. | |
| 3464 | |
| 3465 // Holds the complete set of touches on the screen and will be used as the ' touches' list in the JS event. | |
| 3466 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create(); | |
| 3467 | |
| 3468 // A different view on the 'touches' list above, filtered and grouped by eve nt target. Used for the | |
| 3469 // 'targetTouches' list in the JS event. | |
| 3470 typedef WillBeHeapHashMap<EventTarget*, RefPtrWillBeMember<TouchList> > Targ etTouchesHeapMap; | |
| 3471 TargetTouchesHeapMap touchesByTarget; | |
| 3472 | |
| 3473 // Array of touches per state, used to assemble the 'changedTouches' list in the JS event. | |
| 3474 typedef HashSet<RefPtr<EventTarget> > EventTargetSet; | |
| 3475 struct { | |
| 3476 // The touches corresponding to the particular change state this struct instance represents. | |
| 3477 RefPtrWillBeMember<TouchList> m_touches; | |
| 3478 // Set of targets involved in m_touches. | |
| 3479 EventTargetSet m_targets; | |
| 3480 } changedTouches[PlatformTouchPoint::TouchStateEnd]; | |
| 3481 | |
| 3482 const Vector<PlatformTouchPoint>& points = event.touchPoints(); | 3459 const Vector<PlatformTouchPoint>& points = event.touchPoints(); |
| 3483 | 3460 |
| 3484 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 3461 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
| 3485 | 3462 |
| 3486 unsigned i; | 3463 unsigned i; |
| 3487 bool freshTouchEvents = true; | 3464 bool freshTouchEvents = true; |
| 3488 bool allTouchReleased = true; | 3465 bool allTouchReleased = true; |
| 3489 for (i = 0; i < points.size(); ++i) { | 3466 for (i = 0; i < points.size(); ++i) { |
| 3490 const PlatformTouchPoint& point = points[i]; | 3467 const PlatformTouchPoint& point = points[i]; |
| 3491 if (point.state() != PlatformTouchPoint::TouchPressed) | 3468 if (point.state() != PlatformTouchPoint::TouchPressed) |
| 3492 freshTouchEvents = false; | 3469 freshTouchEvents = false; |
| 3493 if (point.state() != PlatformTouchPoint::TouchReleased && point.state() != PlatformTouchPoint::TouchCancelled) | 3470 if (point.state() != PlatformTouchPoint::TouchReleased && point.state() != PlatformTouchPoint::TouchCancelled) |
| 3494 allTouchReleased = false; | 3471 allTouchReleased = false; |
| 3495 } | 3472 } |
| 3473 if (freshTouchEvents) { | |
| 3474 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should hav e cleared the | |
|
rjkroege
2014/05/02 20:33:50
nit: you could line-break the comment at 80?
Rick Byers
2014/05/02 21:24:15
Done. Also updated comments below.
| |
| 3475 // active document when we saw the last release. But we have some tests that violate | |
| 3476 // this, ClusterFuzz could trigger it, and there may be cases where the browser doesn't | |
| 3477 // reliably release all touches. http://crbug.com/345372 tracks this. | |
| 3478 m_touchSequenceDocument.clear(); | |
| 3479 } | |
| 3496 | 3480 |
| 3481 // First do hit tests for any new touch points. | |
| 3497 for (i = 0; i < points.size(); ++i) { | 3482 for (i = 0; i < points.size(); ++i) { |
| 3498 const PlatformTouchPoint& point = points[i]; | 3483 const PlatformTouchPoint& point = points[i]; |
| 3499 PlatformTouchPoint::State pointState = point.state(); | |
| 3500 LayoutPoint pagePoint = documentPointForWindowPoint(m_frame, point.pos() ); | 3484 LayoutPoint pagePoint = documentPointForWindowPoint(m_frame, point.pos() ); |
| 3501 | 3485 |
| 3502 // Gesture events trigger the active state, not touch events, | 3486 // Touch events implicitly capture to the touched node, and don't change |
| 3503 // so touch event hit tests can always be read only. | 3487 // active/hover states themselves (Gesture events do). So we only need |
| 3504 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent | HitTestRequest::ReadOnly; | 3488 // to hit-test on touchstart, and it can be read-only. |
| 3505 // The HitTestRequest types used for mouse events map quite adequately | 3489 if (point.state() == PlatformTouchPoint::TouchPressed) { |
| 3506 // to touch events. Note that in addition to meaning that the hit test | 3490 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv ent | HitTestRequest::ReadOnly | HitTestRequest::Active; |
| 3507 // should affect the active state of the current node if necessary, | |
| 3508 // HitTestRequest::Active signifies that the hit test is taking place | |
| 3509 // with the mouse (or finger in this case) being pressed. | |
| 3510 switch (pointState) { | |
| 3511 case PlatformTouchPoint::TouchPressed: | |
| 3512 hitType |= HitTestRequest::Active; | |
| 3513 break; | |
| 3514 case PlatformTouchPoint::TouchMoved: | |
| 3515 hitType |= HitTestRequest::Active | HitTestRequest::Move; | |
| 3516 break; | |
| 3517 case PlatformTouchPoint::TouchReleased: | |
| 3518 case PlatformTouchPoint::TouchCancelled: | |
| 3519 hitType |= HitTestRequest::Release; | |
| 3520 break; | |
| 3521 case PlatformTouchPoint::TouchStationary: | |
| 3522 hitType |= HitTestRequest::Active; | |
| 3523 break; | |
| 3524 default: | |
| 3525 ASSERT_NOT_REACHED(); | |
| 3526 break; | |
| 3527 } | |
| 3528 | |
| 3529 // Increment the platform touch id by 1 to avoid storing a key of 0 in t he hashmap. | |
| 3530 unsigned touchPointTargetKey = point.id() + 1; | |
| 3531 RefPtr<EventTarget> touchTarget; | |
| 3532 if (pointState == PlatformTouchPoint::TouchPressed) { | |
| 3533 HitTestResult result; | 3491 HitTestResult result; |
| 3534 if (freshTouchEvents) { | 3492 if (!m_touchSequenceDocument) { |
| 3535 result = hitTestResultAtPoint(pagePoint, hitType); | 3493 result = hitTestResultAtPoint(pagePoint, hitType); |
| 3536 m_originatingTouchPointTargetKey = touchPointTargetKey; | 3494 } else if (m_touchSequenceDocument->frame()) { |
| 3537 } else if (m_originatingTouchPointDocument.get() && m_originatingTou chPointDocument->frame()) { | 3495 LayoutPoint pagePointInOriginatingDocument = documentPointForWin dowPoint(m_touchSequenceDocument->frame(), point.pos()); |
| 3538 LayoutPoint pagePointInOriginatingDocument = documentPointForWin dowPoint(m_originatingTouchPointDocument->frame(), point.pos()); | 3496 result = hitTestResultInFrame(m_touchSequenceDocument->frame(), pagePointInOriginatingDocument, hitType); |
| 3539 result = hitTestResultInFrame(m_originatingTouchPointDocument->f rame(), pagePointInOriginatingDocument, hitType); | |
| 3540 } else | 3497 } else |
| 3541 continue; | 3498 continue; |
| 3542 | 3499 |
| 3543 Node* node = result.innerNode(); | 3500 Node* node = result.innerNode(); |
| 3544 if (!node) | 3501 if (!node) |
| 3545 continue; | 3502 continue; |
| 3546 | 3503 |
| 3547 // Touch events should not go to text nodes | 3504 // Touch events should not go to text nodes |
| 3548 if (node->isTextNode()) | 3505 if (node->isTextNode()) |
| 3549 node = NodeRenderingTraversal::parent(node); | 3506 node = NodeRenderingTraversal::parent(node); |
| 3550 | 3507 |
| 3551 Document& doc = node->document(); | 3508 if (!m_touchSequenceDocument) { |
| 3552 // Record the originating touch document even if it does not have a touch listener. | 3509 // Keep track of which document should receive all touch events in the active sequence. |
| 3553 if (freshTouchEvents) { | 3510 // This must be a single document to ensure we don't leak Nodes between documents. |
| 3554 m_originatingTouchPointDocument = &doc; | 3511 m_touchSequenceDocument = &(result.innerNode()->document()); |
| 3555 freshTouchEvents = false; | |
| 3556 } | 3512 } |
| 3557 if (!doc.hasTouchEventHandlers()) | 3513 |
| 3558 continue; | 3514 // Ideally we'd ASSERT(!m_targetForTouchID.contains(point.id()) sinc e we shouldn't get |
| 3559 m_originatingTouchPointTargets.set(touchPointTargetKey, node); | 3515 // a touchstart for a touch that's already down. However EventSender allows this to be |
| 3560 touchTarget = node; | 3516 // violated and there's some tests that take advantage of it. There may also be edge |
| 3517 // cases in the browser where this happens - http://crbug.com/345372 tracks this. | |
| 3518 m_targetForTouchID.set(point.id(), node); | |
| 3561 | 3519 |
| 3562 TouchAction effectiveTouchAction = computeEffectiveTouchAction(pageP oint); | 3520 TouchAction effectiveTouchAction = computeEffectiveTouchAction(pageP oint); |
| 3563 if (effectiveTouchAction != TouchActionAuto) | 3521 if (effectiveTouchAction != TouchActionAuto) |
| 3564 m_frame->page()->chrome().client().setTouchAction(effectiveTouch Action); | 3522 m_frame->page()->chrome().client().setTouchAction(effectiveTouch Action); |
| 3523 } | |
| 3524 } | |
| 3565 | 3525 |
| 3566 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) { | 3526 m_touchPressed = !allTouchReleased; |
| 3527 | |
| 3528 // If there's no document receiving touch events, or no handlers on the docu ment | |
| 3529 // set to receive the events, then we can skip all the rest of this work. | |
| 3530 if (!m_touchSequenceDocument || !m_touchSequenceDocument->hasTouchEventHandl ers() || !m_touchSequenceDocument->frame()) { | |
| 3531 if (allTouchReleased) | |
| 3532 m_touchSequenceDocument.clear(); | |
| 3533 return false; | |
| 3534 } | |
| 3535 | |
| 3536 // Build up the lists to use for the 'touches', 'targetTouches' and 'changed Touches' | |
| 3537 // attributes in the JS event. See http://www.w3.org/TR/touch-events/#touche vent-interface | |
| 3538 // for how these lists fit together. | |
| 3539 | |
| 3540 // Holds the complete set of touches on the screen and will be used as the ' touches' list in the JS event. | |
| 3541 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create(); | |
| 3542 | |
| 3543 // A different view on the 'touches' list above, filtered and grouped by eve nt target. Used for the | |
| 3544 // 'targetTouches' list in the JS event. | |
| 3545 typedef WillBeHeapHashMap<EventTarget*, RefPtrWillBeMember<TouchList> > Targ etTouchesHeapMap; | |
| 3546 TargetTouchesHeapMap touchesByTarget; | |
| 3547 | |
| 3548 // Array of touches per state, used to assemble the 'changedTouches' list in the JS event. | |
| 3549 typedef HashSet<RefPtr<EventTarget> > EventTargetSet; | |
| 3550 struct { | |
| 3551 // The touches corresponding to the particular change state this struct instance represents. | |
| 3552 RefPtrWillBeMember<TouchList> m_touches; | |
| 3553 // Set of targets involved in m_touches. | |
| 3554 EventTargetSet m_targets; | |
| 3555 } changedTouches[PlatformTouchPoint::TouchStateEnd]; | |
| 3556 | |
| 3557 for (i = 0; i < points.size(); ++i) { | |
| 3558 const PlatformTouchPoint& point = points[i]; | |
| 3559 LayoutPoint pagePoint = documentPointForWindowPoint(m_frame, point.pos() ); | |
| 3560 PlatformTouchPoint::State pointState = point.state(); | |
| 3561 RefPtr<EventTarget> touchTarget; | |
| 3562 | |
| 3563 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla tformTouchPoint::TouchCancelled) { | |
| 3567 // The target should be the original target for this touch, so get i t from the hashmap. As it's a release or cancel | 3564 // The target should be the original target for this touch, so get i t from the hashmap. As it's a release or cancel |
| 3568 // we also remove it from the map. | 3565 // we also remove it from the map. |
| 3569 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe y); | 3566 touchTarget = m_targetForTouchID.take(point.id()); |
| 3570 } else | 3567 } else { |
| 3571 // No hittest is performed on move or stationary, since the target i s not allowed to change anyway. | 3568 // No hittest is performed on move or stationary, since the target i s not allowed to change anyway. |
| 3572 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey ); | 3569 touchTarget = m_targetForTouchID.get(point.id()); |
| 3570 } | |
| 3573 | 3571 |
| 3574 if (!touchTarget.get()) | 3572 LocalFrame* targetFrame; |
| 3575 continue; | 3573 bool knownTarget; |
| 3576 Document& doc = touchTarget->toNode()->document(); | 3574 if (touchTarget) { |
| 3577 if (!doc.hasTouchEventHandlers()) | 3575 Document& doc = touchTarget->toNode()->document(); |
| 3578 continue; | 3576 ASSERT(&doc == m_touchSequenceDocument.get()); |
| 3579 LocalFrame* targetFrame = doc.frame(); | 3577 targetFrame = doc.frame(); |
| 3580 if (!targetFrame) | 3578 knownTarget = true; |
| 3581 continue; | 3579 } else { |
| 3580 // If we don't have a target registered for the point, it means we'v e missed our | |
| 3581 // opportunity to do a hit test for it (due to some optimization tha t prevented blink | |
| 3582 // from ever seeing the touchstart). We should still include the tou ch in the list of | |
| 3583 // those reported to the application, so set it's target to the Docu ment (but don't | |
| 3584 // actually dispatch any events for it). | |
| 3585 touchTarget = m_touchSequenceDocument; | |
| 3586 targetFrame = m_touchSequenceDocument->frame(); | |
| 3587 knownTarget = false; | |
| 3588 } | |
| 3589 ASSERT(targetFrame); | |
| 3582 | 3590 |
| 3583 if (m_frame != targetFrame) { | 3591 if (m_frame != targetFrame) { |
| 3584 // pagePoint should always be relative to the target elements contai ning frame. | 3592 // pagePoint should always be relative to the target elements contai ning frame. |
| 3585 pagePoint = documentPointForWindowPoint(targetFrame, point.pos()); | 3593 pagePoint = documentPointForWindowPoint(targetFrame, point.pos()); |
| 3586 } | 3594 } |
| 3587 | 3595 |
| 3588 float scaleFactor = targetFrame->pageZoomFactor(); | 3596 float scaleFactor = targetFrame->pageZoomFactor(); |
| 3589 | 3597 |
| 3590 int adjustedPageX = lroundf(pagePoint.x() / scaleFactor); | 3598 int adjustedPageX = lroundf(pagePoint.x() / scaleFactor); |
| 3591 int adjustedPageY = lroundf(pagePoint.y() / scaleFactor); | 3599 int adjustedPageY = lroundf(pagePoint.y() / scaleFactor); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 3611 touches->append(touch); | 3619 touches->append(touch); |
| 3612 targetTouchesIterator->value->append(touch); | 3620 targetTouchesIterator->value->append(touch); |
| 3613 } | 3621 } |
| 3614 | 3622 |
| 3615 // Now build up the correct list for changedTouches. | 3623 // Now build up the correct list for changedTouches. |
| 3616 // Note that any touches that are in the TouchStationary state (e.g. if | 3624 // Note that any touches that are in the TouchStationary state (e.g. if |
| 3617 // the user had several points touched but did not move them all) should | 3625 // the user had several points touched but did not move them all) should |
| 3618 // never be in the changedTouches list so we do not handle them explicit ly here. | 3626 // never be in the changedTouches list so we do not handle them explicit ly here. |
| 3619 // See https://bugs.webkit.org/show_bug.cgi?id=37609 for further discuss ion | 3627 // See https://bugs.webkit.org/show_bug.cgi?id=37609 for further discuss ion |
| 3620 // about the TouchStationary state. | 3628 // about the TouchStationary state. |
| 3621 if (pointState != PlatformTouchPoint::TouchStationary) { | 3629 if (pointState != PlatformTouchPoint::TouchStationary && knownTarget) { |
| 3622 ASSERT(pointState < PlatformTouchPoint::TouchStateEnd); | 3630 ASSERT(pointState < PlatformTouchPoint::TouchStateEnd); |
| 3623 if (!changedTouches[pointState].m_touches) | 3631 if (!changedTouches[pointState].m_touches) |
| 3624 changedTouches[pointState].m_touches = TouchList::create(); | 3632 changedTouches[pointState].m_touches = TouchList::create(); |
| 3625 changedTouches[pointState].m_touches->append(touch); | 3633 changedTouches[pointState].m_touches->append(touch); |
| 3626 changedTouches[pointState].m_targets.add(touchTarget); | 3634 changedTouches[pointState].m_targets.add(touchTarget); |
| 3627 } | 3635 } |
| 3628 } | 3636 } |
| 3629 m_touchPressed = touches->length() > 0; | |
| 3630 if (allTouchReleased) | 3637 if (allTouchReleased) |
| 3631 m_originatingTouchPointDocument.clear(); | 3638 m_touchSequenceDocument.clear(); |
| 3632 | 3639 |
| 3633 // Now iterate the changedTouches list and m_targets within it, sending even ts to the targets as required. | 3640 // Now iterate the changedTouches list and m_targets within it, sending even ts to the targets as required. |
| 3634 bool swallowedEvent = false; | 3641 bool swallowedEvent = false; |
| 3635 RefPtrWillBeRawPtr<TouchList> emptyList = TouchList::create(); | 3642 RefPtrWillBeRawPtr<TouchList> emptyList = TouchList::create(); |
| 3636 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) { | 3643 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) { |
| 3637 if (!changedTouches[state].m_touches) | 3644 if (!changedTouches[state].m_touches) |
| 3638 continue; | 3645 continue; |
| 3639 | 3646 |
| 3640 // When sending a touch cancel event, use empty touches and targetTouche s lists. | |
| 3641 bool isTouchCancelEvent = (state == PlatformTouchPoint::TouchCancelled); | |
| 3642 RefPtrWillBeRawPtr<TouchList>& effectiveTouches(isTouchCancelEvent ? emp tyList : touches); | |
| 3643 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl atformTouchPoint::State>(state))); | 3647 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl atformTouchPoint::State>(state))); |
| 3644 const EventTargetSet& targetsForState = changedTouches[state].m_targets; | 3648 const EventTargetSet& targetsForState = changedTouches[state].m_targets; |
| 3645 | |
| 3646 for (EventTargetSet::const_iterator it = targetsForState.begin(); it != targetsForState.end(); ++it) { | 3649 for (EventTargetSet::const_iterator it = targetsForState.begin(); it != targetsForState.end(); ++it) { |
| 3647 EventTarget* touchEventTarget = it->get(); | 3650 EventTarget* touchEventTarget = it->get(); |
| 3648 RefPtrWillBeRawPtr<TouchList> targetTouches(isTouchCancelEvent ? emp tyList.get() : touchesByTarget.get(touchEventTarget)); | 3651 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create( |
| 3649 ASSERT(targetTouches); | 3652 touches.get(), touchesByTarget.get(touchEventTarget), changedTou ches[state].m_touches.get(), |
| 3650 | 3653 stateName, touchEventTarget->toNode()->document().domWindow(), |
| 3651 RefPtrWillBeRawPtr<TouchEvent> touchEvent = | 3654 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(), e vent.metaKey(), event.cancelable()); |
| 3652 TouchEvent::create(effectiveTouches.get(), targetTouches.get(), changedTouches[state].m_touches.get(), | |
| 3653 stateName, touchEventTarget->toNode()->document().domWindow( ), | |
| 3654 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey( ), event.metaKey(), event.cancelable()); | |
| 3655 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get()); | 3655 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get()); |
| 3656 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() || touchEvent->defaultHandled(); | 3656 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() || touchEvent->defaultHandled(); |
| 3657 } | 3657 } |
| 3658 } | 3658 } |
| 3659 | 3659 |
| 3660 return swallowedEvent; | 3660 return swallowedEvent; |
| 3661 } | 3661 } |
| 3662 | 3662 |
| 3663 TouchAction EventHandler::intersectTouchAction(TouchAction action1, TouchAction action2) | 3663 TouchAction EventHandler::intersectTouchAction(TouchAction action1, TouchAction action2) |
| 3664 { | 3664 { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3784 unsigned EventHandler::accessKeyModifiers() | 3784 unsigned EventHandler::accessKeyModifiers() |
| 3785 { | 3785 { |
| 3786 #if OS(MACOSX) | 3786 #if OS(MACOSX) |
| 3787 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3787 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 3788 #else | 3788 #else |
| 3789 return PlatformEvent::AltKey; | 3789 return PlatformEvent::AltKey; |
| 3790 #endif | 3790 #endif |
| 3791 } | 3791 } |
| 3792 | 3792 |
| 3793 } // namespace WebCore | 3793 } // namespace WebCore |
| OLD | NEW |