From e7ea06b761745f1bf33d56f360f170d3812eab3a Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 12 Dec 2023 15:10:21 +0100 Subject: [PATCH] Add support for AsyncContext in dispatching Events --- dom.bs | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/dom.bs b/dom.bs index bbd155dc..d6e3640b 100644 --- a/dom.bs +++ b/dom.bs @@ -1270,8 +1270,9 @@ property of the event being dispatched.

Dispatching events

To dispatch an event to a -target, with an optional legacy target override flag and an optional -legacyOutputDidListenersThrowFlag, run these steps: +target, with an optional legacy target override flag, an optional +legacyOutputDidListenersThrowFlag, and an optional +useCallerAsyncContextFlag, run these steps:

  1. Set event's dispatch flag. @@ -1408,8 +1409,9 @@ property of the event being dispatched.

  2. Otherwise, set event's {{Event/eventPhase}} attribute to {{Event/CAPTURING_PHASE}}. -

  3. Invoke with struct, event, "capturing", and - legacyOutputDidListenersThrowFlag if given. +

  4. Invoke with struct, event, "capturing", + legacyOutputDidListenersThrowFlag if given, and + useCallerAsyncContextFlag if given.

  • @@ -1429,8 +1431,9 @@ property of the event being dispatched.
  • Set event's {{Event/eventPhase}} attribute to {{Event/BUBBLING_PHASE}}. -

  • Invoke with struct, event, "bubbling", and - legacyOutputDidListenersThrowFlag if given. +

  • Invoke with struct, event, "bubbling", + legacyOutputDidListenersThrowFlag if given, and + useCallerAsyncContextFlag if given. @@ -1496,8 +1499,9 @@ steps:

    To invoke, given a struct, -event, phase, and an optional legacyOutputDidListenersThrowFlag, -run these steps: +event, phase, an optional legacyOutputDidListenersThrowFlag, +an optional legacyOutputDidListenersThrowFlag if given, and an optional +useCallerAsyncContextFlag, run these steps:

    1. Set event's target to the @@ -1527,8 +1531,9 @@ run these steps: invocation-target-in-shadow-tree.

    2. Let found be the result of running inner invoke with event, - listeners, phase, invocationTargetInShadowTree, and - legacyOutputDidListenersThrowFlag if given. + listeners, phase, invocationTargetInShadowTree, + legacyOutputDidListenersThrowFlag if given, and useCallerAsyncContextFlag if + given.

    3. If found is false and event's {{Event/isTrusted}} attribute is true, @@ -1553,8 +1558,8 @@ run these steps:

    4. Inner invoke with event, listeners, phase, - invocationTargetInShadowTree, and legacyOutputDidListenersThrowFlag - if given. + invocationTargetInShadowTree, legacyOutputDidListenersThrowFlag if given, + and useCallerAsyncContextFlag if given.

    5. Set event's {{Event/type}} attribute value to originalEventType.

    @@ -1562,11 +1567,15 @@ run these steps:

    To inner invoke, given an event, listeners, phase, invocationTargetInShadowTree, -and an optional legacyOutputDidListenersThrowFlag, run these steps: +and an optional legacyOutputDidListenersThrowFlag, and an optional +useCallerAsyncContextFlag, run these steps:

    1. Let found be false. +

    2. Let useCreationTimeAsyncContext be false if + useCallerAsyncContextFlag is passed and true otherwise. +

    3. For each listener in listeners, whose removed is false: @@ -1609,8 +1618,9 @@ and an optional legacyOutputDidListenersThrowFlag, run these steps:

    4. Call a user object's operation with listener's - callback, "handleEvent", « event », and - event's {{Event/currentTarget}} attribute value. If this throws an exception, then: + callback, "handleEvent", « event », + event's {{Event/currentTarget}} attribute value, and + useCreationTimeAsyncContext. If this throws an exception, then:

      1. Report the exception. @@ -1639,7 +1649,8 @@ and an optional legacyOutputDidListenersThrowFlag, run these steps:

        To fire an event named e at target, optionally using an eventConstructor, with a description of how IDL attributes are to be -initialized, and a legacy target override flag, run these steps: +initialized, a legacy target override flag, and an optional +useCallerAsyncContextFlag run these steps:

        1. If eventConstructor is not given, then let eventConstructor be @@ -1657,7 +1668,8 @@ initialized, and a legacy target override flag, run these steps:

          This also allows for the {{Event/isTrusted}} attribute to be set to false.

        2. Return the result of dispatching event at target, with - legacy target override flag set if set. + legacy target override flag set if set, and useCallerAsyncContextFlag set if + set.

        Fire in the context of DOM is short for