OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 , m_playing(false) | 325 , m_playing(false) |
326 , m_shouldDelayLoadEvent(false) | 326 , m_shouldDelayLoadEvent(false) |
327 , m_haveFiredLoadedData(false) | 327 , m_haveFiredLoadedData(false) |
328 , m_autoplaying(true) | 328 , m_autoplaying(true) |
329 , m_muted(false) | 329 , m_muted(false) |
330 , m_paused(true) | 330 , m_paused(true) |
331 , m_seeking(false) | 331 , m_seeking(false) |
332 , m_sentStalledEvent(false) | 332 , m_sentStalledEvent(false) |
333 , m_sentEndEvent(false) | 333 , m_sentEndEvent(false) |
334 , m_closedCaptionsVisible(false) | 334 , m_closedCaptionsVisible(false) |
335 , m_havePreparedToPlay(false) | 335 , m_forceEffectivePreloadAuto(false) |
336 , m_tracksAreReady(true) | 336 , m_tracksAreReady(true) |
337 , m_processingPreferenceChange(false) | 337 , m_processingPreferenceChange(false) |
338 , m_remoteRoutesAvailable(false) | 338 , m_remoteRoutesAvailable(false) |
339 , m_playingRemotely(false) | 339 , m_playingRemotely(false) |
340 , m_isFinalizing(false) | 340 , m_isFinalizing(false) |
341 , m_initialPlayWithoutUserGesture(false) | 341 , m_initialPlayWithoutUserGesture(false) |
342 , m_autoplayMediaCounted(false) | 342 , m_autoplayMediaCounted(false) |
343 , m_inOverlayFullscreenVideo(false) | 343 , m_inOverlayFullscreenVideo(false) |
344 , m_audioTracks(AudioTrackList::create(*this)) | 344 , m_audioTracks(AudioTrackList::create(*this)) |
345 , m_videoTracks(VideoTrackList::create(*this)) | 345 , m_videoTracks(VideoTrackList::create(*this)) |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 | 464 |
465 removeElementFromDocumentMap(this, &oldDocument); | 465 removeElementFromDocumentMap(this, &oldDocument); |
466 addElementToDocumentMap(this, &document()); | 466 addElementToDocumentMap(this, &document()); |
467 | 467 |
468 // FIXME: This is a temporary fix to prevent this object from causing the | 468 // FIXME: This is a temporary fix to prevent this object from causing the |
469 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the | 469 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the |
470 // previous document. This restarts the load, as if the src attribute had be en set. | 470 // previous document. This restarts the load, as if the src attribute had be en set. |
471 // A proper fix would provide a mechanism to allow this object to refresh | 471 // A proper fix would provide a mechanism to allow this object to refresh |
472 // the MediaPlayer's LocalFrame and FrameLoader references on | 472 // the MediaPlayer's LocalFrame and FrameLoader references on |
473 // document changes so that playback can be resumed properly. | 473 // document changes so that playback can be resumed properly. |
474 clearMediaPlayer(LoadMediaResource); | 474 invokeLoadAlgorithm(); |
475 scheduleDelayedAction(LoadMediaResource); | |
476 | 475 |
477 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed | 476 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed |
478 // and there is no risk of dispatching a load event from within the destruct or. | 477 // and there is no risk of dispatching a load event from within the destruct or. |
479 oldDocument.decrementLoadEventDelayCount(); | 478 oldDocument.decrementLoadEventDelayCount(); |
480 | 479 |
481 ActiveDOMObject::didMoveToNewExecutionContext(&document()); | 480 ActiveDOMObject::didMoveToNewExecutionContext(&document()); |
482 HTMLElement::didMoveToNewDocument(oldDocument); | 481 HTMLElement::didMoveToNewDocument(oldDocument); |
483 } | 482 } |
484 | 483 |
485 bool HTMLMediaElement::supportsFocus() const | 484 bool HTMLMediaElement::supportsFocus() const |
486 { | 485 { |
487 if (ownerDocument()->isMediaDocument()) | 486 if (ownerDocument()->isMediaDocument()) |
488 return false; | 487 return false; |
489 | 488 |
490 // If no controls specified, we should still be able to focus the element if it has tabIndex. | 489 // If no controls specified, we should still be able to focus the element if it has tabIndex. |
491 return shouldShowControls() || HTMLElement::supportsFocus(); | 490 return shouldShowControls() || HTMLElement::supportsFocus(); |
492 } | 491 } |
493 | 492 |
494 bool HTMLMediaElement::isMouseFocusable() const | 493 bool HTMLMediaElement::isMouseFocusable() const |
495 { | 494 { |
496 return false; | 495 return false; |
497 } | 496 } |
498 | 497 |
499 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& oldValue, const AtomicString& value) | 498 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& oldValue, const AtomicString& value) |
500 { | 499 { |
501 if (name == srcAttr) { | 500 if (name == srcAttr) { |
502 // Trigger a reload, as long as the 'src' attribute is present. | 501 // Trigger a reload, as long as the 'src' attribute is present. |
503 if (!value.isNull()) { | 502 if (!value.isNull()) { |
504 clearMediaPlayer(LoadMediaResource); | 503 invokeLoadAlgorithm(); |
505 scheduleDelayedAction(LoadMediaResource); | |
506 } | 504 } |
507 } else if (name == controlsAttr) { | 505 } else if (name == controlsAttr) { |
508 UseCounter::count(document(), UseCounter::HTMLMediaElementControlsAttrib ute); | 506 UseCounter::count(document(), UseCounter::HTMLMediaElementControlsAttrib ute); |
509 configureMediaControls(); | 507 configureMediaControls(); |
510 } else if (name == preloadAttr) { | 508 } else if (name == preloadAttr) { |
511 setPlayerPreload(); | 509 setPlayerPreload(); |
512 } else if (name == disableremoteplaybackAttr) { | 510 } else if (name == disableremoteplaybackAttr) { |
513 UseCounter::count(document(), UseCounter::DisableRemotePlaybackAttribute ); | 511 UseCounter::count(document(), UseCounter::DisableRemotePlaybackAttribute ); |
514 } else { | 512 } else { |
515 HTMLElement::parseAttribute(name, oldValue, value); | 513 HTMLElement::parseAttribute(name, oldValue, value); |
516 } | 514 } |
517 } | 515 } |
518 | 516 |
519 void HTMLMediaElement::finishParsingChildren() | 517 void HTMLMediaElement::finishParsingChildren() |
520 { | 518 { |
521 HTMLElement::finishParsingChildren(); | 519 HTMLElement::finishParsingChildren(); |
522 | 520 |
523 if (Traversal<HTMLTrackElement>::firstChild(*this)) | 521 if (Traversal<HTMLTrackElement>::firstChild(*this)) |
524 scheduleDelayedAction(LoadTextTrackResource); | 522 scheduleTextTrackResourceLoad(); |
525 } | 523 } |
526 | 524 |
527 bool HTMLMediaElement::layoutObjectIsNeeded(const ComputedStyle& style) | 525 bool HTMLMediaElement::layoutObjectIsNeeded(const ComputedStyle& style) |
528 { | 526 { |
529 return shouldShowControls() && HTMLElement::layoutObjectIsNeeded(style); | 527 return shouldShowControls() && HTMLElement::layoutObjectIsNeeded(style); |
530 } | 528 } |
531 | 529 |
532 LayoutObject* HTMLMediaElement::createLayoutObject(const ComputedStyle&) | 530 LayoutObject* HTMLMediaElement::createLayoutObject(const ComputedStyle&) |
533 { | 531 { |
534 return new LayoutMedia(this); | 532 return new LayoutMedia(this); |
535 } | 533 } |
536 | 534 |
537 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint) | 535 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint) |
538 { | 536 { |
539 WTF_LOG(Media, "HTMLMediaElement::insertedInto(%p, %p)", this, insertionPoin t); | 537 WTF_LOG(Media, "HTMLMediaElement::insertedInto(%p, %p)", this, insertionPoin t); |
540 | 538 |
541 HTMLElement::insertedInto(insertionPoint); | 539 HTMLElement::insertedInto(insertionPoint); |
542 if (insertionPoint->inDocument()) { | 540 if (insertionPoint->inDocument()) { |
543 UseCounter::count(document(), UseCounter::HTMLMediaElementInDocument); | 541 UseCounter::count(document(), UseCounter::HTMLMediaElementInDocument); |
544 if (!getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY) | 542 if (!getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY) |
545 scheduleDelayedAction(LoadMediaResource); | 543 invokeLoadAlgorithm(); |
546 } | 544 } |
547 | 545 |
548 return InsertionShouldCallDidNotifySubtreeInsertions; | 546 return InsertionShouldCallDidNotifySubtreeInsertions; |
549 } | 547 } |
550 | 548 |
551 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() | 549 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() |
552 { | 550 { |
553 configureMediaControls(); | 551 configureMediaControls(); |
554 } | 552 } |
555 | 553 |
(...skipping 16 matching lines...) Expand all Loading... | |
572 if (layoutObject()) | 570 if (layoutObject()) |
573 layoutObject()->updateFromElement(); | 571 layoutObject()->updateFromElement(); |
574 } | 572 } |
575 | 573 |
576 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) | 574 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) |
577 { | 575 { |
578 if (layoutObject()) | 576 if (layoutObject()) |
579 layoutObject()->updateFromElement(); | 577 layoutObject()->updateFromElement(); |
580 } | 578 } |
581 | 579 |
582 void HTMLMediaElement::scheduleDelayedAction(DelayedActionType actionType) | 580 void HTMLMediaElement::scheduleTextTrackResourceLoad() |
583 { | 581 { |
584 WTF_LOG(Media, "HTMLMediaElement::scheduleDelayedAction(%p)", this); | 582 WTF_LOG(Media, "HTMLMediaElement::scheduleTextTrackResourceLoad(%p)", this); |
585 | 583 |
586 if ((actionType & LoadMediaResource) && !(m_pendingActionFlags & LoadMediaRe source)) { | 584 m_pendingActionFlags |= LoadTextTrackResource; |
587 prepareForLoad(); | |
588 m_pendingActionFlags |= LoadMediaResource; | |
589 } | |
590 | |
591 if (actionType & LoadTextTrackResource) | |
592 m_pendingActionFlags |= LoadTextTrackResource; | |
593 | 585 |
594 if (!m_loadTimer.isActive()) | 586 if (!m_loadTimer.isActive()) |
595 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | 587 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); |
596 } | 588 } |
597 | 589 |
598 void HTMLMediaElement::scheduleNextSourceChild() | 590 void HTMLMediaElement::scheduleNextSourceChild() |
599 { | 591 { |
600 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala prepareForLoad. | 592 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala prepareForLoad. |
601 m_pendingActionFlags |= LoadMediaResource; | 593 m_pendingActionFlags |= LoadMediaResource; |
602 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | 594 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
703 | 695 |
704 if (UserGestureIndicator::processingUserGesture() && m_userGestureRequiredFo rPlay) { | 696 if (UserGestureIndicator::processingUserGesture() && m_userGestureRequiredFo rPlay) { |
705 recordAutoplayMetric(AutoplayEnabledThroughLoad); | 697 recordAutoplayMetric(AutoplayEnabledThroughLoad); |
706 m_userGestureRequiredForPlay = false; | 698 m_userGestureRequiredForPlay = false; |
707 // While usergesture-initiated load()s technically count as autoplayed, | 699 // While usergesture-initiated load()s technically count as autoplayed, |
708 // they don't feel like such to the users and hence we don't want to | 700 // they don't feel like such to the users and hence we don't want to |
709 // count them for the purposes of metrics. | 701 // count them for the purposes of metrics. |
710 m_autoplayMediaCounted = true; | 702 m_autoplayMediaCounted = true; |
711 } | 703 } |
712 | 704 |
705 m_forceEffectivePreloadAuto = true; | |
706 invokeLoadAlgorithm(); | |
707 } | |
708 | |
709 void HTMLMediaElement::invokeLoadAlgorithm() | |
710 { | |
711 WTF_LOG(Media, "HTMLMediaElement::invokeLoadAlgorithm(%p)", this); | |
712 | |
713 prepareForLoad(); | 713 prepareForLoad(); |
714 loadInternal(); | 714 scheduleNextSourceChild(); |
715 prepareToPlay(); | |
716 } | 715 } |
717 | 716 |
718 void HTMLMediaElement::prepareForLoad() | 717 void HTMLMediaElement::prepareForLoad() |
719 { | 718 { |
720 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad(%p)", this); | 719 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad(%p)", this); |
721 | 720 |
722 // Perform the cleanup required for the resource load algorithm to run. | 721 // Perform the cleanup required for the resource load algorithm to run. |
723 stopPeriodicTimers(); | 722 stopPeriodicTimers(); |
724 m_loadTimer.stop(); | 723 m_loadTimer.stop(); |
725 cancelDeferredLoad(); | 724 cancelDeferredLoad(); |
726 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. | 725 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. |
727 m_pendingActionFlags &= ~LoadMediaResource; | 726 m_pendingActionFlags &= ~LoadMediaResource; |
728 m_sentEndEvent = false; | 727 m_sentEndEvent = false; |
729 m_sentStalledEvent = false; | 728 m_sentStalledEvent = false; |
730 m_haveFiredLoadedData = false; | 729 m_haveFiredLoadedData = false; |
731 m_havePreparedToPlay = false; | |
philipj_slow
2016/03/11 12:52:41
Actually, the renamed state bit should also be res
Srirama
2016/03/11 14:58:20
Done.
| |
732 m_displayMode = Unknown; | 730 m_displayMode = Unknown; |
733 | 731 |
734 // 1 - Abort any already-running instance of the resource selection algorith m for this element. | 732 // 1 - Abort any already-running instance of the resource selection algorith m for this element. |
735 m_loadState = WaitingForSource; | 733 m_loadState = WaitingForSource; |
736 m_currentSourceNode = nullptr; | 734 m_currentSourceNode = nullptr; |
737 | 735 |
738 // 2 - If there are any tasks from the media element's media element event t ask source in | 736 // 2 - If there are any tasks from the media element's media element event t ask source in |
739 // one of the task queues, then remove those tasks. | 737 // one of the task queues, then remove those tasks. |
740 cancelPendingEventsAndCallbacks(); | 738 cancelPendingEventsAndCallbacks(); |
741 | 739 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
785 } | 783 } |
786 | 784 |
787 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute. | 785 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute. |
788 setPlaybackRate(defaultPlaybackRate()); | 786 setPlaybackRate(defaultPlaybackRate()); |
789 | 787 |
790 // 6 - Set the error attribute to null and the autoplaying flag to true. | 788 // 6 - Set the error attribute to null and the autoplaying flag to true. |
791 m_error = nullptr; | 789 m_error = nullptr; |
792 m_autoplaying = true; | 790 m_autoplaying = true; |
793 | 791 |
794 // 7 - Invoke the media element's resource selection algorithm. | 792 // 7 - Invoke the media element's resource selection algorithm. |
793 invokeResourceSelectionAlgorithm(); | |
795 | 794 |
796 // 8 - Note: Playback of any previously playing media resource for this elem ent stops. | 795 // 8 - Note: Playback of any previously playing media resource for this elem ent stops. |
796 } | |
797 | 797 |
798 void HTMLMediaElement::invokeResourceSelectionAlgorithm() | |
799 { | |
800 WTF_LOG(Media, "HTMLMediaElement::invokeResourceSelectionAlgorithm(%p)", thi s); | |
798 // The resource selection algorithm | 801 // The resource selection algorithm |
799 // 1 - Set the networkState to NETWORK_NO_SOURCE | 802 // 1 - Set the networkState to NETWORK_NO_SOURCE |
800 setNetworkState(NETWORK_NO_SOURCE); | 803 setNetworkState(NETWORK_NO_SOURCE); |
801 | 804 |
802 // 2 - Asynchronously await a stable state. | 805 // 2 - Set the element's show poster flag to true |
806 // TODO(srirama.m): Introduce show poster flag and update it as per spec | |
803 | 807 |
804 m_playedTimeRanges = TimeRanges::create(); | 808 m_playedTimeRanges = TimeRanges::create(); |
805 | 809 |
806 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above | 810 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above |
807 // so they are closer to the relevant spec steps. | 811 // so they are closer to the relevant spec steps. |
808 m_lastSeekTime = 0; | 812 m_lastSeekTime = 0; |
809 m_duration = std::numeric_limits<double>::quiet_NaN(); | 813 m_duration = std::numeric_limits<double>::quiet_NaN(); |
810 | 814 |
811 // The spec doesn't say to block the load event until we actually run the as ynchronous section | 815 // 3 - Set the media element's delaying-the-load-event flag to true (this de lays the load event) |
812 // algorithm, but do it now because we won't start that until after the time r fires and the | |
813 // event may have already fired by then. | |
814 setShouldDelayLoadEvent(true); | 816 setShouldDelayLoadEvent(true); |
815 if (mediaControls()) | 817 if (mediaControls()) |
816 mediaControls()->reset(); | 818 mediaControls()->reset(); |
819 | |
820 // 4 - Await a stable state, allowing the task that invoked this algorithm t o continue | |
821 // TODO(srirama.m): Schedule an async continuation of this algorithm as per the spec | |
817 } | 822 } |
818 | 823 |
819 void HTMLMediaElement::loadInternal() | 824 void HTMLMediaElement::loadInternal() |
820 { | 825 { |
821 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the | 826 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the |
822 // disabled state when the element's resource selection algorithm last start ed". | 827 // disabled state when the element's resource selection algorithm last start ed". |
823 m_textTracksWhenResourceSelectionBegan.clear(); | 828 m_textTracksWhenResourceSelectionBegan.clear(); |
824 if (m_textTracks) { | 829 if (m_textTracks) { |
825 for (unsigned i = 0; i < m_textTracks->length(); ++i) { | 830 for (unsigned i = 0; i < m_textTracks->length(); ++i) { |
826 TextTrack* track = m_textTracks->anonymousIndexedGetter(i); | 831 TextTrack* track = m_textTracks->anonymousIndexedGetter(i); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
969 m_mediaSource = nullptr; | 974 m_mediaSource = nullptr; |
970 attemptLoad = false; | 975 attemptLoad = false; |
971 } | 976 } |
972 } | 977 } |
973 } | 978 } |
974 } | 979 } |
975 | 980 |
976 if (attemptLoad && canLoadURL(url, contentType)) { | 981 if (attemptLoad && canLoadURL(url, contentType)) { |
977 ASSERT(!webMediaPlayer()); | 982 ASSERT(!webMediaPlayer()); |
978 | 983 |
979 if (!m_havePreparedToPlay && effectivePreloadType() == WebMediaPlayer::P reloadNone) { | 984 if (effectivePreloadType() == WebMediaPlayer::PreloadNone) { |
980 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this); | 985 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this); |
981 deferLoad(); | 986 deferLoad(); |
982 } else { | 987 } else { |
983 startPlayerLoad(); | 988 startPlayerLoad(); |
984 } | 989 } |
985 } else { | 990 } else { |
986 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 991 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
987 } | 992 } |
988 | 993 |
989 // If there is no poster to display, allow the media engine to render video frames as soon as | 994 // If there is no poster to display, allow the media engine to render video frames as soon as |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1047 // This handles any transition to or from fullscreen overlay mode. | 1052 // This handles any transition to or from fullscreen overlay mode. |
1048 frame->chromeClient().enterFullScreenForElement(this); | 1053 frame->chromeClient().enterFullScreenForElement(this); |
1049 } | 1054 } |
1050 } | 1055 } |
1051 | 1056 |
1052 void HTMLMediaElement::setPlayerPreload() | 1057 void HTMLMediaElement::setPlayerPreload() |
1053 { | 1058 { |
1054 if (m_webMediaPlayer) | 1059 if (m_webMediaPlayer) |
1055 m_webMediaPlayer->setPreload(effectivePreloadType()); | 1060 m_webMediaPlayer->setPreload(effectivePreloadType()); |
1056 | 1061 |
1057 if (loadIsDeferred() && preloadType() != WebMediaPlayer::PreloadNone) | 1062 if (loadIsDeferred() && effectivePreloadType() != WebMediaPlayer::PreloadNon e) |
1058 startDeferredLoad(); | 1063 startDeferredLoad(); |
1059 } | 1064 } |
1060 | 1065 |
1061 bool HTMLMediaElement::loadIsDeferred() const | 1066 bool HTMLMediaElement::loadIsDeferred() const |
1062 { | 1067 { |
1063 return m_deferredLoadState != NotDeferred; | 1068 return m_deferredLoadState != NotDeferred; |
1064 } | 1069 } |
1065 | 1070 |
1066 void HTMLMediaElement::deferLoad() | 1071 void HTMLMediaElement::deferLoad() |
1067 { | 1072 { |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1600 if (!m_playedTimeRanges) | 1605 if (!m_playedTimeRanges) |
1601 m_playedTimeRanges = TimeRanges::create(); | 1606 m_playedTimeRanges = TimeRanges::create(); |
1602 m_playedTimeRanges->add(start, end); | 1607 m_playedTimeRanges->add(start, end); |
1603 } | 1608 } |
1604 | 1609 |
1605 bool HTMLMediaElement::supportsSave() const | 1610 bool HTMLMediaElement::supportsSave() const |
1606 { | 1611 { |
1607 return webMediaPlayer() && webMediaPlayer()->supportsSave(); | 1612 return webMediaPlayer() && webMediaPlayer()->supportsSave(); |
1608 } | 1613 } |
1609 | 1614 |
1610 void HTMLMediaElement::prepareToPlay() | 1615 void HTMLMediaElement::prepareToPlay() |
philipj_slow
2016/03/11 12:52:41
This isn't only in preparation to play, but what w
Srirama
2016/03/11 14:58:20
I will go with setIgnorePreloadNone.
| |
1611 { | 1616 { |
1612 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); | 1617 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); |
1613 if (m_havePreparedToPlay) | 1618 m_forceEffectivePreloadAuto = true; |
1614 return; | 1619 setPlayerPreload(); |
1615 m_havePreparedToPlay = true; | |
1616 | |
1617 if (loadIsDeferred()) | |
1618 startDeferredLoad(); | |
1619 } | 1620 } |
1620 | 1621 |
1621 void HTMLMediaElement::seek(double time) | 1622 void HTMLMediaElement::seek(double time) |
1622 { | 1623 { |
1623 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); | 1624 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); |
1624 | 1625 |
1625 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. | 1626 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. |
1626 if (m_readyState == HAVE_NOTHING) | 1627 if (m_readyState == HAVE_NOTHING) |
1627 return; | 1628 return; |
1628 | 1629 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1937 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28950 | 1938 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28950 |
1938 | 1939 |
1939 // TODO(philipj): Try to make "metadata" the default preload state: | 1940 // TODO(philipj): Try to make "metadata" the default preload state: |
1940 // https://crbug.com/310450 | 1941 // https://crbug.com/310450 |
1941 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault); | 1942 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault); |
1942 return WebMediaPlayer::PreloadAuto; | 1943 return WebMediaPlayer::PreloadAuto; |
1943 } | 1944 } |
1944 | 1945 |
1945 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const | 1946 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const |
1946 { | 1947 { |
1947 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType(); | 1948 if (autoplay()) |
1949 return WebMediaPlayer::PreloadAuto; | |
1950 | |
1951 WebMediaPlayer::Preload preload = preloadType(); | |
1952 if (m_forceEffectivePreloadAuto && preload == WebMediaPlayer::PreloadNone) | |
philipj_slow
2016/03/11 12:52:41
Looking at https://www.w3.org/Bugs/Public/show_bug
Srirama
2016/03/11 14:58:20
You mean *"Maybe add effectivePreload"? I will try
philipj_slow
2016/03/11 18:57:37
Yes, right. The tests could simply verify that loa
| |
1953 return WebMediaPlayer::PreloadAuto; | |
1954 | |
1955 return preload; | |
1948 } | 1956 } |
1949 | 1957 |
1950 ScriptPromise HTMLMediaElement::playForBindings(ScriptState* scriptState) | 1958 ScriptPromise HTMLMediaElement::playForBindings(ScriptState* scriptState) |
1951 { | 1959 { |
1952 Nullable<ExceptionCode> code = play(); | 1960 Nullable<ExceptionCode> code = play(); |
1953 if (!code.isNull()) { | 1961 if (!code.isNull()) { |
1954 String message; | 1962 String message; |
1955 switch (code.get()) { | 1963 switch (code.get()) { |
1956 case NotAllowedError: | 1964 case NotAllowedError: |
1957 message = "play() can only be initiated by a user gesture."; | 1965 message = "play() can only be initiated by a user gesture."; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2008 { | 2016 { |
2009 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); | 2017 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); |
2010 | 2018 |
2011 // Always return the buffering strategy to normal when not paused, | 2019 // Always return the buffering strategy to normal when not paused, |
2012 // regardless of the cause. (In contrast with aggressive buffering which is | 2020 // regardless of the cause. (In contrast with aggressive buffering which is |
2013 // only enabled by pause(), not pauseInternal().) | 2021 // only enabled by pause(), not pauseInternal().) |
2014 if (webMediaPlayer()) | 2022 if (webMediaPlayer()) |
2015 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal); | 2023 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal); |
2016 | 2024 |
2017 // 4.8.10.9. Playing the media resource | 2025 // 4.8.10.9. Playing the media resource |
2018 if (m_networkState == NETWORK_EMPTY) | 2026 if (m_networkState == NETWORK_EMPTY) { |
2019 scheduleDelayedAction(LoadMediaResource); | 2027 // TODO(srirama.m): Remove scheduleNextSourceChild() here and |
2028 // post a micro task inside invokeResourceSelectionAlgorithm(). | |
2029 // See http://crbug.com/593289 for more details. | |
2030 invokeResourceSelectionAlgorithm(); | |
2031 scheduleNextSourceChild(); | |
2032 } | |
2020 | 2033 |
2021 // Generally "ended" and "looping" are exclusive. Here, the loop attribute | 2034 // Generally "ended" and "looping" are exclusive. Here, the loop attribute |
2022 // is ignored to seek back to start in case loop was set after playback | 2035 // is ignored to seek back to start in case loop was set after playback |
2023 // ended. See http://crbug.com/364442 | 2036 // ended. See http://crbug.com/364442 |
2024 if (endedPlayback(LoopCondition::Ignored)) | 2037 if (endedPlayback(LoopCondition::Ignored)) |
2025 seek(0); | 2038 seek(0); |
2026 | 2039 |
2027 if (m_paused) { | 2040 if (m_paused) { |
2028 m_paused = false; | 2041 m_paused = false; |
2029 invalidateCachedTime(); | 2042 invalidateCachedTime(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2071 if (webMediaPlayer() && UserGestureIndicator::processingUserGesture()) | 2084 if (webMediaPlayer() && UserGestureIndicator::processingUserGesture()) |
2072 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Aggressive); | 2085 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Aggressive); |
2073 | 2086 |
2074 pauseInternal(); | 2087 pauseInternal(); |
2075 } | 2088 } |
2076 | 2089 |
2077 void HTMLMediaElement::pauseInternal() | 2090 void HTMLMediaElement::pauseInternal() |
2078 { | 2091 { |
2079 WTF_LOG(Media, "HTMLMediaElement::pauseInternal(%p)", this); | 2092 WTF_LOG(Media, "HTMLMediaElement::pauseInternal(%p)", this); |
2080 | 2093 |
2081 if (m_networkState == NETWORK_EMPTY) | 2094 if (m_networkState == NETWORK_EMPTY) { |
2082 scheduleDelayedAction(LoadMediaResource); | 2095 // TODO(srirama.m): Remove scheduleNextSourceChild() here and |
2096 // post a micro task inside invokeResourceSelectionAlgorithm(). | |
2097 // See http://crbug.com/593289 for more details. | |
2098 invokeResourceSelectionAlgorithm(); | |
2099 scheduleNextSourceChild(); | |
2100 } | |
2083 | 2101 |
2084 m_autoplayHelper.pauseMethodCalled(); | 2102 m_autoplayHelper.pauseMethodCalled(); |
2085 | 2103 |
2086 m_autoplaying = false; | 2104 m_autoplaying = false; |
2087 | 2105 |
2088 if (!m_paused) { | 2106 if (!m_paused) { |
2089 recordMetricsIfPausing(); | 2107 recordMetricsIfPausing(); |
2090 | 2108 |
2091 m_paused = true; | 2109 m_paused = true; |
2092 scheduleTimeupdateEvent(false); | 2110 scheduleTimeupdateEvent(false); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2408 // 5. Populate the new text track's list of cues with the cues parsed so far , folllowing the guidelines for exposing | 2426 // 5. Populate the new text track's list of cues with the cues parsed so far , folllowing the guidelines for exposing |
2409 // cues, and begin updating it dynamically as necessary. | 2427 // cues, and begin updating it dynamically as necessary. |
2410 // - Thess are all done by the media engine. | 2428 // - Thess are all done by the media engine. |
2411 | 2429 |
2412 // 6. Set the new text track's readiness state to loaded. | 2430 // 6. Set the new text track's readiness state to loaded. |
2413 textTrack->setReadinessState(TextTrack::Loaded); | 2431 textTrack->setReadinessState(TextTrack::Loaded); |
2414 | 2432 |
2415 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of | 2433 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of |
2416 // the relevant specification for the data. | 2434 // the relevant specification for the data. |
2417 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection () | 2435 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection () |
2418 scheduleDelayedAction(LoadTextTrackResource); | 2436 scheduleTextTrackResourceLoad(); |
2419 | 2437 |
2420 // 8. Add the new text track to the media element's list of text tracks. | 2438 // 8. Add the new text track to the media element's list of text tracks. |
2421 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent | 2439 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent |
2422 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's | 2440 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's |
2423 // textTracks attribute's TextTrackList object. | 2441 // textTracks attribute's TextTrackList object. |
2424 addTextTrack(textTrack); | 2442 addTextTrack(textTrack); |
2425 } | 2443 } |
2426 | 2444 |
2427 void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack) | 2445 void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack) |
2428 { | 2446 { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2528 // media element's list of text tracks ... [continues in TextTrackList::appe nd] | 2546 // media element's list of text tracks ... [continues in TextTrackList::appe nd] |
2529 TextTrack* textTrack = trackElement->track(); | 2547 TextTrack* textTrack = trackElement->track(); |
2530 if (!textTrack) | 2548 if (!textTrack) |
2531 return; | 2549 return; |
2532 | 2550 |
2533 addTextTrack(textTrack); | 2551 addTextTrack(textTrack); |
2534 | 2552 |
2535 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks | 2553 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks |
2536 // in the markup have been added. | 2554 // in the markup have been added. |
2537 if (isFinishedParsingChildren()) | 2555 if (isFinishedParsingChildren()) |
2538 scheduleDelayedAction(LoadTextTrackResource); | 2556 scheduleTextTrackResourceLoad(); |
2539 } | 2557 } |
2540 | 2558 |
2541 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) | 2559 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) |
2542 { | 2560 { |
2543 #if !LOG_DISABLED | 2561 #if !LOG_DISABLED |
2544 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); | 2562 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); |
2545 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); | 2563 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); |
2546 #endif | 2564 #endif |
2547 | 2565 |
2548 TextTrack* textTrack = trackElement->track(); | 2566 TextTrack* textTrack = trackElement->track(); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2713 #endif | 2731 #endif |
2714 | 2732 |
2715 // We should only consider a <source> element when there is not src attribut e at all. | 2733 // We should only consider a <source> element when there is not src attribut e at all. |
2716 if (fastHasAttribute(srcAttr)) | 2734 if (fastHasAttribute(srcAttr)) |
2717 return; | 2735 return; |
2718 | 2736 |
2719 // 4.8.8 - If a source element is inserted as a child of a media element tha t has no src | 2737 // 4.8.8 - If a source element is inserted as a child of a media element tha t has no src |
2720 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag ent must invoke | 2738 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag ent must invoke |
2721 // the media element's resource selection algorithm. | 2739 // the media element's resource selection algorithm. |
2722 if (getNetworkState() == HTMLMediaElement::NETWORK_EMPTY) { | 2740 if (getNetworkState() == HTMLMediaElement::NETWORK_EMPTY) { |
2723 scheduleDelayedAction(LoadMediaResource); | 2741 // TODO(srirama.m): Remove scheduleNextSourceChild() here and |
2742 // post a micro task inside invokeResourceSelectionAlgorithm(). | |
2743 // See http://crbug.com/593289 for more details. | |
2744 invokeResourceSelectionAlgorithm(); | |
2745 scheduleNextSourceChild(); | |
2746 // Ignore current |m_nextChildNodeToConsider| and consider |source|. | |
2724 m_nextChildNodeToConsider = source; | 2747 m_nextChildNodeToConsider = source; |
2725 return; | 2748 return; |
2726 } | 2749 } |
2727 | 2750 |
2728 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) { | 2751 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) { |
2729 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - <source> inserted immediately after current source", this); | 2752 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - <source> inserted immediately after current source", this); |
2753 // Ignore current |m_nextChildNodeToConsider| and consider |source|. | |
2730 m_nextChildNodeToConsider = source; | 2754 m_nextChildNodeToConsider = source; |
2731 return; | 2755 return; |
2732 } | 2756 } |
2733 | 2757 |
2758 // Consider current |m_nextChildNodeToConsider| as it is already in the midd le of processing. | |
2734 if (m_nextChildNodeToConsider) | 2759 if (m_nextChildNodeToConsider) |
2735 return; | 2760 return; |
2736 | 2761 |
2737 if (m_loadState != WaitingForSource) | 2762 if (m_loadState != WaitingForSource) |
2738 return; | 2763 return; |
2739 | 2764 |
2740 // 4.8.9.5, resource selection algorithm, source elements section: | 2765 // 4.8.9.5, resource selection algorithm, source elements section: |
2741 // 21. Wait until the node after pointer is a node other than the end of the list. (This step might wait forever.) | 2766 // 21. Wait until the node after pointer is a node other than the end of the list. (This step might wait forever.) |
2742 // 22. Asynchronously await a stable state... | 2767 // 22. Asynchronously await a stable state... |
2743 // 23. Set the element's delaying-the-load-event flag back to true (this del ays the load event again, in case | 2768 // 23. Set the element's delaying-the-load-event flag back to true (this del ays the load event again, in case |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3108 void HTMLMediaElement::stop() | 3133 void HTMLMediaElement::stop() |
3109 { | 3134 { |
3110 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); | 3135 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); |
3111 | 3136 |
3112 recordMetricsIfPausing(); | 3137 recordMetricsIfPausing(); |
3113 | 3138 |
3114 // Close the async event queue so that no events are enqueued. | 3139 // Close the async event queue so that no events are enqueued. |
3115 cancelPendingEventsAndCallbacks(); | 3140 cancelPendingEventsAndCallbacks(); |
3116 m_asyncEventQueue->close(); | 3141 m_asyncEventQueue->close(); |
3117 | 3142 |
3118 // Stop the playback without generating events | 3143 // Clear everything in the Media Element |
3119 clearMediaPlayer(-1); | 3144 clearMediaPlayer(-1); |
3120 m_readyState = HAVE_NOTHING; | 3145 m_readyState = HAVE_NOTHING; |
3121 m_readyStateMaximum = HAVE_NOTHING; | 3146 m_readyStateMaximum = HAVE_NOTHING; |
3122 setNetworkState(NETWORK_EMPTY); | 3147 setNetworkState(NETWORK_EMPTY); |
3123 setShouldDelayLoadEvent(false); | 3148 setShouldDelayLoadEvent(false); |
3124 m_currentSourceNode = nullptr; | 3149 m_currentSourceNode = nullptr; |
3125 invalidateCachedTime(); | 3150 invalidateCachedTime(); |
3126 cueTimeline().updateActiveCues(0); | 3151 cueTimeline().updateActiveCues(0); |
3127 m_playing = false; | 3152 m_playing = false; |
3128 m_paused = true; | 3153 m_paused = true; |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3480 } | 3505 } |
3481 | 3506 |
3482 void* HTMLMediaElement::preDispatchEventHandler(Event* event) | 3507 void* HTMLMediaElement::preDispatchEventHandler(Event* event) |
3483 { | 3508 { |
3484 if (event && event->type() == EventTypeNames::webkitfullscreenchange) | 3509 if (event && event->type() == EventTypeNames::webkitfullscreenchange) |
3485 configureMediaControls(); | 3510 configureMediaControls(); |
3486 | 3511 |
3487 return nullptr; | 3512 return nullptr; |
3488 } | 3513 } |
3489 | 3514 |
3490 // TODO(srirama.m): Refactor this and clearMediaPlayer to the extent possible. | 3515 // TODO(srirama.m): Merge it to resetMediaElement if possible and remove it. |
3491 void HTMLMediaElement::resetMediaPlayerAndMediaSource() | 3516 void HTMLMediaElement::resetMediaPlayerAndMediaSource() |
3492 { | 3517 { |
3493 closeMediaSource(); | 3518 closeMediaSource(); |
3494 | 3519 |
3495 { | 3520 { |
3496 AudioSourceProviderClientLockScope scope(*this); | 3521 AudioSourceProviderClientLockScope scope(*this); |
3497 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 3522 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
3498 } | 3523 } |
3499 | 3524 |
3500 // We haven't yet found out if any remote routes are available. | 3525 // We haven't yet found out if any remote routes are available. |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3784 { | 3809 { |
3785 visitor->trace(m_client); | 3810 visitor->trace(m_client); |
3786 } | 3811 } |
3787 | 3812 |
3788 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3813 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
3789 { | 3814 { |
3790 visitor->trace(m_client); | 3815 visitor->trace(m_client); |
3791 } | 3816 } |
3792 | 3817 |
3793 } // namespace blink | 3818 } // namespace blink |
OLD | NEW |