| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 class ScrollableArea; | 79 class ScrollableArea; |
| 80 class Scrollbar; | 80 class Scrollbar; |
| 81 class ScrollState; | 81 class ScrollState; |
| 82 class SelectionController; | 82 class SelectionController; |
| 83 class TextEvent; | 83 class TextEvent; |
| 84 class WheelEvent; | 84 class WheelEvent; |
| 85 class Widget; | 85 class Widget; |
| 86 | 86 |
| 87 enum class DragInitiator; | 87 enum class DragInitiator; |
| 88 | 88 |
| 89 class CORE_EXPORT EventHandler final : public NoBaseWillBeGarbageCollectedFinali
zed<EventHandler> { | 89 class CORE_EXPORT EventHandler final : public GarbageCollectedFinalized<EventHan
dler> { |
| 90 WTF_MAKE_NONCOPYABLE(EventHandler); | 90 WTF_MAKE_NONCOPYABLE(EventHandler); |
| 91 USING_FAST_MALLOC_WILL_BE_REMOVED(EventHandler); | |
| 92 public: | 91 public: |
| 93 explicit EventHandler(LocalFrame*); | 92 explicit EventHandler(LocalFrame*); |
| 94 ~EventHandler(); | 93 ~EventHandler(); |
| 95 DECLARE_TRACE(); | 94 DECLARE_TRACE(); |
| 96 | 95 |
| 97 void clear(); | 96 void clear(); |
| 98 void nodeWillBeRemoved(Node&); | 97 void nodeWillBeRemoved(Node&); |
| 99 | 98 |
| 100 void updateSelectionForMouseDrag(); | 99 void updateSelectionForMouseDrag(); |
| 101 | 100 |
| 102 #if OS(WIN) | 101 #if OS(WIN) |
| 103 void startPanScrolling(LayoutObject*); | 102 void startPanScrolling(LayoutObject*); |
| 104 #endif | 103 #endif |
| 105 | 104 |
| 106 void stopAutoscroll(); | 105 void stopAutoscroll(); |
| 107 | 106 |
| 108 void dispatchFakeMouseMoveEventSoon(); | 107 void dispatchFakeMouseMoveEventSoon(); |
| 109 void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&); | 108 void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&); |
| 110 | 109 |
| 111 HitTestResult hitTestResultAtPoint(const LayoutPoint&, | 110 HitTestResult hitTestResultAtPoint(const LayoutPoint&, |
| 112 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly |
HitTestRequest::Active, | 111 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly |
HitTestRequest::Active, |
| 113 const LayoutSize& padding = LayoutSize()); | 112 const LayoutSize& padding = LayoutSize()); |
| 114 | 113 |
| 115 bool mousePressed() const { return m_mousePressed; } | 114 bool mousePressed() const { return m_mousePressed; } |
| 116 | 115 |
| 117 void setCapturingMouseEventsNode(PassRefPtrWillBeRawPtr<Node>); // A caller
is responsible for resetting capturing node to 0. | 116 void setCapturingMouseEventsNode(RawPtr<Node>); // A caller is responsible f
or resetting capturing node to 0. |
| 118 | 117 |
| 119 WebInputEventResult updateDragAndDrop(const PlatformMouseEvent&, DataTransfe
r*); | 118 WebInputEventResult updateDragAndDrop(const PlatformMouseEvent&, DataTransfe
r*); |
| 120 void cancelDragAndDrop(const PlatformMouseEvent&, DataTransfer*); | 119 void cancelDragAndDrop(const PlatformMouseEvent&, DataTransfer*); |
| 121 WebInputEventResult performDragAndDrop(const PlatformMouseEvent&, DataTransf
er*); | 120 WebInputEventResult performDragAndDrop(const PlatformMouseEvent&, DataTransf
er*); |
| 122 void updateDragStateAfterEditDragIfNeeded(Element* rootEditableElement); | 121 void updateDragStateAfterEditDragIfNeeded(Element* rootEditableElement); |
| 123 | 122 |
| 124 void scheduleHoverStateUpdate(); | 123 void scheduleHoverStateUpdate(); |
| 125 void scheduleCursorUpdate(); | 124 void scheduleCursorUpdate(); |
| 126 | 125 |
| 127 // Return whether a mouse cursor update is currently pending. Used for test
ing. | 126 // Return whether a mouse cursor update is currently pending. Used for test
ing. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 class TouchInfo { | 206 class TouchInfo { |
| 208 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 207 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 209 public: | 208 public: |
| 210 DEFINE_INLINE_TRACE() | 209 DEFINE_INLINE_TRACE() |
| 211 { | 210 { |
| 212 visitor->trace(touchTarget); | 211 visitor->trace(touchTarget); |
| 213 visitor->trace(targetFrame); | 212 visitor->trace(targetFrame); |
| 214 } | 213 } |
| 215 | 214 |
| 216 PlatformTouchPoint point; | 215 PlatformTouchPoint point; |
| 217 RefPtrWillBeMember<EventTarget> touchTarget; | 216 Member<EventTarget> touchTarget; |
| 218 RefPtrWillBeMember<LocalFrame> targetFrame; | 217 Member<LocalFrame> targetFrame; |
| 219 FloatPoint adjustedPagePoint; | 218 FloatPoint adjustedPagePoint; |
| 220 FloatSize adjustedRadius; | 219 FloatSize adjustedRadius; |
| 221 bool knownTarget; | 220 bool knownTarget; |
| 222 bool consumed; | 221 bool consumed; |
| 223 }; | 222 }; |
| 224 | 223 |
| 225 private: | 224 private: |
| 226 static DragState& dragState(); | 225 static DragState& dragState(); |
| 227 | 226 |
| 228 DataTransfer* createDraggingDataTransfer() const; | 227 DataTransfer* createDraggingDataTransfer() const; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 void handleOverscroll(const ScrollResult&, const FloatPoint& position = Floa
tPoint(), const FloatSize& velocity = FloatSize()); | 276 void handleOverscroll(const ScrollResult&, const FloatPoint& position = Floa
tPoint(), const FloatSize& velocity = FloatSize()); |
| 278 | 277 |
| 279 void customizedScroll(const Node& startNode, ScrollState&); | 278 void customizedScroll(const Node& startNode, ScrollState&); |
| 280 | 279 |
| 281 HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, HitTestR
equest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::
Active); | 280 HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, HitTestR
equest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::
Active); |
| 282 | 281 |
| 283 void invalidateClick(); | 282 void invalidateClick(); |
| 284 | 283 |
| 285 void updateMouseEventTargetNode(Node*, const PlatformMouseEvent&); | 284 void updateMouseEventTargetNode(Node*, const PlatformMouseEvent&); |
| 286 | 285 |
| 287 WebInputEventResult dispatchPointerEvent(EventTarget*, PassRefPtrWillBeRawPt
r<PointerEvent>); | 286 WebInputEventResult dispatchPointerEvent(EventTarget*, RawPtr<PointerEvent>)
; |
| 288 EventTarget* getEffectiveTargetForPointerEvent(EventTarget*, PassRefPtrWillB
eRawPtr<PointerEvent>); | 287 EventTarget* getEffectiveTargetForPointerEvent(EventTarget*, RawPtr<PointerE
vent>); |
| 289 | 288 |
| 290 // Dispatches (pointer|mouse)(over|out|enter|leave) events to the specified
node. | 289 // Dispatches (pointer|mouse)(over|out|enter|leave) events to the specified
node. |
| 291 void sendPointerAndMouseTransitionEvents(Node* target, const AtomicString& m
ouseEventType, | 290 void sendPointerAndMouseTransitionEvents(Node* target, const AtomicString& m
ouseEventType, |
| 292 const PlatformMouseEvent&, Node* relatedTarget, bool checkForListener); | 291 const PlatformMouseEvent&, Node* relatedTarget, bool checkForListener); |
| 293 | 292 |
| 294 // Locates the target nodes in DOM based on the transition and dispatches (p
ointer|mouse)(over|out|enter|leave) events to them. | 293 // Locates the target nodes in DOM based on the transition and dispatches (p
ointer|mouse)(over|out|enter|leave) events to them. |
| 295 void sendNodeTransitionEvents(Node*, Node*, const PlatformMouseEvent&); | 294 void sendNodeTransitionEvents(Node*, Node*, const PlatformMouseEvent&); |
| 296 | 295 |
| 297 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const
PlatformMouseEvent&); | 296 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const
PlatformMouseEvent&); |
| 298 | 297 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 348 |
| 350 void conditionallyEnableMouseEventForPointerTypeMouse(const PlatformMouseEve
nt&); | 349 void conditionallyEnableMouseEventForPointerTypeMouse(const PlatformMouseEve
nt&); |
| 351 | 350 |
| 352 bool shouldTopControlsConsumeScroll(FloatSize) const; | 351 bool shouldTopControlsConsumeScroll(FloatSize) const; |
| 353 | 352 |
| 354 // If the given element is a shadow host and its root has delegatesFocus=fal
se flag, | 353 // If the given element is a shadow host and its root has delegatesFocus=fal
se flag, |
| 355 // slide focus to its inner element. Returns true if the resulting focus is
different from | 354 // slide focus to its inner element. Returns true if the resulting focus is
different from |
| 356 // the given element. | 355 // the given element. |
| 357 bool slideFocusOnShadowHostIfNecessary(const Element&); | 356 bool slideFocusOnShadowHostIfNecessary(const Element&); |
| 358 | 357 |
| 359 void dispatchPointerEvents(const PlatformTouchEvent&, WillBeHeapVector<Touch
Info>&); | 358 void dispatchPointerEvents(const PlatformTouchEvent&, HeapVector<TouchInfo>&
); |
| 360 void sendPointerCancels(WillBeHeapVector<TouchInfo>&); | 359 void sendPointerCancels(HeapVector<TouchInfo>&); |
| 361 | 360 |
| 362 WebInputEventResult dispatchTouchEvents(const PlatformTouchEvent&, WillBeHea
pVector<TouchInfo>&, bool, bool); | 361 WebInputEventResult dispatchTouchEvents(const PlatformTouchEvent&, HeapVecto
r<TouchInfo>&, bool, bool); |
| 363 | 362 |
| 364 // NOTE: If adding a new field to this class please ensure that it is | 363 // NOTE: If adding a new field to this class please ensure that it is |
| 365 // cleared in |EventHandler::clear()|. | 364 // cleared in |EventHandler::clear()|. |
| 366 | 365 |
| 367 const RawPtrWillBeMember<LocalFrame> m_frame; | 366 const Member<LocalFrame> m_frame; |
| 368 | 367 |
| 369 // Current button-press state for mouse/mouse-like-stylus. | 368 // Current button-press state for mouse/mouse-like-stylus. |
| 370 // TODO(crbug.com/563676): Buggy for chorded buttons. | 369 // TODO(crbug.com/563676): Buggy for chorded buttons. |
| 371 bool m_mousePressed; | 370 bool m_mousePressed; |
| 372 | 371 |
| 373 bool m_capturesDragging; | 372 bool m_capturesDragging; |
| 374 RefPtrWillBeMember<Node> m_mousePressNode; | 373 Member<Node> m_mousePressNode; |
| 375 | 374 |
| 376 bool m_mouseDownMayStartDrag; | 375 bool m_mouseDownMayStartDrag; |
| 377 const OwnPtrWillBeMember<SelectionController> m_selectionController; | 376 const Member<SelectionController> m_selectionController; |
| 378 | 377 |
| 379 LayoutPoint m_dragStartPos; | 378 LayoutPoint m_dragStartPos; |
| 380 | 379 |
| 381 Timer<EventHandler> m_hoverTimer; | 380 Timer<EventHandler> m_hoverTimer; |
| 382 | 381 |
| 383 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide
state | 382 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide
state |
| 384 // should move out of EventHandler to a new PageEventHandler class. crbug.co
m/449649 | 383 // should move out of EventHandler to a new PageEventHandler class. crbug.co
m/449649 |
| 385 Timer<EventHandler> m_cursorUpdateTimer; | 384 Timer<EventHandler> m_cursorUpdateTimer; |
| 386 | 385 |
| 387 bool m_mouseDownMayStartAutoscroll; | 386 bool m_mouseDownMayStartAutoscroll; |
| 388 | 387 |
| 389 Timer<EventHandler> m_fakeMouseMoveEventTimer; | 388 Timer<EventHandler> m_fakeMouseMoveEventTimer; |
| 390 | 389 |
| 391 bool m_svgPan; | 390 bool m_svgPan; |
| 392 | 391 |
| 393 RawPtrWillBeMember<PaintLayerScrollableArea> m_resizeScrollableArea; | 392 Member<PaintLayerScrollableArea> m_resizeScrollableArea; |
| 394 | 393 |
| 395 RefPtrWillBeMember<Node> m_capturingMouseEventsNode; | 394 Member<Node> m_capturingMouseEventsNode; |
| 396 bool m_eventHandlerWillResetCapturingMouseEventsNode; | 395 bool m_eventHandlerWillResetCapturingMouseEventsNode; |
| 397 | 396 |
| 398 RefPtrWillBeMember<Node> m_nodeUnderMouse; | 397 Member<Node> m_nodeUnderMouse; |
| 399 RefPtrWillBeMember<LocalFrame> m_lastMouseMoveEventSubframe; | 398 Member<LocalFrame> m_lastMouseMoveEventSubframe; |
| 400 RefPtrWillBeMember<Scrollbar> m_lastScrollbarUnderMouse; | 399 Member<Scrollbar> m_lastScrollbarUnderMouse; |
| 401 | 400 |
| 402 int m_clickCount; | 401 int m_clickCount; |
| 403 RefPtrWillBeMember<Node> m_clickNode; | 402 Member<Node> m_clickNode; |
| 404 | 403 |
| 405 RefPtrWillBeMember<Node> m_dragTarget; | 404 Member<Node> m_dragTarget; |
| 406 bool m_shouldOnlyFireDragOverEvent; | 405 bool m_shouldOnlyFireDragOverEvent; |
| 407 | 406 |
| 408 RefPtrWillBeMember<HTMLFrameSetElement> m_frameSetBeingResized; | 407 Member<HTMLFrameSetElement> m_frameSetBeingResized; |
| 409 | 408 |
| 410 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableA
rea. | 409 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableA
rea. |
| 411 | 410 |
| 412 FloatSize m_accumulatedRootOverscroll; | 411 FloatSize m_accumulatedRootOverscroll; |
| 413 | 412 |
| 414 bool m_mousePositionIsUnknown; | 413 bool m_mousePositionIsUnknown; |
| 415 // The last mouse movement position this frame has seen in root frame coordi
nates. | 414 // The last mouse movement position this frame has seen in root frame coordi
nates. |
| 416 IntPoint m_lastKnownMousePosition; | 415 IntPoint m_lastKnownMousePosition; |
| 417 IntPoint m_lastKnownMouseGlobalPosition; | 416 IntPoint m_lastKnownMouseGlobalPosition; |
| 418 IntPoint m_mouseDownPos; // In our view's coords. | 417 IntPoint m_mouseDownPos; // In our view's coords. |
| 419 double m_mouseDownTimestamp; | 418 double m_mouseDownTimestamp; |
| 420 PlatformMouseEvent m_mouseDown; | 419 PlatformMouseEvent m_mouseDown; |
| 421 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; | 420 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; |
| 422 | 421 |
| 423 RefPtrWillBeMember<Node> m_previousWheelScrolledNode; | 422 Member<Node> m_previousWheelScrolledNode; |
| 424 | 423 |
| 425 // The target of each active touch point indexed by the touch ID. | 424 // The target of each active touch point indexed by the touch ID. |
| 426 using TouchTargetMap = WillBeHeapHashMap<unsigned, RefPtrWillBeMember<EventT
arget>, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned
>>; | 425 using TouchTargetMap = HeapHashMap<unsigned, Member<EventTarget>, DefaultHas
h<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
| 427 TouchTargetMap m_targetForTouchID; | 426 TouchTargetMap m_targetForTouchID; |
| 428 | 427 |
| 429 // If set, the document of the active touch sequence. Unset if no touch sequ
ence active. | 428 // If set, the document of the active touch sequence. Unset if no touch sequ
ence active. |
| 430 RefPtrWillBeMember<Document> m_touchSequenceDocument; | 429 Member<Document> m_touchSequenceDocument; |
| 431 RefPtr<UserGestureToken> m_touchSequenceUserGestureToken; | 430 RefPtr<UserGestureToken> m_touchSequenceUserGestureToken; |
| 432 | 431 |
| 433 bool m_touchPressed; | 432 bool m_touchPressed; |
| 434 | 433 |
| 435 PointerEventManager m_pointerEventManager; | 434 PointerEventManager m_pointerEventManager; |
| 436 | 435 |
| 437 // Prevents firing mousedown, mousemove & mouseup in-between a canceled poin
terdown and next pointerup/pointercancel. | 436 // Prevents firing mousedown, mousemove & mouseup in-between a canceled poin
terdown and next pointerup/pointercancel. |
| 438 // See "PREVENT MOUSE EVENT flag" in the spec: | 437 // See "PREVENT MOUSE EVENT flag" in the spec: |
| 439 // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-e
vents | 438 // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-e
vents |
| 440 bool m_preventMouseEventForPointerTypeMouse; | 439 bool m_preventMouseEventForPointerTypeMouse; |
| 441 | 440 |
| 442 // This is set upon sending a pointercancel for touch, prevents PE dispatche
s for touches until | 441 // This is set upon sending a pointercancel for touch, prevents PE dispatche
s for touches until |
| 443 // all touch-points become inactive. | 442 // all touch-points become inactive. |
| 444 // TODO(mustaq): Consider a state per pointerType, as in PointerIdManager? E
xclude mouse? | 443 // TODO(mustaq): Consider a state per pointerType, as in PointerIdManager? E
xclude mouse? |
| 445 bool m_inPointerCanceledState; | 444 bool m_inPointerCanceledState; |
| 446 | 445 |
| 447 RefPtrWillBeMember<Node> m_scrollGestureHandlingNode; | 446 Member<Node> m_scrollGestureHandlingNode; |
| 448 bool m_lastGestureScrollOverWidget; | 447 bool m_lastGestureScrollOverWidget; |
| 449 // The most recent element to scroll natively during this scroll | 448 // The most recent element to scroll natively during this scroll |
| 450 // sequence. Null if no native element has scrolled this scroll | 449 // sequence. Null if no native element has scrolled this scroll |
| 451 // sequence, or if the most recent element to scroll used scroll | 450 // sequence, or if the most recent element to scroll used scroll |
| 452 // customization. | 451 // customization. |
| 453 RefPtrWillBeMember<Node> m_previousGestureScrolledNode; | 452 Member<Node> m_previousGestureScrolledNode; |
| 454 RefPtrWillBeMember<Scrollbar> m_scrollbarHandlingScrollGesture; | 453 Member<Scrollbar> m_scrollbarHandlingScrollGesture; |
| 455 | 454 |
| 456 double m_maxMouseMovedDuration; | 455 double m_maxMouseMovedDuration; |
| 457 | 456 |
| 458 bool m_longTapShouldInvokeContextMenu; | 457 bool m_longTapShouldInvokeContextMenu; |
| 459 | 458 |
| 460 Timer<EventHandler> m_activeIntervalTimer; | 459 Timer<EventHandler> m_activeIntervalTimer; |
| 461 double m_lastShowPressTimestamp; | 460 double m_lastShowPressTimestamp; |
| 462 RefPtrWillBeMember<Element> m_lastDeferredTapElement; | 461 Member<Element> m_lastDeferredTapElement; |
| 463 | 462 |
| 464 // Only used with the ScrollCustomization runtime enabled feature. | 463 // Only used with the ScrollCustomization runtime enabled feature. |
| 465 std::deque<int> m_currentScrollChain; | 464 std::deque<int> m_currentScrollChain; |
| 466 // True iff some of the delta has been consumed for the current | 465 // True iff some of the delta has been consumed for the current |
| 467 // scroll sequence in this frame, or any child frames. Only used | 466 // scroll sequence in this frame, or any child frames. Only used |
| 468 // with ScrollCustomization. If some delta has been consumed, a | 467 // with ScrollCustomization. If some delta has been consumed, a |
| 469 // scroll which shouldn't propagate can't cause any element to | 468 // scroll which shouldn't propagate can't cause any element to |
| 470 // scroll other than the |m_previousGestureScrolledNode|. | 469 // scroll other than the |m_previousGestureScrolledNode|. |
| 471 bool m_deltaConsumedForScrollSequence; | 470 bool m_deltaConsumedForScrollSequence; |
| 472 }; | 471 }; |
| 473 | 472 |
| 474 } // namespace blink | 473 } // namespace blink |
| 475 | 474 |
| 476 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::EventHandler::TouchInfo); | 475 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::EventHandler::TouchInfo); |
| 477 | 476 |
| 478 #endif // EventHandler_h | 477 #endif // EventHandler_h |
| OLD | NEW |