Issue #2362 - Fix click handling according to the spec.

This removes some hackery surrounding preventing content clicks, and in
general handles auxclick as it should, firing that event on secondary
buttons (wheel/right on default setup for right-handed mouse).
This commit is contained in:
Moonchild 2023-11-30 18:56:26 +01:00 committed by roytam1
commit dc253ce953
8 changed files with 82 additions and 85 deletions

View file

@ -4682,6 +4682,7 @@ EventStateManager::InitAndDispatchClickEvent(WidgetMouseEvent* aMouseUpEvent,
event.buttons = aMouseUpEvent->buttons;
event.mTime = aMouseUpEvent->mTime;
event.mTimeStamp = aMouseUpEvent->mTimeStamp;
event.mFlags.mOnlyChromeDispatch = aNoContentDispatch;
event.mFlags.mNoContentDispatch = aNoContentDispatch;
event.button = aMouseUpEvent->button;
event.inputSource = aMouseUpEvent->inputSource;
@ -4764,8 +4765,16 @@ EventStateManager::DispatchClickEvents(nsIPresShell* aPresShell,
return ret;
}
// Fire auxclick even if necessary.
if (fireAuxClick && aClickTarget && aClickTarget->IsInComposedDoc()) {
ret = InitAndDispatchClickEvent(aMouseUpEvent, aStatus, eMouseAuxClick,
aPresShell, aClickTarget, currentTarget,
false);
NS_WARNING_ASSERTION(NS_SUCCEEDED(ret), "Failed to dispatch eMouseAuxClick");
}
// Fire double click event if click count is 2.
if (aMouseUpEvent->mClickCount == 2 &&
if (aMouseUpEvent->mClickCount == 2 && !fireAuxClick &&
aClickTarget && aClickTarget->IsInComposedDoc()) {
ret = InitAndDispatchClickEvent(aMouseUpEvent, aStatus, eMouseDoubleClick,
aPresShell, aClickTarget, currentTarget,
@ -4775,15 +4784,6 @@ EventStateManager::DispatchClickEvents(nsIPresShell* aPresShell,
}
}
// Fire auxclick even if necessary.
if (fireAuxClick &&
aClickTarget && aClickTarget->IsInComposedDoc()) {
ret = InitAndDispatchClickEvent(aMouseUpEvent, aStatus, eMouseAuxClick,
aPresShell, aClickTarget, currentTarget,
false);
NS_WARNING_ASSERTION(NS_SUCCEEDED(ret), "Failed to dispatch eMouseAuxClick");
}
return ret;
}