| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 class TouchInfo { | 218 class TouchInfo { |
| 220 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 219 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 221 public: | 220 public: |
| 222 DEFINE_INLINE_TRACE() | 221 DEFINE_INLINE_TRACE() |
| 223 { | 222 { |
| 224 visitor->trace(touchTarget); | 223 visitor->trace(touchTarget); |
| 225 visitor->trace(targetFrame); | 224 visitor->trace(targetFrame); |
| 226 } | 225 } |
| 227 | 226 |
| 228 PlatformTouchPoint point; | 227 PlatformTouchPoint point; |
| 229 RefPtrWillBeMember<EventTarget> touchTarget; | 228 Member<EventTarget> touchTarget; |
| 230 RefPtrWillBeMember<LocalFrame> targetFrame; | 229 Member<LocalFrame> targetFrame; |
| 231 FloatPoint adjustedPagePoint; | 230 FloatPoint adjustedPagePoint; |
| 232 FloatSize adjustedRadius; | 231 FloatSize adjustedRadius; |
| 233 bool knownTarget; | 232 bool knownTarget; |
| 234 bool consumed; | 233 bool consumed; |
| 235 String region; | 234 String region; |
| 236 }; | 235 }; |
| 237 | 236 |
| 238 private: | 237 private: |
| 239 static DragState& dragState(); | 238 static DragState& dragState(); |
| 240 | 239 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 302 |
| 304 void resetOverscroll(bool didScrollX, bool didScrollY); | 303 void resetOverscroll(bool didScrollX, bool didScrollY); |
| 305 void handleOverscroll(const ScrollResult&, const FloatPoint& position = Floa
tPoint(), const FloatSize& velocity = FloatSize()); | 304 void handleOverscroll(const ScrollResult&, const FloatPoint& position = Floa
tPoint(), const FloatSize& velocity = FloatSize()); |
| 306 | 305 |
| 307 void customizedScroll(const Node& startNode, ScrollState&); | 306 void customizedScroll(const Node& startNode, ScrollState&); |
| 308 | 307 |
| 309 HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, HitTestR
equest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::
Active); | 308 HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, HitTestR
equest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::
Active); |
| 310 | 309 |
| 311 void invalidateClick(); | 310 void invalidateClick(); |
| 312 | 311 |
| 313 PassRefPtrWillBeRawPtr<Node> updateMouseEventTargetNode(Node*, const Platfor
mMouseEvent&); | 312 RawPtr<Node> updateMouseEventTargetNode(Node*, const PlatformMouseEvent&); |
| 314 void updateMouseEventTargetNodeAndSendEvents(Node*, const PlatformMouseEvent
&, bool isFrameBoundaryTransition = false); | 313 void updateMouseEventTargetNodeAndSendEvents(Node*, const PlatformMouseEvent
&, bool isFrameBoundaryTransition = false); |
| 315 | 314 |
| 316 | 315 |
| 317 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const
PlatformMouseEvent&); | 316 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const
PlatformMouseEvent&); |
| 318 | 317 |
| 319 WebInputEventResult dispatchMouseEvent(const AtomicString& eventType, Node*
target, int clickCount, const PlatformMouseEvent&); | 318 WebInputEventResult dispatchMouseEvent(const AtomicString& eventType, Node*
target, int clickCount, const PlatformMouseEvent&); |
| 320 | 319 |
| 321 // Dispatches ME after corresponding PE provided the PE has not been cancele
d. The eventType arg | 320 // Dispatches ME after corresponding PE provided the PE has not been cancele
d. The eventType arg |
| 322 // must be a mouse event that can be gated though a preventDefaulted pointer
down (i.e., one of | 321 // must be a mouse event that can be gated though a preventDefaulted pointer
down (i.e., one of |
| 323 // {mousedown, mousemove, mouseup}). | 322 // {mousedown, mousemove, mouseup}). |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 bool panScrollInProgress() const; | 365 bool panScrollInProgress() const; |
| 367 void setLastKnownMousePosition(const PlatformMouseEvent&); | 366 void setLastKnownMousePosition(const PlatformMouseEvent&); |
| 368 | 367 |
| 369 bool shouldTopControlsConsumeScroll(FloatSize) const; | 368 bool shouldTopControlsConsumeScroll(FloatSize) const; |
| 370 | 369 |
| 371 // If the given element is a shadow host and its root has delegatesFocus=fal
se flag, | 370 // If the given element is a shadow host and its root has delegatesFocus=fal
se flag, |
| 372 // slide focus to its inner element. Returns true if the resulting focus is
different from | 371 // slide focus to its inner element. Returns true if the resulting focus is
different from |
| 373 // the given element. | 372 // the given element. |
| 374 bool slideFocusOnShadowHostIfNecessary(const Element&); | 373 bool slideFocusOnShadowHostIfNecessary(const Element&); |
| 375 | 374 |
| 376 void dispatchPointerEvents(const PlatformTouchEvent&, WillBeHeapVector<Touch
Info>&); | 375 void dispatchPointerEvents(const PlatformTouchEvent&, HeapVector<TouchInfo>&
); |
| 377 void sendPointerCancels(WillBeHeapVector<TouchInfo>&); | 376 void sendPointerCancels(HeapVector<TouchInfo>&); |
| 378 | 377 |
| 379 WebInputEventResult dispatchTouchEvents(const PlatformTouchEvent&, WillBeHea
pVector<TouchInfo>&, bool, bool); | 378 WebInputEventResult dispatchTouchEvents(const PlatformTouchEvent&, HeapVecto
r<TouchInfo>&, bool, bool); |
| 380 | 379 |
| 381 // NOTE: If adding a new field to this class please ensure that it is | 380 // NOTE: If adding a new field to this class please ensure that it is |
| 382 // cleared in |EventHandler::clear()|. | 381 // cleared in |EventHandler::clear()|. |
| 383 | 382 |
| 384 const RawPtrWillBeMember<LocalFrame> m_frame; | 383 const Member<LocalFrame> m_frame; |
| 385 | 384 |
| 386 // Current button-press state for mouse/mouse-like-stylus. | 385 // Current button-press state for mouse/mouse-like-stylus. |
| 387 // TODO(crbug.com/563676): Buggy for chorded buttons. | 386 // TODO(crbug.com/563676): Buggy for chorded buttons. |
| 388 bool m_mousePressed; | 387 bool m_mousePressed; |
| 389 | 388 |
| 390 bool m_capturesDragging; | 389 bool m_capturesDragging; |
| 391 RefPtrWillBeMember<Node> m_mousePressNode; | 390 Member<Node> m_mousePressNode; |
| 392 | 391 |
| 393 bool m_mouseDownMayStartDrag; | 392 bool m_mouseDownMayStartDrag; |
| 394 const OwnPtrWillBeMember<SelectionController> m_selectionController; | 393 const Member<SelectionController> m_selectionController; |
| 395 | 394 |
| 396 LayoutPoint m_dragStartPos; | 395 LayoutPoint m_dragStartPos; |
| 397 | 396 |
| 398 Timer<EventHandler> m_hoverTimer; | 397 Timer<EventHandler> m_hoverTimer; |
| 399 | 398 |
| 400 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide
state | 399 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide
state |
| 401 // should move out of EventHandler to a new PageEventHandler class. crbug.co
m/449649 | 400 // should move out of EventHandler to a new PageEventHandler class. crbug.co
m/449649 |
| 402 Timer<EventHandler> m_cursorUpdateTimer; | 401 Timer<EventHandler> m_cursorUpdateTimer; |
| 403 | 402 |
| 404 bool m_mouseDownMayStartAutoscroll; | 403 bool m_mouseDownMayStartAutoscroll; |
| 405 | 404 |
| 406 Timer<EventHandler> m_fakeMouseMoveEventTimer; | 405 Timer<EventHandler> m_fakeMouseMoveEventTimer; |
| 407 | 406 |
| 408 bool m_svgPan; | 407 bool m_svgPan; |
| 409 | 408 |
| 410 RawPtrWillBeMember<PaintLayerScrollableArea> m_resizeScrollableArea; | 409 Member<PaintLayerScrollableArea> m_resizeScrollableArea; |
| 411 | 410 |
| 412 RefPtrWillBeMember<Node> m_capturingMouseEventsNode; | 411 Member<Node> m_capturingMouseEventsNode; |
| 413 bool m_eventHandlerWillResetCapturingMouseEventsNode; | 412 bool m_eventHandlerWillResetCapturingMouseEventsNode; |
| 414 | 413 |
| 415 // Note the difference of this and m_nodeUnderPointer in PointerEventManager | 414 // Note the difference of this and m_nodeUnderPointer in PointerEventManager |
| 416 RefPtrWillBeMember<Node> m_nodeUnderMouse; | 415 Member<Node> m_nodeUnderMouse; |
| 417 | 416 |
| 418 RefPtrWillBeMember<LocalFrame> m_lastMouseMoveEventSubframe; | 417 Member<LocalFrame> m_lastMouseMoveEventSubframe; |
| 419 RefPtrWillBeMember<Scrollbar> m_lastScrollbarUnderMouse; | 418 Member<Scrollbar> m_lastScrollbarUnderMouse; |
| 420 | 419 |
| 421 int m_clickCount; | 420 int m_clickCount; |
| 422 RefPtrWillBeMember<Node> m_clickNode; | 421 Member<Node> m_clickNode; |
| 423 | 422 |
| 424 RefPtrWillBeMember<Node> m_dragTarget; | 423 Member<Node> m_dragTarget; |
| 425 bool m_shouldOnlyFireDragOverEvent; | 424 bool m_shouldOnlyFireDragOverEvent; |
| 426 | 425 |
| 427 RefPtrWillBeMember<HTMLFrameSetElement> m_frameSetBeingResized; | 426 Member<HTMLFrameSetElement> m_frameSetBeingResized; |
| 428 | 427 |
| 429 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableA
rea. | 428 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableA
rea. |
| 430 | 429 |
| 431 FloatSize m_accumulatedRootOverscroll; | 430 FloatSize m_accumulatedRootOverscroll; |
| 432 | 431 |
| 433 bool m_mousePositionIsUnknown; | 432 bool m_mousePositionIsUnknown; |
| 434 // The last mouse movement position this frame has seen in root frame coordi
nates. | 433 // The last mouse movement position this frame has seen in root frame coordi
nates. |
| 435 IntPoint m_lastKnownMousePosition; | 434 IntPoint m_lastKnownMousePosition; |
| 436 IntPoint m_lastKnownMouseGlobalPosition; | 435 IntPoint m_lastKnownMouseGlobalPosition; |
| 437 IntPoint m_mouseDownPos; // In our view's coords. | 436 IntPoint m_mouseDownPos; // In our view's coords. |
| 438 double m_mouseDownTimestamp; | 437 double m_mouseDownTimestamp; |
| 439 PlatformMouseEvent m_mouseDown; | 438 PlatformMouseEvent m_mouseDown; |
| 440 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; | 439 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; |
| 441 | 440 |
| 442 // The target of each active touch point indexed by the touch ID. | 441 // The target of each active touch point indexed by the touch ID. |
| 443 using TouchTargetMap = WillBeHeapHashMap<unsigned, RefPtrWillBeMember<EventT
arget>, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned
>>; | 442 using TouchTargetMap = HeapHashMap<unsigned, Member<EventTarget>, DefaultHas
h<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
| 444 TouchTargetMap m_targetForTouchID; | 443 TouchTargetMap m_targetForTouchID; |
| 445 using TouchRegionMap = WillBeHeapHashMap<unsigned, String, DefaultHash<unsig
ned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; | 444 using TouchRegionMap = HeapHashMap<unsigned, String, DefaultHash<unsigned>::
Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
| 446 TouchRegionMap m_regionForTouchID; | 445 TouchRegionMap m_regionForTouchID; |
| 447 | 446 |
| 448 // If set, the document of the active touch sequence. Unset if no touch sequ
ence active. | 447 // If set, the document of the active touch sequence. Unset if no touch sequ
ence active. |
| 449 RefPtrWillBeMember<Document> m_touchSequenceDocument; | 448 Member<Document> m_touchSequenceDocument; |
| 450 RefPtr<UserGestureToken> m_touchSequenceUserGestureToken; | 449 RefPtr<UserGestureToken> m_touchSequenceUserGestureToken; |
| 451 | 450 |
| 452 bool m_touchPressed; | 451 bool m_touchPressed; |
| 453 | 452 |
| 454 PointerEventManager m_pointerEventManager; | 453 PointerEventManager m_pointerEventManager; |
| 455 | 454 |
| 456 // This is set upon sending a pointercancel for touch, prevents PE dispatche
s for touches until | 455 // This is set upon sending a pointercancel for touch, prevents PE dispatche
s for touches until |
| 457 // all touch-points become inactive. | 456 // all touch-points become inactive. |
| 458 // TODO(mustaq): Consider a state per pointerType, as in PointerIdManager? E
xclude mouse? | 457 // TODO(mustaq): Consider a state per pointerType, as in PointerIdManager? E
xclude mouse? |
| 459 bool m_inPointerCanceledState; | 458 bool m_inPointerCanceledState; |
| 460 | 459 |
| 461 RefPtrWillBeMember<Node> m_scrollGestureHandlingNode; | 460 Member<Node> m_scrollGestureHandlingNode; |
| 462 bool m_lastGestureScrollOverWidget; | 461 bool m_lastGestureScrollOverWidget; |
| 463 // The most recent element to scroll natively during this scroll | 462 // The most recent element to scroll natively during this scroll |
| 464 // sequence. Null if no native element has scrolled this scroll | 463 // sequence. Null if no native element has scrolled this scroll |
| 465 // sequence, or if the most recent element to scroll used scroll | 464 // sequence, or if the most recent element to scroll used scroll |
| 466 // customization. | 465 // customization. |
| 467 RefPtrWillBeMember<Node> m_previousGestureScrolledNode; | 466 Member<Node> m_previousGestureScrolledNode; |
| 468 RefPtrWillBeMember<Scrollbar> m_scrollbarHandlingScrollGesture; | 467 Member<Scrollbar> m_scrollbarHandlingScrollGesture; |
| 469 | 468 |
| 470 double m_maxMouseMovedDuration; | 469 double m_maxMouseMovedDuration; |
| 471 | 470 |
| 472 bool m_longTapShouldInvokeContextMenu; | 471 bool m_longTapShouldInvokeContextMenu; |
| 473 | 472 |
| 474 Timer<EventHandler> m_activeIntervalTimer; | 473 Timer<EventHandler> m_activeIntervalTimer; |
| 475 double m_lastShowPressTimestamp; | 474 double m_lastShowPressTimestamp; |
| 476 RefPtrWillBeMember<Element> m_lastDeferredTapElement; | 475 Member<Element> m_lastDeferredTapElement; |
| 477 | 476 |
| 478 // Only used with the ScrollCustomization runtime enabled feature. | 477 // Only used with the ScrollCustomization runtime enabled feature. |
| 479 std::deque<int> m_currentScrollChain; | 478 std::deque<int> m_currentScrollChain; |
| 480 // True iff some of the delta has been consumed for the current | 479 // True iff some of the delta has been consumed for the current |
| 481 // scroll sequence in this frame, or any child frames. Only used | 480 // scroll sequence in this frame, or any child frames. Only used |
| 482 // with ScrollCustomization. If some delta has been consumed, a | 481 // with ScrollCustomization. If some delta has been consumed, a |
| 483 // scroll which shouldn't propagate can't cause any element to | 482 // scroll which shouldn't propagate can't cause any element to |
| 484 // scroll other than the |m_previousGestureScrolledNode|. | 483 // scroll other than the |m_previousGestureScrolledNode|. |
| 485 bool m_deltaConsumedForScrollSequence; | 484 bool m_deltaConsumedForScrollSequence; |
| 486 }; | 485 }; |
| 487 | 486 |
| 488 } // namespace blink | 487 } // namespace blink |
| 489 | 488 |
| 490 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::EventHandler::TouchInfo); | 489 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::EventHandler::TouchInfo); |
| 491 | 490 |
| 492 #endif // EventHandler_h | 491 #endif // EventHandler_h |
| OLD | NEW |