1/*
2 * Copyright (C) 2006-2018 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 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 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
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#pragma once
27
28#include "Cursor.h"
29#include "DragActions.h"
30#include "FocusDirection.h"
31#include "HitTestRequest.h"
32#include "LayoutPoint.h"
33#include "PlatformMouseEvent.h"
34#include "RenderObject.h"
35#include "ScrollTypes.h"
36#include "TextEventInputType.h"
37#include "TextGranularity.h"
38#include "Timer.h"
39#include <memory>
40#include <wtf/Forward.h>
41#include <wtf/HashMap.h>
42#include <wtf/HashSet.h>
43#include <wtf/RefPtr.h>
44#include <wtf/WeakPtr.h>
45
46#if PLATFORM(COCOA)
47OBJC_CLASS NSView;
48#endif
49
50#if PLATFORM(IOS_FAMILY)
51OBJC_CLASS WebEvent;
52#endif
53
54#if PLATFORM(MAC)
55OBJC_CLASS NSEvent;
56#endif
57
58#if PLATFORM(IOS_FAMILY) && defined(__OBJC__)
59#include "WAKAppKitStubs.h"
60#endif
61
62namespace WebCore {
63
64class AutoscrollController;
65class ContainerNode;
66class DataTransfer;
67class Document;
68class Element;
69class Event;
70class EventTarget;
71class FloatQuad;
72class Frame;
73class FrameView;
74class HTMLFrameSetElement;
75class HitTestResult;
76class KeyboardEvent;
77class MouseEventWithHitTestResults;
78class Node;
79class Pasteboard;
80class PlatformGestureEvent;
81class PlatformKeyboardEvent;
82class PlatformTouchEvent;
83class PlatformWheelEvent;
84class RenderBox;
85class RenderElement;
86class RenderLayer;
87class RenderWidget;
88class ScrollableArea;
89class Scrollbar;
90class TextEvent;
91class Touch;
92class TouchEvent;
93class VisibleSelection;
94class WheelEvent;
95class Widget;
96
97struct DragState;
98
99#if ENABLE(DRAG_SUPPORT)
100extern const int LinkDragHysteresis;
101extern const int ImageDragHysteresis;
102extern const int TextDragHysteresis;
103extern const int ColorDragHystersis;
104extern const int GeneralDragHysteresis;
105#endif
106
107#if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
108extern const float GestureUnknown;
109extern const unsigned InvalidTouchIdentifier;
110#endif
111
112enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace };
113enum CheckDragHysteresis { ShouldCheckDragHysteresis, DontCheckDragHysteresis };
114
115enum class ImmediateActionStage {
116 None,
117 PerformedHitTest,
118 ActionUpdated,
119 ActionCancelledWithoutUpdate,
120 ActionCancelledAfterUpdate,
121 ActionCompleted
122};
123
124class EventHandler {
125 WTF_MAKE_FAST_ALLOCATED;
126public:
127 explicit EventHandler(Frame&);
128 ~EventHandler();
129
130 void clear();
131 void nodeWillBeRemoved(Node&);
132
133 WEBCORE_EXPORT VisiblePosition selectionExtentRespectingEditingBoundary(const VisibleSelection&, const LayoutPoint&, Node*);
134
135#if ENABLE(DRAG_SUPPORT)
136 void updateSelectionForMouseDrag();
137#endif
138
139#if ENABLE(PAN_SCROLLING)
140 void didPanScrollStart();
141 void didPanScrollStop();
142 void startPanScrolling(RenderElement&);
143#endif
144
145 void stopAutoscrollTimer(bool rendererIsBeingDestroyed = false);
146 RenderBox* autoscrollRenderer() const;
147 void updateAutoscrollRenderer();
148 bool autoscrollInProgress() const;
149 bool mouseDownWasInSubframe() const { return m_mouseDownWasInSubframe; }
150 bool panScrollInProgress() const;
151
152 WEBCORE_EXPORT void dispatchFakeMouseMoveEventSoon();
153 void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
154
155 WEBCORE_EXPORT HitTestResult hitTestResultAtPoint(const LayoutPoint&, HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowUserAgentShadowContent, const LayoutSize& padding = LayoutSize()) const;
156
157 bool mousePressed() const { return m_mousePressed; }
158 Node* mousePressNode() const { return m_mousePressNode.get(); }
159
160 WEBCORE_EXPORT void setCapturingMouseEventsElement(Element*);
161
162#if ENABLE(DRAG_SUPPORT)
163 struct DragTargetResponse {
164 bool accept { false };
165 Optional<DragOperation> operation;
166 };
167 DragTargetResponse updateDragAndDrop(const PlatformMouseEvent&, const std::function<std::unique_ptr<Pasteboard>()>&, DragOperation sourceOperation, bool draggingFiles);
168 void cancelDragAndDrop(const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
169 bool performDragAndDrop(const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
170 void updateDragStateAfterEditDragIfNeeded(Element& rootEditableElement);
171 RefPtr<Element> draggedElement() const;
172#endif
173
174 void scheduleHoverStateUpdate();
175#if ENABLE(CURSOR_SUPPORT)
176 void scheduleCursorUpdate();
177#endif
178
179 void setResizingFrameSet(HTMLFrameSetElement*);
180
181 void resizeLayerDestroyed();
182
183 IntPoint lastKnownMousePosition() const;
184 IntPoint lastKnownMouseGlobalPosition() const { return m_lastKnownMouseGlobalPosition; }
185 Cursor currentMouseCursor() const { return m_currentMouseCursor; }
186
187 IntPoint targetPositionInWindowForSelectionAutoscroll() const;
188 bool shouldUpdateAutoscroll();
189
190 static Frame* subframeForTargetNode(Node*);
191 static Frame* subframeForHitTestResult(const MouseEventWithHitTestResults&);
192
193 WEBCORE_EXPORT bool scrollOverflow(ScrollDirection, ScrollGranularity, Node* startingNode = nullptr);
194 WEBCORE_EXPORT bool scrollRecursively(ScrollDirection, ScrollGranularity, Node* startingNode = nullptr);
195 WEBCORE_EXPORT bool logicalScrollRecursively(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = nullptr);
196
197 bool tabsToLinks(KeyboardEvent*) const;
198 bool tabsToAllFormControls(KeyboardEvent*) const;
199
200 WEBCORE_EXPORT bool mouseMoved(const PlatformMouseEvent&);
201 WEBCORE_EXPORT bool passMouseMovedEventToScrollbars(const PlatformMouseEvent&);
202
203 void lostMouseCapture();
204
205 WEBCORE_EXPORT bool handleMousePressEvent(const PlatformMouseEvent&);
206 bool handleMouseMoveEvent(const PlatformMouseEvent&, HitTestResult* hoveredNode = nullptr, bool onlyUpdateScrollbars = false);
207 WEBCORE_EXPORT bool handleMouseReleaseEvent(const PlatformMouseEvent&);
208 bool handleMouseForceEvent(const PlatformMouseEvent&);
209 WEBCORE_EXPORT bool handleWheelEvent(const PlatformWheelEvent&);
210 void defaultWheelEventHandler(Node*, WheelEvent&);
211 bool handlePasteGlobalSelection(const PlatformMouseEvent&);
212
213 void platformPrepareForWheelEvents(const PlatformWheelEvent&, const HitTestResult&, RefPtr<Element>& eventTarget, RefPtr<ContainerNode>& scrollableContainer, WeakPtr<ScrollableArea>&, bool& isOverWidget);
214 void platformRecordWheelEvent(const PlatformWheelEvent&);
215 bool platformCompleteWheelEvent(const PlatformWheelEvent&, ContainerNode* scrollableContainer, const WeakPtr<ScrollableArea>&);
216 bool platformCompletePlatformWidgetWheelEvent(const PlatformWheelEvent&, const Widget&, ContainerNode* scrollableContainer);
217 void platformNotifyIfEndGesture(const PlatformWheelEvent&, const WeakPtr<ScrollableArea>&);
218
219#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
220 using TouchArray = Vector<RefPtr<Touch>>;
221 using EventTargetTouchMap = HashMap<EventTarget*, TouchArray*>;
222#endif
223
224#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
225 using EventTargetSet = HashSet<RefPtr<EventTarget>>;
226#endif
227
228#if ENABLE(IOS_TOUCH_EVENTS)
229 bool dispatchTouchEvent(const PlatformTouchEvent&, const AtomString&, const EventTargetTouchMap&, float, float);
230 bool dispatchSimulatedTouchEvent(IntPoint location);
231 Frame* touchEventTargetSubframe() const { return m_touchEventTargetSubframe.get(); }
232 const TouchArray& touches() const { return m_touches; }
233#endif
234
235#if ENABLE(IOS_GESTURE_EVENTS)
236 bool dispatchGestureEvent(const PlatformTouchEvent&, const AtomString&, const EventTargetSet&, float, float);
237#elif ENABLE(MAC_GESTURE_EVENTS)
238 bool dispatchGestureEvent(const PlatformGestureEvent&, const AtomString&, const EventTargetSet&, float, float);
239 WEBCORE_EXPORT bool handleGestureEvent(const PlatformGestureEvent&);
240#endif
241
242#if PLATFORM(IOS_FAMILY)
243 void defaultTouchEventHandler(Node&, TouchEvent&);
244 WEBCORE_EXPORT void dispatchSyntheticMouseOut(const PlatformMouseEvent&);
245 WEBCORE_EXPORT void dispatchSyntheticMouseMove(const PlatformMouseEvent&);
246#endif
247
248#if ENABLE(CONTEXT_MENUS)
249 WEBCORE_EXPORT bool sendContextMenuEvent(const PlatformMouseEvent&);
250 WEBCORE_EXPORT bool sendContextMenuEventForKey();
251#endif
252
253 void setMouseDownMayStartAutoscroll() { m_mouseDownMayStartAutoscroll = true; }
254
255 bool needsKeyboardEventDisambiguationQuirks() const;
256
257 WEBCORE_EXPORT static OptionSet<PlatformEvent::Modifier> accessKeyModifiers();
258 WEBCORE_EXPORT bool handleAccessKey(const PlatformKeyboardEvent&);
259 WEBCORE_EXPORT bool keyEvent(const PlatformKeyboardEvent&);
260 void defaultKeyboardEventHandler(KeyboardEvent&);
261 WEBCORE_EXPORT void capsLockStateMayHaveChanged() const;
262
263 bool accessibilityPreventsEventPropagation(KeyboardEvent&);
264 WEBCORE_EXPORT void handleKeyboardSelectionMovementForAccessibility(KeyboardEvent&);
265
266 bool handleTextInputEvent(const String& text, Event* underlyingEvent = nullptr, TextEventInputType = TextEventInputKeyboard);
267 void defaultTextInputEventHandler(TextEvent&);
268
269#if ENABLE(DRAG_SUPPORT)
270 WEBCORE_EXPORT bool eventMayStartDrag(const PlatformMouseEvent&) const;
271
272 WEBCORE_EXPORT void didStartDrag();
273 WEBCORE_EXPORT void dragCancelled();
274 WEBCORE_EXPORT void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation, MayExtendDragSession = MayExtendDragSession::No);
275#endif
276
277 void focusDocumentView();
278
279 WEBCORE_EXPORT void sendScrollEvent();
280
281#if PLATFORM(MAC)
282 WEBCORE_EXPORT void mouseDown(NSEvent *, NSEvent *correspondingPressureEvent);
283 WEBCORE_EXPORT void mouseDragged(NSEvent *, NSEvent *correspondingPressureEvent);
284 WEBCORE_EXPORT void mouseUp(NSEvent *, NSEvent *correspondingPressureEvent);
285 WEBCORE_EXPORT void mouseMoved(NSEvent *, NSEvent *correspondingPressureEvent);
286 WEBCORE_EXPORT void pressureChange(NSEvent *, NSEvent* correspondingPressureEvent);
287 WEBCORE_EXPORT bool keyEvent(NSEvent *);
288 WEBCORE_EXPORT bool wheelEvent(NSEvent *);
289#endif
290
291#if PLATFORM(IOS_FAMILY)
292 WEBCORE_EXPORT void mouseDown(WebEvent *);
293 WEBCORE_EXPORT void mouseUp(WebEvent *);
294 WEBCORE_EXPORT void mouseMoved(WebEvent *);
295 WEBCORE_EXPORT bool keyEvent(WebEvent *);
296 WEBCORE_EXPORT bool wheelEvent(WebEvent *);
297#endif
298
299#if ENABLE(IOS_TOUCH_EVENTS)
300 WEBCORE_EXPORT void touchEvent(WebEvent *);
301#endif
302
303#if PLATFORM(MAC)
304 WEBCORE_EXPORT void passMouseMovedEventToScrollbars(NSEvent *, NSEvent* correspondingPressureEvent);
305
306 WEBCORE_EXPORT void sendFakeEventsAfterWidgetTracking(NSEvent *initiatingEvent);
307
308 void setActivationEventNumber(int num) { m_activationEventNumber = num; }
309
310 WEBCORE_EXPORT static NSEvent *currentNSEvent();
311 static NSEvent *correspondingPressureEvent();
312#endif
313
314#if PLATFORM(IOS_FAMILY)
315 static WebEvent *currentEvent();
316
317 void invalidateClick();
318#endif
319
320#if ENABLE(TOUCH_EVENTS)
321 WEBCORE_EXPORT bool handleTouchEvent(const PlatformTouchEvent&);
322#endif
323
324 bool useHandCursor(Node*, bool isOverLink, bool shiftKey);
325 void updateCursor();
326
327 bool isHandlingWheelEvent() const { return m_isHandlingWheelEvent; }
328
329 WEBCORE_EXPORT void setImmediateActionStage(ImmediateActionStage stage);
330 ImmediateActionStage immediateActionStage() const { return m_immediateActionStage; }
331
332 static Widget* widgetForEventTarget(Element* eventTarget);
333
334#if PLATFORM(IOS_FAMILY) && ENABLE(DRAG_SUPPORT)
335 WEBCORE_EXPORT bool tryToBeginDragAtPoint(const IntPoint& clientPosition, const IntPoint& globalPosition);
336#endif
337
338#if PLATFORM(IOS_FAMILY)
339 WEBCORE_EXPORT void startSelectionAutoscroll(RenderObject* renderer, const FloatPoint& positionInWindow);
340 WEBCORE_EXPORT void cancelSelectionAutoscroll();
341 IntPoint m_targetAutoscrollPositionInWindow;
342 bool m_isAutoscrolling { false };
343#endif
344
345private:
346#if ENABLE(DRAG_SUPPORT)
347 static DragState& dragState();
348 static const Seconds TextDragDelay;
349#endif
350
351 bool eventActivatedView(const PlatformMouseEvent&) const;
352 bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleSelection&, TextGranularity);
353 void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
354 VisibleSelection selectClosestWordFromHitTestResultBasedOnLookup(const HitTestResult&);
355 void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&);
356 void selectClosestContextualWordFromMouseEvent(const MouseEventWithHitTestResults&);
357 void selectClosestContextualWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults&);
358
359 bool handleMouseDoubleClickEvent(const PlatformMouseEvent&);
360
361 WEBCORE_EXPORT bool handleMousePressEvent(const MouseEventWithHitTestResults&);
362 bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
363 bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
364 bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
365
366#if ENABLE(DRAG_SUPPORT)
367 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&, CheckDragHysteresis = ShouldCheckDragHysteresis);
368 bool shouldAllowMouseDownToStartDrag() const;
369#endif
370
371 WEBCORE_EXPORT bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
372
373 bool internalKeyEvent(const PlatformKeyboardEvent&);
374
375 Optional<Cursor> selectCursor(const HitTestResult&, bool shiftKey);
376 void updateCursor(FrameView&, const HitTestResult&, bool shiftKey);
377
378 void hoverTimerFired();
379
380#if ENABLE(CURSOR_SUPPORT)
381 void cursorUpdateTimerFired();
382#endif
383
384 bool logicalScrollOverflow(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = nullptr);
385
386 bool shouldSwapScrollDirection(const HitTestResult&, const PlatformWheelEvent&) const;
387
388 bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; }
389
390 static bool isKeyboardOptionTab(KeyboardEvent&);
391 static bool eventInvertsTabsToLinksClientCallResult(KeyboardEvent&);
392
393#if !ENABLE(IOS_TOUCH_EVENTS)
394 void fakeMouseMoveEventTimerFired();
395 void cancelFakeMouseMoveEvent();
396#endif
397
398 bool isInsideScrollbar(const IntPoint&) const;
399
400#if ENABLE(TOUCH_EVENTS)
401 bool dispatchSyntheticTouchEventIfEnabled(const PlatformMouseEvent&);
402#endif
403
404#if !PLATFORM(IOS_FAMILY)
405 void invalidateClick();
406#endif
407
408 Node* nodeUnderMouse() const;
409
410 enum class FireMouseOverOut { No, Yes };
411 void updateMouseEventTargetNode(Node*, const PlatformMouseEvent&, FireMouseOverOut);
412
413 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&);
414
415 bool dispatchMouseEvent(const AtomString& eventType, Node* target, bool cancelable, int clickCount, const PlatformMouseEvent&, bool setUnder);
416
417#if ENABLE(DRAG_SUPPORT)
418 bool dispatchDragEvent(const AtomString& eventType, Element& target, const PlatformMouseEvent&, DataTransfer&);
419 DragTargetResponse dispatchDragEnterOrDragOverEvent(const AtomString& eventType, Element& target, const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&& , DragOperation, bool draggingFiles);
420 void invalidateDataTransfer();
421
422 bool handleDrag(const MouseEventWithHitTestResults&, CheckDragHysteresis);
423#endif
424
425 bool handleMouseUp(const MouseEventWithHitTestResults&);
426
427#if ENABLE(DRAG_SUPPORT)
428 void clearDragState();
429
430 void dispatchDragSrcEvent(const AtomString& eventType, const PlatformMouseEvent&);
431 bool dispatchDragStartEventOnSourceElement(DataTransfer&);
432
433 bool dragHysteresisExceeded(const FloatPoint&) const;
434 bool dragHysteresisExceeded(const IntPoint&) const;
435#endif
436
437 bool mouseMovementExceedsThreshold(const FloatPoint&, int pointsThreshold) const;
438
439 bool passMousePressEventToSubframe(MouseEventWithHitTestResults&, Frame* subframe);
440 bool passMouseMoveEventToSubframe(MouseEventWithHitTestResults&, Frame* subframe, HitTestResult* hoveredNode = nullptr);
441 bool passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&, Frame* subframe);
442
443 bool passSubframeEventToSubframe(MouseEventWithHitTestResults&, Frame* subframe, HitTestResult* hoveredNode = nullptr);
444
445 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&, Scrollbar*);
446
447 bool passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&);
448 bool passWidgetMouseDownEventToWidget(RenderWidget*);
449
450 bool passMouseDownEventToWidget(Widget*);
451 bool widgetDidHandleWheelEvent(const PlatformWheelEvent&, Widget&);
452 bool completeWidgetWheelEvent(const PlatformWheelEvent&, const WeakPtr<Widget>&, const WeakPtr<ScrollableArea>&, ContainerNode*);
453
454 void defaultSpaceEventHandler(KeyboardEvent&);
455 void defaultBackspaceEventHandler(KeyboardEvent&);
456 void defaultTabEventHandler(KeyboardEvent&);
457 void defaultArrowEventHandler(FocusDirection, KeyboardEvent&);
458
459#if ENABLE(DRAG_SUPPORT)
460 DragSourceAction updateDragSourceActionsAllowed() const;
461 bool supportsSelectionUpdatesOnMouseDrag() const;
462#endif
463
464 // The following are called at the beginning of handleMouseUp and handleDrag.
465 // If they return true it indicates that they have consumed the event.
466 bool eventLoopHandleMouseUp(const MouseEventWithHitTestResults&);
467
468#if ENABLE(DRAG_SUPPORT)
469 bool eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&);
470 void updateSelectionForMouseDrag(const HitTestResult&);
471#endif
472
473 enum class SetOrClearLastScrollbar { Clear, Set };
474 void updateLastScrollbarUnderMouse(Scrollbar*, SetOrClearLastScrollbar);
475
476 void setFrameWasScrolledByUser();
477
478 bool capturesDragging() const { return m_capturesDragging; }
479
480#if PLATFORM(COCOA) && defined(__OBJC__)
481 NSView *mouseDownViewIfStillGood();
482
483 PlatformMouseEvent currentPlatformMouseEvent() const;
484#endif
485
486#if ENABLE(FULLSCREEN_API)
487 bool isKeyEventAllowedInFullScreen(const PlatformKeyboardEvent&) const;
488#endif
489
490 void setLastKnownMousePosition(const PlatformMouseEvent&);
491
492#if ENABLE(CURSOR_VISIBILITY)
493 void startAutoHideCursorTimer();
494 void cancelAutoHideCursorTimer();
495 void autoHideCursorTimerFired();
496#endif
497
498 void clearOrScheduleClearingLatchedStateIfNeeded(const PlatformWheelEvent&);
499 void clearLatchedState();
500
501 bool shouldSendMouseEventsToInactiveWindows() const;
502
503 Frame& m_frame;
504
505 bool m_mousePressed { false };
506 bool m_capturesDragging { false };
507 RefPtr<Node> m_mousePressNode;
508
509 bool m_mouseDownMayStartSelect { false };
510
511#if ENABLE(DRAG_SUPPORT)
512 bool m_mouseDownMayStartDrag { false };
513 bool m_dragMayStartSelectionInstead { false };
514#endif
515
516 bool m_mouseDownWasSingleClickInSelection { false };
517 enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };
518 SelectionInitiationState m_selectionInitiationState { HaveNotStartedSelection };
519
520#if ENABLE(DRAG_SUPPORT)
521 LayoutPoint m_dragStartPosition;
522#endif
523
524 Timer m_hoverTimer;
525
526#if ENABLE(CURSOR_SUPPORT)
527 Timer m_cursorUpdateTimer;
528#endif
529
530#if PLATFORM(MAC)
531 Timer m_pendingMomentumWheelEventsTimer;
532#endif
533
534 std::unique_ptr<AutoscrollController> m_autoscrollController;
535 bool m_mouseDownMayStartAutoscroll { false };
536 bool m_mouseDownWasInSubframe { false };
537
538#if !ENABLE(IOS_TOUCH_EVENTS)
539 Timer m_fakeMouseMoveEventTimer;
540#endif
541
542 bool m_svgPan { false };
543
544 RenderLayer* m_resizeLayer { nullptr };
545
546 RefPtr<Element> m_capturingMouseEventsElement;
547 bool m_eventHandlerWillResetCapturingMouseEventsElement { false };
548
549 RefPtr<Element> m_elementUnderMouse;
550 RefPtr<Element> m_lastElementUnderMouse;
551 RefPtr<Frame> m_lastMouseMoveEventSubframe;
552 WeakPtr<Scrollbar> m_lastScrollbarUnderMouse;
553 Cursor m_currentMouseCursor;
554
555 int m_clickCount { 0 };
556 RefPtr<Node> m_clickNode;
557
558#if ENABLE(IOS_GESTURE_EVENTS)
559 float m_gestureInitialDiameter { GestureUnknown };
560 float m_gestureInitialRotation { GestureUnknown };
561#endif
562
563#if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
564 float m_gestureLastDiameter { GestureUnknown };
565 float m_gestureLastRotation { GestureUnknown };
566 EventTargetSet m_gestureTargets;
567#endif
568
569#if ENABLE(MAC_GESTURE_EVENTS)
570 bool m_hasActiveGesture { false };
571#endif
572
573#if ENABLE(IOS_TOUCH_EVENTS)
574 unsigned m_firstTouchID { InvalidTouchIdentifier };
575
576 TouchArray m_touches;
577 RefPtr<Frame> m_touchEventTargetSubframe;
578#endif
579
580#if ENABLE(DRAG_SUPPORT)
581 RefPtr<Element> m_dragTarget;
582 bool m_shouldOnlyFireDragOverEvent { false };
583#endif
584
585 RefPtr<HTMLFrameSetElement> m_frameSetBeingResized;
586
587 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeLayer.
588
589 bool m_mousePositionIsUnknown { true };
590 IntPoint m_lastKnownMousePosition;
591 IntPoint m_lastKnownMouseGlobalPosition;
592 IntPoint m_mouseDownPos; // In our view's coords.
593 WallTime m_mouseDownTimestamp;
594 PlatformMouseEvent m_mouseDown;
595
596#if PLATFORM(COCOA)
597 NSView *m_mouseDownView { nullptr };
598 bool m_sendingEventToSubview { false };
599#endif
600
601#if PLATFORM(MAC)
602 int m_activationEventNumber { -1 };
603#endif
604
605#if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
606 using TouchTargetMap = HashMap<int, RefPtr<EventTarget>>;
607 TouchTargetMap m_originatingTouchPointTargets;
608 RefPtr<Document> m_originatingTouchPointDocument;
609 unsigned m_originatingTouchPointTargetKey { 0 };
610 bool m_touchPressed { false };
611#endif
612
613#if ENABLE(IOS_TOUCH_EVENTS)
614 unsigned touchIdentifierForMouseEvents { 0 };
615#endif
616
617#if ENABLE(POINTER_EVENTS) && ENABLE(IOS_TOUCH_EVENTS)
618 unsigned m_touchIdentifierForPrimaryTouch { 0 };
619#endif
620
621 double m_maxMouseMovedDuration { 0 };
622 bool m_didStartDrag { false };
623 bool m_isHandlingWheelEvent { false };
624
625#if PLATFORM(IOS_FAMILY)
626 bool m_shouldAllowMouseDownToStartDrag { false };
627#endif
628
629#if ENABLE(CURSOR_VISIBILITY)
630 Timer m_autoHideCursorTimer;
631#endif
632
633 ImmediateActionStage m_immediateActionStage { ImmediateActionStage::None };
634};
635
636} // namespace WebCore
637