mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Make the value of assignment to media currentTime the rhs value
In cases where a script assigns `x = video.currentTime = y`, we are expected to have a result of `x === y`, even if the video's duration is less than y. According to the spec, this happens because the official playback position is set to `y` in this case, but since we are following implementations in making `currentTime` immediately return the position on the valid media timeline, we have to specifically return the unchanged value from the setter. See: https://github.com/whatwg/html/issues/11773
This commit is contained in:
parent
9e4c87ab85
commit
93fde59892
Notes:
github-actions[bot]
2025-10-28 00:30:45 +00:00
Author: https://github.com/Zaggy1024
Commit: 93fde59892
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6410
Reviewed-by: https://github.com/R-Goc
Reviewed-by: https://github.com/gmta ✅
2 changed files with 9 additions and 3 deletions
|
|
@ -267,7 +267,7 @@ double HTMLMediaElement::current_time() const
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-media-currenttime
|
||||
void HTMLMediaElement::set_current_time(double current_time)
|
||||
double HTMLMediaElement::set_current_time(double current_time)
|
||||
{
|
||||
// On setting, if the media element's readyState is HAVE_NOTHING, then it must set the media element's default playback start
|
||||
// position to the new value; otherwise, it must set the official playback position to the new value and then seek to the new
|
||||
|
|
@ -275,9 +275,15 @@ void HTMLMediaElement::set_current_time(double current_time)
|
|||
if (m_ready_state == ReadyState::HaveNothing) {
|
||||
m_default_playback_start_position = current_time;
|
||||
} else {
|
||||
m_official_playback_position = current_time;
|
||||
// AD-HOC: Don't set the official playback position here, as seek_element() will set it according to the seekable
|
||||
// ranges. We return the value passed to the setter to ensure that chained assignments like
|
||||
// videoA.currentTime = videoB.currentTime = Number.MAX_VALUE;
|
||||
// will seek both videoA and videoB to their corresponding ending positions.
|
||||
// See https://github.com/whatwg/html/issues/11773
|
||||
|
||||
seek_element(current_time);
|
||||
}
|
||||
return current_time;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-media-fastseek
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue