Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2146203002: Add an option to make blink media logging verbose (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bring back separate macros for MediaElement/MediaSource/SourceBuffer Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/mediasource/MediaSource.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 #include "public/platform/WebMediaPlayerSource.h" 89 #include "public/platform/WebMediaPlayerSource.h"
90 #include "public/platform/WebMediaStream.h" 90 #include "public/platform/WebMediaStream.h"
91 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" 91 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h"
92 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" 92 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h"
93 #include "wtf/CurrentTime.h" 93 #include "wtf/CurrentTime.h"
94 #include "wtf/MathExtras.h" 94 #include "wtf/MathExtras.h"
95 #include "wtf/PtrUtil.h" 95 #include "wtf/PtrUtil.h"
96 #include "wtf/text/CString.h" 96 #include "wtf/text/CString.h"
97 #include <limits> 97 #include <limits>
98 98
99 #define MEDIA_LOG DVLOG(3) 99 #ifndef BLINK_MEDIA_LOG
100 #define BLINK_MEDIA_LOG DVLOG(3)
101 #endif
100 102
101 #ifndef LOG_MEDIA_EVENTS 103 #ifndef LOG_MEDIA_EVENTS
102 // Default to not logging events because so many are generated they can overwhel m the rest of 104 // Default to not logging events because so many are generated they can overwhel m the rest of
103 // the logging. 105 // the logging.
104 #define LOG_MEDIA_EVENTS 0 106 #define LOG_MEDIA_EVENTS 0
105 #endif 107 #endif
106 108
107 #ifndef LOG_CACHED_TIME_WARNINGS 109 #ifndef LOG_CACHED_TIME_WARNINGS
108 // Default to not logging warnings about excessive drift in the cached media tim e because it adds a 110 // Default to not logging warnings about excessive drift in the cached media tim e because it adds a
109 // fair amount of overhead and logging. 111 // fair amount of overhead and logging.
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolveScheduledPlayPromises)) 447 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolveScheduledPlayPromises))
446 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectScheduledPlayPromises)) 448 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectScheduledPlayPromises))
447 , m_audioSourceNode(nullptr) 449 , m_audioSourceNode(nullptr)
448 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) 450 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this))
449 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et())) 451 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et()))
450 , m_remotePlaybackClient(nullptr) 452 , m_remotePlaybackClient(nullptr)
451 , m_autoplayVisibilityObserver(nullptr) 453 , m_autoplayVisibilityObserver(nullptr)
452 { 454 {
453 ThreadState::current()->registerPreFinalizer(this); 455 ThreadState::current()->registerPreFinalizer(this);
454 456
455 MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; 457 BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")";
456 458
457 // If any experiment is enabled, then we want to enable a user gesture by 459 // If any experiment is enabled, then we want to enable a user gesture by
458 // default, otherwise the experiment does nothing. 460 // default, otherwise the experiment does nothing.
459 if ((document.settings() && document.settings()->mediaPlaybackRequiresUserGe sture()) 461 if ((document.settings() && document.settings()->mediaPlaybackRequiresUserGe sture())
460 || m_autoplayHelper->isExperimentEnabled()) { 462 || m_autoplayHelper->isExperimentEnabled()) {
461 m_lockedPendingUserGesture = true; 463 m_lockedPendingUserGesture = true;
462 } 464 }
463 465
464 setHasCustomStyleCallbacks(); 466 setHasCustomStyleCallbacks();
465 addElementToDocumentMap(this, &document); 467 addElementToDocumentMap(this, &document);
466 468
467 UseCounter::count(document, UseCounter::HTMLMediaElement); 469 UseCounter::count(document, UseCounter::HTMLMediaElement);
468 } 470 }
469 471
470 HTMLMediaElement::~HTMLMediaElement() 472 HTMLMediaElement::~HTMLMediaElement()
471 { 473 {
472 MEDIA_LOG << "~HTMLMediaElement(" << (void*)this << ")"; 474 BLINK_MEDIA_LOG << "~HTMLMediaElement(" << (void*)this << ")";
473 475
474 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). 476 // m_audioSourceNode is explicitly cleared by AudioNode::dispose().
475 // Since AudioNode::dispose() is guaranteed to be always called before 477 // Since AudioNode::dispose() is guaranteed to be always called before
476 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared 478 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared
477 // even if the AudioNode and the HTMLMediaElement die together. 479 // even if the AudioNode and the HTMLMediaElement die together.
478 DCHECK(!m_audioSourceNode); 480 DCHECK(!m_audioSourceNode);
479 } 481 }
480 482
481 void HTMLMediaElement::dispose() 483 void HTMLMediaElement::dispose()
482 { 484 {
483 closeMediaSource(); 485 closeMediaSource();
484 486
485 // Destroying the player may cause a resource load to be canceled, 487 // Destroying the player may cause a resource load to be canceled,
486 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being 488 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being
487 // called via ResourceFetch::didLoadResource(), then 489 // called via ResourceFetch::didLoadResource(), then
488 // FrameLoader::checkCompleted(). But it's guaranteed that the load event 490 // FrameLoader::checkCompleted(). But it's guaranteed that the load event
489 // doesn't get dispatched during the object destruction. 491 // doesn't get dispatched during the object destruction.
490 // See Document::isDelayingLoadEvent(). 492 // See Document::isDelayingLoadEvent().
491 // Also see http://crbug.com/275223 for more details. 493 // Also see http://crbug.com/275223 for more details.
492 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); 494 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking();
493 } 495 }
494 496
495 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) 497 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument)
496 { 498 {
497 MEDIA_LOG << "didMoveToNewDocument(" << (void*)this << ")"; 499 BLINK_MEDIA_LOG << "didMoveToNewDocument(" << (void*)this << ")";
498 500
499 // If any experiment is enabled, then we want to enable a user gesture by 501 // If any experiment is enabled, then we want to enable a user gesture by
500 // default, otherwise the experiment does nothing. 502 // default, otherwise the experiment does nothing.
501 bool oldDocumentRequiresUserGesture = (oldDocument.settings() && oldDocument .settings()->mediaPlaybackRequiresUserGesture()) 503 bool oldDocumentRequiresUserGesture = (oldDocument.settings() && oldDocument .settings()->mediaPlaybackRequiresUserGesture())
502 || m_autoplayHelper->isExperimentEnabled(); 504 || m_autoplayHelper->isExperimentEnabled();
503 bool newDocumentRequiresUserGesture = (document().settings() && document().s ettings()->mediaPlaybackRequiresUserGesture()) 505 bool newDocumentRequiresUserGesture = (document().settings() && document().s ettings()->mediaPlaybackRequiresUserGesture())
504 || m_autoplayHelper->isExperimentEnabled(); 506 || m_autoplayHelper->isExperimentEnabled();
505 if (newDocumentRequiresUserGesture && !oldDocumentRequiresUserGesture) { 507 if (newDocumentRequiresUserGesture && !oldDocumentRequiresUserGesture) {
506 m_lockedPendingUserGesture = true; 508 m_lockedPendingUserGesture = true;
507 } 509 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 } 549 }
548 550
549 bool HTMLMediaElement::isMouseFocusable() const 551 bool HTMLMediaElement::isMouseFocusable() const
550 { 552 {
551 return false; 553 return false;
552 } 554 }
553 555
554 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& oldValue, const AtomicString& value) 556 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& oldValue, const AtomicString& value)
555 { 557 {
556 if (name == srcAttr) { 558 if (name == srcAttr) {
557 MEDIA_LOG << "parseAttribute(" << (void*)this << ", srcAttr, old=" << ol dValue << ", new=" << value << ")"; 559 BLINK_MEDIA_LOG << "parseAttribute(" << (void*)this << ", srcAttr, old=" << oldValue << ", new=" << value << ")";
558 // Trigger a reload, as long as the 'src' attribute is present. 560 // Trigger a reload, as long as the 'src' attribute is present.
559 if (!value.isNull()) { 561 if (!value.isNull()) {
560 m_ignorePreloadNone = false; 562 m_ignorePreloadNone = false;
561 invokeLoadAlgorithm(); 563 invokeLoadAlgorithm();
562 } 564 }
563 } else if (name == controlsAttr) { 565 } else if (name == controlsAttr) {
564 UseCounter::count(document(), UseCounter::HTMLMediaElementControlsAttrib ute); 566 UseCounter::count(document(), UseCounter::HTMLMediaElementControlsAttrib ute);
565 configureMediaControls(); 567 configureMediaControls();
566 } else if (name == preloadAttr) { 568 } else if (name == preloadAttr) {
567 setPlayerPreload(); 569 setPlayerPreload();
(...skipping 17 matching lines...) Expand all
585 return shouldShowControls() && HTMLElement::layoutObjectIsNeeded(style); 587 return shouldShowControls() && HTMLElement::layoutObjectIsNeeded(style);
586 } 588 }
587 589
588 LayoutObject* HTMLMediaElement::createLayoutObject(const ComputedStyle&) 590 LayoutObject* HTMLMediaElement::createLayoutObject(const ComputedStyle&)
589 { 591 {
590 return new LayoutMedia(this); 592 return new LayoutMedia(this);
591 } 593 }
592 594
593 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint) 595 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint)
594 { 596 {
595 MEDIA_LOG << "insertedInto(" << (void*)this << ", " << insertionPoint << ")" ; 597 BLINK_MEDIA_LOG << "insertedInto(" << (void*)this << ", " << insertionPoint << ")";
596 598
597 HTMLElement::insertedInto(insertionPoint); 599 HTMLElement::insertedInto(insertionPoint);
598 if (insertionPoint->inShadowIncludingDocument()) { 600 if (insertionPoint->inShadowIncludingDocument()) {
599 UseCounter::count(document(), UseCounter::HTMLMediaElementInDocument); 601 UseCounter::count(document(), UseCounter::HTMLMediaElementInDocument);
600 if ((!getAttribute(srcAttr).isEmpty() || m_srcObject) && m_networkState == NETWORK_EMPTY) { 602 if ((!getAttribute(srcAttr).isEmpty() || m_srcObject) && m_networkState == NETWORK_EMPTY) {
601 m_ignorePreloadNone = false; 603 m_ignorePreloadNone = false;
602 invokeLoadAlgorithm(); 604 invokeLoadAlgorithm();
603 } 605 }
604 } 606 }
605 607
606 return InsertionShouldCallDidNotifySubtreeInsertions; 608 return InsertionShouldCallDidNotifySubtreeInsertions;
607 } 609 }
608 610
609 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() 611 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument()
610 { 612 {
611 configureMediaControls(); 613 configureMediaControls();
612 } 614 }
613 615
614 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) 616 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint)
615 { 617 {
616 MEDIA_LOG << "removedFrom(" << (void*)this << ", " << insertionPoint << ")"; 618 BLINK_MEDIA_LOG << "removedFrom(" << (void*)this << ", " << insertionPoint < < ")";
617 619
618 HTMLElement::removedFrom(insertionPoint); 620 HTMLElement::removedFrom(insertionPoint);
619 if (insertionPoint->inActiveDocument()) { 621 if (insertionPoint->inActiveDocument()) {
620 configureMediaControls(); 622 configureMediaControls();
621 if (m_networkState > NETWORK_EMPTY) 623 if (m_networkState > NETWORK_EMPTY)
622 pauseInternal(); 624 pauseInternal();
623 } 625 }
624 } 626 }
625 627
626 void HTMLMediaElement::attach(const AttachContext& context) 628 void HTMLMediaElement::attach(const AttachContext& context)
627 { 629 {
628 HTMLElement::attach(context); 630 HTMLElement::attach(context);
629 631
630 if (layoutObject()) 632 if (layoutObject())
631 layoutObject()->updateFromElement(); 633 layoutObject()->updateFromElement();
632 } 634 }
633 635
634 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) 636 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange)
635 { 637 {
636 if (layoutObject()) 638 if (layoutObject())
637 layoutObject()->updateFromElement(); 639 layoutObject()->updateFromElement();
638 } 640 }
639 641
640 void HTMLMediaElement::scheduleTextTrackResourceLoad() 642 void HTMLMediaElement::scheduleTextTrackResourceLoad()
641 { 643 {
642 MEDIA_LOG << "scheduleTextTrackResourceLoad(" << (void*)this << ")"; 644 BLINK_MEDIA_LOG << "scheduleTextTrackResourceLoad(" << (void*)this << ")";
643 645
644 m_pendingActionFlags |= LoadTextTrackResource; 646 m_pendingActionFlags |= LoadTextTrackResource;
645 647
646 if (!m_loadTimer.isActive()) 648 if (!m_loadTimer.isActive())
647 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); 649 m_loadTimer.startOneShot(0, BLINK_FROM_HERE);
648 } 650 }
649 651
650 void HTMLMediaElement::scheduleNextSourceChild() 652 void HTMLMediaElement::scheduleNextSourceChild()
651 { 653 {
652 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala invokeLoadAlgorithm. 654 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala invokeLoadAlgorithm.
653 m_pendingActionFlags |= LoadMediaResource; 655 m_pendingActionFlags |= LoadMediaResource;
654 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); 656 m_loadTimer.startOneShot(0, BLINK_FROM_HERE);
655 } 657 }
656 658
657 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) 659 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName)
658 { 660 {
659 scheduleEvent(Event::createCancelable(eventName)); 661 scheduleEvent(Event::createCancelable(eventName));
660 } 662 }
661 663
662 void HTMLMediaElement::scheduleEvent(Event* event) 664 void HTMLMediaElement::scheduleEvent(Event* event)
663 { 665 {
664 #if LOG_MEDIA_EVENTS 666 #if LOG_MEDIA_EVENTS
665 MEDIA_LOG << "scheduleEvent(" << (void*)this << ")" << " - scheduling '" << event->type() << "'"; 667 BLINK_MEDIA_LOG << "scheduleEvent(" << (void*)this << ")" << " - scheduling '" << event->type() << "'";
666 #endif 668 #endif
667 m_asyncEventQueue->enqueueEvent(event); 669 m_asyncEventQueue->enqueueEvent(event);
668 } 670 }
669 671
670 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) 672 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*)
671 { 673 {
672 if (m_pendingActionFlags & LoadTextTrackResource) 674 if (m_pendingActionFlags & LoadTextTrackResource)
673 honorUserPreferencesForAutomaticTextTrackSelection(); 675 honorUserPreferencesForAutomaticTextTrackSelection();
674 676
675 if (m_pendingActionFlags & LoadMediaResource) { 677 if (m_pendingActionFlags & LoadMediaResource) {
(...skipping 11 matching lines...) Expand all
687 return m_error; 689 return m_error;
688 } 690 }
689 691
690 void HTMLMediaElement::setSrc(const AtomicString& url) 692 void HTMLMediaElement::setSrc(const AtomicString& url)
691 { 693 {
692 setAttribute(srcAttr, url); 694 setAttribute(srcAttr, url);
693 } 695 }
694 696
695 void HTMLMediaElement::setSrcObject(MediaStreamDescriptor* srcObject) 697 void HTMLMediaElement::setSrcObject(MediaStreamDescriptor* srcObject)
696 { 698 {
697 MEDIA_LOG << "setSrcObject(" << (void*)this << ")"; 699 BLINK_MEDIA_LOG << "setSrcObject(" << (void*)this << ")";
698 m_srcObject = srcObject; 700 m_srcObject = srcObject;
699 invokeLoadAlgorithm(); 701 invokeLoadAlgorithm();
700 } 702 }
701 703
702 HTMLMediaElement::NetworkState HTMLMediaElement::getNetworkState() const 704 HTMLMediaElement::NetworkState HTMLMediaElement::getNetworkState() const
703 { 705 {
704 return m_networkState; 706 return m_networkState;
705 } 707 }
706 708
707 String HTMLMediaElement::canPlayType(const String& mimeType) const 709 String HTMLMediaElement::canPlayType(const String& mimeType) const
708 { 710 {
709 WebMimeRegistry::SupportsType support = supportsType(ContentType(mimeType)); 711 WebMimeRegistry::SupportsType support = supportsType(ContentType(mimeType));
710 String canPlay; 712 String canPlay;
711 713
712 // 4.8.10.3 714 // 4.8.10.3
713 switch (support) { 715 switch (support) {
714 case WebMimeRegistry::IsNotSupported: 716 case WebMimeRegistry::IsNotSupported:
715 canPlay = emptyString(); 717 canPlay = emptyString();
716 break; 718 break;
717 case WebMimeRegistry::MayBeSupported: 719 case WebMimeRegistry::MayBeSupported:
718 canPlay = "maybe"; 720 canPlay = "maybe";
719 break; 721 break;
720 case WebMimeRegistry::IsSupported: 722 case WebMimeRegistry::IsSupported:
721 canPlay = "probably"; 723 canPlay = "probably";
722 break; 724 break;
723 } 725 }
724 726
725 MEDIA_LOG << "canPlayType(" << (void*)this << ", " << mimeType << ") -> " << canPlay; 727 BLINK_MEDIA_LOG << "canPlayType(" << (void*)this << ", " << mimeType << ") - > " << canPlay;
726 728
727 return canPlay; 729 return canPlay;
728 } 730 }
729 731
730 void HTMLMediaElement::load() 732 void HTMLMediaElement::load()
731 { 733 {
732 MEDIA_LOG << "load(" << (void*)this << ")"; 734 BLINK_MEDIA_LOG << "load(" << (void*)this << ")";
733 735
734 m_autoplayHelper->loadMethodCalled(); 736 m_autoplayHelper->loadMethodCalled();
735 737
736 m_ignorePreloadNone = true; 738 m_ignorePreloadNone = true;
737 invokeLoadAlgorithm(); 739 invokeLoadAlgorithm();
738 } 740 }
739 741
740 // TODO(srirama.m): Currently m_ignorePreloadNone is reset before calling 742 // TODO(srirama.m): Currently m_ignorePreloadNone is reset before calling
741 // invokeLoadAlgorithm() in all places except load(). Move it inside here 743 // invokeLoadAlgorithm() in all places except load(). Move it inside here
742 // once microtask is implemented for "Await a stable state" step 744 // once microtask is implemented for "Await a stable state" step
743 // in resource selection algorithm. 745 // in resource selection algorithm.
744 void HTMLMediaElement::invokeLoadAlgorithm() 746 void HTMLMediaElement::invokeLoadAlgorithm()
745 { 747 {
746 MEDIA_LOG << "invokeLoadAlgorithm(" << (void*)this << ")"; 748 BLINK_MEDIA_LOG << "invokeLoadAlgorithm(" << (void*)this << ")";
747 749
748 // Perform the cleanup required for the resource load algorithm to run. 750 // Perform the cleanup required for the resource load algorithm to run.
749 stopPeriodicTimers(); 751 stopPeriodicTimers();
750 m_loadTimer.stop(); 752 m_loadTimer.stop();
751 cancelDeferredLoad(); 753 cancelDeferredLoad();
752 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. 754 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here.
753 m_pendingActionFlags &= ~LoadMediaResource; 755 m_pendingActionFlags &= ~LoadMediaResource;
754 m_sentStalledEvent = false; 756 m_sentStalledEvent = false;
755 m_haveFiredLoadedData = false; 757 m_haveFiredLoadedData = false;
756 m_displayMode = Unknown; 758 m_displayMode = Unknown;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 m_autoplaying = true; 825 m_autoplaying = true;
824 826
825 // 7 - Invoke the media element's resource selection algorithm. 827 // 7 - Invoke the media element's resource selection algorithm.
826 invokeResourceSelectionAlgorithm(); 828 invokeResourceSelectionAlgorithm();
827 829
828 // 8 - Note: Playback of any previously playing media resource for this elem ent stops. 830 // 8 - Note: Playback of any previously playing media resource for this elem ent stops.
829 } 831 }
830 832
831 void HTMLMediaElement::invokeResourceSelectionAlgorithm() 833 void HTMLMediaElement::invokeResourceSelectionAlgorithm()
832 { 834 {
833 MEDIA_LOG << "invokeResourceSelectionAlgorithm(" << (void*)this << ")"; 835 BLINK_MEDIA_LOG << "invokeResourceSelectionAlgorithm(" << (void*)this << ")" ;
834 // The resource selection algorithm 836 // The resource selection algorithm
835 // 1 - Set the networkState to NETWORK_NO_SOURCE 837 // 1 - Set the networkState to NETWORK_NO_SOURCE
836 setNetworkState(NETWORK_NO_SOURCE); 838 setNetworkState(NETWORK_NO_SOURCE);
837 839
838 // 2 - Set the element's show poster flag to true 840 // 2 - Set the element's show poster flag to true
839 // TODO(srirama.m): Introduce show poster flag and update it as per spec 841 // TODO(srirama.m): Introduce show poster flag and update it as per spec
840 842
841 m_playedTimeRanges = TimeRanges::create(); 843 m_playedTimeRanges = TimeRanges::create();
842 844
843 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above 845 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above
(...skipping 23 matching lines...) Expand all
867 if (track->mode() != TextTrack::disabledKeyword()) 869 if (track->mode() != TextTrack::disabledKeyword())
868 m_textTracksWhenResourceSelectionBegan.append(track); 870 m_textTracksWhenResourceSelectionBegan.append(track);
869 } 871 }
870 } 872 }
871 873
872 selectMediaResource(); 874 selectMediaResource();
873 } 875 }
874 876
875 void HTMLMediaElement::selectMediaResource() 877 void HTMLMediaElement::selectMediaResource()
876 { 878 {
877 MEDIA_LOG << "selectMediaResource(" << (void*)this << ")"; 879 BLINK_MEDIA_LOG << "selectMediaResource(" << (void*)this << ")";
878 880
879 enum Mode { Object, Attribute, Children, Nothing }; 881 enum Mode { Object, Attribute, Children, Nothing };
880 Mode mode = Nothing; 882 Mode mode = Nothing;
881 883
882 // 6 - If the media element has an assigned media provider object, then let 884 // 6 - If the media element has an assigned media provider object, then let
883 // mode be object. 885 // mode be object.
884 if (m_srcObject) { 886 if (m_srcObject) {
885 mode = Object; 887 mode = Object;
886 } else if (fastHasAttribute(srcAttr)) { 888 } else if (fastHasAttribute(srcAttr)) {
887 // Otherwise, if the media element has no assigned media provider object 889 // Otherwise, if the media element has no assigned media provider object
(...skipping 10 matching lines...) Expand all
898 } else { 900 } else {
899 // Otherwise the media element has no assigned media provider object and 901 // Otherwise the media element has no assigned media provider object and
900 // has neither a src attribute nor a source element child: set the 902 // has neither a src attribute nor a source element child: set the
901 // networkState to NETWORK_EMPTY, and abort these steps; the synchronous 903 // networkState to NETWORK_EMPTY, and abort these steps; the synchronous
902 // section ends. 904 // section ends.
903 m_loadState = WaitingForSource; 905 m_loadState = WaitingForSource;
904 setShouldDelayLoadEvent(false); 906 setShouldDelayLoadEvent(false);
905 setNetworkState(NETWORK_EMPTY); 907 setNetworkState(NETWORK_EMPTY);
906 updateDisplayState(); 908 updateDisplayState();
907 909
908 MEDIA_LOG << "selectMediaResource(" << (void*)this << "), nothing to loa d"; 910 BLINK_MEDIA_LOG << "selectMediaResource(" << (void*)this << "), nothing to load";
909 return; 911 return;
910 } 912 }
911 913
912 // 7 - Set the media element's networkState to NETWORK_LOADING. 914 // 7 - Set the media element's networkState to NETWORK_LOADING.
913 setNetworkState(NETWORK_LOADING); 915 setNetworkState(NETWORK_LOADING);
914 916
915 // 8 - Queue a task to fire a simple event named loadstart at the media elem ent. 917 // 8 - Queue a task to fire a simple event named loadstart at the media elem ent.
916 scheduleEvent(EventTypeNames::loadstart); 918 scheduleEvent(EventTypeNames::loadstart);
917 919
918 // 9 - Run the appropriate steps... 920 // 9 - Run the appropriate steps...
919 switch (mode) { 921 switch (mode) {
920 case Object: 922 case Object:
921 loadSourceFromObject(); 923 loadSourceFromObject();
922 MEDIA_LOG << "selectMediaResource(" << (void*)this << ", using 'srcObjec t' attribute"; 924 BLINK_MEDIA_LOG << "selectMediaResource(" << (void*)this << ", using 'sr cObject' attribute";
923 break; 925 break;
924 case Attribute: 926 case Attribute:
925 loadSourceFromAttribute(); 927 loadSourceFromAttribute();
926 MEDIA_LOG << "selectMediaResource(" << (void*)this << "), using 'src' at tribute url"; 928 BLINK_MEDIA_LOG << "selectMediaResource(" << (void*)this << "), using 's rc' attribute url";
927 break; 929 break;
928 case Children: 930 case Children:
929 loadNextSourceChild(); 931 loadNextSourceChild();
930 MEDIA_LOG << "selectMediaResource(" << (void*)this << "), using source e lement"; 932 BLINK_MEDIA_LOG << "selectMediaResource(" << (void*)this << "), using so urce element";
931 break; 933 break;
932 default: 934 default:
933 NOTREACHED(); 935 NOTREACHED();
934 } 936 }
935 } 937 }
936 938
937 void HTMLMediaElement::loadSourceFromObject() 939 void HTMLMediaElement::loadSourceFromObject()
938 { 940 {
939 DCHECK(m_srcObject); 941 DCHECK(m_srcObject);
940 m_loadState = LoadingFromSrcObject; 942 m_loadState = LoadingFromSrcObject;
941 943
942 // No type is available when the resource comes from the 'srcObject' 944 // No type is available when the resource comes from the 'srcObject'
943 // attribute. 945 // attribute.
944 loadResource(WebMediaPlayerSource(WebMediaStream(m_srcObject)), ContentType( (String()))); 946 loadResource(WebMediaPlayerSource(WebMediaStream(m_srcObject)), ContentType( (String())));
945 } 947 }
946 948
947 void HTMLMediaElement::loadSourceFromAttribute() 949 void HTMLMediaElement::loadSourceFromAttribute()
948 { 950 {
949 m_loadState = LoadingFromSrcAttr; 951 m_loadState = LoadingFromSrcAttr;
950 const AtomicString& srcValue = fastGetAttribute(srcAttr); 952 const AtomicString& srcValue = fastGetAttribute(srcAttr);
951 953
952 // If the src attribute's value is the empty string ... jump down to the fai led step below 954 // If the src attribute's value is the empty string ... jump down to the fai led step below
953 if (srcValue.isEmpty()) { 955 if (srcValue.isEmpty()) {
954 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 956 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
955 MEDIA_LOG << "selectMediaResource(" << (void*)this << "), empty 'src'"; 957 BLINK_MEDIA_LOG << "selectMediaResource(" << (void*)this << "), empty 's rc'";
956 return; 958 return;
957 } 959 }
958 960
959 KURL mediaURL = document().completeURL(srcValue); 961 KURL mediaURL = document().completeURL(srcValue);
960 if (!isSafeToLoadURL(mediaURL, Complain)) { 962 if (!isSafeToLoadURL(mediaURL, Complain)) {
961 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 963 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
962 return; 964 return;
963 } 965 }
964 966
965 // No type is available when the url comes from the 'src' attribute so 967 // No type is available when the url comes from the 'src' attribute so
(...skipping 17 matching lines...) Expand all
983 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); 985 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType);
984 } 986 }
985 987
986 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, const Co ntentType& contentType) 988 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, const Co ntentType& contentType)
987 { 989 {
988 DCHECK(isMainThread()); 990 DCHECK(isMainThread());
989 KURL url; 991 KURL url;
990 if (source.isURL()) { 992 if (source.isURL()) {
991 url = source.getAsURL(); 993 url = source.getAsURL();
992 DCHECK(isSafeToLoadURL(url, Complain)); 994 DCHECK(isSafeToLoadURL(url, Complain));
993 MEDIA_LOG << "loadResource(" << (void*)this << ", " << urlForLoggingMedi a(url) << ", " << contentType.raw() << ")"; 995 BLINK_MEDIA_LOG << "loadResource(" << (void*)this << ", " << urlForLoggi ngMedia(url) << ", " << contentType.raw() << ")";
994 } 996 }
995 997
996 LocalFrame* frame = document().frame(); 998 LocalFrame* frame = document().frame();
997 if (!frame) { 999 if (!frame) {
998 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 1000 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
999 return; 1001 return;
1000 } 1002 }
1001 1003
1002 // The resource fetch algorithm 1004 // The resource fetch algorithm
1003 setNetworkState(NETWORK_LOADING); 1005 setNetworkState(NETWORK_LOADING);
1004 1006
1005 m_autoplayHelper->loadingStarted(); 1007 m_autoplayHelper->loadingStarted();
1006 1008
1007 // Set m_currentSrc *before* changing to the cache url, the fact that we are loading from the app 1009 // Set m_currentSrc *before* changing to the cache url, the fact that we are loading from the app
1008 // cache is an internal detail not exposed through the media element API. 1010 // cache is an internal detail not exposed through the media element API.
1009 m_currentSrc = url; 1011 m_currentSrc = url;
1010 1012
1011 if (m_audioSourceNode) 1013 if (m_audioSourceNode)
1012 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc); 1014 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc);
1013 1015
1014 MEDIA_LOG << "loadResource(" << (void*)this << ") - m_currentSrc -> " << url ForLoggingMedia(m_currentSrc); 1016 BLINK_MEDIA_LOG << "loadResource(" << (void*)this << ") - m_currentSrc -> " << urlForLoggingMedia(m_currentSrc);
1015 1017
1016 startProgressEventTimer(); 1018 startProgressEventTimer();
1017 1019
1018 // Reset display mode to force a recalculation of what to show because we ar e resetting the player. 1020 // Reset display mode to force a recalculation of what to show because we ar e resetting the player.
1019 setDisplayMode(Unknown); 1021 setDisplayMode(Unknown);
1020 1022
1021 setPlayerPreload(); 1023 setPlayerPreload();
1022 1024
1023 if (fastHasAttribute(mutedAttr)) 1025 if (fastHasAttribute(mutedAttr))
1024 m_muted = true; 1026 m_muted = true;
(...skipping 12 matching lines...) Expand all
1037 } 1039 }
1038 1040
1039 bool canLoadResource = source.isMediaStream() || canLoadURL(url, contentType ); 1041 bool canLoadResource = source.isMediaStream() || canLoadURL(url, contentType );
1040 if (attemptLoad && canLoadResource) { 1042 if (attemptLoad && canLoadResource) {
1041 DCHECK(!webMediaPlayer()); 1043 DCHECK(!webMediaPlayer());
1042 1044
1043 // Conditionally defer the load if effective preload is 'none'. 1045 // Conditionally defer the load if effective preload is 'none'.
1044 // Skip this optional deferral for MediaStream sources or any blob URL, 1046 // Skip this optional deferral for MediaStream sources or any blob URL,
1045 // including MediaSource blob URLs. 1047 // including MediaSource blob URLs.
1046 if (!source.isMediaStream() && !url.protocolIs("blob") && effectivePrelo adType() == WebMediaPlayer::PreloadNone) { 1048 if (!source.isMediaStream() && !url.protocolIs("blob") && effectivePrelo adType() == WebMediaPlayer::PreloadNone) {
1047 MEDIA_LOG << "loadResource(" << (void*)this << ") : Delaying load be cause preload == 'none'"; 1049 BLINK_MEDIA_LOG << "loadResource(" << (void*)this << ") : Delaying l oad because preload == 'none'";
1048 deferLoad(); 1050 deferLoad();
1049 } else { 1051 } else {
1050 startPlayerLoad(); 1052 startPlayerLoad();
1051 } 1053 }
1052 } else { 1054 } else {
1053 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 1055 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
1054 } 1056 }
1055 1057
1056 // If there is no poster to display, allow the media engine to render video frames as soon as 1058 // If there is no poster to display, allow the media engine to render video frames as soon as
1057 // they are available. 1059 // they are available.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 } 1260 }
1259 1261
1260 void HTMLMediaElement::disableAutomaticTextTrackSelection() 1262 void HTMLMediaElement::disableAutomaticTextTrackSelection()
1261 { 1263 {
1262 m_shouldPerformAutomaticTrackSelection = false; 1264 m_shouldPerformAutomaticTrackSelection = false;
1263 } 1265 }
1264 1266
1265 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI fInvalid) 1267 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI fInvalid)
1266 { 1268 {
1267 if (!url.isValid()) { 1269 if (!url.isValid()) {
1268 MEDIA_LOG << "isSafeToLoadURL(" << (void*)this << ", " << urlForLoggingM edia(url) << ") -> FALSE because url is invalid"; 1270 BLINK_MEDIA_LOG << "isSafeToLoadURL(" << (void*)this << ", " << urlForLo ggingMedia(url) << ") -> FALSE because url is invalid";
1269 return false; 1271 return false;
1270 } 1272 }
1271 1273
1272 LocalFrame* frame = document().frame(); 1274 LocalFrame* frame = document().frame();
1273 if (!frame || !document().getSecurityOrigin()->canDisplay(url)) { 1275 if (!frame || !document().getSecurityOrigin()->canDisplay(url)) {
1274 if (actionIfInvalid == Complain) 1276 if (actionIfInvalid == Complain)
1275 FrameLoader::reportLocalLoadFailed(frame, url.elidedString()); 1277 FrameLoader::reportLocalLoadFailed(frame, url.elidedString());
1276 MEDIA_LOG << "isSafeToLoadURL(" << (void*)this << ", " << urlForLoggingM edia(url) << ") -> FALSE rejected by SecurityOrigin"; 1278 BLINK_MEDIA_LOG << "isSafeToLoadURL(" << (void*)this << ", " << urlForLo ggingMedia(url) << ") -> FALSE rejected by SecurityOrigin";
1277 return false; 1279 return false;
1278 } 1280 }
1279 1281
1280 if (!document().contentSecurityPolicy()->allowMediaFromSource(url)) { 1282 if (!document().contentSecurityPolicy()->allowMediaFromSource(url)) {
1281 MEDIA_LOG << "isSafeToLoadURL(" << (void*)this << ", " << urlForLoggingM edia(url) << ") -> rejected by Content Security Policy"; 1283 BLINK_MEDIA_LOG << "isSafeToLoadURL(" << (void*)this << ", " << urlForLo ggingMedia(url) << ") -> rejected by Content Security Policy";
1282 return false; 1284 return false;
1283 } 1285 }
1284 1286
1285 return true; 1287 return true;
1286 } 1288 }
1287 1289
1288 bool HTMLMediaElement::isMediaDataCORSSameOrigin(SecurityOrigin* origin) const 1290 bool HTMLMediaElement::isMediaDataCORSSameOrigin(SecurityOrigin* origin) const
1289 { 1291 {
1290 // hasSingleSecurityOrigin() tells us whether the origin in the src is 1292 // hasSingleSecurityOrigin() tells us whether the origin in the src is
1291 // the same as the actual request (i.e. after redirect). 1293 // the same as the actual request (i.e. after redirect).
(...skipping 10 matching lines...) Expand all
1302 if (m_progressEventTimer.isActive()) 1304 if (m_progressEventTimer.isActive())
1303 return; 1305 return;
1304 1306
1305 m_previousProgressTime = WTF::currentTime(); 1307 m_previousProgressTime = WTF::currentTime();
1306 // 350ms is not magic, it is in the spec! 1308 // 350ms is not magic, it is in the spec!
1307 m_progressEventTimer.startRepeating(0.350, BLINK_FROM_HERE); 1309 m_progressEventTimer.startRepeating(0.350, BLINK_FROM_HERE);
1308 } 1310 }
1309 1311
1310 void HTMLMediaElement::waitForSourceChange() 1312 void HTMLMediaElement::waitForSourceChange()
1311 { 1313 {
1312 MEDIA_LOG << "waitForSourceChange(" << (void*)this << ")"; 1314 BLINK_MEDIA_LOG << "waitForSourceChange(" << (void*)this << ")";
1313 1315
1314 stopPeriodicTimers(); 1316 stopPeriodicTimers();
1315 m_loadState = WaitingForSource; 1317 m_loadState = WaitingForSource;
1316 1318
1317 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N O_SOURCE value 1319 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N O_SOURCE value
1318 setNetworkState(NETWORK_NO_SOURCE); 1320 setNetworkState(NETWORK_NO_SOURCE);
1319 1321
1320 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop s delaying the load event. 1322 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop s delaying the load event.
1321 setShouldDelayLoadEvent(false); 1323 setShouldDelayLoadEvent(false);
1322 1324
1323 updateDisplayState(); 1325 updateDisplayState();
1324 1326
1325 if (layoutObject()) 1327 if (layoutObject())
1326 layoutObject()->updateFromElement(); 1328 layoutObject()->updateFromElement();
1327 } 1329 }
1328 1330
1329 void HTMLMediaElement::noneSupported() 1331 void HTMLMediaElement::noneSupported()
1330 { 1332 {
1331 MEDIA_LOG << "noneSupported(" << (void*)this << ")"; 1333 BLINK_MEDIA_LOG << "noneSupported(" << (void*)this << ")";
1332 1334
1333 stopPeriodicTimers(); 1335 stopPeriodicTimers();
1334 m_loadState = WaitingForSource; 1336 m_loadState = WaitingForSource;
1335 m_currentSourceNode = nullptr; 1337 m_currentSourceNode = nullptr;
1336 1338
1337 // 4.8.13.5 1339 // 4.8.13.5
1338 // The dedicated media source failure steps are the following steps: 1340 // The dedicated media source failure steps are the following steps:
1339 1341
1340 // 1 - Set the error attribute to a new MediaError object whose code attribu te is set to 1342 // 1 - Set the error attribute to a new MediaError object whose code attribu te is set to
1341 // MEDIA_ERR_SRC_NOT_SUPPORTED. 1343 // MEDIA_ERR_SRC_NOT_SUPPORTED.
(...skipping 19 matching lines...) Expand all
1361 // 7 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 1363 // 7 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
1362 setShouldDelayLoadEvent(false); 1364 setShouldDelayLoadEvent(false);
1363 1365
1364 if (layoutObject()) 1366 if (layoutObject())
1365 layoutObject()->updateFromElement(); 1367 layoutObject()->updateFromElement();
1366 } 1368 }
1367 1369
1368 void HTMLMediaElement::mediaEngineError(MediaError* err) 1370 void HTMLMediaElement::mediaEngineError(MediaError* err)
1369 { 1371 {
1370 DCHECK_GE(m_readyState, HAVE_METADATA); 1372 DCHECK_GE(m_readyState, HAVE_METADATA);
1371 MEDIA_LOG << "mediaEngineError(" << (void*)this << ", " << static_cast<int>( err->code()) << ")"; 1373 BLINK_MEDIA_LOG << "mediaEngineError(" << (void*)this << ", " << static_cast <int>(err->code()) << ")";
1372 1374
1373 // 1 - The user agent should cancel the fetching process. 1375 // 1 - The user agent should cancel the fetching process.
1374 stopPeriodicTimers(); 1376 stopPeriodicTimers();
1375 m_loadState = WaitingForSource; 1377 m_loadState = WaitingForSource;
1376 1378
1377 // 2 - Set the error attribute to a new MediaError object whose code attribu te is 1379 // 2 - Set the error attribute to a new MediaError object whose code attribu te is
1378 // set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE. 1380 // set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE.
1379 m_error = err; 1381 m_error = err;
1380 1382
1381 // 3 - Queue a task to fire a simple event named error at the media element. 1383 // 3 - Queue a task to fire a simple event named error at the media element.
1382 scheduleEvent(EventTypeNames::error); 1384 scheduleEvent(EventTypeNames::error);
1383 1385
1384 // 4 - Set the element's networkState attribute to the NETWORK_IDLE value. 1386 // 4 - Set the element's networkState attribute to the NETWORK_IDLE value.
1385 setNetworkState(NETWORK_IDLE); 1387 setNetworkState(NETWORK_IDLE);
1386 1388
1387 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 1389 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
1388 setShouldDelayLoadEvent(false); 1390 setShouldDelayLoadEvent(false);
1389 1391
1390 // 6 - Abort the overall resource selection algorithm. 1392 // 6 - Abort the overall resource selection algorithm.
1391 m_currentSourceNode = nullptr; 1393 m_currentSourceNode = nullptr;
1392 } 1394 }
1393 1395
1394 void HTMLMediaElement::cancelPendingEventsAndCallbacks() 1396 void HTMLMediaElement::cancelPendingEventsAndCallbacks()
1395 { 1397 {
1396 MEDIA_LOG << "cancelPendingEventsAndCallbacks(" << (void*)this << ")"; 1398 BLINK_MEDIA_LOG << "cancelPendingEventsAndCallbacks(" << (void*)this << ")";
1397 m_asyncEventQueue->cancelAllEvents(); 1399 m_asyncEventQueue->cancelAllEvents();
1398 1400
1399 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) 1401 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source))
1400 source->cancelPendingErrorEvent(); 1402 source->cancelPendingErrorEvent();
1401 1403
1402 m_playPromiseResolveTask->cancel(); 1404 m_playPromiseResolveTask->cancel();
1403 m_playPromiseResolveList.clear(); 1405 m_playPromiseResolveList.clear();
1404 m_playPromiseRejectTask->cancel(); 1406 m_playPromiseRejectTask->cancel();
1405 m_playPromiseRejectList.clear(); 1407 m_playPromiseRejectList.clear();
1406 } 1408 }
1407 1409
1408 void HTMLMediaElement::networkStateChanged() 1410 void HTMLMediaElement::networkStateChanged()
1409 { 1411 {
1410 setNetworkState(webMediaPlayer()->getNetworkState()); 1412 setNetworkState(webMediaPlayer()->getNetworkState());
1411 } 1413 }
1412 1414
1413 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) 1415 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error)
1414 { 1416 {
1415 stopPeriodicTimers(); 1417 stopPeriodicTimers();
1416 1418
1417 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more 1419 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more
1418 // <source> children, schedule the next one 1420 // <source> children, schedule the next one
1419 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement) { 1421 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement) {
1420 1422
1421 // resource selection algorithm 1423 // resource selection algorithm
1422 // 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. 1424 // 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.
1423 if (m_currentSourceNode) 1425 if (m_currentSourceNode)
1424 m_currentSourceNode->scheduleErrorEvent(); 1426 m_currentSourceNode->scheduleErrorEvent();
1425 else 1427 else
1426 MEDIA_LOG << "setNetworkState(" << (void*)this << ") - error event n ot sent, <source> was removed"; 1428 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ") - error e vent not sent, <source> was removed";
1427 1429
1428 // 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. 1430 // 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.
1429 1431
1430 // 9.Otherwise.11 - Forget the media element's media-resource-specific t racks. 1432 // 9.Otherwise.11 - Forget the media element's media-resource-specific t racks.
1431 forgetResourceSpecificTracks(); 1433 forgetResourceSpecificTracks();
1432 1434
1433 if (havePotentialSourceChild()) { 1435 if (havePotentialSourceChild()) {
1434 MEDIA_LOG << "setNetworkState(" << (void*)this << ") - scheduling ne xt <source>"; 1436 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ") - schedul ing next <source>";
1435 scheduleNextSourceChild(); 1437 scheduleNextSourceChild();
1436 } else { 1438 } else {
1437 MEDIA_LOG << "setNetworkState(" << (void*)this << ") - no more <sour ce> elements, waiting"; 1439 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ") - no more <source> elements, waiting";
1438 waitForSourceChange(); 1440 waitForSourceChange();
1439 } 1441 }
1440 1442
1441 return; 1443 return;
1442 } 1444 }
1443 1445
1444 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA) 1446 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA)
1445 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); 1447 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK));
1446 else if (error == WebMediaPlayer::NetworkStateDecodeError) 1448 else if (error == WebMediaPlayer::NetworkStateDecodeError)
1447 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); 1449 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE));
1448 else if ((error == WebMediaPlayer::NetworkStateFormatError 1450 else if ((error == WebMediaPlayer::NetworkStateFormatError
1449 || error == WebMediaPlayer::NetworkStateNetworkError) 1451 || error == WebMediaPlayer::NetworkStateNetworkError)
1450 && m_loadState == LoadingFromSrcAttr) 1452 && m_loadState == LoadingFromSrcAttr)
1451 noneSupported(); 1453 noneSupported();
1452 1454
1453 updateDisplayState(); 1455 updateDisplayState();
1454 if (mediaControls()) 1456 if (mediaControls())
1455 mediaControls()->reset(); 1457 mediaControls()->reset();
1456 } 1458 }
1457 1459
1458 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) 1460 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state)
1459 { 1461 {
1460 MEDIA_LOG << "setNetworkState(" << (void*)this << ", " << static_cast<int>(s tate) << ") - current state is " << static_cast<int>(m_networkState); 1462 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ", " << static_cast< int>(state) << ") - current state is " << static_cast<int>(m_networkState);
1461 1463
1462 if (state == WebMediaPlayer::NetworkStateEmpty) { 1464 if (state == WebMediaPlayer::NetworkStateEmpty) {
1463 // Just update the cached state and leave, we can't do anything. 1465 // Just update the cached state and leave, we can't do anything.
1464 setNetworkState(NETWORK_EMPTY); 1466 setNetworkState(NETWORK_EMPTY);
1465 return; 1467 return;
1466 } 1468 }
1467 1469
1468 if (state == WebMediaPlayer::NetworkStateFormatError 1470 if (state == WebMediaPlayer::NetworkStateFormatError
1469 || state == WebMediaPlayer::NetworkStateNetworkError 1471 || state == WebMediaPlayer::NetworkStateNetworkError
1470 || state == WebMediaPlayer::NetworkStateDecodeError) { 1472 || state == WebMediaPlayer::NetworkStateDecodeError) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 setNetworkState(NETWORK_IDLE); 1507 setNetworkState(NETWORK_IDLE);
1506 } 1508 }
1507 1509
1508 void HTMLMediaElement::readyStateChanged() 1510 void HTMLMediaElement::readyStateChanged()
1509 { 1511 {
1510 setReadyState(static_cast<ReadyState>(webMediaPlayer()->getReadyState())); 1512 setReadyState(static_cast<ReadyState>(webMediaPlayer()->getReadyState()));
1511 } 1513 }
1512 1514
1513 void HTMLMediaElement::setReadyState(ReadyState state) 1515 void HTMLMediaElement::setReadyState(ReadyState state)
1514 { 1516 {
1515 MEDIA_LOG << "setReadyState(" << (void*)this << ", " << static_cast<int>(sta te) << ") - current state is " << static_cast<int>(m_readyState); 1517 BLINK_MEDIA_LOG << "setReadyState(" << (void*)this << ", " << static_cast<in t>(state) << ") - current state is " << static_cast<int>(m_readyState);
1516 1518
1517 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it 1519 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it
1518 bool wasPotentiallyPlaying = potentiallyPlaying(); 1520 bool wasPotentiallyPlaying = potentiallyPlaying();
1519 1521
1520 ReadyState oldState = m_readyState; 1522 ReadyState oldState = m_readyState;
1521 ReadyState newState = state; 1523 ReadyState newState = state;
1522 1524
1523 bool tracksAreReady = textTracksAreReady(); 1525 bool tracksAreReady = textTracksAreReady();
1524 1526
1525 if (newState == oldState && m_tracksAreReady == tracksAreReady) 1527 if (newState == oldState && m_tracksAreReady == tracksAreReady)
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 layoutObject()->updateFromElement(); 1684 layoutObject()->updateFromElement();
1683 } else if (timedelta > 3.0 && !m_sentStalledEvent) { 1685 } else if (timedelta > 3.0 && !m_sentStalledEvent) {
1684 scheduleEvent(EventTypeNames::stalled); 1686 scheduleEvent(EventTypeNames::stalled);
1685 m_sentStalledEvent = true; 1687 m_sentStalledEvent = true;
1686 setShouldDelayLoadEvent(false); 1688 setShouldDelayLoadEvent(false);
1687 } 1689 }
1688 } 1690 }
1689 1691
1690 void HTMLMediaElement::addPlayedRange(double start, double end) 1692 void HTMLMediaElement::addPlayedRange(double start, double end)
1691 { 1693 {
1692 MEDIA_LOG << "addPlayedRange(" << (void*)this << ", " << start << ", " << en d << ")"; 1694 BLINK_MEDIA_LOG << "addPlayedRange(" << (void*)this << ", " << start << ", " << end << ")";
1693 if (!m_playedTimeRanges) 1695 if (!m_playedTimeRanges)
1694 m_playedTimeRanges = TimeRanges::create(); 1696 m_playedTimeRanges = TimeRanges::create();
1695 m_playedTimeRanges->add(start, end); 1697 m_playedTimeRanges->add(start, end);
1696 } 1698 }
1697 1699
1698 bool HTMLMediaElement::supportsSave() const 1700 bool HTMLMediaElement::supportsSave() const
1699 { 1701 {
1700 return webMediaPlayer() && webMediaPlayer()->supportsSave(); 1702 return webMediaPlayer() && webMediaPlayer()->supportsSave();
1701 } 1703 }
1702 1704
1703 void HTMLMediaElement::setIgnorePreloadNone() 1705 void HTMLMediaElement::setIgnorePreloadNone()
1704 { 1706 {
1705 MEDIA_LOG << "setIgnorePreloadNone(" << (void*)this << ")"; 1707 BLINK_MEDIA_LOG << "setIgnorePreloadNone(" << (void*)this << ")";
1706 m_ignorePreloadNone = true; 1708 m_ignorePreloadNone = true;
1707 setPlayerPreload(); 1709 setPlayerPreload();
1708 } 1710 }
1709 1711
1710 void HTMLMediaElement::seek(double time) 1712 void HTMLMediaElement::seek(double time)
1711 { 1713 {
1712 MEDIA_LOG << "seek(" << (void*)this << ", " << time << ")"; 1714 BLINK_MEDIA_LOG << "seek(" << (void*)this << ", " << time << ")";
1713 1715
1714 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. 1716 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps.
1715 // FIXME: remove m_webMediaPlayer check once we figure out how 1717 // FIXME: remove m_webMediaPlayer check once we figure out how
1716 // m_webMediaPlayer is going out of sync with readystate. 1718 // m_webMediaPlayer is going out of sync with readystate.
1717 // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING. 1719 // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING.
1718 if (!m_webMediaPlayer || m_readyState == HAVE_NOTHING) 1720 if (!m_webMediaPlayer || m_readyState == HAVE_NOTHING)
1719 return; 1721 return;
1720 1722
1721 // Ignore preload none and start load if necessary. 1723 // Ignore preload none and start load if necessary.
1722 setIgnorePreloadNone(); 1724 setIgnorePreloadNone();
(...skipping 19 matching lines...) Expand all
1742 // 7 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. 1744 // 7 - If the new playback position is less than the earliest possible posit ion, let it be that position instead.
1743 time = std::max(time, 0.0); 1745 time = std::max(time, 0.0);
1744 1746
1745 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This 1747 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This
1746 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's 1748 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's
1747 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and 1749 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and
1748 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never 1750 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never
1749 // fire a 'seeked' event. 1751 // fire a 'seeked' event.
1750 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); 1752 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time);
1751 if (time != mediaTime) { 1753 if (time != mediaTime) {
1752 MEDIA_LOG << "seek(" << (void*)this << ", " << time << ") - media timeli ne equivalent is " << mediaTime; 1754 BLINK_MEDIA_LOG << "seek(" << (void*)this << ", " << time << ") - media timeline equivalent is " << mediaTime;
1753 time = mediaTime; 1755 time = mediaTime;
1754 } 1756 }
1755 1757
1756 // 8 - If the (possibly now changed) new playback position is not in one of the ranges given in the 1758 // 8 - If the (possibly now changed) new playback position is not in one of the ranges given in the
1757 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute 1759 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute
1758 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable 1760 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable
1759 // attribute then set the seeking IDL attribute to false and abort these ste ps. 1761 // attribute then set the seeking IDL attribute to false and abort these ste ps.
1760 TimeRanges* seekableRanges = seekable(); 1762 TimeRanges* seekableRanges = seekable();
1761 1763
1762 if (!seekableRanges->length()) { 1764 if (!seekableRanges->length()) {
(...skipping 12 matching lines...) Expand all
1775 1777
1776 // 11 - Set the current playback position to the given new playback position . 1778 // 11 - Set the current playback position to the given new playback position .
1777 webMediaPlayer()->seek(time); 1779 webMediaPlayer()->seek(time);
1778 1780
1779 // 14-17 are handled, if necessary, when the engine signals a readystate cha nge or otherwise 1781 // 14-17 are handled, if necessary, when the engine signals a readystate cha nge or otherwise
1780 // satisfies seek completion and signals a time change. 1782 // satisfies seek completion and signals a time change.
1781 } 1783 }
1782 1784
1783 void HTMLMediaElement::finishSeek() 1785 void HTMLMediaElement::finishSeek()
1784 { 1786 {
1785 MEDIA_LOG << "finishSeek(" << (void*)this << ")"; 1787 BLINK_MEDIA_LOG << "finishSeek(" << (void*)this << ")";
1786 1788
1787 // 14 - Set the seeking IDL attribute to false. 1789 // 14 - Set the seeking IDL attribute to false.
1788 m_seeking = false; 1790 m_seeking = false;
1789 1791
1790 // 16 - Queue a task to fire a simple event named timeupdate at the element. 1792 // 16 - Queue a task to fire a simple event named timeupdate at the element.
1791 scheduleTimeupdateEvent(false); 1793 scheduleTimeupdateEvent(false);
1792 1794
1793 // 17 - Queue a task to fire a simple event named seeked at the element. 1795 // 17 - Queue a task to fire a simple event named seeked at the element.
1794 scheduleEvent(EventTypeNames::seeked); 1796 scheduleEvent(EventTypeNames::seeked);
1795 1797
(...skipping 25 matching lines...) Expand all
1821 void HTMLMediaElement::refreshCachedTime() const 1823 void HTMLMediaElement::refreshCachedTime() const
1822 { 1824 {
1823 if (!webMediaPlayer() || m_readyState < HAVE_METADATA) 1825 if (!webMediaPlayer() || m_readyState < HAVE_METADATA)
1824 return; 1826 return;
1825 1827
1826 m_cachedTime = webMediaPlayer()->currentTime(); 1828 m_cachedTime = webMediaPlayer()->currentTime();
1827 } 1829 }
1828 1830
1829 void HTMLMediaElement::invalidateCachedTime() 1831 void HTMLMediaElement::invalidateCachedTime()
1830 { 1832 {
1831 MEDIA_LOG << "invalidateCachedTime(" << (void*)this << ")"; 1833 BLINK_MEDIA_LOG << "invalidateCachedTime(" << (void*)this << ")";
1832 m_cachedTime = std::numeric_limits<double>::quiet_NaN(); 1834 m_cachedTime = std::numeric_limits<double>::quiet_NaN();
1833 } 1835 }
1834 1836
1835 // playback state 1837 // playback state
1836 double HTMLMediaElement::currentTime() const 1838 double HTMLMediaElement::currentTime() const
1837 { 1839 {
1838 if (m_defaultPlaybackStartPosition) 1840 if (m_defaultPlaybackStartPosition)
1839 return m_defaultPlaybackStartPosition; 1841 return m_defaultPlaybackStartPosition;
1840 1842
1841 if (m_readyState == HAVE_NOTHING) 1843 if (m_readyState == HAVE_NOTHING)
1842 return 0; 1844 return 0;
1843 1845
1844 if (m_seeking) { 1846 if (m_seeking) {
1845 MEDIA_LOG << "currentTime(" << (void*)this << ") - seeking, returning " << m_lastSeekTime; 1847 BLINK_MEDIA_LOG << "currentTime(" << (void*)this << ") - seeking, return ing " << m_lastSeekTime;
1846 return m_lastSeekTime; 1848 return m_lastSeekTime;
1847 } 1849 }
1848 1850
1849 if (!std::isnan(m_cachedTime) && m_paused) { 1851 if (!std::isnan(m_cachedTime) && m_paused) {
1850 #if LOG_CACHED_TIME_WARNINGS 1852 #if LOG_CACHED_TIME_WARNINGS
1851 static const double minCachedDeltaForWarning = 0.01; 1853 static const double minCachedDeltaForWarning = 0.01;
1852 double delta = m_cachedTime - webMediaPlayer()->currentTime(); 1854 double delta = m_cachedTime - webMediaPlayer()->currentTime();
1853 if (delta > minCachedDeltaForWarning) 1855 if (delta > minCachedDeltaForWarning)
1854 MEDIA_LOG << "currentTime(" << (void*)this << ") - WARNING, cached t ime is " << delta << "seconds off of media time when paused"; 1856 BLINK_MEDIA_LOG << "currentTime(" << (void*)this << ") - WARNING, ca ched time is " << delta << "seconds off of media time when paused";
1855 #endif 1857 #endif
1856 return m_cachedTime; 1858 return m_cachedTime;
1857 } 1859 }
1858 1860
1859 refreshCachedTime(); 1861 refreshCachedTime();
1860 1862
1861 return m_cachedTime; 1863 return m_cachedTime;
1862 } 1864 }
1863 1865
1864 void HTMLMediaElement::setCurrentTime(double time) 1866 void HTMLMediaElement::setCurrentTime(double time)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 scheduleEvent(EventTypeNames::ratechange); 1918 scheduleEvent(EventTypeNames::ratechange);
1917 } 1919 }
1918 1920
1919 double HTMLMediaElement::playbackRate() const 1921 double HTMLMediaElement::playbackRate() const
1920 { 1922 {
1921 return m_playbackRate; 1923 return m_playbackRate;
1922 } 1924 }
1923 1925
1924 void HTMLMediaElement::setPlaybackRate(double rate) 1926 void HTMLMediaElement::setPlaybackRate(double rate)
1925 { 1927 {
1926 MEDIA_LOG << "setPlaybackRate(" << (void*)this << ", " << rate << ")"; 1928 BLINK_MEDIA_LOG << "setPlaybackRate(" << (void*)this << ", " << rate << ")";
1927 1929
1928 if (m_playbackRate != rate) { 1930 if (m_playbackRate != rate) {
1929 m_playbackRate = rate; 1931 m_playbackRate = rate;
1930 invalidateCachedTime(); 1932 invalidateCachedTime();
1931 scheduleEvent(EventTypeNames::ratechange); 1933 scheduleEvent(EventTypeNames::ratechange);
1932 } 1934 }
1933 1935
1934 updatePlaybackRate(); 1936 updatePlaybackRate();
1935 } 1937 }
1936 1938
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 return false; 1978 return false;
1977 } 1979 }
1978 1980
1979 String HTMLMediaElement::preload() const 1981 String HTMLMediaElement::preload() const
1980 { 1982 {
1981 return preloadTypeToString(preloadType()); 1983 return preloadTypeToString(preloadType());
1982 } 1984 }
1983 1985
1984 void HTMLMediaElement::setPreload(const AtomicString& preload) 1986 void HTMLMediaElement::setPreload(const AtomicString& preload)
1985 { 1987 {
1986 MEDIA_LOG << "setPreload(" << (void*)this << ", " << preload << ")"; 1988 BLINK_MEDIA_LOG << "setPreload(" << (void*)this << ", " << preload << ")";
1987 setAttribute(preloadAttr, preload); 1989 setAttribute(preloadAttr, preload);
1988 } 1990 }
1989 1991
1990 WebMediaPlayer::Preload HTMLMediaElement::preloadType() const 1992 WebMediaPlayer::Preload HTMLMediaElement::preloadType() const
1991 { 1993 {
1992 // Force preload to none for cellular connections or when data saver is expl icitly set. 1994 // Force preload to none for cellular connections or when data saver is expl icitly set.
1993 if (networkStateNotifier().isCellularConnectionType() 1995 if (networkStateNotifier().isCellularConnectionType()
1994 || (document().settings() && document().settings()->dataSaverEnabled())) { 1996 || (document().settings() && document().settings()->dataSaverEnabled())) {
1995 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadForcedN one); 1997 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadForcedN one);
1996 return WebMediaPlayer::PreloadNone; 1998 return WebMediaPlayer::PreloadNone;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 } 2071 }
2070 resolver->reject(DOMException::create(code.get(), message)); 2072 resolver->reject(DOMException::create(code.get(), message));
2071 return promise; 2073 return promise;
2072 } 2074 }
2073 2075
2074 return promise; 2076 return promise;
2075 } 2077 }
2076 2078
2077 Nullable<ExceptionCode> HTMLMediaElement::play() 2079 Nullable<ExceptionCode> HTMLMediaElement::play()
2078 { 2080 {
2079 MEDIA_LOG << "play(" << (void*)this << ")"; 2081 BLINK_MEDIA_LOG << "play(" << (void*)this << ")";
2080 2082
2081 m_autoplayHelper->playMethodCalled(); 2083 m_autoplayHelper->playMethodCalled();
2082 2084
2083 if (!UserGestureIndicator::processingUserGesture()) { 2085 if (!UserGestureIndicator::processingUserGesture()) {
2084 recordAutoplaySourceMetric(AutoplaySourceMethod); 2086 recordAutoplaySourceMetric(AutoplaySourceMethod);
2085 if (isGestureNeededForPlayback()) { 2087 if (isGestureNeededForPlayback()) {
2086 // If playback is deferred, then don't start playback but don't 2088 // If playback is deferred, then don't start playback but don't
2087 // fail yet either. 2089 // fail yet either.
2088 if (m_autoplayHelper->isPlaybackDeferred()) 2090 if (m_autoplayHelper->isPlaybackDeferred())
2089 return nullptr; 2091 return nullptr;
(...skipping 21 matching lines...) Expand all
2111 if (m_error && m_error->code() == MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED) 2113 if (m_error && m_error->code() == MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED)
2112 return NotSupportedError; 2114 return NotSupportedError;
2113 2115
2114 playInternal(); 2116 playInternal();
2115 2117
2116 return nullptr; 2118 return nullptr;
2117 } 2119 }
2118 2120
2119 void HTMLMediaElement::playInternal() 2121 void HTMLMediaElement::playInternal()
2120 { 2122 {
2121 MEDIA_LOG << "playInternal(" << (void*)this << ")"; 2123 BLINK_MEDIA_LOG << "playInternal(" << (void*)this << ")";
2122 2124
2123 // Always return the buffering strategy to normal when not paused, 2125 // Always return the buffering strategy to normal when not paused,
2124 // regardless of the cause. (In contrast with aggressive buffering which is 2126 // regardless of the cause. (In contrast with aggressive buffering which is
2125 // only enabled by pause(), not pauseInternal().) 2127 // only enabled by pause(), not pauseInternal().)
2126 if (webMediaPlayer()) 2128 if (webMediaPlayer())
2127 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal); 2129 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal);
2128 2130
2129 // 4.8.10.9. Playing the media resource 2131 // 4.8.10.9. Playing the media resource
2130 if (m_networkState == NETWORK_EMPTY) 2132 if (m_networkState == NETWORK_EMPTY)
2131 invokeResourceSelectionAlgorithm(); 2133 invokeResourceSelectionAlgorithm();
(...skipping 18 matching lines...) Expand all
2150 } 2152 }
2151 2153
2152 m_autoplaying = false; 2154 m_autoplaying = false;
2153 2155
2154 setIgnorePreloadNone(); 2156 setIgnorePreloadNone();
2155 updatePlayState(); 2157 updatePlayState();
2156 } 2158 }
2157 2159
2158 void HTMLMediaElement::pause() 2160 void HTMLMediaElement::pause()
2159 { 2161 {
2160 MEDIA_LOG << "pause(" << (void*)this << ")"; 2162 BLINK_MEDIA_LOG << "pause(" << (void*)this << ")";
2161 2163
2162 // Only buffer aggressively on a user-initiated pause. Other types of pauses 2164 // Only buffer aggressively on a user-initiated pause. Other types of pauses
2163 // (which go directly to pauseInternal()) should not cause this behavior. 2165 // (which go directly to pauseInternal()) should not cause this behavior.
2164 if (webMediaPlayer() && UserGestureIndicator::utilizeUserGesture()) 2166 if (webMediaPlayer() && UserGestureIndicator::utilizeUserGesture())
2165 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Aggressive); 2167 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Aggressive);
2166 2168
2167 pauseInternal(); 2169 pauseInternal();
2168 } 2170 }
2169 2171
2170 void HTMLMediaElement::pauseInternal() 2172 void HTMLMediaElement::pauseInternal()
2171 { 2173 {
2172 MEDIA_LOG << "pauseInternal(" << (void*)this << ")"; 2174 BLINK_MEDIA_LOG << "pauseInternal(" << (void*)this << ")";
2173 2175
2174 if (m_networkState == NETWORK_EMPTY) 2176 if (m_networkState == NETWORK_EMPTY)
2175 invokeResourceSelectionAlgorithm(); 2177 invokeResourceSelectionAlgorithm();
2176 2178
2177 m_autoplayHelper->pauseMethodCalled(); 2179 m_autoplayHelper->pauseMethodCalled();
2178 2180
2179 m_autoplaying = false; 2181 m_autoplaying = false;
2180 2182
2181 if (!m_paused) { 2183 if (!m_paused) {
2182 m_paused = true; 2184 m_paused = true;
(...skipping 28 matching lines...) Expand all
2211 m_mediaSource = nullptr; 2213 m_mediaSource = nullptr;
2212 } 2214 }
2213 2215
2214 bool HTMLMediaElement::loop() const 2216 bool HTMLMediaElement::loop() const
2215 { 2217 {
2216 return fastHasAttribute(loopAttr); 2218 return fastHasAttribute(loopAttr);
2217 } 2219 }
2218 2220
2219 void HTMLMediaElement::setLoop(bool b) 2221 void HTMLMediaElement::setLoop(bool b)
2220 { 2222 {
2221 MEDIA_LOG << "setLoop(" << (void*)this << ", " << boolString(b) << ")"; 2223 BLINK_MEDIA_LOG << "setLoop(" << (void*)this << ", " << boolString(b) << ")" ;
2222 setBooleanAttribute(loopAttr, b); 2224 setBooleanAttribute(loopAttr, b);
2223 } 2225 }
2224 2226
2225 bool HTMLMediaElement::shouldShowControls(const RecordMetricsBehavior recordMetr ics) const 2227 bool HTMLMediaElement::shouldShowControls(const RecordMetricsBehavior recordMetr ics) const
2226 { 2228 {
2227 if (fastHasAttribute(controlsAttr)) { 2229 if (fastHasAttribute(controlsAttr)) {
2228 if (recordMetrics == RecordMetricsBehavior::DoRecord) 2230 if (recordMetrics == RecordMetricsBehavior::DoRecord)
2229 showControlsHistogram().count(MediaControlsShowAttribute); 2231 showControlsHistogram().count(MediaControlsShowAttribute);
2230 return true; 2232 return true;
2231 } 2233 }
(...skipping 16 matching lines...) Expand all
2248 return false; 2250 return false;
2249 } 2251 }
2250 2252
2251 double HTMLMediaElement::volume() const 2253 double HTMLMediaElement::volume() const
2252 { 2254 {
2253 return m_volume; 2255 return m_volume;
2254 } 2256 }
2255 2257
2256 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState) 2258 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState)
2257 { 2259 {
2258 MEDIA_LOG << "setVolume(" << (void*)this << ", " << vol << ")"; 2260 BLINK_MEDIA_LOG << "setVolume(" << (void*)this << ", " << vol << ")";
2259 2261
2260 if (m_volume == vol) 2262 if (m_volume == vol)
2261 return; 2263 return;
2262 2264
2263 if (vol < 0.0f || vol > 1.0f) { 2265 if (vol < 0.0f || vol > 1.0f) {
2264 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", vol, 0.0, ExceptionMessages::InclusiveBound, 1.0, Except ionMessages::InclusiveBound)); 2266 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", vol, 0.0, ExceptionMessages::InclusiveBound, 1.0, Except ionMessages::InclusiveBound));
2265 return; 2267 return;
2266 } 2268 }
2267 2269
2268 Platform::current()->recordAction(UserMetricsAction("Media_SetVolume")); 2270 Platform::current()->recordAction(UserMetricsAction("Media_SetVolume"));
2269 2271
2270 m_volume = vol; 2272 m_volume = vol;
2271 updateVolume(); 2273 updateVolume();
2272 scheduleEvent(EventTypeNames::volumechange); 2274 scheduleEvent(EventTypeNames::volumechange);
2273 } 2275 }
2274 2276
2275 bool HTMLMediaElement::muted() const 2277 bool HTMLMediaElement::muted() const
2276 { 2278 {
2277 return m_muted; 2279 return m_muted;
2278 } 2280 }
2279 2281
2280 void HTMLMediaElement::setMuted(bool muted) 2282 void HTMLMediaElement::setMuted(bool muted)
2281 { 2283 {
2282 MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) << ")"; 2284 BLINK_MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) < < ")";
2283 2285
2284 if (m_muted == muted) 2286 if (m_muted == muted)
2285 return; 2287 return;
2286 2288
2287 bool wasAutoplayingMuted = !paused() && m_muted && isLockedPendingUserGestur e(); 2289 bool wasAutoplayingMuted = !paused() && m_muted && isLockedPendingUserGestur e();
2288 2290
2289 if (UserGestureIndicator::processingUserGesture()) 2291 if (UserGestureIndicator::processingUserGesture())
2290 unlockUserGesture(); 2292 unlockUserGesture();
2291 2293
2292 m_muted = muted; 2294 m_muted = muted;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 } 2395 }
2394 2396
2395 AudioTrackList& HTMLMediaElement::audioTracks() 2397 AudioTrackList& HTMLMediaElement::audioTracks()
2396 { 2398 {
2397 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2399 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2398 return *m_audioTracks; 2400 return *m_audioTracks;
2399 } 2401 }
2400 2402
2401 void HTMLMediaElement::audioTrackChanged(WebMediaPlayer::TrackId trackId, bool e nabled) 2403 void HTMLMediaElement::audioTrackChanged(WebMediaPlayer::TrackId trackId, bool e nabled)
2402 { 2404 {
2403 MEDIA_LOG << "audioTrackChanged(" << (void*)this << ") trackId= " << String( trackId) << " enabled=" << boolString(enabled); 2405 BLINK_MEDIA_LOG << "audioTrackChanged(" << (void*)this << ") trackId= " << S tring(trackId) << " enabled=" << boolString(enabled);
2404 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2406 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2405 2407
2406 audioTracks().scheduleChangeEvent(); 2408 audioTracks().scheduleChangeEvent();
2407 2409
2408 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.audioTracks attribute is added. 2410 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.audioTracks attribute is added.
2409 2411
2410 if (!m_audioTracksTimer.isActive()) 2412 if (!m_audioTracksTimer.isActive())
2411 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE); 2413 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE);
2412 } 2414 }
2413 2415
2414 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) 2416 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*)
2415 { 2417 {
2416 Vector<WebMediaPlayer::TrackId> enabledTrackIds; 2418 Vector<WebMediaPlayer::TrackId> enabledTrackIds;
2417 for (unsigned i = 0; i < audioTracks().length(); ++i) { 2419 for (unsigned i = 0; i < audioTracks().length(); ++i) {
2418 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); 2420 AudioTrack* track = audioTracks().anonymousIndexedGetter(i);
2419 if (track->enabled()) 2421 if (track->enabled())
2420 enabledTrackIds.append(track->id()); 2422 enabledTrackIds.append(track->id());
2421 } 2423 }
2422 2424
2423 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); 2425 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds);
2424 } 2426 }
2425 2427
2426 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, Web MediaPlayerClient::AudioTrackKind kind, const WebString& label, const WebString& language, bool enabled) 2428 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, Web MediaPlayerClient::AudioTrackKind kind, const WebString& label, const WebString& language, bool enabled)
2427 { 2429 {
2428 AtomicString kindString = AudioKindToString(kind); 2430 AtomicString kindString = AudioKindToString(kind);
2429 MEDIA_LOG << "addAudioTrack(" << (void*)this << ", '" << (String)id << "', ' " << (AtomicString)kindString 2431 BLINK_MEDIA_LOG << "addAudioTrack(" << (void*)this << ", '" << (String)id << "', ' " << (AtomicString)kindString
2430 << "', '" << (String)label << "', '" << (String)language << "', " << boo lString(enabled) << ")"; 2432 << "', '" << (String)label << "', '" << (String)language << "', " << boo lString(enabled) << ")";
2431 2433
2432 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2434 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2433 return blink::WebMediaPlayer::TrackId(); 2435 return blink::WebMediaPlayer::TrackId();
2434 2436
2435 AudioTrack* audioTrack = AudioTrack::create(id, kindString, label, language, enabled); 2437 AudioTrack* audioTrack = AudioTrack::create(id, kindString, label, language, enabled);
2436 audioTracks().add(audioTrack); 2438 audioTracks().add(audioTrack);
2437 2439
2438 return audioTrack->id(); 2440 return audioTrack->id();
2439 } 2441 }
2440 2442
2441 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) 2443 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId)
2442 { 2444 {
2443 MEDIA_LOG << "removeAudioTrack(" << (void*)this << ")"; 2445 BLINK_MEDIA_LOG << "removeAudioTrack(" << (void*)this << ")";
2444 2446
2445 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2447 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2446 return; 2448 return;
2447 2449
2448 audioTracks().remove(trackId); 2450 audioTracks().remove(trackId);
2449 } 2451 }
2450 2452
2451 VideoTrackList& HTMLMediaElement::videoTracks() 2453 VideoTrackList& HTMLMediaElement::videoTracks()
2452 { 2454 {
2453 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2455 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2454 return *m_videoTracks; 2456 return *m_videoTracks;
2455 } 2457 }
2456 2458
2457 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select edTrackId) 2459 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select edTrackId)
2458 { 2460 {
2459 MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this << ") selectedTrack Id=" << (selectedTrackId ? String(*selectedTrackId) : "none"); 2461 BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this << ") selecte dTrackId=" << (selectedTrackId ? String(*selectedTrackId) : "none");
2460 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2462 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2461 2463
2462 if (selectedTrackId) 2464 if (selectedTrackId)
2463 videoTracks().trackSelected(*selectedTrackId); 2465 videoTracks().trackSelected(*selectedTrackId);
2464 2466
2465 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. 2467 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added.
2466 2468
2467 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); 2469 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId);
2468 } 2470 }
2469 2471
2470 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, Web MediaPlayerClient::VideoTrackKind kind, const WebString& label, const WebString& language, bool selected) 2472 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, Web MediaPlayerClient::VideoTrackKind kind, const WebString& label, const WebString& language, bool selected)
2471 { 2473 {
2472 AtomicString kindString = VideoKindToString(kind); 2474 AtomicString kindString = VideoKindToString(kind);
2473 MEDIA_LOG << "addVideoTrack(" << (void*)this << ", '" << (String)id << "', ' " << (AtomicString)kindString 2475 BLINK_MEDIA_LOG << "addVideoTrack(" << (void*)this << ", '" << (String)id << "', '" << (AtomicString)kindString
2474 << "', '" << (String)label << "', '" << (String)language << "', " << boo lString(selected) << ")"; 2476 << "', '" << (String)label << "', '" << (String)language << "', " << boo lString(selected) << ")";
2475 2477
2476 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2478 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2477 return blink::WebMediaPlayer::TrackId(); 2479 return blink::WebMediaPlayer::TrackId();
2478 2480
2479 // If another track was selected (potentially by the user), leave it selecte d. 2481 // If another track was selected (potentially by the user), leave it selecte d.
2480 if (selected && videoTracks().selectedIndex() != -1) 2482 if (selected && videoTracks().selectedIndex() != -1)
2481 selected = false; 2483 selected = false;
2482 2484
2483 VideoTrack* videoTrack = VideoTrack::create(id, kindString, label, language, selected); 2485 VideoTrack* videoTrack = VideoTrack::create(id, kindString, label, language, selected);
2484 videoTracks().add(videoTrack); 2486 videoTracks().add(videoTrack);
2485 2487
2486 return videoTrack->id(); 2488 return videoTrack->id();
2487 } 2489 }
2488 2490
2489 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) 2491 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId)
2490 { 2492 {
2491 MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")"; 2493 BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")";
2492 2494
2493 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2495 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2494 return; 2496 return;
2495 2497
2496 videoTracks().remove(trackId); 2498 videoTracks().remove(trackId);
2497 } 2499 }
2498 2500
2499 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) 2501 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack)
2500 { 2502 {
2501 // 4.8.10.12.2 Sourcing in-band text tracks 2503 // 4.8.10.12.2 Sourcing in-band text tracks
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2638 2640
2639 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks 2641 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks
2640 // in the markup have been added. 2642 // in the markup have been added.
2641 if (isFinishedParsingChildren()) 2643 if (isFinishedParsingChildren())
2642 scheduleTextTrackResourceLoad(); 2644 scheduleTextTrackResourceLoad();
2643 } 2645 }
2644 2646
2645 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) 2647 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement)
2646 { 2648 {
2647 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); 2649 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr);
2648 MEDIA_LOG << "didRemoveTrackElement(" << (void*)this << ") - 'src' is " << u rlForLoggingMedia(url); 2650 BLINK_MEDIA_LOG << "didRemoveTrackElement(" << (void*)this << ") - 'src' is " << urlForLoggingMedia(url);
2649 2651
2650 TextTrack* textTrack = trackElement->track(); 2652 TextTrack* textTrack = trackElement->track();
2651 if (!textTrack) 2653 if (!textTrack)
2652 return; 2654 return;
2653 2655
2654 textTrack->setHasBeenConfigured(false); 2656 textTrack->setHasBeenConfigured(false);
2655 2657
2656 if (!m_textTracks) 2658 if (!m_textTracks)
2657 return; 2659 return;
2658 2660
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2704 m_nextChildNodeToConsider = nextNode; 2706 m_nextChildNodeToConsider = nextNode;
2705 2707
2706 return nextURL.isValid(); 2708 return nextURL.isValid();
2707 } 2709 }
2708 2710
2709 KURL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, InvalidUR LAction actionIfInvalid) 2711 KURL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, InvalidUR LAction actionIfInvalid)
2710 { 2712 {
2711 // Don't log if this was just called to find out if there are any valid <sou rce> elements. 2713 // Don't log if this was just called to find out if there are any valid <sou rce> elements.
2712 bool shouldLog = actionIfInvalid != DoNothing; 2714 bool shouldLog = actionIfInvalid != DoNothing;
2713 if (shouldLog) 2715 if (shouldLog)
2714 MEDIA_LOG << "selectNextSourceChild(" << (void*)this << ")"; 2716 BLINK_MEDIA_LOG << "selectNextSourceChild(" << (void*)this << ")";
2715 2717
2716 if (!m_nextChildNodeToConsider) { 2718 if (!m_nextChildNodeToConsider) {
2717 if (shouldLog) 2719 if (shouldLog)
2718 MEDIA_LOG << "selectNextSourceChild(" << (void*)this << ") -> 0x0000 , \"\""; 2720 BLINK_MEDIA_LOG << "selectNextSourceChild(" << (void*)this << ") -> 0x0000, \"\"";
2719 return KURL(); 2721 return KURL();
2720 } 2722 }
2721 2723
2722 KURL mediaURL; 2724 KURL mediaURL;
2723 Node* node; 2725 Node* node;
2724 HTMLSourceElement* source = 0; 2726 HTMLSourceElement* source = 0;
2725 String type; 2727 String type;
2726 bool lookingForStartNode = m_nextChildNodeToConsider; 2728 bool lookingForStartNode = m_nextChildNodeToConsider;
2727 bool canUseSourceElement = false; 2729 bool canUseSourceElement = false;
2728 2730
(...skipping 11 matching lines...) Expand all
2740 if (node->parentNode() != this) 2742 if (node->parentNode() != this)
2741 continue; 2743 continue;
2742 2744
2743 source = toHTMLSourceElement(node); 2745 source = toHTMLSourceElement(node);
2744 2746
2745 // 2. If candidate does not have a src attribute, or if its src 2747 // 2. If candidate does not have a src attribute, or if its src
2746 // attribute's value is the empty string ... jump down to the failed 2748 // attribute's value is the empty string ... jump down to the failed
2747 // step below 2749 // step below
2748 const AtomicString& srcValue = source->fastGetAttribute(srcAttr); 2750 const AtomicString& srcValue = source->fastGetAttribute(srcAttr);
2749 if (shouldLog) 2751 if (shouldLog)
2750 MEDIA_LOG << "selectNextSourceChild(" << (void*)this << ") - 'src' i s " << urlForLoggingMedia(mediaURL); 2752 BLINK_MEDIA_LOG << "selectNextSourceChild(" << (void*)this << ") - ' src' is " << urlForLoggingMedia(mediaURL);
2751 if (srcValue.isEmpty()) 2753 if (srcValue.isEmpty())
2752 goto checkAgain; 2754 goto checkAgain;
2753 2755
2754 // 3. Let urlString be the resulting URL string that would have resulted 2756 // 3. Let urlString be the resulting URL string that would have resulted
2755 // from parsing the URL specified by candidate's src attribute's value 2757 // from parsing the URL specified by candidate's src attribute's value
2756 // relative to the candidate's node document when the src attribute was 2758 // relative to the candidate's node document when the src attribute was
2757 // last changed. 2759 // last changed.
2758 mediaURL = source->document().completeURL(srcValue); 2760 mediaURL = source->document().completeURL(srcValue);
2759 2761
2760 // 4. If urlString was not obtained successfully, then end the 2762 // 4. If urlString was not obtained successfully, then end the
2761 // synchronous section, and jump down to the failed with elements step 2763 // synchronous section, and jump down to the failed with elements step
2762 // below. 2764 // below.
2763 if (!isSafeToLoadURL(mediaURL, actionIfInvalid)) 2765 if (!isSafeToLoadURL(mediaURL, actionIfInvalid))
2764 goto checkAgain; 2766 goto checkAgain;
2765 2767
2766 // 5. If candidate has a type attribute whose value, when parsed as a 2768 // 5. If candidate has a type attribute whose value, when parsed as a
2767 // MIME type ... 2769 // MIME type ...
2768 type = source->type(); 2770 type = source->type();
2769 if (type.isEmpty() && mediaURL.protocolIsData()) 2771 if (type.isEmpty() && mediaURL.protocolIsData())
2770 type = mimeTypeFromDataURL(mediaURL); 2772 type = mimeTypeFromDataURL(mediaURL);
2771 if (!type.isEmpty()) { 2773 if (!type.isEmpty()) {
2772 if (shouldLog) 2774 if (shouldLog)
2773 MEDIA_LOG << "selectNextSourceChild(" << (void*)this << ") - 'ty pe' is '" << type << "'"; 2775 BLINK_MEDIA_LOG << "selectNextSourceChild(" << (void*)this << ") - 'type' is '" << type << "'";
2774 if (!supportsType(ContentType(type))) 2776 if (!supportsType(ContentType(type)))
2775 goto checkAgain; 2777 goto checkAgain;
2776 } 2778 }
2777 2779
2778 // Making it this far means the <source> looks reasonable. 2780 // Making it this far means the <source> looks reasonable.
2779 canUseSourceElement = true; 2781 canUseSourceElement = true;
2780 2782
2781 checkAgain: 2783 checkAgain:
2782 if (!canUseSourceElement && actionIfInvalid == Complain && source) 2784 if (!canUseSourceElement && actionIfInvalid == Complain && source)
2783 source->scheduleErrorEvent(); 2785 source->scheduleErrorEvent();
2784 } 2786 }
2785 2787
2786 if (canUseSourceElement) { 2788 if (canUseSourceElement) {
2787 if (contentType) 2789 if (contentType)
2788 *contentType = ContentType(type); 2790 *contentType = ContentType(type);
2789 m_currentSourceNode = source; 2791 m_currentSourceNode = source;
2790 m_nextChildNodeToConsider = source->nextSibling(); 2792 m_nextChildNodeToConsider = source->nextSibling();
2791 } else { 2793 } else {
2792 m_currentSourceNode = nullptr; 2794 m_currentSourceNode = nullptr;
2793 m_nextChildNodeToConsider = nullptr; 2795 m_nextChildNodeToConsider = nullptr;
2794 } 2796 }
2795 2797
2796 if (shouldLog) 2798 if (shouldLog)
2797 MEDIA_LOG << "selectNextSourceChild(" << (void*)this << ") -> " << m_cur rentSourceNode.get() << ", " << (canUseSourceElement ? urlForLoggingMedia(mediaU RL) : ""); 2799 BLINK_MEDIA_LOG << "selectNextSourceChild(" << (void*)this << ") -> " << m_currentSourceNode.get() << ", " << (canUseSourceElement ? urlForLoggingMedia( mediaURL) : "");
2798 return canUseSourceElement ? mediaURL : KURL(); 2800 return canUseSourceElement ? mediaURL : KURL();
2799 } 2801 }
2800 2802
2801 void HTMLMediaElement::sourceWasAdded(HTMLSourceElement* source) 2803 void HTMLMediaElement::sourceWasAdded(HTMLSourceElement* source)
2802 { 2804 {
2803 MEDIA_LOG << "sourceWasAdded(" << (void*)this << ", " << source << ")"; 2805 BLINK_MEDIA_LOG << "sourceWasAdded(" << (void*)this << ", " << source << ")" ;
2804 2806
2805 KURL url = source->getNonEmptyURLAttribute(srcAttr); 2807 KURL url = source->getNonEmptyURLAttribute(srcAttr);
2806 MEDIA_LOG << "sourceWasAdded(" << (void*)this << ") - 'src' is " << urlForLo ggingMedia(url); 2808 BLINK_MEDIA_LOG << "sourceWasAdded(" << (void*)this << ") - 'src' is " << ur lForLoggingMedia(url);
2807 2809
2808 // We should only consider a <source> element when there is not src attribut e at all. 2810 // We should only consider a <source> element when there is not src attribut e at all.
2809 if (fastHasAttribute(srcAttr)) 2811 if (fastHasAttribute(srcAttr))
2810 return; 2812 return;
2811 2813
2812 // 4.8.8 - If a source element is inserted as a child of a media element tha t has no src 2814 // 4.8.8 - If a source element is inserted as a child of a media element tha t has no src
2813 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag ent must invoke 2815 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag ent must invoke
2814 // the media element's resource selection algorithm. 2816 // the media element's resource selection algorithm.
2815 if (getNetworkState() == HTMLMediaElement::NETWORK_EMPTY) { 2817 if (getNetworkState() == HTMLMediaElement::NETWORK_EMPTY) {
2816 invokeResourceSelectionAlgorithm(); 2818 invokeResourceSelectionAlgorithm();
2817 // Ignore current |m_nextChildNodeToConsider| and consider |source|. 2819 // Ignore current |m_nextChildNodeToConsider| and consider |source|.
2818 m_nextChildNodeToConsider = source; 2820 m_nextChildNodeToConsider = source;
2819 return; 2821 return;
2820 } 2822 }
2821 2823
2822 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) { 2824 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) {
2823 MEDIA_LOG << "sourceWasAdded(" << (void*)this << ") - <source> inserted immediately after current source"; 2825 BLINK_MEDIA_LOG << "sourceWasAdded(" << (void*)this << ") - <source> ins erted immediately after current source";
2824 // Ignore current |m_nextChildNodeToConsider| and consider |source|. 2826 // Ignore current |m_nextChildNodeToConsider| and consider |source|.
2825 m_nextChildNodeToConsider = source; 2827 m_nextChildNodeToConsider = source;
2826 return; 2828 return;
2827 } 2829 }
2828 2830
2829 // Consider current |m_nextChildNodeToConsider| as it is already in the midd le of processing. 2831 // Consider current |m_nextChildNodeToConsider| as it is already in the midd le of processing.
2830 if (m_nextChildNodeToConsider) 2832 if (m_nextChildNodeToConsider)
2831 return; 2833 return;
2832 2834
2833 if (m_loadState != WaitingForSource) 2835 if (m_loadState != WaitingForSource)
2834 return; 2836 return;
2835 2837
2836 // 4.8.9.5, resource selection algorithm, source elements section: 2838 // 4.8.9.5, resource selection algorithm, source elements section:
2837 // 21. Wait until the node after pointer is a node other than the end of the list. (This step might wait forever.) 2839 // 21. Wait until the node after pointer is a node other than the end of the list. (This step might wait forever.)
2838 // 22. Asynchronously await a stable state... 2840 // 22. Asynchronously await a stable state...
2839 // 23. Set the element's delaying-the-load-event flag back to true (this del ays the load event again, in case 2841 // 23. Set the element's delaying-the-load-event flag back to true (this del ays the load event again, in case
2840 // it hasn't been fired yet). 2842 // it hasn't been fired yet).
2841 setShouldDelayLoadEvent(true); 2843 setShouldDelayLoadEvent(true);
2842 2844
2843 // 24. Set the networkState back to NETWORK_LOADING. 2845 // 24. Set the networkState back to NETWORK_LOADING.
2844 setNetworkState(NETWORK_LOADING); 2846 setNetworkState(NETWORK_LOADING);
2845 2847
2846 // 25. Jump back to the find next candidate step above. 2848 // 25. Jump back to the find next candidate step above.
2847 m_nextChildNodeToConsider = source; 2849 m_nextChildNodeToConsider = source;
2848 scheduleNextSourceChild(); 2850 scheduleNextSourceChild();
2849 } 2851 }
2850 2852
2851 void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source) 2853 void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source)
2852 { 2854 {
2853 MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ", " << source << ")"; 2855 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ", " << source << " )";
2854 2856
2855 KURL url = source->getNonEmptyURLAttribute(srcAttr); 2857 KURL url = source->getNonEmptyURLAttribute(srcAttr);
2856 MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ") - 'src' is " << urlFor LoggingMedia(url); 2858 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ") - 'src' is " << urlForLoggingMedia(url);
2857 2859
2858 if (source != m_currentSourceNode && source != m_nextChildNodeToConsider) 2860 if (source != m_currentSourceNode && source != m_nextChildNodeToConsider)
2859 return; 2861 return;
2860 2862
2861 if (source == m_nextChildNodeToConsider) { 2863 if (source == m_nextChildNodeToConsider) {
2862 if (m_currentSourceNode) 2864 if (m_currentSourceNode)
2863 m_nextChildNodeToConsider = m_currentSourceNode->nextSibling(); 2865 m_nextChildNodeToConsider = m_currentSourceNode->nextSibling();
2864 MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ") - m_nextChildNodeT oConsider set to " << m_nextChildNodeToConsider.get(); 2866 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ") - m_nextChil dNodeToConsider set to " << m_nextChildNodeToConsider.get();
2865 } else if (source == m_currentSourceNode) { 2867 } else if (source == m_currentSourceNode) {
2866 // Clear the current source node pointer, but don't change the movie as the spec says: 2868 // Clear the current source node pointer, but don't change the movie as the spec says:
2867 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already 2869 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already
2868 // inserted in a video or audio element will have no effect. 2870 // inserted in a video or audio element will have no effect.
2869 m_currentSourceNode = nullptr; 2871 m_currentSourceNode = nullptr;
2870 MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ") - m_currentSourceN ode set to 0"; 2872 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ") - m_currentS ourceNode set to 0";
2871 } 2873 }
2872 } 2874 }
2873 2875
2874 void HTMLMediaElement::timeChanged() 2876 void HTMLMediaElement::timeChanged()
2875 { 2877 {
2876 MEDIA_LOG << "timeChanged(" << (void*)this << ")"; 2878 BLINK_MEDIA_LOG << "timeChanged(" << (void*)this << ")";
2877 2879
2878 cueTimeline().updateActiveCues(currentTime()); 2880 cueTimeline().updateActiveCues(currentTime());
2879 2881
2880 invalidateCachedTime(); 2882 invalidateCachedTime();
2881 2883
2882 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 2884 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek.
2883 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) 2885 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king())
2884 finishSeek(); 2886 finishSeek();
2885 2887
2886 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, 2888 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity,
(...skipping 22 matching lines...) Expand all
2909 // Queue a task to fire a simple event named ended at the media elem ent. 2911 // Queue a task to fire a simple event named ended at the media elem ent.
2910 scheduleEvent(EventTypeNames::ended); 2912 scheduleEvent(EventTypeNames::ended);
2911 Platform::current()->recordAction(UserMetricsAction("Media_Playback_ Ended")); 2913 Platform::current()->recordAction(UserMetricsAction("Media_Playback_ Ended"));
2912 } 2914 }
2913 } 2915 }
2914 updatePlayState(); 2916 updatePlayState();
2915 } 2917 }
2916 2918
2917 void HTMLMediaElement::durationChanged() 2919 void HTMLMediaElement::durationChanged()
2918 { 2920 {
2919 MEDIA_LOG << "durationChanged(" << (void*)this << ")"; 2921 BLINK_MEDIA_LOG << "durationChanged(" << (void*)this << ")";
2920 // FIXME: Change WebMediaPlayer to convey the currentTime 2922 // FIXME: Change WebMediaPlayer to convey the currentTime
2921 // when the duration change occured. The current WebMediaPlayer 2923 // when the duration change occured. The current WebMediaPlayer
2922 // implementations always clamp currentTime() to duration() 2924 // implementations always clamp currentTime() to duration()
2923 // so the requestSeek condition here is always false. 2925 // so the requestSeek condition here is always false.
2924 durationChanged(duration(), currentTime() > duration()); 2926 durationChanged(duration(), currentTime() > duration());
2925 } 2927 }
2926 2928
2927 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) 2929 void HTMLMediaElement::durationChanged(double duration, bool requestSeek)
2928 { 2930 {
2929 MEDIA_LOG << "durationChanged(" << (void*)this << ", " << duration << ", " < < boolString(requestSeek) << ")"; 2931 BLINK_MEDIA_LOG << "durationChanged(" << (void*)this << ", " << duration << ", " << boolString(requestSeek) << ")";
2930 2932
2931 // Abort if duration unchanged. 2933 // Abort if duration unchanged.
2932 if (m_duration == duration) 2934 if (m_duration == duration)
2933 return; 2935 return;
2934 2936
2935 MEDIA_LOG << "durationChanged(" << (void*)this << ") : " << m_duration << " -> " << duration; 2937 BLINK_MEDIA_LOG << "durationChanged(" << (void*)this << ") : " << m_duration << " -> " << duration;
2936 m_duration = duration; 2938 m_duration = duration;
2937 scheduleEvent(EventTypeNames::durationchange); 2939 scheduleEvent(EventTypeNames::durationchange);
2938 2940
2939 if (mediaControls()) 2941 if (mediaControls())
2940 mediaControls()->reset(); 2942 mediaControls()->reset();
2941 if (layoutObject()) 2943 if (layoutObject())
2942 layoutObject()->updateFromElement(); 2944 layoutObject()->updateFromElement();
2943 2945
2944 if (requestSeek) 2946 if (requestSeek)
2945 seek(duration); 2947 seek(duration);
2946 } 2948 }
2947 2949
2948 void HTMLMediaElement::playbackStateChanged() 2950 void HTMLMediaElement::playbackStateChanged()
2949 { 2951 {
2950 MEDIA_LOG << "playbackStateChanged(" << (void*)this << ")"; 2952 BLINK_MEDIA_LOG << "playbackStateChanged(" << (void*)this << ")";
2951 2953
2952 if (!webMediaPlayer()) 2954 if (!webMediaPlayer())
2953 return; 2955 return;
2954 2956
2955 if (webMediaPlayer()->paused()) 2957 if (webMediaPlayer()->paused())
2956 pauseInternal(); 2958 pauseInternal();
2957 else 2959 else
2958 playInternal(); 2960 playInternal();
2959 } 2961 }
2960 2962
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3013 if (m_webLayer) 3015 if (m_webLayer)
3014 m_webLayer->invalidate(); 3016 m_webLayer->invalidate();
3015 3017
3016 updateDisplayState(); 3018 updateDisplayState();
3017 if (layoutObject()) 3019 if (layoutObject())
3018 layoutObject()->setShouldDoFullPaintInvalidation(); 3020 layoutObject()->setShouldDoFullPaintInvalidation();
3019 } 3021 }
3020 3022
3021 void HTMLMediaElement::sizeChanged() 3023 void HTMLMediaElement::sizeChanged()
3022 { 3024 {
3023 MEDIA_LOG << "sizeChanged(" << (void*)this << ")"; 3025 BLINK_MEDIA_LOG << "sizeChanged(" << (void*)this << ")";
3024 3026
3025 DCHECK(hasVideo()); // "resize" makes no sense in absence of video. 3027 DCHECK(hasVideo()); // "resize" makes no sense in absence of video.
3026 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) 3028 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement())
3027 scheduleEvent(EventTypeNames::resize); 3029 scheduleEvent(EventTypeNames::resize);
3028 3030
3029 if (layoutObject()) 3031 if (layoutObject())
3030 layoutObject()->updateFromElement(); 3032 layoutObject()->updateFromElement();
3031 } 3033 }
3032 3034
3033 TimeRanges* HTMLMediaElement::buffered() const 3035 TimeRanges* HTMLMediaElement::buffered() const
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 } 3116 }
3115 3117
3116 return false; 3118 return false;
3117 } 3119 }
3118 3120
3119 void HTMLMediaElement::updatePlayState() 3121 void HTMLMediaElement::updatePlayState()
3120 { 3122 {
3121 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); 3123 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused();
3122 bool shouldBePlaying = potentiallyPlaying(); 3124 bool shouldBePlaying = potentiallyPlaying();
3123 3125
3124 MEDIA_LOG << "updatePlayState(" << (void*)this << ") - shouldBePlaying = " 3126 BLINK_MEDIA_LOG << "updatePlayState(" << (void*)this << ") - shouldBePlaying = "
3125 << boolString(shouldBePlaying) << ", isPlaying = " << boolString(isPlayi ng); 3127 << boolString(shouldBePlaying) << ", isPlaying = " << boolString(isPlayi ng);
3126 3128
3127 if (shouldBePlaying) { 3129 if (shouldBePlaying) {
3128 setDisplayMode(Video); 3130 setDisplayMode(Video);
3129 invalidateCachedTime(); 3131 invalidateCachedTime();
3130 3132
3131 if (!isPlaying) { 3133 if (!isPlaying) {
3132 // Set rate, muted before calling play in case they were set before the media engine was setup. 3134 // Set rate, muted before calling play in case they were set before the media engine was setup.
3133 // The media engine should just stash the rate and muted values sinc e it isn't already playing. 3135 // The media engine should just stash the rate and muted values sinc e it isn't already playing.
3134 webMediaPlayer()->setRate(playbackRate()); 3136 webMediaPlayer()->setRate(playbackRate());
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3206 m_playingRemotely = false; 3208 m_playingRemotely = false;
3207 if (mediaControls()) 3209 if (mediaControls())
3208 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); 3210 mediaControls()->refreshCastButtonVisibilityWithoutUpdate();
3209 3211
3210 if (layoutObject()) 3212 if (layoutObject())
3211 layoutObject()->setShouldDoFullPaintInvalidation(); 3213 layoutObject()->setShouldDoFullPaintInvalidation();
3212 } 3214 }
3213 3215
3214 void HTMLMediaElement::stop() 3216 void HTMLMediaElement::stop()
3215 { 3217 {
3216 MEDIA_LOG << "stop(" << (void*)this << ")"; 3218 BLINK_MEDIA_LOG << "stop(" << (void*)this << ")";
3217 3219
3218 // Close the async event queue so that no events are enqueued. 3220 // Close the async event queue so that no events are enqueued.
3219 cancelPendingEventsAndCallbacks(); 3221 cancelPendingEventsAndCallbacks();
3220 m_asyncEventQueue->close(); 3222 m_asyncEventQueue->close();
3221 3223
3222 // Clear everything in the Media Element 3224 // Clear everything in the Media Element
3223 clearMediaPlayer(); 3225 clearMediaPlayer();
3224 m_readyState = HAVE_NOTHING; 3226 m_readyState = HAVE_NOTHING;
3225 m_readyStateMaximum = HAVE_NOTHING; 3227 m_readyStateMaximum = HAVE_NOTHING;
3226 setNetworkState(NETWORK_EMPTY); 3228 setNetworkState(NETWORK_EMPTY);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3273 return false; 3275 return false;
3274 } 3276 }
3275 3277
3276 bool HTMLMediaElement::isFullscreen() const 3278 bool HTMLMediaElement::isFullscreen() const
3277 { 3279 {
3278 return Fullscreen::isActiveFullScreenElement(*this); 3280 return Fullscreen::isActiveFullScreenElement(*this);
3279 } 3281 }
3280 3282
3281 void HTMLMediaElement::enterFullscreen() 3283 void HTMLMediaElement::enterFullscreen()
3282 { 3284 {
3283 MEDIA_LOG << "enterFullscreen(" << (void*)this << ")"; 3285 BLINK_MEDIA_LOG << "enterFullscreen(" << (void*)this << ")";
3284 3286
3285 Fullscreen::from(document()).requestFullscreen(*this, Fullscreen::PrefixedRe quest); 3287 Fullscreen::from(document()).requestFullscreen(*this, Fullscreen::PrefixedRe quest);
3286 } 3288 }
3287 3289
3288 void HTMLMediaElement::exitFullscreen() 3290 void HTMLMediaElement::exitFullscreen()
3289 { 3291 {
3290 MEDIA_LOG << "exitFullscreen(" << (void*)this << ")"; 3292 BLINK_MEDIA_LOG << "exitFullscreen(" << (void*)this << ")";
3291 3293
3292 Fullscreen::from(document()).exitFullscreen(); 3294 Fullscreen::from(document()).exitFullscreen();
3293 } 3295 }
3294 3296
3295 void HTMLMediaElement::didBecomeFullscreenElement() 3297 void HTMLMediaElement::didBecomeFullscreenElement()
3296 { 3298 {
3297 if (mediaControls()) 3299 if (mediaControls())
3298 mediaControls()->enteredFullscreen(); 3300 mediaControls()->enteredFullscreen();
3299 // FIXME: There is no embedder-side handling in layout test mode. 3301 // FIXME: There is no embedder-side handling in layout test mode.
3300 if (webMediaPlayer() && !LayoutTestSupport::isRunningLayoutTest()) 3302 if (webMediaPlayer() && !LayoutTestSupport::isRunningLayoutTest())
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3371 // so that they are rendered behind them. 3373 // so that they are rendered behind them.
3372 shadowRoot.insertBefore(textTrackContainer, firstChild); 3374 shadowRoot.insertBefore(textTrackContainer, firstChild);
3373 3375
3374 assertShadowRootChildren(shadowRoot); 3376 assertShadowRootChildren(shadowRoot);
3375 3377
3376 return *textTrackContainer; 3378 return *textTrackContainer;
3377 } 3379 }
3378 3380
3379 void HTMLMediaElement::updateTextTrackDisplay() 3381 void HTMLMediaElement::updateTextTrackDisplay()
3380 { 3382 {
3381 MEDIA_LOG << "updateTextTrackDisplay(" << (void*)this << ")"; 3383 BLINK_MEDIA_LOG << "updateTextTrackDisplay(" << (void*)this << ")";
3382 3384
3383 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidNotSt artExposingControls); 3385 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidNotSt artExposingControls);
3384 } 3386 }
3385 3387
3386 void HTMLMediaElement::mediaControlsDidBecomeVisible() 3388 void HTMLMediaElement::mediaControlsDidBecomeVisible()
3387 { 3389 {
3388 MEDIA_LOG << "mediaControlsDidBecomeVisible(" << (void*)this << ")"; 3390 BLINK_MEDIA_LOG << "mediaControlsDidBecomeVisible(" << (void*)this << ")";
3389 3391
3390 // When the user agent starts exposing a user interface for a video element, 3392 // When the user agent starts exposing a user interface for a video element,
3391 // the user agent should run the rules for updating the text track rendering 3393 // the user agent should run the rules for updating the text track rendering
3392 // of each of the text tracks in the video element's list of text tracks ... 3394 // of each of the text tracks in the video element's list of text tracks ...
3393 if (isHTMLVideoElement() && textTracksVisible()) 3395 if (isHTMLVideoElement() && textTracksVisible())
3394 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls); 3396 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls);
3395 } 3397 }
3396 3398
3397 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen t* document) 3399 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen t* document)
3398 { 3400 {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3457 bool HTMLMediaElement::isURLAttribute(const Attribute& attribute) const 3459 bool HTMLMediaElement::isURLAttribute(const Attribute& attribute) const
3458 { 3460 {
3459 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute) ; 3461 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute) ;
3460 } 3462 }
3461 3463
3462 void HTMLMediaElement::setShouldDelayLoadEvent(bool shouldDelay) 3464 void HTMLMediaElement::setShouldDelayLoadEvent(bool shouldDelay)
3463 { 3465 {
3464 if (m_shouldDelayLoadEvent == shouldDelay) 3466 if (m_shouldDelayLoadEvent == shouldDelay)
3465 return; 3467 return;
3466 3468
3467 MEDIA_LOG << "setShouldDelayLoadEvent(" << (void*)this << ", " << boolString (shouldDelay) << ")"; 3469 BLINK_MEDIA_LOG << "setShouldDelayLoadEvent(" << (void*)this << ", " << bool String(shouldDelay) << ")";
3468 3470
3469 m_shouldDelayLoadEvent = shouldDelay; 3471 m_shouldDelayLoadEvent = shouldDelay;
3470 if (shouldDelay) 3472 if (shouldDelay)
3471 document().incrementLoadEventDelayCount(); 3473 document().incrementLoadEventDelayCount();
3472 else 3474 else
3473 document().decrementLoadEventDelayCount(); 3475 document().decrementLoadEventDelayCount();
3474 } 3476 }
3475 3477
3476 MediaControls* HTMLMediaElement::mediaControls() const 3478 MediaControls* HTMLMediaElement::mediaControls() const
3477 { 3479 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3528 CueTimeline& HTMLMediaElement::cueTimeline() 3530 CueTimeline& HTMLMediaElement::cueTimeline()
3529 { 3531 {
3530 if (!m_cueTimeline) 3532 if (!m_cueTimeline)
3531 m_cueTimeline = new CueTimeline(*this); 3533 m_cueTimeline = new CueTimeline(*this);
3532 return *m_cueTimeline; 3534 return *m_cueTimeline;
3533 } 3535 }
3534 3536
3535 void HTMLMediaElement::configureTextTrackDisplay() 3537 void HTMLMediaElement::configureTextTrackDisplay()
3536 { 3538 {
3537 DCHECK(m_textTracks); 3539 DCHECK(m_textTracks);
3538 MEDIA_LOG << "configureTextTrackDisplay(" << (void*)this << ")"; 3540 BLINK_MEDIA_LOG << "configureTextTrackDisplay(" << (void*)this << ")";
3539 3541
3540 if (m_processingPreferenceChange) 3542 if (m_processingPreferenceChange)
3541 return; 3543 return;
3542 3544
3543 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); 3545 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks();
3544 m_textTracksVisible = haveVisibleTextTrack; 3546 m_textTracksVisible = haveVisibleTextTrack;
3545 3547
3546 if (!haveVisibleTextTrack && !mediaControls()) 3548 if (!haveVisibleTextTrack && !mediaControls())
3547 return; 3549 return;
3548 3550
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
4033 4035
4034 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 4036 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
4035 { 4037 {
4036 IntRect result; 4038 IntRect result;
4037 if (LayoutObject* object = m_element->layoutObject()) 4039 if (LayoutObject* object = m_element->layoutObject())
4038 result = object->absoluteBoundingBoxRect(); 4040 result = object->absoluteBoundingBoxRect();
4039 return result; 4041 return result;
4040 } 4042 }
4041 4043
4042 } // namespace blink 4044 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/mediasource/MediaSource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698