Chromium Code Reviews| 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 |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 754 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. | 754 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. |
| 755 m_pendingActionFlags &= ~LoadMediaResource; | 755 m_pendingActionFlags &= ~LoadMediaResource; |
| 756 m_sentStalledEvent = false; | 756 m_sentStalledEvent = false; |
| 757 m_haveFiredLoadedData = false; | 757 m_haveFiredLoadedData = false; |
| 758 m_displayMode = Unknown; | 758 m_displayMode = Unknown; |
| 759 | 759 |
| 760 // 1 - Abort any already-running instance of the resource selection algorith m for this element. | 760 // 1 - Abort any already-running instance of the resource selection algorith m for this element. |
| 761 m_loadState = WaitingForSource; | 761 m_loadState = WaitingForSource; |
| 762 m_currentSourceNode = nullptr; | 762 m_currentSourceNode = nullptr; |
| 763 | 763 |
| 764 // 2 - If there are any tasks from the media element's media element event t ask source in | 764 // 2 - Let pending tasks be a list of tasks from the media element's media |
| 765 // one of the task queues, then remove those tasks. | 765 // element task source in one of the task queues. |
| 766 // | |
| 767 // 3 - For each task in the pending tasks that would run resolve pending | |
| 768 // play promises or project pending play prmoises algorithms, immediately | |
| 769 // resolve or reject those promises in the order the corresponding tasks | |
|
foolip
2016/08/03 16:31:51
Write a TODO about the order or change the spec if
mlamouri (slow - plz ping)
2016/08/04 11:16:16
I'm not sure what you mean. This is in order, we a
foolip
2016/08/04 13:47:37
New tests LGTM. The tricky case I was thinking abo
mlamouri (slow - plz ping)
2016/08/04 14:25:37
Added TODO.
| |
| 770 // were queued. | |
| 771 if (m_playPromiseResolveTask->isPending()) { | |
| 772 m_playPromiseResolveTask->cancel(); | |
| 773 resolveScheduledPlayPromises(); | |
| 774 } | |
| 775 if (m_playPromiseRejectTask->isPending()) { | |
| 776 m_playPromiseRejectTask->cancel(); | |
| 777 rejectScheduledPlayPromises(); | |
| 778 } | |
| 779 | |
| 780 // 4 - Remove each task in pending tasks from its task queue. | |
| 766 cancelPendingEventsAndCallbacks(); | 781 cancelPendingEventsAndCallbacks(); |
| 767 | 782 |
| 768 rejectPlayPromises(AbortError, "The play() request was interrupted by a new load request."); | 783 // 5 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue |
| 769 | |
| 770 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue | |
| 771 // a task to fire a simple event named abort at the media element. | 784 // a task to fire a simple event named abort at the media element. |
| 772 if (m_networkState == kNetworkLoading || m_networkState == kNetworkIdle) | 785 if (m_networkState == kNetworkLoading || m_networkState == kNetworkIdle) |
| 773 scheduleEvent(EventTypeNames::abort); | 786 scheduleEvent(EventTypeNames::abort); |
| 774 | 787 |
| 775 resetMediaPlayerAndMediaSource(); | 788 resetMediaPlayerAndMediaSource(); |
| 776 | 789 |
| 777 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps | 790 // 6 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps |
| 778 if (m_networkState != kNetworkEmpty) { | 791 if (m_networkState != kNetworkEmpty) { |
| 779 // 4.1 - Queue a task to fire a simple event named emptied at the media element. | 792 // 4.1 - Queue a task to fire a simple event named emptied at the media element. |
| 780 scheduleEvent(EventTypeNames::emptied); | 793 scheduleEvent(EventTypeNames::emptied); |
| 781 | 794 |
| 782 // 4.2 - If a fetching process is in progress for the media element, the user agent should stop it. | 795 // 4.2 - Take pending play promises and reject pending play promises wit h the result and an "AbortError" DOMException. |
| 796 rejectPlayPromises(AbortError, "The play() request was interrupted by a new load request."); | |
|
foolip
2016/08/03 16:31:51
If this moves down in the spec, I guess the else b
mlamouri (slow - plz ping)
2016/08/04 11:16:16
I guess you are referring to the spec that says if
foolip
2016/08/04 13:47:37
Yeah, I mean you could DCHECK something in an else
mlamouri (slow - plz ping)
2016/08/04 14:25:37
Added a DCHECK.
| |
| 797 | |
| 798 // 4.3 - If a fetching process is in progress for the media element, the user agent should stop it. | |
| 783 setNetworkState(kNetworkEmpty); | 799 setNetworkState(kNetworkEmpty); |
| 784 | 800 |
| 785 // 4.3 - Forget the media element's media-resource-specific tracks. | 801 // 4.5 - Forget the media element's media-resource-specific tracks. |
| 786 forgetResourceSpecificTracks(); | 802 forgetResourceSpecificTracks(); |
| 787 | 803 |
| 788 // 4.4 - If readyState is not set to HAVE_NOTHING, then set it to that s tate. | 804 // 4.6 - If readyState is not set to HAVE_NOTHING, then set it to that s tate. |
| 789 m_readyState = kHaveNothing; | 805 m_readyState = kHaveNothing; |
| 790 m_readyStateMaximum = kHaveNothing; | 806 m_readyStateMaximum = kHaveNothing; |
| 791 | 807 |
| 792 // 4.5 - If the paused attribute is false, then set it to true. | 808 // 4.6 - If the paused attribute is false, then set it to true. |
| 793 m_paused = true; | 809 m_paused = true; |
| 794 | 810 |
| 795 // 4.6 - If seeking is true, set it to false. | 811 // 4.7 - If seeking is true, set it to false. |
| 796 m_seeking = false; | 812 m_seeking = false; |
| 797 | 813 |
| 798 // 4.7 - Set the current playback position to 0. | 814 // 4.8 - Set the current playback position to 0. |
| 799 // Set the official playback position to 0. | 815 // Set the official playback position to 0. |
| 800 // If this changed the official playback position, then queue a ta sk to fire a simple event named timeupdate at the media element. | 816 // If this changed the official playback position, then queue a ta sk to fire a simple event named timeupdate at the media element. |
| 801 // FIXME: Add support for firing this event. | 817 // FIXME: Add support for firing this event. |
| 802 | 818 |
| 803 // 4.8 - Set the initial playback position to 0. | 819 // 4.9 - Set the initial playback position to 0. |
| 804 // FIXME: Make this less subtle. The position only becomes 0 because the ready state is kHaveNothing. | 820 // FIXME: Make this less subtle. The position only becomes 0 because the ready state is HAVE_NOTHING. |
| 805 invalidateCachedTime(); | 821 invalidateCachedTime(); |
| 806 | 822 |
| 807 // 4.9 - Set the timeline offset to Not-a-Number (NaN). | 823 // 4.10 - Set the timeline offset to Not-a-Number (NaN). |
| 808 // 4.10 - Update the duration attribute to Not-a-Number (NaN). | 824 // 4.11 - Update the duration attribute to Not-a-Number (NaN). |
| 809 | 825 |
| 810 cueTimeline().updateActiveCues(0); | 826 cueTimeline().updateActiveCues(0); |
| 811 } else if (!m_paused) { | 827 } else if (!m_paused) { |
| 812 // TODO(foolip): There is a proposal to always reset the paused state | 828 // TODO(foolip): There is a proposal to always reset the paused state |
| 813 // in the media element load algorithm, to avoid a bogus play() promise | 829 // in the media element load algorithm, to avoid a bogus play() promise |
| 814 // rejection: https://github.com/whatwg/html/issues/869 | 830 // rejection: https://github.com/whatwg/html/issues/869 |
| 815 // This is where that change would have an effect, and it is measured to | 831 // This is where that change would have an effect, and it is measured to |
| 816 // verify the assumption that it's a very rare situation. | 832 // verify the assumption that it's a very rare situation. |
| 817 UseCounter::count(document(), UseCounter::HTMLMediaElementLoadNetworkEmp tyNotPaused); | 833 UseCounter::count(document(), UseCounter::HTMLMediaElementLoadNetworkEmp tyNotPaused); |
| 818 } | 834 } |
| 819 | 835 |
| 820 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute. | 836 // 7 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute. |
| 821 setPlaybackRate(defaultPlaybackRate()); | 837 setPlaybackRate(defaultPlaybackRate()); |
| 822 | 838 |
| 823 // 6 - Set the error attribute to null and the autoplaying flag to true. | 839 // 8 - Set the error attribute to null and the autoplaying flag to true. |
| 824 m_error = nullptr; | 840 m_error = nullptr; |
| 825 m_autoplaying = true; | 841 m_autoplaying = true; |
| 826 | 842 |
| 827 // 7 - Invoke the media element's resource selection algorithm. | 843 // 9 - Invoke the media element's resource selection algorithm. |
| 828 invokeResourceSelectionAlgorithm(); | 844 invokeResourceSelectionAlgorithm(); |
| 829 | 845 |
| 830 // 8 - Note: Playback of any previously playing media resource for this elem ent stops. | 846 // 10 - Note: Playback of any previously playing media resource for this ele ment stops. |
| 831 } | 847 } |
| 832 | 848 |
| 833 void HTMLMediaElement::invokeResourceSelectionAlgorithm() | 849 void HTMLMediaElement::invokeResourceSelectionAlgorithm() |
| 834 { | 850 { |
| 835 BLINK_MEDIA_LOG << "invokeResourceSelectionAlgorithm(" << (void*)this << ")" ; | 851 BLINK_MEDIA_LOG << "invokeResourceSelectionAlgorithm(" << (void*)this << ")" ; |
| 836 // The resource selection algorithm | 852 // The resource selection algorithm |
| 837 // 1 - Set the networkState to NETWORK_NO_SOURCE | 853 // 1 - Set the networkState to NETWORK_NO_SOURCE |
| 838 setNetworkState(kNetworkNoSource); | 854 setNetworkState(kNetworkNoSource); |
| 839 | 855 |
| 840 // 2 - Set the element's show poster flag to true | 856 // 2 - Set the element's show poster flag to true |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1393 m_currentSourceNode = nullptr; | 1409 m_currentSourceNode = nullptr; |
| 1394 } | 1410 } |
| 1395 | 1411 |
| 1396 void HTMLMediaElement::cancelPendingEventsAndCallbacks() | 1412 void HTMLMediaElement::cancelPendingEventsAndCallbacks() |
| 1397 { | 1413 { |
| 1398 BLINK_MEDIA_LOG << "cancelPendingEventsAndCallbacks(" << (void*)this << ")"; | 1414 BLINK_MEDIA_LOG << "cancelPendingEventsAndCallbacks(" << (void*)this << ")"; |
| 1399 m_asyncEventQueue->cancelAllEvents(); | 1415 m_asyncEventQueue->cancelAllEvents(); |
| 1400 | 1416 |
| 1401 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) | 1417 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) |
| 1402 source->cancelPendingErrorEvent(); | 1418 source->cancelPendingErrorEvent(); |
| 1403 | |
| 1404 m_playPromiseResolveTask->cancel(); | |
| 1405 m_playPromiseResolveList.clear(); | |
| 1406 m_playPromiseRejectTask->cancel(); | |
| 1407 m_playPromiseRejectList.clear(); | |
| 1408 } | 1419 } |
| 1409 | 1420 |
| 1410 void HTMLMediaElement::networkStateChanged() | 1421 void HTMLMediaElement::networkStateChanged() |
| 1411 { | 1422 { |
| 1412 setNetworkState(webMediaPlayer()->getNetworkState()); | 1423 setNetworkState(webMediaPlayer()->getNetworkState()); |
| 1413 } | 1424 } |
| 1414 | 1425 |
| 1415 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) | 1426 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) |
| 1416 { | 1427 { |
| 1417 stopPeriodicTimers(); | 1428 stopPeriodicTimers(); |
| (...skipping 2602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4020 | 4031 |
| 4021 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst | 4032 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst |
| 4022 { | 4033 { |
| 4023 IntRect result; | 4034 IntRect result; |
| 4024 if (LayoutObject* object = m_element->layoutObject()) | 4035 if (LayoutObject* object = m_element->layoutObject()) |
| 4025 result = object->absoluteBoundingBoxRect(); | 4036 result = object->absoluteBoundingBoxRect(); |
| 4026 return result; | 4037 return result; |
| 4027 } | 4038 } |
| 4028 | 4039 |
| 4029 } // namespace blink | 4040 } // namespace blink |
| OLD | NEW |