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

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

Issue 470833002: Add WebKit API for doing a hit-test that mimics GestureTap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rewrite based on Rick's comments Created 6 years, 1 month 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
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 2565 matching lines...) Expand 10 before | Expand all | Expand 10 after
2576 } else if (gestureEvent.type() == PlatformEvent::GestureTap) { 2576 } else if (gestureEvent.type() == PlatformEvent::GestureTap) {
2577 // If the Tap is received very shortly after ShowPress, we want to 2577 // If the Tap is received very shortly after ShowPress, we want to
2578 // delay clearing of the active state so that it's visible to the user 2578 // delay clearing of the active state so that it's visible to the user
2579 // for at least a couple of frames. 2579 // for at least a couple of frames.
2580 activeInterval = WTF::currentTime() - m_lastShowPressTimestamp; 2580 activeInterval = WTF::currentTime() - m_lastShowPressTimestamp;
2581 shouldKeepActiveForMinInterval = m_lastShowPressTimestamp && activeInter val < minimumActiveInterval; 2581 shouldKeepActiveForMinInterval = m_lastShowPressTimestamp && activeInter val < minimumActiveInterval;
2582 if (shouldKeepActiveForMinInterval) 2582 if (shouldKeepActiveForMinInterval)
2583 hitType |= HitTestRequest::ReadOnly; 2583 hitType |= HitTestRequest::ReadOnly;
2584 } 2584 }
2585 2585
2586 GestureEventWithHitTestResults eventWithHitTestResults = hitTestResultForGes tureEvent(gestureEvent, hitType);
2587 // Now apply hover/active state to the final target.
2588 // FIXME: This is supposed to send mouseenter/mouseleave events, but doesn't because we
2589 // aren't passing a PlatformMouseEvent.
2590 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent);
2591 if (!request.readOnly())
2592 m_frame->document()->updateHoverActiveState(request, eventWithHitTestRes ults.hitTestResult().innerElement());
2593
2594 if (shouldKeepActiveForMinInterval) {
2595 m_lastDeferredTapElement = eventWithHitTestResults.hitTestResult().inner Element();
2596 m_activeIntervalTimer.startOneShot(minimumActiveInterval - activeInterva l, FROM_HERE);
2597 }
2598
2599 return eventWithHitTestResults;
2600 }
2601
2602 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const PlatformGestureEvent& gestureEvent, HitTestRequest::HitTestRequestType hitType)
2603 {
2586 // Perform the rect-based hit-test (or point-based if adjustment is disabled ). Note that 2604 // Perform the rect-based hit-test (or point-based if adjustment is disabled ). Note that
2587 // we don't yet apply hover/active state here because we need to resolve tou ch adjustment 2605 // we don't yet apply hover/active state here because we need to resolve tou ch adjustment
2588 // first so that we apply hover/active it to the final adjusted node. 2606 // first so that we apply hover/active it to the final adjusted node.
2589 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.posit ion()); 2607 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.posit ion());
2590 LayoutSize padding; 2608 LayoutSize padding;
2591 if (shouldApplyTouchAdjustment(gestureEvent)) { 2609 if (shouldApplyTouchAdjustment(gestureEvent)) {
2592 padding = gestureEvent.area(); 2610 padding = gestureEvent.area();
2593 padding.scale(1.f / 2); 2611 padding.scale(1.f / 2);
2594 } 2612 }
2595 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H itTestRequest::ReadOnly, padding); 2613 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H itTestRequest::ReadOnly, padding);
(...skipping 11 matching lines...) Expand all
2607 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); 2625 LocalFrame* hitFrame = hitTestResult.innerNodeFrame();
2608 if (!hitFrame) 2626 if (!hitFrame)
2609 hitFrame = m_frame; 2627 hitFrame = m_frame;
2610 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT oContents(adjustedEvent.position()), hitType | HitTestRequest::ReadOnly); 2628 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT oContents(adjustedEvent.position()), hitType | HitTestRequest::ReadOnly);
2611 } 2629 }
2612 2630
2613 // If we did a rect-based hit test it must be resolved to the best single no de by now to 2631 // If we did a rect-based hit test it must be resolved to the best single no de by now to
2614 // ensure consumers don't accidentally use one of the other candidates. 2632 // ensure consumers don't accidentally use one of the other candidates.
2615 ASSERT(!hitTestResult.isRectBasedTest()); 2633 ASSERT(!hitTestResult.isRectBasedTest());
2616 2634
2617 // Now apply hover/active state to the final target.
2618 // FIXME: This is supposed to send mouseenter/mouseleave events, but doesn't because we
2619 // aren't passing a PlatformMouseEvent.
2620 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent);
2621 if (!request.readOnly())
2622 m_frame->document()->updateHoverActiveState(request, hitTestResult.inner Element());
2623
2624 if (shouldKeepActiveForMinInterval) {
2625 m_lastDeferredTapElement = hitTestResult.innerElement();
2626 m_activeIntervalTimer.startOneShot(minimumActiveInterval - activeInterva l, FROM_HERE);
2627 }
2628
2629 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); 2635 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult);
2630 } 2636 }
2631 2637
2632 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo rmEvent::Type type) 2638 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo rmEvent::Type type)
2633 { 2639 {
2634 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent; 2640 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent;
2635 switch (type) { 2641 switch (type) {
2636 case PlatformEvent::GestureShowPress: 2642 case PlatformEvent::GestureShowPress:
2637 case PlatformEvent::GestureTapUnconfirmed: 2643 case PlatformEvent::GestureTapUnconfirmed:
2638 return hitType | HitTestRequest::Active; 2644 return hitType | HitTestRequest::Active;
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
3879 unsigned EventHandler::accessKeyModifiers() 3885 unsigned EventHandler::accessKeyModifiers()
3880 { 3886 {
3881 #if OS(MACOSX) 3887 #if OS(MACOSX)
3882 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3888 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3883 #else 3889 #else
3884 return PlatformEvent::AltKey; 3890 return PlatformEvent::AltKey;
3885 #endif 3891 #endif
3886 } 3892 }
3887 3893
3888 } // namespace blink 3894 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698