Issue #2030 - (chore) refactor event dispatch functions

Based on selected bits of M-C 1461708:
- EventStateManager::CheckForAndDispatchClick() to early-return style
- split EventStateManager::CheckForAndDispatchClick() into:
  EventCausesClickEvents, PostHandleMouseUp, DispatchClickEvents
- Move implementation of UIEvent::GetRangeParent() and UIEvent::RangeOffset() to nsLayoutUtils
This commit is contained in:
Martok 2022-11-27 16:35:25 +01:00 committed by roytam1
commit 4d310562d9
5 changed files with 292 additions and 97 deletions

View file

@ -414,16 +414,79 @@ protected:
*/
void UpdateDragDataTransfer(WidgetDragEvent* dragEvent);
static nsresult InitAndDispatchClickEvent(WidgetMouseEvent* aEvent,
/**
* InitAndDispatchClickEvent() dispatches a click event.
*
* @param aMouseUpEvent eMouseUp event which causes the click event.
* 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.
* @param aMouseUpContent The event target of aMouseUpEvent.
* @param aCurrentTarget Current target of the caller.
* @param aNoContentDispatch true if the event shouldn't be exposed to
* web contents (although will be fired on
* document and window).
* @param aOverrideClickTarget Preferred click event target. If this is
* not nullptr, aMouseUpContent and
* aCurrentTarget are ignored.
*/
static nsresult InitAndDispatchClickEvent(WidgetMouseEvent* aMouseUpEvent,
nsEventStatus* aStatus,
EventMessage aMessage,
nsIPresShell* aPresShell,
nsIContent* aMouseTarget,
nsIContent* aMouseUpContent,
nsWeakFrame aCurrentTarget,
bool aNoContentDispatch);
nsresult SetClickCount(WidgetMouseEvent* aEvent, nsEventStatus* aStatus);
nsresult CheckForAndDispatchClick(WidgetMouseEvent* aEvent,
nsEventStatus* aStatus);
/**
* EventCausesClickEvents() returns true when aMouseEvent is an eMouseUp
* event and it should cause eMouseClick, eMouseDoubleClick and/or
* eMouseAuxClick events. Note that this method assumes that
* aMouseEvent.mClickCount has already been initialized with SetClickCount().
*/
static bool EventCausesClickEvents(const WidgetMouseEvent& aMouseEvent);
/**
* PostHandleMouseUp() handles default actions of eMouseUp event.
*
* @param aMouseUpEvent eMouseUp event which causes the click event.
* EventCausesClickEvents() must return true
* if this event is set to it.
* @param aStatus Returns the result of event status.
* If one of dispatching event is consumed or
* this does something as default action,
* returns nsEventStatus_eConsumeNoDefault.
*/
nsresult PostHandleMouseUp(WidgetMouseEvent* aMouseUpEvent,
nsEventStatus* aStatus);
/**
* DispatchClickEvents() dispatches eMouseClick, eMouseDoubleClick and
* eMouseAuxClick events for aMouseUpEvent. aMouseUpEvent should cause
* click event.
*
* @param aPresShell The PresShell.
* @param aMouseUpEvent eMouseUp event which causes the click event.
* EventCausesClickEvents() must return true
* if this event is set to it.
* @param aStatus Returns the result of event status.
* If one of dispatching click event is
* consumed, returns
* nsEventStatus_eConsumeNoDefault.
* @param aMouseUpContent The event target of aMouseUpEvent.
*/
nsresult DispatchClickEvents(nsIPresShell* aPresShell,
WidgetMouseEvent* aMouseUpEvent,
nsEventStatus* aStatus,
nsIContent* aMouseUpContent);
void EnsureDocument(nsPresContext* aPresContext);
void FlushPendingEvents(nsPresContext* aPresContext);