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; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 50 | class Clipboard; |
| 51 | class Document; |
| 52 | class Element; |
| 53 | class Event; |
| 54 | class EventTarget; |
| 55 | class FloatPoint; |
| 56 | class FloatQuad; |
Torne (Richard Coles) | f5e4ad5 | 2013-08-05 13:57:57 +0100 | [diff] [blame] | 57 | class FullscreenElementStack; |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 58 | class LocalFrame; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 59 | class HTMLFrameSetElement; |
| 60 | class HitTestRequest; |
| 61 | class HitTestResult; |
| 62 | class KeyboardEvent; |
| 63 | class MouseEventWithHitTestResults; |
| 64 | class Node; |
| 65 | class OptionalCursor; |
| 66 | class PlatformGestureEvent; |
| 67 | class PlatformKeyboardEvent; |
| 68 | class PlatformTouchEvent; |
| 69 | class PlatformWheelEvent; |
| 70 | class RenderLayer; |
Torne (Richard Coles) | f79f16f | 2013-10-31 11:16:44 +0000 | [diff] [blame] | 71 | class RenderLayerScrollableArea; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 72 | class RenderObject; |
| 73 | class RenderWidget; |
Torne (Richard Coles) | e1f1df5 | 2013-08-23 16:39:30 +0100 | [diff] [blame] | 74 | class ScrollableArea; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 75 | class Scrollbar; |
| 76 | class TextEvent; |
| 77 | class TouchEvent; |
| 78 | class VisibleSelection; |
| 79 | class WheelEvent; |
| 80 | class Widget; |
| 81 | |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 82 | class DragState; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 83 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 84 | enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace }; |
| 85 | enum CheckDragHysteresis { ShouldCheckDragHysteresis, DontCheckDragHysteresis }; |
| 86 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 87 | class EventHandler : public NoBaseWillBeGarbageCollectedFinalized<EventHandler> { |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 88 | WTF_MAKE_NONCOPYABLE(EventHandler); |
| 89 | public: |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 90 | explicit EventHandler(LocalFrame*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 91 | ~EventHandler(); |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 92 | void trace(Visitor*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 93 | |
| 94 | void clear(); |
Torne (Richard Coles) | 19cde67 | 2013-11-06 12:28:04 +0000 | [diff] [blame] | 95 | void nodeWillBeRemoved(Node&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 96 | |
| 97 | void updateSelectionForMouseDrag(); |
| 98 | |
| 99 | Node* mousePressNode() const; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 100 | |
Torne (Richard Coles) | 8abfc58 | 2013-09-12 12:10:38 +0100 | [diff] [blame] | 101 | #if OS(WIN) |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 102 | void startPanScrolling(RenderObject*); |
| 103 | #endif |
| 104 | |
Torne (Richard Coles) | 19cde67 | 2013-11-06 12:28:04 +0000 | [diff] [blame] | 105 | void stopAutoscroll(); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 106 | |
| 107 | void dispatchFakeMouseMoveEventSoon(); |
| 108 | void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&); |
| 109 | |
| 110 | HitTestResult hitTestResultAtPoint(const LayoutPoint&, |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 111 | HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active, |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 112 | const LayoutSize& padding = LayoutSize()); |
| 113 | |
| 114 | bool mousePressed() const { return m_mousePressed; } |
| 115 | void setMousePressed(bool pressed) { m_mousePressed = pressed; } |
| 116 | |
Torne (Richard Coles) | d6cdb82 | 2014-06-03 10:59:05 +0100 | [diff] [blame] | 117 | 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] | 118 | |
| 119 | bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*); |
| 120 | void cancelDragAndDrop(const PlatformMouseEvent&, Clipboard*); |
| 121 | bool performDragAndDrop(const PlatformMouseEvent&, Clipboard*); |
| 122 | void updateDragStateAfterEditDragIfNeeded(Element* rootEditableElement); |
| 123 | |
| 124 | void scheduleHoverStateUpdate(); |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 125 | void scheduleCursorUpdate(); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 126 | |
| 127 | void setResizingFrameSet(HTMLFrameSetElement*); |
| 128 | |
Torne (Richard Coles) | f79f16f | 2013-10-31 11:16:44 +0000 | [diff] [blame] | 129 | void resizeScrollableAreaDestroyed(); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 130 | |
| 131 | IntPoint lastKnownMousePosition() const; |
| 132 | Cursor currentMouseCursor() const { return m_currentMouseCursor; } |
| 133 | |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 134 | // Attempts to scroll the DOM tree. If that fails, scrolls the view. |
| 135 | // If the view can't be scrolled either, recursively bubble to the parent frame. |
| 136 | bool bubblingScroll(ScrollDirection, ScrollGranularity, Node* startingNode = 0); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 137 | |
Torne (Richard Coles) | c0e19a6 | 2013-08-30 15:15:11 +0100 | [diff] [blame] | 138 | bool handleMouseMoveEvent(const PlatformMouseEvent&); |
| 139 | void handleMouseLeaveEvent(const PlatformMouseEvent&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 140 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 141 | bool handleMousePressEvent(const PlatformMouseEvent&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 142 | bool handleMouseReleaseEvent(const PlatformMouseEvent&); |
| 143 | bool handleWheelEvent(const PlatformWheelEvent&); |
| 144 | void defaultWheelEventHandler(Node*, WheelEvent*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 145 | |
| 146 | bool handleGestureEvent(const PlatformGestureEvent&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 147 | bool handleGestureScrollEnd(const PlatformGestureEvent&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 148 | bool isScrollbarHandlingGestures() const; |
| 149 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 150 | bool bestClickableNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode); |
| 151 | bool bestContextMenuNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode); |
| 152 | bool bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntRect& targetArea, Node*& targetNode); |
| 153 | |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 154 | void adjustGesturePosition(const PlatformGestureEvent&, IntPoint& adjustedPoint); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 155 | |
| 156 | bool sendContextMenuEvent(const PlatformMouseEvent&); |
| 157 | bool sendContextMenuEventForKey(); |
| 158 | bool sendContextMenuEventForGesture(const PlatformGestureEvent&); |
| 159 | |
| 160 | void setMouseDownMayStartAutoscroll() { m_mouseDownMayStartAutoscroll = true; } |
| 161 | |
| 162 | static unsigned accessKeyModifiers(); |
| 163 | bool handleAccessKey(const PlatformKeyboardEvent&); |
| 164 | bool keyEvent(const PlatformKeyboardEvent&); |
| 165 | void defaultKeyboardEventHandler(KeyboardEvent*); |
| 166 | |
| 167 | bool handleTextInputEvent(const String& text, Event* underlyingEvent = 0, TextEventInputType = TextEventInputKeyboard); |
| 168 | void defaultTextInputEventHandler(TextEvent*); |
| 169 | |
| 170 | void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation); |
| 171 | |
| 172 | void focusDocumentView(); |
| 173 | |
| 174 | void capsLockStateMayHaveChanged(); // Only called by FrameSelection |
| 175 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 176 | bool handleTouchEvent(const PlatformTouchEvent&); |
| 177 | |
Ben Murdoch | 6f543c7 | 2014-04-16 11:17:22 +0100 | [diff] [blame] | 178 | bool useHandCursor(Node*, bool isOverLink); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 179 | |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 180 | void notifyElementActivated(); |
| 181 | |
Ben Murdoch | 10f88d5 | 2014-04-24 10:50:33 +0100 | [diff] [blame] | 182 | PassRefPtr<UserGestureToken> takeLastMouseDownGestureToken() { return m_lastMouseDownUserGestureToken.release(); } |
| 183 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 184 | private: |
| 185 | static DragState& dragState(); |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 186 | |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 187 | PassRefPtrWillBeRawPtr<Clipboard> createDraggingClipboard() const; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 188 | |
| 189 | bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleSelection&, TextGranularity); |
| 190 | void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace); |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame] | 191 | void selectClosestMisspellingFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 192 | void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&); |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame] | 193 | void selectClosestMisspellingFromMouseEvent(const MouseEventWithHitTestResults&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 194 | void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults&); |
| 195 | |
Torne (Richard Coles) | c0e19a6 | 2013-08-30 15:15:11 +0100 | [diff] [blame] | 196 | bool handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, HitTestResult* hoveredNode = 0, bool onlyUpdateScrollbars = false); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 197 | bool handleMousePressEvent(const MouseEventWithHitTestResults&); |
| 198 | bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&); |
| 199 | bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&); |
| 200 | bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&); |
Ben Murdoch | 6f543c7 | 2014-04-16 11:17:22 +0100 | [diff] [blame] | 201 | bool handleMouseFocus(const PlatformMouseEvent&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 202 | bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&); |
| 203 | bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&); |
| 204 | |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 205 | bool handlePasteGlobalSelection(const PlatformMouseEvent&); |
| 206 | |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 207 | bool handleGestureTap(const PlatformGestureEvent&, const IntPoint& adjustedPoint); |
Torne (Richard Coles) | 51b2906 | 2013-11-28 11:56:03 +0000 | [diff] [blame] | 208 | bool handleGestureLongPress(const PlatformGestureEvent&, const IntPoint& adjustedPoint); |
| 209 | bool handleGestureLongTap(const PlatformGestureEvent&, const IntPoint& adjustedPoint); |
| 210 | bool handleGestureTwoFingerTap(const PlatformGestureEvent&, const IntPoint& adjustedPoint); |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 211 | bool handleGestureScrollUpdate(const PlatformGestureEvent&); |
| 212 | bool handleGestureScrollBegin(const PlatformGestureEvent&); |
| 213 | void clearGestureScrollNodes(); |
| 214 | |
| 215 | bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; |
| 216 | |
Ben Murdoch | 6f543c7 | 2014-04-16 11:17:22 +0100 | [diff] [blame] | 217 | OptionalCursor selectCursor(const HitTestResult&); |
| 218 | OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& iBeam); |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 219 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 220 | void hoverTimerFired(Timer<EventHandler>*); |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 221 | void cursorUpdateTimerFired(Timer<EventHandler>*); |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 222 | void activeIntervalTimerFired(Timer<EventHandler>*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 223 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 224 | bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; } |
| 225 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 226 | void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); |
| 227 | void cancelFakeMouseMoveEvent(); |
| 228 | bool isCursorVisible() const; |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 229 | void updateCursor(); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 230 | |
| 231 | bool isInsideScrollbar(const IntPoint&) const; |
| 232 | |
Torne (Richard Coles) | e1f1df5 | 2013-08-23 16:39:30 +0100 | [diff] [blame] | 233 | ScrollableArea* associatedScrollableArea(const RenderLayer*) const; |
| 234 | |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 235 | // Scrolls the elements of the DOM tree. Returns true if a node was scrolled. |
| 236 | // False if we reached the root and couldn't scroll anything. |
| 237 | // direction - The direction to scroll in. If this is a logicl direction, it will be |
| 238 | // converted to the physical direction based on a node's writing mode. |
| 239 | // granularity - The units that the scroll delta parameter is in. |
| 240 | // startNode - The node to start bubbling the scroll from. If a node can't scroll, |
| 241 | // the scroll bubbles up to the containing block. |
| 242 | // stopNode - On input, if provided and non-null, the node at which we should stop bubbling on input. |
| 243 | // On output, if provided and a node was scrolled stopNode will point to that node. |
| 244 | // delta - The delta to scroll by, in the units of the granularity parameter. (e.g. pixels, lines, pages, etc.) |
| 245 | // absolutePoint - For wheel scrolls - the location, in absolute coordinates, where the event occured. |
| 246 | bool scroll(ScrollDirection, ScrollGranularity, Node* startNode = 0, Node** stopNode = 0, float delta = 1.0f, IntPoint absolutePoint = IntPoint()); |
| 247 | |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 248 | TouchAction intersectTouchAction(const TouchAction, const TouchAction); |
Torne (Richard Coles) | 5d92fed | 2014-06-20 14:52:37 +0100 | [diff] [blame] | 249 | TouchAction computeEffectiveTouchAction(const Node&); |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 250 | |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 251 | HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndOftenMisusedDisallowShadowContent); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 252 | |
| 253 | void invalidateClick(); |
| 254 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 255 | void updateMouseEventTargetNode(Node*, const PlatformMouseEvent&, bool fireMouseOverOut); |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 256 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 257 | MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&); |
| 258 | |
Ben Murdoch | a9984bf | 2014-04-10 11:22:39 +0100 | [diff] [blame] | 259 | bool dispatchMouseEvent(const AtomicString& eventType, Node* target, int clickCount, const PlatformMouseEvent&, bool setUnder); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 260 | bool dispatchDragEvent(const AtomicString& eventType, Node* target, const PlatformMouseEvent&, Clipboard*); |
| 261 | |
| 262 | void freeClipboard(); |
| 263 | |
| 264 | bool handleDrag(const MouseEventWithHitTestResults&, CheckDragHysteresis); |
Ben Murdoch | e69819b | 2013-07-17 14:56:49 +0100 | [diff] [blame] | 265 | bool tryStartDrag(const MouseEventWithHitTestResults&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 266 | void clearDragState(); |
| 267 | |
| 268 | bool dispatchDragSrcEvent(const AtomicString& eventType, const PlatformMouseEvent&); |
| 269 | |
| 270 | bool dragHysteresisExceeded(const FloatPoint&) const; |
| 271 | bool dragHysteresisExceeded(const IntPoint&) const; |
| 272 | |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 273 | bool passMousePressEventToSubframe(MouseEventWithHitTestResults&, LocalFrame* subframe); |
| 274 | bool passMouseMoveEventToSubframe(MouseEventWithHitTestResults&, LocalFrame* subframe, HitTestResult* hoveredNode = 0); |
| 275 | bool passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&, LocalFrame* subframe); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 276 | |
Torne (Richard Coles) | 5d92fed | 2014-06-20 14:52:37 +0100 | [diff] [blame] | 277 | bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 278 | |
| 279 | bool passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&); |
| 280 | |
| 281 | bool passWheelEventToWidget(const PlatformWheelEvent&, Widget*); |
| 282 | |
| 283 | void defaultSpaceEventHandler(KeyboardEvent*); |
| 284 | void defaultBackspaceEventHandler(KeyboardEvent*); |
| 285 | void defaultTabEventHandler(KeyboardEvent*); |
Torne (Richard Coles) | c0e19a6 | 2013-08-30 15:15:11 +0100 | [diff] [blame] | 286 | void defaultEscapeEventHandler(KeyboardEvent*); |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 287 | void defaultArrowEventHandler(FocusType, KeyboardEvent*); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 288 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 289 | void updateSelectionForMouseDrag(const HitTestResult&); |
| 290 | |
| 291 | void updateLastScrollbarUnderMouse(Scrollbar*, bool); |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 292 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 293 | void setFrameWasScrolledByUser(); |
| 294 | |
| 295 | bool capturesDragging() const { return m_capturesDragging; } |
| 296 | |
Torne (Richard Coles) | f5e4ad5 | 2013-08-05 13:57:57 +0100 | [diff] [blame] | 297 | bool isKeyEventAllowedInFullScreen(FullscreenElementStack*, const PlatformKeyboardEvent&) const; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 298 | |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 299 | bool handleGestureShowPress(); |
Torne (Richard Coles) | 81a5157 | 2013-05-13 16:52:28 +0100 | [diff] [blame] | 300 | |
| 301 | bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&); |
| 302 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 303 | bool passGestureEventToWidget(const PlatformGestureEvent&, Widget*); |
| 304 | bool passGestureEventToWidgetIfPossible(const PlatformGestureEvent&, RenderObject*); |
| 305 | bool sendScrollEventToView(const PlatformGestureEvent&, const FloatSize&); |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 306 | LocalFrame* getSubFrameForGestureEvent(const IntPoint& touchAdjustedPoint, const PlatformGestureEvent&); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 307 | |
Torne (Richard Coles) | 19cde67 | 2013-11-06 12:28:04 +0000 | [diff] [blame] | 308 | AutoscrollController* autoscrollController() const; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame] | 309 | bool panScrollInProgress() const; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 310 | void setLastKnownMousePosition(const PlatformMouseEvent&); |
| 311 | |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 312 | LocalFrame* const m_frame; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 313 | |
| 314 | bool m_mousePressed; |
| 315 | bool m_capturesDragging; |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 316 | RefPtrWillBeMember<Node> m_mousePressNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 317 | |
| 318 | bool m_mouseDownMayStartSelect; |
| 319 | bool m_mouseDownMayStartDrag; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 320 | bool m_mouseDownWasSingleClickInSelection; |
| 321 | enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection }; |
| 322 | SelectionInitiationState m_selectionInitiationState; |
| 323 | |
| 324 | LayoutPoint m_dragStartPos; |
| 325 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 326 | Timer<EventHandler> m_hoverTimer; |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 327 | Timer<EventHandler> m_cursorUpdateTimer; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 328 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 329 | bool m_mouseDownMayStartAutoscroll; |
| 330 | bool m_mouseDownWasInSubframe; |
| 331 | |
| 332 | Timer<EventHandler> m_fakeMouseMoveEventTimer; |
| 333 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 334 | bool m_svgPan; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 335 | |
Torne (Richard Coles) | f79f16f | 2013-10-31 11:16:44 +0000 | [diff] [blame] | 336 | RenderLayerScrollableArea* m_resizeScrollableArea; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 337 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 338 | RefPtrWillBeMember<Node> m_capturingMouseEventsNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 339 | bool m_eventHandlerWillResetCapturingMouseEventsNode; |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 340 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 341 | RefPtrWillBeMember<Node> m_nodeUnderMouse; |
| 342 | RefPtrWillBeMember<Node> m_lastNodeUnderMouse; |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 343 | RefPtr<LocalFrame> m_lastMouseMoveEventSubframe; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 344 | RefPtr<Scrollbar> m_lastScrollbarUnderMouse; |
| 345 | Cursor m_currentMouseCursor; |
| 346 | |
| 347 | int m_clickCount; |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 348 | RefPtrWillBeMember<Node> m_clickNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 349 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 350 | RefPtrWillBeMember<Node> m_dragTarget; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 351 | bool m_shouldOnlyFireDragOverEvent; |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 352 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 353 | RefPtrWillBeMember<HTMLFrameSetElement> m_frameSetBeingResized; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 354 | |
Torne (Richard Coles) | f79f16f | 2013-10-31 11:16:44 +0000 | [diff] [blame] | 355 | LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableArea. |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 356 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 357 | bool m_mousePositionIsUnknown; |
| 358 | IntPoint m_lastKnownMousePosition; |
| 359 | IntPoint m_lastKnownMouseGlobalPosition; |
| 360 | IntPoint m_mouseDownPos; // In our view's coords. |
| 361 | double m_mouseDownTimestamp; |
| 362 | PlatformMouseEvent m_mouseDown; |
| 363 | RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; |
| 364 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 365 | RefPtrWillBeMember<Node> m_latchedWheelEventNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 366 | bool m_widgetIsLatched; |
| 367 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 368 | RefPtrWillBeMember<Node> m_previousWheelScrolledNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 369 | |
Torne (Richard Coles) | 3234804 | 2014-05-14 12:12:57 +0100 | [diff] [blame] | 370 | // 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] | 371 | 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] | 372 | TouchTargetMap m_targetForTouchID; |
| 373 | |
| 374 | // 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] | 375 | RefPtrWillBeMember<Document> m_touchSequenceDocument; |
Torne (Richard Coles) | 5d92fed | 2014-06-20 14:52:37 +0100 | [diff] [blame] | 376 | RefPtr<UserGestureToken> m_touchSequenceUserGestureToken; |
Torne (Richard Coles) | 3234804 | 2014-05-14 12:12:57 +0100 | [diff] [blame] | 377 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 378 | bool m_touchPressed; |
| 379 | |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 380 | RefPtrWillBeMember<Node> m_scrollGestureHandlingNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 381 | bool m_lastHitTestResultOverWidget; |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 382 | RefPtrWillBeMember<Node> m_previousGestureScrolledNode; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 383 | RefPtr<Scrollbar> m_scrollbarHandlingScrollGesture; |
| 384 | |
| 385 | double m_maxMouseMovedDuration; |
| 386 | PlatformEvent::Type m_baseEventType; |
| 387 | bool m_didStartDrag; |
| 388 | |
| 389 | bool m_longTapShouldInvokeContextMenu; |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 390 | |
| 391 | Timer<EventHandler> m_activeIntervalTimer; |
| 392 | double m_lastShowPressTimestamp; |
Torne (Richard Coles) | f6b7aed | 2014-06-09 12:01:17 +0100 | [diff] [blame] | 393 | RefPtrWillBeMember<Element> m_lastDeferredTapElement; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 394 | }; |
| 395 | |
| 396 | } // namespace WebCore |
| 397 | |
| 398 | #endif // EventHandler_h |