Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 | 452 |
| 453 removeElementFromDocumentMap(this, &oldDocument); | 453 removeElementFromDocumentMap(this, &oldDocument); |
| 454 addElementToDocumentMap(this, &document()); | 454 addElementToDocumentMap(this, &document()); |
| 455 | 455 |
| 456 // FIXME: This is a temporary fix to prevent this object from causing the | 456 // FIXME: This is a temporary fix to prevent this object from causing the |
| 457 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the | 457 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the |
| 458 // previous document. This restarts the load, as if the src attribute had be en set. | 458 // previous document. This restarts the load, as if the src attribute had be en set. |
| 459 // A proper fix would provide a mechanism to allow this object to refresh | 459 // A proper fix would provide a mechanism to allow this object to refresh |
| 460 // the MediaPlayer's LocalFrame and FrameLoader references on | 460 // the MediaPlayer's LocalFrame and FrameLoader references on |
| 461 // document changes so that playback can be resumed properly. | 461 // document changes so that playback can be resumed properly. |
| 462 clearMediaPlayer(LoadMediaResource); | 462 clearMediaPlayer(LoadMediaResource); |
|
philipj_slow
2016/02/09 07:34:34
As I wrote in some earlier CL, I think this belong
Srirama
2016/02/09 14:50:46
Done.
| |
| 463 scheduleDelayedAction(LoadMediaResource); | 463 invokeLoadAlgorithm(); |
| 464 | 464 |
| 465 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed | 465 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed |
| 466 // and there is no risk of dispatching a load event from within the destruct or. | 466 // and there is no risk of dispatching a load event from within the destruct or. |
| 467 oldDocument.decrementLoadEventDelayCount(); | 467 oldDocument.decrementLoadEventDelayCount(); |
| 468 | 468 |
| 469 ActiveDOMObject::didMoveToNewExecutionContext(&document()); | 469 ActiveDOMObject::didMoveToNewExecutionContext(&document()); |
| 470 HTMLElement::didMoveToNewDocument(oldDocument); | 470 HTMLElement::didMoveToNewDocument(oldDocument); |
| 471 } | 471 } |
| 472 | 472 |
| 473 bool HTMLMediaElement::supportsFocus() const | 473 bool HTMLMediaElement::supportsFocus() const |
| 474 { | 474 { |
| 475 if (ownerDocument()->isMediaDocument()) | 475 if (ownerDocument()->isMediaDocument()) |
| 476 return false; | 476 return false; |
| 477 | 477 |
| 478 // If no controls specified, we should still be able to focus the element if it has tabIndex. | 478 // If no controls specified, we should still be able to focus the element if it has tabIndex. |
| 479 return shouldShowControls() || HTMLElement::supportsFocus(); | 479 return shouldShowControls() || HTMLElement::supportsFocus(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 bool HTMLMediaElement::isMouseFocusable() const | 482 bool HTMLMediaElement::isMouseFocusable() const |
| 483 { | 483 { |
| 484 return false; | 484 return false; |
| 485 } | 485 } |
| 486 | 486 |
| 487 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& oldValue, const AtomicString& value) | 487 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& oldValue, const AtomicString& value) |
| 488 { | 488 { |
| 489 if (name == srcAttr) { | 489 if (name == srcAttr) { |
| 490 // Trigger a reload, as long as the 'src' attribute is present. | 490 // Trigger a reload, as long as the 'src' attribute is present. |
| 491 if (!value.isNull()) { | 491 if (!value.isNull()) { |
| 492 clearMediaPlayer(LoadMediaResource); | 492 clearMediaPlayer(LoadMediaResource); |
|
philipj_slow
2016/02/09 07:34:34
Here too.
Srirama
2016/02/09 14:50:46
Done.
| |
| 493 scheduleDelayedAction(LoadMediaResource); | 493 invokeLoadAlgorithm(); |
| 494 } | 494 } |
| 495 } else if (name == controlsAttr) { | 495 } else if (name == controlsAttr) { |
| 496 configureMediaControls(); | 496 configureMediaControls(); |
| 497 } else if (name == preloadAttr) { | 497 } else if (name == preloadAttr) { |
| 498 setPlayerPreload(); | 498 setPlayerPreload(); |
| 499 } else if (name == disableremoteplaybackAttr) { | 499 } else if (name == disableremoteplaybackAttr) { |
| 500 UseCounter::count(document(), UseCounter::DisableRemotePlaybackAttribute ); | 500 UseCounter::count(document(), UseCounter::DisableRemotePlaybackAttribute ); |
| 501 } else { | 501 } else { |
| 502 HTMLElement::parseAttribute(name, oldValue, value); | 502 HTMLElement::parseAttribute(name, oldValue, value); |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 | 505 |
| 506 void HTMLMediaElement::finishParsingChildren() | 506 void HTMLMediaElement::finishParsingChildren() |
| 507 { | 507 { |
| 508 HTMLElement::finishParsingChildren(); | 508 HTMLElement::finishParsingChildren(); |
| 509 | 509 |
| 510 if (Traversal<HTMLTrackElement>::firstChild(*this)) | 510 if (Traversal<HTMLTrackElement>::firstChild(*this)) |
| 511 scheduleDelayedAction(LoadTextTrackResource); | 511 scheduleTextTrackResourceLoad(); |
| 512 } | 512 } |
| 513 | 513 |
| 514 bool HTMLMediaElement::layoutObjectIsNeeded(const ComputedStyle& style) | 514 bool HTMLMediaElement::layoutObjectIsNeeded(const ComputedStyle& style) |
| 515 { | 515 { |
| 516 return shouldShowControls() && HTMLElement::layoutObjectIsNeeded(style); | 516 return shouldShowControls() && HTMLElement::layoutObjectIsNeeded(style); |
| 517 } | 517 } |
| 518 | 518 |
| 519 LayoutObject* HTMLMediaElement::createLayoutObject(const ComputedStyle&) | 519 LayoutObject* HTMLMediaElement::createLayoutObject(const ComputedStyle&) |
| 520 { | 520 { |
| 521 return new LayoutMedia(this); | 521 return new LayoutMedia(this); |
| 522 } | 522 } |
| 523 | 523 |
| 524 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint) | 524 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint) |
| 525 { | 525 { |
| 526 WTF_LOG(Media, "HTMLMediaElement::insertedInto(%p, %p)", this, insertionPoin t); | 526 WTF_LOG(Media, "HTMLMediaElement::insertedInto(%p, %p)", this, insertionPoin t); |
| 527 | 527 |
| 528 HTMLElement::insertedInto(insertionPoint); | 528 HTMLElement::insertedInto(insertionPoint); |
| 529 if (insertionPoint->inDocument()) { | 529 if (insertionPoint->inDocument()) { |
| 530 if (!getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY) | 530 if (!getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY) |
| 531 scheduleDelayedAction(LoadMediaResource); | 531 invokeLoadAlgorithm(); |
| 532 } | 532 } |
| 533 | 533 |
| 534 return InsertionShouldCallDidNotifySubtreeInsertions; | 534 return InsertionShouldCallDidNotifySubtreeInsertions; |
| 535 } | 535 } |
| 536 | 536 |
| 537 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() | 537 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() |
| 538 { | 538 { |
| 539 configureMediaControls(); | 539 configureMediaControls(); |
| 540 } | 540 } |
| 541 | 541 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 558 if (layoutObject()) | 558 if (layoutObject()) |
| 559 layoutObject()->updateFromElement(); | 559 layoutObject()->updateFromElement(); |
| 560 } | 560 } |
| 561 | 561 |
| 562 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) | 562 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) |
| 563 { | 563 { |
| 564 if (layoutObject()) | 564 if (layoutObject()) |
| 565 layoutObject()->updateFromElement(); | 565 layoutObject()->updateFromElement(); |
| 566 } | 566 } |
| 567 | 567 |
| 568 void HTMLMediaElement::scheduleDelayedAction(DelayedActionType actionType) | 568 void HTMLMediaElement::scheduleTextTrackResourceLoad() |
| 569 { | 569 { |
| 570 WTF_LOG(Media, "HTMLMediaElement::scheduleDelayedAction(%p)", this); | 570 WTF_LOG(Media, "HTMLMediaElement::scheduleTextTrackResourceLoad(%p)", this); |
| 571 | 571 |
| 572 if ((actionType & LoadMediaResource) && !(m_pendingActionFlags & LoadMediaRe source)) { | 572 m_pendingActionFlags |= LoadTextTrackResource; |
| 573 prepareForLoad(); | |
| 574 m_pendingActionFlags |= LoadMediaResource; | |
| 575 } | |
| 576 | |
| 577 if (actionType & LoadTextTrackResource) | |
| 578 m_pendingActionFlags |= LoadTextTrackResource; | |
| 579 | 573 |
| 580 if (!m_loadTimer.isActive()) | 574 if (!m_loadTimer.isActive()) |
| 581 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | 575 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); |
| 582 } | 576 } |
| 583 | 577 |
| 584 void HTMLMediaElement::scheduleNextSourceChild() | 578 void HTMLMediaElement::scheduleNextSourceChild() |
| 585 { | 579 { |
| 586 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala prepareForLoad. | 580 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala prepareForLoad. |
| 587 m_pendingActionFlags |= LoadMediaResource; | 581 m_pendingActionFlags |= LoadMediaResource; |
| 588 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | 582 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 // they don't feel like such to the users and hence we don't want to | 688 // they don't feel like such to the users and hence we don't want to |
| 695 // count them for the purposes of metrics. | 689 // count them for the purposes of metrics. |
| 696 m_autoplayMediaCounted = true; | 690 m_autoplayMediaCounted = true; |
| 697 } | 691 } |
| 698 | 692 |
| 699 prepareForLoad(); | 693 prepareForLoad(); |
| 700 loadInternal(); | 694 loadInternal(); |
| 701 prepareToPlay(); | 695 prepareToPlay(); |
| 702 } | 696 } |
| 703 | 697 |
| 698 void HTMLMediaElement::invokeLoadAlgorithm() | |
| 699 { | |
| 700 WTF_LOG(Media, "HTMLMediaElement::invokeLoadAlgorithm(%p)", this); | |
| 701 | |
| 702 prepareForLoad(); | |
| 703 scheduleNextSourceChild(); | |
|
philipj_slow
2016/02/09 07:34:34
scheduleNextSourceChild() belongs somewhere in the
Srirama
2016/02/09 14:50:46
As you said in the below comment, we can move sche
philipj_slow
2016/02/10 05:02:30
OK, this is interesting. Per spec load() absolutel
Srirama
2016/02/10 11:16:19
ok, i have tried the changes locally and all the l
philipj_slow
2016/02/16 12:19:34
Let's see, m_havePreparedToPlay is used in two way
| |
| 704 } | |
| 705 | |
| 704 void HTMLMediaElement::prepareForLoad() | 706 void HTMLMediaElement::prepareForLoad() |
| 705 { | 707 { |
| 706 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad(%p)", this); | 708 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad(%p)", this); |
| 707 | 709 |
| 708 // Perform the cleanup required for the resource load algorithm to run. | 710 // Perform the cleanup required for the resource load algorithm to run. |
| 709 stopPeriodicTimers(); | 711 stopPeriodicTimers(); |
| 710 m_loadTimer.stop(); | 712 m_loadTimer.stop(); |
| 711 cancelDeferredLoad(); | 713 cancelDeferredLoad(); |
| 712 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. | 714 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. |
| 713 m_pendingActionFlags &= ~LoadMediaResource; | 715 m_pendingActionFlags &= ~LoadMediaResource; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 770 } | 772 } |
| 771 | 773 |
| 772 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute. | 774 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute. |
| 773 setPlaybackRate(defaultPlaybackRate()); | 775 setPlaybackRate(defaultPlaybackRate()); |
| 774 | 776 |
| 775 // 6 - Set the error attribute to null and the autoplaying flag to true. | 777 // 6 - Set the error attribute to null and the autoplaying flag to true. |
| 776 m_error = nullptr; | 778 m_error = nullptr; |
| 777 m_autoplaying = true; | 779 m_autoplaying = true; |
| 778 | 780 |
| 779 // 7 - Invoke the media element's resource selection algorithm. | 781 // 7 - Invoke the media element's resource selection algorithm. |
| 782 invokeResourceSelectionAlgorithm(); | |
| 780 | 783 |
| 781 // 8 - Note: Playback of any previously playing media resource for this elem ent stops. | 784 // 8 - Note: Playback of any previously playing media resource for this elem ent stops. |
| 785 } | |
| 782 | 786 |
| 787 void HTMLMediaElement::invokeResourceSelectionAlgorithm() | |
| 788 { | |
| 789 WTF_LOG(Media, "HTMLMediaElement::invokeResourceSelectionAlgorithm(%p)", thi s); | |
| 783 // The resource selection algorithm | 790 // The resource selection algorithm |
| 784 // 1 - Set the networkState to NETWORK_NO_SOURCE | 791 // 1 - Set the networkState to NETWORK_NO_SOURCE |
| 785 setNetworkState(NETWORK_NO_SOURCE); | 792 setNetworkState(NETWORK_NO_SOURCE); |
| 786 | 793 |
| 787 // 2 - Asynchronously await a stable state. | 794 // 2 - Set the element's show poster flag to true |
| 795 // TODO(srirama.m): Introduce show poster flag and update it as per spec | |
| 788 | 796 |
| 789 m_playedTimeRanges = TimeRanges::create(); | 797 m_playedTimeRanges = TimeRanges::create(); |
| 790 | 798 |
| 791 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above | 799 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above |
| 792 // so they are closer to the relevant spec steps. | 800 // so they are closer to the relevant spec steps. |
| 793 m_lastSeekTime = 0; | 801 m_lastSeekTime = 0; |
| 794 m_duration = std::numeric_limits<double>::quiet_NaN(); | 802 m_duration = std::numeric_limits<double>::quiet_NaN(); |
| 795 | 803 |
| 796 // The spec doesn't say to block the load event until we actually run the as ynchronous section | 804 // 3 - Set the media element's delaying-the-load-event flag to true (this de lays the load event) |
| 797 // algorithm, but do it now because we won't start that until after the time r fires and the | |
| 798 // event may have already fired by then. | |
| 799 setShouldDelayLoadEvent(true); | 805 setShouldDelayLoadEvent(true); |
| 800 if (mediaControls()) | 806 if (mediaControls()) |
| 801 mediaControls()->reset(); | 807 mediaControls()->reset(); |
| 808 | |
| 809 // 4 - Await a stable state, allowing the task that invoked this algorithm t o continue | |
| 810 // TODO(srirama.m): Schedule an async continuation of this algorithm as per the spec | |
|
philipj_slow
2016/02/09 07:34:34
How does this currently work? I think it's the ear
Srirama
2016/02/09 14:50:46
We can move it expect for the problem mentioned in
| |
| 802 } | 811 } |
| 803 | 812 |
| 804 void HTMLMediaElement::loadInternal() | 813 void HTMLMediaElement::loadInternal() |
| 805 { | 814 { |
| 806 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the | 815 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the |
| 807 // disabled state when the element's resource selection algorithm last start ed". | 816 // disabled state when the element's resource selection algorithm last start ed". |
| 808 m_textTracksWhenResourceSelectionBegan.clear(); | 817 m_textTracksWhenResourceSelectionBegan.clear(); |
| 809 if (m_textTracks) { | 818 if (m_textTracks) { |
| 810 for (unsigned i = 0; i < m_textTracks->length(); ++i) { | 819 for (unsigned i = 0; i < m_textTracks->length(); ++i) { |
| 811 TextTrack* track = m_textTracks->anonymousIndexedGetter(i); | 820 TextTrack* track = m_textTracks->anonymousIndexedGetter(i); |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1958 { | 1967 { |
| 1959 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); | 1968 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); |
| 1960 | 1969 |
| 1961 // Always return the buffering strategy to normal when not paused, | 1970 // Always return the buffering strategy to normal when not paused, |
| 1962 // regardless of the cause. (In contrast with aggressive buffering which is | 1971 // regardless of the cause. (In contrast with aggressive buffering which is |
| 1963 // only enabled by pause(), not pauseInternal().) | 1972 // only enabled by pause(), not pauseInternal().) |
| 1964 if (webMediaPlayer()) | 1973 if (webMediaPlayer()) |
| 1965 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal); | 1974 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal); |
| 1966 | 1975 |
| 1967 // 4.8.10.9. Playing the media resource | 1976 // 4.8.10.9. Playing the media resource |
| 1968 if (m_networkState == NETWORK_EMPTY) | 1977 if (m_networkState == NETWORK_EMPTY) { |
| 1969 scheduleDelayedAction(LoadMediaResource); | 1978 invokeResourceSelectionAlgorithm(); |
| 1979 scheduleNextSourceChild(); | |
|
philipj_slow
2016/02/09 07:34:34
Try to get rid of scheduleNextSourceChild() here a
Srirama
2016/02/09 14:50:46
Probably this is also linked to the above issue.
| |
| 1980 } | |
| 1970 | 1981 |
| 1971 // Generally "ended" and "looping" are exclusive. Here, the loop attribute | 1982 // Generally "ended" and "looping" are exclusive. Here, the loop attribute |
| 1972 // is ignored to seek back to start in case loop was set after playback | 1983 // is ignored to seek back to start in case loop was set after playback |
| 1973 // ended. See http://crbug.com/364442 | 1984 // ended. See http://crbug.com/364442 |
| 1974 if (endedPlayback(LoopCondition::Ignored)) | 1985 if (endedPlayback(LoopCondition::Ignored)) |
| 1975 seek(0); | 1986 seek(0); |
| 1976 | 1987 |
| 1977 if (m_paused) { | 1988 if (m_paused) { |
| 1978 m_paused = false; | 1989 m_paused = false; |
| 1979 invalidateCachedTime(); | 1990 invalidateCachedTime(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2018 if (webMediaPlayer() && UserGestureIndicator::processingUserGesture()) | 2029 if (webMediaPlayer() && UserGestureIndicator::processingUserGesture()) |
| 2019 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Aggressive); | 2030 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Aggressive); |
| 2020 | 2031 |
| 2021 pauseInternal(); | 2032 pauseInternal(); |
| 2022 } | 2033 } |
| 2023 | 2034 |
| 2024 void HTMLMediaElement::pauseInternal() | 2035 void HTMLMediaElement::pauseInternal() |
| 2025 { | 2036 { |
| 2026 WTF_LOG(Media, "HTMLMediaElement::pauseInternal(%p)", this); | 2037 WTF_LOG(Media, "HTMLMediaElement::pauseInternal(%p)", this); |
| 2027 | 2038 |
| 2028 if (m_networkState == NETWORK_EMPTY) | 2039 if (m_networkState == NETWORK_EMPTY) { |
| 2029 scheduleDelayedAction(LoadMediaResource); | 2040 invokeResourceSelectionAlgorithm(); |
| 2041 scheduleNextSourceChild(); | |
| 2042 } | |
| 2030 | 2043 |
| 2031 m_autoplayHelper.pauseMethodCalled(); | 2044 m_autoplayHelper.pauseMethodCalled(); |
| 2032 | 2045 |
| 2033 m_autoplaying = false; | 2046 m_autoplaying = false; |
| 2034 | 2047 |
| 2035 if (!m_paused) { | 2048 if (!m_paused) { |
| 2036 recordMetricsIfPausing(); | 2049 recordMetricsIfPausing(); |
| 2037 | 2050 |
| 2038 m_paused = true; | 2051 m_paused = true; |
| 2039 scheduleTimeupdateEvent(false); | 2052 scheduleTimeupdateEvent(false); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2332 // 5. Populate the new text track's list of cues with the cues parsed so far , folllowing the guidelines for exposing | 2345 // 5. Populate the new text track's list of cues with the cues parsed so far , folllowing the guidelines for exposing |
| 2333 // cues, and begin updating it dynamically as necessary. | 2346 // cues, and begin updating it dynamically as necessary. |
| 2334 // - Thess are all done by the media engine. | 2347 // - Thess are all done by the media engine. |
| 2335 | 2348 |
| 2336 // 6. Set the new text track's readiness state to loaded. | 2349 // 6. Set the new text track's readiness state to loaded. |
| 2337 textTrack->setReadinessState(TextTrack::Loaded); | 2350 textTrack->setReadinessState(TextTrack::Loaded); |
| 2338 | 2351 |
| 2339 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of | 2352 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of |
| 2340 // the relevant specification for the data. | 2353 // the relevant specification for the data. |
| 2341 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection () | 2354 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection () |
| 2342 scheduleDelayedAction(LoadTextTrackResource); | 2355 scheduleTextTrackResourceLoad(); |
| 2343 | 2356 |
| 2344 // 8. Add the new text track to the media element's list of text tracks. | 2357 // 8. Add the new text track to the media element's list of text tracks. |
| 2345 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent | 2358 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent |
| 2346 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's | 2359 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's |
| 2347 // textTracks attribute's TextTrackList object. | 2360 // textTracks attribute's TextTrackList object. |
| 2348 addTextTrack(textTrack); | 2361 addTextTrack(textTrack); |
| 2349 } | 2362 } |
| 2350 | 2363 |
| 2351 void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack) | 2364 void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack) |
| 2352 { | 2365 { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2452 // media element's list of text tracks ... [continues in TextTrackList::appe nd] | 2465 // media element's list of text tracks ... [continues in TextTrackList::appe nd] |
| 2453 TextTrack* textTrack = trackElement->track(); | 2466 TextTrack* textTrack = trackElement->track(); |
| 2454 if (!textTrack) | 2467 if (!textTrack) |
| 2455 return; | 2468 return; |
| 2456 | 2469 |
| 2457 addTextTrack(textTrack); | 2470 addTextTrack(textTrack); |
| 2458 | 2471 |
| 2459 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks | 2472 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks |
| 2460 // in the markup have been added. | 2473 // in the markup have been added. |
| 2461 if (isFinishedParsingChildren()) | 2474 if (isFinishedParsingChildren()) |
| 2462 scheduleDelayedAction(LoadTextTrackResource); | 2475 scheduleTextTrackResourceLoad(); |
| 2463 } | 2476 } |
| 2464 | 2477 |
| 2465 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) | 2478 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) |
| 2466 { | 2479 { |
| 2467 #if !LOG_DISABLED | 2480 #if !LOG_DISABLED |
| 2468 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); | 2481 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); |
| 2469 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); | 2482 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); |
| 2470 #endif | 2483 #endif |
| 2471 | 2484 |
| 2472 TextTrack* textTrack = trackElement->track(); | 2485 TextTrack* textTrack = trackElement->track(); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2629 #endif | 2642 #endif |
| 2630 | 2643 |
| 2631 // We should only consider a <source> element when there is not src attribut e at all. | 2644 // We should only consider a <source> element when there is not src attribut e at all. |
| 2632 if (fastHasAttribute(srcAttr)) | 2645 if (fastHasAttribute(srcAttr)) |
| 2633 return; | 2646 return; |
| 2634 | 2647 |
| 2635 // 4.8.8 - If a source element is inserted as a child of a media element tha t has no src | 2648 // 4.8.8 - If a source element is inserted as a child of a media element tha t has no src |
| 2636 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag ent must invoke | 2649 // attribute and whose networkState has the value NETWORK_EMPTY, the user ag ent must invoke |
| 2637 // the media element's resource selection algorithm. | 2650 // the media element's resource selection algorithm. |
| 2638 if (networkState() == HTMLMediaElement::NETWORK_EMPTY) { | 2651 if (networkState() == HTMLMediaElement::NETWORK_EMPTY) { |
| 2639 scheduleDelayedAction(LoadMediaResource); | 2652 invokeResourceSelectionAlgorithm(); |
| 2653 scheduleNextSourceChild(); | |
| 2640 m_nextChildNodeToConsider = source; | 2654 m_nextChildNodeToConsider = source; |
| 2641 return; | 2655 return; |
| 2642 } | 2656 } |
| 2643 | 2657 |
| 2644 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) { | 2658 if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) { |
| 2645 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - <source> inserted immediately after current source", this); | 2659 WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - <source> inserted immediately after current source", this); |
| 2646 m_nextChildNodeToConsider = source; | 2660 m_nextChildNodeToConsider = source; |
| 2647 return; | 2661 return; |
| 2648 } | 2662 } |
| 2649 | 2663 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3018 void HTMLMediaElement::stop() | 3032 void HTMLMediaElement::stop() |
| 3019 { | 3033 { |
| 3020 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); | 3034 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); |
| 3021 | 3035 |
| 3022 recordMetricsIfPausing(); | 3036 recordMetricsIfPausing(); |
| 3023 | 3037 |
| 3024 // Close the async event queue so that no events are enqueued. | 3038 // Close the async event queue so that no events are enqueued. |
| 3025 cancelPendingEventsAndCallbacks(); | 3039 cancelPendingEventsAndCallbacks(); |
| 3026 m_asyncEventQueue->close(); | 3040 m_asyncEventQueue->close(); |
| 3027 | 3041 |
| 3028 // Stop the playback without generating events | 3042 // Clear everything in the Media Element |
| 3029 clearMediaPlayer(-1); | 3043 clearMediaPlayer(-1); |
| 3030 m_readyState = HAVE_NOTHING; | 3044 m_readyState = HAVE_NOTHING; |
| 3031 m_readyStateMaximum = HAVE_NOTHING; | 3045 m_readyStateMaximum = HAVE_NOTHING; |
| 3032 setNetworkState(NETWORK_EMPTY); | 3046 setNetworkState(NETWORK_EMPTY); |
| 3033 setShouldDelayLoadEvent(false); | 3047 setShouldDelayLoadEvent(false); |
| 3034 m_currentSourceNode = nullptr; | 3048 m_currentSourceNode = nullptr; |
| 3035 invalidateCachedTime(); | 3049 invalidateCachedTime(); |
| 3036 cueTimeline().updateActiveCues(0); | 3050 cueTimeline().updateActiveCues(0); |
| 3037 m_playing = false; | 3051 m_playing = false; |
| 3038 m_paused = true; | 3052 m_paused = true; |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3384 } | 3398 } |
| 3385 | 3399 |
| 3386 void* HTMLMediaElement::preDispatchEventHandler(Event* event) | 3400 void* HTMLMediaElement::preDispatchEventHandler(Event* event) |
| 3387 { | 3401 { |
| 3388 if (event && event->type() == EventTypeNames::webkitfullscreenchange) | 3402 if (event && event->type() == EventTypeNames::webkitfullscreenchange) |
| 3389 configureMediaControls(); | 3403 configureMediaControls(); |
| 3390 | 3404 |
| 3391 return nullptr; | 3405 return nullptr; |
| 3392 } | 3406 } |
| 3393 | 3407 |
| 3394 // TODO(srirama.m): Refactor this and clearMediaPlayer to the extent possible. | 3408 // TODO(srirama.m): Merge it to resetMediaElement if possible and remove it. |
| 3395 void HTMLMediaElement::resetMediaPlayerAndMediaSource() | 3409 void HTMLMediaElement::resetMediaPlayerAndMediaSource() |
| 3396 { | 3410 { |
| 3397 closeMediaSource(); | 3411 closeMediaSource(); |
| 3398 | 3412 |
| 3399 { | 3413 { |
| 3400 AudioSourceProviderClientLockScope scope(*this); | 3414 AudioSourceProviderClientLockScope scope(*this); |
| 3401 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 3415 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
| 3402 } | 3416 } |
| 3403 | 3417 |
| 3404 // We haven't yet found out if any remote routes are available. | 3418 // We haven't yet found out if any remote routes are available. |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3624 { | 3638 { |
| 3625 visitor->trace(m_client); | 3639 visitor->trace(m_client); |
| 3626 } | 3640 } |
| 3627 | 3641 |
| 3628 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3642 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
| 3629 { | 3643 { |
| 3630 visitor->trace(m_client); | 3644 visitor->trace(m_client); |
| 3631 } | 3645 } |
| 3632 | 3646 |
| 3633 } // namespace blink | 3647 } // namespace blink |
| OLD | NEW |