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 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3418 } | 3418 } |
3419 if (freshTouchEvents) { | 3419 if (freshTouchEvents) { |
3420 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should | 3420 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should |
3421 // have cleared the active document when we saw the last release. But we | 3421 // have cleared the active document when we saw the last release. But we |
3422 // have some tests that violate this, ClusterFuzz could trigger it, and | 3422 // have some tests that violate this, ClusterFuzz could trigger it, and |
3423 // there may be cases where the browser doesn't reliably release all | 3423 // there may be cases where the browser doesn't reliably release all |
3424 // touches. http://crbug.com/345372 tracks this. | 3424 // touches. http://crbug.com/345372 tracks this. |
3425 m_touchSequenceDocument.clear(); | 3425 m_touchSequenceDocument.clear(); |
3426 } | 3426 } |
3427 | 3427 |
| 3428 ASSERT(m_frame->view()); |
| 3429 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc
hSequenceDocument->frame()->view())) { |
| 3430 // If the active touch document has no frame or view, it's probably bein
g destroyed |
| 3431 // so we can't dispatch events. |
| 3432 return false; |
| 3433 } |
| 3434 |
3428 // First do hit tests for any new touch points. | 3435 // First do hit tests for any new touch points. |
3429 for (i = 0; i < points.size(); ++i) { | 3436 for (i = 0; i < points.size(); ++i) { |
3430 const PlatformTouchPoint& point = points[i]; | 3437 const PlatformTouchPoint& point = points[i]; |
3431 LayoutPoint pagePoint = documentPointForWindowPoint(m_frame, point.pos()
); | |
3432 | 3438 |
3433 // Touch events implicitly capture to the touched node, and don't change | 3439 // Touch events implicitly capture to the touched node, and don't change |
3434 // active/hover states themselves (Gesture events do). So we only need | 3440 // active/hover states themselves (Gesture events do). So we only need |
3435 // to hit-test on touchstart, and it can be read-only. | 3441 // to hit-test on touchstart, and it can be read-only. |
3436 if (point.state() == PlatformTouchPoint::TouchPressed) { | 3442 if (point.state() == PlatformTouchPoint::TouchPressed) { |
3437 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv
ent | HitTestRequest::ReadOnly | HitTestRequest::Active; | 3443 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv
ent | HitTestRequest::ReadOnly | HitTestRequest::Active; |
| 3444 LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->windowTo
Contents(point.pos())); |
3438 HitTestResult result; | 3445 HitTestResult result; |
3439 if (!m_touchSequenceDocument) { | 3446 if (!m_touchSequenceDocument) { |
3440 result = hitTestResultAtPoint(pagePoint, hitType); | 3447 result = hitTestResultAtPoint(pagePoint, hitType); |
3441 } else if (m_touchSequenceDocument->frame()) { | 3448 } else if (m_touchSequenceDocument->frame()) { |
3442 LayoutPoint pagePointInOriginatingDocument = documentPointForWin
dowPoint(m_touchSequenceDocument->frame(), point.pos()); | 3449 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum
ent->frame()->view()->windowToContents(point.pos())); |
3443 result = hitTestResultInFrame(m_touchSequenceDocument->frame(),
pagePointInOriginatingDocument, hitType); | 3450 result = hitTestResultInFrame(m_touchSequenceDocument->frame(),
framePoint, hitType); |
3444 } else | 3451 } else |
3445 continue; | 3452 continue; |
3446 | 3453 |
3447 Node* node = result.innerNode(); | 3454 Node* node = result.innerNode(); |
3448 if (!node) | 3455 if (!node) |
3449 continue; | 3456 continue; |
3450 | 3457 |
3451 // Touch events should not go to text nodes | 3458 // Touch events should not go to text nodes |
3452 if (node->isTextNode()) | 3459 if (node->isTextNode()) |
3453 node = NodeRenderingTraversal::parent(node); | 3460 node = NodeRenderingTraversal::parent(node); |
3454 | 3461 |
3455 if (!m_touchSequenceDocument) { | 3462 if (!m_touchSequenceDocument) { |
3456 // Keep track of which document should receive all touch events | 3463 // Keep track of which document should receive all touch events |
3457 // in the active sequence. This must be a single document to | 3464 // in the active sequence. This must be a single document to |
3458 // ensure we don't leak Nodes between documents. | 3465 // ensure we don't leak Nodes between documents. |
3459 m_touchSequenceDocument = &(result.innerNode()->document()); | 3466 m_touchSequenceDocument = &(result.innerNode()->document()); |
| 3467 ASSERT(m_touchSequenceDocument->frame()->view()); |
3460 } | 3468 } |
3461 | 3469 |
3462 // Ideally we'd ASSERT(!m_targetForTouchID.contains(point.id()) | 3470 // Ideally we'd ASSERT(!m_targetForTouchID.contains(point.id()) |
3463 // since we shouldn't get a touchstart for a touch that's already | 3471 // since we shouldn't get a touchstart for a touch that's already |
3464 // down. However EventSender allows this to be violated and there's | 3472 // down. However EventSender allows this to be violated and there's |
3465 // some tests that take advantage of it. There may also be edge | 3473 // some tests that take advantage of it. There may also be edge |
3466 // cases in the browser where this happens. | 3474 // cases in the browser where this happens. |
3467 // See http://crbug.com/345372. | 3475 // See http://crbug.com/345372. |
3468 m_targetForTouchID.set(point.id(), node); | 3476 m_targetForTouchID.set(point.id(), node); |
3469 | 3477 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3502 struct { | 3510 struct { |
3503 // The touches corresponding to the particular change state this struct | 3511 // The touches corresponding to the particular change state this struct |
3504 // instance represents. | 3512 // instance represents. |
3505 RefPtrWillBeMember<TouchList> m_touches; | 3513 RefPtrWillBeMember<TouchList> m_touches; |
3506 // Set of targets involved in m_touches. | 3514 // Set of targets involved in m_touches. |
3507 EventTargetSet m_targets; | 3515 EventTargetSet m_targets; |
3508 } changedTouches[PlatformTouchPoint::TouchStateEnd]; | 3516 } changedTouches[PlatformTouchPoint::TouchStateEnd]; |
3509 | 3517 |
3510 for (i = 0; i < points.size(); ++i) { | 3518 for (i = 0; i < points.size(); ++i) { |
3511 const PlatformTouchPoint& point = points[i]; | 3519 const PlatformTouchPoint& point = points[i]; |
3512 LayoutPoint pagePoint = documentPointForWindowPoint(m_frame, point.pos()
); | |
3513 PlatformTouchPoint::State pointState = point.state(); | 3520 PlatformTouchPoint::State pointState = point.state(); |
3514 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; | 3521 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; |
3515 | 3522 |
3516 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla
tformTouchPoint::TouchCancelled) { | 3523 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla
tformTouchPoint::TouchCancelled) { |
3517 // The target should be the original target for this touch, so get | 3524 // The target should be the original target for this touch, so get |
3518 // it from the hashmap. As it's a release or cancel we also remove | 3525 // it from the hashmap. As it's a release or cancel we also remove |
3519 // it from the map. | 3526 // it from the map. |
3520 touchTarget = m_targetForTouchID.take(point.id()); | 3527 touchTarget = m_targetForTouchID.take(point.id()); |
3521 } else { | 3528 } else { |
3522 // No hittest is performed on move or stationary, since the target | 3529 // No hittest is performed on move or stationary, since the target |
(...skipping 23 matching lines...) Expand all Loading... |
3546 // Since we know there was no handler invoked, the specific target | 3553 // Since we know there was no handler invoked, the specific target |
3547 // should be completely irrelevant to the application. | 3554 // should be completely irrelevant to the application. |
3548 // FIXME: Oilpan: We can remove the following .get() if EventTarget | 3555 // FIXME: Oilpan: We can remove the following .get() if EventTarget |
3549 // is on-heap. | 3556 // is on-heap. |
3550 touchTarget = m_touchSequenceDocument.get(); | 3557 touchTarget = m_touchSequenceDocument.get(); |
3551 targetFrame = m_touchSequenceDocument->frame(); | 3558 targetFrame = m_touchSequenceDocument->frame(); |
3552 knownTarget = false; | 3559 knownTarget = false; |
3553 } | 3560 } |
3554 ASSERT(targetFrame); | 3561 ASSERT(targetFrame); |
3555 | 3562 |
3556 if (m_frame != targetFrame) { | 3563 // pagePoint should always be relative to the target elements |
3557 // pagePoint should always be relative to the target elements | 3564 // containing frame. |
3558 // containing frame. | 3565 FloatPoint pagePoint = targetFrame->view()->windowToContents(point.pos()
); |
3559 pagePoint = documentPointForWindowPoint(targetFrame, point.pos()); | |
3560 } | |
3561 | 3566 |
3562 float scaleFactor = targetFrame->pageZoomFactor(); | 3567 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); |
3563 | 3568 |
3564 int adjustedPageX = lroundf(pagePoint.x() / scaleFactor); | 3569 FloatPoint adjustedPagePoint = pagePoint.scaledBy(scaleFactor); |
3565 int adjustedPageY = lroundf(pagePoint.y() / scaleFactor); | 3570 FloatSize adjustedRadius = point.radius().scaledBy(scaleFactor); |
3566 int adjustedRadiusX = lroundf(point.radiusX() / scaleFactor); | |
3567 int adjustedRadiusY = lroundf(point.radiusY() / scaleFactor); | |
3568 | 3571 |
3569 RefPtrWillBeRawPtr<Touch> touch = Touch::create(targetFrame, touchTarget
.get(), point.id(), | 3572 RefPtrWillBeRawPtr<Touch> touch = Touch::create( |
3570 point.screenPos().x(), point.screenP
os().y(), | 3573 targetFrame, touchTarget.get(), point.id(), point.screenPos(), adjus
tedPagePoint, adjustedRadius, point.rotationAngle(), point.force()); |
3571 adjustedPageX, adjustedPageY, | |
3572 adjustedRadiusX, adjustedRadiusY, | |
3573 point.rotationAngle(), point.force()
); | |
3574 | 3574 |
3575 // Ensure this target's touch list exists, even if it ends up empty, so | 3575 // Ensure this target's touch list exists, even if it ends up empty, so |
3576 // it can always be passed to TouchEvent::Create below. | 3576 // it can always be passed to TouchEvent::Create below. |
3577 TargetTouchesHeapMap::iterator targetTouchesIterator = touchesByTarget.f
ind(touchTarget.get()); | 3577 TargetTouchesHeapMap::iterator targetTouchesIterator = touchesByTarget.f
ind(touchTarget.get()); |
3578 if (targetTouchesIterator == touchesByTarget.end()) { | 3578 if (targetTouchesIterator == touchesByTarget.end()) { |
3579 touchesByTarget.set(touchTarget.get(), TouchList::create()); | 3579 touchesByTarget.set(touchTarget.get(), TouchList::create()); |
3580 targetTouchesIterator = touchesByTarget.find(touchTarget.get()); | 3580 targetTouchesIterator = touchesByTarget.find(touchTarget.get()); |
3581 } | 3581 } |
3582 | 3582 |
3583 // touches and targetTouches should only contain information about | 3583 // touches and targetTouches should only contain information about |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3752 unsigned EventHandler::accessKeyModifiers() | 3752 unsigned EventHandler::accessKeyModifiers() |
3753 { | 3753 { |
3754 #if OS(MACOSX) | 3754 #if OS(MACOSX) |
3755 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3755 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3756 #else | 3756 #else |
3757 return PlatformEvent::AltKey; | 3757 return PlatformEvent::AltKey; |
3758 #endif | 3758 #endif |
3759 } | 3759 } |
3760 | 3760 |
3761 } // namespace WebCore | 3761 } // namespace WebCore |
OLD | NEW |