| 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 kCheckViewportIntersectionIntervalSeconds = 1; |
| 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 SuspendableObject(&document), | 365 SuspendableObject(&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 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2455 void HTMLMediaElement::startPlaybackProgressTimer() { | 2459 void HTMLMediaElement::startPlaybackProgressTimer() { |
| 2456 if (m_playbackProgressTimer.isActive()) | 2460 if (m_playbackProgressTimer.isActive()) |
| 2457 return; | 2461 return; |
| 2458 | 2462 |
| 2459 m_previousProgressTime = WTF::currentTime(); | 2463 m_previousProgressTime = WTF::currentTime(); |
| 2460 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, | 2464 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, |
| 2461 BLINK_FROM_HERE); | 2465 BLINK_FROM_HERE); |
| 2462 } | 2466 } |
| 2463 | 2467 |
| 2464 void HTMLMediaElement::playbackProgressTimerFired(TimerBase*) { | 2468 void HTMLMediaElement::playbackProgressTimerFired(TimerBase*) { |
| 2465 checkViewportIntersectionChanged(); | |
| 2466 | |
| 2467 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && | 2469 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && |
| 2468 getDirectionOfPlayback() == Forward) { | 2470 getDirectionOfPlayback() == Forward) { |
| 2469 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); | 2471 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); |
| 2470 if (!m_paused) { | 2472 if (!m_paused) { |
| 2471 UseCounter::count(document(), | 2473 UseCounter::count(document(), |
| 2472 UseCounter::HTMLMediaElementPauseAtFragmentEnd); | 2474 UseCounter::HTMLMediaElementPauseAtFragmentEnd); |
| 2473 // changes paused to true and fires a simple event named pause at the | 2475 // changes paused to true and fires a simple event named pause at the |
| 2474 // media element. | 2476 // media element. |
| 2475 pauseInternal(); | 2477 pauseInternal(); |
| 2476 } | 2478 } |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3295 addPlayedRange(m_lastSeekTime, time); | 3297 addPlayedRange(m_lastSeekTime, time); |
| 3296 } | 3298 } |
| 3297 | 3299 |
| 3298 if (layoutObject()) | 3300 if (layoutObject()) |
| 3299 layoutObject()->updateFromElement(); | 3301 layoutObject()->updateFromElement(); |
| 3300 } | 3302 } |
| 3301 | 3303 |
| 3302 void HTMLMediaElement::stopPeriodicTimers() { | 3304 void HTMLMediaElement::stopPeriodicTimers() { |
| 3303 m_progressEventTimer.stop(); | 3305 m_progressEventTimer.stop(); |
| 3304 m_playbackProgressTimer.stop(); | 3306 m_playbackProgressTimer.stop(); |
| 3307 m_checkViewportIntersectionTimer.stop(); |
| 3305 } | 3308 } |
| 3306 | 3309 |
| 3307 void HTMLMediaElement:: | 3310 void HTMLMediaElement:: |
| 3308 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking() { | 3311 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking() { |
| 3309 getAudioSourceProvider().setClient(nullptr); | 3312 getAudioSourceProvider().setClient(nullptr); |
| 3310 if (m_webMediaPlayer) { | 3313 if (m_webMediaPlayer) { |
| 3311 m_audioSourceProvider.wrap(nullptr); | 3314 m_audioSourceProvider.wrap(nullptr); |
| 3312 m_webMediaPlayer.reset(); | 3315 m_webMediaPlayer.reset(); |
| 3313 } | 3316 } |
| 3314 } | 3317 } |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4055 } | 4058 } |
| 4056 | 4059 |
| 4057 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl) { | 4060 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl) { |
| 4058 visitor->trace(m_client); | 4061 visitor->trace(m_client); |
| 4059 } | 4062 } |
| 4060 | 4063 |
| 4061 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) { | 4064 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) { |
| 4062 visitor->trace(m_client); | 4065 visitor->trace(m_client); |
| 4063 } | 4066 } |
| 4064 | 4067 |
| 4065 void HTMLMediaElement::checkViewportIntersectionChanged() { | 4068 void HTMLMediaElement::activateViewportIntersectionMonitoring(bool activate) { |
| 4066 // TODO(xjz): Early return if we not in tab mirroring. | 4069 if (activate && !m_checkViewportIntersectionTimer.isActive()) { |
| 4070 m_checkViewportIntersectionTimer.startRepeating( |
| 4071 kCheckViewportIntersectionIntervalSeconds, BLINK_FROM_HERE); |
| 4072 } else if (!activate) { |
| 4073 m_checkViewportIntersectionTimer.stop(); |
| 4074 } |
| 4075 } |
| 4067 | 4076 |
| 4077 void HTMLMediaElement::checkViewportIntersectionTimerFired(TimerBase*) { |
| 4068 bool shouldReportRootBounds = true; | 4078 bool shouldReportRootBounds = true; |
| 4069 IntersectionGeometry geometry(nullptr, *this, Vector<Length>(), | 4079 IntersectionGeometry geometry(nullptr, *this, Vector<Length>(), |
| 4070 shouldReportRootBounds); | 4080 shouldReportRootBounds); |
| 4071 geometry.computeGeometry(); | 4081 geometry.computeGeometry(); |
| 4072 IntRect intersectRect = geometry.intersectionIntRect(); | 4082 IntRect intersectRect = geometry.intersectionIntRect(); |
| 4073 if (m_currentIntersectRect == intersectRect) | 4083 if (m_currentIntersectRect == intersectRect) |
| 4074 return; | 4084 return; |
| 4075 | 4085 |
| 4076 m_currentIntersectRect = intersectRect; | 4086 m_currentIntersectRect = intersectRect; |
| 4077 // Reset on any intersection change, since this indicates the user is | 4087 // Reset on any intersection change, since this indicates the user is |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4094 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); | 4104 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); |
| 4095 } | 4105 } |
| 4096 | 4106 |
| 4097 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { | 4107 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { |
| 4098 m_mostlyFillingViewport = true; | 4108 m_mostlyFillingViewport = true; |
| 4099 if (m_webMediaPlayer) | 4109 if (m_webMediaPlayer) |
| 4100 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); | 4110 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); |
| 4101 } | 4111 } |
| 4102 | 4112 |
| 4103 } // namespace blink | 4113 } // namespace blink |
| OLD | NEW |