diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /dom/events/PointerEventHandler.cpp | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-adbda400be353e676059e335c3c0aaf99e719475.tar.xz firefox-adbda400be353e676059e335c3c0aaf99e719475.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/events/PointerEventHandler.cpp')
-rw-r--r-- | dom/events/PointerEventHandler.cpp | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/dom/events/PointerEventHandler.cpp b/dom/events/PointerEventHandler.cpp index 6c537bfb67..ef6f2b12c0 100644 --- a/dom/events/PointerEventHandler.cpp +++ b/dom/events/PointerEventHandler.cpp @@ -610,15 +610,16 @@ EventMessage PointerEventHandler::ToPointerEventMessage( /* static */ void PointerEventHandler::DispatchPointerFromMouseOrTouch( - PresShell* aShell, nsIFrame* aFrame, nsIContent* aContent, - WidgetGUIEvent* aEvent, bool aDontRetargetEvents, nsEventStatus* aStatus, - nsIContent** aTargetContent) { - MOZ_ASSERT(aFrame || aContent); - MOZ_ASSERT(aEvent); + PresShell* aShell, nsIFrame* aEventTargetFrame, + nsIContent* aEventTargetContent, WidgetGUIEvent* aMouseOrTouchEvent, + bool aDontRetargetEvents, nsEventStatus* aStatus, + nsIContent** aMouseOrTouchEventTarget /* = nullptr */) { + MOZ_ASSERT(aEventTargetFrame || aEventTargetContent); + MOZ_ASSERT(aMouseOrTouchEvent); EventMessage pointerMessage = eVoidEvent; - if (aEvent->mClass == eMouseEventClass) { - WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); + if (aMouseOrTouchEvent->mClass == eMouseEventClass) { + WidgetMouseEvent* mouseEvent = aMouseOrTouchEvent->AsMouseEvent(); // Don't dispatch pointer events caused by a mouse when simulating touch // devices in RDM. Document* doc = aShell->GetDocument(); @@ -636,7 +637,7 @@ void PointerEventHandler::DispatchPointerFromMouseOrTouch( // 2. We don't synthesize pointer events for those events that are not // dispatched to DOM. if (!mouseEvent->convertToPointer || - !aEvent->IsAllowedToDispatchDOMEvent()) { + !aMouseOrTouchEvent->IsAllowedToDispatchDOMEvent()) { return; } @@ -648,20 +649,20 @@ void PointerEventHandler::DispatchPointerFromMouseOrTouch( InitPointerEventFromMouse(&event, mouseEvent, pointerMessage); event.convertToPointer = mouseEvent->convertToPointer = false; RefPtr<PresShell> shell(aShell); - if (!aFrame) { - shell = PresShell::GetShellForEventTarget(nullptr, aContent); + if (!aEventTargetFrame) { + shell = PresShell::GetShellForEventTarget(nullptr, aEventTargetContent); if (!shell) { return; } } - PreHandlePointerEventsPreventDefault(&event, aEvent); + PreHandlePointerEventsPreventDefault(&event, aMouseOrTouchEvent); // Dispatch pointer event to the same target which is found by the // corresponding mouse event. - shell->HandleEventWithTarget(&event, aFrame, aContent, aStatus, true, - aTargetContent); - PostHandlePointerEventsPreventDefault(&event, aEvent); - } else if (aEvent->mClass == eTouchEventClass) { - WidgetTouchEvent* touchEvent = aEvent->AsTouchEvent(); + shell->HandleEventWithTarget(&event, aEventTargetFrame, aEventTargetContent, + aStatus, true, aMouseOrTouchEventTarget); + PostHandlePointerEventsPreventDefault(&event, aMouseOrTouchEvent); + } else if (aMouseOrTouchEvent->mClass == eTouchEventClass) { + WidgetTouchEvent* touchEvent = aMouseOrTouchEvent->AsTouchEvent(); // loop over all touches and dispatch pointer events on each touch // copy the event pointerMessage = PointerEventHandler::ToPointerEventMessage(touchEvent); @@ -681,7 +682,7 @@ void PointerEventHandler::DispatchPointerFromMouseOrTouch( InitPointerEventFromTouch(event, *touchEvent, *touch, i == 0); event.convertToPointer = touch->convertToPointer = false; event.mCoalescedWidgetEvents = touch->mCoalescedWidgetEvents; - if (aEvent->mMessage == eTouchStart) { + if (aMouseOrTouchEvent->mMessage == eTouchStart) { // We already did hit test for touchstart in PresShell. We should // dispatch pointerdown to the same target as touchstart. nsCOMPtr<nsIContent> content = @@ -696,18 +697,22 @@ void PointerEventHandler::DispatchPointerFromMouseOrTouch( continue; } - PreHandlePointerEventsPreventDefault(&event, aEvent); + PreHandlePointerEventsPreventDefault(&event, aMouseOrTouchEvent); shell->HandleEventWithTarget(&event, frame, content, aStatus, true, - nullptr); - PostHandlePointerEventsPreventDefault(&event, aEvent); + aMouseOrTouchEventTarget); + PostHandlePointerEventsPreventDefault(&event, aMouseOrTouchEvent); } else { // We didn't hit test for other touch events. Spec doesn't mention that // all pointer events should be dispatched to the same target as their // corresponding touch events. Call PresShell::HandleEvent so that we do // hit test for pointer events. - PreHandlePointerEventsPreventDefault(&event, aEvent); - shell->HandleEvent(aFrame, &event, aDontRetargetEvents, aStatus); - PostHandlePointerEventsPreventDefault(&event, aEvent); + // FIXME: If aDontRetargetEvents is true and the event is fired on + // different document, we cannot track the pointer event target when + // it's removed from the tree. + PreHandlePointerEventsPreventDefault(&event, aMouseOrTouchEvent); + shell->HandleEvent(aEventTargetFrame, &event, aDontRetargetEvents, + aStatus); + PostHandlePointerEventsPreventDefault(&event, aMouseOrTouchEvent); } } } |