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 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 - If there are any tasks from the media element's media element event t ask source in |
| 765 // one of the task queues, then remove those tasks. | 765 // one of the task queues, then remove those tasks. |
| 766 cancelPendingEventsAndCallbacks(); | 766 cancelPendingEventsAndCallbacks(); |
| 767 | 767 |
| 768 rejectPlayPromises(AbortError, "The play() request was interrupted by a new load request."); | |
| 769 | |
| 770 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue | 768 // 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. | 769 // a task to fire a simple event named abort at the media element. |
| 772 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) | 770 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) |
| 773 scheduleEvent(EventTypeNames::abort); | 771 scheduleEvent(EventTypeNames::abort); |
| 774 | 772 |
| 775 resetMediaPlayerAndMediaSource(); | 773 resetMediaPlayerAndMediaSource(); |
| 776 | 774 |
| 777 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps | 775 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps |
| 778 if (m_networkState != NETWORK_EMPTY) { | 776 if (m_networkState != NETWORK_EMPTY) { |
| 779 // 4.1 - Queue a task to fire a simple event named emptied at the media element. | 777 // 4.1 - Queue a task to fire a simple event named emptied at the media element. |
| 780 scheduleEvent(EventTypeNames::emptied); | 778 scheduleEvent(EventTypeNames::emptied); |
| 781 | 779 |
| 782 // 4.2 - If a fetching process is in progress for the media element, the user agent should stop it. | 780 // 4.2 - Take pending play promises and reject pending play promises wit h the result and an "AbortError" DOMException. |
| 781 rejectPlayPromises(AbortError, "The play() request was interrupted by a new load request."); | |
| 782 | |
| 783 // 4.3 - If a fetching process is in progress for the media element, the user agent should stop it. | |
| 783 setNetworkState(NETWORK_EMPTY); | 784 setNetworkState(NETWORK_EMPTY); |
| 784 | 785 |
| 785 // 4.3 - Forget the media element's media-resource-specific tracks. | 786 // 4.5 - Forget the media element's media-resource-specific tracks. |
| 786 forgetResourceSpecificTracks(); | 787 forgetResourceSpecificTracks(); |
| 787 | 788 |
| 788 // 4.4 - If readyState is not set to HAVE_NOTHING, then set it to that s tate. | 789 // 4.6 - If readyState is not set to HAVE_NOTHING, then set it to that s tate. |
| 789 m_readyState = HAVE_NOTHING; | 790 m_readyState = HAVE_NOTHING; |
| 790 m_readyStateMaximum = HAVE_NOTHING; | 791 m_readyStateMaximum = HAVE_NOTHING; |
| 791 | 792 |
| 792 // 4.5 - If the paused attribute is false, then set it to true. | 793 // 4.6 - If the paused attribute is false, then set it to true. |
| 793 m_paused = true; | 794 m_paused = true; |
| 794 | 795 |
| 795 // 4.6 - If seeking is true, set it to false. | 796 // 4.7 - If seeking is true, set it to false. |
| 796 m_seeking = false; | 797 m_seeking = false; |
| 797 | 798 |
| 798 // 4.7 - Set the current playback position to 0. | 799 // 4.8 - Set the current playback position to 0. |
| 799 // Set the official playback position to 0. | 800 // 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. | 801 // 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. | 802 // FIXME: Add support for firing this event. |
| 802 | 803 |
| 803 // 4.8 - Set the initial playback position to 0. | 804 // 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 HAVE_NOTHING. | 805 // FIXME: Make this less subtle. The position only becomes 0 because the ready state is HAVE_NOTHING. |
| 805 invalidateCachedTime(); | 806 invalidateCachedTime(); |
| 806 | 807 |
| 807 // 4.9 - Set the timeline offset to Not-a-Number (NaN). | 808 // 4.10 - Set the timeline offset to Not-a-Number (NaN). |
| 808 // 4.10 - Update the duration attribute to Not-a-Number (NaN). | 809 // 4.11 - Update the duration attribute to Not-a-Number (NaN). |
| 809 | 810 |
| 810 cueTimeline().updateActiveCues(0); | 811 cueTimeline().updateActiveCues(0); |
| 811 } else if (!m_paused) { | 812 } else if (!m_paused) { |
| 812 // TODO(foolip): There is a proposal to always reset the paused state | 813 // 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 | 814 // in the media element load algorithm, to avoid a bogus play() promise |
| 814 // rejection: https://github.com/whatwg/html/issues/869 | 815 // rejection: https://github.com/whatwg/html/issues/869 |
| 815 // This is where that change would have an effect, and it is measured to | 816 // 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. | 817 // verify the assumption that it's a very rare situation. |
| 817 UseCounter::count(document(), UseCounter::HTMLMediaElementLoadNetworkEmp tyNotPaused); | 818 UseCounter::count(document(), UseCounter::HTMLMediaElementLoadNetworkEmp tyNotPaused); |
|
foolip
2016/08/03 14:32:56
Can you remove this counter (also from UseCounter.
mlamouri (slow - plz ping)
2016/08/03 15:57:55
Sounds good but I would prefer to do that in a fol
foolip
2016/08/03 16:31:51
Acknowledged.
| |
| 818 } | 819 } |
| 819 | 820 |
| 820 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute. | 821 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute. |
| 821 setPlaybackRate(defaultPlaybackRate()); | 822 setPlaybackRate(defaultPlaybackRate()); |
| 822 | 823 |
| 823 // 6 - Set the error attribute to null and the autoplaying flag to true. | 824 // 6 - Set the error attribute to null and the autoplaying flag to true. |
| 824 m_error = nullptr; | 825 m_error = nullptr; |
| 825 m_autoplaying = true; | 826 m_autoplaying = true; |
| 826 | 827 |
| 827 // 7 - Invoke the media element's resource selection algorithm. | 828 // 7 - Invoke the media element's resource selection algorithm. |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1394 } | 1395 } |
| 1395 | 1396 |
| 1396 void HTMLMediaElement::cancelPendingEventsAndCallbacks() | 1397 void HTMLMediaElement::cancelPendingEventsAndCallbacks() |
| 1397 { | 1398 { |
| 1398 BLINK_MEDIA_LOG << "cancelPendingEventsAndCallbacks(" << (void*)this << ")"; | 1399 BLINK_MEDIA_LOG << "cancelPendingEventsAndCallbacks(" << (void*)this << ")"; |
| 1399 m_asyncEventQueue->cancelAllEvents(); | 1400 m_asyncEventQueue->cancelAllEvents(); |
| 1400 | 1401 |
| 1401 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) | 1402 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) |
| 1402 source->cancelPendingErrorEvent(); | 1403 source->cancelPendingErrorEvent(); |
| 1403 | 1404 |
| 1404 m_playPromiseResolveTask->cancel(); | 1405 if (m_playPromiseResolveTask->isPending()) { |
|
foolip
2016/08/03 14:32:56
Can you update the documentation of HTMLMediaEleme
mlamouri (slow - plz ping)
2016/08/03 15:57:56
Done.
| |
| 1405 m_playPromiseResolveList.clear(); | 1406 m_playPromiseResolveTask->cancel(); |
| 1406 m_playPromiseRejectTask->cancel(); | 1407 resolveScheduledPlayPromises(); |
| 1407 m_playPromiseRejectList.clear(); | 1408 } |
| 1409 | |
| 1410 if (m_playPromiseRejectTask->isPending()) { | |
| 1411 m_playPromiseRejectTask->cancel(); | |
| 1412 rejectScheduledPlayPromises(); | |
| 1413 } | |
| 1408 } | 1414 } |
| 1409 | 1415 |
| 1410 void HTMLMediaElement::networkStateChanged() | 1416 void HTMLMediaElement::networkStateChanged() |
| 1411 { | 1417 { |
| 1412 setNetworkState(webMediaPlayer()->getNetworkState()); | 1418 setNetworkState(webMediaPlayer()->getNetworkState()); |
| 1413 } | 1419 } |
| 1414 | 1420 |
| 1415 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) | 1421 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) |
| 1416 { | 1422 { |
| 1417 stopPeriodicTimers(); | 1423 stopPeriodicTimers(); |
| (...skipping 2602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4020 | 4026 |
| 4021 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst | 4027 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst |
| 4022 { | 4028 { |
| 4023 IntRect result; | 4029 IntRect result; |
| 4024 if (LayoutObject* object = m_element->layoutObject()) | 4030 if (LayoutObject* object = m_element->layoutObject()) |
| 4025 result = object->absoluteBoundingBoxRect(); | 4031 result = object->absoluteBoundingBoxRect(); |
| 4026 return result; | 4032 return result; |
| 4027 } | 4033 } |
| 4028 | 4034 |
| 4029 } // namespace blink | 4035 } // namespace blink |
| OLD | NEW |