mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 15:44:57 +00:00
LibWeb: Move dispatching timeupdate events to a helper for tracking
For some media APIs, we will need to know whether we are currently in an event handler for the timeupdate event, and the last time we fired the event.
This commit is contained in:
parent
6c7b3c56f2
commit
2ef4a51c39
2 changed files with 18 additions and 1 deletions
|
@ -929,7 +929,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::pause_element()
|
|||
auto& realm = this->realm();
|
||||
|
||||
// 1. Fire an event named timeupdate at the element.
|
||||
dispatch_event(DOM::Event::create(realm, HTML::EventNames::timeupdate).release_value_but_fixme_should_propagate_errors());
|
||||
dispatch_time_update_event().release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 2. Fire an event named pause at the element.
|
||||
dispatch_event(DOM::Event::create(realm, HTML::EventNames::pause).release_value_but_fixme_should_propagate_errors());
|
||||
|
@ -973,6 +973,17 @@ void HTMLMediaElement::set_paused(bool paused)
|
|||
on_paused();
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLMediaElement::dispatch_time_update_event()
|
||||
{
|
||||
ScopeGuard guard { [this] { m_running_time_update_event_handler = false; } };
|
||||
m_running_time_update_event_handler = true;
|
||||
|
||||
m_last_time_update_event_time = Time::now_monotonic();
|
||||
|
||||
dispatch_event(TRY(DOM::Event::create(realm(), HTML::EventNames::timeupdate)));
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#take-pending-play-promises
|
||||
JS::MarkedVector<JS::NonnullGCPtr<WebIDL::Promise>> HTMLMediaElement::take_pending_play_promises()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue