1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
|
/*
* Copyright (C) 2006-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* 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 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 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
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "Cursor.h"
#include "DragActions.h"
#include "FocusDirection.h"
#include "HitTestRequest.h"
#include "LayoutPoint.h"
#include "PlatformMouseEvent.h"
#include "RenderObject.h"
#include "ScrollTypes.h"
#include "SimpleRange.h"
#include "TextEventInputType.h"
#include "TextGranularity.h"
#include "Timer.h"
#include <memory>
#include <utility>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/RefPtr.h>
#include <wtf/WeakPtr.h>
#if PLATFORM(COCOA)
OBJC_CLASS NSView;
#endif
#if PLATFORM(IOS_FAMILY)
OBJC_CLASS WebEvent;
#endif
#if PLATFORM(MAC)
OBJC_CLASS NSEvent;
#endif
#if PLATFORM(IOS_FAMILY) && defined(__OBJC__)
#include "WAKAppKitStubs.h"
#endif
namespace WebCore {
class AutoscrollController;
class ContainerNode;
class DataTransfer;
class Document;
class Element;
class Event;
class EventTarget;
class FloatQuad;
class HTMLFrameSetElement;
class HitTestResult;
class KeyboardEvent;
class KeyboardScrollingAnimator;
class LocalFrame;
class LocalFrameView;
class MouseEventWithHitTestResults;
class Node;
class Pasteboard;
class PlatformGestureEvent;
class PlatformKeyboardEvent;
class PlatformTouchEvent;
class PlatformWheelEvent;
class RenderBox;
class RenderElement;
class RenderLayer;
class RenderWidget;
class ScrollableArea;
class Scrollbar;
class TextEvent;
class Touch;
class TouchEvent;
class VisibleSelection;
class WheelEvent;
class Widget;
struct DragState;
enum class WheelEventProcessingSteps : uint8_t;
enum class WheelScrollGestureState : uint8_t;
#if ENABLE(DRAG_SUPPORT)
extern const int LinkDragHysteresis;
extern const int ImageDragHysteresis;
extern const int TextDragHysteresis;
extern const int ColorDragHystersis;
extern const int GeneralDragHysteresis;
#endif
#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 : uint8_t {
None,
PerformedHitTest,
ActionUpdated,
ActionCancelledWithoutUpdate,
ActionCancelledAfterUpdate,
ActionCompleted
};
class EventHandler {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit EventHandler(LocalFrame&);
~EventHandler();
void clear();
void nodeWillBeRemoved(Node&);
WEBCORE_EXPORT VisiblePosition selectionExtentRespectingEditingBoundary(const VisibleSelection&, const LayoutPoint&, Node*);
#if ENABLE(DRAG_SUPPORT)
void updateSelectionForMouseDrag();
#endif
#if ENABLE(PAN_SCROLLING)
void didPanScrollStart();
void didPanScrollStop();
void startPanScrolling(RenderElement&);
#endif
WEBCORE_EXPORT void stopAutoscrollTimer(bool rendererIsBeingDestroyed = false);
RenderBox* autoscrollRenderer() const;
void updateAutoscrollRenderer();
bool autoscrollInProgress() const;
bool mouseDownWasInSubframe() const { return m_mouseDownWasInSubframe; }
bool panScrollInProgress() const;
WEBCORE_EXPORT void dispatchFakeMouseMoveEventSoon();
void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
WEBCORE_EXPORT HitTestResult hitTestResultAtPoint(const LayoutPoint&, OptionSet<HitTestRequest::Type>) const;
bool mousePressed() const { return m_mousePressed; }
Node* mousePressNode() const { return m_mousePressNode.get(); }
WEBCORE_EXPORT void setCapturingMouseEventsElement(Element*);
void pointerCaptureElementDidChange(Element*);
#if ENABLE(DRAG_SUPPORT)
struct DragTargetResponse {
bool accept { false };
std::optional<OptionSet<DragOperation>> operationMask;
};
DragTargetResponse updateDragAndDrop(const PlatformMouseEvent&, const std::function<std::unique_ptr<Pasteboard>()>&, OptionSet<DragOperation>, bool draggingFiles);
void cancelDragAndDrop(const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&&, OptionSet<DragOperation>, bool draggingFiles);
bool performDragAndDrop(const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&&, OptionSet<DragOperation>, bool draggingFiles);
void updateDragStateAfterEditDragIfNeeded(Element& rootEditableElement);
RefPtr<Element> draggedElement() const;
#endif
void scheduleHoverStateUpdate();
void scheduleCursorUpdate();
void setResizingFrameSet(HTMLFrameSetElement*);
void resizeLayerDestroyed();
// FIXME: Each Frame has an EventHandler, and not every event goes to all frames, so this position can be stale. It should probably be stored on Page.
IntPoint lastKnownMousePosition() const;
IntPoint lastKnownMouseGlobalPosition() const { return m_lastKnownMouseGlobalPosition; }
Cursor currentMouseCursor() const { return m_currentMouseCursor; }
IntPoint targetPositionInWindowForSelectionAutoscroll() const;
bool shouldUpdateAutoscroll();
WEBCORE_EXPORT static RefPtr<LocalFrame> subframeForTargetNode(Node*);
static RefPtr<LocalFrame> subframeForHitTestResult(const MouseEventWithHitTestResults&);
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;
WEBCORE_EXPORT bool mouseMoved(const PlatformMouseEvent&);
WEBCORE_EXPORT bool passMouseMovedEventToScrollbars(const PlatformMouseEvent&);
WEBCORE_EXPORT void lostMouseCapture();
WEBCORE_EXPORT bool handleMousePressEvent(const PlatformMouseEvent&);
WEBCORE_EXPORT OptionSet<HitTestRequest::Type> getHitTypeForMouseMoveEvent(const PlatformMouseEvent&, bool onlyUpdateScrollbars = false);
WEBCORE_EXPORT HitTestResult getHitTestResultForMouseEvent(const PlatformMouseEvent&);
bool handleMouseMoveEvent(const PlatformMouseEvent&, HitTestResult* = nullptr, bool onlyUpdateScrollbars = false);
WEBCORE_EXPORT bool handleMouseReleaseEvent(const PlatformMouseEvent&);
bool handleMouseForceEvent(const PlatformMouseEvent&);
WEBCORE_EXPORT bool handleWheelEvent(const PlatformWheelEvent&, OptionSet<WheelEventProcessingSteps>);
void defaultWheelEventHandler(Node*, WheelEvent&);
void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>);
bool handlePasteGlobalSelection(const PlatformMouseEvent&);
#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
using TouchArray = Vector<RefPtr<Touch>>;
using EventTargetTouchArrayMap = HashMap<Ref<EventTarget>, std::unique_ptr<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)
enum class InTouchEventHandling : bool { No, Yes };
enum class InMotion : bool { No, Yes };
void updateTouchLastGlobalPositionAndDelta(PointerID, const IntPoint&, InTouchEventHandling, InMotion);
bool dispatchTouchEvent(const PlatformTouchEvent&, const AtomString&, const EventTargetTouchArrayMap&, float, float);
bool dispatchSimulatedTouchEvent(IntPoint location);
LocalFrame* touchEventTargetSubframe() const { return m_touchEventTargetSubframe.get(); }
const TouchArray& touches() const { return m_touches; }
#endif
#if ENABLE(IOS_GESTURE_EVENTS)
bool dispatchGestureEvent(const PlatformTouchEvent&, const AtomString&, const EventTargetSet&, float, float);
#elif ENABLE(MAC_GESTURE_EVENTS)
bool dispatchGestureEvent(const PlatformGestureEvent&, const AtomString&, const EventTargetSet&, float, float);
WEBCORE_EXPORT bool handleGestureEvent(const PlatformGestureEvent&);
WEBCORE_EXPORT void didEndMagnificationGesture();
#endif
#if PLATFORM(IOS_FAMILY)
void defaultTouchEventHandler(Node&, TouchEvent&);
WEBCORE_EXPORT void dispatchSyntheticMouseOut(const PlatformMouseEvent&);
WEBCORE_EXPORT void dispatchSyntheticMouseMove(const PlatformMouseEvent&);
#endif
#if ENABLE(CONTEXT_MENU_EVENT)
WEBCORE_EXPORT bool sendContextMenuEvent(const PlatformMouseEvent&);
WEBCORE_EXPORT bool sendContextMenuEventForKey();
#endif
void setMouseDownMayStartAutoscroll() { m_mouseDownMayStartAutoscroll = true; }
bool needsKeyboardEventDisambiguationQuirks() const;
WEBCORE_EXPORT static OptionSet<PlatformEvent::Modifier> accessKeyModifiers();
WEBCORE_EXPORT bool handleAccessKey(const PlatformKeyboardEvent&);
WEBCORE_EXPORT bool keyEvent(const PlatformKeyboardEvent&);
void defaultKeyboardEventHandler(KeyboardEvent&);
WEBCORE_EXPORT void capsLockStateMayHaveChanged() const;
bool accessibilityPreventsEventPropagation(KeyboardEvent&);
WEBCORE_EXPORT void handleKeyboardSelectionMovementForAccessibility(KeyboardEvent&);
bool handleTextInputEvent(const String& text, Event* underlyingEvent = nullptr, TextEventInputType = TextEventInputKeyboard);
void defaultTextInputEventHandler(TextEvent&);
#if ENABLE(DRAG_SUPPORT)
WEBCORE_EXPORT bool eventMayStartDrag(const PlatformMouseEvent&) const;
WEBCORE_EXPORT void didStartDrag();
WEBCORE_EXPORT void dragCancelled();
WEBCORE_EXPORT void dragSourceEndedAt(const PlatformMouseEvent&, OptionSet<DragOperation>, MayExtendDragSession = MayExtendDragSession::No);
#endif
void focusDocumentView();
WEBCORE_EXPORT void scheduleScrollEvent();
#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_FAMILY)
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)
WEBCORE_EXPORT void touchEvent(WebEvent *);
#endif
#if PLATFORM(MAC)
WEBCORE_EXPORT void passMouseMovedEventToScrollbars(NSEvent *, NSEvent* correspondingPressureEvent);
WEBCORE_EXPORT void sendFakeEventsAfterWidgetTracking(NSEvent *initiatingEvent);
void setActivationEventNumber(int num) { m_activationEventNumber = num; }
WEBCORE_EXPORT static NSEvent *currentNSEvent();
static NSEvent *correspondingPressureEvent();
#endif
#if PLATFORM(IOS_FAMILY)
static WebEvent *currentEvent();
#endif
#if ENABLE(TOUCH_EVENTS)
WEBCORE_EXPORT bool handleTouchEvent(const PlatformTouchEvent&);
#endif
bool useHandCursor(Node*, bool isOverLink, bool shiftKey);
void updateCursorIfNeeded();
void updateCursor();
bool isHandlingWheelEvent() const { return m_isHandlingWheelEvent; }
void setProcessingKeyRepeatForPotentialScroll(bool processingKeyRepeatForPotentialScroll) { m_isProcessingKeyRepeatForPotentialScroll = processingKeyRepeatForPotentialScroll; }
bool isProcessingKeyRepeatForPotentialScroll() const { return m_isProcessingKeyRepeatForPotentialScroll; }
WEBCORE_EXPORT void setImmediateActionStage(ImmediateActionStage stage);
ImmediateActionStage immediateActionStage() const { return m_immediateActionStage; }
static Widget* widgetForEventTarget(Element* eventTarget);
#if PLATFORM(IOS_FAMILY) && ENABLE(DRAG_SUPPORT)
WEBCORE_EXPORT bool tryToBeginDragAtPoint(const IntPoint& clientPosition, const IntPoint& globalPosition);
#endif
#if PLATFORM(IOS_FAMILY)
WEBCORE_EXPORT void startSelectionAutoscroll(RenderObject* renderer, const FloatPoint& positionInWindow);
WEBCORE_EXPORT void cancelSelectionAutoscroll();
#endif
WEBCORE_EXPORT std::optional<Cursor> selectCursor(const HitTestResult&, bool shiftKey);
#if ENABLE(KINETIC_SCROLLING)
std::optional<WheelScrollGestureState> wheelScrollGestureState() const { return m_wheelScrollGestureState; }
#endif
#if ENABLE(DRAG_SUPPORT)
Element* draggingElement() const;
#endif
bool canDropCurrentlyDraggedImageAsFile() const;
WEBCORE_EXPORT void invalidateClick();
#if ENABLE(IMAGE_ANALYSIS)
WEBCORE_EXPORT RefPtr<Element> textRecognitionCandidateElement() const;
#endif
static bool scrollableAreaCanHandleEvent(const PlatformWheelEvent&, ScrollableArea&);
WEBCORE_EXPORT void selectClosestContextualWordOrLinkFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
bool keyboardScrollRecursively(std::optional<ScrollDirection>, std::optional<ScrollGranularity>, Node*, bool isKeyRepeat);
WEBCORE_EXPORT bool shouldUseSmoothKeyboardScrollingForFocusedScrollableArea();
private:
#if ENABLE(DRAG_SUPPORT)
static DragState& dragState();
static const Seconds TextDragDelay;
#endif
bool eventActivatedView(const PlatformMouseEvent&) const;
bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleSelection&, TextGranularity);
void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
VisibleSelection selectClosestWordFromHitTestResultBasedOnLookup(const HitTestResult&);
void selectClosestContextualWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
bool handleMouseDoubleClickEvent(const PlatformMouseEvent&);
WEBCORE_EXPORT bool handleMousePressEvent(const MouseEventWithHitTestResults&);
bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
bool keyboardScroll(std::optional<ScrollDirection>, std::optional<ScrollGranularity>, Node*, bool isKeyRepeat);
bool beginKeyboardScrollGesture(KeyboardScrollingAnimator*, ScrollDirection, ScrollGranularity, bool isKeyRepeat);
void stopKeyboardScrolling();
bool startKeyboardScrollAnimationOnDocument(ScrollDirection, ScrollGranularity, bool isKeyRepeat);
bool startKeyboardScrollAnimationOnRenderBoxLayer(ScrollDirection, ScrollGranularity, RenderBox*, bool isKeyRepeat);
bool startKeyboardScrollAnimationOnRenderBoxAndItsAncestors(ScrollDirection, ScrollGranularity, RenderBox*, bool isKeyRepeat);
bool startKeyboardScrollAnimationOnEnclosingScrollableContainer(ScrollDirection, ScrollGranularity, Node*, bool isKeyRepeat);
#if ENABLE(DRAG_SUPPORT)
bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&, CheckDragHysteresis = ShouldCheckDragHysteresis);
bool shouldAllowMouseDownToStartDrag() const;
#endif
WEBCORE_EXPORT bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
bool internalKeyEvent(const PlatformKeyboardEvent&);
void updateCursor(LocalFrameView&, const HitTestResult&, bool shiftKey);
void hoverTimerFired();
#if ENABLE(IMAGE_ANALYSIS)
void textRecognitionHoverTimerFired();
#endif
bool logicalScrollOverflow(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = nullptr);
bool shouldSwapScrollDirection(const HitTestResult&, const PlatformWheelEvent&) const;
static bool isKeyboardOptionTab(KeyboardEvent&);
static bool eventInvertsTabsToLinksClientCallResult(KeyboardEvent&);
#if !ENABLE(IOS_TOUCH_EVENTS)
void fakeMouseMoveEventTimerFired();
void cancelFakeMouseMoveEvent();
#endif
bool isInsideScrollbar(const IntPoint&) const;
#if ENABLE(TOUCH_EVENTS)
bool dispatchSyntheticTouchEventIfEnabled(const PlatformMouseEvent&);
#endif
enum class FireMouseOverOut : bool { No, Yes };
void updateMouseEventTargetNode(const AtomString& eventType, Node*, const PlatformMouseEvent&, FireMouseOverOut);
ScrollableArea* enclosingScrollableArea(Node*);
void notifyScrollableAreasOfMouseEvents(const AtomString& eventType, Element* lastElementUnderMouse, Element* elementUnderMouse);
MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&);
enum class Cancelable : bool { No, Yes };
bool dispatchMouseEvent(const AtomString& eventType, Node* target, int clickCount, const PlatformMouseEvent&, FireMouseOverOut);
#if ENABLE(DRAG_SUPPORT)
bool dispatchDragEvent(const AtomString& eventType, Element& target, const PlatformMouseEvent&, DataTransfer&);
DragTargetResponse dispatchDragEnterOrDragOverEvent(const AtomString& eventType, Element& target, const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&& , OptionSet<DragOperation>, bool draggingFiles);
void invalidateDataTransfer();
bool handleDrag(const MouseEventWithHitTestResults&, CheckDragHysteresis);
#endif
bool handleMouseUp(const MouseEventWithHitTestResults&);
#if ENABLE(DRAG_SUPPORT)
void clearDragState();
static bool shouldDispatchEventsToDragSourceElement();
void dispatchEventToDragSourceElement(const AtomString& eventType, const PlatformMouseEvent&);
bool dispatchDragStartEventOnSourceElement(DataTransfer&);
bool dragHysteresisExceeded(const FloatPoint&) const;
bool dragHysteresisExceeded(const IntPoint&) const;
#endif
bool mouseMovementExceedsThreshold(const FloatPoint&, int pointsThreshold) const;
bool passMousePressEventToSubframe(MouseEventWithHitTestResults&, LocalFrame&);
bool passMouseMoveEventToSubframe(MouseEventWithHitTestResults&, LocalFrame&, HitTestResult* = nullptr);
bool passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&, LocalFrame&);
bool passSubframeEventToSubframe(MouseEventWithHitTestResults&, LocalFrame&, HitTestResult* = nullptr);
bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&, Scrollbar*);
bool passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&);
bool passWidgetMouseDownEventToWidget(RenderWidget*);
bool passMouseDownEventToWidget(Widget*);
bool handleWheelEventInternal(const PlatformWheelEvent&, OptionSet<WheelEventProcessingSteps>, OptionSet<EventHandling>&);
bool passWheelEventToWidget(const PlatformWheelEvent&, Widget&, OptionSet<WheelEventProcessingSteps>);
void determineWheelEventTarget(const PlatformWheelEvent&, RefPtr<Element>& eventTarget, WeakPtr<ScrollableArea>&, bool& isOverWidget);
bool processWheelEventForScrolling(const PlatformWheelEvent&, const WeakPtr<ScrollableArea>&, OptionSet<EventHandling>);
void processWheelEventForScrollSnap(const PlatformWheelEvent&, const WeakPtr<ScrollableArea>&);
bool completeWidgetWheelEvent(const PlatformWheelEvent&, const WeakPtr<Widget>&, const WeakPtr<ScrollableArea>&);
bool handleWheelEventInAppropriateEnclosingBox(Node* startNode, const WheelEvent&, FloatSize& filteredPlatformDelta, const FloatSize& filteredVelocity, OptionSet<EventHandling>);
bool handleWheelEventInScrollableArea(const PlatformWheelEvent&, ScrollableArea&, OptionSet<EventHandling>);
std::optional<WheelScrollGestureState> updateWheelGestureState(const PlatformWheelEvent&, OptionSet<EventHandling>);
bool platformCompletePlatformWidgetWheelEvent(const PlatformWheelEvent&, const Widget&, const WeakPtr<ScrollableArea>&);
bool defaultKeyboardScrollEventHandler(KeyboardEvent&, ScrollLogicalDirection, ScrollGranularity);
void defaultPageUpDownEventHandler(KeyboardEvent&);
void defaultHomeEndEventHandler(KeyboardEvent&);
void defaultSpaceEventHandler(KeyboardEvent&);
void defaultBackspaceEventHandler(KeyboardEvent&);
void defaultTabEventHandler(KeyboardEvent&);
void defaultArrowEventHandler(FocusDirection, KeyboardEvent&);
#if ENABLE(DRAG_SUPPORT)
OptionSet<DragSourceAction> updateDragSourceActionsAllowed() const;
bool supportsSelectionUpdatesOnMouseDrag() const;
#endif
// 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&);
void updateSelectionForMouseDrag(const HitTestResult&);
#endif
enum class SetOrClearLastScrollbar { Clear, Set };
void updateLastScrollbarUnderMouse(Scrollbar*, SetOrClearLastScrollbar);
void setFrameWasScrolledByUser();
bool capturesDragging() const { return m_capturesDragging; }
#if PLATFORM(COCOA) && defined(__OBJC__)
NSView *mouseDownViewIfStillGood();
PlatformMouseEvent currentPlatformMouseEvent() const;
#endif
#if ENABLE(FULLSCREEN_API)
bool isKeyEventAllowedInFullScreen(const PlatformKeyboardEvent&) const;
#endif
void setLastKnownMousePosition(const PlatformMouseEvent&);
#if ENABLE(CURSOR_VISIBILITY)
void startAutoHideCursorTimer();
void cancelAutoHideCursorTimer();
void autoHideCursorTimerFired();
#endif
void clearLatchedState();
void clearElementUnderMouse();
bool shouldSendMouseEventsToInactiveWindows() const;
bool canMouseDownStartSelect(const MouseEventWithHitTestResults&);
bool mouseDownMayStartSelect() const;
LocalFrame& m_frame;
RefPtr<Node> m_mousePressNode;
Timer m_hoverTimer;
#if ENABLE(IMAGE_ANALYSIS)
DeferrableOneShotTimer m_textRecognitionHoverTimer;
#endif
std::unique_ptr<AutoscrollController> m_autoscrollController;
WeakPtr<RenderLayer> m_resizeLayer;
double m_maxMouseMovedDuration { 0 };
bool m_mousePressed { false };
bool m_capturesDragging { false };
bool m_mouseDownMayStartSelect { false };
bool m_mouseDownDelegatedFocus { false };
bool m_mouseDownWasSingleClickInSelection { false };
bool m_hasScheduledCursorUpdate { false };
bool m_mouseDownMayStartAutoscroll { false };
bool m_mouseDownWasInSubframe { false };
bool m_didStartDrag { false };
bool m_isHandlingWheelEvent { false };
bool m_currentWheelEventAllowsScrolling { true };
bool m_svgPan { false };
bool m_eventHandlerWillResetCapturingMouseEventsElement { false };
bool m_isProcessingKeyRepeatForPotentialScroll { false };
enum SelectionInitiationState : uint8_t { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };
SelectionInitiationState m_selectionInitiationState { HaveNotStartedSelection };
ImmediateActionStage m_immediateActionStage { ImmediateActionStage::None };
RefPtr<Element> m_capturingMouseEventsElement;
RefPtr<Element> m_elementUnderMouse;
RefPtr<Element> m_lastElementUnderMouse;
RefPtr<LocalFrame> m_lastMouseMoveEventSubframe;
WeakPtr<Scrollbar> m_lastScrollbarUnderMouse;
Cursor m_currentMouseCursor;
RefPtr<Node> m_clickNode;
RefPtr<HTMLFrameSetElement> m_frameSetBeingResized;
LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeLayer.
int m_clickCount { 0 };
std::optional<IntPoint> m_lastKnownMousePosition; // Same coordinates as PlatformMouseEvent::position().
IntPoint m_lastKnownMouseGlobalPosition;
IntPoint m_mouseDownContentsPosition;
WallTime m_mouseDownTimestamp;
PlatformMouseEvent m_mouseDownEvent;
PlatformMouseEvent m_lastPlatformMouseEvent;
#if !ENABLE(IOS_TOUCH_EVENTS)
Timer m_fakeMouseMoveEventTimer;
#endif
#if ENABLE(CURSOR_VISIBILITY)
Timer m_autoHideCursorTimer;
#endif
#if ENABLE(DRAG_SUPPORT)
LayoutPoint m_dragStartPosition;
std::optional<SimpleRange> m_dragStartSelection;
RefPtr<Element> m_dragTarget;
bool m_mouseDownMayStartDrag { false };
bool m_dragMayStartSelectionInstead { false };
bool m_shouldOnlyFireDragOverEvent { false };
#endif
#if ENABLE(MAC_GESTURE_EVENTS)
bool m_hasActiveGesture { false };
#endif
#if ENABLE(KINETIC_SCROLLING)
std::optional<WheelScrollGestureState> m_wheelScrollGestureState;
#endif
#if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
using TouchTargetMap = HashMap<int, RefPtr<EventTarget>>;
TouchTargetMap m_originatingTouchPointTargets;
RefPtr<Document> m_originatingTouchPointDocument;
unsigned m_originatingTouchPointTargetKey { 0 };
bool m_touchPressed { false };
#endif
#if ENABLE(IOS_GESTURE_EVENTS)
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(IOS_TOUCH_EVENTS)
unsigned m_firstTouchID { InvalidTouchIdentifier };
unsigned touchIdentifierForMouseEvents { 0 };
unsigned m_touchIdentifierForPrimaryTouch { 0 };
TouchArray m_touches;
RefPtr<LocalFrame> m_touchEventTargetSubframe;
HashMap<PointerID, std::pair<IntPoint, IntPoint>, WTF::IntHash<PointerID>, WTF::UnsignedWithZeroKeyHashTraits<PointerID>> m_touchLastGlobalPositionAndDeltaMap;
#endif
#if PLATFORM(COCOA)
NSView *m_mouseDownView { nullptr };
bool m_sendingEventToSubview { false };
#endif
#if PLATFORM(MAC)
int m_activationEventNumber { -1 };
#endif
#if PLATFORM(IOS_FAMILY)
bool m_shouldAllowMouseDownToStartDrag { false };
bool m_isAutoscrolling { false };
IntPoint m_targetAutoscrollPositionInUnscrolledRootViewCoordinates;
std::optional<IntPoint> m_initialTargetAutoscrollPositionInUnscrolledRootViewCoordinates;
#endif
};
} // namespace WebCore
|