LibWeb/DOM: Update "inner invoke" to current spec

Two differences:

1. An extra step inserted to record timing info, which we don't yet
   implement.

2. The last step in the loop breaks instead of returning the value
   directly. (But this is functionally the same, as the following step
   does return that value.)

(Also removed the duplicated part of the comment in step 11 née 10.)

So, there's no actual change in behavior.
This commit is contained in:
Sam Atkins 2024-11-25 11:50:07 +00:00 committed by Andreas Kling
parent f2c19f96f8
commit bdabc9b70d
Notes: github-actions[bot] 2024-11-25 12:35:39 +00:00

View file

@ -84,7 +84,9 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<GC::Root<DOM::DOMEventLi
if (listener->passive)
event.set_in_passive_listener(true);
// 10. Call a user objects operation with listeners callback, "handleEvent", « event », and events currentTarget attribute value. If this throws an exception, then:
// FIXME: 10. If global is a Window object, then record timing info for event listener given event and listener.
// 11. Call a user objects operation with listeners callback, "handleEvent", « event », and events currentTarget attribute value.
// FIXME: These should be wrapped for us in call_user_object_operation, but it currently doesn't do that.
auto* this_value = event.current_target().ptr();
auto* wrapped_event = &event;
@ -100,18 +102,18 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<GC::Root<DOM::DOMEventLi
// FIXME: 2. Set legacyOutputDidListenersThrowFlag if given. (Only used by IndexedDB currently)
}
// 11. Unset events in passive listener flag.
// 12. Unset events in passive listener flag.
event.set_in_passive_listener(false);
// 12. If global is a Window object, then set globals current event to currentEvent.
// 13. If global is a Window object, then set globals current event to currentEvent.
if (is<HTML::Window>(global)) {
auto& window = verify_cast<HTML::Window>(global);
window.set_current_event(current_event);
}
// 13. If events stop immediate propagation flag is set, then return found.
// 14. If events stop immediate propagation flag is set, then break.
if (event.should_stop_immediate_propagation())
return found;
break;
}
// 3. Return found.