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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 882 | 882 |
| 883 // RenderView::hitTest causes a layout, and we don't want to hit that until the first | 883 // RenderView::hitTest causes a layout, and we don't want to hit that until the first |
| 884 // layout because until then, there is nothing shown on the screen - the use r can't | 884 // layout because until then, there is nothing shown on the screen - the use r can't |
| 885 // have intentionally clicked on something belonging to this page. Furthermo re, | 885 // have intentionally clicked on something belonging to this page. Furthermo re, |
| 886 // mousemove events before the first layout should not lead to a premature l ayout() | 886 // mousemove events before the first layout should not lead to a premature l ayout() |
| 887 // happening, which could show a flash of white. | 887 // happening, which could show a flash of white. |
| 888 // See also the similar code in Document::prepareMouseEvent. | 888 // See also the similar code in Document::prepareMouseEvent. |
| 889 if (!m_frame->contentRenderer() || !m_frame->view() || !m_frame->view()->did FirstLayout()) | 889 if (!m_frame->contentRenderer() || !m_frame->view() || !m_frame->view()->did FirstLayout()) |
| 890 return result; | 890 return result; |
| 891 | 891 |
| 892 if (padding.width() || padding.height()) | |
| 893 hitType |= HitTestRequest::ListBased; | |
|
Rick Byers
2015/02/04 10:34:03
Perhaps we should require callers to opt-in to lis
pdr.
2015/02/17 04:10:13
Added back! I took this out thinking it would be e
| |
| 894 | |
| 892 // hitTestResultAtPoint is specifically used to hitTest into all frames, thu s it always allows child frame content. | 895 // hitTestResultAtPoint is specifically used to hitTest into all frames, thu s it always allows child frame content. |
| 893 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent); | 896 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent); |
| 894 m_frame->contentRenderer()->hitTest(request, result); | 897 m_frame->contentRenderer()->hitTest(request, result); |
| 895 if (!request.readOnly()) | 898 if (!request.readOnly()) |
| 896 m_frame->document()->updateHoverActiveState(request, result.innerElement ()); | 899 m_frame->document()->updateHoverActiveState(request, result.innerElement ()); |
| 897 | 900 |
| 898 return result; | 901 return result; |
| 899 } | 902 } |
| 900 | 903 |
| 901 void EventHandler::stopAutoscroll() | 904 void EventHandler::stopAutoscroll() |
| (...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2593 // scrollbars being untouchable. | 2596 // scrollbars being untouchable. |
| 2594 if (result.scrollbar()) { | 2597 if (result.scrollbar()) { |
| 2595 targetNode = 0; | 2598 targetNode = 0; |
| 2596 return false; | 2599 return false; |
| 2597 } | 2600 } |
| 2598 | 2601 |
| 2599 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint InMainFrame()); | 2602 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint InMainFrame()); |
| 2600 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation ().boundingBox()); | 2603 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation ().boundingBox()); |
| 2601 | 2604 |
| 2602 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2605 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2603 copyToVector(result.rectBasedTestResult(), nodes); | 2606 copyToVector(result.listBasedTestResult(), nodes); |
| 2604 | 2607 |
| 2605 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. | 2608 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. |
| 2606 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc hRect, WillBeHeapVector<RefPtrWillBeMember<Node>> (nodes)); | 2609 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc hRect, WillBeHeapVector<RefPtrWillBeMember<Node>> (nodes)); |
| 2607 } | 2610 } |
| 2608 | 2611 |
| 2609 bool EventHandler::bestContextMenuNodeForHitTestResult(const HitTestResult& resu lt, IntPoint& targetPoint, Node*& targetNode) | 2612 bool EventHandler::bestContextMenuNodeForHitTestResult(const HitTestResult& resu lt, IntPoint& targetPoint, Node*& targetNode) |
| 2610 { | 2613 { |
| 2611 ASSERT(result.isRectBasedTest()); | 2614 ASSERT(result.isRectBasedTest()); |
| 2612 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint InMainFrame()); | 2615 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint InMainFrame()); |
| 2613 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation ().boundingBox()); | 2616 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation ().boundingBox()); |
| 2614 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2617 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2615 copyToVector(result.rectBasedTestResult(), nodes); | 2618 copyToVector(result.listBasedTestResult(), nodes); |
| 2616 | 2619 |
| 2617 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. | 2620 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. |
| 2618 return findBestContextMenuCandidate(targetNode, targetPoint, touchCenter, to uchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); | 2621 return findBestContextMenuCandidate(targetNode, targetPoint, touchCenter, to uchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); |
| 2619 } | 2622 } |
| 2620 | 2623 |
| 2621 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) | 2624 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) |
| 2622 { | 2625 { |
| 2623 IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); | 2626 IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); |
| 2624 HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::Re adOnly | HitTestRequest::Active, LayoutSize(touchRadius)); | 2627 HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::Re adOnly | HitTestRequest::Active, LayoutSize(touchRadius)); |
| 2625 | 2628 |
| 2626 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); | 2629 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); |
| 2627 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2630 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2628 copyToVector(result.rectBasedTestResult(), nodes); | 2631 copyToVector(result.listBasedTestResult(), nodes); |
| 2629 | 2632 |
| 2630 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. | 2633 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. |
| 2631 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); | 2634 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); |
| 2632 } | 2635 } |
| 2633 | 2636 |
| 2634 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) | 2637 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) |
| 2635 { | 2638 { |
| 2636 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); | 2639 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); |
| 2637 | 2640 |
| 2638 ASSERT(m_frame == m_frame->localFrameRoot()); | 2641 ASSERT(m_frame == m_frame->localFrameRoot()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2689 applyTouchAdjustment(&adjustedEvent, &hitTestResult); | 2692 applyTouchAdjustment(&adjustedEvent, &hitTestResult); |
| 2690 | 2693 |
| 2691 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa ry because | 2694 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa ry because |
| 2692 // rect-based hit testing and touch adjustment sometimes return a different node than | 2695 // rect-based hit testing and touch adjustment sometimes return a different node than |
| 2693 // what a point-based hit test would return for the same point. | 2696 // what a point-based hit test would return for the same point. |
| 2694 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h ttp://crbug.com/398914 | 2697 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h ttp://crbug.com/398914 |
| 2695 if (shouldApplyTouchAdjustment(gestureEvent)) { | 2698 if (shouldApplyTouchAdjustment(gestureEvent)) { |
| 2696 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); | 2699 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); |
| 2697 if (!hitFrame) | 2700 if (!hitFrame) |
| 2698 hitFrame = m_frame; | 2701 hitFrame = m_frame; |
| 2699 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT oContents(adjustedEvent.position()), hitType | HitTestRequest::ReadOnly); | 2702 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT oContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~Hit TestRequest::ListBased); |
| 2700 } | 2703 } |
| 2701 | 2704 |
| 2702 // If we did a rect-based hit test it must be resolved to the best single no de by now to | 2705 // If we did a rect-based hit test it must be resolved to the best single no de by now to |
| 2703 // ensure consumers don't accidentally use one of the other candidates. | 2706 // ensure consumers don't accidentally use one of the other candidates. |
| 2704 ASSERT(!hitTestResult.isRectBasedTest()); | 2707 ASSERT(!hitTestResult.isRectBasedTest()); |
| 2705 | 2708 |
| 2706 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); | 2709 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); |
| 2707 } | 2710 } |
| 2708 | 2711 |
| 2709 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo rmEvent::Type type) | 2712 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo rmEvent::Type type) |
| (...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3906 unsigned EventHandler::accessKeyModifiers() | 3909 unsigned EventHandler::accessKeyModifiers() |
| 3907 { | 3910 { |
| 3908 #if OS(MACOSX) | 3911 #if OS(MACOSX) |
| 3909 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3912 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 3910 #else | 3913 #else |
| 3911 return PlatformEvent::AltKey; | 3914 return PlatformEvent::AltKey; |
| 3912 #endif | 3915 #endif |
| 3913 } | 3916 } |
| 3914 | 3917 |
| 3915 } // namespace blink | 3918 } // namespace blink |
| OLD | NEW |