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..8ebf80990d836b331943b0a6fb81b7e13de61a81 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 kCheckIntersectWhenPausedIntervalInSeconds = 2; |
miu
2016/12/10 02:18:37
If the "stable" check is 5 seconds, the timer inte
xjz
2016/12/12 18:58:45
Done.
|
enum MediaControlsShow { |
MediaControlsShowAttribute = 0, |
@@ -370,6 +371,9 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, |
m_viewportFillDebouncerTimer( |
this, |
&HTMLMediaElement::viewportFillDebouncerTimerFired), |
+ m_checkIntersectionWhenPausedTimer( |
+ this, |
+ &HTMLMediaElement::checkIntersectionWhenPausedTimerFired), |
m_playedTimeRanges(), |
m_asyncEventQueue(GenericEventQueue::create(this)), |
m_playbackRate(1.0f), |
@@ -3254,6 +3258,7 @@ void HTMLMediaElement::updatePlayState() { |
webMediaPlayer()->play(); |
} |
+ m_checkIntersectionWhenPausedTimer.stop(); |
startPlaybackProgressTimer(); |
m_playing = true; |
} else { // Should not be playing right now |
@@ -3262,6 +3267,7 @@ void HTMLMediaElement::updatePlayState() { |
} |
m_playbackProgressTimer.stop(); |
+ startCheckIntersectionWhenPausedTimer(); |
m_playing = false; |
double time = currentTime(); |
if (time > m_lastSeekTime) |
@@ -3275,6 +3281,7 @@ void HTMLMediaElement::updatePlayState() { |
void HTMLMediaElement::stopPeriodicTimers() { |
m_progressEventTimer.stop(); |
m_playbackProgressTimer.stop(); |
+ m_checkIntersectionWhenPausedTimer.stop(); |
miu
2016/12/10 02:18:37
If you take my advice below, this extra stop() cal
xjz
2016/12/12 18:58:45
Done.
|
} |
void HTMLMediaElement:: |
@@ -4033,8 +4040,13 @@ DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) { |
visitor->trace(m_client); |
} |
+void HTMLMediaElement::enableMonitorViewportIntersection(bool enable) { |
+ m_enableMonitorViewportIntersection = enable; |
miu
2016/12/10 02:18:37
IMHO, this would all be simpler if we didn't have
xjz
2016/12/12 18:58:45
Done.
|
+} |
+ |
void HTMLMediaElement::checkViewportIntersectionChanged() { |
- // TODO(xjz): Early return if we not in tab mirroring. |
+ if (!m_enableMonitorViewportIntersection) |
+ return; |
IntersectionGeometry geometry( |
document().frame()->localFrameRoot()->document(), this, Vector<Length>(), |
@@ -4071,4 +4083,16 @@ void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { |
m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); |
} |
+void HTMLMediaElement::checkIntersectionWhenPausedTimerFired(TimerBase*) { |
+ checkViewportIntersectionChanged(); |
+} |
+ |
+void HTMLMediaElement::startCheckIntersectionWhenPausedTimer() { |
+ if (m_checkIntersectionWhenPausedTimer.isActive()) |
+ return; |
+ |
+ m_checkIntersectionWhenPausedTimer.startRepeating( |
+ kCheckIntersectWhenPausedIntervalInSeconds, BLINK_FROM_HERE); |
+} |
+ |
} // namespace blink |