summaryrefslogtreecommitdiff
path: root/Source/WebCore/page/EventHandler.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/page/EventHandler.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/page/EventHandler.h')
-rw-r--r--Source/WebCore/page/EventHandler.h422
1 files changed, 229 insertions, 193 deletions
diff --git a/Source/WebCore/page/EventHandler.h b/Source/WebCore/page/EventHandler.h
index 387876f02..1ec5eed7a 100644
--- a/Source/WebCore/page/EventHandler.h
+++ b/Source/WebCore/page/EventHandler.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,10 +10,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -23,8 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef EventHandler_h
-#define EventHandler_h
+#pragma once
#include "Cursor.h"
#include "DragActions.h"
@@ -32,58 +31,51 @@
#include "HitTestRequest.h"
#include "LayoutPoint.h"
#include "PlatformMouseEvent.h"
-#include "PlatformWheelEvent.h"
#include "ScrollTypes.h"
#include "TextEventInputType.h"
#include "TextGranularity.h"
#include "Timer.h"
-#include <wtf/Deque.h>
+#include <memory>
#include <wtf/Forward.h>
-#include <wtf/OwnPtr.h>
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
#include <wtf/RefPtr.h>
#include <wtf/WeakPtr.h>
-#if PLATFORM(IOS)
-#ifdef __OBJC__
-@class WebEvent;
-@class WAKView;
-#include "WAKAppKitStubs.h"
-#else
-class WebEvent;
+#if PLATFORM(COCOA)
+OBJC_CLASS NSView;
#endif
-#endif // PLATFORM(IOS)
-#if PLATFORM(MAC) && !defined(__OBJC__)
-class NSView;
+#if PLATFORM(IOS)
+OBJC_CLASS WebEvent;
#endif
-#if ENABLE(TOUCH_EVENTS)
-#include <wtf/HashMap.h>
+#if PLATFORM(MAC)
+OBJC_CLASS NSEvent;
#endif
-#if ENABLE(IOS_TOUCH_EVENTS)
-#include <wtf/HashSet.h>
-#include <wtf/Vector.h>
+#if PLATFORM(IOS) && defined(__OBJC__)
+#include "WAKAppKitStubs.h"
#endif
namespace WebCore {
class AutoscrollController;
-class Clipboard;
+class ContainerNode;
+class DataTransfer;
class Document;
class Element;
class Event;
class EventTarget;
-class FloatPoint;
class FloatQuad;
class Frame;
+class FrameView;
class HTMLFrameSetElement;
-class HitTestRequest;
class HitTestResult;
class KeyboardEvent;
class MouseEventWithHitTestResults;
class Node;
-class OptionalCursor;
+class PlatformGestureEvent;
class PlatformKeyboardEvent;
class PlatformTouchEvent;
class PlatformWheelEvent;
@@ -91,7 +83,7 @@ class RenderBox;
class RenderElement;
class RenderLayer;
class RenderWidget;
-class SVGElementInstance;
+class ScrollableArea;
class Scrollbar;
class TextEvent;
class Touch;
@@ -107,35 +99,42 @@ extern const int LinkDragHysteresis;
extern const int ImageDragHysteresis;
extern const int TextDragHysteresis;
extern const int GeneralDragHysteresis;
-#endif // ENABLE(DRAG_SUPPORT)
+#endif
-#if ENABLE(IOS_GESTURE_EVENTS)
+#if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
extern const float GestureUnknown;
+extern const unsigned InvalidTouchIdentifier;
#endif
enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace };
enum CheckDragHysteresis { ShouldCheckDragHysteresis, DontCheckDragHysteresis };
+enum class ImmediateActionStage {
+ None,
+ PerformedHitTest,
+ ActionUpdated,
+ ActionCancelledWithoutUpdate,
+ ActionCancelledAfterUpdate,
+ ActionCompleted
+};
+
class EventHandler {
- WTF_MAKE_NONCOPYABLE(EventHandler);
+ WTF_MAKE_FAST_ALLOCATED;
public:
explicit EventHandler(Frame&);
~EventHandler();
void clear();
- void nodeWillBeRemoved(Node*);
+ void nodeWillBeRemoved(Node&);
#if ENABLE(DRAG_SUPPORT)
void updateSelectionForMouseDrag();
#endif
- Node* mousePressNode() const;
- void setMousePressNode(PassRefPtr<Node>);
-
#if ENABLE(PAN_SCROLLING)
void didPanScrollStart();
void didPanScrollStop();
- void startPanScrolling(RenderElement*);
+ void startPanScrolling(RenderElement&);
#endif
void stopAutoscrollTimer(bool rendererIsBeingDestroyed = false);
@@ -145,23 +144,23 @@ public:
bool mouseDownWasInSubframe() const { return m_mouseDownWasInSubframe; }
bool panScrollInProgress() const;
- void dispatchFakeMouseMoveEventSoon();
+ WEBCORE_EXPORT void dispatchFakeMouseMoveEventSoon();
void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
- HitTestResult hitTestResultAtPoint(const LayoutPoint&,
- HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent,
+ WEBCORE_EXPORT HitTestResult hitTestResultAtPoint(const LayoutPoint&,
+ HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowUserAgentShadowContent,
const LayoutSize& padding = LayoutSize());
bool mousePressed() const { return m_mousePressed; }
- void setMousePressed(bool pressed) { m_mousePressed = pressed; }
+ Node* mousePressNode() const { return m_mousePressNode.get(); }
- void setCapturingMouseEventsElement(PassRefPtr<Element>); // A caller is responsible for resetting capturing element to 0.
+ WEBCORE_EXPORT void setCapturingMouseEventsElement(Element*);
#if ENABLE(DRAG_SUPPORT)
- bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*);
- void cancelDragAndDrop(const PlatformMouseEvent&, Clipboard*);
- bool performDragAndDrop(const PlatformMouseEvent&, Clipboard*);
- void updateDragStateAfterEditDragIfNeeded(Element* rootEditableElement);
+ bool updateDragAndDrop(const PlatformMouseEvent&, DataTransfer&);
+ void cancelDragAndDrop(const PlatformMouseEvent&, DataTransfer&);
+ bool performDragAndDrop(const PlatformMouseEvent&, DataTransfer&);
+ void updateDragStateAfterEditDragIfNeeded(Element& rootEditableElement);
#endif
void scheduleHoverStateUpdate();
@@ -174,120 +173,136 @@ public:
void resizeLayerDestroyed();
IntPoint lastKnownMousePosition() const;
+ IntPoint lastKnownMouseGlobalPosition() const { return m_lastKnownMouseGlobalPosition; }
Cursor currentMouseCursor() const { return m_currentMouseCursor; }
+ IntPoint effectiveMousePositionForSelectionAutoscroll() const;
+
static Frame* subframeForTargetNode(Node*);
static Frame* subframeForHitTestResult(const MouseEventWithHitTestResults&);
- bool scrollOverflow(ScrollDirection, ScrollGranularity, Node* startingNode = 0);
- bool scrollRecursively(ScrollDirection, ScrollGranularity, Node* startingNode = 0);
- bool logicalScrollRecursively(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = 0);
+ WEBCORE_EXPORT bool scrollOverflow(ScrollDirection, ScrollGranularity, Node* startingNode = nullptr);
+ WEBCORE_EXPORT bool scrollRecursively(ScrollDirection, ScrollGranularity, Node* startingNode = nullptr);
+ WEBCORE_EXPORT bool logicalScrollRecursively(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = nullptr);
- bool tabsToLinks(KeyboardEvent*) const;
- bool tabsToAllFormControls(KeyboardEvent*) const;
+ bool tabsToLinks(KeyboardEvent&) const;
+ bool tabsToAllFormControls(KeyboardEvent&) const;
- bool mouseMoved(const PlatformMouseEvent&);
- bool passMouseMovedEventToScrollbars(const PlatformMouseEvent&);
+ WEBCORE_EXPORT bool mouseMoved(const PlatformMouseEvent&);
+ WEBCORE_EXPORT bool passMouseMovedEventToScrollbars(const PlatformMouseEvent&);
void lostMouseCapture();
- bool handleMousePressEvent(const PlatformMouseEvent&);
- bool handleMouseMoveEvent(const PlatformMouseEvent&, HitTestResult* hoveredNode = 0, bool onlyUpdateScrollbars = false);
- bool handleMouseReleaseEvent(const PlatformMouseEvent&);
- bool handleWheelEvent(const PlatformWheelEvent&);
- void defaultWheelEventHandler(Node*, WheelEvent*);
+ WEBCORE_EXPORT bool handleMousePressEvent(const PlatformMouseEvent&);
+ bool handleMouseMoveEvent(const PlatformMouseEvent&, HitTestResult* hoveredNode = nullptr, bool onlyUpdateScrollbars = false);
+ WEBCORE_EXPORT bool handleMouseReleaseEvent(const PlatformMouseEvent&);
+ bool handleMouseForceEvent(const PlatformMouseEvent&);
+ WEBCORE_EXPORT bool handleWheelEvent(const PlatformWheelEvent&);
+ void defaultWheelEventHandler(Node*, WheelEvent&);
bool handlePasteGlobalSelection(const PlatformMouseEvent&);
+ void platformPrepareForWheelEvents(const PlatformWheelEvent&, const HitTestResult&, RefPtr<Element>& eventTarget, RefPtr<ContainerNode>& scrollableContainer, WeakPtr<ScrollableArea>&, bool& isOverWidget);
+ void platformRecordWheelEvent(const PlatformWheelEvent&);
+ bool platformCompleteWheelEvent(const PlatformWheelEvent&, ContainerNode* scrollableContainer, const WeakPtr<ScrollableArea>&);
+ bool platformCompletePlatformWidgetWheelEvent(const PlatformWheelEvent&, const Widget&, ContainerNode* scrollableContainer);
+ void platformNotifyIfEndGesture(const PlatformWheelEvent&, const WeakPtr<ScrollableArea>&);
+
#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
- typedef Vector<RefPtr<Touch>> TouchArray;
- typedef HashMap<EventTarget*, TouchArray*> EventTargetTouchMap;
- typedef HashSet<RefPtr<EventTarget>> EventTargetSet;
+ using TouchArray = Vector<RefPtr<Touch>>;
+ using EventTargetTouchMap = HashMap<EventTarget*, TouchArray*>;
+#endif
+
+#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
+ using EventTargetSet = HashSet<RefPtr<EventTarget>>;
#endif
#if ENABLE(IOS_TOUCH_EVENTS)
bool dispatchTouchEvent(const PlatformTouchEvent&, const AtomicString&, const EventTargetTouchMap&, float, float);
+ bool dispatchSimulatedTouchEvent(IntPoint location);
#endif
#if ENABLE(IOS_GESTURE_EVENTS)
bool dispatchGestureEvent(const PlatformTouchEvent&, const AtomicString&, const EventTargetSet&, float, float);
+#elif ENABLE(MAC_GESTURE_EVENTS)
+ bool dispatchGestureEvent(const PlatformGestureEvent&, const AtomicString&, const EventTargetSet&, float, float);
+ WEBCORE_EXPORT bool handleGestureEvent(const PlatformGestureEvent&);
#endif
#if PLATFORM(IOS)
- void defaultTouchEventHandler(Node*, TouchEvent*);
+ void defaultTouchEventHandler(Node&, TouchEvent&);
#endif
#if ENABLE(CONTEXT_MENUS)
- bool sendContextMenuEvent(const PlatformMouseEvent&);
- bool sendContextMenuEventForKey();
+ WEBCORE_EXPORT bool sendContextMenuEvent(const PlatformMouseEvent&);
+ WEBCORE_EXPORT bool sendContextMenuEventForKey();
#endif
void setMouseDownMayStartAutoscroll() { m_mouseDownMayStartAutoscroll = true; }
bool needsKeyboardEventDisambiguationQuirks() const;
- static unsigned accessKeyModifiers();
- bool handleAccessKey(const PlatformKeyboardEvent&);
- bool keyEvent(const PlatformKeyboardEvent&);
- void defaultKeyboardEventHandler(KeyboardEvent*);
+ WEBCORE_EXPORT static OptionSet<PlatformEvent::Modifier> accessKeyModifiers();
+ WEBCORE_EXPORT bool handleAccessKey(const PlatformKeyboardEvent&);
+ WEBCORE_EXPORT bool keyEvent(const PlatformKeyboardEvent&);
+ void defaultKeyboardEventHandler(KeyboardEvent&);
- void handleKeyboardSelectionMovementForAccessibility(KeyboardEvent*);
+ bool accessibilityPreventsEventPropogation(KeyboardEvent&);
+ WEBCORE_EXPORT void handleKeyboardSelectionMovementForAccessibility(KeyboardEvent&);
- bool handleTextInputEvent(const String& text, Event* underlyingEvent = 0, TextEventInputType = TextEventInputKeyboard);
- void defaultTextInputEventHandler(TextEvent*);
+ bool handleTextInputEvent(const String& text, Event* underlyingEvent = nullptr, TextEventInputType = TextEventInputKeyboard);
+ void defaultTextInputEventHandler(TextEvent&);
#if ENABLE(DRAG_SUPPORT)
- bool eventMayStartDrag(const PlatformMouseEvent&) const;
+ WEBCORE_EXPORT bool eventMayStartDrag(const PlatformMouseEvent&) const;
- void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation);
+ WEBCORE_EXPORT void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation);
#endif
void focusDocumentView();
-
- void capsLockStateMayHaveChanged(); // Only called by FrameSelection
- void sendScrollEvent(); // Ditto
+ WEBCORE_EXPORT void sendScrollEvent();
-#if PLATFORM(MAC) && defined(__OBJC__)
-#if !PLATFORM(IOS)
- void mouseDown(NSEvent *);
- void mouseDragged(NSEvent *);
- void mouseUp(NSEvent *);
- void mouseMoved(NSEvent *);
- bool keyEvent(NSEvent *);
- bool wheelEvent(NSEvent *);
-#else
- void mouseDown(WebEvent *);
- void mouseUp(WebEvent *);
- void mouseMoved(WebEvent *);
- bool keyEvent(WebEvent *);
- bool wheelEvent(WebEvent *);
+#if PLATFORM(MAC)
+ WEBCORE_EXPORT void mouseDown(NSEvent *, NSEvent *correspondingPressureEvent);
+ WEBCORE_EXPORT void mouseDragged(NSEvent *, NSEvent *correspondingPressureEvent);
+ WEBCORE_EXPORT void mouseUp(NSEvent *, NSEvent *correspondingPressureEvent);
+ WEBCORE_EXPORT void mouseMoved(NSEvent *, NSEvent *correspondingPressureEvent);
+ WEBCORE_EXPORT void pressureChange(NSEvent *, NSEvent* correspondingPressureEvent);
+ WEBCORE_EXPORT bool keyEvent(NSEvent *);
+ WEBCORE_EXPORT bool wheelEvent(NSEvent *);
+#endif
+
+#if PLATFORM(IOS)
+ WEBCORE_EXPORT void mouseDown(WebEvent *);
+ WEBCORE_EXPORT void mouseUp(WebEvent *);
+ WEBCORE_EXPORT void mouseMoved(WebEvent *);
+ WEBCORE_EXPORT bool keyEvent(WebEvent *);
+ WEBCORE_EXPORT bool wheelEvent(WebEvent *);
#endif
#if ENABLE(IOS_TOUCH_EVENTS)
- void touchEvent(WebEvent *);
+ WEBCORE_EXPORT void touchEvent(WebEvent *);
#endif
-#if !PLATFORM(IOS)
- void passMouseMovedEventToScrollbars(NSEvent *);
+#if PLATFORM(MAC)
+ WEBCORE_EXPORT void passMouseMovedEventToScrollbars(NSEvent *, NSEvent* correspondingPressureEvent);
- void sendFakeEventsAfterWidgetTracking(NSEvent *initiatingEvent);
-#endif
+ WEBCORE_EXPORT void sendFakeEventsAfterWidgetTracking(NSEvent *initiatingEvent);
-#if !PLATFORM(IOS)
void setActivationEventNumber(int num) { m_activationEventNumber = num; }
- static NSEvent *currentNSEvent();
-#else
- static WebEvent *currentEvent();
-#endif // !PLATFORM(IOS)
-#endif // PLATFORM(MAC) && defined(__OBJC__)
+ WEBCORE_EXPORT static NSEvent *currentNSEvent();
+ static NSEvent *correspondingPressureEvent();
+#endif
#if PLATFORM(IOS)
+ static WebEvent *currentEvent();
+
void invalidateClick();
#endif
#if ENABLE(TOUCH_EVENTS)
- bool handleTouchEvent(const PlatformTouchEvent&);
+ WEBCORE_EXPORT bool handleTouchEvent(const PlatformTouchEvent&);
#endif
bool useHandCursor(Node*, bool isOverLink, bool shiftKey);
@@ -295,56 +310,67 @@ public:
bool isHandlingWheelEvent() const { return m_isHandlingWheelEvent; }
+ WEBCORE_EXPORT void setImmediateActionStage(ImmediateActionStage stage);
+ ImmediateActionStage immediateActionStage() const { return m_immediateActionStage; }
+
+ static Widget* widgetForEventTarget(Element* eventTarget);
+
+#if ENABLE(DATA_INTERACTION)
+ WEBCORE_EXPORT bool tryToBeginDataInteractionAtPoint(const IntPoint& clientPosition, const IntPoint& globalPosition);
+#endif
+
private:
#if ENABLE(DRAG_SUPPORT)
static DragState& dragState();
static const double TextDragDelay;
-
- PassRefPtr<Clipboard> createDraggingClipboard() const;
-#endif // ENABLE(DRAG_SUPPORT)
+ Ref<DataTransfer> createDraggingDataTransfer() const;
+#endif
bool eventActivatedView(const PlatformMouseEvent&) const;
bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleSelection&, TextGranularity);
void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
+ VisibleSelection selectClosestWordFromHitTestResultBasedOnLookup(const HitTestResult&);
void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&);
- void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults&);
+ void selectClosestContextualWordFromMouseEvent(const MouseEventWithHitTestResults&);
+ void selectClosestContextualWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults&);
bool handleMouseDoubleClickEvent(const PlatformMouseEvent&);
- bool handleMousePressEvent(const MouseEventWithHitTestResults&);
+ WEBCORE_EXPORT bool handleMousePressEvent(const MouseEventWithHitTestResults&);
bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
+
#if ENABLE(DRAG_SUPPORT)
- bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&);
+ bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&, CheckDragHysteresis = ShouldCheckDragHysteresis);
#endif
- bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
- OptionalCursor selectCursor(const HitTestResult&, bool shiftKey);
+ WEBCORE_EXPORT bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
+
+ bool internalKeyEvent(const PlatformKeyboardEvent&);
+
+ std::optional<Cursor> selectCursor(const HitTestResult&, bool shiftKey);
+ void updateCursor(FrameView&, const HitTestResult&, bool shiftKey);
+
+ void hoverTimerFired();
- void hoverTimerFired(Timer<EventHandler>&);
#if ENABLE(CURSOR_SUPPORT)
- void cursorUpdateTimerFired(Timer<EventHandler>&);
+ void cursorUpdateTimerFired();
#endif
- bool logicalScrollOverflow(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = 0);
+ bool logicalScrollOverflow(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = nullptr);
bool shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&, const PlatformWheelEvent&) const;
- void recordWheelEventDelta(const PlatformWheelEvent&);
- enum DominantScrollGestureDirection {
- DominantScrollDirectionNone,
- DominantScrollDirectionVertical,
- DominantScrollDirectionHorizontal
- };
- DominantScrollGestureDirection dominantScrollGestureDirection() const;
bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; }
- static bool isKeyboardOptionTab(KeyboardEvent*);
- static bool eventInvertsTabsToLinksClientCallResult(KeyboardEvent*);
+ static bool isKeyboardOptionTab(KeyboardEvent&);
+ static bool eventInvertsTabsToLinksClientCallResult(KeyboardEvent&);
- void fakeMouseMoveEventTimerFired(Timer<EventHandler>&);
+#if !ENABLE(IOS_TOUCH_EVENTS)
+ void fakeMouseMoveEventTimerFired();
void cancelFakeMouseMoveEvent();
+#endif
bool isInsideScrollbar(const IntPoint&) const;
@@ -364,14 +390,16 @@ private:
MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&);
bool dispatchMouseEvent(const AtomicString& eventType, Node* target, bool cancelable, int clickCount, const PlatformMouseEvent&, bool setUnder);
-#if ENABLE(DRAG_SUPPORT)
- bool dispatchDragEvent(const AtomicString& eventType, Element& target, const PlatformMouseEvent&, Clipboard*);
- void freeClipboard();
+#if ENABLE(DRAG_SUPPORT)
+ bool dispatchDragEvent(const AtomicString& eventType, Element& target, const PlatformMouseEvent&, DataTransfer*);
+ void invalidateDataTransfer();
bool handleDrag(const MouseEventWithHitTestResults&, CheckDragHysteresis);
#endif
+
bool handleMouseUp(const MouseEventWithHitTestResults&);
+
#if ENABLE(DRAG_SUPPORT)
void clearDragState();
@@ -379,13 +407,15 @@ private:
bool dragHysteresisExceeded(const FloatPoint&) const;
bool dragHysteresisExceeded(const IntPoint&) const;
-#endif // ENABLE(DRAG_SUPPORT)
+#endif
+
+ bool mouseMovementExceedsThreshold(const FloatPoint&, int pointsThreshold) const;
bool passMousePressEventToSubframe(MouseEventWithHitTestResults&, Frame* subframe);
- bool passMouseMoveEventToSubframe(MouseEventWithHitTestResults&, Frame* subframe, HitTestResult* hoveredNode = 0);
+ bool passMouseMoveEventToSubframe(MouseEventWithHitTestResults&, Frame* subframe, HitTestResult* hoveredNode = nullptr);
bool passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&, Frame* subframe);
- bool passSubframeEventToSubframe(MouseEventWithHitTestResults&, Frame* subframe, HitTestResult* hoveredNode = 0);
+ bool passSubframeEventToSubframe(MouseEventWithHitTestResults&, Frame* subframe, HitTestResult* hoveredNode = nullptr);
bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&, Scrollbar*);
@@ -393,12 +423,13 @@ private:
bool passWidgetMouseDownEventToWidget(RenderWidget*);
bool passMouseDownEventToWidget(Widget*);
- bool passWheelEventToWidget(const PlatformWheelEvent&, Widget*);
+ bool widgetDidHandleWheelEvent(const PlatformWheelEvent&, Widget&);
+ bool completeWidgetWheelEvent(const PlatformWheelEvent&, const WeakPtr<Widget>&, const WeakPtr<ScrollableArea>&, ContainerNode*);
- void defaultSpaceEventHandler(KeyboardEvent*);
- void defaultBackspaceEventHandler(KeyboardEvent*);
- void defaultTabEventHandler(KeyboardEvent*);
- void defaultArrowEventHandler(FocusDirection, KeyboardEvent*);
+ void defaultSpaceEventHandler(KeyboardEvent&);
+ void defaultBackspaceEventHandler(KeyboardEvent&);
+ void defaultTabEventHandler(KeyboardEvent&);
+ void defaultArrowEventHandler(FocusDirection, KeyboardEvent&);
#if ENABLE(DRAG_SUPPORT)
DragSourceAction updateDragSourceActionsAllowed() const;
@@ -407,21 +438,20 @@ private:
// The following are called at the beginning of handleMouseUp and handleDrag.
// If they return true it indicates that they have consumed the event.
bool eventLoopHandleMouseUp(const MouseEventWithHitTestResults&);
-#if ENABLE(DRAG_SUPPORT)
- bool eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&);
-#endif
#if ENABLE(DRAG_SUPPORT)
+ bool eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&);
void updateSelectionForMouseDrag(const HitTestResult&);
#endif
- void updateLastScrollbarUnderMouse(Scrollbar*, bool);
+ enum class SetOrClearLastScrollbar { Clear, Set };
+ void updateLastScrollbarUnderMouse(Scrollbar*, SetOrClearLastScrollbar);
void setFrameWasScrolledByUser();
bool capturesDragging() const { return m_capturesDragging; }
-#if PLATFORM(MAC) && defined(__OBJC__)
+#if PLATFORM(COCOA) && defined(__OBJC__)
NSView *mouseDownViewIfStillGood();
PlatformMouseEvent currentPlatformMouseEvent() const;
@@ -436,51 +466,57 @@ private:
#if ENABLE(CURSOR_VISIBILITY)
void startAutoHideCursorTimer();
void cancelAutoHideCursorTimer();
- void autoHideCursorTimerFired(Timer<EventHandler>&);
+ void autoHideCursorTimerFired();
#endif
+ void clearOrScheduleClearingLatchedStateIfNeeded(const PlatformWheelEvent&);
+ void clearLatchedState();
+
Frame& m_frame;
- bool m_mousePressed;
- bool m_capturesDragging;
+ bool m_mousePressed { false };
+ bool m_capturesDragging { false };
RefPtr<Node> m_mousePressNode;
- bool m_mouseDownMayStartSelect;
+ bool m_mouseDownMayStartSelect { false };
+
#if ENABLE(DRAG_SUPPORT)
- bool m_mouseDownMayStartDrag;
- bool m_dragMayStartSelectionInstead;
+ bool m_mouseDownMayStartDrag { false };
+ bool m_dragMayStartSelectionInstead { false };
#endif
- bool m_mouseDownWasSingleClickInSelection;
+
+ bool m_mouseDownWasSingleClickInSelection { false };
enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };
- SelectionInitiationState m_selectionInitiationState;
+ SelectionInitiationState m_selectionInitiationState { HaveNotStartedSelection };
#if ENABLE(DRAG_SUPPORT)
- LayoutPoint m_dragStartPos;
+ LayoutPoint m_dragStartPosition;
#endif
- bool m_panScrollButtonPressed;
+ Timer m_hoverTimer;
- Timer<EventHandler> m_hoverTimer;
#if ENABLE(CURSOR_SUPPORT)
- Timer<EventHandler> m_cursorUpdateTimer;
+ Timer m_cursorUpdateTimer;
#endif
- OwnPtr<AutoscrollController> m_autoscrollController;
- bool m_mouseDownMayStartAutoscroll;
- bool m_mouseDownWasInSubframe;
+#if PLATFORM(MAC)
+ Timer m_pendingMomentumWheelEventsTimer;
+#endif
- Timer<EventHandler> m_fakeMouseMoveEventTimer;
+ std::unique_ptr<AutoscrollController> m_autoscrollController;
+ bool m_mouseDownMayStartAutoscroll { false };
+ bool m_mouseDownWasInSubframe { false };
-#if ENABLE(SVG)
- bool m_svgPan;
- RefPtr<SVGElementInstance> m_instanceUnderMouse;
- RefPtr<SVGElementInstance> m_lastInstanceUnderMouse;
+#if !ENABLE(IOS_TOUCH_EVENTS)
+ Timer m_fakeMouseMoveEventTimer;
#endif
- RenderLayer* m_resizeLayer;
+ bool m_svgPan { false };
+
+ RenderLayer* m_resizeLayer { nullptr };
RefPtr<Element> m_capturingMouseEventsElement;
- bool m_eventHandlerWillResetCapturingMouseEventsElement;
+ bool m_eventHandlerWillResetCapturingMouseEventsElement { false };
RefPtr<Element> m_elementUnderMouse;
RefPtr<Element> m_lastElementUnderMouse;
@@ -488,73 +524,73 @@ private:
WeakPtr<Scrollbar> m_lastScrollbarUnderMouse;
Cursor m_currentMouseCursor;
- int m_clickCount;
+ int m_clickCount { 0 };
RefPtr<Node> m_clickNode;
#if ENABLE(IOS_GESTURE_EVENTS)
- float m_gestureInitialDiameter;
- float m_gestureLastDiameter;
- float m_gestureInitialRotation;
- float m_gestureLastRotation;
+ float m_gestureInitialDiameter { GestureUnknown };
+ float m_gestureInitialRotation { GestureUnknown };
+#endif
+
+#if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
+ float m_gestureLastDiameter { GestureUnknown };
+ float m_gestureLastRotation { GestureUnknown };
+ EventTargetSet m_gestureTargets;
+#endif
+
+#if ENABLE(MAC_GESTURE_EVENTS)
+ bool m_hasActiveGesture { false };
#endif
#if ENABLE(IOS_TOUCH_EVENTS)
- unsigned m_firstTouchID;
+ unsigned m_firstTouchID { InvalidTouchIdentifier };
TouchArray m_touches;
- EventTargetSet m_gestureTargets;
RefPtr<Frame> m_touchEventTargetSubframe;
#endif
#if ENABLE(DRAG_SUPPORT)
RefPtr<Element> m_dragTarget;
- bool m_shouldOnlyFireDragOverEvent;
+ bool m_shouldOnlyFireDragOverEvent { false };
#endif
RefPtr<HTMLFrameSetElement> m_frameSetBeingResized;
LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeLayer.
- bool m_mousePositionIsUnknown;
+ bool m_mousePositionIsUnknown { true };
IntPoint m_lastKnownMousePosition;
IntPoint m_lastKnownMouseGlobalPosition;
IntPoint m_mouseDownPos; // In our view's coords.
- double m_mouseDownTimestamp;
+ double m_mouseDownTimestamp { 0 };
PlatformMouseEvent m_mouseDown;
- Deque<FloatSize> m_recentWheelEventDeltas;
- RefPtr<Element> m_latchedWheelEventElement;
- bool m_inTrackingScrollGesturePhase;
- bool m_widgetIsLatched;
-
- RefPtr<Element> m_previousWheelScrolledElement;
-
-#if PLATFORM(MAC) || PLATFORM(IOS)
- NSView *m_mouseDownView;
- bool m_sendingEventToSubview;
-#if !PLATFORM(IOS)
- int m_activationEventNumber;
+#if PLATFORM(COCOA)
+ NSView *m_mouseDownView { nullptr };
+ bool m_sendingEventToSubview { false };
#endif
+
+#if PLATFORM(MAC)
+ int m_activationEventNumber { -1 };
#endif
+
#if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
- typedef HashMap<int, RefPtr<EventTarget>> TouchTargetMap;
+ using TouchTargetMap = HashMap<int, RefPtr<EventTarget>>;
TouchTargetMap m_originatingTouchPointTargets;
RefPtr<Document> m_originatingTouchPointDocument;
- unsigned m_originatingTouchPointTargetKey;
- bool m_touchPressed;
+ unsigned m_originatingTouchPointTargetKey { 0 };
+ bool m_touchPressed { false };
#endif
- double m_maxMouseMovedDuration;
- PlatformEvent::Type m_baseEventType;
- bool m_didStartDrag;
- bool m_didLongPressInvokeContextMenu;
- bool m_isHandlingWheelEvent;
+ double m_maxMouseMovedDuration { 0 };
+ bool m_didStartDrag { false };
+ bool m_isHandlingWheelEvent { false };
#if ENABLE(CURSOR_VISIBILITY)
- Timer<EventHandler> m_autoHideCursorTimer;
+ Timer m_autoHideCursorTimer;
#endif
+
+ ImmediateActionStage m_immediateActionStage { ImmediateActionStage::None };
};
} // namespace WebCore
-
-#endif // EventHandler_h