OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 using namespace HTMLNames; | 121 using namespace HTMLNames; |
122 | 122 |
123 using WeakMediaElementSet = HeapHashSet<WeakMember<HTMLMediaElement>>; | 123 using WeakMediaElementSet = HeapHashSet<WeakMember<HTMLMediaElement>>; |
124 using DocumentElementSetMap = | 124 using DocumentElementSetMap = |
125 HeapHashMap<WeakMember<Document>, Member<WeakMediaElementSet>>; | 125 HeapHashMap<WeakMember<Document>, Member<WeakMediaElementSet>>; |
126 | 126 |
127 namespace { | 127 namespace { |
128 | 128 |
129 constexpr float kMostlyFillViewportThreshold = 0.85f; | 129 constexpr float kMostlyFillViewportThreshold = 0.85f; |
130 constexpr double kMostlyFillViewportBecomeStableSeconds = 5; | 130 constexpr double kMostlyFillViewportBecomeStableSeconds = 5; |
131 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.
| |
131 | 132 |
132 enum MediaControlsShow { | 133 enum MediaControlsShow { |
133 MediaControlsShowAttribute = 0, | 134 MediaControlsShowAttribute = 0, |
134 MediaControlsShowFullscreen, | 135 MediaControlsShowFullscreen, |
135 MediaControlsShowNoScript, | 136 MediaControlsShowNoScript, |
136 MediaControlsShowNotShown, | 137 MediaControlsShowNotShown, |
137 MediaControlsShowMax | 138 MediaControlsShowMax |
138 }; | 139 }; |
139 | 140 |
140 String urlForLoggingMedia(const KURL& url) { | 141 String urlForLoggingMedia(const KURL& url) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 ActiveScriptWrappable(this), | 364 ActiveScriptWrappable(this), |
364 ActiveDOMObject(&document), | 365 ActiveDOMObject(&document), |
365 m_loadTimer(this, &HTMLMediaElement::loadTimerFired), | 366 m_loadTimer(this, &HTMLMediaElement::loadTimerFired), |
366 m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired), | 367 m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired), |
367 m_playbackProgressTimer(this, | 368 m_playbackProgressTimer(this, |
368 &HTMLMediaElement::playbackProgressTimerFired), | 369 &HTMLMediaElement::playbackProgressTimerFired), |
369 m_audioTracksTimer(this, &HTMLMediaElement::audioTracksTimerFired), | 370 m_audioTracksTimer(this, &HTMLMediaElement::audioTracksTimerFired), |
370 m_viewportFillDebouncerTimer( | 371 m_viewportFillDebouncerTimer( |
371 this, | 372 this, |
372 &HTMLMediaElement::viewportFillDebouncerTimerFired), | 373 &HTMLMediaElement::viewportFillDebouncerTimerFired), |
374 m_checkViewportIntersectionTimer( | |
375 this, | |
376 &HTMLMediaElement::checkViewportIntersectionTimerFired), | |
373 m_playedTimeRanges(), | 377 m_playedTimeRanges(), |
374 m_asyncEventQueue(GenericEventQueue::create(this)), | 378 m_asyncEventQueue(GenericEventQueue::create(this)), |
375 m_playbackRate(1.0f), | 379 m_playbackRate(1.0f), |
376 m_defaultPlaybackRate(1.0f), | 380 m_defaultPlaybackRate(1.0f), |
377 m_networkState(kNetworkEmpty), | 381 m_networkState(kNetworkEmpty), |
378 m_readyState(kHaveNothing), | 382 m_readyState(kHaveNothing), |
379 m_readyStateMaximum(kHaveNothing), | 383 m_readyStateMaximum(kHaveNothing), |
380 m_volume(1.0f), | 384 m_volume(1.0f), |
381 m_lastSeekTime(0), | 385 m_lastSeekTime(0), |
382 m_previousProgressTime(std::numeric_limits<double>::max()), | 386 m_previousProgressTime(std::numeric_limits<double>::max()), |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2426 void HTMLMediaElement::startPlaybackProgressTimer() { | 2430 void HTMLMediaElement::startPlaybackProgressTimer() { |
2427 if (m_playbackProgressTimer.isActive()) | 2431 if (m_playbackProgressTimer.isActive()) |
2428 return; | 2432 return; |
2429 | 2433 |
2430 m_previousProgressTime = WTF::currentTime(); | 2434 m_previousProgressTime = WTF::currentTime(); |
2431 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, | 2435 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, |
2432 BLINK_FROM_HERE); | 2436 BLINK_FROM_HERE); |
2433 } | 2437 } |
2434 | 2438 |
2435 void HTMLMediaElement::playbackProgressTimerFired(TimerBase*) { | 2439 void HTMLMediaElement::playbackProgressTimerFired(TimerBase*) { |
2436 checkViewportIntersectionChanged(); | |
2437 | |
2438 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && | 2440 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && |
2439 getDirectionOfPlayback() == Forward) { | 2441 getDirectionOfPlayback() == Forward) { |
2440 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); | 2442 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); |
2441 if (!m_paused) { | 2443 if (!m_paused) { |
2442 UseCounter::count(document(), | 2444 UseCounter::count(document(), |
2443 UseCounter::HTMLMediaElementPauseAtFragmentEnd); | 2445 UseCounter::HTMLMediaElementPauseAtFragmentEnd); |
2444 // changes paused to true and fires a simple event named pause at the | 2446 // changes paused to true and fires a simple event named pause at the |
2445 // media element. | 2447 // media element. |
2446 pauseInternal(); | 2448 pauseInternal(); |
2447 } | 2449 } |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3268 addPlayedRange(m_lastSeekTime, time); | 3270 addPlayedRange(m_lastSeekTime, time); |
3269 } | 3271 } |
3270 | 3272 |
3271 if (layoutObject()) | 3273 if (layoutObject()) |
3272 layoutObject()->updateFromElement(); | 3274 layoutObject()->updateFromElement(); |
3273 } | 3275 } |
3274 | 3276 |
3275 void HTMLMediaElement::stopPeriodicTimers() { | 3277 void HTMLMediaElement::stopPeriodicTimers() { |
3276 m_progressEventTimer.stop(); | 3278 m_progressEventTimer.stop(); |
3277 m_playbackProgressTimer.stop(); | 3279 m_playbackProgressTimer.stop(); |
3280 m_checkViewportIntersectionTimer.stop(); | |
3278 } | 3281 } |
3279 | 3282 |
3280 void HTMLMediaElement:: | 3283 void HTMLMediaElement:: |
3281 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking() { | 3284 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking() { |
3282 getAudioSourceProvider().setClient(nullptr); | 3285 getAudioSourceProvider().setClient(nullptr); |
3283 if (m_webMediaPlayer) { | 3286 if (m_webMediaPlayer) { |
3284 m_audioSourceProvider.wrap(nullptr); | 3287 m_audioSourceProvider.wrap(nullptr); |
3285 m_webMediaPlayer.reset(); | 3288 m_webMediaPlayer.reset(); |
3286 } | 3289 } |
3287 } | 3290 } |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4026 } | 4029 } |
4027 | 4030 |
4028 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl) { | 4031 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl) { |
4029 visitor->trace(m_client); | 4032 visitor->trace(m_client); |
4030 } | 4033 } |
4031 | 4034 |
4032 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) { | 4035 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) { |
4033 visitor->trace(m_client); | 4036 visitor->trace(m_client); |
4034 } | 4037 } |
4035 | 4038 |
4036 void HTMLMediaElement::checkViewportIntersectionChanged() { | 4039 void HTMLMediaElement::enableMonitorViewportIntersection(bool enable) { |
4037 // TODO(xjz): Early return if we not in tab mirroring. | 4040 if (enable && !m_checkViewportIntersectionTimer.isActive()) { |
4041 m_checkViewportIntersectionTimer.startRepeating( | |
4042 kCheckViewportIntersectionIntervalInSeconds, BLINK_FROM_HERE); | |
4043 } else if (!enable) { | |
4044 m_checkViewportIntersectionTimer.stop(); | |
4045 } | |
4046 } | |
4038 | 4047 |
4048 void HTMLMediaElement::checkViewportIntersectionTimerFired(TimerBase*) { | |
4039 IntersectionGeometry geometry( | 4049 IntersectionGeometry geometry( |
4040 document().frame()->localFrameRoot()->document(), this, Vector<Length>(), | 4050 document().frame()->localFrameRoot()->document(), this, Vector<Length>(), |
4041 IntersectionGeometry::ReportRootBounds::kShouldReportRootBounds); | 4051 IntersectionGeometry::ReportRootBounds::kShouldReportRootBounds); |
4042 geometry.computeGeometry(); | 4052 geometry.computeGeometry(); |
4043 IntRect intersectRect = geometry.intersectionIntRect(); | 4053 IntRect intersectRect = geometry.intersectionIntRect(); |
4044 if (m_currentIntersectRect == intersectRect) | 4054 if (m_currentIntersectRect == intersectRect) |
4045 return; | 4055 return; |
4046 | 4056 |
4047 m_currentIntersectRect = intersectRect; | 4057 m_currentIntersectRect = intersectRect; |
4048 // Reset on any intersection change, since this indicates the user is | 4058 // Reset on any intersection change, since this indicates the user is |
(...skipping 16 matching lines...) Expand all Loading... | |
4065 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); | 4075 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); |
4066 } | 4076 } |
4067 | 4077 |
4068 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { | 4078 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { |
4069 m_mostlyFillingViewport = true; | 4079 m_mostlyFillingViewport = true; |
4070 if (m_webMediaPlayer) | 4080 if (m_webMediaPlayer) |
4071 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); | 4081 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); |
4072 } | 4082 } |
4073 | 4083 |
4074 } // namespace blink | 4084 } // namespace blink |
OLD | NEW |