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

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

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

Powered by Google App Engine
This is Rietveld 408576698