blob: 5204ef06073a847f3cc8ca3e237b665933f15de9 [file] [log] [blame]
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +01001/*
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 Murdoch02772c62013-07-26 10:21:05 +010023 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010024 */
25
26#ifndef EventHandler_h
27#define EventHandler_h
28
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010029#include "core/editing/TextGranularity.h"
Torne (Richard Coles)1e202182013-10-18 15:46:42 +010030#include "core/events/TextEventInputType.h"
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010031#include "core/page/DragActions.h"
Torne (Richard Coles)09380292014-02-21 12:17:33 +000032#include "core/page/FocusType.h"
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010033#include "core/rendering/HitTestRequest.h"
Torne (Richard Coles)a854de02013-12-18 16:25:25 +000034#include "core/rendering/style/RenderStyleConstants.h"
35#include "platform/Cursor.h"
Torne (Richard Coles)1e202182013-10-18 15:46:42 +010036#include "platform/PlatformMouseEvent.h"
37#include "platform/Timer.h"
38#include "platform/UserGestureIndicator.h"
39#include "platform/geometry/LayoutPoint.h"
Bo Liuf91f5fa2014-05-01 10:37:55 -070040#include "platform/heap/Handle.h"
Torne (Richard Coles)1e202182013-10-18 15:46:42 +010041#include "platform/scroll/ScrollTypes.h"
Ben Murdoch591b9582013-07-10 11:41:44 +010042#include "wtf/Forward.h"
43#include "wtf/HashMap.h"
Torne (Richard Coles)32348042014-05-14 12:12:57 +010044#include "wtf/HashTraits.h"
Ben Murdoch591b9582013-07-10 11:41:44 +010045#include "wtf/RefPtr.h"
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010046
47namespace WebCore {
48
Torne (Richard Coles)19cde672013-11-06 12:28:04 +000049class AutoscrollController;
Ben Murdoch197021e2014-07-20 18:26:29 -070050class DataTransfer;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010051class Document;
Ben Murdoch197021e2014-07-20 18:26:29 -070052class DragState;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010053class Element;
54class Event;
55class EventTarget;
Ben Murdoch197021e2014-07-20 18:26:29 -070056template <typename EventType>
57class EventWithHitTestResults;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010058class FloatPoint;
59class FloatQuad;
Torne (Richard Coles)f5e4ad52013-08-05 13:57:57 +010060class FullscreenElementStack;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010061class HTMLFrameSetElement;
62class HitTestRequest;
63class HitTestResult;
64class KeyboardEvent;
Ben Murdoch197021e2014-07-20 18:26:29 -070065class LocalFrame;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010066class Node;
67class OptionalCursor;
68class PlatformGestureEvent;
69class PlatformKeyboardEvent;
70class PlatformTouchEvent;
71class PlatformWheelEvent;
72class RenderLayer;
Torne (Richard Coles)f79f16f2013-10-31 11:16:44 +000073class RenderLayerScrollableArea;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010074class RenderObject;
75class RenderWidget;
Torne (Richard Coles)e1f1df52013-08-23 16:39:30 +010076class ScrollableArea;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010077class Scrollbar;
78class TextEvent;
79class TouchEvent;
80class VisibleSelection;
81class WheelEvent;
82class Widget;
83
Ben Murdoch197021e2014-07-20 18:26:29 -070084typedef EventWithHitTestResults<PlatformGestureEvent> GestureEventWithHitTestResults;
85typedef EventWithHitTestResults<PlatformMouseEvent> MouseEventWithHitTestResults;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010086
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010087enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace };
88enum CheckDragHysteresis { ShouldCheckDragHysteresis, DontCheckDragHysteresis };
89
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +010090class EventHandler : public NoBaseWillBeGarbageCollectedFinalized<EventHandler> {
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010091 WTF_MAKE_NONCOPYABLE(EventHandler);
92public:
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000093 explicit EventHandler(LocalFrame*);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010094 ~EventHandler();
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +010095 void trace(Visitor*);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010096
97 void clear();
Torne (Richard Coles)19cde672013-11-06 12:28:04 +000098 void nodeWillBeRemoved(Node&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010099
100 void updateSelectionForMouseDrag();
101
102 Node* mousePressNode() const;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100103
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100104#if OS(WIN)
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100105 void startPanScrolling(RenderObject*);
106#endif
107
Torne (Richard Coles)19cde672013-11-06 12:28:04 +0000108 void stopAutoscroll();
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100109
110 void dispatchFakeMouseMoveEventSoon();
111 void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
112
113 HitTestResult hitTestResultAtPoint(const LayoutPoint&,
Ben Murdoch591b9582013-07-10 11:41:44 +0100114 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active,
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100115 const LayoutSize& padding = LayoutSize());
116
117 bool mousePressed() const { return m_mousePressed; }
118 void setMousePressed(bool pressed) { m_mousePressed = pressed; }
119
Torne (Richard Coles)d6cdb822014-06-03 10:59:05 +0100120 void setCapturingMouseEventsNode(PassRefPtrWillBeRawPtr<Node>); // A caller is responsible for resetting capturing node to 0.
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100121
Ben Murdoch197021e2014-07-20 18:26:29 -0700122 bool updateDragAndDrop(const PlatformMouseEvent&, DataTransfer*);
123 void cancelDragAndDrop(const PlatformMouseEvent&, DataTransfer*);
124 bool performDragAndDrop(const PlatformMouseEvent&, DataTransfer*);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100125 void updateDragStateAfterEditDragIfNeeded(Element* rootEditableElement);
126
127 void scheduleHoverStateUpdate();
Torne (Richard Coles)1e202182013-10-18 15:46:42 +0100128 void scheduleCursorUpdate();
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100129
130 void setResizingFrameSet(HTMLFrameSetElement*);
131
Torne (Richard Coles)f79f16f2013-10-31 11:16:44 +0000132 void resizeScrollableAreaDestroyed();
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100133
134 IntPoint lastKnownMousePosition() const;
135 Cursor currentMouseCursor() const { return m_currentMouseCursor; }
136
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000137 // 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)53e740f2013-05-09 18:38:43 +0100140
Torne (Richard Coles)c0e19a62013-08-30 15:15:11 +0100141 bool handleMouseMoveEvent(const PlatformMouseEvent&);
142 void handleMouseLeaveEvent(const PlatformMouseEvent&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100143
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100144 bool handleMousePressEvent(const PlatformMouseEvent&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100145 bool handleMouseReleaseEvent(const PlatformMouseEvent&);
146 bool handleWheelEvent(const PlatformWheelEvent&);
147 void defaultWheelEventHandler(Node*, WheelEvent*);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100148
Ben Murdoch197021e2014-07-20 18:26:29 -0700149 // Called on the local root frame exactly once per gesture event.
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100150 bool handleGestureEvent(const PlatformGestureEvent&);
Ben Murdoch197021e2014-07-20 18:26:29 -0700151
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)53e740f2013-05-09 18:38:43 +0100164 bool handleGestureScrollEnd(const PlatformGestureEvent&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100165 bool isScrollbarHandlingGestures() const;
166
Ben Murdoch197021e2014-07-20 18:26:29 -0700167 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)53e740f2013-05-09 18:38:43 +0100170 bool bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntRect& targetArea, Node*& targetNode);
171
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100172 bool sendContextMenuEvent(const PlatformMouseEvent&);
173 bool sendContextMenuEventForKey();
Ben Murdoch197021e2014-07-20 18:26:29 -0700174 bool sendContextMenuEventForGesture(const GestureEventWithHitTestResults&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100175
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)53e740f2013-05-09 18:38:43 +0100192 bool handleTouchEvent(const PlatformTouchEvent&);
193
Ben Murdoch6f543c72014-04-16 11:17:22 +0100194 bool useHandCursor(Node*, bool isOverLink);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100195
Torne (Richard Coles)a854de02013-12-18 16:25:25 +0000196 void notifyElementActivated();
197
Ben Murdoch10f88d52014-04-24 10:50:33 +0100198 PassRefPtr<UserGestureToken> takeLastMouseDownGestureToken() { return m_lastMouseDownUserGestureToken.release(); }
199
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100200private:
201 static DragState& dragState();
Ben Murdoch02772c62013-07-26 10:21:05 +0100202
Ben Murdoch197021e2014-07-20 18:26:29 -0700203 PassRefPtrWillBeRawPtr<DataTransfer> createDraggingDataTransfer() const;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100204
205 bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleSelection&, TextGranularity);
206 void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
Torne (Richard Coles)5267f702013-06-11 10:57:24 +0100207 void selectClosestMisspellingFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100208 void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&);
Torne (Richard Coles)5267f702013-06-11 10:57:24 +0100209 void selectClosestMisspellingFromMouseEvent(const MouseEventWithHitTestResults&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100210 void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults&);
211
Torne (Richard Coles)c0e19a62013-08-30 15:15:11 +0100212 bool handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, HitTestResult* hoveredNode = 0, bool onlyUpdateScrollbars = false);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100213 bool handleMousePressEvent(const MouseEventWithHitTestResults&);
214 bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
215 bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
216 bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
Ben Murdoch6f543c72014-04-16 11:17:22 +0100217 bool handleMouseFocus(const PlatformMouseEvent&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100218 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&);
219 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
220
Torne (Richard Coles)1e202182013-10-18 15:46:42 +0100221 bool handlePasteGlobalSelection(const PlatformMouseEvent&);
222
Ben Murdoch197021e2014-07-20 18:26:29 -0700223 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)1e202182013-10-18 15:46:42 +0100228 bool handleGestureScrollUpdate(const PlatformGestureEvent&);
229 bool handleGestureScrollBegin(const PlatformGestureEvent&);
230 void clearGestureScrollNodes();
231
232 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const;
233
Ben Murdoch6f543c72014-04-16 11:17:22 +0100234 OptionalCursor selectCursor(const HitTestResult&);
235 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& iBeam);
Torne (Richard Coles)1e202182013-10-18 15:46:42 +0100236
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100237 void hoverTimerFired(Timer<EventHandler>*);
Torne (Richard Coles)1e202182013-10-18 15:46:42 +0100238 void cursorUpdateTimerFired(Timer<EventHandler>*);
Torne (Richard Coles)a854de02013-12-18 16:25:25 +0000239 void activeIntervalTimerFired(Timer<EventHandler>*);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100240
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100241 bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; }
242
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100243 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*);
244 void cancelFakeMouseMoveEvent();
245 bool isCursorVisible() const;
Torne (Richard Coles)1e202182013-10-18 15:46:42 +0100246 void updateCursor();
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100247
248 bool isInsideScrollbar(const IntPoint&) const;
249
Torne (Richard Coles)e1f1df52013-08-23 16:39:30 +0100250 ScrollableArea* associatedScrollableArea(const RenderLayer*) const;
251
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000252 // 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)09380292014-02-21 12:17:33 +0000265 TouchAction intersectTouchAction(const TouchAction, const TouchAction);
Torne (Richard Coles)5d92fed2014-06-20 14:52:37 +0100266 TouchAction computeEffectiveTouchAction(const Node&);
Torne (Richard Coles)a854de02013-12-18 16:25:25 +0000267
Ben Murdoch197021e2014-07-20 18:26:29 -0700268 HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100269
270 void invalidateClick();
271
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100272 void updateMouseEventTargetNode(Node*, const PlatformMouseEvent&, bool fireMouseOverOut);
Ben Murdoch02772c62013-07-26 10:21:05 +0100273
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100274 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&);
275
Ben Murdocha9984bf2014-04-10 11:22:39 +0100276 bool dispatchMouseEvent(const AtomicString& eventType, Node* target, int clickCount, const PlatformMouseEvent&, bool setUnder);
Ben Murdoch197021e2014-07-20 18:26:29 -0700277 bool dispatchDragEvent(const AtomicString& eventType, Node* target, const PlatformMouseEvent&, DataTransfer*);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100278
Ben Murdoch197021e2014-07-20 18:26:29 -0700279 void clearDragDataTransfer();
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100280
281 bool handleDrag(const MouseEventWithHitTestResults&, CheckDragHysteresis);
Ben Murdoche69819b2013-07-17 14:56:49 +0100282 bool tryStartDrag(const MouseEventWithHitTestResults&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100283 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)d5428f32014-03-18 10:21:16 +0000290 bool passMousePressEventToSubframe(MouseEventWithHitTestResults&, LocalFrame* subframe);
291 bool passMouseMoveEventToSubframe(MouseEventWithHitTestResults&, LocalFrame* subframe, HitTestResult* hoveredNode = 0);
292 bool passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&, LocalFrame* subframe);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100293
Torne (Richard Coles)5d92fed2014-06-20 14:52:37 +0100294 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100295
296 bool passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&);
297
298 bool passWheelEventToWidget(const PlatformWheelEvent&, Widget*);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100299 void defaultSpaceEventHandler(KeyboardEvent*);
300 void defaultBackspaceEventHandler(KeyboardEvent*);
301 void defaultTabEventHandler(KeyboardEvent*);
Torne (Richard Coles)c0e19a62013-08-30 15:15:11 +0100302 void defaultEscapeEventHandler(KeyboardEvent*);
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000303 void defaultArrowEventHandler(FocusType, KeyboardEvent*);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100304
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100305 void updateSelectionForMouseDrag(const HitTestResult&);
306
307 void updateLastScrollbarUnderMouse(Scrollbar*, bool);
Ben Murdoch02772c62013-07-26 10:21:05 +0100308
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100309 void setFrameWasScrolledByUser();
310
311 bool capturesDragging() const { return m_capturesDragging; }
312
Torne (Richard Coles)f5e4ad52013-08-05 13:57:57 +0100313 bool isKeyEventAllowedInFullScreen(FullscreenElementStack*, const PlatformKeyboardEvent&) const;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100314
Torne (Richard Coles)1e202182013-10-18 15:46:42 +0100315 bool handleGestureShowPress();
Torne (Richard Coles)81a51572013-05-13 16:52:28 +0100316
317 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&);
318
Ben Murdoch197021e2014-07-20 18:26:29 -0700319 bool passScrollGestureEventToWidget(const PlatformGestureEvent&, RenderObject*);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100320 bool sendScrollEventToView(const PlatformGestureEvent&, const FloatSize&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100321
Torne (Richard Coles)19cde672013-11-06 12:28:04 +0000322 AutoscrollController* autoscrollController() const;
Torne (Richard Coles)5267f702013-06-11 10:57:24 +0100323 bool panScrollInProgress() const;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100324 void setLastKnownMousePosition(const PlatformMouseEvent&);
325
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000326 LocalFrame* const m_frame;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100327
328 bool m_mousePressed;
329 bool m_capturesDragging;
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100330 RefPtrWillBeMember<Node> m_mousePressNode;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100331
332 bool m_mouseDownMayStartSelect;
333 bool m_mouseDownMayStartDrag;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100334 bool m_mouseDownWasSingleClickInSelection;
335 enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };
336 SelectionInitiationState m_selectionInitiationState;
337
338 LayoutPoint m_dragStartPos;
339
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100340 Timer<EventHandler> m_hoverTimer;
Torne (Richard Coles)1e202182013-10-18 15:46:42 +0100341 Timer<EventHandler> m_cursorUpdateTimer;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100342
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100343 bool m_mouseDownMayStartAutoscroll;
344 bool m_mouseDownWasInSubframe;
345
346 Timer<EventHandler> m_fakeMouseMoveEventTimer;
347
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100348 bool m_svgPan;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100349
Torne (Richard Coles)f79f16f2013-10-31 11:16:44 +0000350 RenderLayerScrollableArea* m_resizeScrollableArea;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100351
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100352 RefPtrWillBeMember<Node> m_capturingMouseEventsNode;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100353 bool m_eventHandlerWillResetCapturingMouseEventsNode;
Ben Murdoch02772c62013-07-26 10:21:05 +0100354
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100355 RefPtrWillBeMember<Node> m_nodeUnderMouse;
356 RefPtrWillBeMember<Node> m_lastNodeUnderMouse;
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000357 RefPtr<LocalFrame> m_lastMouseMoveEventSubframe;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100358 RefPtr<Scrollbar> m_lastScrollbarUnderMouse;
359 Cursor m_currentMouseCursor;
360
361 int m_clickCount;
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100362 RefPtrWillBeMember<Node> m_clickNode;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100363
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100364 RefPtrWillBeMember<Node> m_dragTarget;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100365 bool m_shouldOnlyFireDragOverEvent;
Ben Murdoch02772c62013-07-26 10:21:05 +0100366
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100367 RefPtrWillBeMember<HTMLFrameSetElement> m_frameSetBeingResized;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100368
Torne (Richard Coles)f79f16f2013-10-31 11:16:44 +0000369 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableArea.
Ben Murdoch02772c62013-07-26 10:21:05 +0100370
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100371 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)f6b7aed2014-06-09 12:01:17 +0100379 RefPtrWillBeMember<Node> m_latchedWheelEventNode;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100380 bool m_widgetIsLatched;
381
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100382 RefPtrWillBeMember<Node> m_previousWheelScrolledNode;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100383
Torne (Richard Coles)32348042014-05-14 12:12:57 +0100384 // The target of each active touch point indexed by the touch ID.
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100385 typedef WillBeHeapHashMap<unsigned, RefPtrWillBeMember<EventTarget>, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned> > TouchTargetMap;
Torne (Richard Coles)32348042014-05-14 12:12:57 +0100386 TouchTargetMap m_targetForTouchID;
387
388 // If set, the document of the active touch sequence. Unset if no touch sequence active.
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100389 RefPtrWillBeMember<Document> m_touchSequenceDocument;
Torne (Richard Coles)5d92fed2014-06-20 14:52:37 +0100390 RefPtr<UserGestureToken> m_touchSequenceUserGestureToken;
Torne (Richard Coles)32348042014-05-14 12:12:57 +0100391
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100392 bool m_touchPressed;
393
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100394 RefPtrWillBeMember<Node> m_scrollGestureHandlingNode;
Ben Murdoch197021e2014-07-20 18:26:29 -0700395 bool m_lastGestureScrollOverWidget;
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100396 RefPtrWillBeMember<Node> m_previousGestureScrolledNode;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100397 RefPtr<Scrollbar> m_scrollbarHandlingScrollGesture;
398
399 double m_maxMouseMovedDuration;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100400 bool m_didStartDrag;
401
402 bool m_longTapShouldInvokeContextMenu;
Torne (Richard Coles)a854de02013-12-18 16:25:25 +0000403
404 Timer<EventHandler> m_activeIntervalTimer;
405 double m_lastShowPressTimestamp;
Torne (Richard Coles)f6b7aed2014-06-09 12:01:17 +0100406 RefPtrWillBeMember<Element> m_lastDeferredTapElement;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100407};
408
409} // namespace WebCore
410
411#endif // EventHandler_h