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

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

Issue 556703002: Include "this" pointer in HTMLMediaElement logging. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 , m_audioTracks(AudioTrackList::create(*this)) 360 , m_audioTracks(AudioTrackList::create(*this))
361 , m_videoTracks(VideoTrackList::create(*this)) 361 , m_videoTracks(VideoTrackList::create(*this))
362 , m_textTracks(nullptr) 362 , m_textTracks(nullptr)
363 , m_ignoreTrackDisplayUpdate(0) 363 , m_ignoreTrackDisplayUpdate(0)
364 #if ENABLE(WEB_AUDIO) 364 #if ENABLE(WEB_AUDIO)
365 , m_audioSourceNode(nullptr) 365 , m_audioSourceNode(nullptr)
366 #endif 366 #endif
367 { 367 {
368 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); 368 ASSERT(RuntimeEnabledFeatures::mediaEnabled());
369 369
370 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); 370 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this);
371 371
372 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) 372 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture())
373 m_userGestureRequiredForPlay = true; 373 m_userGestureRequiredForPlay = true;
374 374
375 setHasCustomStyleCallbacks(); 375 setHasCustomStyleCallbacks();
376 addElementToDocumentMap(this, &document); 376 addElementToDocumentMap(this, &document);
377 } 377 }
378 378
379 HTMLMediaElement::~HTMLMediaElement() 379 HTMLMediaElement::~HTMLMediaElement()
380 { 380 {
381 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement"); 381 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement(%p)", this);
382 382
383 #if ENABLE(OILPAN) 383 #if ENABLE(OILPAN)
384 // If the HTMLMediaElement dies with the document we are not 384 // If the HTMLMediaElement dies with the document we are not
385 // allowed to touch the document to adjust delay load event counts 385 // allowed to touch the document to adjust delay load event counts
386 // because the document could have been already 386 // because the document could have been already
387 // destructed. However, if the HTMLMediaElement dies with the 387 // destructed. However, if the HTMLMediaElement dies with the
388 // document there is no need to change the delayed load counts 388 // document there is no need to change the delayed load counts
389 // because no load event will fire anyway. If the document is 389 // because no load event will fire anyway. If the document is
390 // still alive we do have to decrement the load delay counts. We 390 // still alive we do have to decrement the load delay counts. We
391 // determine if the document is alive via the ActiveDOMObject 391 // determine if the document is alive via the ActiveDOMObject
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 #if ENABLE(OILPAN) 473 #if ENABLE(OILPAN)
474 void HTMLMediaElement::setCloseMediaSourceWhenFinalizing() 474 void HTMLMediaElement::setCloseMediaSourceWhenFinalizing()
475 { 475 {
476 ASSERT(!m_closeMediaSourceWhenFinalizing); 476 ASSERT(!m_closeMediaSourceWhenFinalizing);
477 m_closeMediaSourceWhenFinalizing = true; 477 m_closeMediaSourceWhenFinalizing = true;
478 } 478 }
479 #endif 479 #endif
480 480
481 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) 481 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument)
482 { 482 {
483 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument"); 483 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this);
484 484
485 if (m_shouldDelayLoadEvent) { 485 if (m_shouldDelayLoadEvent) {
486 document().incrementLoadEventDelayCount(); 486 document().incrementLoadEventDelayCount();
487 // Note: Keeping the load event delay count increment on oldDocument tha t was added 487 // Note: Keeping the load event delay count increment on oldDocument tha t was added
488 // when m_shouldDelayLoadEvent was set so that destruction of m_player c an not 488 // when m_shouldDelayLoadEvent was set so that destruction of m_player c an not
489 // cause load event dispatching in oldDocument. 489 // cause load event dispatching in oldDocument.
490 } else { 490 } else {
491 // Incrementing the load event delay count so that destruction of m_play er can not 491 // Incrementing the load event delay count so that destruction of m_play er can not
492 // cause load event dispatching in oldDocument. 492 // cause load event dispatching in oldDocument.
493 oldDocument.incrementLoadEventDelayCount(); 493 oldDocument.incrementLoadEventDelayCount();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 return shouldShowControls() && HTMLElement::rendererIsNeeded(style); 570 return shouldShowControls() && HTMLElement::rendererIsNeeded(style);
571 } 571 }
572 572
573 RenderObject* HTMLMediaElement::createRenderer(RenderStyle*) 573 RenderObject* HTMLMediaElement::createRenderer(RenderStyle*)
574 { 574 {
575 return new RenderMedia(this); 575 return new RenderMedia(this);
576 } 576 }
577 577
578 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint) 578 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint)
579 { 579 {
580 WTF_LOG(Media, "HTMLMediaElement::insertedInto"); 580 WTF_LOG(Media, "HTMLMediaElement::insertedInto(%p, %p)", this, insertionPoin t);
581 581
582 HTMLElement::insertedInto(insertionPoint); 582 HTMLElement::insertedInto(insertionPoint);
583 if (insertionPoint->inDocument()) { 583 if (insertionPoint->inDocument()) {
584 m_active = true; 584 m_active = true;
585 585
586 if (!getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY) 586 if (!getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY)
587 scheduleDelayedAction(LoadMediaResource); 587 scheduleDelayedAction(LoadMediaResource);
588 } 588 }
589 589
590 return InsertionShouldCallDidNotifySubtreeInsertions; 590 return InsertionShouldCallDidNotifySubtreeInsertions;
591 } 591 }
592 592
593 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() 593 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument()
594 { 594 {
595 configureMediaControls(); 595 configureMediaControls();
596 } 596 }
597 597
598 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) 598 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint)
599 { 599 {
600 WTF_LOG(Media, "HTMLMediaElement::removedFrom"); 600 WTF_LOG(Media, "HTMLMediaElement::removedFrom(%p, %p)", this, insertionPoint );
601 601
602 m_active = false; 602 m_active = false;
603 if (insertionPoint->inDocument() && insertionPoint->document().isActive()) { 603 if (insertionPoint->inDocument() && insertionPoint->document().isActive()) {
604 configureMediaControls(); 604 configureMediaControls();
605 if (m_networkState > NETWORK_EMPTY) 605 if (m_networkState > NETWORK_EMPTY)
606 pause(); 606 pause();
607 } 607 }
608 608
609 HTMLElement::removedFrom(insertionPoint); 609 HTMLElement::removedFrom(insertionPoint);
610 } 610 }
611 611
612 void HTMLMediaElement::attach(const AttachContext& context) 612 void HTMLMediaElement::attach(const AttachContext& context)
613 { 613 {
614 HTMLElement::attach(context); 614 HTMLElement::attach(context);
615 615
616 if (renderer()) 616 if (renderer())
617 renderer()->updateFromElement(); 617 renderer()->updateFromElement();
618 } 618 }
619 619
620 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) 620 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange)
621 { 621 {
622 if (renderer()) 622 if (renderer())
623 renderer()->updateFromElement(); 623 renderer()->updateFromElement();
624 } 624 }
625 625
626 void HTMLMediaElement::scheduleDelayedAction(DelayedActionType actionType) 626 void HTMLMediaElement::scheduleDelayedAction(DelayedActionType actionType)
627 { 627 {
628 WTF_LOG(Media, "HTMLMediaElement::scheduleDelayedAction"); 628 WTF_LOG(Media, "HTMLMediaElement::scheduleDelayedAction(%p)", this);
629 629
630 if ((actionType & LoadMediaResource) && !(m_pendingActionFlags & LoadMediaRe source)) { 630 if ((actionType & LoadMediaResource) && !(m_pendingActionFlags & LoadMediaRe source)) {
631 prepareForLoad(); 631 prepareForLoad();
632 m_pendingActionFlags |= LoadMediaResource; 632 m_pendingActionFlags |= LoadMediaResource;
633 } 633 }
634 634
635 if (actionType & LoadTextTrackResource) 635 if (actionType & LoadTextTrackResource)
636 m_pendingActionFlags |= LoadTextTrackResource; 636 m_pendingActionFlags |= LoadTextTrackResource;
637 637
638 if (!m_loadTimer.isActive()) 638 if (!m_loadTimer.isActive())
639 m_loadTimer.startOneShot(0, FROM_HERE); 639 m_loadTimer.startOneShot(0, FROM_HERE);
640 } 640 }
641 641
642 void HTMLMediaElement::scheduleNextSourceChild() 642 void HTMLMediaElement::scheduleNextSourceChild()
643 { 643 {
644 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala prepareForLoad. 644 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala prepareForLoad.
645 m_pendingActionFlags |= LoadMediaResource; 645 m_pendingActionFlags |= LoadMediaResource;
646 m_loadTimer.startOneShot(0, FROM_HERE); 646 m_loadTimer.startOneShot(0, FROM_HERE);
647 } 647 }
648 648
649 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) 649 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName)
650 { 650 {
651 scheduleEvent(Event::createCancelable(eventName)); 651 scheduleEvent(Event::createCancelable(eventName));
652 } 652 }
653 653
654 void HTMLMediaElement::scheduleEvent(PassRefPtrWillBeRawPtr<Event> event) 654 void HTMLMediaElement::scheduleEvent(PassRefPtrWillBeRawPtr<Event> event)
655 { 655 {
656 #if LOG_MEDIA_EVENTS 656 #if LOG_MEDIA_EVENTS
657 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent - scheduling '%s'", event->t ype().ascii().data()); 657 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent(%p) - scheduling '%s'", this , event->type().ascii().data());
658 #endif 658 #endif
659 m_asyncEventQueue->enqueueEvent(event); 659 m_asyncEventQueue->enqueueEvent(event);
660 } 660 }
661 661
662 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) 662 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*)
663 { 663 {
664 if (m_pendingActionFlags & LoadTextTrackResource) 664 if (m_pendingActionFlags & LoadTextTrackResource)
665 configureTextTracks(); 665 configureTextTracks();
666 666
667 if (m_pendingActionFlags & LoadMediaResource) { 667 if (m_pendingActionFlags & LoadMediaResource) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 canPlay = emptyString(); 704 canPlay = emptyString();
705 break; 705 break;
706 case WebMimeRegistry::MayBeSupported: 706 case WebMimeRegistry::MayBeSupported:
707 canPlay = "maybe"; 707 canPlay = "maybe";
708 break; 708 break;
709 case WebMimeRegistry::IsSupported: 709 case WebMimeRegistry::IsSupported:
710 canPlay = "probably"; 710 canPlay = "probably";
711 break; 711 break;
712 } 712 }
713 713
714 WTF_LOG(Media, "HTMLMediaElement::canPlayType(%s, %s) -> %s", mimeType.utf8( ).data(), keySystem.utf8().data(), canPlay.utf8().data()); 714 WTF_LOG(Media, "HTMLMediaElement::canPlayType(%p, %s, %s) -> %s", this, mime Type.utf8().data(), keySystem.utf8().data(), canPlay.utf8().data());
715 715
716 return canPlay; 716 return canPlay;
717 } 717 }
718 718
719 void HTMLMediaElement::load() 719 void HTMLMediaElement::load()
720 { 720 {
721 WTF_LOG(Media, "HTMLMediaElement::load()"); 721 WTF_LOG(Media, "HTMLMediaElement::load(%p)", this);
722 722
723 if (UserGestureIndicator::processingUserGesture()) 723 if (UserGestureIndicator::processingUserGesture())
724 m_userGestureRequiredForPlay = false; 724 m_userGestureRequiredForPlay = false;
725 725
726 prepareForLoad(); 726 prepareForLoad();
727 loadInternal(); 727 loadInternal();
728 prepareToPlay(); 728 prepareToPlay();
729 } 729 }
730 730
731 void HTMLMediaElement::prepareForLoad() 731 void HTMLMediaElement::prepareForLoad()
732 { 732 {
733 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad"); 733 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad(%p)", this);
734 734
735 // Perform the cleanup required for the resource load algorithm to run. 735 // Perform the cleanup required for the resource load algorithm to run.
736 stopPeriodicTimers(); 736 stopPeriodicTimers();
737 m_loadTimer.stop(); 737 m_loadTimer.stop();
738 cancelDeferredLoad(); 738 cancelDeferredLoad();
739 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. 739 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here.
740 m_pendingActionFlags &= ~LoadMediaResource; 740 m_pendingActionFlags &= ~LoadMediaResource;
741 m_sentEndEvent = false; 741 m_sentEndEvent = false;
742 m_sentStalledEvent = false; 742 m_sentStalledEvent = false;
743 m_haveFiredLoadedData = false; 743 m_haveFiredLoadedData = false;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 if (track->mode() != TextTrack::disabledKeyword()) 841 if (track->mode() != TextTrack::disabledKeyword())
842 m_textTracksWhenResourceSelectionBegan.append(track); 842 m_textTracksWhenResourceSelectionBegan.append(track);
843 } 843 }
844 } 844 }
845 845
846 selectMediaResource(); 846 selectMediaResource();
847 } 847 }
848 848
849 void HTMLMediaElement::selectMediaResource() 849 void HTMLMediaElement::selectMediaResource()
850 { 850 {
851 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource"); 851 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p)", this);
852 852
853 enum Mode { attribute, children }; 853 enum Mode { attribute, children };
854 854
855 // 3 - If the media element has a src attribute, then let mode be attribute. 855 // 3 - If the media element has a src attribute, then let mode be attribute.
856 Mode mode = attribute; 856 Mode mode = attribute;
857 if (!fastHasAttribute(srcAttr)) { 857 if (!fastHasAttribute(srcAttr)) {
858 // Otherwise, if the media element does not have a src attribute but has a source 858 // Otherwise, if the media element does not have a src attribute but has a source
859 // element child, then let mode be children and let candidate be the fir st such 859 // element child, then let mode be children and let candidate be the fir st such
860 // source element child in tree order. 860 // source element child in tree order.
861 if (HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstChil d(*this)) { 861 if (HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstChil d(*this)) {
862 mode = children; 862 mode = children;
863 m_nextChildNodeToConsider = element; 863 m_nextChildNodeToConsider = element;
864 m_currentSourceNode = nullptr; 864 m_currentSourceNode = nullptr;
865 } else { 865 } else {
866 // Otherwise the media element has neither a src attribute nor a sou rce element 866 // Otherwise the media element has neither a src attribute nor a sou rce element
867 // child: set the networkState to NETWORK_EMPTY, and abort these ste ps; the 867 // child: set the networkState to NETWORK_EMPTY, and abort these ste ps; the
868 // synchronous section ends. 868 // synchronous section ends.
869 m_loadState = WaitingForSource; 869 m_loadState = WaitingForSource;
870 setShouldDelayLoadEvent(false); 870 setShouldDelayLoadEvent(false);
871 m_networkState = NETWORK_EMPTY; 871 m_networkState = NETWORK_EMPTY;
872 872
873 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, nothing to lo ad"); 873 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing t o load", this);
874 return; 874 return;
875 } 875 }
876 } 876 }
877 877
878 // 4 - Set the media element's delaying-the-load-event flag to true (this de lays the load event), 878 // 4 - Set the media element's delaying-the-load-event flag to true (this de lays the load event),
879 // and set its networkState to NETWORK_LOADING. 879 // and set its networkState to NETWORK_LOADING.
880 setShouldDelayLoadEvent(true); 880 setShouldDelayLoadEvent(true);
881 m_networkState = NETWORK_LOADING; 881 m_networkState = NETWORK_LOADING;
882 882
883 // 5 - Queue a task to fire a simple event named loadstart at the media elem ent. 883 // 5 - Queue a task to fire a simple event named loadstart at the media elem ent.
884 scheduleEvent(EventTypeNames::loadstart); 884 scheduleEvent(EventTypeNames::loadstart);
885 885
886 // 6 - If mode is attribute, then run these substeps 886 // 6 - If mode is attribute, then run these substeps
887 if (mode == attribute) { 887 if (mode == attribute) {
888 m_loadState = LoadingFromSrcAttr; 888 m_loadState = LoadingFromSrcAttr;
889 889
890 // If the src attribute's value is the empty string ... jump down to the failed step below 890 // If the src attribute's value is the empty string ... jump down to the failed step below
891 KURL mediaURL = getNonEmptyURLAttribute(srcAttr); 891 KURL mediaURL = getNonEmptyURLAttribute(srcAttr);
892 if (mediaURL.isEmpty()) { 892 if (mediaURL.isEmpty()) {
893 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 893 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
894 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, empty 'src'") ; 894 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), empty 'sr c'", this);
895 return; 895 return;
896 } 896 }
897 897
898 if (!isSafeToLoadURL(mediaURL, Complain)) { 898 if (!isSafeToLoadURL(mediaURL, Complain)) {
899 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 899 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
900 return; 900 return;
901 } 901 }
902 902
903 // No type or key system information is available when the url comes 903 // No type or key system information is available when the url comes
904 // from the 'src' attribute so MediaPlayer 904 // from the 'src' attribute so MediaPlayer
905 // will have to pick a media engine based on the file extension. 905 // will have to pick a media engine based on the file extension.
906 ContentType contentType((String())); 906 ContentType contentType((String()));
907 loadResource(mediaURL, contentType, String()); 907 loadResource(mediaURL, contentType, String());
908 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, using 'src' attri bute url"); 908 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using 'src' a ttribute url", this);
909 return; 909 return;
910 } 910 }
911 911
912 // Otherwise, the source elements will be used 912 // Otherwise, the source elements will be used
913 loadNextSourceChild(); 913 loadNextSourceChild();
914 } 914 }
915 915
916 void HTMLMediaElement::loadNextSourceChild() 916 void HTMLMediaElement::loadNextSourceChild()
917 { 917 {
918 ContentType contentType((String())); 918 ContentType contentType((String()));
919 String keySystem; 919 String keySystem;
920 KURL mediaURL = selectNextSourceChild(&contentType, &keySystem, Complain); 920 KURL mediaURL = selectNextSourceChild(&contentType, &keySystem, Complain);
921 if (!mediaURL.isValid()) { 921 if (!mediaURL.isValid()) {
922 waitForSourceChange(); 922 waitForSourceChange();
923 return; 923 return;
924 } 924 }
925 925
926 // Recreate the media player for the new url 926 // Recreate the media player for the new url
927 createMediaPlayer(); 927 createMediaPlayer();
928 928
929 m_loadState = LoadingFromSourceElement; 929 m_loadState = LoadingFromSourceElement;
930 loadResource(mediaURL, contentType, keySystem); 930 loadResource(mediaURL, contentType, keySystem);
931 } 931 }
932 932
933 void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType, c onst String& keySystem) 933 void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType, c onst String& keySystem)
934 { 934 {
935 ASSERT(isSafeToLoadURL(url, Complain)); 935 ASSERT(isSafeToLoadURL(url, Complain));
936 936
937 WTF_LOG(Media, "HTMLMediaElement::loadResource(%s, %s, %s)", urlForLoggingMe dia(url).utf8().data(), contentType.raw().utf8().data(), keySystem.utf8().data() ); 937 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p, %s, %s, %s)", this, urlFo rLoggingMedia(url).utf8().data(), contentType.raw().utf8().data(), keySystem.utf 8().data());
938 938
939 LocalFrame* frame = document().frame(); 939 LocalFrame* frame = document().frame();
940 if (!frame) { 940 if (!frame) {
941 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 941 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
942 return; 942 return;
943 } 943 }
944 944
945 // The resource fetch algorithm 945 // The resource fetch algorithm
946 m_networkState = NETWORK_LOADING; 946 m_networkState = NETWORK_LOADING;
947 947
948 // Set m_currentSrc *before* changing to the cache url, the fact that we are loading from the app 948 // Set m_currentSrc *before* changing to the cache url, the fact that we are loading from the app
949 // cache is an internal detail not exposed through the media element API. 949 // cache is an internal detail not exposed through the media element API.
950 m_currentSrc = url; 950 m_currentSrc = url;
951 951
952 WTF_LOG(Media, "HTMLMediaElement::loadResource - m_currentSrc -> %s", urlFor LoggingMedia(m_currentSrc).utf8().data()); 952 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) - m_currentSrc -> %s", th is, urlForLoggingMedia(m_currentSrc).utf8().data());
953 953
954 startProgressEventTimer(); 954 startProgressEventTimer();
955 955
956 // Reset display mode to force a recalculation of what to show because we ar e resetting the player. 956 // Reset display mode to force a recalculation of what to show because we ar e resetting the player.
957 setDisplayMode(Unknown); 957 setDisplayMode(Unknown);
958 958
959 if (!autoplay()) 959 if (!autoplay())
960 setPlayerPreload(); 960 setPlayerPreload();
961 961
962 if (fastHasAttribute(mutedAttr)) 962 if (fastHasAttribute(mutedAttr))
(...skipping 18 matching lines...) Expand all
981 attemptLoad = false; 981 attemptLoad = false;
982 } 982 }
983 } 983 }
984 } 984 }
985 } 985 }
986 986
987 if (attemptLoad && canLoadURL(url, contentType, keySystem)) { 987 if (attemptLoad && canLoadURL(url, contentType, keySystem)) {
988 ASSERT(!webMediaPlayer()); 988 ASSERT(!webMediaPlayer());
989 989
990 if (!m_havePreparedToPlay && !autoplay() && m_preload == MediaPlayer::No ne) { 990 if (!m_havePreparedToPlay && !autoplay() && m_preload == MediaPlayer::No ne) {
991 WTF_LOG(Media, "HTMLMediaElement::loadResource : Delaying load becau se preload == 'none'"); 991 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this);
992 deferLoad(); 992 deferLoad();
993 } else { 993 } else {
994 startPlayerLoad(); 994 startPlayerLoad();
995 } 995 }
996 } else { 996 } else {
997 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 997 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
998 } 998 }
999 999
1000 // If there is no poster to display, allow the media engine to render video frames as soon as 1000 // If there is no poster to display, allow the media engine to render video frames as soon as
1001 // they are available. 1001 // they are available.
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 void HTMLMediaElement::endIgnoringTrackDisplayUpdateRequests() 1453 void HTMLMediaElement::endIgnoringTrackDisplayUpdateRequests()
1454 { 1454 {
1455 ASSERT(m_ignoreTrackDisplayUpdate); 1455 ASSERT(m_ignoreTrackDisplayUpdate);
1456 --m_ignoreTrackDisplayUpdate; 1456 --m_ignoreTrackDisplayUpdate;
1457 if (!m_ignoreTrackDisplayUpdate && m_active) 1457 if (!m_ignoreTrackDisplayUpdate && m_active)
1458 updateActiveTextTrackCues(currentTime()); 1458 updateActiveTextTrackCues(currentTime());
1459 } 1459 }
1460 1460
1461 void HTMLMediaElement::textTrackAddCues(TextTrack* track, const TextTrackCueList * cues) 1461 void HTMLMediaElement::textTrackAddCues(TextTrack* track, const TextTrackCueList * cues)
1462 { 1462 {
1463 WTF_LOG(Media, "HTMLMediaElement::textTrackAddCues"); 1463 WTF_LOG(Media, "HTMLMediaElement::textTrackAddCues(%p)", this);
1464 if (track->mode() == TextTrack::disabledKeyword()) 1464 if (track->mode() == TextTrack::disabledKeyword())
1465 return; 1465 return;
1466 1466
1467 TrackDisplayUpdateScope scope(this); 1467 TrackDisplayUpdateScope scope(this);
1468 for (size_t i = 0; i < cues->length(); ++i) 1468 for (size_t i = 0; i < cues->length(); ++i)
1469 textTrackAddCue(cues->item(i)->track(), cues->item(i)); 1469 textTrackAddCue(cues->item(i)->track(), cues->item(i));
1470 } 1470 }
1471 1471
1472 void HTMLMediaElement::textTrackRemoveCues(TextTrack*, const TextTrackCueList* c ues) 1472 void HTMLMediaElement::textTrackRemoveCues(TextTrack*, const TextTrackCueList* c ues)
1473 { 1473 {
1474 WTF_LOG(Media, "HTMLMediaElement::textTrackRemoveCues"); 1474 WTF_LOG(Media, "HTMLMediaElement::textTrackRemoveCues(%p)", this);
1475 1475
1476 TrackDisplayUpdateScope scope(this); 1476 TrackDisplayUpdateScope scope(this);
1477 for (size_t i = 0; i < cues->length(); ++i) 1477 for (size_t i = 0; i < cues->length(); ++i)
1478 textTrackRemoveCue(cues->item(i)->track(), cues->item(i)); 1478 textTrackRemoveCue(cues->item(i)->track(), cues->item(i));
1479 } 1479 }
1480 1480
1481 void HTMLMediaElement::textTrackAddCue(TextTrack* track, PassRefPtrWillBeRawPtr< TextTrackCue> cue) 1481 void HTMLMediaElement::textTrackAddCue(TextTrack* track, PassRefPtrWillBeRawPtr< TextTrackCue> cue)
1482 { 1482 {
1483 if (track->mode() == TextTrack::disabledKeyword()) 1483 if (track->mode() == TextTrack::disabledKeyword())
1484 return; 1484 return;
(...skipping 30 matching lines...) Expand all
1515 cue->removeDisplayTree(); 1515 cue->removeDisplayTree();
1516 updateActiveTextTrackCues(currentTime()); 1516 updateActiveTextTrackCues(currentTime());
1517 1517
1518 cue->notifyRegionWhenRemovingDisplayTree(true); 1518 cue->notifyRegionWhenRemovingDisplayTree(true);
1519 } 1519 }
1520 1520
1521 1521
1522 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI fInvalid) 1522 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI fInvalid)
1523 { 1523 {
1524 if (!url.isValid()) { 1524 if (!url.isValid()) {
1525 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%s) -> FALSE because u rl is invalid", urlForLoggingMedia(url).utf8().data()); 1525 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> FALSE becau se url is invalid", this, urlForLoggingMedia(url).utf8().data());
1526 return false; 1526 return false;
1527 } 1527 }
1528 1528
1529 LocalFrame* frame = document().frame(); 1529 LocalFrame* frame = document().frame();
1530 if (!frame || !document().securityOrigin()->canDisplay(url)) { 1530 if (!frame || !document().securityOrigin()->canDisplay(url)) {
1531 if (actionIfInvalid == Complain) 1531 if (actionIfInvalid == Complain)
1532 FrameLoader::reportLocalLoadFailed(frame, url.elidedString()); 1532 FrameLoader::reportLocalLoadFailed(frame, url.elidedString());
1533 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%s) -> FALSE rejected by SecurityOrigin", urlForLoggingMedia(url).utf8().data()); 1533 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> FALSE rejec ted by SecurityOrigin", this, urlForLoggingMedia(url).utf8().data());
1534 return false; 1534 return false;
1535 } 1535 }
1536 1536
1537 if (!document().contentSecurityPolicy()->allowMediaFromSource(url)) { 1537 if (!document().contentSecurityPolicy()->allowMediaFromSource(url)) {
1538 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%s) -> rejected by Con tent Security Policy", urlForLoggingMedia(url).utf8().data()); 1538 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> rejected by Content Security Policy", this, urlForLoggingMedia(url).utf8().data());
1539 return false; 1539 return false;
1540 } 1540 }
1541 1541
1542 return true; 1542 return true;
1543 } 1543 }
1544 1544
1545 void HTMLMediaElement::startProgressEventTimer() 1545 void HTMLMediaElement::startProgressEventTimer()
1546 { 1546 {
1547 if (m_progressEventTimer.isActive()) 1547 if (m_progressEventTimer.isActive())
1548 return; 1548 return;
1549 1549
1550 m_previousProgressTime = WTF::currentTime(); 1550 m_previousProgressTime = WTF::currentTime();
1551 // 350ms is not magic, it is in the spec! 1551 // 350ms is not magic, it is in the spec!
1552 m_progressEventTimer.startRepeating(0.350, FROM_HERE); 1552 m_progressEventTimer.startRepeating(0.350, FROM_HERE);
1553 } 1553 }
1554 1554
1555 void HTMLMediaElement::waitForSourceChange() 1555 void HTMLMediaElement::waitForSourceChange()
1556 { 1556 {
1557 WTF_LOG(Media, "HTMLMediaElement::waitForSourceChange"); 1557 WTF_LOG(Media, "HTMLMediaElement::waitForSourceChange(%p)", this);
1558 1558
1559 stopPeriodicTimers(); 1559 stopPeriodicTimers();
1560 m_loadState = WaitingForSource; 1560 m_loadState = WaitingForSource;
1561 1561
1562 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N O_SOURCE value 1562 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N O_SOURCE value
1563 m_networkState = NETWORK_NO_SOURCE; 1563 m_networkState = NETWORK_NO_SOURCE;
1564 1564
1565 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop s delaying the load event. 1565 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop s delaying the load event.
1566 setShouldDelayLoadEvent(false); 1566 setShouldDelayLoadEvent(false);
1567 1567
1568 updateDisplayState(); 1568 updateDisplayState();
1569 1569
1570 if (renderer()) 1570 if (renderer())
1571 renderer()->updateFromElement(); 1571 renderer()->updateFromElement();
1572 } 1572 }
1573 1573
1574 void HTMLMediaElement::noneSupported() 1574 void HTMLMediaElement::noneSupported()
1575 { 1575 {
1576 WTF_LOG(Media, "HTMLMediaElement::noneSupported"); 1576 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this);
1577 1577
1578 stopPeriodicTimers(); 1578 stopPeriodicTimers();
1579 m_loadState = WaitingForSource; 1579 m_loadState = WaitingForSource;
1580 m_currentSourceNode = nullptr; 1580 m_currentSourceNode = nullptr;
1581 1581
1582 // 4.8.10.5 1582 // 4.8.10.5
1583 // 6 - Reaching this step indicates that the media resource failed to load o r that the given 1583 // 6 - Reaching this step indicates that the media resource failed to load o r that the given
1584 // URL could not be resolved. In one atomic operation, run the following ste ps: 1584 // URL could not be resolved. In one atomic operation, run the following ste ps:
1585 1585
1586 // 6.1 - Set the error attribute to a new MediaError object whose code attri bute is set to 1586 // 6.1 - Set the error attribute to a new MediaError object whose code attri bute is set to
(...skipping 19 matching lines...) Expand all
1606 1606
1607 updateDisplayState(); 1607 updateDisplayState();
1608 1608
1609 if (renderer()) 1609 if (renderer())
1610 renderer()->updateFromElement(); 1610 renderer()->updateFromElement();
1611 } 1611 }
1612 1612
1613 void HTMLMediaElement::mediaEngineError(PassRefPtrWillBeRawPtr<MediaError> err) 1613 void HTMLMediaElement::mediaEngineError(PassRefPtrWillBeRawPtr<MediaError> err)
1614 { 1614 {
1615 ASSERT(m_readyState >= HAVE_METADATA); 1615 ASSERT(m_readyState >= HAVE_METADATA);
1616 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%d)", static_cast<int>(er r->code())); 1616 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca st<int>(err->code()));
1617 1617
1618 // 1 - The user agent should cancel the fetching process. 1618 // 1 - The user agent should cancel the fetching process.
1619 stopPeriodicTimers(); 1619 stopPeriodicTimers();
1620 m_loadState = WaitingForSource; 1620 m_loadState = WaitingForSource;
1621 1621
1622 // 2 - Set the error attribute to a new MediaError object whose code attribu te is 1622 // 2 - Set the error attribute to a new MediaError object whose code attribu te is
1623 // set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE. 1623 // set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE.
1624 m_error = err; 1624 m_error = err;
1625 1625
1626 // 3 - Queue a task to fire a simple event named error at the media element. 1626 // 3 - Queue a task to fire a simple event named error at the media element.
1627 scheduleEvent(EventTypeNames::error); 1627 scheduleEvent(EventTypeNames::error);
1628 1628
1629 // 4 - Set the element's networkState attribute to the NETWORK_IDLE value. 1629 // 4 - Set the element's networkState attribute to the NETWORK_IDLE value.
1630 m_networkState = NETWORK_IDLE; 1630 m_networkState = NETWORK_IDLE;
1631 1631
1632 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 1632 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
1633 setShouldDelayLoadEvent(false); 1633 setShouldDelayLoadEvent(false);
1634 1634
1635 // 6 - Abort the overall resource selection algorithm. 1635 // 6 - Abort the overall resource selection algorithm.
1636 m_currentSourceNode = nullptr; 1636 m_currentSourceNode = nullptr;
1637 } 1637 }
1638 1638
1639 void HTMLMediaElement::cancelPendingEventsAndCallbacks() 1639 void HTMLMediaElement::cancelPendingEventsAndCallbacks()
1640 { 1640 {
1641 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks"); 1641 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this );
1642 m_asyncEventQueue->cancelAllEvents(); 1642 m_asyncEventQueue->cancelAllEvents();
1643 1643
1644 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) 1644 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source))
1645 source->cancelPendingErrorEvent(); 1645 source->cancelPendingErrorEvent();
1646 } 1646 }
1647 1647
1648 void HTMLMediaElement::mediaPlayerNetworkStateChanged() 1648 void HTMLMediaElement::mediaPlayerNetworkStateChanged()
1649 { 1649 {
1650 setNetworkState(webMediaPlayer()->networkState()); 1650 setNetworkState(webMediaPlayer()->networkState());
1651 } 1651 }
1652 1652
1653 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) 1653 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error)
1654 { 1654 {
1655 stopPeriodicTimers(); 1655 stopPeriodicTimers();
1656 1656
1657 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more 1657 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more
1658 // <source> children, schedule the next one 1658 // <source> children, schedule the next one
1659 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement) { 1659 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement) {
1660 1660
1661 // resource selection algorithm 1661 // resource selection algorithm
1662 // 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. 1662 // 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.
1663 if (m_currentSourceNode) 1663 if (m_currentSourceNode)
1664 m_currentSourceNode->scheduleErrorEvent(); 1664 m_currentSourceNode->scheduleErrorEvent();
1665 else 1665 else
1666 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - error event not sent, <source> was removed"); 1666 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - error event not sent, <source> was removed", this);
1667 1667
1668 // 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. 1668 // 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.
1669 1669
1670 // 9.Otherwise.11 - Forget the media element's media-resource-specific t racks. 1670 // 9.Otherwise.11 - Forget the media element's media-resource-specific t racks.
1671 forgetResourceSpecificTracks(); 1671 forgetResourceSpecificTracks();
1672 1672
1673 if (havePotentialSourceChild()) { 1673 if (havePotentialSourceChild()) {
1674 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - scheduling next <source>"); 1674 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - scheduling n ext <source>", this);
1675 scheduleNextSourceChild(); 1675 scheduleNextSourceChild();
1676 } else { 1676 } else {
1677 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - no more <source> elements, waiting"); 1677 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - no more <sou rce> elements, waiting", this);
1678 waitForSourceChange(); 1678 waitForSourceChange();
1679 } 1679 }
1680 1680
1681 return; 1681 return;
1682 } 1682 }
1683 1683
1684 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA) 1684 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA)
1685 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); 1685 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK));
1686 else if (error == WebMediaPlayer::NetworkStateDecodeError) 1686 else if (error == WebMediaPlayer::NetworkStateDecodeError)
1687 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); 1687 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE));
1688 else if ((error == WebMediaPlayer::NetworkStateFormatError 1688 else if ((error == WebMediaPlayer::NetworkStateFormatError
1689 || error == WebMediaPlayer::NetworkStateNetworkError) 1689 || error == WebMediaPlayer::NetworkStateNetworkError)
1690 && m_loadState == LoadingFromSrcAttr) 1690 && m_loadState == LoadingFromSrcAttr)
1691 noneSupported(); 1691 noneSupported();
1692 1692
1693 updateDisplayState(); 1693 updateDisplayState();
1694 if (hasMediaControls()) 1694 if (hasMediaControls())
1695 mediaControls()->reset(); 1695 mediaControls()->reset();
1696 } 1696 }
1697 1697
1698 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) 1698 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state)
1699 { 1699 {
1700 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%d) - current state is %d" , static_cast<int>(state), static_cast<int>(m_networkState)); 1700 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p, %d) - current state is %d", this, static_cast<int>(state), static_cast<int>(m_networkState));
1701 1701
1702 if (state == WebMediaPlayer::NetworkStateEmpty) { 1702 if (state == WebMediaPlayer::NetworkStateEmpty) {
1703 // Just update the cached state and leave, we can't do anything. 1703 // Just update the cached state and leave, we can't do anything.
1704 m_networkState = NETWORK_EMPTY; 1704 m_networkState = NETWORK_EMPTY;
1705 return; 1705 return;
1706 } 1706 }
1707 1707
1708 if (state == WebMediaPlayer::NetworkStateFormatError 1708 if (state == WebMediaPlayer::NetworkStateFormatError
1709 || state == WebMediaPlayer::NetworkStateNetworkError 1709 || state == WebMediaPlayer::NetworkStateNetworkError
1710 || state == WebMediaPlayer::NetworkStateDecodeError) { 1710 || state == WebMediaPlayer::NetworkStateDecodeError) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 m_networkState = NETWORK_IDLE; 1747 m_networkState = NETWORK_IDLE;
1748 } 1748 }
1749 1749
1750 void HTMLMediaElement::mediaPlayerReadyStateChanged() 1750 void HTMLMediaElement::mediaPlayerReadyStateChanged()
1751 { 1751 {
1752 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); 1752 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState()));
1753 } 1753 }
1754 1754
1755 void HTMLMediaElement::setReadyState(ReadyState state) 1755 void HTMLMediaElement::setReadyState(ReadyState state)
1756 { 1756 {
1757 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%d) - current state is %d,", static_cast<int>(state), static_cast<int>(m_readyState)); 1757 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState));
1758 1758
1759 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it 1759 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it
1760 bool wasPotentiallyPlaying = potentiallyPlaying(); 1760 bool wasPotentiallyPlaying = potentiallyPlaying();
1761 1761
1762 ReadyState oldState = m_readyState; 1762 ReadyState oldState = m_readyState;
1763 ReadyState newState = state; 1763 ReadyState newState = state;
1764 1764
1765 bool tracksAreReady = textTracksAreReady(); 1765 bool tracksAreReady = textTracksAreReady();
1766 1766
1767 if (newState == oldState && m_tracksAreReady == tracksAreReady) 1767 if (newState == oldState && m_tracksAreReady == tracksAreReady)
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 renderer()->updateFromElement(); 1888 renderer()->updateFromElement();
1889 } else if (timedelta > 3.0 && !m_sentStalledEvent) { 1889 } else if (timedelta > 3.0 && !m_sentStalledEvent) {
1890 scheduleEvent(EventTypeNames::stalled); 1890 scheduleEvent(EventTypeNames::stalled);
1891 m_sentStalledEvent = true; 1891 m_sentStalledEvent = true;
1892 setShouldDelayLoadEvent(false); 1892 setShouldDelayLoadEvent(false);
1893 } 1893 }
1894 } 1894 }
1895 1895
1896 void HTMLMediaElement::addPlayedRange(double start, double end) 1896 void HTMLMediaElement::addPlayedRange(double start, double end)
1897 { 1897 {
1898 WTF_LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); 1898 WTF_LOG(Media, "HTMLMediaElement::addPlayedRange(%p, %f, %f)", this, start, end);
1899 if (!m_playedTimeRanges) 1899 if (!m_playedTimeRanges)
1900 m_playedTimeRanges = TimeRanges::create(); 1900 m_playedTimeRanges = TimeRanges::create();
1901 m_playedTimeRanges->add(start, end); 1901 m_playedTimeRanges->add(start, end);
1902 } 1902 }
1903 1903
1904 bool HTMLMediaElement::supportsSave() const 1904 bool HTMLMediaElement::supportsSave() const
1905 { 1905 {
1906 return webMediaPlayer() && webMediaPlayer()->supportsSave(); 1906 return webMediaPlayer() && webMediaPlayer()->supportsSave();
1907 } 1907 }
1908 1908
1909 void HTMLMediaElement::prepareToPlay() 1909 void HTMLMediaElement::prepareToPlay()
1910 { 1910 {
1911 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); 1911 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this);
1912 if (m_havePreparedToPlay) 1912 if (m_havePreparedToPlay)
1913 return; 1913 return;
1914 m_havePreparedToPlay = true; 1914 m_havePreparedToPlay = true;
1915 1915
1916 if (loadIsDeferred()) 1916 if (loadIsDeferred())
1917 startDeferredLoad(); 1917 startDeferredLoad();
1918 } 1918 }
1919 1919
1920 void HTMLMediaElement::seek(double time, ExceptionState& exceptionState) 1920 void HTMLMediaElement::seek(double time, ExceptionState& exceptionState)
1921 { 1921 {
1922 WTF_LOG(Media, "HTMLMediaElement::seek(%f)", time); 1922 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time);
1923 1923
1924 // 4.8.10.9 Seeking 1924 // 4.8.10.9 Seeking
1925 1925
1926 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an Inva lidStateError exception. 1926 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an Inva lidStateError exception.
1927 if (m_readyState == HAVE_NOTHING) { 1927 if (m_readyState == HAVE_NOTHING) {
1928 exceptionState.throwDOMException(InvalidStateError, "The element's ready State is HAVE_NOTHING."); 1928 exceptionState.throwDOMException(InvalidStateError, "The element's ready State is HAVE_NOTHING.");
1929 return; 1929 return;
1930 } 1930 }
1931 1931
1932 // If the media engine has been told to postpone loading data, let it go ahe ad now. 1932 // If the media engine has been told to postpone loading data, let it go ahe ad now.
(...skipping 21 matching lines...) Expand all
1954 // 6 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. 1954 // 6 - If the new playback position is less than the earliest possible posit ion, let it be that position instead.
1955 time = std::max(time, 0.0); 1955 time = std::max(time, 0.0);
1956 1956
1957 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This 1957 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This
1958 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's 1958 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's
1959 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and 1959 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and
1960 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never 1960 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never
1961 // fire a 'seeked' event. 1961 // fire a 'seeked' event.
1962 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); 1962 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time);
1963 if (time != mediaTime) { 1963 if (time != mediaTime) {
1964 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i s %f", time, mediaTime); 1964 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale nt is %f", this, time, mediaTime);
1965 time = mediaTime; 1965 time = mediaTime;
1966 } 1966 }
1967 1967
1968 // 7 - If the (possibly now changed) new playback position is not in one of the ranges given in the 1968 // 7 - If the (possibly now changed) new playback position is not in one of the ranges given in the
1969 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute 1969 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute
1970 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable 1970 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable
1971 // attribute then set the seeking IDL attribute to false and abort these ste ps. 1971 // attribute then set the seeking IDL attribute to false and abort these ste ps.
1972 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); 1972 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable();
1973 1973
1974 // Short circuit seeking to the current time by just firing the events if no seek is required. 1974 // Short circuit seeking to the current time by just firing the events if no seek is required.
(...skipping 28 matching lines...) Expand all
2003 2003
2004 // 9 - Set the current playback position to the given new playback position 2004 // 9 - Set the current playback position to the given new playback position
2005 webMediaPlayer()->seek(time); 2005 webMediaPlayer()->seek(time);
2006 2006
2007 // 10-14 are handled, if necessary, when the engine signals a readystate cha nge or otherwise 2007 // 10-14 are handled, if necessary, when the engine signals a readystate cha nge or otherwise
2008 // satisfies seek completion and signals a time change. 2008 // satisfies seek completion and signals a time change.
2009 } 2009 }
2010 2010
2011 void HTMLMediaElement::finishSeek() 2011 void HTMLMediaElement::finishSeek()
2012 { 2012 {
2013 WTF_LOG(Media, "HTMLMediaElement::finishSeek"); 2013 WTF_LOG(Media, "HTMLMediaElement::finishSeek(%p)", this);
2014 2014
2015 // 4.8.10.9 Seeking completion 2015 // 4.8.10.9 Seeking completion
2016 // 12 - Set the seeking IDL attribute to false. 2016 // 12 - Set the seeking IDL attribute to false.
2017 m_seeking = false; 2017 m_seeking = false;
2018 2018
2019 // 13 - Queue a task to fire a simple event named timeupdate at the element. 2019 // 13 - Queue a task to fire a simple event named timeupdate at the element.
2020 scheduleTimeupdateEvent(false); 2020 scheduleTimeupdateEvent(false);
2021 2021
2022 // 14 - Queue a task to fire a simple event named seeked at the element. 2022 // 14 - Queue a task to fire a simple event named seeked at the element.
2023 scheduleEvent(EventTypeNames::seeked); 2023 scheduleEvent(EventTypeNames::seeked);
(...skipping 19 matching lines...) Expand all
2043 void HTMLMediaElement::refreshCachedTime() const 2043 void HTMLMediaElement::refreshCachedTime() const
2044 { 2044 {
2045 if (!webMediaPlayer() || m_readyState < HAVE_METADATA) 2045 if (!webMediaPlayer() || m_readyState < HAVE_METADATA)
2046 return; 2046 return;
2047 2047
2048 m_cachedTime = webMediaPlayer()->currentTime(); 2048 m_cachedTime = webMediaPlayer()->currentTime();
2049 } 2049 }
2050 2050
2051 void HTMLMediaElement::invalidateCachedTime() 2051 void HTMLMediaElement::invalidateCachedTime()
2052 { 2052 {
2053 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime"); 2053 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime(%p)", this);
2054 m_cachedTime = MediaPlayer::invalidTime(); 2054 m_cachedTime = MediaPlayer::invalidTime();
2055 } 2055 }
2056 2056
2057 // playback state 2057 // playback state
2058 double HTMLMediaElement::currentTime() const 2058 double HTMLMediaElement::currentTime() const
2059 { 2059 {
2060 if (m_readyState == HAVE_NOTHING) 2060 if (m_readyState == HAVE_NOTHING)
2061 return 0; 2061 return 0;
2062 2062
2063 if (m_seeking) { 2063 if (m_seeking) {
2064 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime); 2064 WTF_LOG(Media, "HTMLMediaElement::currentTime(%p) - seeking, returning % f", this, m_lastSeekTime);
2065 return m_lastSeekTime; 2065 return m_lastSeekTime;
2066 } 2066 }
2067 2067
2068 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { 2068 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) {
2069 #if LOG_CACHED_TIME_WARNINGS 2069 #if LOG_CACHED_TIME_WARNINGS
2070 static const double minCachedDeltaForWarning = 0.01; 2070 static const double minCachedDeltaForWarning = 0.01;
2071 double delta = m_cachedTime - webMediaPlayer()->currentTime(); 2071 double delta = m_cachedTime - webMediaPlayer()->currentTime();
2072 if (delta > minCachedDeltaForWarning) 2072 if (delta > minCachedDeltaForWarning)
2073 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta); 2073 WTF_LOG(Media, "HTMLMediaElement::currentTime(%p) - WARNING, cached time is %f seconds off of media time when paused", this, delta);
2074 #endif 2074 #endif
2075 return m_cachedTime; 2075 return m_cachedTime;
2076 } 2076 }
2077 2077
2078 refreshCachedTime(); 2078 refreshCachedTime();
2079 2079
2080 return m_cachedTime; 2080 return m_cachedTime;
2081 } 2081 }
2082 2082
2083 void HTMLMediaElement::setCurrentTime(double time, ExceptionState& exceptionStat e) 2083 void HTMLMediaElement::setCurrentTime(double time, ExceptionState& exceptionStat e)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 scheduleEvent(EventTypeNames::ratechange); 2132 scheduleEvent(EventTypeNames::ratechange);
2133 } 2133 }
2134 2134
2135 double HTMLMediaElement::playbackRate() const 2135 double HTMLMediaElement::playbackRate() const
2136 { 2136 {
2137 return m_playbackRate; 2137 return m_playbackRate;
2138 } 2138 }
2139 2139
2140 void HTMLMediaElement::setPlaybackRate(double rate) 2140 void HTMLMediaElement::setPlaybackRate(double rate)
2141 { 2141 {
2142 WTF_LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate); 2142 WTF_LOG(Media, "HTMLMediaElement::setPlaybackRate(%p, %f)", this, rate);
2143 2143
2144 if (m_playbackRate != rate) { 2144 if (m_playbackRate != rate) {
2145 m_playbackRate = rate; 2145 m_playbackRate = rate;
2146 invalidateCachedTime(); 2146 invalidateCachedTime();
2147 scheduleEvent(EventTypeNames::ratechange); 2147 scheduleEvent(EventTypeNames::ratechange);
2148 } 2148 }
2149 2149
2150 updatePlaybackRate(); 2150 updatePlaybackRate();
2151 } 2151 }
2152 2152
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 return "auto"; 2193 return "auto";
2194 break; 2194 break;
2195 } 2195 }
2196 2196
2197 ASSERT_NOT_REACHED(); 2197 ASSERT_NOT_REACHED();
2198 return String(); 2198 return String();
2199 } 2199 }
2200 2200
2201 void HTMLMediaElement::setPreload(const AtomicString& preload) 2201 void HTMLMediaElement::setPreload(const AtomicString& preload)
2202 { 2202 {
2203 WTF_LOG(Media, "HTMLMediaElement::setPreload(%s)", preload.utf8().data()); 2203 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8(). data());
2204 setAttribute(preloadAttr, preload); 2204 setAttribute(preloadAttr, preload);
2205 } 2205 }
2206 2206
2207 void HTMLMediaElement::play() 2207 void HTMLMediaElement::play()
2208 { 2208 {
2209 WTF_LOG(Media, "HTMLMediaElement::play()"); 2209 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this);
2210 2210
2211 if (m_userGestureRequiredForPlay && !UserGestureIndicator::processingUserGes ture()) 2211 if (m_userGestureRequiredForPlay && !UserGestureIndicator::processingUserGes ture())
2212 return; 2212 return;
2213 if (UserGestureIndicator::processingUserGesture()) 2213 if (UserGestureIndicator::processingUserGesture())
2214 m_userGestureRequiredForPlay = false; 2214 m_userGestureRequiredForPlay = false;
2215 2215
2216 playInternal(); 2216 playInternal();
2217 } 2217 }
2218 2218
2219 void HTMLMediaElement::playInternal() 2219 void HTMLMediaElement::playInternal()
2220 { 2220 {
2221 WTF_LOG(Media, "HTMLMediaElement::playInternal"); 2221 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this);
2222 2222
2223 // 4.8.10.9. Playing the media resource 2223 // 4.8.10.9. Playing the media resource
2224 if (!m_player || m_networkState == NETWORK_EMPTY) 2224 if (!m_player || m_networkState == NETWORK_EMPTY)
2225 scheduleDelayedAction(LoadMediaResource); 2225 scheduleDelayedAction(LoadMediaResource);
2226 2226
2227 if (endedPlayback()) 2227 if (endedPlayback())
2228 seek(0, IGNORE_EXCEPTION); 2228 seek(0, IGNORE_EXCEPTION);
2229 2229
2230 if (m_mediaController) 2230 if (m_mediaController)
2231 m_mediaController->bringElementUpToSpeed(this); 2231 m_mediaController->bringElementUpToSpeed(this);
2232 2232
2233 if (m_paused) { 2233 if (m_paused) {
2234 m_paused = false; 2234 m_paused = false;
2235 invalidateCachedTime(); 2235 invalidateCachedTime();
2236 scheduleEvent(EventTypeNames::play); 2236 scheduleEvent(EventTypeNames::play);
2237 2237
2238 if (m_readyState <= HAVE_CURRENT_DATA) 2238 if (m_readyState <= HAVE_CURRENT_DATA)
2239 scheduleEvent(EventTypeNames::waiting); 2239 scheduleEvent(EventTypeNames::waiting);
2240 else if (m_readyState >= HAVE_FUTURE_DATA) 2240 else if (m_readyState >= HAVE_FUTURE_DATA)
2241 scheduleEvent(EventTypeNames::playing); 2241 scheduleEvent(EventTypeNames::playing);
2242 } 2242 }
2243 m_autoplaying = false; 2243 m_autoplaying = false;
2244 2244
2245 updatePlayState(); 2245 updatePlayState();
2246 updateMediaController(); 2246 updateMediaController();
2247 } 2247 }
2248 2248
2249 void HTMLMediaElement::pause() 2249 void HTMLMediaElement::pause()
2250 { 2250 {
2251 WTF_LOG(Media, "HTMLMediaElement::pause()"); 2251 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this);
2252 2252
2253 if (!m_player || m_networkState == NETWORK_EMPTY) 2253 if (!m_player || m_networkState == NETWORK_EMPTY)
2254 scheduleDelayedAction(LoadMediaResource); 2254 scheduleDelayedAction(LoadMediaResource);
2255 2255
2256 m_autoplaying = false; 2256 m_autoplaying = false;
2257 2257
2258 if (!m_paused) { 2258 if (!m_paused) {
2259 m_paused = true; 2259 m_paused = true;
2260 scheduleTimeupdateEvent(false); 2260 scheduleTimeupdateEvent(false);
2261 scheduleEvent(EventTypeNames::pause); 2261 scheduleEvent(EventTypeNames::pause);
(...skipping 11 matching lines...) Expand all
2273 m_mediaSource = nullptr; 2273 m_mediaSource = nullptr;
2274 } 2274 }
2275 2275
2276 bool HTMLMediaElement::loop() const 2276 bool HTMLMediaElement::loop() const
2277 { 2277 {
2278 return fastHasAttribute(loopAttr); 2278 return fastHasAttribute(loopAttr);
2279 } 2279 }
2280 2280
2281 void HTMLMediaElement::setLoop(bool b) 2281 void HTMLMediaElement::setLoop(bool b)
2282 { 2282 {
2283 WTF_LOG(Media, "HTMLMediaElement::setLoop(%s)", boolString(b)); 2283 WTF_LOG(Media, "HTMLMediaElement::setLoop(%p, %s)", this, boolString(b));
2284 setBooleanAttribute(loopAttr, b); 2284 setBooleanAttribute(loopAttr, b);
2285 } 2285 }
2286 2286
2287 bool HTMLMediaElement::shouldShowControls() const 2287 bool HTMLMediaElement::shouldShowControls() const
2288 { 2288 {
2289 LocalFrame* frame = document().frame(); 2289 LocalFrame* frame = document().frame();
2290 2290
2291 // always show controls when scripting is disabled 2291 // always show controls when scripting is disabled
2292 if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript)) 2292 if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript))
2293 return true; 2293 return true;
2294 2294
2295 // Always show controls when in full screen mode. 2295 // Always show controls when in full screen mode.
2296 if (isFullscreen()) 2296 if (isFullscreen())
2297 return true; 2297 return true;
2298 2298
2299 return fastHasAttribute(controlsAttr); 2299 return fastHasAttribute(controlsAttr);
2300 } 2300 }
2301 2301
2302 double HTMLMediaElement::volume() const 2302 double HTMLMediaElement::volume() const
2303 { 2303 {
2304 return m_volume; 2304 return m_volume;
2305 } 2305 }
2306 2306
2307 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState) 2307 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState)
2308 { 2308 {
2309 WTF_LOG(Media, "HTMLMediaElement::setVolume(%f)", vol); 2309 WTF_LOG(Media, "HTMLMediaElement::setVolume(%p, %f)", this, vol);
2310 2310
2311 if (m_volume == vol) 2311 if (m_volume == vol)
2312 return; 2312 return;
2313 2313
2314 if (vol < 0.0f || vol > 1.0f) { 2314 if (vol < 0.0f || vol > 1.0f) {
2315 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", vol, 0.0, ExceptionMessages::InclusiveBound, 1.0, Except ionMessages::InclusiveBound)); 2315 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", vol, 0.0, ExceptionMessages::InclusiveBound, 1.0, Except ionMessages::InclusiveBound));
2316 return; 2316 return;
2317 } 2317 }
2318 2318
2319 m_volume = vol; 2319 m_volume = vol;
2320 updateVolume(); 2320 updateVolume();
2321 scheduleEvent(EventTypeNames::volumechange); 2321 scheduleEvent(EventTypeNames::volumechange);
2322 } 2322 }
2323 2323
2324 bool HTMLMediaElement::muted() const 2324 bool HTMLMediaElement::muted() const
2325 { 2325 {
2326 return m_muted; 2326 return m_muted;
2327 } 2327 }
2328 2328
2329 void HTMLMediaElement::setMuted(bool muted) 2329 void HTMLMediaElement::setMuted(bool muted)
2330 { 2330 {
2331 WTF_LOG(Media, "HTMLMediaElement::setMuted(%s)", boolString(muted)); 2331 WTF_LOG(Media, "HTMLMediaElement::setMuted(%p, %s)", this, boolString(muted) );
2332 2332
2333 if (m_muted == muted) 2333 if (m_muted == muted)
2334 return; 2334 return;
2335 2335
2336 m_muted = muted; 2336 m_muted = muted;
2337 2337
2338 updateVolume(); 2338 updateVolume();
2339 2339
2340 scheduleEvent(EventTypeNames::volumechange); 2340 scheduleEvent(EventTypeNames::volumechange);
2341 } 2341 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 } 2447 }
2448 2448
2449 AudioTrackList& HTMLMediaElement::audioTracks() 2449 AudioTrackList& HTMLMediaElement::audioTracks()
2450 { 2450 {
2451 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2451 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2452 return *m_audioTracks; 2452 return *m_audioTracks;
2453 } 2453 }
2454 2454
2455 void HTMLMediaElement::audioTrackChanged() 2455 void HTMLMediaElement::audioTrackChanged()
2456 { 2456 {
2457 WTF_LOG(Media, "HTMLMediaElement::audioTrackChanged()"); 2457 WTF_LOG(Media, "HTMLMediaElement::audioTrackChanged(%p)", this);
2458 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2458 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2459 2459
2460 audioTracks().scheduleChangeEvent(); 2460 audioTracks().scheduleChangeEvent();
2461 2461
2462 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.audioTracks attribute is added. 2462 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.audioTracks attribute is added.
2463 2463
2464 if (!m_audioTracksTimer.isActive()) 2464 if (!m_audioTracksTimer.isActive())
2465 m_audioTracksTimer.startOneShot(0, FROM_HERE); 2465 m_audioTracksTimer.startOneShot(0, FROM_HERE);
2466 } 2466 }
2467 2467
2468 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) 2468 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*)
2469 { 2469 {
2470 Vector<WebMediaPlayer::TrackId> enabledTrackIds; 2470 Vector<WebMediaPlayer::TrackId> enabledTrackIds;
2471 for (unsigned i = 0; i < audioTracks().length(); ++i) { 2471 for (unsigned i = 0; i < audioTracks().length(); ++i) {
2472 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); 2472 AudioTrack* track = audioTracks().anonymousIndexedGetter(i);
2473 if (track->enabled()) 2473 if (track->enabled())
2474 enabledTrackIds.append(track->trackId()); 2474 enabledTrackIds.append(track->trackId());
2475 } 2475 }
2476 2476
2477 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); 2477 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds);
2478 } 2478 }
2479 2479
2480 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, blink: :WebMediaPlayerClient::AudioTrackKind kind, const AtomicString& label, const Ato micString& language, bool enabled) 2480 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, blink: :WebMediaPlayerClient::AudioTrackKind kind, const AtomicString& label, const Ato micString& language, bool enabled)
2481 { 2481 {
2482 AtomicString kindString = AudioKindToString(kind); 2482 AtomicString kindString = AudioKindToString(kind);
2483 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack('%s', '%s', '%s', '%s', %d)" , 2483 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)",
2484 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), enabled); 2484 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data() , language.ascii().data(), enabled);
2485 2485
2486 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2486 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2487 return 0; 2487 return 0;
2488 2488
2489 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled); 2489 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled);
2490 audioTracks().add(audioTrack); 2490 audioTracks().add(audioTrack);
2491 2491
2492 return audioTrack->trackId(); 2492 return audioTrack->trackId();
2493 } 2493 }
2494 2494
2495 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) 2495 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId)
2496 { 2496 {
2497 WTF_LOG(Media, "HTMLMediaElement::removeAudioTrack()"); 2497 WTF_LOG(Media, "HTMLMediaElement::removeAudioTrack(%p)", this);
2498 2498
2499 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2499 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2500 return; 2500 return;
2501 2501
2502 audioTracks().remove(trackId); 2502 audioTracks().remove(trackId);
2503 } 2503 }
2504 2504
2505 VideoTrackList& HTMLMediaElement::videoTracks() 2505 VideoTrackList& HTMLMediaElement::videoTracks()
2506 { 2506 {
2507 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2507 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2508 return *m_videoTracks; 2508 return *m_videoTracks;
2509 } 2509 }
2510 2510
2511 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select edTrackId) 2511 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select edTrackId)
2512 { 2512 {
2513 WTF_LOG(Media, "HTMLMediaElement::selectedVideoTrackChanged()"); 2513 WTF_LOG(Media, "HTMLMediaElement::selectedVideoTrackChanged(%p)", this);
2514 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2514 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2515 2515
2516 if (selectedTrackId) 2516 if (selectedTrackId)
2517 videoTracks().trackSelected(*selectedTrackId); 2517 videoTracks().trackSelected(*selectedTrackId);
2518 2518
2519 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. 2519 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added.
2520 2520
2521 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); 2521 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId);
2522 } 2522 }
2523 2523
2524 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, blink: :WebMediaPlayerClient::VideoTrackKind kind, const AtomicString& label, const Ato micString& language, bool selected) 2524 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, blink: :WebMediaPlayerClient::VideoTrackKind kind, const AtomicString& label, const Ato micString& language, bool selected)
2525 { 2525 {
2526 AtomicString kindString = VideoKindToString(kind); 2526 AtomicString kindString = VideoKindToString(kind);
2527 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack('%s', '%s', '%s', '%s', %d)" , 2527 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)",
2528 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), selected); 2528 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data() , language.ascii().data(), selected);
2529 2529
2530 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2530 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2531 return 0; 2531 return 0;
2532 2532
2533 // If another track was selected (potentially by the user), leave it selecte d. 2533 // If another track was selected (potentially by the user), leave it selecte d.
2534 if (selected && videoTracks().selectedIndex() != -1) 2534 if (selected && videoTracks().selectedIndex() != -1)
2535 selected = false; 2535 selected = false;
2536 2536
2537 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected); 2537 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected);
2538 videoTracks().add(videoTrack); 2538 videoTracks().add(videoTrack);
2539 2539
2540 return videoTrack->trackId(); 2540 return videoTrack->trackId();
2541 } 2541 }
2542 2542
2543 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) 2543 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId)
2544 { 2544 {
2545 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack()"); 2545 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this);
2546 2546
2547 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2547 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2548 return; 2548 return;
2549 2549
2550 videoTracks().remove(trackId); 2550 videoTracks().remove(trackId);
2551 } 2551 }
2552 2552
2553 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) 2553 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack)
2554 { 2554 {
2555 // 4.8.10.12.2 Sourcing in-band text tracks 2555 // 4.8.10.12.2 Sourcing in-band text tracks
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks 2691 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks
2692 // in the markup have been added. 2692 // in the markup have been added.
2693 if (isFinishedParsingChildren()) 2693 if (isFinishedParsingChildren())
2694 scheduleDelayedAction(LoadTextTrackResource); 2694 scheduleDelayedAction(LoadTextTrackResource);
2695 } 2695 }
2696 2696
2697 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) 2697 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement)
2698 { 2698 {
2699 #if !LOG_DISABLED 2699 #if !LOG_DISABLED
2700 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); 2700 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr);
2701 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement - 'src' is %s", urlF orLoggingMedia(url).utf8().data()); 2701 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data());
2702 #endif 2702 #endif
2703 2703
2704 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track(); 2704 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track();
2705 if (!textTrack) 2705 if (!textTrack)
2706 return; 2706 return;
2707 2707
2708 textTrack->setHasBeenConfigured(false); 2708 textTrack->setHasBeenConfigured(false);
2709 2709
2710 if (!m_textTracks) 2710 if (!m_textTracks)
2711 return; 2711 return;
(...skipping 27 matching lines...) Expand all
2739 if (track.kind() != TextTrack::captionsKeyword() && track.kind() != TextTrac k::subtitlesKeyword()) 2739 if (track.kind() != TextTrack::captionsKeyword() && track.kind() != TextTrac k::subtitlesKeyword())
2740 return 0; 2740 return 0;
2741 2741
2742 return textTrackLanguageSelectionScore(track); 2742 return textTrackLanguageSelectionScore(track);
2743 } 2743 }
2744 2744
2745 void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group) 2745 void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group)
2746 { 2746 {
2747 ASSERT(group.tracks.size()); 2747 ASSERT(group.tracks.size());
2748 2748
2749 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackGroup(%d)", group.kind); 2749 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackGroup(%p, %d)", this, gr oup.kind);
2750 2750
2751 // First, find the track in the group that should be enabled (if any). 2751 // First, find the track in the group that should be enabled (if any).
2752 WillBeHeapVector<RefPtrWillBeMember<TextTrack> > currentlyEnabledTracks; 2752 WillBeHeapVector<RefPtrWillBeMember<TextTrack> > currentlyEnabledTracks;
2753 RefPtrWillBeRawPtr<TextTrack> trackToEnable = nullptr; 2753 RefPtrWillBeRawPtr<TextTrack> trackToEnable = nullptr;
2754 RefPtrWillBeRawPtr<TextTrack> defaultTrack = nullptr; 2754 RefPtrWillBeRawPtr<TextTrack> defaultTrack = nullptr;
2755 RefPtrWillBeRawPtr<TextTrack> fallbackTrack = nullptr; 2755 RefPtrWillBeRawPtr<TextTrack> fallbackTrack = nullptr;
2756 int highestTrackScore = 0; 2756 int highestTrackScore = 0;
2757 for (size_t i = 0; i < group.tracks.size(); ++i) { 2757 for (size_t i = 0; i < group.tracks.size(); ++i) {
2758 RefPtrWillBeRawPtr<TextTrack> textTrack = group.tracks[i]; 2758 RefPtrWillBeRawPtr<TextTrack> textTrack = group.tracks[i];
2759 2759
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 2887
2888 return nextURL.isValid(); 2888 return nextURL.isValid();
2889 } 2889 }
2890 2890
2891 KURL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, String* k eySystem, InvalidURLAction actionIfInvalid) 2891 KURL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, String* k eySystem, InvalidURLAction actionIfInvalid)
2892 { 2892 {
2893 #if !LOG_DISABLED 2893 #if !LOG_DISABLED
2894 // Don't log if this was just called to find out if there are any valid <sou rce> elements. 2894 // Don't log if this was just called to find out if there are any valid <sou rce> elements.
2895 bool shouldLog = actionIfInvalid != DoNothing; 2895 bool shouldLog = actionIfInvalid != DoNothing;
2896 if (shouldLog) 2896 if (shouldLog)
2897 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild"); 2897 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p)", this);
2898 #endif 2898 #endif
2899 2899
2900 if (!m_nextChildNodeToConsider) { 2900 if (!m_nextChildNodeToConsider) {
2901 #if !LOG_DISABLED 2901 #if !LOG_DISABLED
2902 if (shouldLog) 2902 if (shouldLog)
2903 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild -> 0x0000, \ "\""); 2903 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) -> 0x000 0, \"\"", this);
2904 #endif 2904 #endif
2905 return KURL(); 2905 return KURL();
2906 } 2906 }
2907 2907
2908 KURL mediaURL; 2908 KURL mediaURL;
2909 Node* node; 2909 Node* node;
2910 HTMLSourceElement* source = 0; 2910 HTMLSourceElement* source = 0;
2911 String type; 2911 String type;
2912 String system; 2912 String system;
2913 bool lookingForStartNode = m_nextChildNodeToConsider; 2913 bool lookingForStartNode = m_nextChildNodeToConsider;
(...skipping 12 matching lines...) Expand all
2926 continue; 2926 continue;
2927 if (node->parentNode() != this) 2927 if (node->parentNode() != this)
2928 continue; 2928 continue;
2929 2929
2930 source = toHTMLSourceElement(node); 2930 source = toHTMLSourceElement(node);
2931 2931
2932 // If candidate does not have a src attribute, or if its src attribute's value is the empty string ... jump down to the failed step below 2932 // If candidate does not have a src attribute, or if its src attribute's value is the empty string ... jump down to the failed step below
2933 mediaURL = source->getNonEmptyURLAttribute(srcAttr); 2933 mediaURL = source->getNonEmptyURLAttribute(srcAttr);
2934 #if !LOG_DISABLED 2934 #if !LOG_DISABLED
2935 if (shouldLog) 2935 if (shouldLog)
2936 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'src' is % s", urlForLoggingMedia(mediaURL).utf8().data()); 2936 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 'src' is %s", this, urlForLoggingMedia(mediaURL).utf8().data());
2937 #endif 2937 #endif
2938 if (mediaURL.isEmpty()) 2938 if (mediaURL.isEmpty())
2939 goto check_again; 2939 goto check_again;
2940 2940
2941 type = source->type(); 2941 type = source->type();
2942 // FIXME(82965): Add support for keySystem in <source> and set system fr om source. 2942 // FIXME(82965): Add support for keySystem in <source> and set system fr om source.
2943 if (type.isEmpty() && mediaURL.protocolIsData()) 2943 if (type.isEmpty() && mediaURL.protocolIsData())
2944 type = mimeTypeFromDataURL(mediaURL); 2944 type = mimeTypeFromDataURL(mediaURL);
2945 if (!type.isEmpty() || !system.isEmpty()) { 2945 if (!type.isEmpty() || !system.isEmpty()) {
2946 #if !LOG_DISABLED 2946 #if !LOG_DISABLED
2947 if (shouldLog) 2947 if (shouldLog)
2948 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'type' is '%s' - key system is '%s'", type.utf8().data(), system.utf8().data()); 2948 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 't ype' is '%s' - key system is '%s'", this, type.utf8().data(), system.utf8().data ());
2949 #endif 2949 #endif
2950 if (!supportsType(ContentType(type), system)) 2950 if (!supportsType(ContentType(type), system))
2951 goto check_again; 2951 goto check_again;
2952 } 2952 }
2953 2953
2954 // Is it safe to load this url? 2954 // Is it safe to load this url?
2955 if (!isSafeToLoadURL(mediaURL, actionIfInvalid)) 2955 if (!isSafeToLoadURL(mediaURL, actionIfInvalid))
2956 goto check_again; 2956 goto check_again;
2957 2957
2958 // Making it this far means the <source> looks reasonable. 2958 // Making it this far means the <source> looks reasonable.
(...skipping 11 matching lines...) Expand all
2970 *keySystem = system; 2970 *keySystem = system;
2971 m_currentSourceNode = source; 2971 m_currentSourceNode = source;
2972 m_nextChildNodeToConsider = source->nextSibling(); 2972 m_nextChildNodeToConsider = source->nextSibling();
2973 } else { 2973 } else {
2974 m_currentSourceNode = nullptr; 2974 m_currentSourceNode = nullptr;
2975 m_nextChildNodeToConsider = nullptr; 2975 m_nextChildNodeToConsider = nullptr;
2976 } 2976 }
2977 2977
2978 #if !LOG_DISABLED 2978 #if !LOG_DISABLED
2979 if (shouldLog) 2979 if (shouldLog)
2980 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild -> %p, %s", m_cu rrentSourceNode.get(), canUseSourceElement ? urlForLoggingMedia(mediaURL).utf8() .data() : ""); 2980 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) -> %p, %s", this, m_currentSourceNode.get(), canUseSourceElement ? urlForLoggingMedia(mediaU RL).utf8().data() : "");
2981 #endif 2981 #endif
2982 return canUseSourceElement ? mediaURL : KURL(); 2982 return canUseSourceElement ? mediaURL : KURL();
2983 } 2983 }
2984 2984
2985 void HTMLMediaElement::sourceWasAdded(HTMLSourceElement* source) 2985 void HTMLMediaElement::sourceWasAdded(HTMLSourceElement* source)
2986 { 2986 {
2987 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded(%p)", source); 2987 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded(%p, %p)", this, source);
2988 2988
2989 #if !LOG_DISABLED 2989 #if !LOG_DISABLED
2990 KURL url = source->getNonEmptyURLAttribute(srcAttr); 2990 KURL url = source->getNonEmptyURLAttribute(srcAttr);
2991 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded - 'src' is %s", urlForLoggi ngMedia(url).utf8().data()); 2991 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - 'src' is %s", this, u rlForLoggingMedia(url).utf8().data());
2992 #endif 2992 #endif
2993 2993
2994 // We should only consider a <source> element when there is not src attribut e at all. 2994 // We should only consider a <source> element when there is not src attribut e at all.
2995 if (fastHasAttribute(srcAttr)) 2995 if (fastHasAttribute(srcAttr))
2996 return; 2996 return;
2997 2997
2998 // 4.8.8 - If a source element is inserted as a child of a media element tha t has no src 2998 // 4.8.8 - If a source element is inserted as a child of a media element tha t has no src
2999 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag ent must invoke 2999 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag ent must invoke
3000 // the media element's resource selection algorithm. 3000 // the media element's resource selection algorithm.
3001 if (networkState() == HTMLMediaElement::NETWORK_EMPTY) { 3001 if (networkState() == HTMLMediaElement::NETWORK_EMPTY) {
3002 scheduleDelayedAction(LoadMediaResource); 3002 scheduleDelayedAction(LoadMediaResource);
3003 m_nextChildNodeToConsider = source; 3003 m_nextChildNodeToConsider = source;
3004 return; 3004 return;
3005 } 3005 }
3006 3006
3007 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) { 3007 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) {
3008 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded - <source> inserted imm ediately after current source"); 3008 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - <source> inserted immediately after current source", this);
3009 m_nextChildNodeToConsider = source; 3009 m_nextChildNodeToConsider = source;
3010 return; 3010 return;
3011 } 3011 }
3012 3012
3013 if (m_nextChildNodeToConsider) 3013 if (m_nextChildNodeToConsider)
3014 return; 3014 return;
3015 3015
3016 if (m_loadState != WaitingForSource) 3016 if (m_loadState != WaitingForSource)
3017 return; 3017 return;
3018 3018
3019 // 4.8.9.5, resource selection algorithm, source elements section: 3019 // 4.8.9.5, resource selection algorithm, source elements section:
3020 // 21. Wait until the node after pointer is a node other than the end of the list. (This step might wait forever.) 3020 // 21. Wait until the node after pointer is a node other than the end of the list. (This step might wait forever.)
3021 // 22. Asynchronously await a stable state... 3021 // 22. Asynchronously await a stable state...
3022 // 23. Set the element's delaying-the-load-event flag back to true (this del ays the load event again, in case 3022 // 23. Set the element's delaying-the-load-event flag back to true (this del ays the load event again, in case
3023 // it hasn't been fired yet). 3023 // it hasn't been fired yet).
3024 setShouldDelayLoadEvent(true); 3024 setShouldDelayLoadEvent(true);
3025 3025
3026 // 24. Set the networkState back to NETWORK_LOADING. 3026 // 24. Set the networkState back to NETWORK_LOADING.
3027 m_networkState = NETWORK_LOADING; 3027 m_networkState = NETWORK_LOADING;
3028 3028
3029 // 25. Jump back to the find next candidate step above. 3029 // 25. Jump back to the find next candidate step above.
3030 m_nextChildNodeToConsider = source; 3030 m_nextChildNodeToConsider = source;
3031 scheduleNextSourceChild(); 3031 scheduleNextSourceChild();
3032 } 3032 }
3033 3033
3034 void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source) 3034 void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source)
3035 { 3035 {
3036 WTF_LOG(Media, "HTMLMediaElement::sourceWasRemoved(%p)", source); 3036 WTF_LOG(Media, "HTMLMediaElement::sourceWasRemoved(%p, %p)", this, source);
3037 3037
3038 #if !LOG_DISABLED 3038 #if !LOG_DISABLED
3039 KURL url = source->getNonEmptyURLAttribute(srcAttr); 3039 KURL url = source->getNonEmptyURLAttribute(srcAttr);
3040 WTF_LOG(Media, "HTMLMediaElement::sourceWasRemoved - 'src' is %s", urlForLog gingMedia(url).utf8().data()); 3040 WTF_LOG(Media, "HTMLMediaElement::sourceWasRemoved(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data());
3041 #endif 3041 #endif
3042 3042
3043 if (source != m_currentSourceNode && source != m_nextChildNodeToConsider) 3043 if (source != m_currentSourceNode && source != m_nextChildNodeToConsider)
3044 return; 3044 return;
3045 3045
3046 if (source == m_nextChildNodeToConsider) { 3046 if (source == m_nextChildNodeToConsider) {
3047 if (m_currentSourceNode) 3047 if (m_currentSourceNode)
3048 m_nextChildNodeToConsider = m_currentSourceNode->nextSibling(); 3048 m_nextChildNodeToConsider = m_currentSourceNode->nextSibling();
3049 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved - m_nextChildNodeToConsi der set to %p", m_nextChildNodeToConsider.get()); 3049 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC onsider set to %p", this, m_nextChildNodeToConsider.get());
3050 } else if (source == m_currentSourceNode) { 3050 } else if (source == m_currentSourceNode) {
3051 // Clear the current source node pointer, but don't change the movie as the spec says: 3051 // Clear the current source node pointer, but don't change the movie as the spec says:
3052 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already 3052 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already
3053 // inserted in a video or audio element will have no effect. 3053 // inserted in a video or audio element will have no effect.
3054 m_currentSourceNode = nullptr; 3054 m_currentSourceNode = nullptr;
3055 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved - m_currentSourceNode se t to 0"); 3055 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this);
3056 } 3056 }
3057 } 3057 }
3058 3058
3059 void HTMLMediaElement::mediaPlayerTimeChanged() 3059 void HTMLMediaElement::mediaPlayerTimeChanged()
3060 { 3060 {
3061 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged"); 3061 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this);
3062 3062
3063 updateActiveTextTrackCues(currentTime()); 3063 updateActiveTextTrackCues(currentTime());
3064 3064
3065 invalidateCachedTime(); 3065 invalidateCachedTime();
3066 3066
3067 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 3067 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek.
3068 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) 3068 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king())
3069 finishSeek(); 3069 finishSeek();
3070 3070
3071 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, 3071 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3104 } 3104 }
3105 } 3105 }
3106 else 3106 else
3107 m_sentEndEvent = false; 3107 m_sentEndEvent = false;
3108 3108
3109 updatePlayState(); 3109 updatePlayState();
3110 } 3110 }
3111 3111
3112 void HTMLMediaElement::mediaPlayerDurationChanged() 3112 void HTMLMediaElement::mediaPlayerDurationChanged()
3113 { 3113 {
3114 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged"); 3114 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this);
3115 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey 3115 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey
3116 // the currentTime when the duration change occured. The current 3116 // the currentTime when the duration change occured. The current
3117 // WebMediaPlayer implementations always clamp currentTime() to 3117 // WebMediaPlayer implementations always clamp currentTime() to
3118 // duration() so the requestSeek condition here is always false. 3118 // duration() so the requestSeek condition here is always false.
3119 durationChanged(duration(), currentTime() > duration()); 3119 durationChanged(duration(), currentTime() > duration());
3120 } 3120 }
3121 3121
3122 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) 3122 void HTMLMediaElement::durationChanged(double duration, bool requestSeek)
3123 { 3123 {
3124 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%f, %d)", duration, reques tSeek); 3124 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek);
3125 3125
3126 // Abort if duration unchanged. 3126 // Abort if duration unchanged.
3127 if (m_duration == duration) 3127 if (m_duration == duration)
3128 return; 3128 return;
3129 3129
3130 WTF_LOG(Media, "HTMLMediaElement::durationChanged : %f -> %f", m_duration, d uration); 3130 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration);
3131 m_duration = duration; 3131 m_duration = duration;
3132 scheduleEvent(EventTypeNames::durationchange); 3132 scheduleEvent(EventTypeNames::durationchange);
3133 3133
3134 if (hasMediaControls()) 3134 if (hasMediaControls())
3135 mediaControls()->reset(); 3135 mediaControls()->reset();
3136 if (renderer()) 3136 if (renderer())
3137 renderer()->updateFromElement(); 3137 renderer()->updateFromElement();
3138 3138
3139 if (requestSeek) 3139 if (requestSeek)
3140 seek(duration, IGNORE_EXCEPTION); 3140 seek(duration, IGNORE_EXCEPTION);
3141 } 3141 }
3142 3142
3143 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() 3143 void HTMLMediaElement::mediaPlayerPlaybackStateChanged()
3144 { 3144 {
3145 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); 3145 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this );
3146 3146
3147 if (!m_player || m_pausedInternal) 3147 if (!m_player || m_pausedInternal)
3148 return; 3148 return;
3149 3149
3150 if (webMediaPlayer()->paused()) 3150 if (webMediaPlayer()->paused())
3151 pause(); 3151 pause();
3152 else 3152 else
3153 playInternal(); 3153 playInternal();
3154 } 3154 }
3155 3155
3156 void HTMLMediaElement::mediaPlayerRequestFullscreen() 3156 void HTMLMediaElement::mediaPlayerRequestFullscreen()
3157 { 3157 {
3158 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen"); 3158 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen(%p)", this);
3159 3159
3160 // The player is responsible for only invoking this callback in response to 3160 // The player is responsible for only invoking this callback in response to
3161 // user interaction or when it is technically required to play the video. 3161 // user interaction or when it is technically required to play the video.
3162 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 3162 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
3163 3163
3164 enterFullscreen(); 3164 enterFullscreen();
3165 } 3165 }
3166 3166
3167 void HTMLMediaElement::mediaPlayerRequestSeek(double time) 3167 void HTMLMediaElement::mediaPlayerRequestSeek(double time)
3168 { 3168 {
(...skipping 11 matching lines...) Expand all
3180 if (m_webLayer) 3180 if (m_webLayer)
3181 m_webLayer->invalidate(); 3181 m_webLayer->invalidate();
3182 3182
3183 updateDisplayState(); 3183 updateDisplayState();
3184 if (renderer()) 3184 if (renderer())
3185 renderer()->setShouldDoFullPaintInvalidation(true); 3185 renderer()->setShouldDoFullPaintInvalidation(true);
3186 } 3186 }
3187 3187
3188 void HTMLMediaElement::mediaPlayerSizeChanged() 3188 void HTMLMediaElement::mediaPlayerSizeChanged()
3189 { 3189 {
3190 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged"); 3190 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this);
3191 3191
3192 ASSERT(hasVideo()); // "resize" makes no sense absent video. 3192 ASSERT(hasVideo()); // "resize" makes no sense absent video.
3193 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) 3193 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement())
3194 scheduleEvent(EventTypeNames::resize); 3194 scheduleEvent(EventTypeNames::resize);
3195 3195
3196 if (renderer()) 3196 if (renderer())
3197 renderer()->updateFromElement(); 3197 renderer()->updateFromElement();
3198 } 3198 }
3199 3199
3200 PassRefPtrWillBeRawPtr<TimeRanges> HTMLMediaElement::buffered() const 3200 PassRefPtrWillBeRawPtr<TimeRanges> HTMLMediaElement::buffered() const
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3294 webMediaPlayer()->pause(); 3294 webMediaPlayer()->pause();
3295 refreshCachedTime(); 3295 refreshCachedTime();
3296 m_playbackProgressTimer.stop(); 3296 m_playbackProgressTimer.stop();
3297 if (hasMediaControls()) 3297 if (hasMediaControls())
3298 mediaControls()->playbackStopped(); 3298 mediaControls()->playbackStopped();
3299 return; 3299 return;
3300 } 3300 }
3301 3301
3302 bool shouldBePlaying = potentiallyPlaying(); 3302 bool shouldBePlaying = potentiallyPlaying();
3303 3303
3304 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, is Playing = %s", 3304 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s",
3305 boolString(shouldBePlaying), boolString(isPlaying)); 3305 this, boolString(shouldBePlaying), boolString(isPlaying));
3306 3306
3307 if (shouldBePlaying) { 3307 if (shouldBePlaying) {
3308 setDisplayMode(Video); 3308 setDisplayMode(Video);
3309 invalidateCachedTime(); 3309 invalidateCachedTime();
3310 3310
3311 if (!isPlaying) { 3311 if (!isPlaying) {
3312 // Set rate, muted before calling play in case they were set before the media engine was setup. 3312 // Set rate, muted before calling play in case they were set before the media engine was setup.
3313 // The media engine should just stash the rate and muted values sinc e it isn't already playing. 3313 // The media engine should just stash the rate and muted values sinc e it isn't already playing.
3314 webMediaPlayer()->setRate(effectivePlaybackRate()); 3314 webMediaPlayer()->setRate(effectivePlaybackRate());
3315 updateVolume(); 3315 updateVolume();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3352 } 3352 }
3353 3353
3354 void HTMLMediaElement::stopPeriodicTimers() 3354 void HTMLMediaElement::stopPeriodicTimers()
3355 { 3355 {
3356 m_progressEventTimer.stop(); 3356 m_progressEventTimer.stop();
3357 m_playbackProgressTimer.stop(); 3357 m_playbackProgressTimer.stop();
3358 } 3358 }
3359 3359
3360 void HTMLMediaElement::userCancelledLoad() 3360 void HTMLMediaElement::userCancelledLoad()
3361 { 3361 {
3362 WTF_LOG(Media, "HTMLMediaElement::userCancelledLoad"); 3362 WTF_LOG(Media, "HTMLMediaElement::userCancelledLoad(%p)", this);
3363 3363
3364 // If the media data fetching process is aborted by the user: 3364 // If the media data fetching process is aborted by the user:
3365 3365
3366 // 1 - The user agent should cancel the fetching process. 3366 // 1 - The user agent should cancel the fetching process.
3367 clearMediaPlayer(-1); 3367 clearMediaPlayer(-1);
3368 3368
3369 if (m_networkState == NETWORK_EMPTY || m_completelyLoaded) 3369 if (m_networkState == NETWORK_EMPTY || m_completelyLoaded)
3370 return; 3370 return;
3371 3371
3372 // 2 - Set the error attribute to a new MediaError object whose code attribu te is set to MEDIA_ERR_ABORTED. 3372 // 2 - Set the error attribute to a new MediaError object whose code attribu te is set to MEDIA_ERR_ABORTED.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3428 3428
3429 m_pendingActionFlags &= ~flags; 3429 m_pendingActionFlags &= ~flags;
3430 m_loadState = WaitingForSource; 3430 m_loadState = WaitingForSource;
3431 3431
3432 if (m_textTracks) 3432 if (m_textTracks)
3433 configureTextTrackDisplay(AssumeNoVisibleChange); 3433 configureTextTrackDisplay(AssumeNoVisibleChange);
3434 } 3434 }
3435 3435
3436 void HTMLMediaElement::stop() 3436 void HTMLMediaElement::stop()
3437 { 3437 {
3438 WTF_LOG(Media, "HTMLMediaElement::stop"); 3438 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this);
3439 3439
3440 m_active = false; 3440 m_active = false;
3441 userCancelledLoad(); 3441 userCancelledLoad();
3442 3442
3443 // Stop the playback without generating events 3443 // Stop the playback without generating events
3444 m_playing = false; 3444 m_playing = false;
3445 setPausedInternal(true); 3445 setPausedInternal(true);
3446 3446
3447 if (renderer()) 3447 if (renderer())
3448 renderer()->updateFromElement(); 3448 renderer()->updateFromElement();
(...skipping 20 matching lines...) Expand all
3469 ActiveDOMObject::contextDestroyed(); 3469 ActiveDOMObject::contextDestroyed();
3470 } 3470 }
3471 3471
3472 bool HTMLMediaElement::isFullscreen() const 3472 bool HTMLMediaElement::isFullscreen() const
3473 { 3473 {
3474 return Fullscreen::isActiveFullScreenElement(*this); 3474 return Fullscreen::isActiveFullScreenElement(*this);
3475 } 3475 }
3476 3476
3477 void HTMLMediaElement::enterFullscreen() 3477 void HTMLMediaElement::enterFullscreen()
3478 { 3478 {
3479 WTF_LOG(Media, "HTMLMediaElement::enterFullscreen"); 3479 WTF_LOG(Media, "HTMLMediaElement::enterFullscreen(%p)", this);
3480 3480
3481 Fullscreen::from(document()).requestFullscreen(*this, Fullscreen::PrefixedVi deoRequest); 3481 Fullscreen::from(document()).requestFullscreen(*this, Fullscreen::PrefixedVi deoRequest);
3482 } 3482 }
3483 3483
3484 void HTMLMediaElement::exitFullscreen() 3484 void HTMLMediaElement::exitFullscreen()
3485 { 3485 {
3486 WTF_LOG(Media, "HTMLMediaElement::exitFullscreen"); 3486 WTF_LOG(Media, "HTMLMediaElement::exitFullscreen(%p)", this);
3487 3487
3488 Fullscreen::from(document()).exitFullscreen(); 3488 Fullscreen::from(document()).exitFullscreen();
3489 } 3489 }
3490 3490
3491 void HTMLMediaElement::didBecomeFullscreenElement() 3491 void HTMLMediaElement::didBecomeFullscreenElement()
3492 { 3492 {
3493 if (hasMediaControls()) 3493 if (hasMediaControls())
3494 mediaControls()->enteredFullscreen(); 3494 mediaControls()->enteredFullscreen();
3495 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isHTMLVideoEl ement()) 3495 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isHTMLVideoEl ement())
3496 document().renderView()->compositor()->setNeedsCompositingUpdate(Composi tingUpdateRebuildTree); 3496 document().renderView()->compositor()->setNeedsCompositingUpdate(Composi tingUpdateRebuildTree);
(...skipping 27 matching lines...) Expand all
3524 return false; 3524 return false;
3525 } 3525 }
3526 3526
3527 bool HTMLMediaElement::closedCaptionsVisible() const 3527 bool HTMLMediaElement::closedCaptionsVisible() const
3528 { 3528 {
3529 return m_closedCaptionsVisible; 3529 return m_closedCaptionsVisible;
3530 } 3530 }
3531 3531
3532 void HTMLMediaElement::updateTextTrackDisplay() 3532 void HTMLMediaElement::updateTextTrackDisplay()
3533 { 3533 {
3534 WTF_LOG(Media, "HTMLMediaElement::updateTextTrackDisplay"); 3534 WTF_LOG(Media, "HTMLMediaElement::updateTextTrackDisplay(%p)", this);
3535 3535
3536 if (!createMediaControls()) 3536 if (!createMediaControls())
3537 return; 3537 return;
3538 3538
3539 mediaControls()->updateTextTrackDisplay(); 3539 mediaControls()->updateTextTrackDisplay();
3540 } 3540 }
3541 3541
3542 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) 3542 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible)
3543 { 3543 {
3544 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%s)", boolString( closedCaptionVisible)); 3544 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b oolString(closedCaptionVisible));
3545 3545
3546 if (!m_player || !hasClosedCaptions()) 3546 if (!m_player || !hasClosedCaptions())
3547 return; 3547 return;
3548 3548
3549 m_closedCaptionsVisible = closedCaptionVisible; 3549 m_closedCaptionsVisible = closedCaptionVisible;
3550 3550
3551 markCaptionAndSubtitleTracksAsUnconfigured(); 3551 markCaptionAndSubtitleTracksAsUnconfigured();
3552 m_processingPreferenceChange = true; 3552 m_processingPreferenceChange = true;
3553 configureTextTracks(); 3553 configureTextTracks();
3554 m_processingPreferenceChange = false; 3554 m_processingPreferenceChange = false;
(...skipping 18 matching lines...) Expand all
3573 bool HTMLMediaElement::isURLAttribute(const Attribute& attribute) const 3573 bool HTMLMediaElement::isURLAttribute(const Attribute& attribute) const
3574 { 3574 {
3575 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute) ; 3575 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute) ;
3576 } 3576 }
3577 3577
3578 void HTMLMediaElement::setShouldDelayLoadEvent(bool shouldDelay) 3578 void HTMLMediaElement::setShouldDelayLoadEvent(bool shouldDelay)
3579 { 3579 {
3580 if (m_shouldDelayLoadEvent == shouldDelay) 3580 if (m_shouldDelayLoadEvent == shouldDelay)
3581 return; 3581 return;
3582 3582
3583 WTF_LOG(Media, "HTMLMediaElement::setShouldDelayLoadEvent(%s)", boolString(s houldDelay)); 3583 WTF_LOG(Media, "HTMLMediaElement::setShouldDelayLoadEvent(%p, %s)", this, bo olString(shouldDelay));
3584 3584
3585 m_shouldDelayLoadEvent = shouldDelay; 3585 m_shouldDelayLoadEvent = shouldDelay;
3586 if (shouldDelay) 3586 if (shouldDelay)
3587 document().incrementLoadEventDelayCount(); 3587 document().incrementLoadEventDelayCount();
3588 else 3588 else
3589 document().decrementLoadEventDelayCount(); 3589 document().decrementLoadEventDelayCount();
3590 } 3590 }
3591 3591
3592 3592
3593 MediaControls* HTMLMediaElement::mediaControls() const 3593 MediaControls* HTMLMediaElement::mediaControls() const
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 if (!createMediaControls()) 3638 if (!createMediaControls())
3639 return; 3639 return;
3640 3640
3641 mediaControls()->reset(); 3641 mediaControls()->reset();
3642 mediaControls()->show(); 3642 mediaControls()->show();
3643 } 3643 }
3644 3644
3645 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu mption) 3645 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu mption)
3646 { 3646 {
3647 ASSERT(m_textTracks); 3647 ASSERT(m_textTracks);
3648 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay"); 3648 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this);
3649 3649
3650 if (m_processingPreferenceChange) 3650 if (m_processingPreferenceChange)
3651 return; 3651 return;
3652 3652
3653 bool haveVisibleTextTrack = false; 3653 bool haveVisibleTextTrack = false;
3654 for (unsigned i = 0; i < m_textTracks->length(); ++i) { 3654 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
3655 if (m_textTracks->item(i)->mode() == TextTrack::showingKeyword()) { 3655 if (m_textTracks->item(i)->mode() == TextTrack::showingKeyword()) {
3656 haveVisibleTextTrack = true; 3656 haveVisibleTextTrack = true;
3657 break; 3657 break;
3658 } 3658 }
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
3970 3970
3971 #if ENABLE(WEB_AUDIO) 3971 #if ENABLE(WEB_AUDIO)
3972 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3972 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3973 { 3973 {
3974 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 3974 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3975 audioSourceProvider()->setClient(0); 3975 audioSourceProvider()->setClient(0);
3976 } 3976 }
3977 #endif 3977 #endif
3978 3978
3979 } 3979 }
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