| 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 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2600 // scrollbars being untouchable. | 2602 // scrollbars being untouchable. |
| 2601 if (result.scrollbar()) { | 2603 if (result.scrollbar()) { |
| 2602 targetNode = 0; | 2604 targetNode = 0; |
| 2603 return false; | 2605 return false; |
| 2604 } | 2606 } |
| 2605 | 2607 |
| 2606 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint
InMainFrame()); | 2608 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint
InMainFrame()); |
| 2607 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation
().boundingBox()); | 2609 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation
().boundingBox()); |
| 2608 | 2610 |
| 2609 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2611 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2610 copyToVector(result.rectBasedTestResult(), nodes); | 2612 copyToVector(result.listBasedTestResult(), nodes); |
| 2611 | 2613 |
| 2612 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. | 2614 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. |
| 2613 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc
hRect, WillBeHeapVector<RefPtrWillBeMember<Node>> (nodes)); | 2615 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc
hRect, WillBeHeapVector<RefPtrWillBeMember<Node>> (nodes)); |
| 2614 } | 2616 } |
| 2615 | 2617 |
| 2616 bool EventHandler::bestContextMenuNodeForHitTestResult(const HitTestResult& resu
lt, IntPoint& targetPoint, Node*& targetNode) | 2618 bool EventHandler::bestContextMenuNodeForHitTestResult(const HitTestResult& resu
lt, IntPoint& targetPoint, Node*& targetNode) |
| 2617 { | 2619 { |
| 2618 ASSERT(result.isRectBasedTest()); | 2620 ASSERT(result.isRectBasedTest()); |
| 2619 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint
InMainFrame()); | 2621 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint
InMainFrame()); |
| 2620 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation
().boundingBox()); | 2622 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation
().boundingBox()); |
| 2621 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2623 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2622 copyToVector(result.rectBasedTestResult(), nodes); | 2624 copyToVector(result.listBasedTestResult(), nodes); |
| 2623 | 2625 |
| 2624 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. | 2626 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. |
| 2625 return findBestContextMenuCandidate(targetNode, targetPoint, touchCenter, to
uchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); | 2627 return findBestContextMenuCandidate(targetNode, targetPoint, touchCenter, to
uchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); |
| 2626 } | 2628 } |
| 2627 | 2629 |
| 2628 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co
nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) | 2630 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co
nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) |
| 2629 { | 2631 { |
| 2632 if (touchRadius.isEmpty()) |
| 2633 return false; |
| 2634 |
| 2630 IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); | 2635 IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); |
| 2631 HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::Re
adOnly | HitTestRequest::Active, LayoutSize(touchRadius)); | 2636 |
| 2637 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | HitTestRequest::ListBased; |
| 2638 HitTestResult result = hitTestResultAtPoint(hitTestPoint, hitType, LayoutSiz
e(touchRadius)); |
| 2632 | 2639 |
| 2633 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); | 2640 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); |
| 2634 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2641 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2635 copyToVector(result.rectBasedTestResult(), nodes); | 2642 copyToVector(result.listBasedTestResult(), nodes); |
| 2636 | 2643 |
| 2637 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. | 2644 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. |
| 2638 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect,
WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); | 2645 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect,
WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); |
| 2639 } | 2646 } |
| 2640 | 2647 |
| 2641 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe
stureEvent& gestureEvent, bool readOnly) | 2648 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe
stureEvent& gestureEvent, bool readOnly) |
| 2642 { | 2649 { |
| 2643 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); | 2650 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); |
| 2644 | 2651 |
| 2645 ASSERT(m_frame == m_frame->localFrameRoot()); | 2652 ASSERT(m_frame == m_frame->localFrameRoot()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2679 | 2686 |
| 2680 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const
PlatformGestureEvent& gestureEvent, HitTestRequest::HitTestRequestType hitType) | 2687 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const
PlatformGestureEvent& gestureEvent, HitTestRequest::HitTestRequestType hitType) |
| 2681 { | 2688 { |
| 2682 // Perform the rect-based hit-test (or point-based if adjustment is disabled
). Note that | 2689 // Perform the rect-based hit-test (or point-based if adjustment is disabled
). Note that |
| 2683 // we don't yet apply hover/active state here because we need to resolve tou
ch adjustment | 2690 // we don't yet apply hover/active state here because we need to resolve tou
ch adjustment |
| 2684 // first so that we apply hover/active it to the final adjusted node. | 2691 // first so that we apply hover/active it to the final adjusted node. |
| 2685 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.posit
ion()); | 2692 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.posit
ion()); |
| 2686 LayoutSize padding; | 2693 LayoutSize padding; |
| 2687 if (shouldApplyTouchAdjustment(gestureEvent)) { | 2694 if (shouldApplyTouchAdjustment(gestureEvent)) { |
| 2688 padding = LayoutSize(gestureEvent.area()); | 2695 padding = LayoutSize(gestureEvent.area()); |
| 2689 padding.scale(1.f / 2); | 2696 if (!padding.isEmpty()) { |
| 2697 padding.scale(1.f / 2); |
| 2698 hitType |= HitTestRequest::ListBased; |
| 2699 } |
| 2690 } | 2700 } |
| 2691 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H
itTestRequest::ReadOnly, padding); | 2701 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H
itTestRequest::ReadOnly, padding); |
| 2692 | 2702 |
| 2693 // Adjust the location of the gesture to the most likely nearby node, as app
ropriate for the | 2703 // Adjust the location of the gesture to the most likely nearby node, as app
ropriate for the |
| 2694 // type of event. | 2704 // type of event. |
| 2695 PlatformGestureEvent adjustedEvent = gestureEvent; | 2705 PlatformGestureEvent adjustedEvent = gestureEvent; |
| 2696 applyTouchAdjustment(&adjustedEvent, &hitTestResult); | 2706 applyTouchAdjustment(&adjustedEvent, &hitTestResult); |
| 2697 | 2707 |
| 2698 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa
ry because | 2708 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa
ry because |
| 2699 // rect-based hit testing and touch adjustment sometimes return a different
node than | 2709 // rect-based hit testing and touch adjustment sometimes return a different
node than |
| 2700 // what a point-based hit test would return for the same point. | 2710 // what a point-based hit test would return for the same point. |
| 2701 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h
ttp://crbug.com/398914 | 2711 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h
ttp://crbug.com/398914 |
| 2702 if (shouldApplyTouchAdjustment(gestureEvent)) { | 2712 if (shouldApplyTouchAdjustment(gestureEvent)) { |
| 2703 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); | 2713 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); |
| 2704 if (!hitFrame) | 2714 if (!hitFrame) |
| 2705 hitFrame = m_frame; | 2715 hitFrame = m_frame; |
| 2706 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT
oContents(adjustedEvent.position()), hitType | HitTestRequest::ReadOnly); | 2716 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT
oContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~Hit
TestRequest::ListBased); |
| 2707 } | 2717 } |
| 2708 | 2718 |
| 2709 // If we did a rect-based hit test it must be resolved to the best single no
de by now to | 2719 // If we did a rect-based hit test it must be resolved to the best single no
de by now to |
| 2710 // ensure consumers don't accidentally use one of the other candidates. | 2720 // ensure consumers don't accidentally use one of the other candidates. |
| 2711 ASSERT(!hitTestResult.isRectBasedTest()); | 2721 ASSERT(!hitTestResult.isRectBasedTest()); |
| 2712 | 2722 |
| 2713 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); | 2723 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); |
| 2714 } | 2724 } |
| 2715 | 2725 |
| 2716 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo
rmEvent::Type type) | 2726 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo
rmEvent::Type type) |
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3927 | 3937 |
| 3928 // If it's in the direction to hide the top controls, only consume when the
frame can also scroll. | 3938 // If it's in the direction to hide the top controls, only consume when the
frame can also scroll. |
| 3929 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo
sition().y()) | 3939 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo
sition().y()) |
| 3930 return true; | 3940 return true; |
| 3931 | 3941 |
| 3932 return false; | 3942 return false; |
| 3933 } | 3943 } |
| 3934 | 3944 |
| 3935 | 3945 |
| 3936 } // namespace blink | 3946 } // namespace blink |
| OLD | NEW |