| Index: third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
|
| diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
|
| index 8c0f1083541509794c61c292e4bc9b1401602d05..b1e4225af6ddf532d957d49138b9a734a433203f 100644
|
| --- a/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
|
| +++ b/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
|
| @@ -32,6 +32,7 @@
|
| #include "core/events/MouseEvent.h"
|
| #include "core/frame/Settings.h"
|
| #include "core/html/HTMLMediaElement.h"
|
| +#include "core/html/TimeRanges.h"
|
| #include "core/html/track/TextTrackContainer.h"
|
| #include "core/layout/LayoutTheme.h"
|
| #include "platform/EventDispatchForbiddenScope.h"
|
| @@ -126,6 +127,7 @@ MediaControls::MediaControls(HTMLMediaElement& mediaElement)
|
| , m_panelWidthChangedTimer(this, &MediaControls::panelWidthChangedTimerFired)
|
| , m_panelWidth(0)
|
| , m_allowHiddenVolumeControls(RuntimeEnabledFeatures::newMediaPlaybackUiEnabled())
|
| + , m_bufferedRangesPaintInvalidationTimer(this, &MediaControls::bufferedRangesPaintInvalidationTimerFired)
|
| {
|
| }
|
|
|
| @@ -275,7 +277,7 @@ void MediaControls::reset()
|
| updateCurrentTimeDisplay();
|
|
|
| m_timeline->setDuration(duration);
|
| - m_timeline->setPosition(mediaElement().currentTime());
|
| + updateTimelinePosition();
|
|
|
| updateVolume();
|
|
|
| @@ -361,7 +363,7 @@ void MediaControls::playbackStarted()
|
| }
|
|
|
| updatePlayState();
|
| - m_timeline->setPosition(mediaElement().currentTime());
|
| + updateTimelinePosition();
|
| updateCurrentTimeDisplay();
|
|
|
| startHideMediaControlsTimer();
|
| @@ -369,7 +371,7 @@ void MediaControls::playbackStarted()
|
|
|
| void MediaControls::playbackProgressed()
|
| {
|
| - m_timeline->setPosition(mediaElement().currentTime());
|
| + updateTimelinePosition();
|
| updateCurrentTimeDisplay();
|
|
|
| if (shouldHideMediaControls())
|
| @@ -379,7 +381,7 @@ void MediaControls::playbackProgressed()
|
| void MediaControls::playbackStopped()
|
| {
|
| updatePlayState();
|
| - m_timeline->setPosition(mediaElement().currentTime());
|
| + updateTimelinePosition();
|
| updateCurrentTimeDisplay();
|
| makeOpaque();
|
|
|
| @@ -394,6 +396,8 @@ void MediaControls::updatePlayState()
|
| if (m_overlayPlayButton)
|
| m_overlayPlayButton->updateDisplayType();
|
| m_playButton->updateDisplayType();
|
| +
|
| + startOrStopBufferedRangesPaintInvalidationTimer();
|
| }
|
|
|
| void MediaControls::beginScrubbing()
|
| @@ -782,6 +786,48 @@ void MediaControls::networkStateChanged()
|
| invalidate(m_fullScreenButton);
|
| invalidate(m_timeline);
|
| invalidate(m_volumeSlider);
|
| +
|
| + startOrStopBufferedRangesPaintInvalidationTimer();
|
| +}
|
| +
|
| +void MediaControls::startOrStopBufferedRangesPaintInvalidationTimer()
|
| +{
|
| + if (m_mediaElement->getNetworkState() == HTMLMediaElement::kNetworkLoading && m_mediaElement->paused()) {
|
| + updateBufferedRanges();
|
| + // Start timer to invalidate m_timeline to repaint the buffered ranges when the media is
|
| + // loading in paused state. In play state, m_timeline will be invalidated on play progresses.
|
| + if (!m_bufferedRangesPaintInvalidationTimer.isActive())
|
| + m_bufferedRangesPaintInvalidationTimer.startRepeating(0.5, BLINK_FROM_HERE);
|
| + } else {
|
| + m_bufferedRangesPaintInvalidationTimer.stop();
|
| + }
|
| +}
|
| +
|
| +void MediaControls::updateTimelinePosition()
|
| +{
|
| + m_timeline->setPosition(mediaElement().currentTime());
|
| + // Synchronize buffered ranges when the current time changes.
|
| + updateBufferedRanges();
|
| +};
|
| +
|
| +void MediaControls::updateBufferedRanges()
|
| +{
|
| + TimeRanges* newBufferedRanges = m_mediaElement->buffered();
|
| + if (!m_lastBufferedRanges) {
|
| + if (!newBufferedRanges->length())
|
| + return;
|
| + } else if (*m_lastBufferedRanges != *newBufferedRanges) {
|
| + return;
|
| + }
|
| +
|
| + // Invalidate the timeline to repaint the buffered ranges.
|
| + invalidate(m_timeline);
|
| + m_lastBufferedRanges = newBufferedRanges->copy();
|
| +}
|
| +
|
| +void MediaControls::bufferedRangesPaintInvalidationTimerFired(TimerBase*)
|
| +{
|
| + updateBufferedRanges();
|
| }
|
|
|
| DEFINE_TRACE(MediaControls)
|
| @@ -802,6 +848,7 @@ DEFINE_TRACE(MediaControls)
|
| visitor->trace(m_textTrackList);
|
| visitor->trace(m_castButton);
|
| visitor->trace(m_overlayCastButton);
|
| + visitor->trace(m_lastBufferedRanges);
|
| HTMLDivElement::trace(visitor);
|
| }
|
|
|
|
|