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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 | 857 |
858 bool EventHandler::panScrollInProgress() const | 858 bool EventHandler::panScrollInProgress() const |
859 { | 859 { |
860 return autoscrollController() && autoscrollController()->panScrollInProgress (); | 860 return autoscrollController() && autoscrollController()->panScrollInProgress (); |
861 } | 861 } |
862 | 862 |
863 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding) | 863 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding) |
864 { | 864 { |
865 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); | 865 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); |
866 | 866 |
867 ASSERT((hitType & HitTestRequest::ListBased) || padding.isEmpty()); | |
868 | |
867 // We always send hitTestResultAtPoint to the main frame if we have one, | 869 // We always send hitTestResultAtPoint to the main frame if we have one, |
868 // otherwise we might hit areas that are obscured by higher frames. | 870 // otherwise we might hit areas that are obscured by higher frames. |
869 if (m_frame->page()) { | 871 if (m_frame->page()) { |
870 LocalFrame* mainFrame = m_frame->localFrameRoot(); | 872 LocalFrame* mainFrame = m_frame->localFrameRoot(); |
871 if (mainFrame && m_frame != mainFrame) { | 873 if (mainFrame && m_frame != mainFrame) { |
872 FrameView* frameView = m_frame->view(); | 874 FrameView* frameView = m_frame->view(); |
873 FrameView* mainView = mainFrame->view(); | 875 FrameView* mainView = mainFrame->view(); |
874 if (frameView && mainView) { | 876 if (frameView && mainView) { |
875 IntPoint mainFramePoint = mainView->rootViewToContents(frameView ->contentsToRootView(roundedIntPoint(point))); | 877 IntPoint mainFramePoint = mainView->rootViewToContents(frameView ->contentsToRootView(roundedIntPoint(point))); |
876 return mainFrame->eventHandler().hitTestResultAtPoint(mainFrameP oint, hitType, padding); | 878 return mainFrame->eventHandler().hitTestResultAtPoint(mainFrameP oint, hitType, padding); |
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2584 // scrollbars being untouchable. | 2586 // scrollbars being untouchable. |
2585 if (result.scrollbar()) { | 2587 if (result.scrollbar()) { |
2586 targetNode = 0; | 2588 targetNode = 0; |
2587 return false; | 2589 return false; |
2588 } | 2590 } |
2589 | 2591 |
2590 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint InMainFrame()); | 2592 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint InMainFrame()); |
2591 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation ().boundingBox()); | 2593 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation ().boundingBox()); |
2592 | 2594 |
2593 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2595 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
2594 copyToVector(result.rectBasedTestResult(), nodes); | 2596 copyToVector(result.listBasedTestResult(), nodes); |
2595 | 2597 |
2596 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. | 2598 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. |
2597 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc hRect, WillBeHeapVector<RefPtrWillBeMember<Node>> (nodes)); | 2599 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc hRect, WillBeHeapVector<RefPtrWillBeMember<Node>> (nodes)); |
2598 } | 2600 } |
2599 | 2601 |
2600 bool EventHandler::bestContextMenuNodeForHitTestResult(const HitTestResult& resu lt, IntPoint& targetPoint, Node*& targetNode) | 2602 bool EventHandler::bestContextMenuNodeForHitTestResult(const HitTestResult& resu lt, IntPoint& targetPoint, Node*& targetNode) |
2601 { | 2603 { |
2602 ASSERT(result.isRectBasedTest()); | 2604 ASSERT(result.isRectBasedTest()); |
2603 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint InMainFrame()); | 2605 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint InMainFrame()); |
2604 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation ().boundingBox()); | 2606 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation ().boundingBox()); |
2605 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2607 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
2606 copyToVector(result.rectBasedTestResult(), nodes); | 2608 copyToVector(result.listBasedTestResult(), nodes); |
2607 | 2609 |
2608 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. | 2610 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. |
2609 return findBestContextMenuCandidate(targetNode, targetPoint, touchCenter, to uchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); | 2611 return findBestContextMenuCandidate(targetNode, targetPoint, touchCenter, to uchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); |
2610 } | 2612 } |
2611 | 2613 |
2612 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) | 2614 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) |
2613 { | 2615 { |
2614 IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); | 2616 IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); |
2615 HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::Re adOnly | HitTestRequest::Active, LayoutSize(touchRadius)); | 2617 |
2618 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT estRequest::Active; | |
2619 if (!touchRadius.isEmpty()) | |
2620 hitType |= HitTestRequest::ListBased; | |
Rick Byers
2015/02/20 20:02:24
This function it intended to be used only with a n
pdr.
2015/02/22 23:28:13
Done
| |
2621 | |
2622 HitTestResult result = hitTestResultAtPoint(hitTestPoint, hitType, LayoutSiz e(touchRadius)); | |
2616 | 2623 |
2617 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); | 2624 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); |
2618 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2625 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
2619 copyToVector(result.rectBasedTestResult(), nodes); | 2626 copyToVector(result.listBasedTestResult(), nodes); |
2620 | 2627 |
2621 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. | 2628 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. |
2622 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); | 2629 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); |
2623 } | 2630 } |
2624 | 2631 |
2625 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) | 2632 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) |
2626 { | 2633 { |
2627 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); | 2634 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); |
2628 | 2635 |
2629 ASSERT(m_frame == m_frame->localFrameRoot()); | 2636 ASSERT(m_frame == m_frame->localFrameRoot()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2663 | 2670 |
2664 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const PlatformGestureEvent& gestureEvent, HitTestRequest::HitTestRequestType hitType) | 2671 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const PlatformGestureEvent& gestureEvent, HitTestRequest::HitTestRequestType hitType) |
2665 { | 2672 { |
2666 // Perform the rect-based hit-test (or point-based if adjustment is disabled ). Note that | 2673 // Perform the rect-based hit-test (or point-based if adjustment is disabled ). Note that |
2667 // we don't yet apply hover/active state here because we need to resolve tou ch adjustment | 2674 // we don't yet apply hover/active state here because we need to resolve tou ch adjustment |
2668 // first so that we apply hover/active it to the final adjusted node. | 2675 // first so that we apply hover/active it to the final adjusted node. |
2669 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.posit ion()); | 2676 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.posit ion()); |
2670 LayoutSize padding; | 2677 LayoutSize padding; |
2671 if (shouldApplyTouchAdjustment(gestureEvent)) { | 2678 if (shouldApplyTouchAdjustment(gestureEvent)) { |
2672 padding = LayoutSize(gestureEvent.area()); | 2679 padding = LayoutSize(gestureEvent.area()); |
2673 padding.scale(1.f / 2); | 2680 if (!padding.isEmpty()) { |
2681 padding.scale(1.f / 2); | |
2682 hitType |= HitTestRequest::ListBased; | |
2683 } | |
2674 } | 2684 } |
2675 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H itTestRequest::ReadOnly, padding); | 2685 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H itTestRequest::ReadOnly, padding); |
2676 | 2686 |
2677 // Adjust the location of the gesture to the most likely nearby node, as app ropriate for the | 2687 // Adjust the location of the gesture to the most likely nearby node, as app ropriate for the |
2678 // type of event. | 2688 // type of event. |
2679 PlatformGestureEvent adjustedEvent = gestureEvent; | 2689 PlatformGestureEvent adjustedEvent = gestureEvent; |
2680 applyTouchAdjustment(&adjustedEvent, &hitTestResult); | 2690 applyTouchAdjustment(&adjustedEvent, &hitTestResult); |
2681 | 2691 |
2682 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa ry because | 2692 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa ry because |
2683 // rect-based hit testing and touch adjustment sometimes return a different node than | 2693 // rect-based hit testing and touch adjustment sometimes return a different node than |
2684 // what a point-based hit test would return for the same point. | 2694 // what a point-based hit test would return for the same point. |
2685 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h ttp://crbug.com/398914 | 2695 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h ttp://crbug.com/398914 |
2686 if (shouldApplyTouchAdjustment(gestureEvent)) { | 2696 if (shouldApplyTouchAdjustment(gestureEvent)) { |
2687 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); | 2697 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); |
2688 if (!hitFrame) | 2698 if (!hitFrame) |
2689 hitFrame = m_frame; | 2699 hitFrame = m_frame; |
2690 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT oContents(adjustedEvent.position()), hitType | HitTestRequest::ReadOnly); | 2700 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT oContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~Hit TestRequest::ListBased); |
2691 } | 2701 } |
2692 | 2702 |
2693 // If we did a rect-based hit test it must be resolved to the best single no de by now to | 2703 // If we did a rect-based hit test it must be resolved to the best single no de by now to |
2694 // ensure consumers don't accidentally use one of the other candidates. | 2704 // ensure consumers don't accidentally use one of the other candidates. |
2695 ASSERT(!hitTestResult.isRectBasedTest()); | 2705 ASSERT(!hitTestResult.isRectBasedTest()); |
2696 | 2706 |
2697 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); | 2707 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); |
2698 } | 2708 } |
2699 | 2709 |
2700 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo rmEvent::Type type) | 2710 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo rmEvent::Type type) |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3897 unsigned EventHandler::accessKeyModifiers() | 3907 unsigned EventHandler::accessKeyModifiers() |
3898 { | 3908 { |
3899 #if OS(MACOSX) | 3909 #if OS(MACOSX) |
3900 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3910 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3901 #else | 3911 #else |
3902 return PlatformEvent::AltKey; | 3912 return PlatformEvent::AltKey; |
3903 #endif | 3913 #endif |
3904 } | 3914 } |
3905 | 3915 |
3906 } // namespace blink | 3916 } // namespace blink |
OLD | NEW |