1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:47:35 +00:00

AK: Rename Time to Duration

That's what this class really is; in fact that's what the first line of
the comment says it is.

This commit does not rename the main files, since those will contain
other time-related classes in a little bit.
This commit is contained in:
kleines Filmröllchen 2023-03-13 16:30:34 +01:00 committed by Jelle Raaijmakers
parent 82ddc813d5
commit 213025f210
140 changed files with 634 additions and 628 deletions

View file

@ -1585,7 +1585,7 @@ 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();
m_last_time_update_event_time = Duration::now_monotonic();
dispatch_event(TRY(DOM::Event::create(realm(), HTML::EventNames::timeupdate)));
return {};
@ -1617,7 +1617,7 @@ void HTMLMediaElement::time_marches_on(TimeMarchesOnReason reason)
auto dispatch_event = true;
if (m_last_time_update_event_time.has_value()) {
auto time_since_last_event = Time::now_monotonic() - *m_last_time_update_event_time;
auto time_since_last_event = Duration::now_monotonic() - *m_last_time_update_event_time;
dispatch_event = time_since_last_event.to_milliseconds() > 250;
}

View file

@ -211,7 +211,7 @@ private:
Optional<DOM::DocumentLoadEventDelayer> m_delaying_the_load_event;
bool m_running_time_update_event_handler { false };
Optional<Time> m_last_time_update_event_time;
Optional<Duration> m_last_time_update_event_time;
JS::GCPtr<DOM::DocumentObserver> m_document_observer;

View file

@ -128,7 +128,7 @@ void HTMLVideoElement::on_paused()
void HTMLVideoElement::on_seek(double position, MediaSeekMode seek_mode)
{
if (m_video_track)
m_video_track->seek(Time::from_milliseconds(position * 1000.0), seek_mode);
m_video_track->seek(Duration::from_milliseconds(position * 1000.0), seek_mode);
}
// https://html.spec.whatwg.org/multipage/media.html#attr-video-poster

View file

@ -98,17 +98,17 @@ void VideoTrack::pause_video(Badge<HTMLVideoElement>)
m_playback_manager->pause_playback();
}
Time VideoTrack::position() const
Duration VideoTrack::position() const
{
return m_playback_manager->current_playback_time();
}
Time VideoTrack::duration() const
Duration VideoTrack::duration() const
{
return m_playback_manager->selected_video_track().video_data().duration;
}
void VideoTrack::seek(Time position, MediaSeekMode seek_mode)
void VideoTrack::seek(Duration position, MediaSeekMode seek_mode)
{
switch (seek_mode) {
case MediaSeekMode::Accurate:

View file

@ -25,9 +25,9 @@ public:
void play_video(Badge<HTMLVideoElement>);
void pause_video(Badge<HTMLVideoElement>);
Time position() const;
Time duration() const;
void seek(Time, MediaSeekMode);
Duration position() const;
Duration duration() const;
void seek(Duration, MediaSeekMode);
u64 pixel_width() const;
u64 pixel_height() const;