| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/html/HTMLMediaElement.h" | 26 #include "core/html/HTMLMediaElement.h" |
| 27 | 27 |
| 28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
| 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 30 #include "bindings/core/v8/Microtask.h" |
| 30 #include "bindings/core/v8/ScriptController.h" | 31 #include "bindings/core/v8/ScriptController.h" |
| 31 #include "bindings/core/v8/ScriptEventListener.h" | 32 #include "bindings/core/v8/ScriptEventListener.h" |
| 32 #include "bindings/core/v8/ScriptPromiseResolver.h" | 33 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 33 #include "core/HTMLNames.h" | 34 #include "core/HTMLNames.h" |
| 34 #include "core/css/MediaList.h" | 35 #include "core/css/MediaList.h" |
| 35 #include "core/dom/Attribute.h" | 36 #include "core/dom/Attribute.h" |
| 36 #include "core/dom/DOMException.h" | 37 #include "core/dom/DOMException.h" |
| 37 #include "core/dom/ElementTraversal.h" | 38 #include "core/dom/ElementTraversal.h" |
| 38 #include "core/dom/ElementVisibilityObserver.h" | 39 #include "core/dom/ElementVisibilityObserver.h" |
| 39 #include "core/dom/Fullscreen.h" | 40 #include "core/dom/Fullscreen.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 382 |
| 382 bool HTMLMediaElement::isMediaStreamURL(const String& url) | 383 bool HTMLMediaElement::isMediaStreamURL(const String& url) |
| 383 { | 384 { |
| 384 return s_mediaStreamRegistry ? s_mediaStreamRegistry->contains(url) : false; | 385 return s_mediaStreamRegistry ? s_mediaStreamRegistry->contains(url) : false; |
| 385 } | 386 } |
| 386 | 387 |
| 387 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
ent) | 388 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
ent) |
| 388 : HTMLElement(tagName, document) | 389 : HTMLElement(tagName, document) |
| 389 , ActiveScriptWrappable(this) | 390 , ActiveScriptWrappable(this) |
| 390 , ActiveDOMObject(&document) | 391 , ActiveDOMObject(&document) |
| 391 , m_loadTimer(this, &HTMLMediaElement::loadTimerFired) | 392 , m_textTrackLoadTimer(this, &HTMLMediaElement::textTrackLoadTimerFired) |
| 392 , m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired) | 393 , m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired) |
| 393 , m_playbackProgressTimer(this, &HTMLMediaElement::playbackProgressTimerFire
d) | 394 , m_playbackProgressTimer(this, &HTMLMediaElement::playbackProgressTimerFire
d) |
| 394 , m_audioTracksTimer(this, &HTMLMediaElement::audioTracksTimerFired) | 395 , m_audioTracksTimer(this, &HTMLMediaElement::audioTracksTimerFired) |
| 395 , m_playedTimeRanges() | 396 , m_playedTimeRanges() |
| 396 , m_asyncEventQueue(GenericEventQueue::create(this)) | 397 , m_asyncEventQueue(GenericEventQueue::create(this)) |
| 397 , m_playbackRate(1.0f) | 398 , m_playbackRate(1.0f) |
| 398 , m_defaultPlaybackRate(1.0f) | 399 , m_defaultPlaybackRate(1.0f) |
| 399 , m_networkState(kNetworkEmpty) | 400 , m_networkState(kNetworkEmpty) |
| 400 , m_readyState(kHaveNothing) | 401 , m_readyState(kHaveNothing) |
| 401 , m_readyStateMaximum(kHaveNothing) | 402 , m_readyStateMaximum(kHaveNothing) |
| 402 , m_volume(1.0f) | 403 , m_volume(1.0f) |
| 403 , m_lastSeekTime(0) | 404 , m_lastSeekTime(0) |
| 404 , m_previousProgressTime(std::numeric_limits<double>::max()) | 405 , m_previousProgressTime(std::numeric_limits<double>::max()) |
| 405 , m_duration(std::numeric_limits<double>::quiet_NaN()) | 406 , m_duration(std::numeric_limits<double>::quiet_NaN()) |
| 406 , m_lastTimeUpdateEventWallTime(0) | 407 , m_lastTimeUpdateEventWallTime(0) |
| 407 , m_lastTimeUpdateEventMovieTime(0) | 408 , m_lastTimeUpdateEventMovieTime(0) |
| 408 , m_defaultPlaybackStartPosition(0) | 409 , m_defaultPlaybackStartPosition(0) |
| 409 , m_loadState(WaitingForSource) | 410 , m_loadState(WaitingForSource) |
| 410 , m_deferredLoadState(NotDeferred) | 411 , m_deferredLoadState(NotDeferred) |
| 411 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) | 412 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) |
| 412 , m_webLayer(nullptr) | 413 , m_webLayer(nullptr) |
| 413 , m_displayMode(Unknown) | 414 , m_displayMode(Unknown) |
| 414 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) | 415 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) |
| 415 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) | 416 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) |
| 416 , m_pendingActionFlags(0) | |
| 417 , m_lockedPendingUserGesture(false) | 417 , m_lockedPendingUserGesture(false) |
| 418 , m_playing(false) | 418 , m_playing(false) |
| 419 , m_shouldDelayLoadEvent(false) | 419 , m_shouldDelayLoadEvent(false) |
| 420 , m_haveFiredLoadedData(false) | 420 , m_haveFiredLoadedData(false) |
| 421 , m_autoplaying(true) | 421 , m_autoplaying(true) |
| 422 , m_muted(false) | 422 , m_muted(false) |
| 423 , m_paused(true) | 423 , m_paused(true) |
| 424 , m_seeking(false) | 424 , m_seeking(false) |
| 425 , m_sentStalledEvent(false) | 425 , m_sentStalledEvent(false) |
| 426 , m_ignorePreloadNone(false) | 426 , m_ignorePreloadNone(false) |
| 427 , m_textTracksVisible(false) | 427 , m_textTracksVisible(false) |
| 428 , m_shouldPerformAutomaticTrackSelection(true) | 428 , m_shouldPerformAutomaticTrackSelection(true) |
| 429 , m_tracksAreReady(true) | 429 , m_tracksAreReady(true) |
| 430 , m_processingPreferenceChange(false) | 430 , m_processingPreferenceChange(false) |
| 431 , m_remoteRoutesAvailable(false) | 431 , m_remoteRoutesAvailable(false) |
| 432 , m_playingRemotely(false) | 432 , m_playingRemotely(false) |
| 433 , m_inOverlayFullscreenVideo(false) | 433 , m_inOverlayFullscreenVideo(false) |
| 434 , m_audioTracks(AudioTrackList::create(*this)) | 434 , m_audioTracks(AudioTrackList::create(*this)) |
| 435 , m_videoTracks(VideoTrackList::create(*this)) | 435 , m_videoTracks(VideoTrackList::create(*this)) |
| 436 , m_textTracks(nullptr) | 436 , m_textTracks(nullptr) |
| 437 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl
ement::resolveScheduledPlayPromises)) | 437 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl
ement::resolveScheduledPlayPromises)) |
| 438 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle
ment::rejectScheduledPlayPromises)) | 438 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle
ment::rejectScheduledPlayPromises)) |
| 439 , m_weakTaskFactory(this) |
| 439 , m_audioSourceNode(nullptr) | 440 , m_audioSourceNode(nullptr) |
| 440 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) | 441 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) |
| 441 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g
et())) | 442 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g
et())) |
| 442 , m_autoplayUmaHelper(AutoplayUmaHelper::create(this)) | 443 , m_autoplayUmaHelper(AutoplayUmaHelper::create(this)) |
| 443 , m_remotePlaybackClient(nullptr) | 444 , m_remotePlaybackClient(nullptr) |
| 444 , m_autoplayVisibilityObserver(nullptr) | 445 , m_autoplayVisibilityObserver(nullptr) |
| 445 { | 446 { |
| 446 ThreadState::current()->registerPreFinalizer(this); | 447 ThreadState::current()->registerPreFinalizer(this); |
| 447 | 448 |
| 448 BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; | 449 BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) | 629 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) |
| 629 { | 630 { |
| 630 if (layoutObject()) | 631 if (layoutObject()) |
| 631 layoutObject()->updateFromElement(); | 632 layoutObject()->updateFromElement(); |
| 632 } | 633 } |
| 633 | 634 |
| 634 void HTMLMediaElement::scheduleTextTrackResourceLoad() | 635 void HTMLMediaElement::scheduleTextTrackResourceLoad() |
| 635 { | 636 { |
| 636 BLINK_MEDIA_LOG << "scheduleTextTrackResourceLoad(" << (void*)this << ")"; | 637 BLINK_MEDIA_LOG << "scheduleTextTrackResourceLoad(" << (void*)this << ")"; |
| 637 | 638 |
| 638 m_pendingActionFlags |= LoadTextTrackResource; | 639 if (!m_textTrackLoadTimer.isActive()) |
| 639 | 640 m_textTrackLoadTimer.startOneShot(0, BLINK_FROM_HERE); |
| 640 if (!m_loadTimer.isActive()) | |
| 641 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | |
| 642 } | |
| 643 | |
| 644 void HTMLMediaElement::scheduleNextSourceChild() | |
| 645 { | |
| 646 // Schedule the timer to try the next <source> element WITHOUT resetting sta
te ala invokeLoadAlgorithm. | |
| 647 m_pendingActionFlags |= LoadMediaResource; | |
| 648 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | |
| 649 } | 641 } |
| 650 | 642 |
| 651 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) | 643 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) |
| 652 { | 644 { |
| 653 scheduleEvent(Event::createCancelable(eventName)); | 645 scheduleEvent(Event::createCancelable(eventName)); |
| 654 } | 646 } |
| 655 | 647 |
| 656 void HTMLMediaElement::scheduleEvent(Event* event) | 648 void HTMLMediaElement::scheduleEvent(Event* event) |
| 657 { | 649 { |
| 658 #if LOG_MEDIA_EVENTS | 650 #if LOG_MEDIA_EVENTS |
| 659 BLINK_MEDIA_LOG << "scheduleEvent(" << (void*)this << ")" << " - scheduling
'" << event->type() << "'"; | 651 BLINK_MEDIA_LOG << "scheduleEvent(" << (void*)this << ")" << " - scheduling
'" << event->type() << "'"; |
| 660 #endif | 652 #endif |
| 661 m_asyncEventQueue->enqueueEvent(event); | 653 m_asyncEventQueue->enqueueEvent(event); |
| 662 } | 654 } |
| 663 | 655 |
| 664 void HTMLMediaElement::loadTimerFired(TimerBase*) | 656 void HTMLMediaElement::textTrackLoadTimerFired(TimerBase*) |
| 665 { | 657 { |
| 666 if (m_pendingActionFlags & LoadTextTrackResource) | 658 BLINK_MEDIA_LOG << "HTMLMediaElement::textTrackLoadTimerFired(" << (void*)th
is << ")"; |
| 667 honorUserPreferencesForAutomaticTextTrackSelection(); | 659 honorUserPreferencesForAutomaticTextTrackSelection(); |
| 668 | |
| 669 if (m_pendingActionFlags & LoadMediaResource) { | |
| 670 if (m_loadState == LoadingFromSourceElement) | |
| 671 loadNextSourceChild(); | |
| 672 else | |
| 673 loadInternal(); | |
| 674 } | |
| 675 | |
| 676 m_pendingActionFlags = 0; | |
| 677 } | 660 } |
| 678 | 661 |
| 679 MediaError* HTMLMediaElement::error() const | 662 MediaError* HTMLMediaElement::error() const |
| 680 { | 663 { |
| 681 return m_error; | 664 return m_error; |
| 682 } | 665 } |
| 683 | 666 |
| 684 void HTMLMediaElement::setSrc(const AtomicString& url) | 667 void HTMLMediaElement::setSrc(const AtomicString& url) |
| 685 { | 668 { |
| 686 setAttribute(srcAttr, url); | 669 setAttribute(srcAttr, url); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 // TODO(srirama.m): Currently m_ignorePreloadNone is reset before calling | 717 // TODO(srirama.m): Currently m_ignorePreloadNone is reset before calling |
| 735 // invokeLoadAlgorithm() in all places except load(). Move it inside here | 718 // invokeLoadAlgorithm() in all places except load(). Move it inside here |
| 736 // once microtask is implemented for "Await a stable state" step | 719 // once microtask is implemented for "Await a stable state" step |
| 737 // in resource selection algorithm. | 720 // in resource selection algorithm. |
| 738 void HTMLMediaElement::invokeLoadAlgorithm() | 721 void HTMLMediaElement::invokeLoadAlgorithm() |
| 739 { | 722 { |
| 740 BLINK_MEDIA_LOG << "invokeLoadAlgorithm(" << (void*)this << ")"; | 723 BLINK_MEDIA_LOG << "invokeLoadAlgorithm(" << (void*)this << ")"; |
| 741 | 724 |
| 742 // Perform the cleanup required for the resource load algorithm to run. | 725 // Perform the cleanup required for the resource load algorithm to run. |
| 743 stopPeriodicTimers(); | 726 stopPeriodicTimers(); |
| 744 m_loadTimer.stop(); | |
| 745 cancelDeferredLoad(); | 727 cancelDeferredLoad(); |
| 746 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec
essary and set m_pendingActionFlags to 0 here. | |
| 747 m_pendingActionFlags &= ~LoadMediaResource; | |
| 748 m_sentStalledEvent = false; | 728 m_sentStalledEvent = false; |
| 749 m_haveFiredLoadedData = false; | 729 m_haveFiredLoadedData = false; |
| 750 m_displayMode = Unknown; | 730 m_displayMode = Unknown; |
| 751 | 731 |
| 752 // 1 - Abort any already-running instance of the resource selection algorith
m for this element. | 732 // 1 - Abort any already-running instance of the resource selection algorith
m for this element. |
| 733 m_weakTaskFactory.revokeAll(); |
| 753 m_loadState = WaitingForSource; | 734 m_loadState = WaitingForSource; |
| 754 m_currentSourceNode = nullptr; | 735 m_currentSourceNode = nullptr; |
| 755 | 736 |
| 756 // 2 - Let pending tasks be a list of tasks from the media element's media | 737 // 2 - Let pending tasks be a list of tasks from the media element's media |
| 757 // element task source in one of the task queues. | 738 // element task source in one of the task queues. |
| 758 // | 739 // |
| 759 // 3 - For each task in the pending tasks that would run resolve pending | 740 // 3 - For each task in the pending tasks that would run resolve pending |
| 760 // play promises or project pending play prmoises algorithms, immediately | 741 // play promises or project pending play prmoises algorithms, immediately |
| 761 // resolve or reject those promises in the order the corresponding tasks | 742 // resolve or reject those promises in the order the corresponding tasks |
| 762 // were queued. | 743 // were queued. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 // 8 - Set the error attribute to null and the autoplaying flag to true. | 821 // 8 - Set the error attribute to null and the autoplaying flag to true. |
| 841 m_error = nullptr; | 822 m_error = nullptr; |
| 842 m_autoplaying = true; | 823 m_autoplaying = true; |
| 843 | 824 |
| 844 // 9 - Invoke the media element's resource selection algorithm. | 825 // 9 - Invoke the media element's resource selection algorithm. |
| 845 invokeResourceSelectionAlgorithm(); | 826 invokeResourceSelectionAlgorithm(); |
| 846 | 827 |
| 847 // 10 - Note: Playback of any previously playing media resource for this ele
ment stops. | 828 // 10 - Note: Playback of any previously playing media resource for this ele
ment stops. |
| 848 } | 829 } |
| 849 | 830 |
| 831 void HTMLMediaElement::continueResourceSelectionAlgorithm() |
| 832 { |
| 833 BLINK_MEDIA_LOG << "HTMLMediaElement::continueResourceSelectionAlgorithm(" <
< (void*)this << ")"; |
| 834 loadInternal(); |
| 835 } |
| 836 |
| 850 void HTMLMediaElement::invokeResourceSelectionAlgorithm() | 837 void HTMLMediaElement::invokeResourceSelectionAlgorithm() |
| 851 { | 838 { |
| 852 BLINK_MEDIA_LOG << "invokeResourceSelectionAlgorithm(" << (void*)this << ")"
; | 839 BLINK_MEDIA_LOG << "invokeResourceSelectionAlgorithm(" << (void*)this << ")"
; |
| 853 // The resource selection algorithm | 840 // The resource selection algorithm |
| 854 // 1 - Set the networkState to NETWORK_NO_SOURCE | 841 // 1 - Set the networkState to NETWORK_NO_SOURCE |
| 855 setNetworkState(kNetworkNoSource); | 842 setNetworkState(kNetworkNoSource); |
| 856 | 843 |
| 857 // 2 - Set the element's show poster flag to true | 844 // 2 - Set the element's show poster flag to true |
| 858 // TODO(srirama.m): Introduce show poster flag and update it as per spec | 845 // TODO(srirama.m): Introduce show poster flag and update it as per spec |
| 859 | 846 |
| 860 m_playedTimeRanges = TimeRanges::create(); | 847 m_playedTimeRanges = TimeRanges::create(); |
| 861 | 848 |
| 862 // FIXME: Investigate whether these can be moved into m_networkState != kNet
workEmpty block above | 849 // FIXME: Investigate whether these can be moved into m_networkState != kNet
workEmpty block above |
| 863 // so they are closer to the relevant spec steps. | 850 // so they are closer to the relevant spec steps. |
| 864 m_lastSeekTime = 0; | 851 m_lastSeekTime = 0; |
| 865 m_duration = std::numeric_limits<double>::quiet_NaN(); | 852 m_duration = std::numeric_limits<double>::quiet_NaN(); |
| 866 | 853 |
| 867 // 3 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event) | 854 // 3 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event) |
| 868 setShouldDelayLoadEvent(true); | 855 setShouldDelayLoadEvent(true); |
| 869 if (mediaControls()) | 856 if (mediaControls()) |
| 870 mediaControls()->reset(); | 857 mediaControls()->reset(); |
| 871 | 858 |
| 872 // 4 - Await a stable state, allowing the task that invoked this algorithm t
o continue | 859 // 4 - Await a stable state, allowing the task that invoked this algorithm t
o continue |
| 873 // TODO(srirama.m): Remove scheduleNextSourceChild() and post a microtask in
stead. | 860 Microtask::enqueueMicrotask(WTF::bind(&HTMLMediaElement::continueResourceSel
ectionAlgorithm, m_weakTaskFactory.createWeakPtr())); |
| 874 // See http://crbug.com/593289 for more details. | |
| 875 scheduleNextSourceChild(); | |
| 876 } | 861 } |
| 877 | 862 |
| 878 void HTMLMediaElement::loadInternal() | 863 void HTMLMediaElement::loadInternal() |
| 879 { | 864 { |
| 880 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose
mode was not in the | 865 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose
mode was not in the |
| 881 // disabled state when the element's resource selection algorithm last start
ed". | 866 // disabled state when the element's resource selection algorithm last start
ed". |
| 882 m_textTracksWhenResourceSelectionBegan.clear(); | 867 m_textTracksWhenResourceSelectionBegan.clear(); |
| 883 if (m_textTracks) { | 868 if (m_textTracks) { |
| 884 for (unsigned i = 0; i < m_textTracks->length(); ++i) { | 869 for (unsigned i = 0; i < m_textTracks->length(); ++i) { |
| 885 TextTrack* track = m_textTracks->anonymousIndexedGetter(i); | 870 TextTrack* track = m_textTracks->anonymousIndexedGetter(i); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 return; | 980 return; |
| 996 } | 981 } |
| 997 | 982 |
| 998 // Reset the MediaPlayer and MediaSource if any | 983 // Reset the MediaPlayer and MediaSource if any |
| 999 resetMediaPlayerAndMediaSource(); | 984 resetMediaPlayerAndMediaSource(); |
| 1000 | 985 |
| 1001 m_loadState = LoadingFromSourceElement; | 986 m_loadState = LoadingFromSourceElement; |
| 1002 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); | 987 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); |
| 1003 } | 988 } |
| 1004 | 989 |
| 990 void HTMLMediaElement::loadNextSourceChildAfterError() |
| 991 { |
| 992 // 9.Otherwise.11 - Forget the media element's media-resource-specific track
s. |
| 993 forgetResourceSpecificTracks(); |
| 994 loadNextSourceChild(); |
| 995 } |
| 996 |
| 1005 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, const Co
ntentType& contentType) | 997 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, const Co
ntentType& contentType) |
| 1006 { | 998 { |
| 1007 DCHECK(isMainThread()); | 999 DCHECK(isMainThread()); |
| 1008 KURL url; | 1000 KURL url; |
| 1009 if (source.isURL()) { | 1001 if (source.isURL()) { |
| 1010 url = source.getAsURL(); | 1002 url = source.getAsURL(); |
| 1011 DCHECK(isSafeToLoadURL(url, Complain)); | 1003 DCHECK(isSafeToLoadURL(url, Complain)); |
| 1012 BLINK_MEDIA_LOG << "loadResource(" << (void*)this << ", " << urlForLoggi
ngMedia(url) << ", " << contentType.raw() << ")"; | 1004 BLINK_MEDIA_LOG << "loadResource(" << (void*)this << ", " << urlForLoggi
ngMedia(url) << ", " << contentType.raw() << ")"; |
| 1013 } | 1005 } |
| 1014 | 1006 |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 if (m_readyState < kHaveMetadata && m_loadState == LoadingFromSourceElement)
{ | 1425 if (m_readyState < kHaveMetadata && m_loadState == LoadingFromSourceElement)
{ |
| 1434 | 1426 |
| 1435 // resource selection algorithm | 1427 // resource selection algorithm |
| 1436 // Step 9.Otherwise.9 - Failed with elements: Queue a task, using the DO
M manipulation task source, to fire a simple event named error at the candidate
element. | 1428 // Step 9.Otherwise.9 - Failed with elements: Queue a task, using the DO
M manipulation task source, to fire a simple event named error at the candidate
element. |
| 1437 if (m_currentSourceNode) | 1429 if (m_currentSourceNode) |
| 1438 m_currentSourceNode->scheduleErrorEvent(); | 1430 m_currentSourceNode->scheduleErrorEvent(); |
| 1439 else | 1431 else |
| 1440 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ") - error e
vent not sent, <source> was removed"; | 1432 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ") - error e
vent not sent, <source> was removed"; |
| 1441 | 1433 |
| 1442 // 9.Otherwise.10 - Asynchronously await a stable state. The synchronous
section consists of all the remaining steps of this algorithm until the algorit
hm says the synchronous section has ended. | 1434 // 9.Otherwise.10 - Asynchronously await a stable state. The synchronous
section consists of all the remaining steps of this algorithm until the algorit
hm says the synchronous section has ended. |
| 1443 | |
| 1444 // 9.Otherwise.11 - Forget the media element's media-resource-specific t
racks. | |
| 1445 forgetResourceSpecificTracks(); | |
| 1446 | |
| 1447 if (havePotentialSourceChild()) { | 1435 if (havePotentialSourceChild()) { |
| 1448 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ") - schedul
ing next <source>"; | 1436 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ") - schedul
ing next <source>"; |
| 1449 scheduleNextSourceChild(); | 1437 Microtask::enqueueMicrotask(WTF::bind(&HTMLMediaElement::loadNextSou
rceChildAfterError, m_weakTaskFactory.createWeakPtr())); |
| 1450 } else { | 1438 } else { |
| 1451 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ") - no more
<source> elements, waiting"; | 1439 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ") - no more
<source> elements, waiting"; |
| 1452 waitForSourceChange(); | 1440 waitForSourceChange(); |
| 1453 } | 1441 } |
| 1454 | 1442 |
| 1455 return; | 1443 return; |
| 1456 } | 1444 } |
| 1457 | 1445 |
| 1458 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= kHa
veMetadata) | 1446 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= kHa
veMetadata) |
| 1459 mediaEngineError(MediaError::create(MediaError::kMediaErrNetwork)); | 1447 mediaEngineError(MediaError::create(MediaError::kMediaErrNetwork)); |
| (...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2853 // 22. Asynchronously await a stable state... | 2841 // 22. Asynchronously await a stable state... |
| 2854 // 23. Set the element's delaying-the-load-event flag back to true (this del
ays the load event again, in case | 2842 // 23. Set the element's delaying-the-load-event flag back to true (this del
ays the load event again, in case |
| 2855 // it hasn't been fired yet). | 2843 // it hasn't been fired yet). |
| 2856 setShouldDelayLoadEvent(true); | 2844 setShouldDelayLoadEvent(true); |
| 2857 | 2845 |
| 2858 // 24. Set the networkState back to NETWORK_LOADING. | 2846 // 24. Set the networkState back to NETWORK_LOADING. |
| 2859 setNetworkState(kNetworkLoading); | 2847 setNetworkState(kNetworkLoading); |
| 2860 | 2848 |
| 2861 // 25. Jump back to the find next candidate step above. | 2849 // 25. Jump back to the find next candidate step above. |
| 2862 m_nextChildNodeToConsider = source; | 2850 m_nextChildNodeToConsider = source; |
| 2863 scheduleNextSourceChild(); | 2851 loadNextSourceChild(); |
| 2864 } | 2852 } |
| 2865 | 2853 |
| 2866 void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source) | 2854 void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source) |
| 2867 { | 2855 { |
| 2868 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ", " << source << "
)"; | 2856 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ", " << source << "
)"; |
| 2869 | 2857 |
| 2870 KURL url = source->getNonEmptyURLAttribute(srcAttr); | 2858 KURL url = source->getNonEmptyURLAttribute(srcAttr); |
| 2871 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ") - 'src' is " <<
urlForLoggingMedia(url); | 2859 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ") - 'src' is " <<
urlForLoggingMedia(url); |
| 2872 | 2860 |
| 2873 if (source != m_currentSourceNode && source != m_nextChildNodeToConsider) | 2861 if (source != m_currentSourceNode && source != m_nextChildNodeToConsider) |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3201 closeMediaSource(); | 3189 closeMediaSource(); |
| 3202 | 3190 |
| 3203 cancelDeferredLoad(); | 3191 cancelDeferredLoad(); |
| 3204 | 3192 |
| 3205 { | 3193 { |
| 3206 AudioSourceProviderClientLockScope scope(*this); | 3194 AudioSourceProviderClientLockScope scope(*this); |
| 3207 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 3195 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
| 3208 } | 3196 } |
| 3209 | 3197 |
| 3210 stopPeriodicTimers(); | 3198 stopPeriodicTimers(); |
| 3211 m_loadTimer.stop(); | 3199 m_textTrackLoadTimer.stop(); |
| 3212 | 3200 |
| 3213 m_pendingActionFlags = 0; | |
| 3214 m_loadState = WaitingForSource; | 3201 m_loadState = WaitingForSource; |
| 3215 | 3202 |
| 3216 // We can't cast if we don't have a media player. | 3203 // We can't cast if we don't have a media player. |
| 3217 m_remoteRoutesAvailable = false; | 3204 m_remoteRoutesAvailable = false; |
| 3218 m_playingRemotely = false; | 3205 m_playingRemotely = false; |
| 3219 if (mediaControls()) | 3206 if (mediaControls()) |
| 3220 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); | 3207 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); |
| 3221 | 3208 |
| 3222 if (layoutObject()) | 3209 if (layoutObject()) |
| 3223 layoutObject()->setShouldDoFullPaintInvalidation(); | 3210 layoutObject()->setShouldDoFullPaintInvalidation(); |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4027 | 4014 |
| 4028 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst | 4015 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst |
| 4029 { | 4016 { |
| 4030 IntRect result; | 4017 IntRect result; |
| 4031 if (LayoutObject* object = m_element->layoutObject()) | 4018 if (LayoutObject* object = m_element->layoutObject()) |
| 4032 result = object->absoluteBoundingBoxRect(); | 4019 result = object->absoluteBoundingBoxRect(); |
| 4033 return result; | 4020 return result; |
| 4034 } | 4021 } |
| 4035 | 4022 |
| 4036 } // namespace blink | 4023 } // namespace blink |
| OLD | NEW |