Commit 4bc3e930 authored by Masayuki Nakano's avatar Masayuki Nakano
Browse files

Bug 1461708 - part 3: EventStateManager::InitAndDispatchClickEvent() shouldn't...

Bug 1461708 - part 3: EventStateManager::InitAndDispatchClickEvent() shouldn't overwrite nsEventStatus with nsEventStatus_eIgnore r=smaug

EventStateManager::InitAndDispatchClickEvent() sends given nsEventStatus to
nsIPresShell::HandleEventWithTarget().  Then, it sends the status to
EventStateManager::PreHandleEvent() before dispatching the event.  At this
time, EventStateManager::PreHandleEvent() resets the state to
nsEventStatus_eIgnore.  Therefore, for example, if eMouseClick event is
consumed but eMouseAuxClick is ignored, the event status result is
nsEventStatus_eIgnore.  So, neither DispatchClickEvents() nor
PostMouseUpEventHandler() cannot check whether at least one click event
is consumed.

This patch makes EventStateManager::InitAndDispatchClickEvent() sends
local variable of nsEventStatus to nsIPresShell::HandleEventWithTarget().
Then, merge the result with current status.

If we'd change nsEventStatus to enum class, we could make this change as
custom "operator|=" or something.

Differential Revision:

extra : moz-landing-system : lando
parent bfb564ef
......@@ -5008,8 +5008,26 @@ EventStateManager::InitAndDispatchClickEvent(WidgetMouseEvent* aMouseUpEvent,
targetFrame = aOverrideClickTarget->GetPrimaryFrame();
return aPresShell->HandleEventWithTarget(&event, targetFrame,
target, aStatus);
// Use local event status for each click event dispatching since it'll be
// cleared by EventStateManager::PreHandleEvent(). Therefore, dispatching
// an event means that previous event status will be ignored.
nsEventStatus status = nsEventStatus_eIgnore;
nsresult rv = aPresShell->HandleEventWithTarget(&event, targetFrame,
target, &status);
// If current status is nsEventStatus_eConsumeNoDefault, we don't need to
// overwrite it.
if (*aStatus == nsEventStatus_eConsumeNoDefault) {
return rv;
// If new status is nsEventStatus_eConsumeNoDefault or
// nsEventStatus_eConsumeDoDefault, use it.
if (status == nsEventStatus_eConsumeNoDefault ||
status == nsEventStatus_eConsumeDoDefault) {
*aStatus = status;
return rv;
// Otherwise, keep the original status.
return rv;
......@@ -469,6 +469,9 @@ protected:
* EventCausesClickEvents() must return true
* if this event is set to it.
* @param aStatus Returns the result of click event.
* If the status indicates consumed, the
* value won't be overwritten with
* nsEventStatus_eIgnore.
* @param aMessage Should be eMouseClick, eMouseDoubleClick or
* eMouseAuxClick.
* @param aPresShell The PresShell.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment