sometimes all slaved videos don't start playing
https://bugs.webkit.org/show_bug.cgi?id=88553
Reviewed by Darin Adler.
Source/WebCore:
Test: media/media-controller-time-clamp.html
Some PlatformClock classes will occasionally return times < 0 and will
always return times slightly > duration() when playback has ended. Clamp
the value of currentTime() to the specified [0..duration] range.
* html/MediaController.cpp:
(MediaController::currentTime):
LayoutTests:
* media/media-controller-time-clamp-expected.txt: Added.
* media/media-controller-time-clamp.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@119739 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/html/MediaController.cpp b/Source/WebCore/html/MediaController.cpp
index 806af55..bba6f03 100644
--- a/Source/WebCore/html/MediaController.cpp
+++ b/Source/WebCore/html/MediaController.cpp
@@ -142,8 +142,9 @@
{
if (m_mediaElements.isEmpty())
return 0;
-
- return m_clock->currentTime();
+
+ // Some clocks may return times outside the range of [0..duration].
+ return max(0.0f, min(duration(), m_clock->currentTime()));
}
void MediaController::setCurrentTime(float time, ExceptionCode& code)