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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 #include "public/platform/WebInbandTextTrack.h" | 87 #include "public/platform/WebInbandTextTrack.h" |
88 #include "public/platform/WebMediaPlayerSource.h" | 88 #include "public/platform/WebMediaPlayerSource.h" |
89 #include "public/platform/WebMediaStream.h" | 89 #include "public/platform/WebMediaStream.h" |
90 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" | 90 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" |
91 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" | 91 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" |
92 #include "wtf/CurrentTime.h" | 92 #include "wtf/CurrentTime.h" |
93 #include "wtf/MathExtras.h" | 93 #include "wtf/MathExtras.h" |
94 #include "wtf/text/CString.h" | 94 #include "wtf/text/CString.h" |
95 #include <limits> | 95 #include <limits> |
96 | 96 |
97 #define LOG_LEVEL 3 | |
fs
2016/05/18 13:24:36
LOG_LEVEL is a pretty generic name, so clashes doe
Srirama
2016/05/18 13:55:01
Done.
| |
98 | |
97 #ifndef LOG_MEDIA_EVENTS | 99 #ifndef LOG_MEDIA_EVENTS |
98 // Default to not logging events because so many are generated they can overwhel m the rest of | 100 // Default to not logging events because so many are generated they can overwhel m the rest of |
99 // the logging. | 101 // the logging. |
100 #define LOG_MEDIA_EVENTS 0 | 102 #define LOG_MEDIA_EVENTS 0 |
101 #endif | 103 #endif |
102 | 104 |
103 #ifndef LOG_CACHED_TIME_WARNINGS | 105 #ifndef LOG_CACHED_TIME_WARNINGS |
104 // Default to not logging warnings about excessive drift in the cached media tim e because it adds a | 106 // Default to not logging warnings about excessive drift in the cached media tim e because it adds a |
105 // fair amount of overhead and logging. | 107 // fair amount of overhead and logging. |
106 #define LOG_CACHED_TIME_WARNINGS 0 | 108 #define LOG_CACHED_TIME_WARNINGS 0 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 , m_textTracks(nullptr) | 428 , m_textTracks(nullptr) |
427 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolvePlayPromises)) | 429 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolvePlayPromises)) |
428 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectPlayPromises)) | 430 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectPlayPromises)) |
429 , m_audioSourceNode(nullptr) | 431 , m_audioSourceNode(nullptr) |
430 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) | 432 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) |
431 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et())) | 433 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et())) |
432 , m_remotePlaybackClient(nullptr) | 434 , m_remotePlaybackClient(nullptr) |
433 { | 435 { |
434 ThreadState::current()->registerPreFinalizer(this); | 436 ThreadState::current()->registerPreFinalizer(this); |
435 | 437 |
436 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this); | 438 DVLOG(LOG_LEVEL) << "HTMLMediaElement(" << this << ")"; |
437 | 439 |
438 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) | 440 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) |
439 m_userGestureRequiredForPlay = true; | 441 m_userGestureRequiredForPlay = true; |
440 | 442 |
441 setHasCustomStyleCallbacks(); | 443 setHasCustomStyleCallbacks(); |
442 addElementToDocumentMap(this, &document); | 444 addElementToDocumentMap(this, &document); |
443 | 445 |
444 UseCounter::count(document, UseCounter::HTMLMediaElement); | 446 UseCounter::count(document, UseCounter::HTMLMediaElement); |
445 } | 447 } |
446 | 448 |
447 HTMLMediaElement::~HTMLMediaElement() | 449 HTMLMediaElement::~HTMLMediaElement() |
448 { | 450 { |
449 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement(%p)", this); | 451 DVLOG(LOG_LEVEL) << "~HTMLMediaElement(" << this << ")"; |
450 | 452 |
451 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). | 453 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). |
452 // Since AudioNode::dispose() is guaranteed to be always called before | 454 // Since AudioNode::dispose() is guaranteed to be always called before |
453 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared | 455 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared |
454 // even if the AudioNode and the HTMLMediaElement die together. | 456 // even if the AudioNode and the HTMLMediaElement die together. |
455 ASSERT(!m_audioSourceNode); | 457 ASSERT(!m_audioSourceNode); |
456 } | 458 } |
457 | 459 |
458 void HTMLMediaElement::dispose() | 460 void HTMLMediaElement::dispose() |
459 { | 461 { |
460 closeMediaSource(); | 462 closeMediaSource(); |
461 | 463 |
462 // Destroying the player may cause a resource load to be canceled, | 464 // Destroying the player may cause a resource load to be canceled, |
463 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being | 465 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being |
464 // called via ResourceFetch::didLoadResource(), then | 466 // called via ResourceFetch::didLoadResource(), then |
465 // FrameLoader::checkCompleted(). But it's guaranteed that the load event | 467 // FrameLoader::checkCompleted(). But it's guaranteed that the load event |
466 // doesn't get dispatched during the object destruction. | 468 // doesn't get dispatched during the object destruction. |
467 // See Document::isDelayingLoadEvent(). | 469 // See Document::isDelayingLoadEvent(). |
468 // Also see http://crbug.com/275223 for more details. | 470 // Also see http://crbug.com/275223 for more details. |
469 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 471 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
470 } | 472 } |
471 | 473 |
472 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) | 474 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) |
473 { | 475 { |
474 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this); | 476 DVLOG(LOG_LEVEL) << "didMoveToNewDocument"; |
475 | 477 |
476 if (m_shouldDelayLoadEvent) { | 478 if (m_shouldDelayLoadEvent) { |
477 document().incrementLoadEventDelayCount(); | 479 document().incrementLoadEventDelayCount(); |
478 // Note: Keeping the load event delay count increment on oldDocument tha t was added | 480 // Note: Keeping the load event delay count increment on oldDocument tha t was added |
479 // when m_shouldDelayLoadEvent was set so that destruction of m_webMedia Player can not | 481 // when m_shouldDelayLoadEvent was set so that destruction of m_webMedia Player can not |
480 // cause load event dispatching in oldDocument. | 482 // cause load event dispatching in oldDocument. |
481 } else { | 483 } else { |
482 // Incrementing the load event delay count so that destruction of m_webM ediaPlayer can not | 484 // Incrementing the load event delay count so that destruction of m_webM ediaPlayer can not |
483 // cause load event dispatching in oldDocument. | 485 // cause load event dispatching in oldDocument. |
484 oldDocument.incrementLoadEventDelayCount(); | 486 oldDocument.incrementLoadEventDelayCount(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 return shouldShowControls() && HTMLElement::layoutObjectIsNeeded(style); | 553 return shouldShowControls() && HTMLElement::layoutObjectIsNeeded(style); |
552 } | 554 } |
553 | 555 |
554 LayoutObject* HTMLMediaElement::createLayoutObject(const ComputedStyle&) | 556 LayoutObject* HTMLMediaElement::createLayoutObject(const ComputedStyle&) |
555 { | 557 { |
556 return new LayoutMedia(this); | 558 return new LayoutMedia(this); |
557 } | 559 } |
558 | 560 |
559 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint) | 561 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint) |
560 { | 562 { |
561 WTF_LOG(Media, "HTMLMediaElement::insertedInto(%p, %p)", this, insertionPoin t); | 563 DVLOG(LOG_LEVEL) << "insertedInto(" << insertionPoint << ")"; |
562 | 564 |
563 HTMLElement::insertedInto(insertionPoint); | 565 HTMLElement::insertedInto(insertionPoint); |
564 if (insertionPoint->inShadowIncludingDocument()) { | 566 if (insertionPoint->inShadowIncludingDocument()) { |
565 UseCounter::count(document(), UseCounter::HTMLMediaElementInDocument); | 567 UseCounter::count(document(), UseCounter::HTMLMediaElementInDocument); |
566 if ((!getAttribute(srcAttr).isEmpty() || m_srcObject) && m_networkState == NETWORK_EMPTY) { | 568 if ((!getAttribute(srcAttr).isEmpty() || m_srcObject) && m_networkState == NETWORK_EMPTY) { |
567 m_ignorePreloadNone = false; | 569 m_ignorePreloadNone = false; |
568 invokeLoadAlgorithm(); | 570 invokeLoadAlgorithm(); |
569 } | 571 } |
570 } | 572 } |
571 | 573 |
572 return InsertionShouldCallDidNotifySubtreeInsertions; | 574 return InsertionShouldCallDidNotifySubtreeInsertions; |
573 } | 575 } |
574 | 576 |
575 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() | 577 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() |
576 { | 578 { |
577 configureMediaControls(); | 579 configureMediaControls(); |
578 } | 580 } |
579 | 581 |
580 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) | 582 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) |
581 { | 583 { |
582 WTF_LOG(Media, "HTMLMediaElement::removedFrom(%p, %p)", this, insertionPoint ); | 584 DVLOG(LOG_LEVEL) << "removedFrom(" << insertionPoint << ")"; |
583 | 585 |
584 HTMLElement::removedFrom(insertionPoint); | 586 HTMLElement::removedFrom(insertionPoint); |
585 if (insertionPoint->inActiveDocument()) { | 587 if (insertionPoint->inActiveDocument()) { |
586 configureMediaControls(); | 588 configureMediaControls(); |
587 if (m_networkState > NETWORK_EMPTY) | 589 if (m_networkState > NETWORK_EMPTY) |
588 pauseInternal(); | 590 pauseInternal(); |
589 } | 591 } |
590 } | 592 } |
591 | 593 |
592 void HTMLMediaElement::attach(const AttachContext& context) | 594 void HTMLMediaElement::attach(const AttachContext& context) |
593 { | 595 { |
594 HTMLElement::attach(context); | 596 HTMLElement::attach(context); |
595 | 597 |
596 if (layoutObject()) | 598 if (layoutObject()) |
597 layoutObject()->updateFromElement(); | 599 layoutObject()->updateFromElement(); |
598 } | 600 } |
599 | 601 |
600 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) | 602 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) |
601 { | 603 { |
602 if (layoutObject()) | 604 if (layoutObject()) |
603 layoutObject()->updateFromElement(); | 605 layoutObject()->updateFromElement(); |
604 } | 606 } |
605 | 607 |
606 void HTMLMediaElement::scheduleTextTrackResourceLoad() | 608 void HTMLMediaElement::scheduleTextTrackResourceLoad() |
607 { | 609 { |
608 WTF_LOG(Media, "HTMLMediaElement::scheduleTextTrackResourceLoad(%p)", this); | 610 DVLOG(LOG_LEVEL) << "scheduleTextTrackResourceLoad"; |
609 | 611 |
610 m_pendingActionFlags |= LoadTextTrackResource; | 612 m_pendingActionFlags |= LoadTextTrackResource; |
611 | 613 |
612 if (!m_loadTimer.isActive()) | 614 if (!m_loadTimer.isActive()) |
613 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | 615 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); |
614 } | 616 } |
615 | 617 |
616 void HTMLMediaElement::scheduleNextSourceChild() | 618 void HTMLMediaElement::scheduleNextSourceChild() |
617 { | 619 { |
618 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala invokeLoadAlgorithm. | 620 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala invokeLoadAlgorithm. |
619 m_pendingActionFlags |= LoadMediaResource; | 621 m_pendingActionFlags |= LoadMediaResource; |
620 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | 622 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); |
621 } | 623 } |
622 | 624 |
623 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) | 625 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) |
624 { | 626 { |
625 scheduleEvent(Event::createCancelable(eventName)); | 627 scheduleEvent(Event::createCancelable(eventName)); |
626 } | 628 } |
627 | 629 |
628 void HTMLMediaElement::scheduleEvent(Event* event) | 630 void HTMLMediaElement::scheduleEvent(Event* event) |
629 { | 631 { |
630 #if LOG_MEDIA_EVENTS | 632 #if LOG_MEDIA_EVENTS |
631 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent(%p) - scheduling '%s'", this , event->type().ascii().data()); | 633 DVLOG(LOG_LEVEL) << "scheduleEvent - scheduling '" << event->type().ascii(). data() << "'"; |
632 #endif | 634 #endif |
633 m_asyncEventQueue->enqueueEvent(event); | 635 m_asyncEventQueue->enqueueEvent(event); |
634 } | 636 } |
635 | 637 |
636 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) | 638 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) |
637 { | 639 { |
638 if (m_pendingActionFlags & LoadTextTrackResource) | 640 if (m_pendingActionFlags & LoadTextTrackResource) |
639 honorUserPreferencesForAutomaticTextTrackSelection(); | 641 honorUserPreferencesForAutomaticTextTrackSelection(); |
640 | 642 |
641 if (m_pendingActionFlags & LoadMediaResource) { | 643 if (m_pendingActionFlags & LoadMediaResource) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
680 canPlay = emptyString(); | 682 canPlay = emptyString(); |
681 break; | 683 break; |
682 case WebMimeRegistry::MayBeSupported: | 684 case WebMimeRegistry::MayBeSupported: |
683 canPlay = "maybe"; | 685 canPlay = "maybe"; |
684 break; | 686 break; |
685 case WebMimeRegistry::IsSupported: | 687 case WebMimeRegistry::IsSupported: |
686 canPlay = "probably"; | 688 canPlay = "probably"; |
687 break; | 689 break; |
688 } | 690 } |
689 | 691 |
690 WTF_LOG(Media, "HTMLMediaElement::canPlayType(%p, %s) -> %s", this, mimeType .utf8().data(), canPlay.utf8().data()); | 692 DVLOG(LOG_LEVEL) << "canPlayType(" << this << ", " << mimeType.utf8().data() << ") -> " << canPlay.utf8().data(); |
691 | 693 |
692 return canPlay; | 694 return canPlay; |
693 } | 695 } |
694 | 696 |
695 void HTMLMediaElement::load() | 697 void HTMLMediaElement::load() |
696 { | 698 { |
697 WTF_LOG(Media, "HTMLMediaElement::load(%p)", this); | 699 DVLOG(LOG_LEVEL) << "load"; |
698 | 700 |
699 m_autoplayHelper->loadMethodCalled(); | 701 m_autoplayHelper->loadMethodCalled(); |
700 | 702 |
701 m_ignorePreloadNone = true; | 703 m_ignorePreloadNone = true; |
702 invokeLoadAlgorithm(); | 704 invokeLoadAlgorithm(); |
703 } | 705 } |
704 | 706 |
705 // TODO(srirama.m): Currently m_ignorePreloadNone is reset before calling | 707 // TODO(srirama.m): Currently m_ignorePreloadNone is reset before calling |
706 // invokeLoadAlgorithm() in all places except load(). Move it inside here | 708 // invokeLoadAlgorithm() in all places except load(). Move it inside here |
707 // once microtask is implemented for "Await a stable state" step | 709 // once microtask is implemented for "Await a stable state" step |
708 // in resource selection algorithm. | 710 // in resource selection algorithm. |
709 void HTMLMediaElement::invokeLoadAlgorithm() | 711 void HTMLMediaElement::invokeLoadAlgorithm() |
710 { | 712 { |
711 WTF_LOG(Media, "HTMLMediaElement::invokeLoadAlgorithm(%p)", this); | 713 DVLOG(LOG_LEVEL) << "invokeLoadAlgorithm"; |
712 | 714 |
713 // Perform the cleanup required for the resource load algorithm to run. | 715 // Perform the cleanup required for the resource load algorithm to run. |
714 stopPeriodicTimers(); | 716 stopPeriodicTimers(); |
715 m_loadTimer.stop(); | 717 m_loadTimer.stop(); |
716 cancelDeferredLoad(); | 718 cancelDeferredLoad(); |
717 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. | 719 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. |
718 m_pendingActionFlags &= ~LoadMediaResource; | 720 m_pendingActionFlags &= ~LoadMediaResource; |
719 m_sentEndEvent = false; | 721 m_sentEndEvent = false; |
720 m_sentStalledEvent = false; | 722 m_sentStalledEvent = false; |
721 m_haveFiredLoadedData = false; | 723 m_haveFiredLoadedData = false; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
789 m_autoplaying = true; | 791 m_autoplaying = true; |
790 | 792 |
791 // 7 - Invoke the media element's resource selection algorithm. | 793 // 7 - Invoke the media element's resource selection algorithm. |
792 invokeResourceSelectionAlgorithm(); | 794 invokeResourceSelectionAlgorithm(); |
793 | 795 |
794 // 8 - Note: Playback of any previously playing media resource for this elem ent stops. | 796 // 8 - Note: Playback of any previously playing media resource for this elem ent stops. |
795 } | 797 } |
796 | 798 |
797 void HTMLMediaElement::invokeResourceSelectionAlgorithm() | 799 void HTMLMediaElement::invokeResourceSelectionAlgorithm() |
798 { | 800 { |
799 WTF_LOG(Media, "HTMLMediaElement::invokeResourceSelectionAlgorithm(%p)", thi s); | 801 DVLOG(LOG_LEVEL) << "invokeResourceSelectionAlgorithm"; |
800 // The resource selection algorithm | 802 // The resource selection algorithm |
801 // 1 - Set the networkState to NETWORK_NO_SOURCE | 803 // 1 - Set the networkState to NETWORK_NO_SOURCE |
802 setNetworkState(NETWORK_NO_SOURCE); | 804 setNetworkState(NETWORK_NO_SOURCE); |
803 | 805 |
804 // 2 - Set the element's show poster flag to true | 806 // 2 - Set the element's show poster flag to true |
805 // TODO(srirama.m): Introduce show poster flag and update it as per spec | 807 // TODO(srirama.m): Introduce show poster flag and update it as per spec |
806 | 808 |
807 m_playedTimeRanges = TimeRanges::create(); | 809 m_playedTimeRanges = TimeRanges::create(); |
808 | 810 |
809 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above | 811 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above |
(...skipping 23 matching lines...) Expand all Loading... | |
833 if (track->mode() != TextTrack::disabledKeyword()) | 835 if (track->mode() != TextTrack::disabledKeyword()) |
834 m_textTracksWhenResourceSelectionBegan.append(track); | 836 m_textTracksWhenResourceSelectionBegan.append(track); |
835 } | 837 } |
836 } | 838 } |
837 | 839 |
838 selectMediaResource(); | 840 selectMediaResource(); |
839 } | 841 } |
840 | 842 |
841 void HTMLMediaElement::selectMediaResource() | 843 void HTMLMediaElement::selectMediaResource() |
842 { | 844 { |
843 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p)", this); | 845 DVLOG(LOG_LEVEL) << "selectMediaResource"; |
844 | 846 |
845 enum Mode { Object, Attribute, Children, Nothing }; | 847 enum Mode { Object, Attribute, Children, Nothing }; |
846 Mode mode = Nothing; | 848 Mode mode = Nothing; |
847 | 849 |
848 // 6 - If the media element has an assigned media provider object, then let | 850 // 6 - If the media element has an assigned media provider object, then let |
849 // mode be object. | 851 // mode be object. |
850 if (m_srcObject) { | 852 if (m_srcObject) { |
851 mode = Object; | 853 mode = Object; |
852 } else if (fastHasAttribute(srcAttr)) { | 854 } else if (fastHasAttribute(srcAttr)) { |
853 // Otherwise, if the media element has no assigned media provider object | 855 // Otherwise, if the media element has no assigned media provider object |
(...skipping 10 matching lines...) Expand all Loading... | |
864 } else { | 866 } else { |
865 // Otherwise the media element has no assigned media provider object and | 867 // Otherwise the media element has no assigned media provider object and |
866 // has neither a src attribute nor a source element child: set the | 868 // has neither a src attribute nor a source element child: set the |
867 // networkState to NETWORK_EMPTY, and abort these steps; the synchronous | 869 // networkState to NETWORK_EMPTY, and abort these steps; the synchronous |
868 // section ends. | 870 // section ends. |
869 m_loadState = WaitingForSource; | 871 m_loadState = WaitingForSource; |
870 setShouldDelayLoadEvent(false); | 872 setShouldDelayLoadEvent(false); |
871 setNetworkState(NETWORK_EMPTY); | 873 setNetworkState(NETWORK_EMPTY); |
872 updateDisplayState(); | 874 updateDisplayState(); |
873 | 875 |
874 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing to lo ad", this); | 876 DVLOG(LOG_LEVEL) << "selectMediaResource, nothing to load"; |
875 return; | 877 return; |
876 } | 878 } |
877 | 879 |
878 // 7 - Set the media element's networkState to NETWORK_LOADING. | 880 // 7 - Set the media element's networkState to NETWORK_LOADING. |
879 setNetworkState(NETWORK_LOADING); | 881 setNetworkState(NETWORK_LOADING); |
880 | 882 |
881 // 8 - Queue a task to fire a simple event named loadstart at the media elem ent. | 883 // 8 - Queue a task to fire a simple event named loadstart at the media elem ent. |
882 scheduleEvent(EventTypeNames::loadstart); | 884 scheduleEvent(EventTypeNames::loadstart); |
883 | 885 |
884 // 9 - Run the appropriate steps... | 886 // 9 - Run the appropriate steps... |
885 switch (mode) { | 887 switch (mode) { |
886 case Object: | 888 case Object: |
887 loadSourceFromObject(); | 889 loadSourceFromObject(); |
888 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using 'srcObj ect' attribute", this); | 890 DVLOG(LOG_LEVEL) << "selectMediaResource, using 'srcObject' attribute"; |
889 break; | 891 break; |
890 case Attribute: | 892 case Attribute: |
891 loadSourceFromAttribute(); | 893 loadSourceFromAttribute(); |
892 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using 'src' a ttribute url", this); | 894 DVLOG(LOG_LEVEL) << "selectMediaResource, using 'src' attribute url"; |
893 break; | 895 break; |
894 case Children: | 896 case Children: |
895 loadNextSourceChild(); | 897 loadNextSourceChild(); |
896 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using source element", this); | 898 DVLOG(LOG_LEVEL) << "selectMediaResource, using source element"; |
897 break; | 899 break; |
898 default: | 900 default: |
899 ASSERT_NOT_REACHED(); | 901 ASSERT_NOT_REACHED(); |
900 } | 902 } |
901 } | 903 } |
902 | 904 |
903 void HTMLMediaElement::loadSourceFromObject() | 905 void HTMLMediaElement::loadSourceFromObject() |
904 { | 906 { |
905 ASSERT(m_srcObject); | 907 ASSERT(m_srcObject); |
906 m_loadState = LoadingFromSrcObject; | 908 m_loadState = LoadingFromSrcObject; |
907 | 909 |
908 // No type is available when the resource comes from the 'srcObject' | 910 // No type is available when the resource comes from the 'srcObject' |
909 // attribute. | 911 // attribute. |
910 ContentType contentType((String())); | 912 ContentType contentType((String())); |
911 loadResource(WebMediaPlayerSource(WebMediaStream(m_srcObject)), contentType) ; | 913 loadResource(WebMediaPlayerSource(WebMediaStream(m_srcObject)), contentType) ; |
912 } | 914 } |
913 | 915 |
914 void HTMLMediaElement::loadSourceFromAttribute() | 916 void HTMLMediaElement::loadSourceFromAttribute() |
915 { | 917 { |
916 m_loadState = LoadingFromSrcAttr; | 918 m_loadState = LoadingFromSrcAttr; |
917 const AtomicString& srcValue = fastGetAttribute(srcAttr); | 919 const AtomicString& srcValue = fastGetAttribute(srcAttr); |
918 | 920 |
919 // If the src attribute's value is the empty string ... jump down to the fai led step below | 921 // If the src attribute's value is the empty string ... jump down to the fai led step below |
920 if (srcValue.isEmpty()) { | 922 if (srcValue.isEmpty()) { |
921 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 923 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
922 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), empty 'src'", this); | 924 DVLOG(LOG_LEVEL) << "selectMediaResource, empty 'src'"; |
923 return; | 925 return; |
924 } | 926 } |
925 | 927 |
926 KURL mediaURL = document().completeURL(srcValue); | 928 KURL mediaURL = document().completeURL(srcValue); |
927 if (!isSafeToLoadURL(mediaURL, Complain)) { | 929 if (!isSafeToLoadURL(mediaURL, Complain)) { |
928 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 930 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
929 return; | 931 return; |
930 } | 932 } |
931 | 933 |
932 // No type is available when the url comes from the 'src' attribute so | 934 // No type is available when the url comes from the 'src' attribute so |
(...skipping 18 matching lines...) Expand all Loading... | |
951 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); | 953 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); |
952 } | 954 } |
953 | 955 |
954 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, ContentT ype& contentType) | 956 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, ContentT ype& contentType) |
955 { | 957 { |
956 ASSERT(isMainThread()); | 958 ASSERT(isMainThread()); |
957 KURL url; | 959 KURL url; |
958 if (source.isURL()) { | 960 if (source.isURL()) { |
959 url = source.getAsURL(); | 961 url = source.getAsURL(); |
960 ASSERT(isSafeToLoadURL(url, Complain)); | 962 ASSERT(isSafeToLoadURL(url, Complain)); |
961 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p, %s, %s)", this, urlFo rLoggingMedia(url).utf8().data(), contentType.raw().utf8().data()); | 963 DVLOG(LOG_LEVEL) << "loadResource(" << urlForLoggingMedia(url).utf8().da ta() << ", " << contentType.raw().utf8().data() << ")"; |
962 } | 964 } |
963 | 965 |
964 LocalFrame* frame = document().frame(); | 966 LocalFrame* frame = document().frame(); |
965 if (!frame) { | 967 if (!frame) { |
966 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 968 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
967 return; | 969 return; |
968 } | 970 } |
969 | 971 |
970 // The resource fetch algorithm | 972 // The resource fetch algorithm |
971 setNetworkState(NETWORK_LOADING); | 973 setNetworkState(NETWORK_LOADING); |
972 | 974 |
973 m_autoplayHelper->loadingStarted(); | 975 m_autoplayHelper->loadingStarted(); |
974 | 976 |
975 // Set m_currentSrc *before* changing to the cache url, the fact that we are loading from the app | 977 // Set m_currentSrc *before* changing to the cache url, the fact that we are loading from the app |
976 // cache is an internal detail not exposed through the media element API. | 978 // cache is an internal detail not exposed through the media element API. |
977 m_currentSrc = url; | 979 m_currentSrc = url; |
978 | 980 |
979 if (m_audioSourceNode) | 981 if (m_audioSourceNode) |
980 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc); | 982 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc); |
981 | 983 |
982 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) - m_currentSrc -> %s", th is, urlForLoggingMedia(m_currentSrc).utf8().data()); | 984 DVLOG(LOG_LEVEL) << "loadResource - m_currentSrc -> " << urlForLoggingMedia( m_currentSrc).utf8().data(); |
983 | 985 |
984 startProgressEventTimer(); | 986 startProgressEventTimer(); |
985 | 987 |
986 // Reset display mode to force a recalculation of what to show because we ar e resetting the player. | 988 // Reset display mode to force a recalculation of what to show because we ar e resetting the player. |
987 setDisplayMode(Unknown); | 989 setDisplayMode(Unknown); |
988 | 990 |
989 setPlayerPreload(); | 991 setPlayerPreload(); |
990 | 992 |
991 if (fastHasAttribute(mutedAttr)) | 993 if (fastHasAttribute(mutedAttr)) |
992 m_muted = true; | 994 m_muted = true; |
(...skipping 23 matching lines...) Expand all Loading... | |
1016 } | 1018 } |
1017 | 1019 |
1018 bool canLoadResource = source.isMediaStream() || canLoadURL(url, contentType ); | 1020 bool canLoadResource = source.isMediaStream() || canLoadURL(url, contentType ); |
1019 if (attemptLoad && canLoadResource) { | 1021 if (attemptLoad && canLoadResource) { |
1020 ASSERT(!webMediaPlayer()); | 1022 ASSERT(!webMediaPlayer()); |
1021 | 1023 |
1022 // Conditionally defer the load if effective preload is 'none'. | 1024 // Conditionally defer the load if effective preload is 'none'. |
1023 // Skip this optional deferral for MediaStream sources or any blob URL, | 1025 // Skip this optional deferral for MediaStream sources or any blob URL, |
1024 // including MediaSource blob URLs. | 1026 // including MediaSource blob URLs. |
1025 if (!isStreamOrBlobUrl && effectivePreloadType() == WebMediaPlayer::Prel oadNone) { | 1027 if (!isStreamOrBlobUrl && effectivePreloadType() == WebMediaPlayer::Prel oadNone) { |
1026 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this); | 1028 DVLOG(LOG_LEVEL) << "loadResource : Delaying load because preload == 'none'"; |
1027 deferLoad(); | 1029 deferLoad(); |
1028 } else { | 1030 } else { |
1029 startPlayerLoad(); | 1031 startPlayerLoad(); |
1030 } | 1032 } |
1031 } else { | 1033 } else { |
1032 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 1034 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
1033 } | 1035 } |
1034 | 1036 |
1035 // If there is no poster to display, allow the media engine to render video frames as soon as | 1037 // If there is no poster to display, allow the media engine to render video frames as soon as |
1036 // they are available. | 1038 // they are available. |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1237 } | 1239 } |
1238 | 1240 |
1239 void HTMLMediaElement::disableAutomaticTextTrackSelection() | 1241 void HTMLMediaElement::disableAutomaticTextTrackSelection() |
1240 { | 1242 { |
1241 m_shouldPerformAutomaticTrackSelection = false; | 1243 m_shouldPerformAutomaticTrackSelection = false; |
1242 } | 1244 } |
1243 | 1245 |
1244 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI fInvalid) | 1246 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI fInvalid) |
1245 { | 1247 { |
1246 if (!url.isValid()) { | 1248 if (!url.isValid()) { |
1247 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> FALSE becau se url is invalid", this, urlForLoggingMedia(url).utf8().data()); | 1249 DVLOG(LOG_LEVEL) << "isSafeToLoadURL(" << urlForLoggingMedia(url).utf8() .data() << ") -> FALSE because url is invalid"; |
1248 return false; | 1250 return false; |
1249 } | 1251 } |
1250 | 1252 |
1251 LocalFrame* frame = document().frame(); | 1253 LocalFrame* frame = document().frame(); |
1252 if (!frame || !document().getSecurityOrigin()->canDisplay(url)) { | 1254 if (!frame || !document().getSecurityOrigin()->canDisplay(url)) { |
1253 if (actionIfInvalid == Complain) | 1255 if (actionIfInvalid == Complain) |
1254 FrameLoader::reportLocalLoadFailed(frame, url.elidedString()); | 1256 FrameLoader::reportLocalLoadFailed(frame, url.elidedString()); |
1255 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> FALSE rejec ted by SecurityOrigin", this, urlForLoggingMedia(url).utf8().data()); | 1257 DVLOG(LOG_LEVEL) << "isSafeToLoadURL(" << urlForLoggingMedia(url).utf8() .data() << ") -> FALSE rejected by SecurityOrigin"; |
1256 return false; | 1258 return false; |
1257 } | 1259 } |
1258 | 1260 |
1259 if (!document().contentSecurityPolicy()->allowMediaFromSource(url)) { | 1261 if (!document().contentSecurityPolicy()->allowMediaFromSource(url)) { |
1260 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> rejected by Content Security Policy", this, urlForLoggingMedia(url).utf8().data()); | 1262 DVLOG(LOG_LEVEL) << "isSafeToLoadURL(" << urlForLoggingMedia(url).utf8() .data() << ") -> rejected by Content Security Policy"; |
1261 return false; | 1263 return false; |
1262 } | 1264 } |
1263 | 1265 |
1264 return true; | 1266 return true; |
1265 } | 1267 } |
1266 | 1268 |
1267 bool HTMLMediaElement::isMediaDataCORSSameOrigin(SecurityOrigin* origin) const | 1269 bool HTMLMediaElement::isMediaDataCORSSameOrigin(SecurityOrigin* origin) const |
1268 { | 1270 { |
1269 // hasSingleSecurityOrigin() tells us whether the origin in the src is | 1271 // hasSingleSecurityOrigin() tells us whether the origin in the src is |
1270 // the same as the actual request (i.e. after redirect). | 1272 // the same as the actual request (i.e. after redirect). |
(...skipping 10 matching lines...) Expand all Loading... | |
1281 if (m_progressEventTimer.isActive()) | 1283 if (m_progressEventTimer.isActive()) |
1282 return; | 1284 return; |
1283 | 1285 |
1284 m_previousProgressTime = WTF::currentTime(); | 1286 m_previousProgressTime = WTF::currentTime(); |
1285 // 350ms is not magic, it is in the spec! | 1287 // 350ms is not magic, it is in the spec! |
1286 m_progressEventTimer.startRepeating(0.350, BLINK_FROM_HERE); | 1288 m_progressEventTimer.startRepeating(0.350, BLINK_FROM_HERE); |
1287 } | 1289 } |
1288 | 1290 |
1289 void HTMLMediaElement::waitForSourceChange() | 1291 void HTMLMediaElement::waitForSourceChange() |
1290 { | 1292 { |
1291 WTF_LOG(Media, "HTMLMediaElement::waitForSourceChange(%p)", this); | 1293 DVLOG(LOG_LEVEL) << "waitForSourceChange"; |
1292 | 1294 |
1293 stopPeriodicTimers(); | 1295 stopPeriodicTimers(); |
1294 m_loadState = WaitingForSource; | 1296 m_loadState = WaitingForSource; |
1295 | 1297 |
1296 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N O_SOURCE value | 1298 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N O_SOURCE value |
1297 setNetworkState(NETWORK_NO_SOURCE); | 1299 setNetworkState(NETWORK_NO_SOURCE); |
1298 | 1300 |
1299 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop s delaying the load event. | 1301 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop s delaying the load event. |
1300 setShouldDelayLoadEvent(false); | 1302 setShouldDelayLoadEvent(false); |
1301 | 1303 |
1302 updateDisplayState(); | 1304 updateDisplayState(); |
1303 | 1305 |
1304 if (layoutObject()) | 1306 if (layoutObject()) |
1305 layoutObject()->updateFromElement(); | 1307 layoutObject()->updateFromElement(); |
1306 } | 1308 } |
1307 | 1309 |
1308 void HTMLMediaElement::noneSupported() | 1310 void HTMLMediaElement::noneSupported() |
1309 { | 1311 { |
1310 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this); | 1312 DVLOG(LOG_LEVEL) << "noneSupported"; |
1311 | 1313 |
1312 stopPeriodicTimers(); | 1314 stopPeriodicTimers(); |
1313 m_loadState = WaitingForSource; | 1315 m_loadState = WaitingForSource; |
1314 m_currentSourceNode = nullptr; | 1316 m_currentSourceNode = nullptr; |
1315 | 1317 |
1316 // 4.8.13.5 | 1318 // 4.8.13.5 |
1317 // The dedicated media source failure steps are the following steps: | 1319 // The dedicated media source failure steps are the following steps: |
1318 | 1320 |
1319 // 1 - Set the error attribute to a new MediaError object whose code attribu te is set to | 1321 // 1 - Set the error attribute to a new MediaError object whose code attribu te is set to |
1320 // MEDIA_ERR_SRC_NOT_SUPPORTED. | 1322 // MEDIA_ERR_SRC_NOT_SUPPORTED. |
(...skipping 19 matching lines...) Expand all Loading... | |
1340 // 7 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. | 1342 // 7 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. |
1341 setShouldDelayLoadEvent(false); | 1343 setShouldDelayLoadEvent(false); |
1342 | 1344 |
1343 if (layoutObject()) | 1345 if (layoutObject()) |
1344 layoutObject()->updateFromElement(); | 1346 layoutObject()->updateFromElement(); |
1345 } | 1347 } |
1346 | 1348 |
1347 void HTMLMediaElement::mediaEngineError(MediaError* err) | 1349 void HTMLMediaElement::mediaEngineError(MediaError* err) |
1348 { | 1350 { |
1349 ASSERT(m_readyState >= HAVE_METADATA); | 1351 ASSERT(m_readyState >= HAVE_METADATA); |
1350 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca st<int>(err->code())); | 1352 DVLOG(LOG_LEVEL) << "mediaEngineError(" << static_cast<int>(err->code()) << ")"; |
1351 | 1353 |
1352 // 1 - The user agent should cancel the fetching process. | 1354 // 1 - The user agent should cancel the fetching process. |
1353 stopPeriodicTimers(); | 1355 stopPeriodicTimers(); |
1354 m_loadState = WaitingForSource; | 1356 m_loadState = WaitingForSource; |
1355 | 1357 |
1356 // 2 - Set the error attribute to a new MediaError object whose code attribu te is | 1358 // 2 - Set the error attribute to a new MediaError object whose code attribu te is |
1357 // set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE. | 1359 // set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE. |
1358 m_error = err; | 1360 m_error = err; |
1359 | 1361 |
1360 // 3 - Queue a task to fire a simple event named error at the media element. | 1362 // 3 - Queue a task to fire a simple event named error at the media element. |
1361 scheduleEvent(EventTypeNames::error); | 1363 scheduleEvent(EventTypeNames::error); |
1362 | 1364 |
1363 // 4 - Set the element's networkState attribute to the NETWORK_IDLE value. | 1365 // 4 - Set the element's networkState attribute to the NETWORK_IDLE value. |
1364 setNetworkState(NETWORK_IDLE); | 1366 setNetworkState(NETWORK_IDLE); |
1365 | 1367 |
1366 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. | 1368 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. |
1367 setShouldDelayLoadEvent(false); | 1369 setShouldDelayLoadEvent(false); |
1368 | 1370 |
1369 // 6 - Abort the overall resource selection algorithm. | 1371 // 6 - Abort the overall resource selection algorithm. |
1370 m_currentSourceNode = nullptr; | 1372 m_currentSourceNode = nullptr; |
1371 } | 1373 } |
1372 | 1374 |
1373 void HTMLMediaElement::cancelPendingEventsAndCallbacks() | 1375 void HTMLMediaElement::cancelPendingEventsAndCallbacks() |
1374 { | 1376 { |
1375 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this ); | 1377 DVLOG(LOG_LEVEL) << "cancelPendingEventsAndCallbacks"; |
1376 m_asyncEventQueue->cancelAllEvents(); | 1378 m_asyncEventQueue->cancelAllEvents(); |
1377 | 1379 |
1378 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) | 1380 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) |
1379 source->cancelPendingErrorEvent(); | 1381 source->cancelPendingErrorEvent(); |
1380 | 1382 |
1381 m_playPromiseResolveTask->cancel(); | 1383 m_playPromiseResolveTask->cancel(); |
1382 m_playPromiseRejectTask->cancel(); | 1384 m_playPromiseRejectTask->cancel(); |
1383 } | 1385 } |
1384 | 1386 |
1385 void HTMLMediaElement::networkStateChanged() | 1387 void HTMLMediaElement::networkStateChanged() |
1386 { | 1388 { |
1387 setNetworkState(webMediaPlayer()->getNetworkState()); | 1389 setNetworkState(webMediaPlayer()->getNetworkState()); |
1388 } | 1390 } |
1389 | 1391 |
1390 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) | 1392 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) |
1391 { | 1393 { |
1392 stopPeriodicTimers(); | 1394 stopPeriodicTimers(); |
1393 | 1395 |
1394 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more | 1396 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more |
1395 // <source> children, schedule the next one | 1397 // <source> children, schedule the next one |
1396 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement) { | 1398 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement) { |
1397 | 1399 |
1398 // resource selection algorithm | 1400 // resource selection algorithm |
1399 // Step 9.Otherwise.9 - Failed with elements: Queue a task, using the DO M manipulation task source, to fire a simple event named error at the candidate element. | 1401 // Step 9.Otherwise.9 - Failed with elements: Queue a task, using the DO M manipulation task source, to fire a simple event named error at the candidate element. |
1400 if (m_currentSourceNode) | 1402 if (m_currentSourceNode) |
1401 m_currentSourceNode->scheduleErrorEvent(); | 1403 m_currentSourceNode->scheduleErrorEvent(); |
1402 else | 1404 else |
1403 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - error event not sent, <source> was removed", this); | 1405 DVLOG(LOG_LEVEL) << "setNetworkState - error event not sent, <source > was removed"; |
1404 | 1406 |
1405 // 9.Otherwise.10 - Asynchronously await a stable state. The synchronous section consists of all the remaining steps of this algorithm until the algorit hm says the synchronous section has ended. | 1407 // 9.Otherwise.10 - Asynchronously await a stable state. The synchronous section consists of all the remaining steps of this algorithm until the algorit hm says the synchronous section has ended. |
1406 | 1408 |
1407 // 9.Otherwise.11 - Forget the media element's media-resource-specific t racks. | 1409 // 9.Otherwise.11 - Forget the media element's media-resource-specific t racks. |
1408 forgetResourceSpecificTracks(); | 1410 forgetResourceSpecificTracks(); |
1409 | 1411 |
1410 if (havePotentialSourceChild()) { | 1412 if (havePotentialSourceChild()) { |
1411 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - scheduling n ext <source>", this); | 1413 DVLOG(LOG_LEVEL) << "setNetworkState - scheduling next <source>"; |
1412 scheduleNextSourceChild(); | 1414 scheduleNextSourceChild(); |
1413 } else { | 1415 } else { |
1414 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - no more <sou rce> elements, waiting", this); | 1416 DVLOG(LOG_LEVEL) << "setNetworkState - no more <source> elements, wa iting"; |
1415 waitForSourceChange(); | 1417 waitForSourceChange(); |
1416 } | 1418 } |
1417 | 1419 |
1418 return; | 1420 return; |
1419 } | 1421 } |
1420 | 1422 |
1421 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA) | 1423 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA) |
1422 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); | 1424 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); |
1423 else if (error == WebMediaPlayer::NetworkStateDecodeError) | 1425 else if (error == WebMediaPlayer::NetworkStateDecodeError) |
1424 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); | 1426 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); |
1425 else if ((error == WebMediaPlayer::NetworkStateFormatError | 1427 else if ((error == WebMediaPlayer::NetworkStateFormatError |
1426 || error == WebMediaPlayer::NetworkStateNetworkError) | 1428 || error == WebMediaPlayer::NetworkStateNetworkError) |
1427 && m_loadState == LoadingFromSrcAttr) | 1429 && m_loadState == LoadingFromSrcAttr) |
1428 noneSupported(); | 1430 noneSupported(); |
1429 | 1431 |
1430 updateDisplayState(); | 1432 updateDisplayState(); |
1431 if (mediaControls()) | 1433 if (mediaControls()) |
1432 mediaControls()->reset(); | 1434 mediaControls()->reset(); |
1433 } | 1435 } |
1434 | 1436 |
1435 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) | 1437 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) |
1436 { | 1438 { |
1437 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p, %d) - current state is %d", this, static_cast<int>(state), static_cast<int>(m_networkState)); | 1439 DVLOG(LOG_LEVEL) << "setNetworkState(" << static_cast<int>(state) << ") - cu rrent state is " << static_cast<int>(m_networkState); |
1438 | 1440 |
1439 if (state == WebMediaPlayer::NetworkStateEmpty) { | 1441 if (state == WebMediaPlayer::NetworkStateEmpty) { |
1440 // Just update the cached state and leave, we can't do anything. | 1442 // Just update the cached state and leave, we can't do anything. |
1441 setNetworkState(NETWORK_EMPTY); | 1443 setNetworkState(NETWORK_EMPTY); |
1442 return; | 1444 return; |
1443 } | 1445 } |
1444 | 1446 |
1445 if (state == WebMediaPlayer::NetworkStateFormatError | 1447 if (state == WebMediaPlayer::NetworkStateFormatError |
1446 || state == WebMediaPlayer::NetworkStateNetworkError | 1448 || state == WebMediaPlayer::NetworkStateNetworkError |
1447 || state == WebMediaPlayer::NetworkStateDecodeError) { | 1449 || state == WebMediaPlayer::NetworkStateDecodeError) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1482 setNetworkState(NETWORK_IDLE); | 1484 setNetworkState(NETWORK_IDLE); |
1483 } | 1485 } |
1484 | 1486 |
1485 void HTMLMediaElement::readyStateChanged() | 1487 void HTMLMediaElement::readyStateChanged() |
1486 { | 1488 { |
1487 setReadyState(static_cast<ReadyState>(webMediaPlayer()->getReadyState())); | 1489 setReadyState(static_cast<ReadyState>(webMediaPlayer()->getReadyState())); |
1488 } | 1490 } |
1489 | 1491 |
1490 void HTMLMediaElement::setReadyState(ReadyState state) | 1492 void HTMLMediaElement::setReadyState(ReadyState state) |
1491 { | 1493 { |
1492 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState)); | 1494 DVLOG(LOG_LEVEL) << "setReadyState(" << static_cast<int>(state) << ") - curr ent state is " << static_cast<int>(m_readyState); |
1493 | 1495 |
1494 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it | 1496 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it |
1495 bool wasPotentiallyPlaying = potentiallyPlaying(); | 1497 bool wasPotentiallyPlaying = potentiallyPlaying(); |
1496 | 1498 |
1497 ReadyState oldState = m_readyState; | 1499 ReadyState oldState = m_readyState; |
1498 ReadyState newState = state; | 1500 ReadyState newState = state; |
1499 | 1501 |
1500 bool tracksAreReady = textTracksAreReady(); | 1502 bool tracksAreReady = textTracksAreReady(); |
1501 | 1503 |
1502 if (newState == oldState && m_tracksAreReady == tracksAreReady) | 1504 if (newState == oldState && m_tracksAreReady == tracksAreReady) |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1648 layoutObject()->updateFromElement(); | 1650 layoutObject()->updateFromElement(); |
1649 } else if (timedelta > 3.0 && !m_sentStalledEvent) { | 1651 } else if (timedelta > 3.0 && !m_sentStalledEvent) { |
1650 scheduleEvent(EventTypeNames::stalled); | 1652 scheduleEvent(EventTypeNames::stalled); |
1651 m_sentStalledEvent = true; | 1653 m_sentStalledEvent = true; |
1652 setShouldDelayLoadEvent(false); | 1654 setShouldDelayLoadEvent(false); |
1653 } | 1655 } |
1654 } | 1656 } |
1655 | 1657 |
1656 void HTMLMediaElement::addPlayedRange(double start, double end) | 1658 void HTMLMediaElement::addPlayedRange(double start, double end) |
1657 { | 1659 { |
1658 WTF_LOG(Media, "HTMLMediaElement::addPlayedRange(%p, %f, %f)", this, start, end); | 1660 DVLOG(LOG_LEVEL) << "addPlayedRange(" << start << ", " << end << ")"; |
1659 if (!m_playedTimeRanges) | 1661 if (!m_playedTimeRanges) |
1660 m_playedTimeRanges = TimeRanges::create(); | 1662 m_playedTimeRanges = TimeRanges::create(); |
1661 m_playedTimeRanges->add(start, end); | 1663 m_playedTimeRanges->add(start, end); |
1662 } | 1664 } |
1663 | 1665 |
1664 bool HTMLMediaElement::supportsSave() const | 1666 bool HTMLMediaElement::supportsSave() const |
1665 { | 1667 { |
1666 return webMediaPlayer() && webMediaPlayer()->supportsSave(); | 1668 return webMediaPlayer() && webMediaPlayer()->supportsSave(); |
1667 } | 1669 } |
1668 | 1670 |
1669 void HTMLMediaElement::setIgnorePreloadNone() | 1671 void HTMLMediaElement::setIgnorePreloadNone() |
1670 { | 1672 { |
1671 WTF_LOG(Media, "HTMLMediaElement::setIgnorePreloadNone(%p)", this); | 1673 DVLOG(LOG_LEVEL) << "setIgnorePreloadNone"; |
1672 m_ignorePreloadNone = true; | 1674 m_ignorePreloadNone = true; |
1673 setPlayerPreload(); | 1675 setPlayerPreload(); |
1674 } | 1676 } |
1675 | 1677 |
1676 void HTMLMediaElement::seek(double time) | 1678 void HTMLMediaElement::seek(double time) |
1677 { | 1679 { |
1678 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); | 1680 DVLOG(LOG_LEVEL) << "seek(" << time << ")"; |
1679 | 1681 |
1680 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. | 1682 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. |
1681 if (m_readyState == HAVE_NOTHING) | 1683 if (m_readyState == HAVE_NOTHING) |
1682 return; | 1684 return; |
1683 | 1685 |
1684 // Ignore preload none and start load if necessary. | 1686 // Ignore preload none and start load if necessary. |
1685 setIgnorePreloadNone(); | 1687 setIgnorePreloadNone(); |
1686 | 1688 |
1687 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. | 1689 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. |
1688 refreshCachedTime(); | 1690 refreshCachedTime(); |
(...skipping 16 matching lines...) Expand all Loading... | |
1705 // 7 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. | 1707 // 7 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. |
1706 time = std::max(time, 0.0); | 1708 time = std::max(time, 0.0); |
1707 | 1709 |
1708 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This | 1710 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This |
1709 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's | 1711 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's |
1710 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and | 1712 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and |
1711 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never | 1713 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never |
1712 // fire a 'seeked' event. | 1714 // fire a 'seeked' event. |
1713 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); | 1715 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); |
1714 if (time != mediaTime) { | 1716 if (time != mediaTime) { |
1715 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale nt is %f", this, time, mediaTime); | 1717 DVLOG(LOG_LEVEL) << "seek(" << time << ") - media timeline equivalent is " << mediaTime; |
1716 time = mediaTime; | 1718 time = mediaTime; |
1717 } | 1719 } |
1718 | 1720 |
1719 // 8 - If the (possibly now changed) new playback position is not in one of the ranges given in the | 1721 // 8 - If the (possibly now changed) new playback position is not in one of the ranges given in the |
1720 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute | 1722 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute |
1721 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable | 1723 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable |
1722 // attribute then set the seeking IDL attribute to false and abort these ste ps. | 1724 // attribute then set the seeking IDL attribute to false and abort these ste ps. |
1723 TimeRanges* seekableRanges = seekable(); | 1725 TimeRanges* seekableRanges = seekable(); |
1724 | 1726 |
1725 if (!seekableRanges->length()) { | 1727 if (!seekableRanges->length()) { |
(...skipping 13 matching lines...) Expand all Loading... | |
1739 | 1741 |
1740 // 11 - Set the current playback position to the given new playback position . | 1742 // 11 - Set the current playback position to the given new playback position . |
1741 webMediaPlayer()->seek(time); | 1743 webMediaPlayer()->seek(time); |
1742 | 1744 |
1743 // 14-17 are handled, if necessary, when the engine signals a readystate cha nge or otherwise | 1745 // 14-17 are handled, if necessary, when the engine signals a readystate cha nge or otherwise |
1744 // satisfies seek completion and signals a time change. | 1746 // satisfies seek completion and signals a time change. |
1745 } | 1747 } |
1746 | 1748 |
1747 void HTMLMediaElement::finishSeek() | 1749 void HTMLMediaElement::finishSeek() |
1748 { | 1750 { |
1749 WTF_LOG(Media, "HTMLMediaElement::finishSeek(%p)", this); | 1751 DVLOG(LOG_LEVEL) << "finishSeek"; |
1750 | 1752 |
1751 // 14 - Set the seeking IDL attribute to false. | 1753 // 14 - Set the seeking IDL attribute to false. |
1752 m_seeking = false; | 1754 m_seeking = false; |
1753 | 1755 |
1754 // 16 - Queue a task to fire a simple event named timeupdate at the element. | 1756 // 16 - Queue a task to fire a simple event named timeupdate at the element. |
1755 scheduleTimeupdateEvent(false); | 1757 scheduleTimeupdateEvent(false); |
1756 | 1758 |
1757 // 17 - Queue a task to fire a simple event named seeked at the element. | 1759 // 17 - Queue a task to fire a simple event named seeked at the element. |
1758 scheduleEvent(EventTypeNames::seeked); | 1760 scheduleEvent(EventTypeNames::seeked); |
1759 | 1761 |
(...skipping 25 matching lines...) Expand all Loading... | |
1785 void HTMLMediaElement::refreshCachedTime() const | 1787 void HTMLMediaElement::refreshCachedTime() const |
1786 { | 1788 { |
1787 if (!webMediaPlayer() || m_readyState < HAVE_METADATA) | 1789 if (!webMediaPlayer() || m_readyState < HAVE_METADATA) |
1788 return; | 1790 return; |
1789 | 1791 |
1790 m_cachedTime = webMediaPlayer()->currentTime(); | 1792 m_cachedTime = webMediaPlayer()->currentTime(); |
1791 } | 1793 } |
1792 | 1794 |
1793 void HTMLMediaElement::invalidateCachedTime() | 1795 void HTMLMediaElement::invalidateCachedTime() |
1794 { | 1796 { |
1795 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime(%p)", this); | 1797 DVLOG(LOG_LEVEL) << "invalidateCachedTime"; |
1796 m_cachedTime = std::numeric_limits<double>::quiet_NaN(); | 1798 m_cachedTime = std::numeric_limits<double>::quiet_NaN(); |
1797 } | 1799 } |
1798 | 1800 |
1799 // playback state | 1801 // playback state |
1800 double HTMLMediaElement::currentTime() const | 1802 double HTMLMediaElement::currentTime() const |
1801 { | 1803 { |
1802 if (m_defaultPlaybackStartPosition) | 1804 if (m_defaultPlaybackStartPosition) |
1803 return m_defaultPlaybackStartPosition; | 1805 return m_defaultPlaybackStartPosition; |
1804 | 1806 |
1805 if (m_readyState == HAVE_NOTHING) | 1807 if (m_readyState == HAVE_NOTHING) |
1806 return 0; | 1808 return 0; |
1807 | 1809 |
1808 if (m_seeking) { | 1810 if (m_seeking) { |
1809 WTF_LOG(Media, "HTMLMediaElement::currentTime(%p) - seeking, returning % f", this, m_lastSeekTime); | 1811 DVLOG(LOG_LEVEL) << "currentTime - seeking, returning " << m_lastSeekTim e; |
1810 return m_lastSeekTime; | 1812 return m_lastSeekTime; |
1811 } | 1813 } |
1812 | 1814 |
1813 if (!std::isnan(m_cachedTime) && m_paused) { | 1815 if (!std::isnan(m_cachedTime) && m_paused) { |
1814 #if LOG_CACHED_TIME_WARNINGS | 1816 #if LOG_CACHED_TIME_WARNINGS |
1815 static const double minCachedDeltaForWarning = 0.01; | 1817 static const double minCachedDeltaForWarning = 0.01; |
1816 double delta = m_cachedTime - webMediaPlayer()->currentTime(); | 1818 double delta = m_cachedTime - webMediaPlayer()->currentTime(); |
1817 if (delta > minCachedDeltaForWarning) | 1819 if (delta > minCachedDeltaForWarning) |
1818 WTF_LOG(Media, "HTMLMediaElement::currentTime(%p) - WARNING, cached time is %f seconds off of media time when paused", this, delta); | 1820 DVLOG(LOG_LEVEL) << "currentTime - WARNING, cached time is " << delt a << "seconds off of media time when paused"; |
1819 #endif | 1821 #endif |
1820 return m_cachedTime; | 1822 return m_cachedTime; |
1821 } | 1823 } |
1822 | 1824 |
1823 refreshCachedTime(); | 1825 refreshCachedTime(); |
1824 | 1826 |
1825 return m_cachedTime; | 1827 return m_cachedTime; |
1826 } | 1828 } |
1827 | 1829 |
1828 void HTMLMediaElement::setCurrentTime(double time) | 1830 void HTMLMediaElement::setCurrentTime(double time) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1880 scheduleEvent(EventTypeNames::ratechange); | 1882 scheduleEvent(EventTypeNames::ratechange); |
1881 } | 1883 } |
1882 | 1884 |
1883 double HTMLMediaElement::playbackRate() const | 1885 double HTMLMediaElement::playbackRate() const |
1884 { | 1886 { |
1885 return m_playbackRate; | 1887 return m_playbackRate; |
1886 } | 1888 } |
1887 | 1889 |
1888 void HTMLMediaElement::setPlaybackRate(double rate) | 1890 void HTMLMediaElement::setPlaybackRate(double rate) |
1889 { | 1891 { |
1890 WTF_LOG(Media, "HTMLMediaElement::setPlaybackRate(%p, %f)", this, rate); | 1892 DVLOG(LOG_LEVEL) << "setPlaybackRate(" << rate << ")"; |
1891 | 1893 |
1892 if (m_playbackRate != rate) { | 1894 if (m_playbackRate != rate) { |
1893 m_playbackRate = rate; | 1895 m_playbackRate = rate; |
1894 invalidateCachedTime(); | 1896 invalidateCachedTime(); |
1895 scheduleEvent(EventTypeNames::ratechange); | 1897 scheduleEvent(EventTypeNames::ratechange); |
1896 } | 1898 } |
1897 | 1899 |
1898 updatePlaybackRate(); | 1900 updatePlaybackRate(); |
1899 } | 1901 } |
1900 | 1902 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1940 return false; | 1942 return false; |
1941 } | 1943 } |
1942 | 1944 |
1943 String HTMLMediaElement::preload() const | 1945 String HTMLMediaElement::preload() const |
1944 { | 1946 { |
1945 return preloadTypeToString(preloadType()); | 1947 return preloadTypeToString(preloadType()); |
1946 } | 1948 } |
1947 | 1949 |
1948 void HTMLMediaElement::setPreload(const AtomicString& preload) | 1950 void HTMLMediaElement::setPreload(const AtomicString& preload) |
1949 { | 1951 { |
1950 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8(). data()); | 1952 DVLOG(LOG_LEVEL) << "setPreload(" << preload.utf8().data() << ")"; |
1951 setAttribute(preloadAttr, preload); | 1953 setAttribute(preloadAttr, preload); |
1952 } | 1954 } |
1953 | 1955 |
1954 WebMediaPlayer::Preload HTMLMediaElement::preloadType() const | 1956 WebMediaPlayer::Preload HTMLMediaElement::preloadType() const |
1955 { | 1957 { |
1956 // Force preload to none for cellular connections. | 1958 // Force preload to none for cellular connections. |
1957 if (networkStateNotifier().isCellularConnectionType()) { | 1959 if (networkStateNotifier().isCellularConnectionType()) { |
1958 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadForcedN one); | 1960 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadForcedN one); |
1959 return WebMediaPlayer::PreloadNone; | 1961 return WebMediaPlayer::PreloadNone; |
1960 } | 1962 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2023 | 2025 |
2024 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | 2026 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; |
2025 ScriptPromise promise = resolver->promise(); | 2027 ScriptPromise promise = resolver->promise(); |
2026 | 2028 |
2027 m_playResolvers.append(resolver); | 2029 m_playResolvers.append(resolver); |
2028 return promise; | 2030 return promise; |
2029 } | 2031 } |
2030 | 2032 |
2031 Nullable<ExceptionCode> HTMLMediaElement::play() | 2033 Nullable<ExceptionCode> HTMLMediaElement::play() |
2032 { | 2034 { |
2033 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); | 2035 DVLOG(LOG_LEVEL) << "play"; |
2034 | 2036 |
2035 m_autoplayHelper->playMethodCalled(); | 2037 m_autoplayHelper->playMethodCalled(); |
2036 | 2038 |
2037 if (!UserGestureIndicator::processingUserGesture()) { | 2039 if (!UserGestureIndicator::processingUserGesture()) { |
2038 if (m_userGestureRequiredForPlay) { | 2040 if (m_userGestureRequiredForPlay) { |
2039 recordAutoplayMetric(PlayMethodFailed); | 2041 recordAutoplayMetric(PlayMethodFailed); |
2040 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); | 2042 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); |
2041 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); | 2043 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); |
2042 return NotAllowedError; | 2044 return NotAllowedError; |
2043 } | 2045 } |
2044 } else { | 2046 } else { |
2045 UserGestureIndicator::utilizeUserGesture(); | 2047 UserGestureIndicator::utilizeUserGesture(); |
2046 // We ask the helper to remove the gesture requirement for us, so that | 2048 // We ask the helper to remove the gesture requirement for us, so that |
2047 // it can record the reason. | 2049 // it can record the reason. |
2048 Platform::current()->recordAction(UserMetricsAction("Media_Play_WithGest ure")); | 2050 Platform::current()->recordAction(UserMetricsAction("Media_Play_WithGest ure")); |
2049 m_autoplayHelper->removeUserGestureRequirement(GesturelessPlaybackEnable dByPlayMethod); | 2051 m_autoplayHelper->removeUserGestureRequirement(GesturelessPlaybackEnable dByPlayMethod); |
2050 } | 2052 } |
2051 | 2053 |
2052 if (m_error && m_error->code() == MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED) | 2054 if (m_error && m_error->code() == MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED) |
2053 return NotSupportedError; | 2055 return NotSupportedError; |
2054 | 2056 |
2055 playInternal(); | 2057 playInternal(); |
2056 | 2058 |
2057 return nullptr; | 2059 return nullptr; |
2058 } | 2060 } |
2059 | 2061 |
2060 void HTMLMediaElement::playInternal() | 2062 void HTMLMediaElement::playInternal() |
2061 { | 2063 { |
2062 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); | 2064 DVLOG(LOG_LEVEL) << "playInternal"; |
2063 | 2065 |
2064 // Always return the buffering strategy to normal when not paused, | 2066 // Always return the buffering strategy to normal when not paused, |
2065 // regardless of the cause. (In contrast with aggressive buffering which is | 2067 // regardless of the cause. (In contrast with aggressive buffering which is |
2066 // only enabled by pause(), not pauseInternal().) | 2068 // only enabled by pause(), not pauseInternal().) |
2067 if (webMediaPlayer()) | 2069 if (webMediaPlayer()) |
2068 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal); | 2070 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal); |
2069 | 2071 |
2070 // 4.8.10.9. Playing the media resource | 2072 // 4.8.10.9. Playing the media resource |
2071 if (m_networkState == NETWORK_EMPTY) | 2073 if (m_networkState == NETWORK_EMPTY) |
2072 invokeResourceSelectionAlgorithm(); | 2074 invokeResourceSelectionAlgorithm(); |
(...skipping 18 matching lines...) Expand all Loading... | |
2091 } | 2093 } |
2092 | 2094 |
2093 m_autoplaying = false; | 2095 m_autoplaying = false; |
2094 | 2096 |
2095 setIgnorePreloadNone(); | 2097 setIgnorePreloadNone(); |
2096 updatePlayState(); | 2098 updatePlayState(); |
2097 } | 2099 } |
2098 | 2100 |
2099 void HTMLMediaElement::pause() | 2101 void HTMLMediaElement::pause() |
2100 { | 2102 { |
2101 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this); | 2103 DVLOG(LOG_LEVEL) << "pause"; |
2102 | 2104 |
2103 // Only buffer aggressively on a user-initiated pause. Other types of pauses | 2105 // Only buffer aggressively on a user-initiated pause. Other types of pauses |
2104 // (which go directly to pauseInternal()) should not cause this behavior. | 2106 // (which go directly to pauseInternal()) should not cause this behavior. |
2105 if (webMediaPlayer() && UserGestureIndicator::utilizeUserGesture()) | 2107 if (webMediaPlayer() && UserGestureIndicator::utilizeUserGesture()) |
2106 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Aggressive); | 2108 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Aggressive); |
2107 | 2109 |
2108 pauseInternal(); | 2110 pauseInternal(); |
2109 } | 2111 } |
2110 | 2112 |
2111 void HTMLMediaElement::pauseInternal() | 2113 void HTMLMediaElement::pauseInternal() |
2112 { | 2114 { |
2113 WTF_LOG(Media, "HTMLMediaElement::pauseInternal(%p)", this); | 2115 DVLOG(LOG_LEVEL) << "pauseInternal"; |
2114 | 2116 |
2115 if (m_networkState == NETWORK_EMPTY) | 2117 if (m_networkState == NETWORK_EMPTY) |
2116 invokeResourceSelectionAlgorithm(); | 2118 invokeResourceSelectionAlgorithm(); |
2117 | 2119 |
2118 m_autoplayHelper->pauseMethodCalled(); | 2120 m_autoplayHelper->pauseMethodCalled(); |
2119 | 2121 |
2120 m_autoplaying = false; | 2122 m_autoplaying = false; |
2121 | 2123 |
2122 if (!m_paused) { | 2124 if (!m_paused) { |
2123 m_paused = true; | 2125 m_paused = true; |
(...skipping 28 matching lines...) Expand all Loading... | |
2152 m_mediaSource = nullptr; | 2154 m_mediaSource = nullptr; |
2153 } | 2155 } |
2154 | 2156 |
2155 bool HTMLMediaElement::loop() const | 2157 bool HTMLMediaElement::loop() const |
2156 { | 2158 { |
2157 return fastHasAttribute(loopAttr); | 2159 return fastHasAttribute(loopAttr); |
2158 } | 2160 } |
2159 | 2161 |
2160 void HTMLMediaElement::setLoop(bool b) | 2162 void HTMLMediaElement::setLoop(bool b) |
2161 { | 2163 { |
2162 WTF_LOG(Media, "HTMLMediaElement::setLoop(%p, %s)", this, boolString(b)); | 2164 DVLOG(LOG_LEVEL) << "setLoop(" << boolString(b) << ")"; |
2163 setBooleanAttribute(loopAttr, b); | 2165 setBooleanAttribute(loopAttr, b); |
2164 } | 2166 } |
2165 | 2167 |
2166 bool HTMLMediaElement::shouldShowControls(const RecordMetricsBehavior recordMetr ics) const | 2168 bool HTMLMediaElement::shouldShowControls(const RecordMetricsBehavior recordMetr ics) const |
2167 { | 2169 { |
2168 DEFINE_STATIC_LOCAL(EnumerationHistogram, showControlsHistogram, ("Media.Con trols.Show", MediaControlsShowMax)); | 2170 DEFINE_STATIC_LOCAL(EnumerationHistogram, showControlsHistogram, ("Media.Con trols.Show", MediaControlsShowMax)); |
2169 | 2171 |
2170 if (fastHasAttribute(controlsAttr)) { | 2172 if (fastHasAttribute(controlsAttr)) { |
2171 if (recordMetrics == RecordMetricsBehavior::DoRecord) | 2173 if (recordMetrics == RecordMetricsBehavior::DoRecord) |
2172 showControlsHistogram.count(MediaControlsShowAttribute); | 2174 showControlsHistogram.count(MediaControlsShowAttribute); |
(...skipping 18 matching lines...) Expand all Loading... | |
2191 return false; | 2193 return false; |
2192 } | 2194 } |
2193 | 2195 |
2194 double HTMLMediaElement::volume() const | 2196 double HTMLMediaElement::volume() const |
2195 { | 2197 { |
2196 return m_volume; | 2198 return m_volume; |
2197 } | 2199 } |
2198 | 2200 |
2199 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState) | 2201 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState) |
2200 { | 2202 { |
2201 WTF_LOG(Media, "HTMLMediaElement::setVolume(%p, %f)", this, vol); | 2203 DVLOG(LOG_LEVEL) << "setVolume(" << vol << ")"; |
2202 | 2204 |
2203 if (m_volume == vol) | 2205 if (m_volume == vol) |
2204 return; | 2206 return; |
2205 | 2207 |
2206 if (vol < 0.0f || vol > 1.0f) { | 2208 if (vol < 0.0f || vol > 1.0f) { |
2207 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", vol, 0.0, ExceptionMessages::InclusiveBound, 1.0, Except ionMessages::InclusiveBound)); | 2209 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", vol, 0.0, ExceptionMessages::InclusiveBound, 1.0, Except ionMessages::InclusiveBound)); |
2208 return; | 2210 return; |
2209 } | 2211 } |
2210 | 2212 |
2211 Platform::current()->recordAction(UserMetricsAction("Media_SetVolume")); | 2213 Platform::current()->recordAction(UserMetricsAction("Media_SetVolume")); |
2212 | 2214 |
2213 m_volume = vol; | 2215 m_volume = vol; |
2214 updateVolume(); | 2216 updateVolume(); |
2215 scheduleEvent(EventTypeNames::volumechange); | 2217 scheduleEvent(EventTypeNames::volumechange); |
2216 } | 2218 } |
2217 | 2219 |
2218 bool HTMLMediaElement::muted() const | 2220 bool HTMLMediaElement::muted() const |
2219 { | 2221 { |
2220 return m_muted; | 2222 return m_muted; |
2221 } | 2223 } |
2222 | 2224 |
2223 void HTMLMediaElement::setMuted(bool muted) | 2225 void HTMLMediaElement::setMuted(bool muted) |
2224 { | 2226 { |
2225 WTF_LOG(Media, "HTMLMediaElement::setMuted(%p, %s)", this, boolString(muted) ); | 2227 DVLOG(LOG_LEVEL) << "setMuted(" << boolString(muted) << ")"; |
2226 | 2228 |
2227 if (m_muted == muted) | 2229 if (m_muted == muted) |
2228 return; | 2230 return; |
2229 | 2231 |
2230 m_muted = muted; | 2232 m_muted = muted; |
2231 | 2233 |
2232 m_autoplayHelper->mutedChanged(); | 2234 m_autoplayHelper->mutedChanged(); |
2233 | 2235 |
2234 updateVolume(); | 2236 updateVolume(); |
2235 | 2237 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2321 } | 2323 } |
2322 | 2324 |
2323 AudioTrackList& HTMLMediaElement::audioTracks() | 2325 AudioTrackList& HTMLMediaElement::audioTracks() |
2324 { | 2326 { |
2325 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2327 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
2326 return *m_audioTracks; | 2328 return *m_audioTracks; |
2327 } | 2329 } |
2328 | 2330 |
2329 void HTMLMediaElement::audioTrackChanged(WebMediaPlayer::TrackId trackId, bool e nabled) | 2331 void HTMLMediaElement::audioTrackChanged(WebMediaPlayer::TrackId trackId, bool e nabled) |
2330 { | 2332 { |
2331 WTF_LOG(Media, "HTMLMediaElement::audioTrackChanged(%p) trackId=%u enabled=% d", this, trackId, enabled); | 2333 DVLOG(LOG_LEVEL) << "audioTrackChanged trackId= " << trackId << " enabled=" << enabled; |
fs
2016/05/18 13:24:36
boolString(enabled)?
Srirama
2016/05/18 13:55:01
Done.
| |
2332 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2334 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
2333 | 2335 |
2334 audioTracks().scheduleChangeEvent(); | 2336 audioTracks().scheduleChangeEvent(); |
2335 | 2337 |
2336 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.audioTracks attribute is added. | 2338 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.audioTracks attribute is added. |
2337 | 2339 |
2338 if (!m_audioTracksTimer.isActive()) | 2340 if (!m_audioTracksTimer.isActive()) |
2339 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE); | 2341 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE); |
2340 } | 2342 } |
2341 | 2343 |
2342 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) | 2344 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) |
2343 { | 2345 { |
2344 Vector<WebMediaPlayer::TrackId> enabledTrackIds; | 2346 Vector<WebMediaPlayer::TrackId> enabledTrackIds; |
2345 for (unsigned i = 0; i < audioTracks().length(); ++i) { | 2347 for (unsigned i = 0; i < audioTracks().length(); ++i) { |
2346 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); | 2348 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); |
2347 if (track->enabled()) | 2349 if (track->enabled()) |
2348 enabledTrackIds.append(track->trackId()); | 2350 enabledTrackIds.append(track->trackId()); |
2349 } | 2351 } |
2350 | 2352 |
2351 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); | 2353 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); |
2352 } | 2354 } |
2353 | 2355 |
2354 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, Web MediaPlayerClient::AudioTrackKind kind, const WebString& label, const WebString& language, bool enabled) | 2356 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, Web MediaPlayerClient::AudioTrackKind kind, const WebString& label, const WebString& language, bool enabled) |
2355 { | 2357 { |
2356 AtomicString kindString = AudioKindToString(kind); | 2358 AtomicString kindString = AudioKindToString(kind); |
2357 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)", | 2359 DVLOG(LOG_LEVEL) << "addAudioTrack('" << id.utf8().data() << "', ' " << kind String.ascii().data() |
2358 this, id.utf8().data(), kindString.ascii().data(), label.utf8().data(), language.utf8().data(), enabled); | 2360 << "', '" << label.utf8().data() << "', '" << language.utf8().data() << "', " << enabled << ")"; |
fs
2016/05/18 13:24:36
Ditto.
Srirama
2016/05/18 13:55:00
Done.
| |
2359 | 2361 |
2360 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2362 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
2361 return 0; | 2363 return 0; |
2362 | 2364 |
2363 AudioTrack* audioTrack = AudioTrack::create(id, kindString, label, language, enabled); | 2365 AudioTrack* audioTrack = AudioTrack::create(id, kindString, label, language, enabled); |
2364 audioTracks().add(audioTrack); | 2366 audioTracks().add(audioTrack); |
2365 | 2367 |
2366 return audioTrack->trackId(); | 2368 return audioTrack->trackId(); |
2367 } | 2369 } |
2368 | 2370 |
2369 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) | 2371 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) |
2370 { | 2372 { |
2371 WTF_LOG(Media, "HTMLMediaElement::removeAudioTrack(%p)", this); | 2373 DVLOG(LOG_LEVEL) << "removeAudioTrack"; |
2372 | 2374 |
2373 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2375 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
2374 return; | 2376 return; |
2375 | 2377 |
2376 audioTracks().remove(trackId); | 2378 audioTracks().remove(trackId); |
2377 } | 2379 } |
2378 | 2380 |
2379 VideoTrackList& HTMLMediaElement::videoTracks() | 2381 VideoTrackList& HTMLMediaElement::videoTracks() |
2380 { | 2382 { |
2381 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2383 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
2382 return *m_videoTracks; | 2384 return *m_videoTracks; |
2383 } | 2385 } |
2384 | 2386 |
2385 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select edTrackId) | 2387 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select edTrackId) |
2386 { | 2388 { |
2387 WTF_LOG(Media, "HTMLMediaElement::selectedVideoTrackChanged(%p) selectedTrac kId=%s", this, selectedTrackId ? String::format("%u", *selectedTrackId).ascii(). data() : "none"); | 2389 DVLOG(LOG_LEVEL) << "selectedVideoTrackChanged selectedTrackId=" << (selecte dTrackId ? String::format("%u", *selectedTrackId).ascii().data() : "none"); |
2388 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2390 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
2389 | 2391 |
2390 if (selectedTrackId) | 2392 if (selectedTrackId) |
2391 videoTracks().trackSelected(*selectedTrackId); | 2393 videoTracks().trackSelected(*selectedTrackId); |
2392 | 2394 |
2393 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. | 2395 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. |
2394 | 2396 |
2395 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); | 2397 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); |
2396 } | 2398 } |
2397 | 2399 |
2398 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, Web MediaPlayerClient::VideoTrackKind kind, const WebString& label, const WebString& language, bool selected) | 2400 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, Web MediaPlayerClient::VideoTrackKind kind, const WebString& label, const WebString& language, bool selected) |
2399 { | 2401 { |
2400 AtomicString kindString = VideoKindToString(kind); | 2402 AtomicString kindString = VideoKindToString(kind); |
2401 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)", | 2403 DVLOG(LOG_LEVEL) << "addVideoTrack('" << id.utf8().data() << "', '" << kindS tring.ascii().data() |
2402 this, id.utf8().data(), kindString.ascii().data(), label.utf8().data(), language.utf8().data(), selected); | 2404 << "', '" << label.utf8().data() << "', '" << language.utf8().data() << "', " << selected << ")"; |
fs
2016/05/18 13:24:36
boolString(selected)
Srirama
2016/05/18 13:55:01
Done.
| |
2403 | 2405 |
2404 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2406 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
2405 return 0; | 2407 return 0; |
2406 | 2408 |
2407 // If another track was selected (potentially by the user), leave it selecte d. | 2409 // If another track was selected (potentially by the user), leave it selecte d. |
2408 if (selected && videoTracks().selectedIndex() != -1) | 2410 if (selected && videoTracks().selectedIndex() != -1) |
2409 selected = false; | 2411 selected = false; |
2410 | 2412 |
2411 VideoTrack* videoTrack = VideoTrack::create(id, kindString, label, language, selected); | 2413 VideoTrack* videoTrack = VideoTrack::create(id, kindString, label, language, selected); |
2412 videoTracks().add(videoTrack); | 2414 videoTracks().add(videoTrack); |
2413 | 2415 |
2414 return videoTrack->trackId(); | 2416 return videoTrack->trackId(); |
2415 } | 2417 } |
2416 | 2418 |
2417 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) | 2419 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) |
2418 { | 2420 { |
2419 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this); | 2421 DVLOG(LOG_LEVEL) << "removeVideoTrack"; |
2420 | 2422 |
2421 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2423 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
2422 return; | 2424 return; |
2423 | 2425 |
2424 videoTracks().remove(trackId); | 2426 videoTracks().remove(trackId); |
2425 } | 2427 } |
2426 | 2428 |
2427 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) | 2429 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) |
2428 { | 2430 { |
2429 // 4.8.10.12.2 Sourcing in-band text tracks | 2431 // 4.8.10.12.2 Sourcing in-band text tracks |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2567 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks | 2569 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks |
2568 // in the markup have been added. | 2570 // in the markup have been added. |
2569 if (isFinishedParsingChildren()) | 2571 if (isFinishedParsingChildren()) |
2570 scheduleTextTrackResourceLoad(); | 2572 scheduleTextTrackResourceLoad(); |
2571 } | 2573 } |
2572 | 2574 |
2573 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) | 2575 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) |
2574 { | 2576 { |
2575 #if !LOG_DISABLED | 2577 #if !LOG_DISABLED |
2576 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); | 2578 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); |
2577 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); | 2579 DVLOG(LOG_LEVEL) << "didRemoveTrackElement - 'src' is " << urlForLoggingMedi a(url).utf8().data(); |
2578 #endif | 2580 #endif |
2579 | 2581 |
2580 TextTrack* textTrack = trackElement->track(); | 2582 TextTrack* textTrack = trackElement->track(); |
2581 if (!textTrack) | 2583 if (!textTrack) |
2582 return; | 2584 return; |
2583 | 2585 |
2584 textTrack->setHasBeenConfigured(false); | 2586 textTrack->setHasBeenConfigured(false); |
2585 | 2587 |
2586 if (!m_textTracks) | 2588 if (!m_textTracks) |
2587 return; | 2589 return; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2631 KURL nextURL = selectNextSourceChild(0, DoNothing); | 2633 KURL nextURL = selectNextSourceChild(0, DoNothing); |
2632 | 2634 |
2633 m_currentSourceNode = currentSourceNode; | 2635 m_currentSourceNode = currentSourceNode; |
2634 m_nextChildNodeToConsider = nextNode; | 2636 m_nextChildNodeToConsider = nextNode; |
2635 | 2637 |
2636 return nextURL.isValid(); | 2638 return nextURL.isValid(); |
2637 } | 2639 } |
2638 | 2640 |
2639 KURL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, InvalidUR LAction actionIfInvalid) | 2641 KURL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, InvalidUR LAction actionIfInvalid) |
2640 { | 2642 { |
2641 #if !LOG_DISABLED | 2643 #if !LOG_DISABLED |
fs
2016/05/18 13:24:36
Not sure how useful this is now, but that can be c
Srirama
2016/05/18 13:55:01
Acknowledged.
| |
2642 // Don't log if this was just called to find out if there are any valid <sou rce> elements. | 2644 // Don't log if this was just called to find out if there are any valid <sou rce> elements. |
2643 bool shouldLog = actionIfInvalid != DoNothing; | 2645 bool shouldLog = actionIfInvalid != DoNothing; |
2644 if (shouldLog) | 2646 if (shouldLog) |
2645 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p)", this); | 2647 DVLOG(LOG_LEVEL) << "selectNextSourceChild"; |
2646 #endif | 2648 #endif |
2647 | 2649 |
2648 if (!m_nextChildNodeToConsider) { | 2650 if (!m_nextChildNodeToConsider) { |
2649 #if !LOG_DISABLED | 2651 #if !LOG_DISABLED |
2650 if (shouldLog) | 2652 if (shouldLog) |
2651 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) -> 0x000 0, \"\"", this); | 2653 DVLOG(LOG_LEVEL) << "selectNextSourceChild -> 0x0000, \"\""; |
2652 #endif | 2654 #endif |
2653 return KURL(); | 2655 return KURL(); |
2654 } | 2656 } |
2655 | 2657 |
2656 KURL mediaURL; | 2658 KURL mediaURL; |
2657 Node* node; | 2659 Node* node; |
2658 HTMLSourceElement* source = 0; | 2660 HTMLSourceElement* source = 0; |
2659 String type; | 2661 String type; |
2660 bool lookingForStartNode = m_nextChildNodeToConsider; | 2662 bool lookingForStartNode = m_nextChildNodeToConsider; |
2661 bool canUseSourceElement = false; | 2663 bool canUseSourceElement = false; |
(...skipping 13 matching lines...) Expand all Loading... | |
2675 continue; | 2677 continue; |
2676 | 2678 |
2677 source = toHTMLSourceElement(node); | 2679 source = toHTMLSourceElement(node); |
2678 | 2680 |
2679 // 2. If candidate does not have a src attribute, or if its src | 2681 // 2. If candidate does not have a src attribute, or if its src |
2680 // attribute's value is the empty string ... jump down to the failed | 2682 // attribute's value is the empty string ... jump down to the failed |
2681 // step below | 2683 // step below |
2682 const AtomicString& srcValue = source->fastGetAttribute(srcAttr); | 2684 const AtomicString& srcValue = source->fastGetAttribute(srcAttr); |
2683 #if !LOG_DISABLED | 2685 #if !LOG_DISABLED |
2684 if (shouldLog) | 2686 if (shouldLog) |
2685 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 'src' is %s", this, urlForLoggingMedia(mediaURL).utf8().data()); | 2687 DVLOG(LOG_LEVEL) << "selectNextSourceChild - 'src' is " << urlForLog gingMedia(mediaURL).utf8().data(); |
2686 #endif | 2688 #endif |
2687 if (srcValue.isEmpty()) | 2689 if (srcValue.isEmpty()) |
2688 goto checkAgain; | 2690 goto checkAgain; |
2689 | 2691 |
2690 // 3. Let urlString be the resulting URL string that would have resulted | 2692 // 3. Let urlString be the resulting URL string that would have resulted |
2691 // from parsing the URL specified by candidate's src attribute's value | 2693 // from parsing the URL specified by candidate's src attribute's value |
2692 // relative to the candidate's node document when the src attribute was | 2694 // relative to the candidate's node document when the src attribute was |
2693 // last changed. | 2695 // last changed. |
2694 mediaURL = source->document().completeURL(srcValue); | 2696 mediaURL = source->document().completeURL(srcValue); |
2695 | 2697 |
2696 // 4. If urlString was not obtained successfully, then end the | 2698 // 4. If urlString was not obtained successfully, then end the |
2697 // synchronous section, and jump down to the failed with elements step | 2699 // synchronous section, and jump down to the failed with elements step |
2698 // below. | 2700 // below. |
2699 if (!isSafeToLoadURL(mediaURL, actionIfInvalid)) | 2701 if (!isSafeToLoadURL(mediaURL, actionIfInvalid)) |
2700 goto checkAgain; | 2702 goto checkAgain; |
2701 | 2703 |
2702 // 5. If candidate has a type attribute whose value, when parsed as a | 2704 // 5. If candidate has a type attribute whose value, when parsed as a |
2703 // MIME type ... | 2705 // MIME type ... |
2704 type = source->type(); | 2706 type = source->type(); |
2705 if (type.isEmpty() && mediaURL.protocolIsData()) | 2707 if (type.isEmpty() && mediaURL.protocolIsData()) |
2706 type = mimeTypeFromDataURL(mediaURL); | 2708 type = mimeTypeFromDataURL(mediaURL); |
2707 if (!type.isEmpty()) { | 2709 if (!type.isEmpty()) { |
2708 #if !LOG_DISABLED | 2710 #if !LOG_DISABLED |
2709 if (shouldLog) | 2711 if (shouldLog) |
2710 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 't ype' is '%s'", this, type.utf8().data()); | 2712 DVLOG(LOG_LEVEL) << "selectNextSourceChild - 'type' is '" << typ e.utf8().data() << "'"; |
2711 #endif | 2713 #endif |
2712 if (!supportsType(ContentType(type))) | 2714 if (!supportsType(ContentType(type))) |
2713 goto checkAgain; | 2715 goto checkAgain; |
2714 } | 2716 } |
2715 | 2717 |
2716 // Making it this far means the <source> looks reasonable. | 2718 // Making it this far means the <source> looks reasonable. |
2717 canUseSourceElement = true; | 2719 canUseSourceElement = true; |
2718 | 2720 |
2719 checkAgain: | 2721 checkAgain: |
2720 if (!canUseSourceElement && actionIfInvalid == Complain && source) | 2722 if (!canUseSourceElement && actionIfInvalid == Complain && source) |
2721 source->scheduleErrorEvent(); | 2723 source->scheduleErrorEvent(); |
2722 } | 2724 } |
2723 | 2725 |
2724 if (canUseSourceElement) { | 2726 if (canUseSourceElement) { |
2725 if (contentType) | 2727 if (contentType) |
2726 *contentType = ContentType(type); | 2728 *contentType = ContentType(type); |
2727 m_currentSourceNode = source; | 2729 m_currentSourceNode = source; |
2728 m_nextChildNodeToConsider = source->nextSibling(); | 2730 m_nextChildNodeToConsider = source->nextSibling(); |
2729 } else { | 2731 } else { |
2730 m_currentSourceNode = nullptr; | 2732 m_currentSourceNode = nullptr; |
2731 m_nextChildNodeToConsider = nullptr; | 2733 m_nextChildNodeToConsider = nullptr; |
2732 } | 2734 } |
2733 | 2735 |
2734 #if !LOG_DISABLED | 2736 #if !LOG_DISABLED |
2735 if (shouldLog) | 2737 if (shouldLog) |
2736 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) -> %p, %s", this, m_currentSourceNode.get(), canUseSourceElement ? urlForLoggingMedia(mediaU RL).utf8().data() : ""); | 2738 DVLOG(LOG_LEVEL) << "selectNextSourceChild -> " << m_currentSourceNode.g et() << ", " << (canUseSourceElement ? urlForLoggingMedia(mediaURL).utf8().data( ) : ""); |
2737 #endif | 2739 #endif |
2738 return canUseSourceElement ? mediaURL : KURL(); | 2740 return canUseSourceElement ? mediaURL : KURL(); |
2739 } | 2741 } |
2740 | 2742 |
2741 void HTMLMediaElement::sourceWasAdded(HTMLSourceElement* source) | 2743 void HTMLMediaElement::sourceWasAdded(HTMLSourceElement* source) |
2742 { | 2744 { |
2743 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded(%p, %p)", this, source); | 2745 DVLOG(LOG_LEVEL) << "sourceWasAdded(" << source << ")"; |
2744 | 2746 |
2745 #if !LOG_DISABLED | 2747 #if !LOG_DISABLED |
2746 KURL url = source->getNonEmptyURLAttribute(srcAttr); | 2748 KURL url = source->getNonEmptyURLAttribute(srcAttr); |
2747 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - 'src' is %s", this, u rlForLoggingMedia(url).utf8().data()); | 2749 DVLOG(LOG_LEVEL) << "sourceWasAdded - 'src' is " << urlForLoggingMedia(url). utf8().data(); |
2748 #endif | 2750 #endif |
2749 | 2751 |
2750 // We should only consider a <source> element when there is not src attribut e at all. | 2752 // We should only consider a <source> element when there is not src attribut e at all. |
2751 if (fastHasAttribute(srcAttr)) | 2753 if (fastHasAttribute(srcAttr)) |
2752 return; | 2754 return; |
2753 | 2755 |
2754 // 4.8.8 - If a source element is inserted as a child of a media element tha t has no src | 2756 // 4.8.8 - If a source element is inserted as a child of a media element tha t has no src |
2755 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag ent must invoke | 2757 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag ent must invoke |
2756 // the media element's resource selection algorithm. | 2758 // the media element's resource selection algorithm. |
2757 if (getNetworkState() == HTMLMediaElement::NETWORK_EMPTY) { | 2759 if (getNetworkState() == HTMLMediaElement::NETWORK_EMPTY) { |
2758 invokeResourceSelectionAlgorithm(); | 2760 invokeResourceSelectionAlgorithm(); |
2759 // Ignore current |m_nextChildNodeToConsider| and consider |source|. | 2761 // Ignore current |m_nextChildNodeToConsider| and consider |source|. |
2760 m_nextChildNodeToConsider = source; | 2762 m_nextChildNodeToConsider = source; |
2761 return; | 2763 return; |
2762 } | 2764 } |
2763 | 2765 |
2764 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) { | 2766 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) { |
2765 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - <source> inserted immediately after current source", this); | 2767 DVLOG(LOG_LEVEL) << "sourceWasAdded - <source> inserted immediately afte r current source"; |
2766 // Ignore current |m_nextChildNodeToConsider| and consider |source|. | 2768 // Ignore current |m_nextChildNodeToConsider| and consider |source|. |
2767 m_nextChildNodeToConsider = source; | 2769 m_nextChildNodeToConsider = source; |
2768 return; | 2770 return; |
2769 } | 2771 } |
2770 | 2772 |
2771 // Consider current |m_nextChildNodeToConsider| as it is already in the midd le of processing. | 2773 // Consider current |m_nextChildNodeToConsider| as it is already in the midd le of processing. |
2772 if (m_nextChildNodeToConsider) | 2774 if (m_nextChildNodeToConsider) |
2773 return; | 2775 return; |
2774 | 2776 |
2775 if (m_loadState != WaitingForSource) | 2777 if (m_loadState != WaitingForSource) |
2776 return; | 2778 return; |
2777 | 2779 |
2778 // 4.8.9.5, resource selection algorithm, source elements section: | 2780 // 4.8.9.5, resource selection algorithm, source elements section: |
2779 // 21. Wait until the node after pointer is a node other than the end of the list. (This step might wait forever.) | 2781 // 21. Wait until the node after pointer is a node other than the end of the list. (This step might wait forever.) |
2780 // 22. Asynchronously await a stable state... | 2782 // 22. Asynchronously await a stable state... |
2781 // 23. Set the element's delaying-the-load-event flag back to true (this del ays the load event again, in case | 2783 // 23. Set the element's delaying-the-load-event flag back to true (this del ays the load event again, in case |
2782 // it hasn't been fired yet). | 2784 // it hasn't been fired yet). |
2783 setShouldDelayLoadEvent(true); | 2785 setShouldDelayLoadEvent(true); |
2784 | 2786 |
2785 // 24. Set the networkState back to NETWORK_LOADING. | 2787 // 24. Set the networkState back to NETWORK_LOADING. |
2786 setNetworkState(NETWORK_LOADING); | 2788 setNetworkState(NETWORK_LOADING); |
2787 | 2789 |
2788 // 25. Jump back to the find next candidate step above. | 2790 // 25. Jump back to the find next candidate step above. |
2789 m_nextChildNodeToConsider = source; | 2791 m_nextChildNodeToConsider = source; |
2790 scheduleNextSourceChild(); | 2792 scheduleNextSourceChild(); |
2791 } | 2793 } |
2792 | 2794 |
2793 void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source) | 2795 void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source) |
2794 { | 2796 { |
2795 WTF_LOG(Media, "HTMLMediaElement::sourceWasRemoved(%p, %p)", this, source); | 2797 DVLOG(LOG_LEVEL) << "sourceWasRemoved(" << source << ")"; |
2796 | 2798 |
2797 #if !LOG_DISABLED | 2799 #if !LOG_DISABLED |
2798 KURL url = source->getNonEmptyURLAttribute(srcAttr); | 2800 KURL url = source->getNonEmptyURLAttribute(srcAttr); |
2799 WTF_LOG(Media, "HTMLMediaElement::sourceWasRemoved(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); | 2801 DVLOG(LOG_LEVEL) << "sourceWasRemoved - 'src' is " << urlForLoggingMedia(url ).utf8().data(); |
2800 #endif | 2802 #endif |
2801 | 2803 |
2802 if (source != m_currentSourceNode && source != m_nextChildNodeToConsider) | 2804 if (source != m_currentSourceNode && source != m_nextChildNodeToConsider) |
2803 return; | 2805 return; |
2804 | 2806 |
2805 if (source == m_nextChildNodeToConsider) { | 2807 if (source == m_nextChildNodeToConsider) { |
2806 if (m_currentSourceNode) | 2808 if (m_currentSourceNode) |
2807 m_nextChildNodeToConsider = m_currentSourceNode->nextSibling(); | 2809 m_nextChildNodeToConsider = m_currentSourceNode->nextSibling(); |
2808 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC onsider set to %p", this, m_nextChildNodeToConsider.get()); | 2810 DVLOG(LOG_LEVEL) << "sourceWasRemoved - m_nextChildNodeToConsider set to " << m_nextChildNodeToConsider.get(); |
2809 } else if (source == m_currentSourceNode) { | 2811 } else if (source == m_currentSourceNode) { |
2810 // Clear the current source node pointer, but don't change the movie as the spec says: | 2812 // Clear the current source node pointer, but don't change the movie as the spec says: |
2811 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already | 2813 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already |
2812 // inserted in a video or audio element will have no effect. | 2814 // inserted in a video or audio element will have no effect. |
2813 m_currentSourceNode = nullptr; | 2815 m_currentSourceNode = nullptr; |
2814 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this); | 2816 DVLOG(LOG_LEVEL) << "sourceWasRemoved - m_currentSourceNode set to 0"; |
2815 } | 2817 } |
2816 } | 2818 } |
2817 | 2819 |
2818 void HTMLMediaElement::timeChanged() | 2820 void HTMLMediaElement::timeChanged() |
2819 { | 2821 { |
2820 WTF_LOG(Media, "HTMLMediaElement::timeChanged(%p)", this); | 2822 DVLOG(LOG_LEVEL) << "timeChanged(" << this << ")"; |
2821 | 2823 |
2822 cueTimeline().updateActiveCues(currentTime()); | 2824 cueTimeline().updateActiveCues(currentTime()); |
2823 | 2825 |
2824 invalidateCachedTime(); | 2826 invalidateCachedTime(); |
2825 | 2827 |
2826 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. | 2828 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. |
2827 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) | 2829 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) |
2828 finishSeek(); | 2830 finishSeek(); |
2829 | 2831 |
2830 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, | 2832 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, |
(...skipping 29 matching lines...) Expand all Loading... | |
2860 } | 2862 } |
2861 } else { | 2863 } else { |
2862 m_sentEndEvent = false; | 2864 m_sentEndEvent = false; |
2863 } | 2865 } |
2864 | 2866 |
2865 updatePlayState(); | 2867 updatePlayState(); |
2866 } | 2868 } |
2867 | 2869 |
2868 void HTMLMediaElement::durationChanged() | 2870 void HTMLMediaElement::durationChanged() |
2869 { | 2871 { |
2870 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p)", this); | 2872 DVLOG(LOG_LEVEL) << "durationChanged"; |
2871 // FIXME: Change WebMediaPlayer to convey the currentTime | 2873 // FIXME: Change WebMediaPlayer to convey the currentTime |
2872 // when the duration change occured. The current WebMediaPlayer | 2874 // when the duration change occured. The current WebMediaPlayer |
2873 // implementations always clamp currentTime() to duration() | 2875 // implementations always clamp currentTime() to duration() |
2874 // so the requestSeek condition here is always false. | 2876 // so the requestSeek condition here is always false. |
2875 durationChanged(duration(), currentTime() > duration()); | 2877 durationChanged(duration(), currentTime() > duration()); |
2876 } | 2878 } |
2877 | 2879 |
2878 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) | 2880 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) |
2879 { | 2881 { |
2880 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); | 2882 DVLOG(LOG_LEVEL) << "durationChanged(" << duration << ", " << requestSeek << ")"; |
fs
2016/05/18 13:24:36
boolString?
Srirama
2016/05/18 13:55:01
Done.
| |
2881 | 2883 |
2882 // Abort if duration unchanged. | 2884 // Abort if duration unchanged. |
2883 if (m_duration == duration) | 2885 if (m_duration == duration) |
2884 return; | 2886 return; |
2885 | 2887 |
2886 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration); | 2888 DVLOG(LOG_LEVEL) << "durationChanged : " << m_duration << " -> " << duration ; |
2887 m_duration = duration; | 2889 m_duration = duration; |
2888 scheduleEvent(EventTypeNames::durationchange); | 2890 scheduleEvent(EventTypeNames::durationchange); |
2889 | 2891 |
2890 if (mediaControls()) | 2892 if (mediaControls()) |
2891 mediaControls()->reset(); | 2893 mediaControls()->reset(); |
2892 if (layoutObject()) | 2894 if (layoutObject()) |
2893 layoutObject()->updateFromElement(); | 2895 layoutObject()->updateFromElement(); |
2894 | 2896 |
2895 if (requestSeek) | 2897 if (requestSeek) |
2896 seek(duration); | 2898 seek(duration); |
2897 } | 2899 } |
2898 | 2900 |
2899 void HTMLMediaElement::playbackStateChanged() | 2901 void HTMLMediaElement::playbackStateChanged() |
2900 { | 2902 { |
2901 WTF_LOG(Media, "HTMLMediaElement::playbackStateChanged(%p)", this); | 2903 DVLOG(LOG_LEVEL) << "playbackStateChanged"; |
2902 | 2904 |
2903 if (!webMediaPlayer()) | 2905 if (!webMediaPlayer()) |
2904 return; | 2906 return; |
2905 | 2907 |
2906 if (webMediaPlayer()->paused()) | 2908 if (webMediaPlayer()->paused()) |
2907 pauseInternal(); | 2909 pauseInternal(); |
2908 else | 2910 else |
2909 playInternal(); | 2911 playInternal(); |
2910 } | 2912 } |
2911 | 2913 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2954 if (m_webLayer) | 2956 if (m_webLayer) |
2955 m_webLayer->invalidate(); | 2957 m_webLayer->invalidate(); |
2956 | 2958 |
2957 updateDisplayState(); | 2959 updateDisplayState(); |
2958 if (layoutObject()) | 2960 if (layoutObject()) |
2959 layoutObject()->setShouldDoFullPaintInvalidation(); | 2961 layoutObject()->setShouldDoFullPaintInvalidation(); |
2960 } | 2962 } |
2961 | 2963 |
2962 void HTMLMediaElement::sizeChanged() | 2964 void HTMLMediaElement::sizeChanged() |
2963 { | 2965 { |
2964 WTF_LOG(Media, "HTMLMediaElement::sizeChanged(%p)", this); | 2966 DVLOG(LOG_LEVEL) << "sizeChanged"; |
2965 | 2967 |
2966 ASSERT(hasVideo()); // "resize" makes no sense absent video. | 2968 ASSERT(hasVideo()); // "resize" makes no sense absent video. |
2967 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) | 2969 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) |
2968 scheduleEvent(EventTypeNames::resize); | 2970 scheduleEvent(EventTypeNames::resize); |
2969 | 2971 |
2970 if (layoutObject()) | 2972 if (layoutObject()) |
2971 layoutObject()->updateFromElement(); | 2973 layoutObject()->updateFromElement(); |
2972 } | 2974 } |
2973 | 2975 |
2974 TimeRanges* HTMLMediaElement::buffered() const | 2976 TimeRanges* HTMLMediaElement::buffered() const |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3055 } | 3057 } |
3056 | 3058 |
3057 return false; | 3059 return false; |
3058 } | 3060 } |
3059 | 3061 |
3060 void HTMLMediaElement::updatePlayState() | 3062 void HTMLMediaElement::updatePlayState() |
3061 { | 3063 { |
3062 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); | 3064 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); |
3063 bool shouldBePlaying = potentiallyPlaying(); | 3065 bool shouldBePlaying = potentiallyPlaying(); |
3064 | 3066 |
3065 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s", | 3067 DVLOG(LOG_LEVEL) << "updatePlayState - shouldBePlaying = " |
3066 this, boolString(shouldBePlaying), boolString(isPlaying)); | 3068 << boolString(shouldBePlaying) << ", isPlaying = " << boolString(isPlayi ng); |
3067 | 3069 |
3068 if (shouldBePlaying) { | 3070 if (shouldBePlaying) { |
3069 setDisplayMode(Video); | 3071 setDisplayMode(Video); |
3070 invalidateCachedTime(); | 3072 invalidateCachedTime(); |
3071 | 3073 |
3072 if (!isPlaying) { | 3074 if (!isPlaying) { |
3073 // Set rate, muted before calling play in case they were set before the media engine was setup. | 3075 // Set rate, muted before calling play in case they were set before the media engine was setup. |
3074 // The media engine should just stash the rate and muted values sinc e it isn't already playing. | 3076 // The media engine should just stash the rate and muted values sinc e it isn't already playing. |
3075 webMediaPlayer()->setRate(playbackRate()); | 3077 webMediaPlayer()->setRate(playbackRate()); |
3076 updateVolume(); | 3078 updateVolume(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3147 m_playingRemotely = false; | 3149 m_playingRemotely = false; |
3148 if (mediaControls()) | 3150 if (mediaControls()) |
3149 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); | 3151 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); |
3150 | 3152 |
3151 if (layoutObject()) | 3153 if (layoutObject()) |
3152 layoutObject()->setShouldDoFullPaintInvalidation(); | 3154 layoutObject()->setShouldDoFullPaintInvalidation(); |
3153 } | 3155 } |
3154 | 3156 |
3155 void HTMLMediaElement::stop() | 3157 void HTMLMediaElement::stop() |
3156 { | 3158 { |
3157 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); | 3159 DVLOG(LOG_LEVEL) << "stop"; |
3158 | 3160 |
3159 // Close the async event queue so that no events are enqueued. | 3161 // Close the async event queue so that no events are enqueued. |
3160 cancelPendingEventsAndCallbacks(); | 3162 cancelPendingEventsAndCallbacks(); |
3161 m_asyncEventQueue->close(); | 3163 m_asyncEventQueue->close(); |
3162 | 3164 |
3163 // Clear everything in the Media Element | 3165 // Clear everything in the Media Element |
3164 clearMediaPlayer(); | 3166 clearMediaPlayer(); |
3165 m_readyState = HAVE_NOTHING; | 3167 m_readyState = HAVE_NOTHING; |
3166 m_readyStateMaximum = HAVE_NOTHING; | 3168 m_readyStateMaximum = HAVE_NOTHING; |
3167 setNetworkState(NETWORK_EMPTY); | 3169 setNetworkState(NETWORK_EMPTY); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3214 return false; | 3216 return false; |
3215 } | 3217 } |
3216 | 3218 |
3217 bool HTMLMediaElement::isFullscreen() const | 3219 bool HTMLMediaElement::isFullscreen() const |
3218 { | 3220 { |
3219 return Fullscreen::isActiveFullScreenElement(*this); | 3221 return Fullscreen::isActiveFullScreenElement(*this); |
3220 } | 3222 } |
3221 | 3223 |
3222 void HTMLMediaElement::enterFullscreen() | 3224 void HTMLMediaElement::enterFullscreen() |
3223 { | 3225 { |
3224 WTF_LOG(Media, "HTMLMediaElement::enterFullscreen(%p)", this); | 3226 DVLOG(LOG_LEVEL) << "enterFullscreen"; |
3225 | 3227 |
3226 Fullscreen::from(document()).requestFullscreen(*this, Fullscreen::PrefixedRe quest); | 3228 Fullscreen::from(document()).requestFullscreen(*this, Fullscreen::PrefixedRe quest); |
3227 } | 3229 } |
3228 | 3230 |
3229 void HTMLMediaElement::exitFullscreen() | 3231 void HTMLMediaElement::exitFullscreen() |
3230 { | 3232 { |
3231 WTF_LOG(Media, "HTMLMediaElement::exitFullscreen(%p)", this); | 3233 DVLOG(LOG_LEVEL) << "exitFullscreen"; |
3232 | 3234 |
3233 Fullscreen::from(document()).exitFullscreen(); | 3235 Fullscreen::from(document()).exitFullscreen(); |
3234 } | 3236 } |
3235 | 3237 |
3236 void HTMLMediaElement::didBecomeFullscreenElement() | 3238 void HTMLMediaElement::didBecomeFullscreenElement() |
3237 { | 3239 { |
3238 if (mediaControls()) | 3240 if (mediaControls()) |
3239 mediaControls()->enteredFullscreen(); | 3241 mediaControls()->enteredFullscreen(); |
3240 // FIXME: There is no embedder-side handling in layout test mode. | 3242 // FIXME: There is no embedder-side handling in layout test mode. |
3241 if (webMediaPlayer() && !LayoutTestSupport::isRunningLayoutTest()) | 3243 if (webMediaPlayer() && !LayoutTestSupport::isRunningLayoutTest()) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3317 // so that they are rendered behind them. | 3319 // so that they are rendered behind them. |
3318 shadowRoot.insertBefore(textTrackContainer, firstChild); | 3320 shadowRoot.insertBefore(textTrackContainer, firstChild); |
3319 | 3321 |
3320 assertShadowRootChildren(shadowRoot); | 3322 assertShadowRootChildren(shadowRoot); |
3321 | 3323 |
3322 return *textTrackContainer; | 3324 return *textTrackContainer; |
3323 } | 3325 } |
3324 | 3326 |
3325 void HTMLMediaElement::updateTextTrackDisplay() | 3327 void HTMLMediaElement::updateTextTrackDisplay() |
3326 { | 3328 { |
3327 WTF_LOG(Media, "HTMLMediaElement::updateTextTrackDisplay(%p)", this); | 3329 DVLOG(LOG_LEVEL) << "updateTextTrackDisplay"; |
3328 | 3330 |
3329 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidNotSt artExposingControls); | 3331 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidNotSt artExposingControls); |
3330 } | 3332 } |
3331 | 3333 |
3332 void HTMLMediaElement::mediaControlsDidBecomeVisible() | 3334 void HTMLMediaElement::mediaControlsDidBecomeVisible() |
3333 { | 3335 { |
3334 WTF_LOG(Media, "HTMLMediaElement::mediaControlsDidBecomeVisible(%p)", this); | 3336 DVLOG(LOG_LEVEL) << "mediaControlsDidBecomeVisible"; |
3335 | 3337 |
3336 // When the user agent starts exposing a user interface for a video element, | 3338 // When the user agent starts exposing a user interface for a video element, |
3337 // the user agent should run the rules for updating the text track rendering | 3339 // the user agent should run the rules for updating the text track rendering |
3338 // of each of the text tracks in the video element's list of text tracks ... | 3340 // of each of the text tracks in the video element's list of text tracks ... |
3339 if (isHTMLVideoElement() && textTracksVisible()) | 3341 if (isHTMLVideoElement() && textTracksVisible()) |
3340 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls); | 3342 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls); |
3341 } | 3343 } |
3342 | 3344 |
3343 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen t* document) | 3345 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen t* document) |
3344 { | 3346 { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3405 bool HTMLMediaElement::isURLAttribute(const Attribute& attribute) const | 3407 bool HTMLMediaElement::isURLAttribute(const Attribute& attribute) const |
3406 { | 3408 { |
3407 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute) ; | 3409 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute) ; |
3408 } | 3410 } |
3409 | 3411 |
3410 void HTMLMediaElement::setShouldDelayLoadEvent(bool shouldDelay) | 3412 void HTMLMediaElement::setShouldDelayLoadEvent(bool shouldDelay) |
3411 { | 3413 { |
3412 if (m_shouldDelayLoadEvent == shouldDelay) | 3414 if (m_shouldDelayLoadEvent == shouldDelay) |
3413 return; | 3415 return; |
3414 | 3416 |
3415 WTF_LOG(Media, "HTMLMediaElement::setShouldDelayLoadEvent(%p, %s)", this, bo olString(shouldDelay)); | 3417 DVLOG(LOG_LEVEL) << "setShouldDelayLoadEvent(" << boolString(shouldDelay) << ")"; |
3416 | 3418 |
3417 m_shouldDelayLoadEvent = shouldDelay; | 3419 m_shouldDelayLoadEvent = shouldDelay; |
3418 if (shouldDelay) | 3420 if (shouldDelay) |
3419 document().incrementLoadEventDelayCount(); | 3421 document().incrementLoadEventDelayCount(); |
3420 else | 3422 else |
3421 document().decrementLoadEventDelayCount(); | 3423 document().decrementLoadEventDelayCount(); |
3422 } | 3424 } |
3423 | 3425 |
3424 MediaControls* HTMLMediaElement::mediaControls() const | 3426 MediaControls* HTMLMediaElement::mediaControls() const |
3425 { | 3427 { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3476 CueTimeline& HTMLMediaElement::cueTimeline() | 3478 CueTimeline& HTMLMediaElement::cueTimeline() |
3477 { | 3479 { |
3478 if (!m_cueTimeline) | 3480 if (!m_cueTimeline) |
3479 m_cueTimeline = new CueTimeline(*this); | 3481 m_cueTimeline = new CueTimeline(*this); |
3480 return *m_cueTimeline; | 3482 return *m_cueTimeline; |
3481 } | 3483 } |
3482 | 3484 |
3483 void HTMLMediaElement::configureTextTrackDisplay() | 3485 void HTMLMediaElement::configureTextTrackDisplay() |
3484 { | 3486 { |
3485 ASSERT(m_textTracks); | 3487 ASSERT(m_textTracks); |
3486 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this); | 3488 DVLOG(LOG_LEVEL) << "configureTextTrackDisplay"; |
3487 | 3489 |
3488 if (m_processingPreferenceChange) | 3490 if (m_processingPreferenceChange) |
3489 return; | 3491 return; |
3490 | 3492 |
3491 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); | 3493 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); |
3492 m_textTracksVisible = haveVisibleTextTrack; | 3494 m_textTracksVisible = haveVisibleTextTrack; |
3493 | 3495 |
3494 if (!haveVisibleTextTrack && !mediaControls()) | 3496 if (!haveVisibleTextTrack && !mediaControls()) |
3495 return; | 3497 return; |
3496 | 3498 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3850 | 3852 |
3851 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst | 3853 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst |
3852 { | 3854 { |
3853 IntRect result; | 3855 IntRect result; |
3854 if (LayoutObject* object = m_element->layoutObject()) | 3856 if (LayoutObject* object = m_element->layoutObject()) |
3855 result = object->absoluteBoundingBoxRect(); | 3857 result = object->absoluteBoundingBoxRect(); |
3856 return result; | 3858 return result; |
3857 } | 3859 } |
3858 | 3860 |
3859 } // namespace blink | 3861 } // namespace blink |
OLD | NEW |