Bug 1816473 - Fix event reference point handling in accessible caret check. r=edgar
If an event will not be handled by accessible caret, do not use the event reference point that may have been modified by event retargetting. Restore the original reference point. Depends on D185327 Differential Revision: https://phabricator.services.mozilla.com/D187896
This commit is contained in:
@@ -7377,6 +7377,32 @@ bool PresShell::EventHandler::DispatchPrecedingPointerEvent(
|
||||
return !!aEventTargetData->mPresShell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event retargetting may retarget a mouse event and change the reference point.
|
||||
* If event retargetting changes the reference point of a event that accessible
|
||||
* caret will not handle, restore the original reference point.
|
||||
*/
|
||||
class AutoEventTargetPointResetter {
|
||||
public:
|
||||
explicit AutoEventTargetPointResetter(WidgetGUIEvent* aGUIEvent)
|
||||
: mGUIEvent(aGUIEvent),
|
||||
mRefPoint(aGUIEvent->mRefPoint),
|
||||
mHandledByAccessibleCaret(false) {}
|
||||
|
||||
void SetHandledByAccessibleCaret() { mHandledByAccessibleCaret = true; }
|
||||
|
||||
~AutoEventTargetPointResetter() {
|
||||
if (!mHandledByAccessibleCaret) {
|
||||
mGUIEvent->mRefPoint = mRefPoint;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
WidgetGUIEvent* mGUIEvent;
|
||||
LayoutDeviceIntPoint mRefPoint;
|
||||
bool mHandledByAccessibleCaret;
|
||||
};
|
||||
|
||||
bool PresShell::EventHandler::MaybeHandleEventWithAccessibleCaret(
|
||||
nsIFrame* aFrameForPresShell, WidgetGUIEvent* aGUIEvent,
|
||||
nsEventStatus* aEventStatus) {
|
||||
@@ -7402,6 +7428,7 @@ bool PresShell::EventHandler::MaybeHandleEventWithAccessibleCaret(
|
||||
return false;
|
||||
}
|
||||
|
||||
AutoEventTargetPointResetter autoEventTargetPointResetter(aGUIEvent);
|
||||
// First, try the event hub at the event point to handle a long press to
|
||||
// select a word in an unfocused window.
|
||||
do {
|
||||
@@ -7429,6 +7456,7 @@ bool PresShell::EventHandler::MaybeHandleEventWithAccessibleCaret(
|
||||
// If the event is consumed, cancel APZC panning by setting
|
||||
// mMultipleActionsPrevented.
|
||||
aGUIEvent->mFlags.mMultipleActionsPrevented = true;
|
||||
autoEventTargetPointResetter.SetHandledByAccessibleCaret();
|
||||
return true;
|
||||
} while (false);
|
||||
|
||||
@@ -7458,6 +7486,7 @@ bool PresShell::EventHandler::MaybeHandleEventWithAccessibleCaret(
|
||||
// If the event is consumed, cancel APZC panning by setting
|
||||
// mMultipleActionsPrevented.
|
||||
aGUIEvent->mFlags.mMultipleActionsPrevented = true;
|
||||
autoEventTargetPointResetter.SetHandledByAccessibleCaret();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user