OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011 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 "config.h" | 26 #include "config.h" |
27 | 27 |
28 #if ENABLE(VIDEO) | 28 #if ENABLE(VIDEO) |
29 #include "HTMLMediaElement.h" | 29 #include "HTMLMediaElement.h" |
30 | 30 |
31 #include "ApplicationCacheHost.h" | 31 #include "ApplicationCacheHost.h" |
32 #include "ApplicationCacheResource.h" | 32 #include "ApplicationCacheResource.h" |
33 #include "Attribute.h" | 33 #include "Attribute.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 return url.string().substring(0, maximumURLLengthForLogging) + "..."; | 113 return url.string().substring(0, maximumURLLengthForLogging) + "..."; |
114 } | 114 } |
115 | 115 |
116 static const char* boolString(bool val) | 116 static const char* boolString(bool val) |
117 { | 117 { |
118 return val ? "true" : "false"; | 118 return val ? "true" : "false"; |
119 } | 119 } |
120 #endif | 120 #endif |
121 | 121 |
122 #ifndef LOG_MEDIA_EVENTS | 122 #ifndef LOG_MEDIA_EVENTS |
123 // Default to not logging events because so many are generated they can overwhel
m the rest of | 123 // Default to not logging events because so many are generated they can overwhel
m the rest of |
124 // the logging. | 124 // the logging. |
125 #define LOG_MEDIA_EVENTS 0 | 125 #define LOG_MEDIA_EVENTS 0 |
126 #endif | 126 #endif |
127 | 127 |
128 #ifndef LOG_CACHED_TIME_WARNINGS | 128 #ifndef LOG_CACHED_TIME_WARNINGS |
129 // Default to not logging warnings about excessive drift in the cached media tim
e because it adds a | 129 // Default to not logging warnings about excessive drift in the cached media tim
e because it adds a |
130 // fair amount of overhead and logging. | 130 // fair amount of overhead and logging. |
131 #define LOG_CACHED_TIME_WARNINGS 0 | 131 #define LOG_CACHED_TIME_WARNINGS 0 |
132 #endif | 132 #endif |
133 | 133 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 , m_loadState(WaitingForSource) | 188 , m_loadState(WaitingForSource) |
189 , m_currentSourceNode(0) | 189 , m_currentSourceNode(0) |
190 , m_nextChildNodeToConsider(0) | 190 , m_nextChildNodeToConsider(0) |
191 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) | 191 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) |
192 , m_proxyWidget(0) | 192 , m_proxyWidget(0) |
193 #endif | 193 #endif |
194 , m_restrictions(RequireUserGestureForFullscreenRestriction | RequirePageCon
sentToLoadMediaRestriction) | 194 , m_restrictions(RequireUserGestureForFullscreenRestriction | RequirePageCon
sentToLoadMediaRestriction) |
195 , m_preload(MediaPlayer::Auto) | 195 , m_preload(MediaPlayer::Auto) |
196 , m_displayMode(Unknown) | 196 , m_displayMode(Unknown) |
197 , m_processingMediaPlayerCallback(0) | 197 , m_processingMediaPlayerCallback(0) |
198 #if ENABLE(MEDIA_SOURCE) | 198 #if ENABLE(MEDIA_SOURCE) |
199 , m_sourceState(SOURCE_CLOSED) | 199 , m_sourceState(SOURCE_CLOSED) |
200 #endif | 200 #endif |
201 , m_cachedTime(invalidMediaTime) | 201 , m_cachedTime(invalidMediaTime) |
202 , m_cachedTimeWallClockUpdateTime(0) | 202 , m_cachedTimeWallClockUpdateTime(0) |
203 , m_minimumWallClockTimeToCacheMediaTime(0) | 203 , m_minimumWallClockTimeToCacheMediaTime(0) |
204 , m_pendingLoadFlags(0) | 204 , m_pendingLoadFlags(0) |
205 , m_playing(false) | 205 , m_playing(false) |
206 , m_isWaitingUntilMediaCanStart(false) | 206 , m_isWaitingUntilMediaCanStart(false) |
207 , m_shouldDelayLoadEvent(false) | 207 , m_shouldDelayLoadEvent(false) |
208 , m_haveFiredLoadedData(false) | 208 , m_haveFiredLoadedData(false) |
(...skipping 19 matching lines...) Expand all Loading... |
228 , m_audioSourceNode(0) | 228 , m_audioSourceNode(0) |
229 #endif | 229 #endif |
230 #if ENABLE(VIDEO_TRACK) | 230 #if ENABLE(VIDEO_TRACK) |
231 , m_textTracks(0) | 231 , m_textTracks(0) |
232 #endif | 232 #endif |
233 { | 233 { |
234 LOG(Media, "HTMLMediaElement::HTMLMediaElement"); | 234 LOG(Media, "HTMLMediaElement::HTMLMediaElement"); |
235 document->registerForDocumentActivationCallbacks(this); | 235 document->registerForDocumentActivationCallbacks(this); |
236 document->registerForMediaVolumeCallbacks(this); | 236 document->registerForMediaVolumeCallbacks(this); |
237 document->registerForPrivateBrowsingStateChangedCallbacks(this); | 237 document->registerForPrivateBrowsingStateChangedCallbacks(this); |
238 | 238 |
239 if (document->settings() && document->settings()->mediaPlaybackRequiresUserG
esture()) | 239 if (document->settings() && document->settings()->mediaPlaybackRequiresUserG
esture()) |
240 addBehaviorRestriction(RequireUserGestureForRateChangeRestriction); | 240 addBehaviorRestriction(RequireUserGestureForRateChangeRestriction); |
241 | 241 |
242 #if ENABLE(MEDIA_SOURCE) | 242 #if ENABLE(MEDIA_SOURCE) |
243 m_mediaSourceURL.setProtocol(mediaSourceURLProtocol); | 243 m_mediaSourceURL.setProtocol(mediaSourceURLProtocol); |
244 m_mediaSourceURL.setPath(createCanonicalUUIDString()); | 244 m_mediaSourceURL.setPath(createCanonicalUUIDString()); |
245 #endif | 245 #endif |
246 | 246 |
247 setHasCustomWillOrDidRecalcStyle(); | 247 setHasCustomWillOrDidRecalcStyle(); |
248 addElementToDocumentMap(this, document); | 248 addElementToDocumentMap(this, document); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 mediaRenderer->setWidget(m_proxyWidget); | 417 mediaRenderer->setWidget(m_proxyWidget); |
418 | 418 |
419 if (Frame* frame = document()->frame()) | 419 if (Frame* frame = document()->frame()) |
420 frame->loader()->client()->showMediaPlayerProxyPlugin(m_proxyWidget.
get()); | 420 frame->loader()->client()->showMediaPlayerProxyPlugin(m_proxyWidget.
get()); |
421 } | 421 } |
422 return mediaRenderer; | 422 return mediaRenderer; |
423 #else | 423 #else |
424 return new (arena) RenderMedia(this); | 424 return new (arena) RenderMedia(this); |
425 #endif | 425 #endif |
426 } | 426 } |
427 | 427 |
428 void HTMLMediaElement::insertedIntoDocument() | 428 void HTMLMediaElement::insertedIntoDocument() |
429 { | 429 { |
430 LOG(Media, "HTMLMediaElement::insertedIntoDocument"); | 430 LOG(Media, "HTMLMediaElement::insertedIntoDocument"); |
431 HTMLElement::insertedIntoDocument(); | 431 HTMLElement::insertedIntoDocument(); |
432 if (!getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY) | 432 if (!getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY) |
433 scheduleLoad(MediaResource); | 433 scheduleLoad(MediaResource); |
434 } | 434 } |
435 | 435 |
436 void HTMLMediaElement::removedFromDocument() | 436 void HTMLMediaElement::removedFromDocument() |
437 { | 437 { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 } | 470 } |
471 | 471 |
472 void HTMLMediaElement::scheduleLoad(LoadType loadType) | 472 void HTMLMediaElement::scheduleLoad(LoadType loadType) |
473 { | 473 { |
474 LOG(Media, "HTMLMediaElement::scheduleLoad"); | 474 LOG(Media, "HTMLMediaElement::scheduleLoad"); |
475 | 475 |
476 if ((loadType & MediaResource) && !(m_pendingLoadFlags & MediaResource)) { | 476 if ((loadType & MediaResource) && !(m_pendingLoadFlags & MediaResource)) { |
477 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) | 477 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) |
478 createMediaPlayerProxy(); | 478 createMediaPlayerProxy(); |
479 #endif | 479 #endif |
480 | 480 |
481 prepareForLoad(); | 481 prepareForLoad(); |
482 m_pendingLoadFlags |= MediaResource; | 482 m_pendingLoadFlags |= MediaResource; |
483 } | 483 } |
484 | 484 |
485 #if ENABLE(VIDEO_TRACK) | 485 #if ENABLE(VIDEO_TRACK) |
486 if (loadType & TextTrackResource) | 486 if (loadType & TextTrackResource) |
487 m_pendingLoadFlags |= TextTrackResource; | 487 m_pendingLoadFlags |= TextTrackResource; |
488 #endif | 488 #endif |
489 | 489 |
490 if (!m_loadTimer.isActive()) | 490 if (!m_loadTimer.isActive()) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 } | 538 } |
539 | 539 |
540 #if ENABLE(VIDEO_TRACK) | 540 #if ENABLE(VIDEO_TRACK) |
541 if (m_pendingLoadFlags & TextTrackResource) | 541 if (m_pendingLoadFlags & TextTrackResource) |
542 scheduleLoad(TextTrackResource); | 542 scheduleLoad(TextTrackResource); |
543 #endif | 543 #endif |
544 | 544 |
545 m_pendingLoadFlags = 0; | 545 m_pendingLoadFlags = 0; |
546 } | 546 } |
547 | 547 |
548 PassRefPtr<MediaError> HTMLMediaElement::error() const | 548 PassRefPtr<MediaError> HTMLMediaElement::error() const |
549 { | 549 { |
550 return m_error; | 550 return m_error; |
551 } | 551 } |
552 | 552 |
553 void HTMLMediaElement::setSrc(const String& url) | 553 void HTMLMediaElement::setSrc(const String& url) |
554 { | 554 { |
555 setAttribute(srcAttr, url); | 555 setAttribute(srcAttr, url); |
556 } | 556 } |
557 | 557 |
558 HTMLMediaElement::NetworkState HTMLMediaElement::networkState() const | 558 HTMLMediaElement::NetworkState HTMLMediaElement::networkState() const |
(...skipping 12 matching lines...) Expand all Loading... |
571 case MediaPlayer::IsNotSupported: | 571 case MediaPlayer::IsNotSupported: |
572 canPlay = ""; | 572 canPlay = ""; |
573 break; | 573 break; |
574 case MediaPlayer::MayBeSupported: | 574 case MediaPlayer::MayBeSupported: |
575 canPlay = "maybe"; | 575 canPlay = "maybe"; |
576 break; | 576 break; |
577 case MediaPlayer::IsSupported: | 577 case MediaPlayer::IsSupported: |
578 canPlay = "probably"; | 578 canPlay = "probably"; |
579 break; | 579 break; |
580 } | 580 } |
581 | 581 |
582 LOG(Media, "HTMLMediaElement::canPlayType(%s) -> %s", mimeType.utf8().data()
, canPlay.utf8().data()); | 582 LOG(Media, "HTMLMediaElement::canPlayType(%s) -> %s", mimeType.utf8().data()
, canPlay.utf8().data()); |
583 | 583 |
584 return canPlay; | 584 return canPlay; |
585 } | 585 } |
586 | 586 |
587 void HTMLMediaElement::load(ExceptionCode& ec) | 587 void HTMLMediaElement::load(ExceptionCode& ec) |
588 { | 588 { |
589 LOG(Media, "HTMLMediaElement::load()"); | 589 LOG(Media, "HTMLMediaElement::load()"); |
590 | 590 |
591 if (userGestureRequiredForLoad() && !ScriptController::processingUserGesture
()) | 591 if (userGestureRequiredForLoad() && !ScriptController::processingUserGesture
()) |
(...skipping 17 matching lines...) Expand all Loading... |
609 m_sentStalledEvent = false; | 609 m_sentStalledEvent = false; |
610 m_haveFiredLoadedData = false; | 610 m_haveFiredLoadedData = false; |
611 m_completelyLoaded = false; | 611 m_completelyLoaded = false; |
612 m_havePreparedToPlay = false; | 612 m_havePreparedToPlay = false; |
613 m_displayMode = Unknown; | 613 m_displayMode = Unknown; |
614 | 614 |
615 // 1 - Abort any already-running instance of the resource selection algorith
m for this element. | 615 // 1 - Abort any already-running instance of the resource selection algorith
m for this element. |
616 m_loadState = WaitingForSource; | 616 m_loadState = WaitingForSource; |
617 m_currentSourceNode = 0; | 617 m_currentSourceNode = 0; |
618 | 618 |
619 // 2 - If there are any tasks from the media element's media element event t
ask source in | 619 // 2 - If there are any tasks from the media element's media element event t
ask source in |
620 // one of the task queues, then remove those tasks. | 620 // one of the task queues, then remove those tasks. |
621 cancelPendingEventsAndCallbacks(); | 621 cancelPendingEventsAndCallbacks(); |
622 | 622 |
623 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW
ORK_IDLE, queue | 623 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW
ORK_IDLE, queue |
624 // a task to fire a simple event named abort at the media element. | 624 // a task to fire a simple event named abort at the media element. |
625 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) | 625 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) |
626 scheduleEvent(eventNames().abortEvent); | 626 scheduleEvent(eventNames().abortEvent); |
627 | 627 |
628 #if !ENABLE(PLUGIN_PROXY_FOR_VIDEO) | 628 #if !ENABLE(PLUGIN_PROXY_FOR_VIDEO) |
629 createMediaPlayer(); | 629 createMediaPlayer(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 // 1 - Set the networkState to NETWORK_NO_SOURCE | 667 // 1 - Set the networkState to NETWORK_NO_SOURCE |
668 m_networkState = NETWORK_NO_SOURCE; | 668 m_networkState = NETWORK_NO_SOURCE; |
669 | 669 |
670 // 2 - Asynchronously await a stable state. | 670 // 2 - Asynchronously await a stable state. |
671 | 671 |
672 m_playedTimeRanges = TimeRanges::create(); | 672 m_playedTimeRanges = TimeRanges::create(); |
673 m_lastSeekTime = 0; | 673 m_lastSeekTime = 0; |
674 m_closedCaptionsVisible = false; | 674 m_closedCaptionsVisible = false; |
675 | 675 |
676 // The spec doesn't say to block the load event until we actually run the as
ynchronous section | 676 // The spec doesn't say to block the load event until we actually run the as
ynchronous section |
677 // algorithm, but do it now because we won't start that until after the time
r fires and the | 677 // algorithm, but do it now because we won't start that until after the time
r fires and the |
678 // event may have already fired by then. | 678 // event may have already fired by then. |
679 setShouldDelayLoadEvent(true); | 679 setShouldDelayLoadEvent(true); |
680 | 680 |
681 configureMediaControls(); | 681 configureMediaControls(); |
682 } | 682 } |
683 | 683 |
684 void HTMLMediaElement::loadInternal() | 684 void HTMLMediaElement::loadInternal() |
685 { | 685 { |
686 // If we can't start a load right away, start it later. | 686 // If we can't start a load right away, start it later. |
687 Page* page = document()->page(); | 687 Page* page = document()->page(); |
688 if (pageConsentRequiredForLoad() && page && !page->canStartMedia()) { | 688 if (pageConsentRequiredForLoad() && page && !page->canStartMedia()) { |
689 if (m_isWaitingUntilMediaCanStart) | 689 if (m_isWaitingUntilMediaCanStart) |
690 return; | 690 return; |
691 document()->addMediaCanStartListener(this); | 691 document()->addMediaCanStartListener(this); |
692 m_isWaitingUntilMediaCanStart = true; | 692 m_isWaitingUntilMediaCanStart = true; |
693 return; | 693 return; |
694 } | 694 } |
695 | 695 |
696 // Once the page has allowed an element to load media, it is free to load at
will. This allows a | 696 // Once the page has allowed an element to load media, it is free to load at
will. This allows a |
697 // playlist that starts in a foreground tab to continue automatically if the
tab is subsequently | 697 // playlist that starts in a foreground tab to continue automatically if the
tab is subsequently |
698 // put in the the background. | 698 // put in the the background. |
699 removeBehaviorRestriction(RequirePageConsentToLoadMediaRestriction); | 699 removeBehaviorRestriction(RequirePageConsentToLoadMediaRestriction); |
700 | 700 |
701 selectMediaResource(); | 701 selectMediaResource(); |
702 } | 702 } |
703 | 703 |
704 void HTMLMediaElement::selectMediaResource() | 704 void HTMLMediaElement::selectMediaResource() |
705 { | 705 { |
706 LOG(Media, "HTMLMediaElement::selectMediaResource"); | 706 LOG(Media, "HTMLMediaElement::selectMediaResource"); |
707 | 707 |
708 enum Mode { attribute, children }; | 708 enum Mode { attribute, children }; |
709 | 709 |
710 // 3 - If the media element has a src attribute, then let mode be attribute. | 710 // 3 - If the media element has a src attribute, then let mode be attribute. |
711 Mode mode = attribute; | 711 Mode mode = attribute; |
712 if (!fastHasAttribute(srcAttr)) { | 712 if (!fastHasAttribute(srcAttr)) { |
713 Node* node; | 713 Node* node; |
714 for (node = firstChild(); node; node = node->nextSibling()) { | 714 for (node = firstChild(); node; node = node->nextSibling()) { |
715 if (node->hasTagName(sourceTag)) | 715 if (node->hasTagName(sourceTag)) |
716 break; | 716 break; |
717 } | 717 } |
718 | 718 |
719 // Otherwise, if the media element does not have a src attribute but has
a source | 719 // Otherwise, if the media element does not have a src attribute but has
a source |
720 // element child, then let mode be children and let candidate be the fir
st such | 720 // element child, then let mode be children and let candidate be the fir
st such |
721 // source element child in tree order. | 721 // source element child in tree order. |
722 if (node) { | 722 if (node) { |
723 mode = children; | 723 mode = children; |
724 m_nextChildNodeToConsider = 0; | 724 m_nextChildNodeToConsider = 0; |
725 m_currentSourceNode = 0; | 725 m_currentSourceNode = 0; |
726 } else { | 726 } else { |
727 // Otherwise the media element has neither a src attribute nor a sou
rce element | 727 // Otherwise the media element has neither a src attribute nor a sou
rce element |
728 // child: set the networkState to NETWORK_EMPTY, and abort these ste
ps; the | 728 // child: set the networkState to NETWORK_EMPTY, and abort these ste
ps; the |
729 // synchronous section ends. | 729 // synchronous section ends. |
730 m_loadState = WaitingForSource; | 730 m_loadState = WaitingForSource; |
731 setShouldDelayLoadEvent(false); | 731 setShouldDelayLoadEvent(false); |
732 m_networkState = NETWORK_EMPTY; | 732 m_networkState = NETWORK_EMPTY; |
733 | 733 |
734 LOG(Media, "HTMLMediaElement::selectMediaResource, nothing to load")
; | 734 LOG(Media, "HTMLMediaElement::selectMediaResource, nothing to load")
; |
735 return; | 735 return; |
736 } | 736 } |
737 } | 737 } |
738 | 738 |
739 // 4 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event), | 739 // 4 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event), |
740 // and set its networkState to NETWORK_LOADING. | 740 // and set its networkState to NETWORK_LOADING. |
741 setShouldDelayLoadEvent(true); | 741 setShouldDelayLoadEvent(true); |
742 m_networkState = NETWORK_LOADING; | 742 m_networkState = NETWORK_LOADING; |
743 | 743 |
744 // 5 - Queue a task to fire a simple event named loadstart at the media elem
ent. | 744 // 5 - Queue a task to fire a simple event named loadstart at the media elem
ent. |
745 scheduleEvent(eventNames().loadstartEvent); | 745 scheduleEvent(eventNames().loadstartEvent); |
746 | 746 |
747 // 6 - If mode is attribute, then run these substeps | 747 // 6 - If mode is attribute, then run these substeps |
748 if (mode == attribute) { | 748 if (mode == attribute) { |
749 m_loadState = LoadingFromSrcAttr; | 749 m_loadState = LoadingFromSrcAttr; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 if (!frame) { | 823 if (!frame) { |
824 mediaLoadingFailed(MediaPlayer::FormatError); | 824 mediaLoadingFailed(MediaPlayer::FormatError); |
825 return; | 825 return; |
826 } | 826 } |
827 | 827 |
828 KURL url = initialURL; | 828 KURL url = initialURL; |
829 if (!frame->loader()->willLoadMediaElementURL(url)) { | 829 if (!frame->loader()->willLoadMediaElementURL(url)) { |
830 mediaLoadingFailed(MediaPlayer::FormatError); | 830 mediaLoadingFailed(MediaPlayer::FormatError); |
831 return; | 831 return; |
832 } | 832 } |
833 | 833 |
834 #if ENABLE(MEDIA_SOURCE) | 834 #if ENABLE(MEDIA_SOURCE) |
835 // If this is a media source URL, make sure it is the one for this media ele
ment. | 835 // If this is a media source URL, make sure it is the one for this media ele
ment. |
836 if (url.protocolIs(mediaSourceURLProtocol) && url != m_mediaSourceURL) { | 836 if (url.protocolIs(mediaSourceURLProtocol) && url != m_mediaSourceURL) { |
837 mediaLoadingFailed(MediaPlayer::FormatError); | 837 mediaLoadingFailed(MediaPlayer::FormatError); |
838 return; | 838 return; |
839 } | 839 } |
840 #endif | 840 #endif |
841 | 841 |
842 // The resource fetch algorithm | 842 // The resource fetch algorithm |
843 m_networkState = NETWORK_LOADING; | 843 m_networkState = NETWORK_LOADING; |
844 | 844 |
845 #if !PLATFORM(CHROMIUM) | 845 #if !PLATFORM(CHROMIUM) |
846 // If the url should be loaded from the application cache, pass the url of t
he cached file | 846 // If the url should be loaded from the application cache, pass the url of t
he cached file |
847 // to the media engine. | 847 // to the media engine. |
848 ApplicationCacheHost* cacheHost = frame->loader()->documentLoader()->applica
tionCacheHost(); | 848 ApplicationCacheHost* cacheHost = frame->loader()->documentLoader()->applica
tionCacheHost(); |
849 ApplicationCacheResource* resource = 0; | 849 ApplicationCacheResource* resource = 0; |
850 if (cacheHost && cacheHost->shouldLoadResourceFromApplicationCache(ResourceR
equest(url), resource)) { | 850 if (cacheHost && cacheHost->shouldLoadResourceFromApplicationCache(ResourceR
equest(url), resource)) { |
851 // Resources that are not present in the manifest will always fail to lo
ad (at least, after the | 851 // Resources that are not present in the manifest will always fail to lo
ad (at least, after the |
852 // cache has been primed the first time), making the testing of offline
applications simpler. | 852 // cache has been primed the first time), making the testing of offline
applications simpler. |
(...skipping 10 matching lines...) Expand all Loading... |
863 | 863 |
864 #if !PLATFORM(CHROMIUM) | 864 #if !PLATFORM(CHROMIUM) |
865 if (resource) { | 865 if (resource) { |
866 url = createFileURLForApplicationCacheResource(resource->path()); | 866 url = createFileURLForApplicationCacheResource(resource->path()); |
867 LOG(Media, "HTMLMediaElement::loadResource - will load from app cache ->
%s", urlForLogging(url).utf8().data()); | 867 LOG(Media, "HTMLMediaElement::loadResource - will load from app cache ->
%s", urlForLogging(url).utf8().data()); |
868 } | 868 } |
869 #endif | 869 #endif |
870 | 870 |
871 LOG(Media, "HTMLMediaElement::loadResource - m_currentSrc -> %s", urlForLogg
ing(m_currentSrc).utf8().data()); | 871 LOG(Media, "HTMLMediaElement::loadResource - m_currentSrc -> %s", urlForLogg
ing(m_currentSrc).utf8().data()); |
872 | 872 |
873 if (m_sendProgressEvents) | 873 if (m_sendProgressEvents) |
874 startProgressEventTimer(); | 874 startProgressEventTimer(); |
875 | 875 |
876 Settings* settings = document()->settings(); | 876 Settings* settings = document()->settings(); |
877 bool privateMode = !settings || settings->privateBrowsingEnabled(); | 877 bool privateMode = !settings || settings->privateBrowsingEnabled(); |
878 m_player->setPrivateBrowsingMode(privateMode); | 878 m_player->setPrivateBrowsingMode(privateMode); |
879 | 879 |
880 // Reset display mode to force a recalculation of what to show because we ar
e resetting the player. | 880 // Reset display mode to force a recalculation of what to show because we ar
e resetting the player. |
881 setDisplayMode(Unknown); | 881 setDisplayMode(Unknown); |
882 | 882 |
883 if (!autoplay()) | 883 if (!autoplay()) |
(...skipping 14 matching lines...) Expand all Loading... |
898 if (renderer()) | 898 if (renderer()) |
899 renderer()->updateFromElement(); | 899 renderer()->updateFromElement(); |
900 } | 900 } |
901 | 901 |
902 #if ENABLE(VIDEO_TRACK) | 902 #if ENABLE(VIDEO_TRACK) |
903 void HTMLMediaElement::updateActiveTextTrackCues(float movieTime) | 903 void HTMLMediaElement::updateActiveTextTrackCues(float movieTime) |
904 { | 904 { |
905 Vector<CueIntervalTree::IntervalType> previouslyVisibleCues = m_currentlyVis
ibleCues; | 905 Vector<CueIntervalTree::IntervalType> previouslyVisibleCues = m_currentlyVis
ibleCues; |
906 | 906 |
907 m_currentlyVisibleCues = m_cueTree.allOverlaps(m_cueTree.createInterval(movi
eTime, movieTime)); | 907 m_currentlyVisibleCues = m_cueTree.allOverlaps(m_cueTree.createInterval(movi
eTime, movieTime)); |
908 | 908 |
909 // FIXME(72171): Events need to be sorted and filtered before dispatching. | 909 // FIXME(72171): Events need to be sorted and filtered before dispatching. |
910 | 910 |
911 for (size_t i = 0; i < previouslyVisibleCues.size(); ++i) { | 911 for (size_t i = 0; i < previouslyVisibleCues.size(); ++i) { |
912 if (!m_currentlyVisibleCues.contains(previouslyVisibleCues[i])) | 912 if (!m_currentlyVisibleCues.contains(previouslyVisibleCues[i])) |
913 previouslyVisibleCues[i].data()->setIsActive(false); | 913 previouslyVisibleCues[i].data()->setIsActive(false); |
914 } | 914 } |
915 for (size_t i = 0; i < m_currentlyVisibleCues.size(); ++i) { | 915 for (size_t i = 0; i < m_currentlyVisibleCues.size(); ++i) { |
916 if (!previouslyVisibleCues.contains(m_currentlyVisibleCues[i])) | 916 if (!previouslyVisibleCues.contains(m_currentlyVisibleCues[i])) |
917 m_currentlyVisibleCues[i].data()->setIsActive(true); | 917 m_currentlyVisibleCues[i].data()->setIsActive(true); |
918 } | 918 } |
919 | 919 |
920 // FIXME(72173): Pause the media element for cues going past their endTime | 920 // FIXME(72173): Pause the media element for cues going past their endTime |
921 // during a monotonic time increase. | 921 // during a monotonic time increase. |
922 } | 922 } |
923 | 923 |
924 void HTMLMediaElement::textTrackReadyStateChanged(TextTrack*) | 924 void HTMLMediaElement::textTrackReadyStateChanged(TextTrack*) |
925 { | 925 { |
926 // FIXME(62885): Implement. | 926 // FIXME(62885): Implement. |
927 } | 927 } |
928 | 928 |
929 void HTMLMediaElement::textTrackModeChanged(TextTrack*) | 929 void HTMLMediaElement::textTrackModeChanged(TextTrack*) |
930 { | 930 { |
931 // FIXME(62885): Implement. | 931 // FIXME(62885): Implement. |
932 } | 932 } |
933 | 933 |
934 void HTMLMediaElement::textTrackKindChanged(TextTrack*) | 934 void HTMLMediaElement::textTrackKindChanged(TextTrack*) |
935 { | 935 { |
936 // FIXME(62885): Implement. | 936 // FIXME(62885): Implement. |
937 } | 937 } |
938 | 938 |
939 void HTMLMediaElement::textTrackAddCues(TextTrack*, const TextTrackCueList* cues
) | 939 void HTMLMediaElement::textTrackAddCues(TextTrack*, const TextTrackCueList* cues
) |
940 { | 940 { |
941 for (size_t i = 0; i < cues->length(); ++i) | 941 for (size_t i = 0; i < cues->length(); ++i) |
942 textTrackAddCue(cues->item(i)->track(), cues->item(i)); | 942 textTrackAddCue(cues->item(i)->track(), cues->item(i)); |
943 } | 943 } |
944 | 944 |
945 void HTMLMediaElement::textTrackRemoveCues(TextTrack*, const TextTrackCueList* c
ues) | 945 void HTMLMediaElement::textTrackRemoveCues(TextTrack*, const TextTrackCueList* c
ues) |
946 { | 946 { |
947 for (size_t i = 0; i < cues->length(); ++i) | 947 for (size_t i = 0; i < cues->length(); ++i) |
948 textTrackRemoveCue(cues->item(i)->track(), cues->item(i)); | 948 textTrackRemoveCue(cues->item(i)->track(), cues->item(i)); |
949 } | 949 } |
950 | 950 |
951 void HTMLMediaElement::textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue> cue) | 951 void HTMLMediaElement::textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue> cue) |
952 { | 952 { |
953 m_cueTree.add(m_cueTree.createInterval(cue->startTime(), cue->endTime(), cue
.get())); | 953 m_cueTree.add(m_cueTree.createInterval(cue->startTime(), cue->endTime(), cue
.get())); |
954 } | 954 } |
955 | 955 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 } | 1014 } |
1015 | 1015 |
1016 void HTMLMediaElement::noneSupported() | 1016 void HTMLMediaElement::noneSupported() |
1017 { | 1017 { |
1018 LOG(Media, "HTMLMediaElement::noneSupported"); | 1018 LOG(Media, "HTMLMediaElement::noneSupported"); |
1019 | 1019 |
1020 stopPeriodicTimers(); | 1020 stopPeriodicTimers(); |
1021 m_loadState = WaitingForSource; | 1021 m_loadState = WaitingForSource; |
1022 m_currentSourceNode = 0; | 1022 m_currentSourceNode = 0; |
1023 | 1023 |
1024 // 4.8.10.5 | 1024 // 4.8.10.5 |
1025 // 6 - Reaching this step indicates that the media resource failed to load o
r that the given | 1025 // 6 - Reaching this step indicates that the media resource failed to load o
r that the given |
1026 // URL could not be resolved. In one atomic operation, run the following ste
ps: | 1026 // URL could not be resolved. In one atomic operation, run the following ste
ps: |
1027 | 1027 |
1028 // 6.1 - Set the error attribute to a new MediaError object whose code attri
bute is set to | 1028 // 6.1 - Set the error attribute to a new MediaError object whose code attri
bute is set to |
1029 // MEDIA_ERR_SRC_NOT_SUPPORTED. | 1029 // MEDIA_ERR_SRC_NOT_SUPPORTED. |
1030 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); | 1030 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); |
1031 | 1031 |
1032 // 6.2 - Forget the media element's media-resource-specific text tracks. | 1032 // 6.2 - Forget the media element's media-resource-specific text tracks. |
1033 | 1033 |
1034 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v
alue. | 1034 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v
alue. |
1035 m_networkState = NETWORK_NO_SOURCE; | 1035 m_networkState = NETWORK_NO_SOURCE; |
1036 | 1036 |
1037 // 7 - Queue a task to fire a simple event named error at the media element. | 1037 // 7 - Queue a task to fire a simple event named error at the media element. |
1038 scheduleEvent(eventNames().errorEvent); | 1038 scheduleEvent(eventNames().errorEvent); |
1039 | 1039 |
1040 // 8 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. | 1040 // 8 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. |
1041 setShouldDelayLoadEvent(false); | 1041 setShouldDelayLoadEvent(false); |
1042 | 1042 |
1043 // 9 - Abort these steps. Until the load() method is invoked or the src attr
ibute is changed, | 1043 // 9 - Abort these steps. Until the load() method is invoked or the src attr
ibute is changed, |
1044 // the element won't attempt to load another resource. | 1044 // the element won't attempt to load another resource. |
1045 | 1045 |
1046 updateDisplayState(); | 1046 updateDisplayState(); |
1047 | 1047 |
1048 if (renderer()) | 1048 if (renderer()) |
1049 renderer()->updateFromElement(); | 1049 renderer()->updateFromElement(); |
1050 } | 1050 } |
1051 | 1051 |
1052 void HTMLMediaElement::mediaEngineError(PassRefPtr<MediaError> err) | 1052 void HTMLMediaElement::mediaEngineError(PassRefPtr<MediaError> err) |
1053 { | 1053 { |
1054 LOG(Media, "HTMLMediaElement::mediaEngineError(%d)", static_cast<int>(err->c
ode())); | 1054 LOG(Media, "HTMLMediaElement::mediaEngineError(%d)", static_cast<int>(err->c
ode())); |
1055 | 1055 |
1056 // 1 - The user agent should cancel the fetching process. | 1056 // 1 - The user agent should cancel the fetching process. |
1057 stopPeriodicTimers(); | 1057 stopPeriodicTimers(); |
1058 m_loadState = WaitingForSource; | 1058 m_loadState = WaitingForSource; |
1059 | 1059 |
1060 // 2 - Set the error attribute to a new MediaError object whose code attribu
te is | 1060 // 2 - Set the error attribute to a new MediaError object whose code attribu
te is |
1061 // set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE. | 1061 // set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE. |
1062 m_error = err; | 1062 m_error = err; |
1063 | 1063 |
1064 // 3 - Queue a task to fire a simple event named error at the media element. | 1064 // 3 - Queue a task to fire a simple event named error at the media element. |
1065 scheduleEvent(eventNames().errorEvent); | 1065 scheduleEvent(eventNames().errorEvent); |
1066 | 1066 |
1067 #if ENABLE(MEDIA_SOURCE) | 1067 #if ENABLE(MEDIA_SOURCE) |
1068 if (m_sourceState != SOURCE_CLOSED) | 1068 if (m_sourceState != SOURCE_CLOSED) |
1069 setSourceState(SOURCE_CLOSED); | 1069 setSourceState(SOURCE_CLOSED); |
1070 #endif | 1070 #endif |
(...skipping 18 matching lines...) Expand all Loading... |
1089 | 1089 |
1090 for (Node* node = firstChild(); node; node = node->nextSibling()) { | 1090 for (Node* node = firstChild(); node; node = node->nextSibling()) { |
1091 if (node->hasTagName(sourceTag)) | 1091 if (node->hasTagName(sourceTag)) |
1092 static_cast<HTMLSourceElement*>(node)->cancelPendingErrorEvent(); | 1092 static_cast<HTMLSourceElement*>(node)->cancelPendingErrorEvent(); |
1093 } | 1093 } |
1094 } | 1094 } |
1095 | 1095 |
1096 Document* HTMLMediaElement::mediaPlayerOwningDocument() | 1096 Document* HTMLMediaElement::mediaPlayerOwningDocument() |
1097 { | 1097 { |
1098 Document* d = document(); | 1098 Document* d = document(); |
1099 | 1099 |
1100 if (!d) | 1100 if (!d) |
1101 d = ownerDocument(); | 1101 d = ownerDocument(); |
1102 | 1102 |
1103 return d; | 1103 return d; |
1104 } | 1104 } |
1105 | 1105 |
1106 void HTMLMediaElement::mediaPlayerNetworkStateChanged(MediaPlayer*) | 1106 void HTMLMediaElement::mediaPlayerNetworkStateChanged(MediaPlayer*) |
1107 { | 1107 { |
1108 beginProcessingMediaPlayerCallback(); | 1108 beginProcessingMediaPlayerCallback(); |
1109 setNetworkState(m_player->networkState()); | 1109 setNetworkState(m_player->networkState()); |
1110 endProcessingMediaPlayerCallback(); | 1110 endProcessingMediaPlayerCallback(); |
1111 } | 1111 } |
1112 | 1112 |
1113 void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error) | 1113 void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error) |
1114 { | 1114 { |
1115 stopPeriodicTimers(); | 1115 stopPeriodicTimers(); |
1116 | 1116 |
1117 // If we failed while trying to load a <source> element, the movie was never
parsed, and there are more | 1117 // If we failed while trying to load a <source> element, the movie was never
parsed, and there are more |
1118 // <source> children, schedule the next one | 1118 // <source> children, schedule the next one |
1119 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement)
{ | 1119 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement)
{ |
1120 | 1120 |
1121 if (m_currentSourceNode) | 1121 if (m_currentSourceNode) |
1122 m_currentSourceNode->scheduleErrorEvent(); | 1122 m_currentSourceNode->scheduleErrorEvent(); |
1123 else | 1123 else |
1124 LOG(Media, "HTMLMediaElement::setNetworkState - error event not sent
, <source> was removed"); | 1124 LOG(Media, "HTMLMediaElement::setNetworkState - error event not sent
, <source> was removed"); |
1125 | 1125 |
1126 if (havePotentialSourceChild()) { | 1126 if (havePotentialSourceChild()) { |
1127 LOG(Media, "HTMLMediaElement::setNetworkState - scheduling next <sou
rce>"); | 1127 LOG(Media, "HTMLMediaElement::setNetworkState - scheduling next <sou
rce>"); |
1128 scheduleNextSourceChild(); | 1128 scheduleNextSourceChild(); |
1129 } else { | 1129 } else { |
1130 LOG(Media, "HTMLMediaElement::setNetworkState - no more <source> ele
ments, waiting"); | 1130 LOG(Media, "HTMLMediaElement::setNetworkState - no more <source> ele
ments, waiting"); |
1131 waitForSourceChange(); | 1131 waitForSourceChange(); |
1132 } | 1132 } |
1133 | 1133 |
1134 return; | 1134 return; |
1135 } | 1135 } |
1136 | 1136 |
1137 if (error == MediaPlayer::NetworkError && m_readyState >= HAVE_METADATA) | 1137 if (error == MediaPlayer::NetworkError && m_readyState >= HAVE_METADATA) |
1138 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); | 1138 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); |
1139 else if (error == MediaPlayer::DecodeError) | 1139 else if (error == MediaPlayer::DecodeError) |
1140 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); | 1140 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); |
1141 else if ((error == MediaPlayer::FormatError || error == MediaPlayer::Network
Error) && m_loadState == LoadingFromSrcAttr) | 1141 else if ((error == MediaPlayer::FormatError || error == MediaPlayer::Network
Error) && m_loadState == LoadingFromSrcAttr) |
1142 noneSupported(); | 1142 noneSupported(); |
1143 | 1143 |
1144 updateDisplayState(); | 1144 updateDisplayState(); |
1145 if (hasMediaControls()) { | 1145 if (hasMediaControls()) { |
1146 mediaControls()->reset(); | 1146 mediaControls()->reset(); |
1147 mediaControls()->reportedError(); | 1147 mediaControls()->reportedError(); |
1148 } | 1148 } |
1149 } | 1149 } |
1150 | 1150 |
1151 void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state) | 1151 void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state) |
1152 { | 1152 { |
1153 LOG(Media, "HTMLMediaElement::setNetworkState(%d) - current state is %d", st
atic_cast<int>(state), static_cast<int>(m_networkState)); | 1153 LOG(Media, "HTMLMediaElement::setNetworkState(%d) - current state is %d", st
atic_cast<int>(state), static_cast<int>(m_networkState)); |
1154 | 1154 |
1155 if (state == MediaPlayer::Empty) { | 1155 if (state == MediaPlayer::Empty) { |
1156 // Just update the cached state and leave, we can't do anything. | 1156 // Just update the cached state and leave, we can't do anything. |
1157 m_networkState = NETWORK_EMPTY; | 1157 m_networkState = NETWORK_EMPTY; |
1158 return; | 1158 return; |
1159 } | 1159 } |
1160 | 1160 |
1161 if (state == MediaPlayer::FormatError || state == MediaPlayer::NetworkError
|| state == MediaPlayer::DecodeError) { | 1161 if (state == MediaPlayer::FormatError || state == MediaPlayer::NetworkError
|| state == MediaPlayer::DecodeError) { |
1162 mediaLoadingFailed(state); | 1162 mediaLoadingFailed(state); |
1163 return; | 1163 return; |
1164 } | 1164 } |
1165 | 1165 |
1166 if (state == MediaPlayer::Idle) { | 1166 if (state == MediaPlayer::Idle) { |
1167 if (m_networkState > NETWORK_IDLE) { | 1167 if (m_networkState > NETWORK_IDLE) { |
1168 m_progressEventTimer.stop(); | 1168 m_progressEventTimer.stop(); |
| 1169 if (hasMediaControls() && m_player->bytesLoaded() != m_previousProgr
ess) |
| 1170 mediaControls()->bufferingProgressed(); |
| 1171 |
1169 scheduleEvent(eventNames().suspendEvent); | 1172 scheduleEvent(eventNames().suspendEvent); |
1170 setShouldDelayLoadEvent(false); | 1173 setShouldDelayLoadEvent(false); |
1171 } | 1174 } |
1172 m_networkState = NETWORK_IDLE; | 1175 m_networkState = NETWORK_IDLE; |
1173 } | 1176 } |
1174 | 1177 |
1175 if (state == MediaPlayer::Loading) { | 1178 if (state == MediaPlayer::Loading) { |
1176 if (m_networkState < NETWORK_LOADING || m_networkState == NETWORK_NO_SOU
RCE) | 1179 if (m_networkState < NETWORK_LOADING || m_networkState == NETWORK_NO_SOU
RCE) |
1177 startProgressEventTimer(); | 1180 startProgressEventTimer(); |
1178 m_networkState = NETWORK_LOADING; | 1181 m_networkState = NETWORK_LOADING; |
1179 } | 1182 } |
1180 | 1183 |
1181 if (state == MediaPlayer::Loaded) { | 1184 if (state == MediaPlayer::Loaded) { |
1182 if (m_networkState != NETWORK_IDLE) { | 1185 if (m_networkState != NETWORK_IDLE) { |
1183 m_progressEventTimer.stop(); | 1186 m_progressEventTimer.stop(); |
| 1187 if (hasMediaControls() && m_player->bytesLoaded() != m_previousProgr
ess) |
| 1188 mediaControls()->bufferingProgressed(); |
1184 | 1189 |
1185 // Schedule one last progress event so we guarantee that at least on
e is fired | 1190 // Schedule one last progress event so we guarantee that at least on
e is fired |
1186 // for files that load very quickly. | 1191 // for files that load very quickly. |
1187 scheduleEvent(eventNames().progressEvent); | 1192 scheduleEvent(eventNames().progressEvent); |
1188 } | 1193 } |
1189 m_networkState = NETWORK_IDLE; | 1194 m_networkState = NETWORK_IDLE; |
1190 m_completelyLoaded = true; | 1195 m_completelyLoaded = true; |
1191 } | 1196 } |
1192 | 1197 |
1193 if (hasMediaControls()) | 1198 if (hasMediaControls()) |
(...skipping 14 matching lines...) Expand all Loading... |
1208 LOG(Media, "HTMLMediaElement::setReadyState(%d) - current state is %d,", sta
tic_cast<int>(state), static_cast<int>(m_readyState)); | 1213 LOG(Media, "HTMLMediaElement::setReadyState(%d) - current state is %d,", sta
tic_cast<int>(state), static_cast<int>(m_readyState)); |
1209 | 1214 |
1210 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay
ing() uses it | 1215 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay
ing() uses it |
1211 bool wasPotentiallyPlaying = potentiallyPlaying(); | 1216 bool wasPotentiallyPlaying = potentiallyPlaying(); |
1212 | 1217 |
1213 ReadyState oldState = m_readyState; | 1218 ReadyState oldState = m_readyState; |
1214 m_readyState = static_cast<ReadyState>(state); | 1219 m_readyState = static_cast<ReadyState>(state); |
1215 | 1220 |
1216 if (m_readyState == oldState) | 1221 if (m_readyState == oldState) |
1217 return; | 1222 return; |
1218 | 1223 |
1219 if (oldState > m_readyStateMaximum) | 1224 if (oldState > m_readyStateMaximum) |
1220 m_readyStateMaximum = oldState; | 1225 m_readyStateMaximum = oldState; |
1221 | 1226 |
1222 if (m_networkState == NETWORK_EMPTY) | 1227 if (m_networkState == NETWORK_EMPTY) |
1223 return; | 1228 return; |
1224 | 1229 |
1225 if (m_seeking) { | 1230 if (m_seeking) { |
1226 // 4.8.10.9, step 11 | 1231 // 4.8.10.9, step 11 |
1227 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) | 1232 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) |
1228 scheduleEvent(eventNames().waitingEvent); | 1233 scheduleEvent(eventNames().waitingEvent); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 m_sentStalledEvent = true; | 1330 m_sentStalledEvent = true; |
1326 setShouldDelayLoadEvent(false); | 1331 setShouldDelayLoadEvent(false); |
1327 } | 1332 } |
1328 } else { | 1333 } else { |
1329 scheduleEvent(eventNames().progressEvent); | 1334 scheduleEvent(eventNames().progressEvent); |
1330 m_previousProgress = progress; | 1335 m_previousProgress = progress; |
1331 m_previousProgressTime = time; | 1336 m_previousProgressTime = time; |
1332 m_sentStalledEvent = false; | 1337 m_sentStalledEvent = false; |
1333 if (renderer()) | 1338 if (renderer()) |
1334 renderer()->updateFromElement(); | 1339 renderer()->updateFromElement(); |
| 1340 if (hasMediaControls()) |
| 1341 mediaControls()->bufferingProgressed(); |
1335 } | 1342 } |
1336 } | 1343 } |
1337 | 1344 |
1338 void HTMLMediaElement::rewind(float timeDelta) | 1345 void HTMLMediaElement::rewind(float timeDelta) |
1339 { | 1346 { |
1340 LOG(Media, "HTMLMediaElement::rewind(%f)", timeDelta); | 1347 LOG(Media, "HTMLMediaElement::rewind(%f)", timeDelta); |
1341 | 1348 |
1342 ExceptionCode e; | 1349 ExceptionCode e; |
1343 setCurrentTime(max(currentTime() - timeDelta, minTimeSeekable()), e); | 1350 setCurrentTime(max(currentTime() - timeDelta, minTimeSeekable()), e); |
1344 } | 1351 } |
1345 | 1352 |
1346 void HTMLMediaElement::returnToRealtime() | 1353 void HTMLMediaElement::returnToRealtime() |
1347 { | 1354 { |
1348 LOG(Media, "HTMLMediaElement::returnToRealtime"); | 1355 LOG(Media, "HTMLMediaElement::returnToRealtime"); |
1349 ExceptionCode e; | 1356 ExceptionCode e; |
1350 setCurrentTime(maxTimeSeekable(), e); | 1357 setCurrentTime(maxTimeSeekable(), e); |
1351 } | 1358 } |
1352 | 1359 |
1353 void HTMLMediaElement::addPlayedRange(float start, float end) | 1360 void HTMLMediaElement::addPlayedRange(float start, float end) |
1354 { | 1361 { |
1355 LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); | 1362 LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); |
1356 if (!m_playedTimeRanges) | 1363 if (!m_playedTimeRanges) |
1357 m_playedTimeRanges = TimeRanges::create(); | 1364 m_playedTimeRanges = TimeRanges::create(); |
1358 m_playedTimeRanges->add(start, end); | 1365 m_playedTimeRanges->add(start, end); |
1359 } | 1366 } |
1360 | 1367 |
1361 bool HTMLMediaElement::supportsSave() const | 1368 bool HTMLMediaElement::supportsSave() const |
1362 { | 1369 { |
1363 return m_player ? m_player->supportsSave() : false; | 1370 return m_player ? m_player->supportsSave() : false; |
1364 } | 1371 } |
1365 | 1372 |
1366 bool HTMLMediaElement::supportsScanning() const | 1373 bool HTMLMediaElement::supportsScanning() const |
1367 { | 1374 { |
1368 return m_player ? m_player->supportsScanning() : false; | 1375 return m_player ? m_player->supportsScanning() : false; |
1369 } | 1376 } |
(...skipping 29 matching lines...) Expand all Loading... |
1399 | 1406 |
1400 // 2 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is | 1407 // 2 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is |
1401 // already running. Abort that other instance of the algorithm without waiti
ng for the step that | 1408 // already running. Abort that other instance of the algorithm without waiti
ng for the step that |
1402 // it is running to complete. | 1409 // it is running to complete. |
1403 // Nothing specific to be done here. | 1410 // Nothing specific to be done here. |
1404 | 1411 |
1405 // 3 - Set the seeking IDL attribute to true. | 1412 // 3 - Set the seeking IDL attribute to true. |
1406 // The flag will be cleared when the engine tells us the time has actually c
hanged. | 1413 // The flag will be cleared when the engine tells us the time has actually c
hanged. |
1407 m_seeking = true; | 1414 m_seeking = true; |
1408 | 1415 |
1409 // 5 - If the new playback position is later than the end of the media resou
rce, then let it be the end | 1416 // 5 - If the new playback position is later than the end of the media resou
rce, then let it be the end |
1410 // of the media resource instead. | 1417 // of the media resource instead. |
1411 time = min(time, duration()); | 1418 time = min(time, duration()); |
1412 | 1419 |
1413 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. | 1420 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. |
1414 float earliestTime = m_player->startTime(); | 1421 float earliestTime = m_player->startTime(); |
1415 time = max(time, earliestTime); | 1422 time = max(time, earliestTime); |
1416 | 1423 |
1417 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This | 1424 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This |
1418 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's | 1425 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's |
1419 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and | 1426 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and |
1420 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never | 1427 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never |
1421 // fire a 'seeked' event. | 1428 // fire a 'seeked' event. |
1422 #if !LOG_DISABLED | 1429 #if !LOG_DISABLED |
1423 float mediaTime = m_player->mediaTimeForTimeValue(time); | 1430 float mediaTime = m_player->mediaTimeForTimeValue(time); |
1424 if (time != mediaTime) | 1431 if (time != mediaTime) |
1425 LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent is %f
", time, mediaTime); | 1432 LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent is %f
", time, mediaTime); |
1426 #endif | 1433 #endif |
1427 time = m_player->mediaTimeForTimeValue(time); | 1434 time = m_player->mediaTimeForTimeValue(time); |
1428 | 1435 |
1429 // 7 - If the (possibly now changed) new playback position is not in one of
the ranges given in the | 1436 // 7 - If the (possibly now changed) new playback position is not in one of
the ranges given in the |
1430 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute | 1437 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute |
1431 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable | 1438 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable |
1432 // attribute then set the seeking IDL attribute to false and abort these ste
ps. | 1439 // attribute then set the seeking IDL attribute to false and abort these ste
ps. |
1433 RefPtr<TimeRanges> seekableRanges = seekable(); | 1440 RefPtr<TimeRanges> seekableRanges = seekable(); |
1434 | 1441 |
1435 // Short circuit seeking to the current time by just firing the events if no
seek is required. | 1442 // Short circuit seeking to the current time by just firing the events if no
seek is required. |
1436 // Don't skip calling the media engine if we are in poster mode because a se
ek should always | 1443 // Don't skip calling the media engine if we are in poster mode because a se
ek should always |
1437 // cancel poster display. | 1444 // cancel poster display. |
1438 bool noSeekRequired = !seekableRanges->length() || (time == now && displayMo
de() != Poster); | 1445 bool noSeekRequired = !seekableRanges->length() || (time == now && displayMo
de() != Poster); |
1439 | 1446 |
1440 #if ENABLE(MEDIA_SOURCE) | 1447 #if ENABLE(MEDIA_SOURCE) |
1441 // Always notify the media engine of a seek if the source is not closed. Thi
s ensures that the source is | 1448 // Always notify the media engine of a seek if the source is not closed. Thi
s ensures that the source is |
1442 // always in a flushed state when the 'seeking' event fires. | 1449 // always in a flushed state when the 'seeking' event fires. |
1443 if (m_sourceState != SOURCE_CLOSED) | 1450 if (m_sourceState != SOURCE_CLOSED) |
1444 noSeekRequired = false; | 1451 noSeekRequired = false; |
1445 #endif | 1452 #endif |
1446 | 1453 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 } | 1645 } |
1639 | 1646 |
1640 float HTMLMediaElement::playbackRate() const | 1647 float HTMLMediaElement::playbackRate() const |
1641 { | 1648 { |
1642 return m_playbackRate; | 1649 return m_playbackRate; |
1643 } | 1650 } |
1644 | 1651 |
1645 void HTMLMediaElement::setPlaybackRate(float rate) | 1652 void HTMLMediaElement::setPlaybackRate(float rate) |
1646 { | 1653 { |
1647 LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate); | 1654 LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate); |
1648 | 1655 |
1649 if (m_playbackRate != rate) { | 1656 if (m_playbackRate != rate) { |
1650 m_playbackRate = rate; | 1657 m_playbackRate = rate; |
1651 invalidateCachedTime(); | 1658 invalidateCachedTime(); |
1652 scheduleEvent(eventNames().ratechangeEvent); | 1659 scheduleEvent(eventNames().ratechangeEvent); |
1653 } | 1660 } |
1654 | 1661 |
1655 if (m_player && potentiallyPlaying() && m_player->rate() != rate && !m_media
Controller) | 1662 if (m_player && potentiallyPlaying() && m_player->rate() != rate && !m_media
Controller) |
1656 m_player->setRate(rate); | 1663 m_player->setRate(rate); |
1657 } | 1664 } |
1658 | 1665 |
1659 void HTMLMediaElement::updatePlaybackRate() | 1666 void HTMLMediaElement::updatePlaybackRate() |
1660 { | 1667 { |
1661 float effectiveRate = m_mediaController ? m_mediaController->playbackRate()
: m_playbackRate; | 1668 float effectiveRate = m_mediaController ? m_mediaController->playbackRate()
: m_playbackRate; |
1662 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate &&
!m_mediaController) | 1669 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate &&
!m_mediaController) |
1663 m_player->setRate(effectiveRate); | 1670 m_player->setRate(effectiveRate); |
1664 } | 1671 } |
1665 | 1672 |
1666 bool HTMLMediaElement::webkitPreservesPitch() const | 1673 bool HTMLMediaElement::webkitPreservesPitch() const |
1667 { | 1674 { |
1668 return m_webkitPreservesPitch; | 1675 return m_webkitPreservesPitch; |
1669 } | 1676 } |
1670 | 1677 |
1671 void HTMLMediaElement::setWebkitPreservesPitch(bool preservesPitch) | 1678 void HTMLMediaElement::setWebkitPreservesPitch(bool preservesPitch) |
1672 { | 1679 { |
1673 LOG(Media, "HTMLMediaElement::setWebkitPreservesPitch(%s)", boolString(prese
rvesPitch)); | 1680 LOG(Media, "HTMLMediaElement::setWebkitPreservesPitch(%s)", boolString(prese
rvesPitch)); |
1674 | 1681 |
1675 m_webkitPreservesPitch = preservesPitch; | 1682 m_webkitPreservesPitch = preservesPitch; |
1676 | 1683 |
1677 if (!m_player) | 1684 if (!m_player) |
1678 return; | 1685 return; |
1679 | 1686 |
1680 m_player->setPreservesPitch(preservesPitch); | 1687 m_player->setPreservesPitch(preservesPitch); |
1681 } | 1688 } |
1682 | 1689 |
1683 bool HTMLMediaElement::ended() const | 1690 bool HTMLMediaElement::ended() const |
1684 { | 1691 { |
1685 // 4.8.10.8 Playing the media resource | 1692 // 4.8.10.8 Playing the media resource |
1686 // The ended attribute must return true if the media element has ended | 1693 // The ended attribute must return true if the media element has ended |
1687 // playback and the direction of playback is forwards, and false otherwise. | 1694 // playback and the direction of playback is forwards, and false otherwise. |
1688 return endedPlayback() && m_playbackRate > 0; | 1695 return endedPlayback() && m_playbackRate > 0; |
1689 } | 1696 } |
1690 | 1697 |
1691 bool HTMLMediaElement::autoplay() const | 1698 bool HTMLMediaElement::autoplay() const |
1692 { | 1699 { |
1693 return fastHasAttribute(autoplayAttr); | 1700 return fastHasAttribute(autoplayAttr); |
1694 } | 1701 } |
1695 | 1702 |
1696 void HTMLMediaElement::setAutoplay(bool b) | 1703 void HTMLMediaElement::setAutoplay(bool b) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 | 1795 |
1789 void HTMLMediaElement::pauseInternal() | 1796 void HTMLMediaElement::pauseInternal() |
1790 { | 1797 { |
1791 LOG(Media, "HTMLMediaElement::pauseInternal"); | 1798 LOG(Media, "HTMLMediaElement::pauseInternal"); |
1792 | 1799 |
1793 // 4.8.10.9. Playing the media resource | 1800 // 4.8.10.9. Playing the media resource |
1794 if (!m_player || m_networkState == NETWORK_EMPTY) | 1801 if (!m_player || m_networkState == NETWORK_EMPTY) |
1795 scheduleLoad(MediaResource); | 1802 scheduleLoad(MediaResource); |
1796 | 1803 |
1797 m_autoplaying = false; | 1804 m_autoplaying = false; |
1798 | 1805 |
1799 if (!m_paused) { | 1806 if (!m_paused) { |
1800 m_paused = true; | 1807 m_paused = true; |
1801 scheduleTimeupdateEvent(false); | 1808 scheduleTimeupdateEvent(false); |
1802 scheduleEvent(eventNames().pauseEvent); | 1809 scheduleEvent(eventNames().pauseEvent); |
1803 } | 1810 } |
1804 | 1811 |
1805 updatePlayState(); | 1812 updatePlayState(); |
1806 } | 1813 } |
1807 | 1814 |
1808 #if ENABLE(MEDIA_SOURCE) | 1815 #if ENABLE(MEDIA_SOURCE) |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 } | 1926 } |
1920 | 1927 |
1921 void HTMLMediaElement::setVolume(float vol, ExceptionCode& ec) | 1928 void HTMLMediaElement::setVolume(float vol, ExceptionCode& ec) |
1922 { | 1929 { |
1923 LOG(Media, "HTMLMediaElement::setVolume(%f)", vol); | 1930 LOG(Media, "HTMLMediaElement::setVolume(%f)", vol); |
1924 | 1931 |
1925 if (vol < 0.0f || vol > 1.0f) { | 1932 if (vol < 0.0f || vol > 1.0f) { |
1926 ec = INDEX_SIZE_ERR; | 1933 ec = INDEX_SIZE_ERR; |
1927 return; | 1934 return; |
1928 } | 1935 } |
1929 | 1936 |
1930 if (m_volume != vol) { | 1937 if (m_volume != vol) { |
1931 m_volume = vol; | 1938 m_volume = vol; |
1932 updateVolume(); | 1939 updateVolume(); |
1933 scheduleEvent(eventNames().volumechangeEvent); | 1940 scheduleEvent(eventNames().volumechangeEvent); |
1934 } | 1941 } |
1935 } | 1942 } |
1936 | 1943 |
1937 bool HTMLMediaElement::muted() const | 1944 bool HTMLMediaElement::muted() const |
1938 { | 1945 { |
1939 return m_muted; | 1946 return m_muted; |
(...skipping 19 matching lines...) Expand all Loading... |
1959 | 1966 |
1960 void HTMLMediaElement::togglePlayState() | 1967 void HTMLMediaElement::togglePlayState() |
1961 { | 1968 { |
1962 LOG(Media, "HTMLMediaElement::togglePlayState - canPlay() is %s", boolString
(canPlay())); | 1969 LOG(Media, "HTMLMediaElement::togglePlayState - canPlay() is %s", boolString
(canPlay())); |
1963 | 1970 |
1964 // We can safely call the internal play/pause methods, which don't check res
trictions, because | 1971 // We can safely call the internal play/pause methods, which don't check res
trictions, because |
1965 // this method is only called from the built-in media controller | 1972 // this method is only called from the built-in media controller |
1966 if (canPlay()) { | 1973 if (canPlay()) { |
1967 updatePlaybackRate(); | 1974 updatePlaybackRate(); |
1968 playInternal(); | 1975 playInternal(); |
1969 } else | 1976 } else |
1970 pauseInternal(); | 1977 pauseInternal(); |
1971 } | 1978 } |
1972 | 1979 |
1973 void HTMLMediaElement::beginScrubbing() | 1980 void HTMLMediaElement::beginScrubbing() |
1974 { | 1981 { |
1975 LOG(Media, "HTMLMediaElement::beginScrubbing - paused() is %s", boolString(p
aused())); | 1982 LOG(Media, "HTMLMediaElement::beginScrubbing - paused() is %s", boolString(p
aused())); |
1976 | 1983 |
1977 if (!paused()) { | 1984 if (!paused()) { |
1978 if (ended()) { | 1985 if (ended()) { |
1979 // Because a media element stays in non-paused state when it reaches
end, playback resumes | 1986 // Because a media element stays in non-paused state when it reaches
end, playback resumes |
1980 // when the slider is dragged from the end to another position unles
s we pause first. Do | 1987 // when the slider is dragged from the end to another position unles
s we pause first. Do |
1981 // a "hard pause" so an event is generated, since we want to stay pa
used after scrubbing finishes. | 1988 // a "hard pause" so an event is generated, since we want to stay pa
used after scrubbing finishes. |
1982 pause(); | 1989 pause(); |
1983 } else { | 1990 } else { |
1984 // Not at the end but we still want to pause playback so the media e
ngine doesn't try to | 1991 // Not at the end but we still want to pause playback so the media e
ngine doesn't try to |
1985 // continue playing during scrubbing. Pause without generating an ev
ent as we will | 1992 // continue playing during scrubbing. Pause without generating an ev
ent as we will |
1986 // unpause after scrubbing finishes. | 1993 // unpause after scrubbing finishes. |
1987 setPausedInternal(true); | 1994 setPausedInternal(true); |
1988 } | 1995 } |
1989 } | 1996 } |
1990 } | 1997 } |
1991 | 1998 |
1992 void HTMLMediaElement::endScrubbing() | 1999 void HTMLMediaElement::endScrubbing() |
1993 { | 2000 { |
1994 LOG(Media, "HTMLMediaElement::endScrubbing - m_pausedInternal is %s", boolSt
ring(m_pausedInternal)); | 2001 LOG(Media, "HTMLMediaElement::endScrubbing - m_pausedInternal is %s", boolSt
ring(m_pausedInternal)); |
1995 | 2002 |
(...skipping 20 matching lines...) Expand all Loading... |
2016 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) | 2023 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) |
2017 { | 2024 { |
2018 ASSERT(m_player); | 2025 ASSERT(m_player); |
2019 if (!m_playbackRate) | 2026 if (!m_playbackRate) |
2020 return; | 2027 return; |
2021 | 2028 |
2022 scheduleTimeupdateEvent(true); | 2029 scheduleTimeupdateEvent(true); |
2023 if (hasMediaControls()) | 2030 if (hasMediaControls()) |
2024 mediaControls()->playbackProgressed(); | 2031 mediaControls()->playbackProgressed(); |
2025 // FIXME: deal with cue ranges here | 2032 // FIXME: deal with cue ranges here |
2026 | 2033 |
2027 #if ENABLE(VIDEO_TRACK) | 2034 #if ENABLE(VIDEO_TRACK) |
2028 updateActiveTextTrackCues(currentTime()); | 2035 updateActiveTextTrackCues(currentTime()); |
2029 #endif | 2036 #endif |
2030 } | 2037 } |
2031 | 2038 |
2032 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent) | 2039 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent) |
2033 { | 2040 { |
2034 double now = WTF::currentTime(); | 2041 double now = WTF::currentTime(); |
2035 double timedelta = now - m_lastTimeUpdateEventWallTime; | 2042 double timedelta = now - m_lastTimeUpdateEventWallTime; |
2036 | 2043 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2074 } | 2081 } |
2075 | 2082 |
2076 #if ENABLE(VIDEO_TRACK) | 2083 #if ENABLE(VIDEO_TRACK) |
2077 PassRefPtr<TextTrack> HTMLMediaElement::addTrack(const String& kind, const Strin
g& label, const String& language, ExceptionCode& ec) | 2084 PassRefPtr<TextTrack> HTMLMediaElement::addTrack(const String& kind, const Strin
g& label, const String& language, ExceptionCode& ec) |
2078 { | 2085 { |
2079 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) | 2086 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) |
2080 return 0; | 2087 return 0; |
2081 | 2088 |
2082 // 4.8.10.12.4 Text track API | 2089 // 4.8.10.12.4 Text track API |
2083 // The addTextTrack(kind, label, language) method of media elements, when in
voked, must run the following steps: | 2090 // The addTextTrack(kind, label, language) method of media elements, when in
voked, must run the following steps: |
2084 | 2091 |
2085 // 1. If kind is not one of the following strings, then throw a SyntaxError
exception and abort these steps | 2092 // 1. If kind is not one of the following strings, then throw a SyntaxError
exception and abort these steps |
2086 if (!TextTrack::isValidKindKeyword(kind)) { | 2093 if (!TextTrack::isValidKindKeyword(kind)) { |
2087 ec = SYNTAX_ERR; | 2094 ec = SYNTAX_ERR; |
2088 return 0; | 2095 return 0; |
2089 } | 2096 } |
2090 | 2097 |
2091 // 2. If the label argument was omitted, let label be the empty string. | 2098 // 2. If the label argument was omitted, let label be the empty string. |
2092 // 3. If the language argument was omitted, let language be the empty string
. | 2099 // 3. If the language argument was omitted, let language be the empty string
. |
2093 // 4. Create a new TextTrack object. | 2100 // 4. Create a new TextTrack object. |
2094 RefPtr<TextTrack> textTrack = TextTrack::create(ActiveDOMObject::scriptExecu
tionContext(), this, kind, label, language); | 2101 RefPtr<TextTrack> textTrack = TextTrack::create(ActiveDOMObject::scriptExecu
tionContext(), this, kind, label, language); |
2095 | 2102 |
2096 // 5. Create a new text track corresponding to the new object, and set its t
ext track kind to kind, its text | 2103 // 5. Create a new text track corresponding to the new object, and set its t
ext track kind to kind, its text |
2097 // track label to label, its text track language to language, its text track
readiness state to the text track | 2104 // track label to label, its text track language to language, its text track
readiness state to the text track |
2098 // loaded state, its text track mode to the text track hidden mode, and its
text track list of cues to an empty list. | 2105 // loaded state, its text track mode to the text track hidden mode, and its
text track list of cues to an empty list. |
2099 | 2106 |
2100 // 6. Add the new text track to the media element's list of text tracks. | 2107 // 6. Add the new text track to the media element's list of text tracks. |
2101 addTextTrack(textTrack); | 2108 addTextTrack(textTrack); |
2102 | 2109 |
2103 return textTrack.release(); | 2110 return textTrack.release(); |
2104 } | 2111 } |
2105 | 2112 |
2106 void HTMLMediaElement::addTextTrack(PassRefPtr<TextTrack> track) | 2113 void HTMLMediaElement::addTextTrack(PassRefPtr<TextTrack> track) |
2107 { | 2114 { |
2108 textTracks()->append(track); | 2115 textTracks()->append(track); |
2109 configureTextTracks(); | 2116 configureTextTracks(); |
2110 } | 2117 } |
2111 | 2118 |
2112 void HTMLMediaElement::configureTextTracks() | 2119 void HTMLMediaElement::configureTextTracks() |
2113 { | 2120 { |
2114 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) | 2121 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) |
2115 return; | 2122 return; |
2116 | 2123 |
2117 // 4.8.10.12.3 Sourcing out-of-band text tracks | 2124 // 4.8.10.12.3 Sourcing out-of-band text tracks |
2118 | 2125 |
2119 // When a text track corresponding to a track element is added to a media el
ement's list of text tracks, | 2126 // When a text track corresponding to a track element is added to a media el
ement's list of text tracks, |
2120 // the user agent must set the text track mode appropriately, as determined
by the following conditions: | 2127 // the user agent must set the text track mode appropriately, as determined
by the following conditions: |
2121 | 2128 |
2122 // * If the text track kind is subtitles or captions and the user has indica
ted an interest in having a | 2129 // * If the text track kind is subtitles or captions and the user has indica
ted an interest in having a |
2123 // track with this text track kind, text track language, and text track labe
l enabled, and there is no | 2130 // track with this text track kind, text track language, and text track labe
l enabled, and there is no |
2124 // other text track in the media element's list of text tracks with a text t
rack kind of either subtitles | 2131 // other text track in the media element's list of text tracks with a text t
rack kind of either subtitles |
2125 // or captions whose text track mode is showing | 2132 // or captions whose text track mode is showing |
2126 // * If the text track kind is descriptions and the user has indicated an in
terest in having text | 2133 // * If the text track kind is descriptions and the user has indicated an in
terest in having text |
2127 // descriptions with this text track language and text track label enabled,
and there is no other text | 2134 // descriptions with this text track language and text track label enabled,
and there is no other text |
2128 // track in the media element's list of text tracks with a text track kind o
f descriptions whose text | 2135 // track in the media element's list of text tracks with a text track kind o
f descriptions whose text |
2129 // track mode is showing | 2136 // track mode is showing |
2130 // Let the text track mode be showing. | 2137 // Let the text track mode be showing. |
2131 // If there is a text track in the media element's list of text tracks wh
ose text track mode is showing | 2138 // If there is a text track in the media element's list of text tracks wh
ose text track mode is showing |
2132 // by default, the user agent must furthermore change that text track's t
ext track mode to hidden. | 2139 // by default, the user agent must furthermore change that text track's t
ext track mode to hidden. |
2133 | 2140 |
2134 // * If the text track kind is chapters and the text track language is one t
hat the user agent has reason | 2141 // * If the text track kind is chapters and the text track language is one t
hat the user agent has reason |
2135 // to believe is appropriate for the user, and there is no other text track
in the media element's list of | 2142 // to believe is appropriate for the user, and there is no other text track
in the media element's list of |
2136 // text tracks with a text track kind of chapters whose text track mode is s
howing | 2143 // text tracks with a text track kind of chapters whose text track mode is s
howing |
2137 // Let the text track mode be showing. | 2144 // Let the text track mode be showing. |
2138 | 2145 |
2139 // * If the track element has a default attribute specified, and there is no
other text track in the media | 2146 // * If the track element has a default attribute specified, and there is no
other text track in the media |
2140 // element's list of text tracks whose text track mode is showing or showing
by default | 2147 // element's list of text tracks whose text track mode is showing or showing
by default |
2141 // Let the text track mode be showing by default. | 2148 // Let the text track mode be showing by default. |
2142 | 2149 |
2143 // Otherwise | 2150 // Otherwise |
2144 // Let the text track mode be disabled. | 2151 // Let the text track mode be disabled. |
2145 | 2152 |
2146 // FIXME(71123): Until the above logic has been implemented, just tell all t
ext tracks to load. | 2153 // FIXME(71123): Until the above logic has been implemented, just tell all t
ext tracks to load. |
2147 for (Node* node = firstChild(); node; node = node->nextSibling()) { | 2154 for (Node* node = firstChild(); node; node = node->nextSibling()) { |
2148 if (node->hasTagName(trackTag)) | 2155 if (node->hasTagName(trackTag)) |
2149 static_cast<HTMLTrackElement*>(node)->scheduleLoad(); | 2156 static_cast<HTMLTrackElement*>(node)->scheduleLoad(); |
2150 } | 2157 } |
2151 } | 2158 } |
2152 | 2159 |
2153 TextTrackList* HTMLMediaElement::textTracks() | 2160 TextTrackList* HTMLMediaElement::textTracks() |
2154 { | 2161 { |
2155 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) | 2162 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) |
2156 return 0; | 2163 return 0; |
2157 | 2164 |
2158 if (!m_textTracks) | 2165 if (!m_textTracks) |
2159 m_textTracks = TextTrackList::create(this, ActiveDOMObject::scriptExecut
ionContext()); | 2166 m_textTracks = TextTrackList::create(this, ActiveDOMObject::scriptExecut
ionContext()); |
2160 | 2167 |
2161 return m_textTracks.get(); | 2168 return m_textTracks.get(); |
2162 } | 2169 } |
2163 | 2170 |
2164 void HTMLMediaElement::trackWasAdded(HTMLTrackElement* trackElement) | 2171 void HTMLMediaElement::trackWasAdded(HTMLTrackElement* trackElement) |
2165 { | 2172 { |
2166 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) | 2173 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) |
2167 return; | 2174 return; |
2168 | 2175 |
2169 #if !LOG_DISABLED | 2176 #if !LOG_DISABLED |
2170 if (trackElement->hasTagName(trackTag)) { | 2177 if (trackElement->hasTagName(trackTag)) { |
2171 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); | 2178 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); |
2172 LOG(Media, "HTMLMediaElement::trackWasAdded - 'src' is %s", urlForLoggin
g(url).utf8().data()); | 2179 LOG(Media, "HTMLMediaElement::trackWasAdded - 'src' is %s", urlForLoggin
g(url).utf8().data()); |
2173 } | 2180 } |
2174 #endif | 2181 #endif |
2175 | 2182 |
2176 // 4.8.10.12.3 Sourcing out-of-band text tracks | 2183 // 4.8.10.12.3 Sourcing out-of-band text tracks |
2177 // When a track element's parent element changes and the new parent is a med
ia element, | 2184 // When a track element's parent element changes and the new parent is a med
ia element, |
2178 // then the user agent must add the track element's corresponding text track
to the | 2185 // then the user agent must add the track element's corresponding text track
to the |
2179 // media element's list of text tracks ... [continues in TextTrackList::appe
nd] | 2186 // media element's list of text tracks ... [continues in TextTrackList::appe
nd] |
2180 RefPtr<TextTrack> textTrack = trackElement->track(); | 2187 RefPtr<TextTrack> textTrack = trackElement->track(); |
2181 if (!textTrack) | 2188 if (!textTrack) |
2182 return; | 2189 return; |
2183 addTextTrack(textTrack); | 2190 addTextTrack(textTrack); |
2184 scheduleLoad(TextTrackResource); | 2191 scheduleLoad(TextTrackResource); |
2185 } | 2192 } |
2186 | 2193 |
2187 void HTMLMediaElement::trackWillBeRemoved(HTMLTrackElement* trackElement) | 2194 void HTMLMediaElement::trackWillBeRemoved(HTMLTrackElement* trackElement) |
2188 { | 2195 { |
2189 #if !LOG_DISABLED | 2196 #if !LOG_DISABLED |
2190 if (trackElement->hasTagName(trackTag)) { | 2197 if (trackElement->hasTagName(trackTag)) { |
2191 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); | 2198 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); |
2192 LOG(Media, "HTMLMediaElement::trackWillBeRemoved - 'src' is %s", urlForL
ogging(url).utf8().data()); | 2199 LOG(Media, "HTMLMediaElement::trackWillBeRemoved - 'src' is %s", urlForL
ogging(url).utf8().data()); |
2193 } | 2200 } |
2194 #endif | 2201 #endif |
2195 | 2202 |
2196 RefPtr<TextTrack> textTrack = trackElement->track(); | 2203 RefPtr<TextTrack> textTrack = trackElement->track(); |
2197 if (!textTrack) | 2204 if (!textTrack) |
2198 return; | 2205 return; |
2199 | 2206 |
2200 // 4.8.10.12.3 Sourcing out-of-band text tracks | 2207 // 4.8.10.12.3 Sourcing out-of-band text tracks |
2201 // When a track element's parent element changes and the old parent was a me
dia element, | 2208 // When a track element's parent element changes and the old parent was a me
dia element, |
2202 // then the user agent must remove the track element's corresponding text tr
ack from the | 2209 // then the user agent must remove the track element's corresponding text tr
ack from the |
2203 // media element's list of text tracks. | 2210 // media element's list of text tracks. |
2204 m_textTracks->remove(textTrack); | 2211 m_textTracks->remove(textTrack); |
2205 } | 2212 } |
2206 #endif | 2213 #endif |
2207 | 2214 |
2208 bool HTMLMediaElement::havePotentialSourceChild() | 2215 bool HTMLMediaElement::havePotentialSourceChild() |
2209 { | 2216 { |
2210 // Stash the current <source> node and next nodes so we can restore them aft
er checking | 2217 // Stash the current <source> node and next nodes so we can restore them aft
er checking |
2211 // to see there is another potential. | 2218 // to see there is another potential. |
2212 HTMLSourceElement* currentSourceNode = m_currentSourceNode; | 2219 HTMLSourceElement* currentSourceNode = m_currentSourceNode; |
(...skipping 27 matching lines...) Expand all Loading... |
2240 KURL mediaURL; | 2247 KURL mediaURL; |
2241 Node* node; | 2248 Node* node; |
2242 HTMLSourceElement* source = 0; | 2249 HTMLSourceElement* source = 0; |
2243 bool lookingForStartNode = m_nextChildNodeToConsider; | 2250 bool lookingForStartNode = m_nextChildNodeToConsider; |
2244 bool canUse = false; | 2251 bool canUse = false; |
2245 | 2252 |
2246 for (node = firstChild(); !canUse && node; node = node->nextSibling()) { | 2253 for (node = firstChild(); !canUse && node; node = node->nextSibling()) { |
2247 if (lookingForStartNode && m_nextChildNodeToConsider != node) | 2254 if (lookingForStartNode && m_nextChildNodeToConsider != node) |
2248 continue; | 2255 continue; |
2249 lookingForStartNode = false; | 2256 lookingForStartNode = false; |
2250 | 2257 |
2251 if (!node->hasTagName(sourceTag)) | 2258 if (!node->hasTagName(sourceTag)) |
2252 continue; | 2259 continue; |
2253 | 2260 |
2254 source = static_cast<HTMLSourceElement*>(node); | 2261 source = static_cast<HTMLSourceElement*>(node); |
2255 | 2262 |
2256 // If candidate does not have a src attribute, or if its src attribute's
value is the empty string ... jump down to the failed step below | 2263 // If candidate does not have a src attribute, or if its src attribute's
value is the empty string ... jump down to the failed step below |
2257 mediaURL = source->getNonEmptyURLAttribute(srcAttr); | 2264 mediaURL = source->getNonEmptyURLAttribute(srcAttr); |
2258 #if !LOG_DISABLED | 2265 #if !LOG_DISABLED |
2259 if (shouldLog) | 2266 if (shouldLog) |
2260 LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'src' is %s",
urlForLogging(mediaURL).utf8().data()); | 2267 LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'src' is %s",
urlForLogging(mediaURL).utf8().data()); |
2261 #endif | 2268 #endif |
2262 if (mediaURL.isEmpty()) | 2269 if (mediaURL.isEmpty()) |
2263 goto check_again; | 2270 goto check_again; |
2264 | 2271 |
2265 if (source->fastHasAttribute(mediaAttr)) { | 2272 if (source->fastHasAttribute(mediaAttr)) { |
2266 MediaQueryEvaluator screenEval("screen", document()->frame(), render
er() ? renderer()->style() : 0); | 2273 MediaQueryEvaluator screenEval("screen", document()->frame(), render
er() ? renderer()->style() : 0); |
2267 RefPtr<MediaList> media = MediaList::createAllowingDescriptionSyntax
(source->media()); | 2274 RefPtr<MediaList> media = MediaList::createAllowingDescriptionSyntax
(source->media()); |
2268 #if !LOG_DISABLED | 2275 #if !LOG_DISABLED |
2269 if (shouldLog) | 2276 if (shouldLog) |
2270 LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'media' is
%s", source->media().utf8().data()); | 2277 LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'media' is
%s", source->media().utf8().data()); |
2271 #endif | 2278 #endif |
2272 if (!screenEval.eval(media.get())) | 2279 if (!screenEval.eval(media.get())) |
2273 goto check_again; | 2280 goto check_again; |
2274 } | 2281 } |
2275 | 2282 |
2276 if (source->fastHasAttribute(typeAttr)) { | 2283 if (source->fastHasAttribute(typeAttr)) { |
2277 #if !LOG_DISABLED | 2284 #if !LOG_DISABLED |
2278 if (shouldLog) | 2285 if (shouldLog) |
2279 LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'type' is
%s", source->type().utf8().data()); | 2286 LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'type' is
%s", source->type().utf8().data()); |
2280 #endif | 2287 #endif |
2281 if (!MediaPlayer::supportsType(ContentType(source->type()))) | 2288 if (!MediaPlayer::supportsType(ContentType(source->type()))) |
2282 goto check_again; | 2289 goto check_again; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2316 void HTMLMediaElement::sourceWasAdded(HTMLSourceElement* source) | 2323 void HTMLMediaElement::sourceWasAdded(HTMLSourceElement* source) |
2317 { | 2324 { |
2318 LOG(Media, "HTMLMediaElement::sourceWasAdded(%p)", source); | 2325 LOG(Media, "HTMLMediaElement::sourceWasAdded(%p)", source); |
2319 | 2326 |
2320 #if !LOG_DISABLED | 2327 #if !LOG_DISABLED |
2321 if (source->hasTagName(sourceTag)) { | 2328 if (source->hasTagName(sourceTag)) { |
2322 KURL url = source->getNonEmptyURLAttribute(srcAttr); | 2329 KURL url = source->getNonEmptyURLAttribute(srcAttr); |
2323 LOG(Media, "HTMLMediaElement::sourceWasAdded - 'src' is %s", urlForLoggi
ng(url).utf8().data()); | 2330 LOG(Media, "HTMLMediaElement::sourceWasAdded - 'src' is %s", urlForLoggi
ng(url).utf8().data()); |
2324 } | 2331 } |
2325 #endif | 2332 #endif |
2326 | 2333 |
2327 // We should only consider a <source> element when there is not src attribut
e at all. | 2334 // We should only consider a <source> element when there is not src attribut
e at all. |
2328 if (fastHasAttribute(srcAttr)) | 2335 if (fastHasAttribute(srcAttr)) |
2329 return; | 2336 return; |
2330 | 2337 |
2331 // 4.8.8 - If a source element is inserted as a child of a media element tha
t has no src | 2338 // 4.8.8 - If a source element is inserted as a child of a media element tha
t has no src |
2332 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag
ent must invoke | 2339 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag
ent must invoke |
2333 // the media element's resource selection algorithm. | 2340 // the media element's resource selection algorithm. |
2334 if (networkState() == HTMLMediaElement::NETWORK_EMPTY) { | 2341 if (networkState() == HTMLMediaElement::NETWORK_EMPTY) { |
2335 scheduleLoad(MediaResource); | 2342 scheduleLoad(MediaResource); |
2336 return; | 2343 return; |
2337 } | 2344 } |
2338 | 2345 |
2339 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) { | 2346 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) { |
2340 LOG(Media, "HTMLMediaElement::sourceWasAdded - <source> inserted immedia
tely after current source"); | 2347 LOG(Media, "HTMLMediaElement::sourceWasAdded - <source> inserted immedia
tely after current source"); |
2341 m_nextChildNodeToConsider = source; | 2348 m_nextChildNodeToConsider = source; |
2342 return; | 2349 return; |
2343 } | 2350 } |
2344 | 2351 |
2345 if (m_nextChildNodeToConsider != sourceChildEndOfListValue()) | 2352 if (m_nextChildNodeToConsider != sourceChildEndOfListValue()) |
2346 return; | 2353 return; |
2347 | 2354 |
2348 // 4.8.9.5, resource selection algorithm, source elements section: | 2355 // 4.8.9.5, resource selection algorithm, source elements section: |
2349 // 20 - Wait until the node after pointer is a node other than the end of th
e list. (This step might wait forever.) | 2356 // 20 - Wait until the node after pointer is a node other than the end of th
e list. (This step might wait forever.) |
2350 // 21 - Asynchronously await a stable state... | 2357 // 21 - Asynchronously await a stable state... |
2351 // 22 - Set the element's delaying-the-load-event flag back to true (this de
lays the load event again, in case | 2358 // 22 - Set the element's delaying-the-load-event flag back to true (this de
lays the load event again, in case |
2352 // it hasn't been fired yet). | 2359 // it hasn't been fired yet). |
2353 setShouldDelayLoadEvent(true); | 2360 setShouldDelayLoadEvent(true); |
2354 | 2361 |
2355 // 23 - Set the networkState back to NETWORK_LOADING. | 2362 // 23 - Set the networkState back to NETWORK_LOADING. |
2356 m_networkState = NETWORK_LOADING; | 2363 m_networkState = NETWORK_LOADING; |
2357 | 2364 |
2358 // 24 - Jump back to the find next candidate step above. | 2365 // 24 - Jump back to the find next candidate step above. |
2359 m_nextChildNodeToConsider = source; | 2366 m_nextChildNodeToConsider = source; |
2360 scheduleNextSourceChild(); | 2367 scheduleNextSourceChild(); |
2361 } | 2368 } |
2362 | 2369 |
2363 void HTMLMediaElement::sourceWillBeRemoved(HTMLSourceElement* source) | 2370 void HTMLMediaElement::sourceWillBeRemoved(HTMLSourceElement* source) |
2364 { | 2371 { |
2365 LOG(Media, "HTMLMediaElement::sourceWillBeRemoved(%p)", source); | 2372 LOG(Media, "HTMLMediaElement::sourceWillBeRemoved(%p)", source); |
2366 | 2373 |
2367 #if !LOG_DISABLED | 2374 #if !LOG_DISABLED |
2368 if (source->hasTagName(sourceTag)) { | 2375 if (source->hasTagName(sourceTag)) { |
2369 KURL url = source->getNonEmptyURLAttribute(srcAttr); | 2376 KURL url = source->getNonEmptyURLAttribute(srcAttr); |
2370 LOG(Media, "HTMLMediaElement::sourceWillBeRemoved - 'src' is %s", urlFor
Logging(url).utf8().data()); | 2377 LOG(Media, "HTMLMediaElement::sourceWillBeRemoved - 'src' is %s", urlFor
Logging(url).utf8().data()); |
2371 } | 2378 } |
2372 #endif | 2379 #endif |
2373 | 2380 |
2374 if (source != m_currentSourceNode && source != m_nextChildNodeToConsider) | 2381 if (source != m_currentSourceNode && source != m_nextChildNodeToConsider) |
2375 return; | 2382 return; |
2376 | 2383 |
2377 if (source == m_nextChildNodeToConsider) { | 2384 if (source == m_nextChildNodeToConsider) { |
2378 m_nextChildNodeToConsider = m_nextChildNodeToConsider->nextSibling(); | 2385 m_nextChildNodeToConsider = m_nextChildNodeToConsider->nextSibling(); |
2379 if (!m_nextChildNodeToConsider) | 2386 if (!m_nextChildNodeToConsider) |
2380 m_nextChildNodeToConsider = sourceChildEndOfListValue(); | 2387 m_nextChildNodeToConsider = sourceChildEndOfListValue(); |
2381 LOG(Media, "HTMLMediaElement::sourceRemoved - m_nextChildNodeToConsider
set to %p", m_nextChildNodeToConsider); | 2388 LOG(Media, "HTMLMediaElement::sourceRemoved - m_nextChildNodeToConsider
set to %p", m_nextChildNodeToConsider); |
2382 } else if (source == m_currentSourceNode) { | 2389 } else if (source == m_currentSourceNode) { |
2383 // Clear the current source node pointer, but don't change the movie as
the spec says: | 2390 // Clear the current source node pointer, but don't change the movie as
the spec says: |
2384 // 4.8.8 - Dynamically modifying a source element and its attribute when
the element is already | 2391 // 4.8.8 - Dynamically modifying a source element and its attribute when
the element is already |
2385 // inserted in a video or audio element will have no effect. | 2392 // inserted in a video or audio element will have no effect. |
2386 m_currentSourceNode = 0; | 2393 m_currentSourceNode = 0; |
2387 LOG(Media, "HTMLMediaElement::sourceRemoved - m_currentSourceNode set to
0"); | 2394 LOG(Media, "HTMLMediaElement::sourceRemoved - m_currentSourceNode set to
0"); |
2388 } | 2395 } |
2389 } | 2396 } |
2390 | 2397 |
2391 void HTMLMediaElement::mediaPlayerTimeChanged(MediaPlayer*) | 2398 void HTMLMediaElement::mediaPlayerTimeChanged(MediaPlayer*) |
2392 { | 2399 { |
2393 LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged"); | 2400 LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged"); |
2394 | 2401 |
2395 beginProcessingMediaPlayerCallback(); | 2402 beginProcessingMediaPlayerCallback(); |
2396 | 2403 |
2397 invalidateCachedTime(); | 2404 invalidateCachedTime(); |
2398 | 2405 |
2399 // 4.8.10.9 step 14 & 15. Needed if no ReadyState change is associated with
the seek. | 2406 // 4.8.10.9 step 14 & 15. Needed if no ReadyState change is associated with
the seek. |
2400 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA) | 2407 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA) |
2401 finishSeek(); | 2408 finishSeek(); |
2402 | 2409 |
2403 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, | 2410 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, |
2404 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current | 2411 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current |
2405 // movie time. | 2412 // movie time. |
2406 scheduleTimeupdateEvent(false); | 2413 scheduleTimeupdateEvent(false); |
2407 | 2414 |
2408 float now = currentTime(); | 2415 float now = currentTime(); |
2409 float dur = duration(); | 2416 float dur = duration(); |
2410 | 2417 |
2411 // When the current playback position reaches the end of the media resource
when the direction of | 2418 // When the current playback position reaches the end of the media resource
when the direction of |
2412 // playback is forwards, then the user agent must follow these steps: | 2419 // playback is forwards, then the user agent must follow these steps: |
2413 if (!isnan(dur) && dur && now >= dur && m_playbackRate > 0) { | 2420 if (!isnan(dur) && dur && now >= dur && m_playbackRate > 0) { |
2414 // If the media element has a loop attribute specified and does not have
a current media controller, | 2421 // If the media element has a loop attribute specified and does not have
a current media controller, |
2415 if (loop() && !m_mediaController) { | 2422 if (loop() && !m_mediaController) { |
2416 ExceptionCode ignoredException; | 2423 ExceptionCode ignoredException; |
2417 m_sentEndEvent = false; | 2424 m_sentEndEvent = false; |
2418 // then seek to the earliest possible position of the media resourc
e and abort these steps. | 2425 // then seek to the earliest possible position of the media resourc
e and abort these steps. |
2419 seek(startTime(), ignoredException); | 2426 seek(startTime(), ignoredException); |
2420 } else { | 2427 } else { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2581 #if USE(ACCELERATED_COMPOSITING) | 2588 #if USE(ACCELERATED_COMPOSITING) |
2582 mediaPlayerRenderingModeChanged(m_player.get()); | 2589 mediaPlayerRenderingModeChanged(m_player.get()); |
2583 #endif | 2590 #endif |
2584 } | 2591 } |
2585 endProcessingMediaPlayerCallback(); | 2592 endProcessingMediaPlayerCallback(); |
2586 } | 2593 } |
2587 | 2594 |
2588 void HTMLMediaElement::mediaPlayerCharacteristicChanged(MediaPlayer*) | 2595 void HTMLMediaElement::mediaPlayerCharacteristicChanged(MediaPlayer*) |
2589 { | 2596 { |
2590 LOG(Media, "HTMLMediaElement::mediaPlayerCharacteristicChanged"); | 2597 LOG(Media, "HTMLMediaElement::mediaPlayerCharacteristicChanged"); |
2591 | 2598 |
2592 beginProcessingMediaPlayerCallback(); | 2599 beginProcessingMediaPlayerCallback(); |
2593 if (hasMediaControls()) | 2600 if (hasMediaControls()) |
2594 mediaControls()->reset(); | 2601 mediaControls()->reset(); |
2595 if (renderer()) | 2602 if (renderer()) |
2596 renderer()->updateFromElement(); | 2603 renderer()->updateFromElement(); |
2597 endProcessingMediaPlayerCallback(); | 2604 endProcessingMediaPlayerCallback(); |
2598 } | 2605 } |
2599 | 2606 |
2600 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const | 2607 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const |
2601 { | 2608 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2638 } | 2645 } |
2639 | 2646 |
2640 bool HTMLMediaElement::endedPlayback() const | 2647 bool HTMLMediaElement::endedPlayback() const |
2641 { | 2648 { |
2642 float dur = duration(); | 2649 float dur = duration(); |
2643 if (!m_player || isnan(dur)) | 2650 if (!m_player || isnan(dur)) |
2644 return false; | 2651 return false; |
2645 | 2652 |
2646 // 4.8.10.8 Playing the media resource | 2653 // 4.8.10.8 Playing the media resource |
2647 | 2654 |
2648 // A media element is said to have ended playback when the element's | 2655 // A media element is said to have ended playback when the element's |
2649 // readyState attribute is HAVE_METADATA or greater, | 2656 // readyState attribute is HAVE_METADATA or greater, |
2650 if (m_readyState < HAVE_METADATA) | 2657 if (m_readyState < HAVE_METADATA) |
2651 return false; | 2658 return false; |
2652 | 2659 |
2653 // and the current playback position is the end of the media resource and th
e direction | 2660 // and the current playback position is the end of the media resource and th
e direction |
2654 // of playback is forwards, Either the media element does not have a loop at
tribute specified, | 2661 // of playback is forwards, Either the media element does not have a loop at
tribute specified, |
2655 // or the media element has a current media controller. | 2662 // or the media element has a current media controller. |
2656 float now = currentTime(); | 2663 float now = currentTime(); |
2657 if (m_playbackRate > 0) | 2664 if (m_playbackRate > 0) |
2658 return dur > 0 && now >= dur && (!loop() || m_mediaController); | 2665 return dur > 0 && now >= dur && (!loop() || m_mediaController); |
2659 | 2666 |
2660 // or the current playback position is the earliest possible position and th
e direction | 2667 // or the current playback position is the earliest possible position and th
e direction |
2661 // of playback is backwards | 2668 // of playback is backwards |
2662 if (m_playbackRate < 0) | 2669 if (m_playbackRate < 0) |
2663 return now <= 0; | 2670 return now <= 0; |
2664 | 2671 |
2665 return false; | 2672 return false; |
2666 } | 2673 } |
2667 | 2674 |
2668 bool HTMLMediaElement::stoppedDueToErrors() const | 2675 bool HTMLMediaElement::stoppedDueToErrors() const |
2669 { | 2676 { |
2670 if (m_readyState >= HAVE_METADATA && m_error) { | 2677 if (m_readyState >= HAVE_METADATA && m_error) { |
2671 RefPtr<TimeRanges> seekableRanges = seekable(); | 2678 RefPtr<TimeRanges> seekableRanges = seekable(); |
2672 if (!seekableRanges->contain(currentTime())) | 2679 if (!seekableRanges->contain(currentTime())) |
2673 return true; | 2680 return true; |
2674 } | 2681 } |
2675 | 2682 |
2676 return false; | 2683 return false; |
2677 } | 2684 } |
2678 | 2685 |
2679 bool HTMLMediaElement::pausedForUserInteraction() const | 2686 bool HTMLMediaElement::pausedForUserInteraction() const |
2680 { | 2687 { |
2681 // return !paused() && m_readyState >= HAVE_FUTURE_DATA && [UA requires a dec
itions from the user] | 2688 // return !paused() && m_readyState >= HAVE_FUTURE_DATA && [UA requires a dec
itions from the user] |
2682 return false; | 2689 return false; |
2683 } | 2690 } |
2684 | 2691 |
2685 float HTMLMediaElement::minTimeSeekable() const | 2692 float HTMLMediaElement::minTimeSeekable() const |
2686 { | 2693 { |
2687 return 0; | 2694 return 0; |
2688 } | 2695 } |
2689 | 2696 |
2690 float HTMLMediaElement::maxTimeSeekable() const | 2697 float HTMLMediaElement::maxTimeSeekable() const |
2691 { | 2698 { |
2692 return m_player ? m_player->maxTimeSeekable() : 0; | 2699 return m_player ? m_player->maxTimeSeekable() : 0; |
2693 } | 2700 } |
2694 | 2701 |
2695 void HTMLMediaElement::updateVolume() | 2702 void HTMLMediaElement::updateVolume() |
2696 { | 2703 { |
2697 if (!m_player) | 2704 if (!m_player) |
2698 return; | 2705 return; |
2699 | 2706 |
2700 // Avoid recursion when the player reports volume changes. | 2707 // Avoid recursion when the player reports volume changes. |
2701 if (!processingMediaPlayerCallback()) { | 2708 if (!processingMediaPlayerCallback()) { |
2702 Page* page = document()->page(); | 2709 Page* page = document()->page(); |
2703 float volumeMultiplier = page ? page->mediaVolume() : 1; | 2710 float volumeMultiplier = page ? page->mediaVolume() : 1; |
2704 bool shouldMute = m_muted; | 2711 bool shouldMute = m_muted; |
(...skipping 18 matching lines...) Expand all Loading... |
2723 | 2730 |
2724 if (m_pausedInternal) { | 2731 if (m_pausedInternal) { |
2725 if (!m_player->paused()) | 2732 if (!m_player->paused()) |
2726 m_player->pause(); | 2733 m_player->pause(); |
2727 refreshCachedTime(); | 2734 refreshCachedTime(); |
2728 m_playbackProgressTimer.stop(); | 2735 m_playbackProgressTimer.stop(); |
2729 if (hasMediaControls()) | 2736 if (hasMediaControls()) |
2730 mediaControls()->playbackStopped(); | 2737 mediaControls()->playbackStopped(); |
2731 return; | 2738 return; |
2732 } | 2739 } |
2733 | 2740 |
2734 bool shouldBePlaying = potentiallyPlaying(); | 2741 bool shouldBePlaying = potentiallyPlaying(); |
2735 bool playerPaused = m_player->paused(); | 2742 bool playerPaused = m_player->paused(); |
2736 | 2743 |
2737 LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, player
Paused = %s", | 2744 LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, player
Paused = %s", |
2738 boolString(shouldBePlaying), boolString(playerPaused)); | 2745 boolString(shouldBePlaying), boolString(playerPaused)); |
2739 | 2746 |
2740 if (shouldBePlaying) { | 2747 if (shouldBePlaying) { |
2741 setDisplayMode(Video); | 2748 setDisplayMode(Video); |
2742 invalidateCachedTime(); | 2749 invalidateCachedTime(); |
2743 | 2750 |
2744 if (playerPaused) { | 2751 if (playerPaused) { |
2745 if (!m_isFullscreen && isVideo() && document() && document()->page()
&& document()->page()->chrome()->requiresFullscreenForVideoPlayback()) | 2752 if (!m_isFullscreen && isVideo() && document() && document()->page()
&& document()->page()->chrome()->requiresFullscreenForVideoPlayback()) |
2746 enterFullscreen(); | 2753 enterFullscreen(); |
2747 | 2754 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2815 m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED); | 2822 m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED); |
2816 | 2823 |
2817 // 3 - Queue a task to fire a simple event named error at the media element. | 2824 // 3 - Queue a task to fire a simple event named error at the media element. |
2818 scheduleEvent(eventNames().abortEvent); | 2825 scheduleEvent(eventNames().abortEvent); |
2819 | 2826 |
2820 #if ENABLE(MEDIA_SOURCE) | 2827 #if ENABLE(MEDIA_SOURCE) |
2821 if (m_sourceState != SOURCE_CLOSED) | 2828 if (m_sourceState != SOURCE_CLOSED) |
2822 setSourceState(SOURCE_CLOSED); | 2829 setSourceState(SOURCE_CLOSED); |
2823 #endif | 2830 #endif |
2824 | 2831 |
2825 // 4 - If the media element's readyState attribute has a value equal to HAVE
_NOTHING, set the | 2832 // 4 - If the media element's readyState attribute has a value equal to HAVE
_NOTHING, set the |
2826 // element's networkState attribute to the NETWORK_EMPTY value and queue a t
ask to fire a | 2833 // element's networkState attribute to the NETWORK_EMPTY value and queue a t
ask to fire a |
2827 // simple event named emptied at the element. Otherwise, set the element's n
etworkState | 2834 // simple event named emptied at the element. Otherwise, set the element's n
etworkState |
2828 // attribute to the NETWORK_IDLE value. | 2835 // attribute to the NETWORK_IDLE value. |
2829 if (m_readyState == HAVE_NOTHING) { | 2836 if (m_readyState == HAVE_NOTHING) { |
2830 m_networkState = NETWORK_EMPTY; | 2837 m_networkState = NETWORK_EMPTY; |
2831 scheduleEvent(eventNames().emptiedEvent); | 2838 scheduleEvent(eventNames().emptiedEvent); |
2832 } | 2839 } |
2833 else | 2840 else |
2834 m_networkState = NETWORK_IDLE; | 2841 m_networkState = NETWORK_IDLE; |
2835 | 2842 |
2836 // 5 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. | 2843 // 5 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. |
2837 setShouldDelayLoadEvent(false); | 2844 setShouldDelayLoadEvent(false); |
2838 | 2845 |
2839 // 6 - Abort the overall resource selection algorithm. | 2846 // 6 - Abort the overall resource selection algorithm. |
2840 m_currentSourceNode = 0; | 2847 m_currentSourceNode = 0; |
2841 | 2848 |
2842 // Reset m_readyState since m_player is gone. | 2849 // Reset m_readyState since m_player is gone. |
2843 m_readyState = HAVE_NOTHING; | 2850 m_readyState = HAVE_NOTHING; |
2844 updateMediaController(); | 2851 updateMediaController(); |
2845 } | 2852 } |
2846 | 2853 |
2847 bool HTMLMediaElement::canSuspend() const | 2854 bool HTMLMediaElement::canSuspend() const |
2848 { | 2855 { |
2849 return true; | 2856 return true; |
2850 } | 2857 } |
2851 | 2858 |
2852 void HTMLMediaElement::stop() | 2859 void HTMLMediaElement::stop() |
2853 { | 2860 { |
2854 LOG(Media, "HTMLMediaElement::stop"); | 2861 LOG(Media, "HTMLMediaElement::stop"); |
2855 if (m_isFullscreen) | 2862 if (m_isFullscreen) |
2856 exitFullscreen(); | 2863 exitFullscreen(); |
2857 | 2864 |
2858 m_inActiveDocument = false; | 2865 m_inActiveDocument = false; |
2859 userCancelledLoad(); | 2866 userCancelledLoad(); |
2860 | 2867 |
2861 // Stop the playback without generating events | 2868 // Stop the playback without generating events |
2862 setPausedInternal(true); | 2869 setPausedInternal(true); |
2863 | 2870 |
2864 if (renderer()) | 2871 if (renderer()) |
2865 renderer()->updateFromElement(); | 2872 renderer()->updateFromElement(); |
2866 | 2873 |
2867 stopPeriodicTimers(); | 2874 stopPeriodicTimers(); |
2868 cancelPendingEventsAndCallbacks(); | 2875 cancelPendingEventsAndCallbacks(); |
2869 } | 2876 } |
2870 | 2877 |
2871 void HTMLMediaElement::suspend(ReasonForSuspension why) | 2878 void HTMLMediaElement::suspend(ReasonForSuspension why) |
2872 { | 2879 { |
2873 LOG(Media, "HTMLMediaElement::suspend"); | 2880 LOG(Media, "HTMLMediaElement::suspend"); |
2874 | 2881 |
2875 switch (why) | 2882 switch (why) |
2876 { | 2883 { |
2877 case DocumentWillBecomeInactive: | 2884 case DocumentWillBecomeInactive: |
2878 stop(); | 2885 stop(); |
2879 break; | 2886 break; |
2880 case JavaScriptDebuggerPaused: | 2887 case JavaScriptDebuggerPaused: |
2881 case WillShowDialog: | 2888 case WillShowDialog: |
2882 // Do nothing, we don't pause media playback in these cases. | 2889 // Do nothing, we don't pause media playback in these cases. |
2883 break; | 2890 break; |
2884 } | 2891 } |
(...skipping 14 matching lines...) Expand all Loading... |
2899 ExceptionCode ec; | 2906 ExceptionCode ec; |
2900 load(ec); | 2907 load(ec); |
2901 } | 2908 } |
2902 | 2909 |
2903 if (renderer()) | 2910 if (renderer()) |
2904 renderer()->updateFromElement(); | 2911 renderer()->updateFromElement(); |
2905 } | 2912 } |
2906 | 2913 |
2907 bool HTMLMediaElement::hasPendingActivity() const | 2914 bool HTMLMediaElement::hasPendingActivity() const |
2908 { | 2915 { |
2909 // Return true when we have pending events so we can't fire events after the
JS | 2916 // Return true when we have pending events so we can't fire events after the
JS |
2910 // object gets collected. | 2917 // object gets collected. |
2911 bool pending = m_pendingEvents.size(); | 2918 bool pending = m_pendingEvents.size(); |
2912 LOG(Media, "HTMLMediaElement::hasPendingActivity -> %s", boolString(pending)
); | 2919 LOG(Media, "HTMLMediaElement::hasPendingActivity -> %s", boolString(pending)
); |
2913 return pending; | 2920 return pending; |
2914 } | 2921 } |
2915 | 2922 |
2916 void HTMLMediaElement::mediaVolumeDidChange() | 2923 void HTMLMediaElement::mediaVolumeDidChange() |
2917 { | 2924 { |
2918 LOG(Media, "HTMLMediaElement::mediaVolumeDidChange"); | 2925 LOG(Media, "HTMLMediaElement::mediaVolumeDidChange"); |
2919 updateVolume(); | 2926 updateVolume(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3005 if (!frame) | 3012 if (!frame) |
3006 return; | 3013 return; |
3007 | 3014 |
3008 LOG(Media, "HTMLMediaElement::createMediaPlayerProxy"); | 3015 LOG(Media, "HTMLMediaElement::createMediaPlayerProxy"); |
3009 | 3016 |
3010 KURL url; | 3017 KURL url; |
3011 Vector<String> paramNames; | 3018 Vector<String> paramNames; |
3012 Vector<String> paramValues; | 3019 Vector<String> paramValues; |
3013 | 3020 |
3014 getPluginProxyParams(url, paramNames, paramValues); | 3021 getPluginProxyParams(url, paramNames, paramValues); |
3015 | 3022 |
3016 // Hang onto the proxy widget so it won't be destroyed if the plug-in is set
to | 3023 // Hang onto the proxy widget so it won't be destroyed if the plug-in is set
to |
3017 // display:none | 3024 // display:none |
3018 m_proxyWidget = frame->loader()->subframeLoader()->loadMediaPlayerProxyPlugi
n(this, url, paramNames, paramValues); | 3025 m_proxyWidget = frame->loader()->subframeLoader()->loadMediaPlayerProxyPlugi
n(this, url, paramNames, paramValues); |
3019 if (m_proxyWidget) | 3026 if (m_proxyWidget) |
3020 m_needWidgetUpdate = false; | 3027 m_needWidgetUpdate = false; |
3021 } | 3028 } |
3022 | 3029 |
3023 void HTMLMediaElement::updateWidget(PluginCreationOption) | 3030 void HTMLMediaElement::updateWidget(PluginCreationOption) |
3024 { | 3031 { |
3025 mediaElement->setNeedWidgetUpdate(false); | 3032 mediaElement->setNeedWidgetUpdate(false); |
3026 | 3033 |
3027 Vector<String> paramNames; | 3034 Vector<String> paramNames; |
3028 Vector<String> paramValues; | 3035 Vector<String> paramValues; |
3029 // FIXME: Rename kurl to something more sensible. | 3036 // FIXME: Rename kurl to something more sensible. |
3030 KURL kurl; | 3037 KURL kurl; |
3031 | 3038 |
3032 mediaElement->getPluginProxyParams(kurl, paramNames, paramValues); | 3039 mediaElement->getPluginProxyParams(kurl, paramNames, paramValues); |
3033 // FIXME: What if document()->frame() is 0? | 3040 // FIXME: What if document()->frame() is 0? |
3034 SubframeLoader* loader = document()->frame()->loader()->subframeLoader(); | 3041 SubframeLoader* loader = document()->frame()->loader()->subframeLoader(); |
3035 loader->loadMediaPlayerProxyPlugin(mediaElement, kurl, paramNames, paramValu
es); | 3042 loader->loadMediaPlayerProxyPlugin(mediaElement, kurl, paramNames, paramValu
es); |
3036 } | 3043 } |
3037 | 3044 |
3038 #endif // ENABLE(PLUGIN_PROXY_FOR_VIDEO) | 3045 #endif // ENABLE(PLUGIN_PROXY_FOR_VIDEO) |
3039 | 3046 |
3040 bool HTMLMediaElement::isFullscreen() const | 3047 bool HTMLMediaElement::isFullscreen() const |
3041 { | 3048 { |
3042 if (m_isFullscreen) | 3049 if (m_isFullscreen) |
3043 return true; | 3050 return true; |
3044 | 3051 |
3045 #if ENABLE(FULLSCREEN_API) | 3052 #if ENABLE(FULLSCREEN_API) |
3046 if (document()->webkitIsFullScreen() && document()->webkitCurrentFullScreenE
lement() == this) | 3053 if (document()->webkitIsFullScreen() && document()->webkitCurrentFullScreenE
lement() == this) |
3047 return true; | 3054 return true; |
3048 #endif | 3055 #endif |
3049 | 3056 |
3050 return false; | 3057 return false; |
3051 } | 3058 } |
3052 | 3059 |
3053 void HTMLMediaElement::enterFullscreen() | 3060 void HTMLMediaElement::enterFullscreen() |
3054 { | 3061 { |
3055 LOG(Media, "HTMLMediaElement::enterFullscreen"); | 3062 LOG(Media, "HTMLMediaElement::enterFullscreen"); |
3056 | 3063 |
3057 #if ENABLE(FULLSCREEN_API) | 3064 #if ENABLE(FULLSCREEN_API) |
3058 if (document() && document()->settings() && document()->settings()->fullScre
enEnabled()) { | 3065 if (document() && document()->settings() && document()->settings()->fullScre
enEnabled()) { |
3059 document()->requestFullScreenForElement(this, 0, Document::ExemptIFrameA
llowFulScreenRequirement); | 3066 document()->requestFullScreenForElement(this, 0, Document::ExemptIFrameA
llowFulScreenRequirement); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3192 return; | 3199 return; |
3193 | 3200 |
3194 LOG(Media, "HTMLMediaElement::setShouldDelayLoadEvent(%s)", boolString(shoul
dDelay)); | 3201 LOG(Media, "HTMLMediaElement::setShouldDelayLoadEvent(%s)", boolString(shoul
dDelay)); |
3195 | 3202 |
3196 m_shouldDelayLoadEvent = shouldDelay; | 3203 m_shouldDelayLoadEvent = shouldDelay; |
3197 if (shouldDelay) | 3204 if (shouldDelay) |
3198 document()->incrementLoadEventDelayCount(); | 3205 document()->incrementLoadEventDelayCount(); |
3199 else | 3206 else |
3200 document()->decrementLoadEventDelayCount(); | 3207 document()->decrementLoadEventDelayCount(); |
3201 } | 3208 } |
3202 | 3209 |
3203 | 3210 |
3204 void HTMLMediaElement::getSitesInMediaCache(Vector<String>& sites) | 3211 void HTMLMediaElement::getSitesInMediaCache(Vector<String>& sites) |
3205 { | 3212 { |
3206 MediaPlayer::getSitesInMediaCache(sites); | 3213 MediaPlayer::getSitesInMediaCache(sites); |
3207 } | 3214 } |
3208 | 3215 |
3209 void HTMLMediaElement::clearMediaCache() | 3216 void HTMLMediaElement::clearMediaCache() |
3210 { | 3217 { |
3211 MediaPlayer::clearMediaCache(); | 3218 MediaPlayer::clearMediaCache(); |
3212 } | 3219 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3283 | 3290 |
3284 return 0; | 3291 return 0; |
3285 } | 3292 } |
3286 | 3293 |
3287 void HTMLMediaElement::createMediaPlayer() | 3294 void HTMLMediaElement::createMediaPlayer() |
3288 { | 3295 { |
3289 #if ENABLE(WEB_AUDIO) | 3296 #if ENABLE(WEB_AUDIO) |
3290 if (m_audioSourceNode) | 3297 if (m_audioSourceNode) |
3291 m_audioSourceNode->lock(); | 3298 m_audioSourceNode->lock(); |
3292 #endif | 3299 #endif |
3293 | 3300 |
3294 m_player = MediaPlayer::create(this); | 3301 m_player = MediaPlayer::create(this); |
3295 | 3302 |
3296 #if ENABLE(WEB_AUDIO) | 3303 #if ENABLE(WEB_AUDIO) |
3297 if (m_audioSourceNode) { | 3304 if (m_audioSourceNode) { |
3298 // When creating the player, make sure its AudioSourceProvider knows abo
ut the MediaElementAudioSourceNode. | 3305 // When creating the player, make sure its AudioSourceProvider knows abo
ut the MediaElementAudioSourceNode. |
3299 if (audioSourceProvider()) | 3306 if (audioSourceProvider()) |
3300 audioSourceProvider()->setClient(m_audioSourceNode); | 3307 audioSourceProvider()->setClient(m_audioSourceNode); |
3301 | 3308 |
3302 m_audioSourceNode->unlock(); | 3309 m_audioSourceNode->unlock(); |
3303 } | 3310 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3338 { | 3345 { |
3339 return m_mediaGroup; | 3346 return m_mediaGroup; |
3340 } | 3347 } |
3341 | 3348 |
3342 void HTMLMediaElement::setMediaGroup(const String& group) | 3349 void HTMLMediaElement::setMediaGroup(const String& group) |
3343 { | 3350 { |
3344 if (m_mediaGroup == group) | 3351 if (m_mediaGroup == group) |
3345 return; | 3352 return; |
3346 m_mediaGroup = group; | 3353 m_mediaGroup = group; |
3347 | 3354 |
3348 // When a media element is created with a mediagroup attribute, and when a m
edia element's mediagroup | 3355 // When a media element is created with a mediagroup attribute, and when a m
edia element's mediagroup |
3349 // attribute is set, changed, or removed, the user agent must run the follow
ing steps: | 3356 // attribute is set, changed, or removed, the user agent must run the follow
ing steps: |
3350 // 1. Let m [this] be the media element in question. | 3357 // 1. Let m [this] be the media element in question. |
3351 // 2. Let m have no current media controller, if it currently has one. | 3358 // 2. Let m have no current media controller, if it currently has one. |
3352 setController(0); | 3359 setController(0); |
3353 | 3360 |
3354 // 3. If m's mediagroup attribute is being removed, then abort these steps. | 3361 // 3. If m's mediagroup attribute is being removed, then abort these steps. |
3355 if (group.isNull() || group.isEmpty()) | 3362 if (group.isNull() || group.isEmpty()) |
3356 return; | 3363 return; |
3357 | 3364 |
3358 // 4. If there is another media element whose Document is the same as m's Do
cument (even if one or both | 3365 // 4. If there is another media element whose Document is the same as m's Do
cument (even if one or both |
3359 // of these elements are not actually in the Document), | 3366 // of these elements are not actually in the Document), |
3360 HashSet<HTMLMediaElement*> elements = documentToElementSetMap().get(document
()); | 3367 HashSet<HTMLMediaElement*> elements = documentToElementSetMap().get(document
()); |
3361 for (HashSet<HTMLMediaElement*>::iterator i = elements.begin(); i != element
s.end(); ++i) { | 3368 for (HashSet<HTMLMediaElement*>::iterator i = elements.begin(); i != element
s.end(); ++i) { |
3362 if (*i == this) | 3369 if (*i == this) |
3363 continue; | 3370 continue; |
3364 | 3371 |
3365 // and which also has a mediagroup attribute, and whose mediagroup attri
bute has the same value as | 3372 // and which also has a mediagroup attribute, and whose mediagroup attri
bute has the same value as |
3366 // the new value of m's mediagroup attribute, | 3373 // the new value of m's mediagroup attribute, |
3367 if ((*i)->mediaGroup() == group) { | 3374 if ((*i)->mediaGroup() == group) { |
3368 // then let controller be that media element's current media contro
ller. | 3375 // then let controller be that media element's current media contro
ller. |
3369 setController((*i)->controller()); | 3376 setController((*i)->controller()); |
3370 return; | 3377 return; |
3371 } | 3378 } |
3372 } | 3379 } |
3373 | 3380 |
3374 // Otherwise, let controller be a newly created MediaController. | 3381 // Otherwise, let controller be a newly created MediaController. |
3375 setController(MediaController::create(Node::scriptExecutionContext())); | 3382 setController(MediaController::create(Node::scriptExecutionContext())); |
3376 } | 3383 } |
(...skipping 29 matching lines...) Expand all Loading... |
3406 | 3413 |
3407 // or if the element has paused for user interaction. | 3414 // or if the element has paused for user interaction. |
3408 return pausedForUserInteraction(); | 3415 return pausedForUserInteraction(); |
3409 } | 3416 } |
3410 | 3417 |
3411 bool HTMLMediaElement::isBlockedOnMediaController() const | 3418 bool HTMLMediaElement::isBlockedOnMediaController() const |
3412 { | 3419 { |
3413 if (!m_mediaController) | 3420 if (!m_mediaController) |
3414 return false; | 3421 return false; |
3415 | 3422 |
3416 // A media element is blocked on its media controller if the MediaController
is a blocked | 3423 // A media element is blocked on its media controller if the MediaController
is a blocked |
3417 // media controller, | 3424 // media controller, |
3418 if (m_mediaController->isBlocked()) | 3425 if (m_mediaController->isBlocked()) |
3419 return true; | 3426 return true; |
3420 | 3427 |
3421 // or if its media controller position is either before the media resource's
earliest possible | 3428 // or if its media controller position is either before the media resource's
earliest possible |
3422 // position relative to the MediaController's timeline or after the end of t
he media resource | 3429 // position relative to the MediaController's timeline or after the end of t
he media resource |
3423 // relative to the MediaController's timeline. | 3430 // relative to the MediaController's timeline. |
3424 float mediaControllerPosition = m_mediaController->currentTime(); | 3431 float mediaControllerPosition = m_mediaController->currentTime(); |
3425 if (mediaControllerPosition < startTime() || mediaControllerPosition > start
Time() + duration()) | 3432 if (mediaControllerPosition < startTime() || mediaControllerPosition > start
Time() + duration()) |
3426 return true; | 3433 return true; |
3427 | 3434 |
3428 return false; | 3435 return false; |
3429 } | 3436 } |
3430 | 3437 |
3431 } | 3438 } |
3432 | 3439 |
3433 #endif | 3440 #endif |
OLD | NEW |