| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "core/events/DragEvent.h" | 43 #include "core/events/DragEvent.h" |
| 44 #include "core/events/EventPath.h" | 44 #include "core/events/EventPath.h" |
| 45 #include "core/events/GestureEvent.h" | 45 #include "core/events/GestureEvent.h" |
| 46 #include "core/events/KeyboardEvent.h" | 46 #include "core/events/KeyboardEvent.h" |
| 47 #include "core/events/MouseEvent.h" | 47 #include "core/events/MouseEvent.h" |
| 48 #include "core/events/PointerEvent.h" | 48 #include "core/events/PointerEvent.h" |
| 49 #include "core/events/TextEvent.h" | 49 #include "core/events/TextEvent.h" |
| 50 #include "core/events/TouchEvent.h" | 50 #include "core/events/TouchEvent.h" |
| 51 #include "core/events/WheelEvent.h" | 51 #include "core/events/WheelEvent.h" |
| 52 #include "core/fetch/ImageResource.h" | 52 #include "core/fetch/ImageResource.h" |
| 53 #include "core/frame/Deprecation.h" |
| 53 #include "core/frame/EventHandlerRegistry.h" | 54 #include "core/frame/EventHandlerRegistry.h" |
| 54 #include "core/frame/FrameHost.h" | 55 #include "core/frame/FrameHost.h" |
| 55 #include "core/frame/FrameView.h" | 56 #include "core/frame/FrameView.h" |
| 56 #include "core/frame/LocalFrame.h" | 57 #include "core/frame/LocalFrame.h" |
| 57 #include "core/frame/Settings.h" | 58 #include "core/frame/Settings.h" |
| 59 #include "core/frame/UseCounter.h" |
| 58 #include "core/frame/VisualViewport.h" | 60 #include "core/frame/VisualViewport.h" |
| 59 #include "core/html/HTMLDialogElement.h" | 61 #include "core/html/HTMLDialogElement.h" |
| 60 #include "core/html/HTMLFrameElementBase.h" | 62 #include "core/html/HTMLFrameElementBase.h" |
| 61 #include "core/html/HTMLFrameSetElement.h" | 63 #include "core/html/HTMLFrameSetElement.h" |
| 62 #include "core/html/HTMLInputElement.h" | 64 #include "core/html/HTMLInputElement.h" |
| 63 #include "core/input/InputDeviceCapabilities.h" | 65 #include "core/input/InputDeviceCapabilities.h" |
| 64 #include "core/input/TouchActionUtil.h" | 66 #include "core/input/TouchActionUtil.h" |
| 65 #include "core/layout/HitTestRequest.h" | 67 #include "core/layout/HitTestRequest.h" |
| 66 #include "core/layout/HitTestResult.h" | 68 #include "core/layout/HitTestResult.h" |
| 67 #include "core/layout/LayoutPart.h" | 69 #include "core/layout/LayoutPart.h" |
| (...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 return view ? view->rootFrameToContents(pointInRootFrame) : pointInRootFrame
; | 973 return view ? view->rootFrameToContents(pointInRootFrame) : pointInRootFrame
; |
| 972 } | 974 } |
| 973 | 975 |
| 974 WebInputEventResult EventHandler::handleMousePressEvent(const PlatformMouseEvent
& mouseEvent) | 976 WebInputEventResult EventHandler::handleMousePressEvent(const PlatformMouseEvent
& mouseEvent) |
| 975 { | 977 { |
| 976 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); | 978 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); |
| 977 | 979 |
| 978 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 980 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
| 979 | 981 |
| 980 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 982 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
| 981 m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken =
gestureIndicator.currentToken(); | 983 m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken =
UserGestureIndicator::currentToken(); |
| 982 | 984 |
| 983 cancelFakeMouseMoveEvent(); | 985 cancelFakeMouseMoveEvent(); |
| 984 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 986 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
| 985 m_capturingMouseEventsNode = nullptr; | 987 m_capturingMouseEventsNode = nullptr; |
| 986 m_mousePressed = true; | 988 m_mousePressed = true; |
| 987 m_capturesDragging = true; | 989 m_capturesDragging = true; |
| 988 setLastKnownMousePosition(mouseEvent); | 990 setLastKnownMousePosition(mouseEvent); |
| 989 m_mouseDownTimestamp = mouseEvent.timestamp(); | 991 m_mouseDownTimestamp = mouseEvent.timestamp(); |
| 990 m_mouseDownMayStartDrag = false; | 992 m_mouseDownMayStartDrag = false; |
| 991 selectionController().setMouseDownMayStartSelect(false); | 993 selectionController().setMouseDownMayStartSelect(false); |
| (...skipping 2734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3726 if (freshTouchEvents) { | 3728 if (freshTouchEvents) { |
| 3727 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should | 3729 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should |
| 3728 // have cleared the active document when we saw the last release. But we | 3730 // have cleared the active document when we saw the last release. But we |
| 3729 // have some tests that violate this, ClusterFuzz could trigger it, and | 3731 // have some tests that violate this, ClusterFuzz could trigger it, and |
| 3730 // there may be cases where the browser doesn't reliably release all | 3732 // there may be cases where the browser doesn't reliably release all |
| 3731 // touches. http://crbug.com/345372 tracks this. | 3733 // touches. http://crbug.com/345372 tracks this. |
| 3732 m_touchSequenceDocument.clear(); | 3734 m_touchSequenceDocument.clear(); |
| 3733 m_touchSequenceUserGestureToken.clear(); | 3735 m_touchSequenceUserGestureToken.clear(); |
| 3734 } | 3736 } |
| 3735 | 3737 |
| 3736 OwnPtr<UserGestureIndicator> gestureIndicator; | |
| 3737 | |
| 3738 if (m_touchSequenceUserGestureToken) | |
| 3739 gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequenceUser
GestureToken.release())); | |
| 3740 else | |
| 3741 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin
gUserGesture)); | |
| 3742 | |
| 3743 m_touchSequenceUserGestureToken = gestureIndicator->currentToken(); | |
| 3744 | |
| 3745 ASSERT(m_frame->view()); | 3738 ASSERT(m_frame->view()); |
| 3746 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc
hSequenceDocument->frame()->view())) { | 3739 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc
hSequenceDocument->frame()->view())) { |
| 3747 // If the active touch document has no frame or view, it's probably bein
g destroyed | 3740 // If the active touch document has no frame or view, it's probably bein
g destroyed |
| 3748 // so we can't dispatch events. | 3741 // so we can't dispatch events. |
| 3749 return WebInputEventResult::NotHandled; | 3742 return WebInputEventResult::NotHandled; |
| 3750 } | 3743 } |
| 3751 | 3744 |
| 3752 // First do hit tests for any new touch points. | 3745 // First do hit tests for any new touch points. |
| 3753 for (unsigned i = 0; i < points.size(); ++i) { | 3746 for (unsigned i = 0; i < points.size(); ++i) { |
| 3754 const PlatformTouchPoint& point = points[i]; | 3747 const PlatformTouchPoint& point = points[i]; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3805 // document set to receive the events, then we can skip all the rest of | 3798 // document set to receive the events, then we can skip all the rest of |
| 3806 // this work. | 3799 // this work. |
| 3807 if (!m_touchSequenceDocument || !m_touchSequenceDocument->frameHost() || !ha
sTouchHandlers(m_touchSequenceDocument->frameHost()->eventHandlerRegistry()) ||
!m_touchSequenceDocument->frame()) { | 3800 if (!m_touchSequenceDocument || !m_touchSequenceDocument->frameHost() || !ha
sTouchHandlers(m_touchSequenceDocument->frameHost()->eventHandlerRegistry()) ||
!m_touchSequenceDocument->frame()) { |
| 3808 if (allTouchReleased) { | 3801 if (allTouchReleased) { |
| 3809 m_touchSequenceDocument.clear(); | 3802 m_touchSequenceDocument.clear(); |
| 3810 m_touchSequenceUserGestureToken.clear(); | 3803 m_touchSequenceUserGestureToken.clear(); |
| 3811 } | 3804 } |
| 3812 return WebInputEventResult::NotHandled; | 3805 return WebInputEventResult::NotHandled; |
| 3813 } | 3806 } |
| 3814 | 3807 |
| 3808 // Whether a touch should be considered a "user gesture" or not is a tricky
question. |
| 3809 // XXX - link to doc, |
| 3810 // TODO(rbyers): Disable user gesture in some cases but retain logging for n
ow (crbug.com/582140). |
| 3811 OwnPtr<UserGestureIndicator> gestureIndicator; |
| 3812 if (event.touchPoints().size() == 1 |
| 3813 && event.touchPoints()[0].state() == PlatformTouchPoint::TouchReleased |
| 3814 && !event.causesScrollingIfUncanceled()) { |
| 3815 // This is a touchend corresponding to a tap, definitely a user gesture. |
| 3816 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin
gUserGesture)); |
| 3817 } else { |
| 3818 // This is some other touch event that perhaps shouldn't be considered a
user gesture. |
| 3819 if (m_touchSequenceUserGestureToken) |
| 3820 gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequence
UserGestureToken.release(), &m_touchSequenceDocument->frame()->eventHandler())); |
| 3821 else |
| 3822 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProce
ssingUserGesture, &m_touchSequenceDocument->frame()->eventHandler())); |
| 3823 m_touchSequenceUserGestureToken = UserGestureIndicator::currentToken(); |
| 3824 } |
| 3825 |
| 3826 |
| 3815 // Compute and store the common info used by both PointerEvent and TouchEven
t. | 3827 // Compute and store the common info used by both PointerEvent and TouchEven
t. |
| 3816 WillBeHeapVector<TouchInfo> touchInfos(points.size()); | 3828 WillBeHeapVector<TouchInfo> touchInfos(points.size()); |
| 3817 | 3829 |
| 3818 for (unsigned i = 0; i < points.size(); ++i) { | 3830 for (unsigned i = 0; i < points.size(); ++i) { |
| 3819 const PlatformTouchPoint& point = points[i]; | 3831 const PlatformTouchPoint& point = points[i]; |
| 3820 PlatformTouchPoint::TouchState pointState = point.state(); | 3832 PlatformTouchPoint::TouchState pointState = point.state(); |
| 3821 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; | 3833 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; |
| 3822 | 3834 |
| 3823 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla
tformTouchPoint::TouchCancelled) { | 3835 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla
tformTouchPoint::TouchCancelled) { |
| 3824 // The target should be the original target for this touch, so get | 3836 // The target should be the original target for this touch, so get |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3898 m_inPointerCanceledState = true; | 3910 m_inPointerCanceledState = true; |
| 3899 sendPointerCancels(touchInfos); | 3911 sendPointerCancels(touchInfos); |
| 3900 } | 3912 } |
| 3901 } else if (allTouchReleased) { | 3913 } else if (allTouchReleased) { |
| 3902 m_inPointerCanceledState = false; | 3914 m_inPointerCanceledState = false; |
| 3903 } | 3915 } |
| 3904 | 3916 |
| 3905 return eventResult; | 3917 return eventResult; |
| 3906 } | 3918 } |
| 3907 | 3919 |
| 3920 void EventHandler::userGestureUsed() |
| 3921 { |
| 3922 // This is invoked UserGestureIndicators created in handleTouchEvent which p
erhaps represent |
| 3923 // touch actions which shouldn't be considered a user-gesture. |
| 3924 UseCounter::count(m_frame, UseCounter::TouchDragUserGestureUsed); |
| 3925 Deprecation::countDeprecationCrossOriginIframe(m_frame, UseCounter::TouchDra
gUserGestureUsedCrossOrigin); |
| 3926 } |
| 3927 |
| 3908 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) | 3928 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) |
| 3909 { | 3929 { |
| 3910 m_mousePositionIsUnknown = false; | 3930 m_mousePositionIsUnknown = false; |
| 3911 m_lastKnownMousePosition = event.position(); | 3931 m_lastKnownMousePosition = event.position(); |
| 3912 m_lastKnownMouseGlobalPosition = event.globalPosition(); | 3932 m_lastKnownMouseGlobalPosition = event.globalPosition(); |
| 3913 } | 3933 } |
| 3914 | 3934 |
| 3915 WebInputEventResult EventHandler::passMousePressEventToSubframe(MouseEventWithHi
tTestResults& mev, LocalFrame* subframe) | 3935 WebInputEventResult EventHandler::passMousePressEventToSubframe(MouseEventWithHi
tTestResults& mev, LocalFrame* subframe) |
| 3916 { | 3936 { |
| 3917 selectionController().passMousePressEventToSubframe(mev); | 3937 selectionController().passMousePressEventToSubframe(mev); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3955 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 3975 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
| 3956 { | 3976 { |
| 3957 #if OS(MACOSX) | 3977 #if OS(MACOSX) |
| 3958 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); | 3978 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); |
| 3959 #else | 3979 #else |
| 3960 return PlatformEvent::AltKey; | 3980 return PlatformEvent::AltKey; |
| 3961 #endif | 3981 #endif |
| 3962 } | 3982 } |
| 3963 | 3983 |
| 3964 } // namespace blink | 3984 } // namespace blink |
| OLD | NEW |