Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
| index dcf3d60f9d3a77daeb6ba5f0f05e3c4c7e30e025..fedd25ca724b1f414292f1d0938f170e452988bf 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
| @@ -128,6 +128,7 @@ namespace { |
| constexpr float kMostlyFillViewportThreshold = 0.85f; |
| constexpr double kMostlyFillViewportBecomeStableSeconds = 5; |
| +constexpr double kCheckViewportIntersectionIntervalInSeconds = 1; |
|
ojan
2016/12/14 00:39:08
Naming nit: Other variables leave out the "In", e.
xjz
2016/12/14 00:55:05
Done.
|
| enum MediaControlsShow { |
| MediaControlsShowAttribute = 0, |
| @@ -370,6 +371,9 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, |
| m_viewportFillDebouncerTimer( |
| this, |
| &HTMLMediaElement::viewportFillDebouncerTimerFired), |
| + m_checkViewportIntersectionTimer( |
| + this, |
| + &HTMLMediaElement::checkViewportIntersectionTimerFired), |
| m_playedTimeRanges(), |
| m_asyncEventQueue(GenericEventQueue::create(this)), |
| m_playbackRate(1.0f), |
| @@ -2433,8 +2437,6 @@ void HTMLMediaElement::startPlaybackProgressTimer() { |
| } |
| void HTMLMediaElement::playbackProgressTimerFired(TimerBase*) { |
| - checkViewportIntersectionChanged(); |
| - |
| if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && |
| getDirectionOfPlayback() == Forward) { |
| m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); |
| @@ -3275,6 +3277,7 @@ void HTMLMediaElement::updatePlayState() { |
| void HTMLMediaElement::stopPeriodicTimers() { |
| m_progressEventTimer.stop(); |
| m_playbackProgressTimer.stop(); |
| + m_checkViewportIntersectionTimer.stop(); |
| } |
| void HTMLMediaElement:: |
| @@ -4033,9 +4036,16 @@ DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) { |
| visitor->trace(m_client); |
| } |
| -void HTMLMediaElement::checkViewportIntersectionChanged() { |
| - // TODO(xjz): Early return if we not in tab mirroring. |
| +void HTMLMediaElement::enableMonitorViewportIntersection(bool enable) { |
| + if (enable && !m_checkViewportIntersectionTimer.isActive()) { |
| + m_checkViewportIntersectionTimer.startRepeating( |
| + kCheckViewportIntersectionIntervalInSeconds, BLINK_FROM_HERE); |
| + } else if (!enable) { |
| + m_checkViewportIntersectionTimer.stop(); |
| + } |
| +} |
| +void HTMLMediaElement::checkViewportIntersectionTimerFired(TimerBase*) { |
| IntersectionGeometry geometry( |
| document().frame()->localFrameRoot()->document(), this, Vector<Length>(), |
| IntersectionGeometry::ReportRootBounds::kShouldReportRootBounds); |