Issue #2515 - Clarify only dispatching in chrome.

This commit is contained in:
Moonchild 2024-07-25 15:42:08 +02:00 • committed by roytam1
commit bd439689e1

View file

@ -4668,7 +4668,7 @@ EventStateManager::InitAndDispatchClickEvent(WidgetMouseEvent* aMouseUpEvent,
nsIPresShell* aPresShell, nsIPresShell* aPresShell,
nsIContent* aMouseUpContent, nsIContent* aMouseUpContent,
nsWeakFrame aCurrentTarget, nsWeakFrame aCurrentTarget,
bool aNoContentDispatch) bool aOnlyChromeDispatch)
{ {
MOZ_ASSERT(aMouseUpEvent); MOZ_ASSERT(aMouseUpEvent);
MOZ_ASSERT(EventCausesClickEvents(*aMouseUpEvent)); MOZ_ASSERT(EventCausesClickEvents(*aMouseUpEvent));
@ -4682,7 +4682,7 @@ EventStateManager::InitAndDispatchClickEvent(WidgetMouseEvent* aMouseUpEvent,
event.buttons = aMouseUpEvent->buttons; event.buttons = aMouseUpEvent->buttons;
event.mTime = aMouseUpEvent->mTime; event.mTime = aMouseUpEvent->mTime;
event.mTimeStamp = aMouseUpEvent->mTimeStamp; event.mTimeStamp = aMouseUpEvent->mTimeStamp;
event.mFlags.mOnlyChromeDispatch = aNoContentDispatch; event.mFlags.mOnlyChromeDispatch = aOnlyChromeDispatch;
event.button = aMouseUpEvent->button; event.button = aMouseUpEvent->button;
event.inputSource = aMouseUpEvent->inputSource; event.inputSource = aMouseUpEvent->inputSource;
@ -4749,41 +4749,41 @@ EventStateManager::DispatchClickEvents(nsIPresShell* aPresShell,
MOZ_ASSERT(aStatus); MOZ_ASSERT(aStatus);
MOZ_ASSERT(aClickTarget); MOZ_ASSERT(aClickTarget);
bool notDispatchToContents = bool onlyDispatchInChrome =
(aMouseUpEvent->button == WidgetMouseEvent::eMiddleButton || (aMouseUpEvent->button == WidgetMouseEvent::eMiddleButton ||
aMouseUpEvent->button == WidgetMouseEvent::eRightButton); aMouseUpEvent->button == WidgetMouseEvent::eRightButton);
bool fireAuxClick = notDispatchToContents; bool fireAuxClick = onlyDispatchInChrome;
nsWeakFrame currentTarget = aClickTarget->GetPrimaryFrame(); nsWeakFrame currentTarget = aClickTarget->GetPrimaryFrame();
nsresult ret = nsresult rv =
InitAndDispatchClickEvent(aMouseUpEvent, aStatus, eMouseClick, InitAndDispatchClickEvent(aMouseUpEvent, aStatus, eMouseClick,
aPresShell, aClickTarget, currentTarget, aPresShell, aClickTarget, currentTarget,
notDispatchToContents); onlyDispatchInChrome);
if (NS_WARN_IF(NS_FAILED(ret))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return ret; return rv;
} }
// Fire auxclick even if necessary. // Fire auxclick even if necessary.
if (fireAuxClick && aClickTarget && aClickTarget->IsInComposedDoc()) { if (fireAuxClick && aClickTarget && aClickTarget->IsInComposedDoc()) {
ret = InitAndDispatchClickEvent(aMouseUpEvent, aStatus, eMouseAuxClick, rv = InitAndDispatchClickEvent(aMouseUpEvent, aStatus, eMouseAuxClick,
aPresShell, aClickTarget, currentTarget, aPresShell, aClickTarget, currentTarget,
false); false);
NS_WARNING_ASSERTION(NS_SUCCEEDED(ret), "Failed to dispatch eMouseAuxClick"); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to dispatch eMouseAuxClick");
} }
// Fire double click event if click count is 2. // Fire double click event if click count is 2.
if (aMouseUpEvent->mClickCount == 2 && !fireAuxClick && if (aMouseUpEvent->mClickCount == 2 && !fireAuxClick &&
aClickTarget && aClickTarget->IsInComposedDoc()) { aClickTarget && aClickTarget->IsInComposedDoc()) {
ret = InitAndDispatchClickEvent(aMouseUpEvent, aStatus, eMouseDoubleClick, rv = InitAndDispatchClickEvent(aMouseUpEvent, aStatus, eMouseDoubleClick,
aPresShell, aClickTarget, currentTarget, aPresShell, aClickTarget, currentTarget,
notDispatchToContents); onlyDispatchInChrome);
if (NS_WARN_IF(NS_FAILED(ret))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return ret; return rv;
} }
} }
return ret; return rv;
} }
nsIFrame* nsIFrame*