Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: Source/core/input/EventHandler.cpp

Issue 1192463008: Pass real pointer type to be passed to PointerEvents. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: TODO Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/events/pointerevents/touch-pointer-event-properties.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)
3493 {
3494 // TODO(e_hakkinen): Simplify this by changing PointerIdManager to use
3495 // WebPointerProperties::PointerType instead of defining its own enum.
3496 switch (type) {
3497 case WebPointerProperties::PointerTypeUnknown:
3498 return PointerIdManager::PointerTypeUnknown;
3499 case WebPointerProperties::PointerTypeTouch:
3500 return PointerIdManager::PointerTypeTouch;
3501 case WebPointerProperties::PointerTypePen:
3502 return PointerIdManager::PointerTypePen;
3503 case WebPointerProperties::PointerTypeMouse:
3504 return PointerIdManager::PointerTypeMouse;
3505 }
3506 ASSERT_NOT_REACHED();
3507 return PointerIdManager::PointerTypeUnknown;
3508 }
3509
3510 static const char* pointerTypeNameForWebPointPointerType(WebPointerProperties::P ointerType type)
3511 {
3512 switch (type) {
3513 case WebPointerProperties::PointerTypeUnknown:
3514 return "";
3515 case WebPointerProperties::PointerTypeTouch:
3516 return "touch";
3517 case WebPointerProperties::PointerTypePen:
3518 return "pen";
3519 case WebPointerProperties::PointerTypeMouse:
3520 return "mouse";
3521 }
3522 ASSERT_NOT_REACHED();
3523 return "";
3524 }
3525
3492 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout Point& point, HitTestRequest::HitTestRequestType hitType) 3526 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout Point& point, HitTestRequest::HitTestRequestType hitType)
3493 { 3527 {
3494 HitTestResult result(HitTestRequest(hitType), point); 3528 HitTestResult result(HitTestRequest(hitType), point);
3495 3529
3496 if (!frame || !frame->contentLayoutObject()) 3530 if (!frame || !frame->contentLayoutObject())
3497 return result; 3531 return result;
3498 if (frame->view()) { 3532 if (frame->view()) {
3499 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars); 3533 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars);
3500 if (!rect.contains(roundedIntPoint(point))) 3534 if (!rect.contains(roundedIntPoint(point)))
3501 return result; 3535 return result;
3502 } 3536 }
3503 frame->contentLayoutObject()->hitTest(result); 3537 frame->contentLayoutObject()->hitTest(result);
3504 return result; 3538 return result;
3505 } 3539 }
3506 3540
3507 void EventHandler::dispatchPointerEventsForTouchEvent(const PlatformTouchEvent& event, 3541 void EventHandler::dispatchPointerEventsForTouchEvent(const PlatformTouchEvent& event,
3508 WillBeHeapVector<TouchInfo>& touchInfos) 3542 WillBeHeapVector<TouchInfo>& touchInfos)
3509 { 3543 {
3510 const String& PointerTypeStrForTouch("touch");
3511
3512 // Iterate through the touch points, sending PointerEvents to the targets as required. 3544 // Iterate through the touch points, sending PointerEvents to the targets as required.
3513 for (unsigned i = 0; i < touchInfos.size(); ++i) { 3545 for (unsigned i = 0; i < touchInfos.size(); ++i) {
3514 TouchInfo& touchInfo = touchInfos[i]; 3546 TouchInfo& touchInfo = touchInfos[i];
3515 const PlatformTouchPoint& point = touchInfo.point; 3547 const PlatformTouchPoint& point = touchInfo.point;
3516 const unsigned& pointerId = point.id(); 3548 const unsigned& pointerId = point.id();
3517 const PlatformTouchPoint::State pointState = point.state(); 3549 const PlatformTouchPoint::State pointState = point.state();
3518 3550
3519 if (pointState == PlatformTouchPoint::TouchStationary || !touchInfo.know nTarget) 3551 if (pointState == PlatformTouchPoint::TouchStationary || !touchInfo.know nTarget)
3520 continue; 3552 continue;
3521 3553
3522 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::Touc hReleased 3554 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::Touc hReleased
3523 || pointState == PlatformTouchPoint::TouchCancelled; 3555 || pointState == PlatformTouchPoint::TouchCancelled;
3556 const PointerIdManager::PointerType pointerType = pointerTypeForWebPoint PointerType(point.pointerProperties().pointerType);
3557 const String& pointerTypeStr = pointerTypeNameForWebPointPointerType(poi nt.pointerProperties().pointerType);
3524 3558
3525 if (pointState == PlatformTouchPoint::TouchPressed) 3559 if (pointState == PlatformTouchPoint::TouchPressed)
3526 m_pointerIdManager.add(PointerIdManager::PointerTypeTouch, pointerId ); 3560 m_pointerIdManager.add(pointerType, pointerId);
3527 3561
3528 const AtomicString& eventName = pointerEventNameForTouchPointState(point State); 3562 const AtomicString& eventName = pointerEventNameForTouchPointState(point State);
3529 3563
3530 bool isEnterOrLeave = false; 3564 bool isEnterOrLeave = false;
3531 3565
3532 PointerEventInit pointerEventInit; 3566 PointerEventInit pointerEventInit;
3533 pointerEventInit.setPointerId(pointerId); 3567 pointerEventInit.setPointerId(pointerId);
3534 pointerEventInit.setWidth(touchInfo.adjustedRadius.width()); 3568 pointerEventInit.setWidth(touchInfo.adjustedRadius.width());
3535 pointerEventInit.setHeight(touchInfo.adjustedRadius.height()); 3569 pointerEventInit.setHeight(touchInfo.adjustedRadius.height());
3536 pointerEventInit.setPressure(point.force()); 3570 pointerEventInit.setPressure(point.force());
3537 pointerEventInit.setTiltX(point.pointerProperties().tiltX); 3571 pointerEventInit.setTiltX(point.pointerProperties().tiltX);
3538 pointerEventInit.setTiltY(point.pointerProperties().tiltY); 3572 pointerEventInit.setTiltY(point.pointerProperties().tiltY);
3539 pointerEventInit.setPointerType(PointerTypeStrForTouch); 3573 pointerEventInit.setPointerType(pointerTypeStr);
3540 pointerEventInit.setIsPrimary(m_pointerIdManager.isPrimary(PointerIdMana ger::PointerTypeTouch, pointerId)); 3574 pointerEventInit.setIsPrimary(m_pointerIdManager.isPrimary(pointerType, pointerId));
3541 pointerEventInit.setScreenX(point.screenPos().x()); 3575 pointerEventInit.setScreenX(point.screenPos().x());
3542 pointerEventInit.setScreenY(point.screenPos().y()); 3576 pointerEventInit.setScreenY(point.screenPos().y());
3543 pointerEventInit.setClientX(touchInfo.adjustedPagePoint.x()); 3577 pointerEventInit.setClientX(touchInfo.adjustedPagePoint.x());
3544 pointerEventInit.setClientY(touchInfo.adjustedPagePoint.y()); 3578 pointerEventInit.setClientY(touchInfo.adjustedPagePoint.y());
3545 pointerEventInit.setButton(0); 3579 pointerEventInit.setButton(0);
3546 pointerEventInit.setButtons(pointerReleasedOrCancelled ? 0 : 1); 3580 pointerEventInit.setButtons(pointerReleasedOrCancelled ? 0 : 1);
3547 3581
3548 pointerEventInit.setCtrlKey(event.ctrlKey()); 3582 pointerEventInit.setCtrlKey(event.ctrlKey());
3549 pointerEventInit.setShiftKey(event.shiftKey()); 3583 pointerEventInit.setShiftKey(event.shiftKey());
3550 pointerEventInit.setAltKey(event.altKey()); 3584 pointerEventInit.setAltKey(event.altKey());
3551 pointerEventInit.setMetaKey(event.metaKey()); 3585 pointerEventInit.setMetaKey(event.metaKey());
3552 3586
3553 pointerEventInit.setBubbles(!isEnterOrLeave); 3587 pointerEventInit.setBubbles(!isEnterOrLeave);
3554 pointerEventInit.setCancelable(!isEnterOrLeave && pointState != Platform TouchPoint::TouchCancelled); 3588 pointerEventInit.setCancelable(!isEnterOrLeave && pointState != Platform TouchPoint::TouchCancelled);
3555 3589
3556 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(eve ntName, pointerEventInit); 3590 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(eve ntName, pointerEventInit);
3557 touchInfo.touchTarget->dispatchEvent(pointerEvent.get()); 3591 touchInfo.touchTarget->dispatchEvent(pointerEvent.get());
3558 touchInfo.consumed = pointerEvent->defaultPrevented() || pointerEvent->d efaultHandled(); 3592 touchInfo.consumed = pointerEvent->defaultPrevented() || pointerEvent->d efaultHandled();
3559 3593
3560 // Remove the released/cancelled id at the end to correctly determine pr imary id above. 3594 // Remove the released/cancelled id at the end to correctly determine pr imary id above.
3561 if (pointerReleasedOrCancelled) 3595 if (pointerReleasedOrCancelled)
3562 m_pointerIdManager.remove(PointerIdManager::PointerTypeTouch, pointe rId); 3596 m_pointerIdManager.remove(pointerType, pointerId);
3563 } 3597 }
3564 } 3598 }
3565 3599
3566 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos) 3600 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos)
3567 { 3601 {
3568 for (unsigned i = 0; i < touchInfos.size(); ++i) { 3602 for (unsigned i = 0; i < touchInfos.size(); ++i) {
3569 TouchInfo& touchInfo = touchInfos[i]; 3603 TouchInfo& touchInfo = touchInfos[i];
3570 const PlatformTouchPoint& point = touchInfo.point; 3604 const PlatformTouchPoint& point = touchInfo.point;
3571 const unsigned& pointerId = point.id(); 3605 const unsigned& pointerId = point.id();
3572 const PlatformTouchPoint::State pointState = point.state(); 3606 const PlatformTouchPoint::State pointState = point.state();
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
3999 unsigned EventHandler::accessKeyModifiers() 4033 unsigned EventHandler::accessKeyModifiers()
4000 { 4034 {
4001 #if OS(MACOSX) 4035 #if OS(MACOSX)
4002 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 4036 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
4003 #else 4037 #else
4004 return PlatformEvent::AltKey; 4038 return PlatformEvent::AltKey;
4005 #endif 4039 #endif
4006 } 4040 }
4007 4041
4008 } // namespace blink 4042 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/events/pointerevents/touch-pointer-event-properties.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698