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 3471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3482 case PlatformTouchPoint::TouchMoved: | 3482 case PlatformTouchPoint::TouchMoved: |
| 3483 return EventTypeNames::pointermove; | 3483 return EventTypeNames::pointermove; |
| 3484 case PlatformTouchPoint::TouchStationary: | 3484 case PlatformTouchPoint::TouchStationary: |
| 3485 // Fall through to default | 3485 // Fall through to default |
| 3486 default: | 3486 default: |
| 3487 ASSERT_NOT_REACHED(); | 3487 ASSERT_NOT_REACHED(); |
| 3488 return emptyAtom; | 3488 return emptyAtom; |
| 3489 } | 3489 } |
| 3490 } | 3490 } |
| 3491 | 3491 |
| 3492 PointerIdManager::PointerType pointerTypeForWebPointPointerType(WebPointerProper ties::PointerType type) | |
|
Rick Byers
2015/07/31 13:13:35
You could probably simplify this by changing Point
mustaq
2015/08/06 20:37:28
Yes, the enums defined only in WebPointerPropertie
| |
| 3493 { | |
| 3494 switch (type) { | |
| 3495 case WebPointerProperties::PointerTypeUnknown: | |
| 3496 return PointerIdManager::PointerTypeUnknown; | |
| 3497 case WebPointerProperties::PointerTypeTouch: | |
| 3498 return PointerIdManager::PointerTypeTouch; | |
| 3499 case WebPointerProperties::PointerTypePen: | |
| 3500 return PointerIdManager::PointerTypePen; | |
| 3501 case WebPointerProperties::PointerTypeMouse: | |
| 3502 return PointerIdManager::PointerTypeMouse; | |
| 3503 } | |
| 3504 ASSERT_NOT_REACHED(); | |
| 3505 return PointerIdManager::PointerTypeUnknown; | |
| 3506 } | |
| 3507 | |
| 3508 static const char* pointerTypeNameForWebPointPointerType(WebPointerProperties::P ointerType type) | |
| 3509 { | |
| 3510 switch (type) { | |
| 3511 case WebPointerProperties::PointerTypeUnknown: | |
| 3512 return ""; | |
| 3513 case WebPointerProperties::PointerTypeTouch: | |
| 3514 return "touch"; | |
| 3515 case WebPointerProperties::PointerTypePen: | |
| 3516 return "pen"; | |
| 3517 case WebPointerProperties::PointerTypeMouse: | |
| 3518 return "mouse"; | |
| 3519 } | |
| 3520 ASSERT_NOT_REACHED(); | |
| 3521 return ""; | |
| 3522 } | |
| 3523 | |
| 3492 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout Point& point, HitTestRequest::HitTestRequestType hitType) | 3524 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout Point& point, HitTestRequest::HitTestRequestType hitType) |
| 3493 { | 3525 { |
| 3494 HitTestResult result(HitTestRequest(hitType), point); | 3526 HitTestResult result(HitTestRequest(hitType), point); |
| 3495 | 3527 |
| 3496 if (!frame || !frame->contentLayoutObject()) | 3528 if (!frame || !frame->contentLayoutObject()) |
| 3497 return result; | 3529 return result; |
| 3498 if (frame->view()) { | 3530 if (frame->view()) { |
| 3499 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars); | 3531 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars); |
| 3500 if (!rect.contains(roundedIntPoint(point))) | 3532 if (!rect.contains(roundedIntPoint(point))) |
| 3501 return result; | 3533 return result; |
| 3502 } | 3534 } |
| 3503 frame->contentLayoutObject()->hitTest(result); | 3535 frame->contentLayoutObject()->hitTest(result); |
| 3504 return result; | 3536 return result; |
| 3505 } | 3537 } |
| 3506 | 3538 |
| 3507 void EventHandler::dispatchPointerEventsForTouchEvent(const PlatformTouchEvent& event, | 3539 void EventHandler::dispatchPointerEventsForTouchEvent(const PlatformTouchEvent& event, |
| 3508 WillBeHeapVector<TouchInfo>& touchInfos) | 3540 WillBeHeapVector<TouchInfo>& touchInfos) |
| 3509 { | 3541 { |
| 3510 const String& PointerTypeStrForTouch("touch"); | |
| 3511 | |
| 3512 // Iterate through the touch points, sending PointerEvents to the targets as required. | 3542 // Iterate through the touch points, sending PointerEvents to the targets as required. |
| 3513 for (unsigned i = 0; i < touchInfos.size(); ++i) { | 3543 for (unsigned i = 0; i < touchInfos.size(); ++i) { |
| 3514 TouchInfo& touchInfo = touchInfos[i]; | 3544 TouchInfo& touchInfo = touchInfos[i]; |
| 3515 const PlatformTouchPoint& point = touchInfo.point; | 3545 const PlatformTouchPoint& point = touchInfo.point; |
| 3516 const unsigned& pointerId = point.id(); | 3546 const unsigned& pointerId = point.id(); |
| 3517 const PlatformTouchPoint::State pointState = point.state(); | 3547 const PlatformTouchPoint::State pointState = point.state(); |
| 3518 | 3548 |
| 3519 if (pointState == PlatformTouchPoint::TouchStationary || !touchInfo.know nTarget) | 3549 if (pointState == PlatformTouchPoint::TouchStationary || !touchInfo.know nTarget) |
| 3520 continue; | 3550 continue; |
| 3521 | 3551 |
| 3522 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::Touc hReleased | 3552 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::Touc hReleased |
| 3523 || pointState == PlatformTouchPoint::TouchCancelled; | 3553 || pointState == PlatformTouchPoint::TouchCancelled; |
| 3554 const PointerIdManager::PointerType pointerType = pointerTypeForWebPoint PointerType(point.pointerProperties().pointerType); | |
| 3555 const String& pointerTypeStr = pointerTypeNameForWebPointPointerType(poi nt.pointerProperties().pointerType); | |
| 3524 | 3556 |
| 3525 if (pointState == PlatformTouchPoint::TouchPressed) | 3557 if (pointState == PlatformTouchPoint::TouchPressed) |
| 3526 m_pointerIdManager.add(PointerIdManager::PointerTypeTouch, pointerId ); | 3558 m_pointerIdManager.add(pointerType, pointerId); |
| 3527 | 3559 |
| 3528 const AtomicString& eventName = pointerEventNameForTouchPointState(point State); | 3560 const AtomicString& eventName = pointerEventNameForTouchPointState(point State); |
| 3529 | 3561 |
| 3530 bool isEnterOrLeave = false; | 3562 bool isEnterOrLeave = false; |
| 3531 | 3563 |
| 3532 PointerEventInit pointerEventInit; | 3564 PointerEventInit pointerEventInit; |
| 3533 pointerEventInit.setPointerId(pointerId); | 3565 pointerEventInit.setPointerId(pointerId); |
| 3534 pointerEventInit.setWidth(touchInfo.adjustedRadius.width()); | 3566 pointerEventInit.setWidth(touchInfo.adjustedRadius.width()); |
| 3535 pointerEventInit.setHeight(touchInfo.adjustedRadius.height()); | 3567 pointerEventInit.setHeight(touchInfo.adjustedRadius.height()); |
| 3536 pointerEventInit.setPressure(point.force()); | 3568 pointerEventInit.setPressure(point.force()); |
| 3537 pointerEventInit.setTiltX(point.pointerProperties().tiltX); | 3569 pointerEventInit.setTiltX(point.pointerProperties().tiltX); |
| 3538 pointerEventInit.setTiltY(point.pointerProperties().tiltY); | 3570 pointerEventInit.setTiltY(point.pointerProperties().tiltY); |
| 3539 pointerEventInit.setPointerType(PointerTypeStrForTouch); | 3571 pointerEventInit.setPointerType(pointerTypeStr); |
| 3540 pointerEventInit.setIsPrimary(m_pointerIdManager.isPrimary(PointerIdMana ger::PointerTypeTouch, pointerId)); | 3572 pointerEventInit.setIsPrimary(m_pointerIdManager.isPrimary(pointerType, pointerId)); |
| 3541 pointerEventInit.setScreenX(point.screenPos().x()); | 3573 pointerEventInit.setScreenX(point.screenPos().x()); |
| 3542 pointerEventInit.setScreenY(point.screenPos().y()); | 3574 pointerEventInit.setScreenY(point.screenPos().y()); |
| 3543 pointerEventInit.setClientX(touchInfo.adjustedPagePoint.x()); | 3575 pointerEventInit.setClientX(touchInfo.adjustedPagePoint.x()); |
| 3544 pointerEventInit.setClientY(touchInfo.adjustedPagePoint.y()); | 3576 pointerEventInit.setClientY(touchInfo.adjustedPagePoint.y()); |
| 3545 pointerEventInit.setButton(0); | 3577 pointerEventInit.setButton(0); |
| 3546 pointerEventInit.setButtons(pointerReleasedOrCancelled ? 0 : 1); | 3578 pointerEventInit.setButtons(pointerReleasedOrCancelled ? 0 : 1); |
| 3547 | 3579 |
| 3548 pointerEventInit.setCtrlKey(event.ctrlKey()); | 3580 pointerEventInit.setCtrlKey(event.ctrlKey()); |
| 3549 pointerEventInit.setShiftKey(event.shiftKey()); | 3581 pointerEventInit.setShiftKey(event.shiftKey()); |
| 3550 pointerEventInit.setAltKey(event.altKey()); | 3582 pointerEventInit.setAltKey(event.altKey()); |
| 3551 pointerEventInit.setMetaKey(event.metaKey()); | 3583 pointerEventInit.setMetaKey(event.metaKey()); |
| 3552 | 3584 |
| 3553 pointerEventInit.setBubbles(!isEnterOrLeave); | 3585 pointerEventInit.setBubbles(!isEnterOrLeave); |
| 3554 pointerEventInit.setCancelable(!isEnterOrLeave && pointState != Platform TouchPoint::TouchCancelled); | 3586 pointerEventInit.setCancelable(!isEnterOrLeave && pointState != Platform TouchPoint::TouchCancelled); |
| 3555 | 3587 |
| 3556 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(eve ntName, pointerEventInit); | 3588 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(eve ntName, pointerEventInit); |
| 3557 touchInfo.touchTarget->dispatchEvent(pointerEvent.get()); | 3589 touchInfo.touchTarget->dispatchEvent(pointerEvent.get()); |
| 3558 touchInfo.consumed = pointerEvent->defaultPrevented() || pointerEvent->d efaultHandled(); | 3590 touchInfo.consumed = pointerEvent->defaultPrevented() || pointerEvent->d efaultHandled(); |
| 3559 | 3591 |
| 3560 // Remove the released/cancelled id at the end to correctly determine pr imary id above. | 3592 // Remove the released/cancelled id at the end to correctly determine pr imary id above. |
| 3561 if (pointerReleasedOrCancelled) | 3593 if (pointerReleasedOrCancelled) |
| 3562 m_pointerIdManager.remove(PointerIdManager::PointerTypeTouch, pointe rId); | 3594 m_pointerIdManager.remove(pointerType, pointerId); |
| 3563 } | 3595 } |
| 3564 } | 3596 } |
| 3565 | 3597 |
| 3566 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos) | 3598 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos) |
| 3567 { | 3599 { |
| 3568 for (unsigned i = 0; i < touchInfos.size(); ++i) { | 3600 for (unsigned i = 0; i < touchInfos.size(); ++i) { |
| 3569 TouchInfo& touchInfo = touchInfos[i]; | 3601 TouchInfo& touchInfo = touchInfos[i]; |
| 3570 const PlatformTouchPoint& point = touchInfo.point; | 3602 const PlatformTouchPoint& point = touchInfo.point; |
| 3571 const unsigned& pointerId = point.id(); | 3603 const unsigned& pointerId = point.id(); |
| 3572 const PlatformTouchPoint::State pointState = point.state(); | 3604 const PlatformTouchPoint::State pointState = point.state(); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3999 unsigned EventHandler::accessKeyModifiers() | 4031 unsigned EventHandler::accessKeyModifiers() |
| 4000 { | 4032 { |
| 4001 #if OS(MACOSX) | 4033 #if OS(MACOSX) |
| 4002 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4034 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 4003 #else | 4035 #else |
| 4004 return PlatformEvent::AltKey; | 4036 return PlatformEvent::AltKey; |
| 4005 #endif | 4037 #endif |
| 4006 } | 4038 } |
| 4007 | 4039 |
| 4008 } // namespace blink | 4040 } // namespace blink |
| OLD | NEW |