Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | #ifndef EventHandler_h |
| 27 | #define EventHandler_h |
| 28 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 29 | #include "core/editing/TextGranularity.h" |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 30 | #include "core/events/TextEventInputType.h" |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 31 | #include "core/page/DragActions.h" |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 32 | #include "core/page/FocusType.h" |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 33 | #include "core/rendering/HitTestRequest.h" |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 34 | #include "core/rendering/style/RenderStyleConstants.h" |
| 35 | #include "platform/Cursor.h" |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 36 | #include "platform/PlatformMouseEvent.h" |
| 37 | #include "platform/Timer.h" |
| 38 | #include "platform/UserGestureIndicator.h" |
| 39 | #include "platform/geometry/LayoutPoint.h" |
Bo Liu | f91f5fa | 2014-05-01 10:37:55 -0700 | [diff] [blame] | 40 | #include "platform/heap/Handle.h" |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 41 | #include "platform/scroll/ScrollTypes.h" |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 42 | #include "wtf/Forward.h" |
| 43 | #include "wtf/HashMap.h" |
Torne (Richard Coles) | 3234804 | 2014-05-14 12:12:57 +0100 | [diff] [blame] | 44 | #include "wtf/HashTraits.h" |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 45 | #include "wtf/RefPtr.h" |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 46 | |
| 47 | namespace WebCore { |
| 48 | |
Torne (Richard Coles) | 19cde67 | 2013-11-06 12:28:04 +0000 | [diff] [blame] | 49 | class AutoscrollController; |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 50 | class DataTransfer; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 51 | class Document; |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 52 | class DragState; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 53 | class Element; |
| 54 | class Event; |
| 55 | class EventTarget; |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 56 | template <typename EventType> |
| 57 | class EventWithHitTestResults; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 58 | class FloatPoint; |
| 59 | class FloatQuad; |
Torne (Richard Coles) | f5e4ad5 | 2013-08-05 13:57:57 +0100 | [diff] [blame] | 60 | class FullscreenElementStack; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 61 | class HTMLFrameSetElement; |
| 62 | class HitTestRequest; |
| 63 | class HitTestResult; |
| 64 | class KeyboardEvent; |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 65 | class LocalFrame; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 66 | class Node; |
| 67 | class OptionalCursor; |
| 68 | class PlatformGestureEvent; |
| 69 | class PlatformKeyboardEvent; |
| 70 | class PlatformTouchEvent; |
| 71 | class PlatformWheelEvent; |
| 72 | class RenderLayer; |
Torne (Richard Coles) | f79f16f | 2013-10-31 11:16:44 +0000 | [diff] [blame] | 73 | class RenderLayerScrollableArea; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 74 | class RenderObject; |
| 75 | class RenderWidget; |
Torne (Richard Coles) | e1f1df5 | 2013-08-23 16:39:30 +0100 | [diff] [blame] | 76 | class ScrollableArea; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 77 | class Scrollbar; |
| 78 | class TextEvent; |
| 79 | class TouchEvent; |
| 80 | class VisibleSelection; |
| 81 | class WheelEvent; |
| 82 | class Widget; |
| 83 | |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 84 | typedef EventWithHitTestResults<PlatformGestureEvent> GestureEventWithHitTestResults; |
| 85 | typedef EventWithHitTestResults<PlatformMouseEvent> MouseEventWithHitTestResults; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 86 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 87 | enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace }; |
| 88 | enum CheckDragHysteresis { ShouldCheckDragHysteresis, DontCheckDragHysteresis }; |
| 89 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 90 | class EventHandler : public NoBaseWillBeGarbageCollectedFinalized<EventHandler> { |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 91 | WTF_MAKE_NONCOPYABLE(EventHandler); |
| 92 | public: |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 93 | explicit EventHandler(LocalFrame*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 94 | ~EventHandler(); |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 95 | void trace(Visitor*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 96 | |
| 97 | void clear(); |
Torne (Richard Coles) | 19cde67 | 2013-11-06 12:28:04 +0000 | [diff] [blame] | 98 | void nodeWillBeRemoved(Node&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 99 | |
| 100 | void updateSelectionForMouseDrag(); |
| 101 | |
| 102 | Node* mousePressNode() const; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 103 | |
Torne (Richard Coles) | 8abfc58 | 2013-09-12 12:10:38 +0100 | [diff] [blame] | 104 | #if OS(WIN) |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 105 | void startPanScrolling(RenderObject*); |
| 106 | #endif |
| 107 | |
Torne (Richard Coles) | 19cde67 | 2013-11-06 12:28:04 +0000 | [diff] [blame] | 108 | void stopAutoscroll(); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 109 | |
| 110 | void dispatchFakeMouseMoveEventSoon(); |
| 111 | void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&); |
| 112 | |
| 113 | HitTestResult hitTestResultAtPoint(const LayoutPoint&, |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 114 | HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active, |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 115 | const LayoutSize& padding = LayoutSize()); |
| 116 | |
| 117 | bool mousePressed() const { return m_mousePressed; } |
| 118 | void setMousePressed(bool pressed) { m_mousePressed = pressed; } |
| 119 | |
Torne (Richard Coles) | d6cdb82 | 2014-06-03 10:59:05 +0100 | [diff] [blame] | 120 | void setCapturingMouseEventsNode(PassRefPtrWillBeRawPtr<Node>); // A caller is responsible for resetting capturing node to 0. |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 121 | |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 122 | bool updateDragAndDrop(const PlatformMouseEvent&, DataTransfer*); |
| 123 | void cancelDragAndDrop(const PlatformMouseEvent&, DataTransfer*); |
| 124 | bool performDragAndDrop(const PlatformMouseEvent&, DataTransfer*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 125 | void updateDragStateAfterEditDragIfNeeded(Element* rootEditableElement); |
| 126 | |
| 127 | void scheduleHoverStateUpdate(); |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 128 | void scheduleCursorUpdate(); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 129 | |
| 130 | void setResizingFrameSet(HTMLFrameSetElement*); |
| 131 | |
Torne (Richard Coles) | f79f16f | 2013-10-31 11:16:44 +0000 | [diff] [blame] | 132 | void resizeScrollableAreaDestroyed(); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 133 | |
| 134 | IntPoint lastKnownMousePosition() const; |
| 135 | Cursor currentMouseCursor() const { return m_currentMouseCursor; } |
| 136 | |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 137 | // Attempts to scroll the DOM tree. If that fails, scrolls the view. |
| 138 | // If the view can't be scrolled either, recursively bubble to the parent frame. |
| 139 | bool bubblingScroll(ScrollDirection, ScrollGranularity, Node* startingNode = 0); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 140 | |
Torne (Richard Coles) | c0e19a6 | 2013-08-30 15:15:11 +0100 | [diff] [blame] | 141 | bool handleMouseMoveEvent(const PlatformMouseEvent&); |
| 142 | void handleMouseLeaveEvent(const PlatformMouseEvent&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 143 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 144 | bool handleMousePressEvent(const PlatformMouseEvent&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 145 | bool handleMouseReleaseEvent(const PlatformMouseEvent&); |
| 146 | bool handleWheelEvent(const PlatformWheelEvent&); |
| 147 | void defaultWheelEventHandler(Node*, WheelEvent*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 148 | |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 149 | // Called on the local root frame exactly once per gesture event. |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 150 | bool handleGestureEvent(const PlatformGestureEvent&); |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 151 | |
| 152 | // Hit-test the provided (non-scroll) gesture event, applying touch-adjustment and updating |
| 153 | // hover/active state across all frames if necessary. This should be called at most once |
| 154 | // per gesture event, and called on the local root frame. |
| 155 | // Note: This is similar to (the less clearly named) prepareMouseEvent. |
| 156 | // FIXME: Remove readOnly param when there is only ever a single call to this. |
| 157 | GestureEventWithHitTestResults targetGestureEvent(const PlatformGestureEvent&, bool readOnly = false); |
| 158 | |
| 159 | // Handle the provided non-scroll gesture event. Should be called only on the inner frame. |
| 160 | bool handleGestureEventInFrame(const GestureEventWithHitTestResults&); |
| 161 | |
| 162 | // Handle the provided scroll gesture event, propagating down to child frames as necessary. |
| 163 | bool handleGestureScrollEvent(const PlatformGestureEvent&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 164 | bool handleGestureScrollEnd(const PlatformGestureEvent&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 165 | bool isScrollbarHandlingGestures() const; |
| 166 | |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 167 | bool bestClickableNodeForHitTestResult(const HitTestResult&, IntPoint& targetPoint, Node*& targetNode); |
| 168 | bool bestContextMenuNodeForHitTestResult(const HitTestResult&, IntPoint& targetPoint, Node*& targetNode); |
| 169 | // FIXME: This doesn't appear to be used outside tests anymore, what path are we using now and is it tested? |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 170 | bool bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntRect& targetArea, Node*& targetNode); |
| 171 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 172 | bool sendContextMenuEvent(const PlatformMouseEvent&); |
| 173 | bool sendContextMenuEventForKey(); |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 174 | bool sendContextMenuEventForGesture(const GestureEventWithHitTestResults&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 175 | |
| 176 | void setMouseDownMayStartAutoscroll() { m_mouseDownMayStartAutoscroll = true; } |
| 177 | |
| 178 | static unsigned accessKeyModifiers(); |
| 179 | bool handleAccessKey(const PlatformKeyboardEvent&); |
| 180 | bool keyEvent(const PlatformKeyboardEvent&); |
| 181 | void defaultKeyboardEventHandler(KeyboardEvent*); |
| 182 | |
| 183 | bool handleTextInputEvent(const String& text, Event* underlyingEvent = 0, TextEventInputType = TextEventInputKeyboard); |
| 184 | void defaultTextInputEventHandler(TextEvent*); |
| 185 | |
| 186 | void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation); |
| 187 | |
| 188 | void focusDocumentView(); |
| 189 | |
| 190 | void capsLockStateMayHaveChanged(); // Only called by FrameSelection |
| 191 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 192 | bool handleTouchEvent(const PlatformTouchEvent&); |
| 193 | |
Ben Murdoch | 6f543c7 | 2014-04-16 11:17:22 +0100 | [diff] [blame] | 194 | bool useHandCursor(Node*, bool isOverLink); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 195 | |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 196 | void notifyElementActivated(); |
| 197 | |
Ben Murdoch | 10f88d5 | 2014-04-24 10:50:33 +0100 | [diff] [blame] | 198 | PassRefPtr<UserGestureToken> takeLastMouseDownGestureToken() { return m_lastMouseDownUserGestureToken.release(); } |
| 199 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 200 | private: |
| 201 | static DragState& dragState(); |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 202 | |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 203 | PassRefPtrWillBeRawPtr<DataTransfer> createDraggingDataTransfer() const; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 204 | |
| 205 | bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleSelection&, TextGranularity); |
| 206 | void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace); |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame] | 207 | void selectClosestMisspellingFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 208 | void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&); |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame] | 209 | void selectClosestMisspellingFromMouseEvent(const MouseEventWithHitTestResults&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 210 | void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults&); |
| 211 | |
Torne (Richard Coles) | c0e19a6 | 2013-08-30 15:15:11 +0100 | [diff] [blame] | 212 | bool handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, HitTestResult* hoveredNode = 0, bool onlyUpdateScrollbars = false); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 213 | bool handleMousePressEvent(const MouseEventWithHitTestResults&); |
| 214 | bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&); |
| 215 | bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&); |
| 216 | bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&); |
Ben Murdoch | 6f543c7 | 2014-04-16 11:17:22 +0100 | [diff] [blame] | 217 | bool handleMouseFocus(const PlatformMouseEvent&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 218 | bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&); |
| 219 | bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&); |
| 220 | |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 221 | bool handlePasteGlobalSelection(const PlatformMouseEvent&); |
| 222 | |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 223 | HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::Type); |
| 224 | void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); |
| 225 | bool handleGestureTap(const GestureEventWithHitTestResults&); |
| 226 | bool handleGestureLongPress(const GestureEventWithHitTestResults&); |
| 227 | bool handleGestureLongTap(const GestureEventWithHitTestResults&); |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 228 | bool handleGestureScrollUpdate(const PlatformGestureEvent&); |
| 229 | bool handleGestureScrollBegin(const PlatformGestureEvent&); |
| 230 | void clearGestureScrollNodes(); |
| 231 | |
| 232 | bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; |
| 233 | |
Ben Murdoch | 6f543c7 | 2014-04-16 11:17:22 +0100 | [diff] [blame] | 234 | OptionalCursor selectCursor(const HitTestResult&); |
| 235 | OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& iBeam); |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 236 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 237 | void hoverTimerFired(Timer<EventHandler>*); |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 238 | void cursorUpdateTimerFired(Timer<EventHandler>*); |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 239 | void activeIntervalTimerFired(Timer<EventHandler>*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 240 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 241 | bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; } |
| 242 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 243 | void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); |
| 244 | void cancelFakeMouseMoveEvent(); |
| 245 | bool isCursorVisible() const; |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 246 | void updateCursor(); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 247 | |
| 248 | bool isInsideScrollbar(const IntPoint&) const; |
| 249 | |
Torne (Richard Coles) | e1f1df5 | 2013-08-23 16:39:30 +0100 | [diff] [blame] | 250 | ScrollableArea* associatedScrollableArea(const RenderLayer*) const; |
| 251 | |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 252 | // Scrolls the elements of the DOM tree. Returns true if a node was scrolled. |
| 253 | // False if we reached the root and couldn't scroll anything. |
| 254 | // direction - The direction to scroll in. If this is a logicl direction, it will be |
| 255 | // converted to the physical direction based on a node's writing mode. |
| 256 | // granularity - The units that the scroll delta parameter is in. |
| 257 | // startNode - The node to start bubbling the scroll from. If a node can't scroll, |
| 258 | // the scroll bubbles up to the containing block. |
| 259 | // stopNode - On input, if provided and non-null, the node at which we should stop bubbling on input. |
| 260 | // On output, if provided and a node was scrolled stopNode will point to that node. |
| 261 | // delta - The delta to scroll by, in the units of the granularity parameter. (e.g. pixels, lines, pages, etc.) |
| 262 | // absolutePoint - For wheel scrolls - the location, in absolute coordinates, where the event occured. |
| 263 | bool scroll(ScrollDirection, ScrollGranularity, Node* startNode = 0, Node** stopNode = 0, float delta = 1.0f, IntPoint absolutePoint = IntPoint()); |
| 264 | |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 265 | TouchAction intersectTouchAction(const TouchAction, const TouchAction); |
Torne (Richard Coles) | 5d92fed | 2014-06-20 14:52:37 +0100 | [diff] [blame] | 266 | TouchAction computeEffectiveTouchAction(const Node&); |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 267 | |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 268 | HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 269 | |
| 270 | void invalidateClick(); |
| 271 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 272 | void updateMouseEventTargetNode(Node*, const PlatformMouseEvent&, bool fireMouseOverOut); |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 273 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 274 | MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&); |
| 275 | |
Ben Murdoch | a9984bf | 2014-04-10 11:22:39 +0100 | [diff] [blame] | 276 | bool dispatchMouseEvent(const AtomicString& eventType, Node* target, int clickCount, const PlatformMouseEvent&, bool setUnder); |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 277 | bool dispatchDragEvent(const AtomicString& eventType, Node* target, const PlatformMouseEvent&, DataTransfer*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 278 | |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 279 | void clearDragDataTransfer(); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 280 | |
| 281 | bool handleDrag(const MouseEventWithHitTestResults&, CheckDragHysteresis); |
Ben Murdoch | e69819b | 2013-07-17 14:56:49 +0100 | [diff] [blame] | 282 | bool tryStartDrag(const MouseEventWithHitTestResults&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 283 | void clearDragState(); |
| 284 | |
| 285 | bool dispatchDragSrcEvent(const AtomicString& eventType, const PlatformMouseEvent&); |
| 286 | |
| 287 | bool dragHysteresisExceeded(const FloatPoint&) const; |
| 288 | bool dragHysteresisExceeded(const IntPoint&) const; |
| 289 | |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 290 | bool passMousePressEventToSubframe(MouseEventWithHitTestResults&, LocalFrame* subframe); |
| 291 | bool passMouseMoveEventToSubframe(MouseEventWithHitTestResults&, LocalFrame* subframe, HitTestResult* hoveredNode = 0); |
| 292 | bool passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&, LocalFrame* subframe); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 293 | |
Torne (Richard Coles) | 5d92fed | 2014-06-20 14:52:37 +0100 | [diff] [blame] | 294 | bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 295 | |
| 296 | bool passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&); |
| 297 | |
| 298 | bool passWheelEventToWidget(const PlatformWheelEvent&, Widget*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 299 | void defaultSpaceEventHandler(KeyboardEvent*); |
| 300 | void defaultBackspaceEventHandler(KeyboardEvent*); |
| 301 | void defaultTabEventHandler(KeyboardEvent*); |
Torne (Richard Coles) | c0e19a6 | 2013-08-30 15:15:11 +0100 | [diff] [blame] | 302 | void defaultEscapeEventHandler(KeyboardEvent*); |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 303 | void defaultArrowEventHandler(FocusType, KeyboardEvent*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 304 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 305 | void updateSelectionForMouseDrag(const HitTestResult&); |
| 306 | |
| 307 | void updateLastScrollbarUnderMouse(Scrollbar*, bool); |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 308 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 309 | void setFrameWasScrolledByUser(); |
| 310 | |
| 311 | bool capturesDragging() const { return m_capturesDragging; } |
| 312 | |
Torne (Richard Coles) | f5e4ad5 | 2013-08-05 13:57:57 +0100 | [diff] [blame] | 313 | bool isKeyEventAllowedInFullScreen(FullscreenElementStack*, const PlatformKeyboardEvent&) const; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 314 | |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 315 | bool handleGestureShowPress(); |
Torne (Richard Coles) | 81a5157 | 2013-05-13 16:52:28 +0100 | [diff] [blame] | 316 | |
| 317 | bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&); |
| 318 | |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 319 | bool passScrollGestureEventToWidget(const PlatformGestureEvent&, RenderObject*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 320 | bool sendScrollEventToView(const PlatformGestureEvent&, const FloatSize&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 321 | |
Torne (Richard Coles) | 19cde67 | 2013-11-06 12:28:04 +0000 | [diff] [blame] | 322 | AutoscrollController* autoscrollController() const; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame] | 323 | bool panScrollInProgress() const; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 324 | void setLastKnownMousePosition(const PlatformMouseEvent&); |
| 325 | |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 326 | LocalFrame* const m_frame; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 327 | |
| 328 | bool m_mousePressed; |
| 329 | bool m_capturesDragging; |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 330 | RefPtrWillBeMember<Node> m_mousePressNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 331 | |
| 332 | bool m_mouseDownMayStartSelect; |
| 333 | bool m_mouseDownMayStartDrag; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 334 | bool m_mouseDownWasSingleClickInSelection; |
| 335 | enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection }; |
| 336 | SelectionInitiationState m_selectionInitiationState; |
| 337 | |
| 338 | LayoutPoint m_dragStartPos; |
| 339 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 340 | Timer<EventHandler> m_hoverTimer; |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 341 | Timer<EventHandler> m_cursorUpdateTimer; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 342 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 343 | bool m_mouseDownMayStartAutoscroll; |
| 344 | bool m_mouseDownWasInSubframe; |
| 345 | |
| 346 | Timer<EventHandler> m_fakeMouseMoveEventTimer; |
| 347 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 348 | bool m_svgPan; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 349 | |
Torne (Richard Coles) | f79f16f | 2013-10-31 11:16:44 +0000 | [diff] [blame] | 350 | RenderLayerScrollableArea* m_resizeScrollableArea; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 351 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 352 | RefPtrWillBeMember<Node> m_capturingMouseEventsNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 353 | bool m_eventHandlerWillResetCapturingMouseEventsNode; |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 354 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 355 | RefPtrWillBeMember<Node> m_nodeUnderMouse; |
| 356 | RefPtrWillBeMember<Node> m_lastNodeUnderMouse; |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 357 | RefPtr<LocalFrame> m_lastMouseMoveEventSubframe; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 358 | RefPtr<Scrollbar> m_lastScrollbarUnderMouse; |
| 359 | Cursor m_currentMouseCursor; |
| 360 | |
| 361 | int m_clickCount; |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 362 | RefPtrWillBeMember<Node> m_clickNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 363 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 364 | RefPtrWillBeMember<Node> m_dragTarget; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 365 | bool m_shouldOnlyFireDragOverEvent; |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 366 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 367 | RefPtrWillBeMember<HTMLFrameSetElement> m_frameSetBeingResized; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 368 | |
Torne (Richard Coles) | f79f16f | 2013-10-31 11:16:44 +0000 | [diff] [blame] | 369 | LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableArea. |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 370 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 371 | bool m_mousePositionIsUnknown; |
| 372 | IntPoint m_lastKnownMousePosition; |
| 373 | IntPoint m_lastKnownMouseGlobalPosition; |
| 374 | IntPoint m_mouseDownPos; // In our view's coords. |
| 375 | double m_mouseDownTimestamp; |
| 376 | PlatformMouseEvent m_mouseDown; |
| 377 | RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; |
| 378 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 379 | RefPtrWillBeMember<Node> m_latchedWheelEventNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 380 | bool m_widgetIsLatched; |
| 381 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 382 | RefPtrWillBeMember<Node> m_previousWheelScrolledNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 383 | |
Torne (Richard Coles) | 3234804 | 2014-05-14 12:12:57 +0100 | [diff] [blame] | 384 | // The target of each active touch point indexed by the touch ID. |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 385 | typedef WillBeHeapHashMap<unsigned, RefPtrWillBeMember<EventTarget>, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned> > TouchTargetMap; |
Torne (Richard Coles) | 3234804 | 2014-05-14 12:12:57 +0100 | [diff] [blame] | 386 | TouchTargetMap m_targetForTouchID; |
| 387 | |
| 388 | // If set, the document of the active touch sequence. Unset if no touch sequence active. |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 389 | RefPtrWillBeMember<Document> m_touchSequenceDocument; |
Torne (Richard Coles) | 5d92fed | 2014-06-20 14:52:37 +0100 | [diff] [blame] | 390 | RefPtr<UserGestureToken> m_touchSequenceUserGestureToken; |
Torne (Richard Coles) | 3234804 | 2014-05-14 12:12:57 +0100 | [diff] [blame] | 391 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 392 | bool m_touchPressed; |
| 393 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 394 | RefPtrWillBeMember<Node> m_scrollGestureHandlingNode; |
Ben Murdoch | 197021e | 2014-07-20 18:26:29 -0700 | [diff] [blame^] | 395 | bool m_lastGestureScrollOverWidget; |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 396 | RefPtrWillBeMember<Node> m_previousGestureScrolledNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 397 | RefPtr<Scrollbar> m_scrollbarHandlingScrollGesture; |
| 398 | |
| 399 | double m_maxMouseMovedDuration; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 400 | bool m_didStartDrag; |
| 401 | |
| 402 | bool m_longTapShouldInvokeContextMenu; |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 403 | |
| 404 | Timer<EventHandler> m_activeIntervalTimer; |
| 405 | double m_lastShowPressTimestamp; |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 406 | RefPtrWillBeMember<Element> m_lastDeferredTapElement; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 407 | }; |
| 408 | |
| 409 | } // namespace WebCore |
| 410 | |
| 411 | #endif // EventHandler_h |