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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 , m_textTracks(nullptr) | 426 , m_textTracks(nullptr) |
| 427 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolvePlayPromises)) | 427 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolvePlayPromises)) |
| 428 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectPlayPromises)) | 428 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectPlayPromises)) |
| 429 , m_audioSourceNode(nullptr) | 429 , m_audioSourceNode(nullptr) |
| 430 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) | 430 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) |
| 431 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et())) | 431 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et())) |
| 432 , m_remotePlaybackClient(nullptr) | 432 , m_remotePlaybackClient(nullptr) |
| 433 { | 433 { |
| 434 ThreadState::current()->registerPreFinalizer(this); | 434 ThreadState::current()->registerPreFinalizer(this); |
| 435 | 435 |
| 436 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this); | 436 DVLOG(1) << "HTMLMediaElement::HTMLMediaElement(" << this << ")"; |
|
Srirama
2016/05/17 13:27:37
Should we simplify it by using ":" instead of brac
fs
2016/05/17 13:59:07
Maybe just have "HTMLMediaElement(" << this << ")"
| |
| 437 | 437 |
| 438 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) | 438 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) |
| 439 m_userGestureRequiredForPlay = true; | 439 m_userGestureRequiredForPlay = true; |
| 440 | 440 |
| 441 setHasCustomStyleCallbacks(); | 441 setHasCustomStyleCallbacks(); |
| 442 addElementToDocumentMap(this, &document); | 442 addElementToDocumentMap(this, &document); |
| 443 | 443 |
| 444 UseCounter::count(document, UseCounter::HTMLMediaElement); | 444 UseCounter::count(document, UseCounter::HTMLMediaElement); |
| 445 } | 445 } |
| 446 | 446 |
| 447 HTMLMediaElement::~HTMLMediaElement() | 447 HTMLMediaElement::~HTMLMediaElement() |
| 448 { | 448 { |
| 449 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement(%p)", this); | 449 DVLOG(1) << "HTMLMediaElement::~HTMLMediaElement(" << this << ")"; |
| 450 | 450 |
| 451 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). | 451 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). |
| 452 // Since AudioNode::dispose() is guaranteed to be always called before | 452 // Since AudioNode::dispose() is guaranteed to be always called before |
| 453 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared | 453 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared |
| 454 // even if the AudioNode and the HTMLMediaElement die together. | 454 // even if the AudioNode and the HTMLMediaElement die together. |
| 455 ASSERT(!m_audioSourceNode); | 455 ASSERT(!m_audioSourceNode); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void HTMLMediaElement::dispose() | 458 void HTMLMediaElement::dispose() |
| 459 { | 459 { |
| 460 closeMediaSource(); | 460 closeMediaSource(); |
| 461 | 461 |
| 462 // Destroying the player may cause a resource load to be canceled, | 462 // Destroying the player may cause a resource load to be canceled, |
| 463 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being | 463 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being |
| 464 // called via ResourceFetch::didLoadResource(), then | 464 // called via ResourceFetch::didLoadResource(), then |
| 465 // FrameLoader::checkCompleted(). But it's guaranteed that the load event | 465 // FrameLoader::checkCompleted(). But it's guaranteed that the load event |
| 466 // doesn't get dispatched during the object destruction. | 466 // doesn't get dispatched during the object destruction. |
| 467 // See Document::isDelayingLoadEvent(). | 467 // See Document::isDelayingLoadEvent(). |
| 468 // Also see http://crbug.com/275223 for more details. | 468 // Also see http://crbug.com/275223 for more details. |
| 469 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 469 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
| 470 } | 470 } |
| 471 | 471 |
| 472 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) | 472 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) |
| 473 { | 473 { |
| 474 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this); | 474 DVLOG(1) << "HTMLMediaElement::didMoveToNewDocument(" << this << ")"; |
| 475 | 475 |
| 476 if (m_shouldDelayLoadEvent) { | 476 if (m_shouldDelayLoadEvent) { |
| 477 document().incrementLoadEventDelayCount(); | 477 document().incrementLoadEventDelayCount(); |
| 478 // Note: Keeping the load event delay count increment on oldDocument tha t was added | 478 // Note: Keeping the load event delay count increment on oldDocument tha t was added |
| 479 // when m_shouldDelayLoadEvent was set so that destruction of m_webMedia Player can not | 479 // when m_shouldDelayLoadEvent was set so that destruction of m_webMedia Player can not |
| 480 // cause load event dispatching in oldDocument. | 480 // cause load event dispatching in oldDocument. |
| 481 } else { | 481 } else { |
| 482 // Incrementing the load event delay count so that destruction of m_webM ediaPlayer can not | 482 // Incrementing the load event delay count so that destruction of m_webM ediaPlayer can not |
| 483 // cause load event dispatching in oldDocument. | 483 // cause load event dispatching in oldDocument. |
| 484 oldDocument.incrementLoadEventDelayCount(); | 484 oldDocument.incrementLoadEventDelayCount(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 return shouldShowControls() && HTMLElement::layoutObjectIsNeeded(style); | 551 return shouldShowControls() && HTMLElement::layoutObjectIsNeeded(style); |
| 552 } | 552 } |
| 553 | 553 |
| 554 LayoutObject* HTMLMediaElement::createLayoutObject(const ComputedStyle&) | 554 LayoutObject* HTMLMediaElement::createLayoutObject(const ComputedStyle&) |
| 555 { | 555 { |
| 556 return new LayoutMedia(this); | 556 return new LayoutMedia(this); |
| 557 } | 557 } |
| 558 | 558 |
| 559 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint) | 559 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint) |
| 560 { | 560 { |
| 561 WTF_LOG(Media, "HTMLMediaElement::insertedInto(%p, %p)", this, insertionPoin t); | 561 DVLOG(1) << "HTMLMediaElement::insertedInto(" << this << ", " << insertionPo int << ")"; |
| 562 | 562 |
| 563 HTMLElement::insertedInto(insertionPoint); | 563 HTMLElement::insertedInto(insertionPoint); |
| 564 if (insertionPoint->inShadowIncludingDocument()) { | 564 if (insertionPoint->inShadowIncludingDocument()) { |
| 565 UseCounter::count(document(), UseCounter::HTMLMediaElementInDocument); | 565 UseCounter::count(document(), UseCounter::HTMLMediaElementInDocument); |
| 566 if ((!getAttribute(srcAttr).isEmpty() || m_srcObject) && m_networkState == NETWORK_EMPTY) { | 566 if ((!getAttribute(srcAttr).isEmpty() || m_srcObject) && m_networkState == NETWORK_EMPTY) { |
| 567 m_ignorePreloadNone = false; | 567 m_ignorePreloadNone = false; |
| 568 invokeLoadAlgorithm(); | 568 invokeLoadAlgorithm(); |
| 569 } | 569 } |
| 570 } | 570 } |
| 571 | 571 |
| 572 return InsertionShouldCallDidNotifySubtreeInsertions; | 572 return InsertionShouldCallDidNotifySubtreeInsertions; |
| 573 } | 573 } |
| 574 | 574 |
| 575 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() | 575 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() |
| 576 { | 576 { |
| 577 configureMediaControls(); | 577 configureMediaControls(); |
| 578 } | 578 } |
| 579 | 579 |
| 580 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) | 580 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) |
| 581 { | 581 { |
| 582 WTF_LOG(Media, "HTMLMediaElement::removedFrom(%p, %p)", this, insertionPoint ); | 582 DVLOG(1) << "HTMLMediaElement::removedFrom(" << this << ", " << insertionPoi nt << ")"; |
| 583 | 583 |
| 584 HTMLElement::removedFrom(insertionPoint); | 584 HTMLElement::removedFrom(insertionPoint); |
| 585 if (insertionPoint->inActiveDocument()) { | 585 if (insertionPoint->inActiveDocument()) { |
| 586 configureMediaControls(); | 586 configureMediaControls(); |
| 587 if (m_networkState > NETWORK_EMPTY) | 587 if (m_networkState > NETWORK_EMPTY) |
| 588 pauseInternal(); | 588 pauseInternal(); |
| 589 } | 589 } |
| 590 } | 590 } |
| 591 | 591 |
| 592 void HTMLMediaElement::attach(const AttachContext& context) | 592 void HTMLMediaElement::attach(const AttachContext& context) |
| 593 { | 593 { |
| 594 HTMLElement::attach(context); | 594 HTMLElement::attach(context); |
| 595 | 595 |
| 596 if (layoutObject()) | 596 if (layoutObject()) |
| 597 layoutObject()->updateFromElement(); | 597 layoutObject()->updateFromElement(); |
| 598 } | 598 } |
| 599 | 599 |
| 600 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) | 600 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) |
| 601 { | 601 { |
| 602 if (layoutObject()) | 602 if (layoutObject()) |
| 603 layoutObject()->updateFromElement(); | 603 layoutObject()->updateFromElement(); |
| 604 } | 604 } |
| 605 | 605 |
| 606 void HTMLMediaElement::scheduleTextTrackResourceLoad() | 606 void HTMLMediaElement::scheduleTextTrackResourceLoad() |
| 607 { | 607 { |
| 608 WTF_LOG(Media, "HTMLMediaElement::scheduleTextTrackResourceLoad(%p)", this); | 608 DVLOG(1) << "HTMLMediaElement::scheduleTextTrackResourceLoad(" << this << ") "; |
| 609 | 609 |
| 610 m_pendingActionFlags |= LoadTextTrackResource; | 610 m_pendingActionFlags |= LoadTextTrackResource; |
| 611 | 611 |
| 612 if (!m_loadTimer.isActive()) | 612 if (!m_loadTimer.isActive()) |
| 613 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | 613 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); |
| 614 } | 614 } |
| 615 | 615 |
| 616 void HTMLMediaElement::scheduleNextSourceChild() | 616 void HTMLMediaElement::scheduleNextSourceChild() |
| 617 { | 617 { |
| 618 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala invokeLoadAlgorithm. | 618 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala invokeLoadAlgorithm. |
| 619 m_pendingActionFlags |= LoadMediaResource; | 619 m_pendingActionFlags |= LoadMediaResource; |
| 620 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | 620 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); |
| 621 } | 621 } |
| 622 | 622 |
| 623 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) | 623 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) |
| 624 { | 624 { |
| 625 scheduleEvent(Event::createCancelable(eventName)); | 625 scheduleEvent(Event::createCancelable(eventName)); |
| 626 } | 626 } |
| 627 | 627 |
| 628 void HTMLMediaElement::scheduleEvent(Event* event) | 628 void HTMLMediaElement::scheduleEvent(Event* event) |
| 629 { | 629 { |
| 630 #if LOG_MEDIA_EVENTS | 630 #if LOG_MEDIA_EVENTS |
| 631 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent(%p) - scheduling '%s'", this , event->type().ascii().data()); | 631 DVLOG(1) << "HTMLMediaElement::scheduleEvent(" << this << ")" << " - schedul ing '" << event->type().ascii().data() << "'"; |
| 632 #endif | 632 #endif |
| 633 m_asyncEventQueue->enqueueEvent(event); | 633 m_asyncEventQueue->enqueueEvent(event); |
| 634 } | 634 } |
| 635 | 635 |
| 636 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) | 636 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) |
| 637 { | 637 { |
| 638 if (m_pendingActionFlags & LoadTextTrackResource) | 638 if (m_pendingActionFlags & LoadTextTrackResource) |
| 639 honorUserPreferencesForAutomaticTextTrackSelection(); | 639 honorUserPreferencesForAutomaticTextTrackSelection(); |
| 640 | 640 |
| 641 if (m_pendingActionFlags & LoadMediaResource) { | 641 if (m_pendingActionFlags & LoadMediaResource) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 680 canPlay = emptyString(); | 680 canPlay = emptyString(); |
| 681 break; | 681 break; |
| 682 case WebMimeRegistry::MayBeSupported: | 682 case WebMimeRegistry::MayBeSupported: |
| 683 canPlay = "maybe"; | 683 canPlay = "maybe"; |
| 684 break; | 684 break; |
| 685 case WebMimeRegistry::IsSupported: | 685 case WebMimeRegistry::IsSupported: |
| 686 canPlay = "probably"; | 686 canPlay = "probably"; |
| 687 break; | 687 break; |
| 688 } | 688 } |
| 689 | 689 |
| 690 WTF_LOG(Media, "HTMLMediaElement::canPlayType(%p, %s) -> %s", this, mimeType .utf8().data(), canPlay.utf8().data()); | 690 DVLOG(1) << "HTMLMediaElement::canPlayType(" << this << ", " << mimeType.utf 8().data() << ") -> " << canPlay.utf8().data(); |
| 691 | 691 |
| 692 return canPlay; | 692 return canPlay; |
| 693 } | 693 } |
| 694 | 694 |
| 695 void HTMLMediaElement::load() | 695 void HTMLMediaElement::load() |
| 696 { | 696 { |
| 697 WTF_LOG(Media, "HTMLMediaElement::load(%p)", this); | 697 WTF_LOG(Media, "HTMLMediaElement::load(%p)", this); |
| 698 | 698 |
| 699 m_autoplayHelper->loadMethodCalled(); | 699 m_autoplayHelper->loadMethodCalled(); |
| 700 | 700 |
| 701 m_ignorePreloadNone = true; | 701 m_ignorePreloadNone = true; |
| 702 invokeLoadAlgorithm(); | 702 invokeLoadAlgorithm(); |
| 703 } | 703 } |
| 704 | 704 |
| 705 // TODO(srirama.m): Currently m_ignorePreloadNone is reset before calling | 705 // TODO(srirama.m): Currently m_ignorePreloadNone is reset before calling |
| 706 // invokeLoadAlgorithm() in all places except load(). Move it inside here | 706 // invokeLoadAlgorithm() in all places except load(). Move it inside here |
| 707 // once microtask is implemented for "Await a stable state" step | 707 // once microtask is implemented for "Await a stable state" step |
| 708 // in resource selection algorithm. | 708 // in resource selection algorithm. |
| 709 void HTMLMediaElement::invokeLoadAlgorithm() | 709 void HTMLMediaElement::invokeLoadAlgorithm() |
| 710 { | 710 { |
| 711 WTF_LOG(Media, "HTMLMediaElement::invokeLoadAlgorithm(%p)", this); | 711 DVLOG(1) << "HTMLMediaElement::invokeLoadAlgorithm(" << this << ")"; |
| 712 | 712 |
| 713 // Perform the cleanup required for the resource load algorithm to run. | 713 // Perform the cleanup required for the resource load algorithm to run. |
| 714 stopPeriodicTimers(); | 714 stopPeriodicTimers(); |
| 715 m_loadTimer.stop(); | 715 m_loadTimer.stop(); |
| 716 cancelDeferredLoad(); | 716 cancelDeferredLoad(); |
| 717 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. | 717 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. |
| 718 m_pendingActionFlags &= ~LoadMediaResource; | 718 m_pendingActionFlags &= ~LoadMediaResource; |
| 719 m_sentEndEvent = false; | 719 m_sentEndEvent = false; |
| 720 m_sentStalledEvent = false; | 720 m_sentStalledEvent = false; |
| 721 m_haveFiredLoadedData = false; | 721 m_haveFiredLoadedData = false; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 m_autoplaying = true; | 789 m_autoplaying = true; |
| 790 | 790 |
| 791 // 7 - Invoke the media element's resource selection algorithm. | 791 // 7 - Invoke the media element's resource selection algorithm. |
| 792 invokeResourceSelectionAlgorithm(); | 792 invokeResourceSelectionAlgorithm(); |
| 793 | 793 |
| 794 // 8 - Note: Playback of any previously playing media resource for this elem ent stops. | 794 // 8 - Note: Playback of any previously playing media resource for this elem ent stops. |
| 795 } | 795 } |
| 796 | 796 |
| 797 void HTMLMediaElement::invokeResourceSelectionAlgorithm() | 797 void HTMLMediaElement::invokeResourceSelectionAlgorithm() |
| 798 { | 798 { |
| 799 WTF_LOG(Media, "HTMLMediaElement::invokeResourceSelectionAlgorithm(%p)", thi s); | 799 DVLOG(1) << "HTMLMediaElement::invokeResourceSelectionAlgorithm(" << this << ")"; |
| 800 // The resource selection algorithm | 800 // The resource selection algorithm |
| 801 // 1 - Set the networkState to NETWORK_NO_SOURCE | 801 // 1 - Set the networkState to NETWORK_NO_SOURCE |
| 802 setNetworkState(NETWORK_NO_SOURCE); | 802 setNetworkState(NETWORK_NO_SOURCE); |
| 803 | 803 |
| 804 // 2 - Set the element's show poster flag to true | 804 // 2 - Set the element's show poster flag to true |
| 805 // TODO(srirama.m): Introduce show poster flag and update it as per spec | 805 // TODO(srirama.m): Introduce show poster flag and update it as per spec |
| 806 | 806 |
| 807 m_playedTimeRanges = TimeRanges::create(); | 807 m_playedTimeRanges = TimeRanges::create(); |
| 808 | 808 |
| 809 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above | 809 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 833 if (track->mode() != TextTrack::disabledKeyword()) | 833 if (track->mode() != TextTrack::disabledKeyword()) |
| 834 m_textTracksWhenResourceSelectionBegan.append(track); | 834 m_textTracksWhenResourceSelectionBegan.append(track); |
| 835 } | 835 } |
| 836 } | 836 } |
| 837 | 837 |
| 838 selectMediaResource(); | 838 selectMediaResource(); |
| 839 } | 839 } |
| 840 | 840 |
| 841 void HTMLMediaElement::selectMediaResource() | 841 void HTMLMediaElement::selectMediaResource() |
| 842 { | 842 { |
| 843 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p)", this); | 843 DVLOG(1) << "HTMLMediaElement::selectMediaResource(" << this << ")"; |
| 844 | 844 |
| 845 enum Mode { Object, Attribute, Children, Nothing }; | 845 enum Mode { Object, Attribute, Children, Nothing }; |
| 846 Mode mode = Nothing; | 846 Mode mode = Nothing; |
| 847 | 847 |
| 848 // 6 - If the media element has an assigned media provider object, then let | 848 // 6 - If the media element has an assigned media provider object, then let |
| 849 // mode be object. | 849 // mode be object. |
| 850 if (m_srcObject) { | 850 if (m_srcObject) { |
| 851 mode = Object; | 851 mode = Object; |
| 852 } else if (fastHasAttribute(srcAttr)) { | 852 } else if (fastHasAttribute(srcAttr)) { |
| 853 // Otherwise, if the media element has no assigned media provider object | 853 // Otherwise, if the media element has no assigned media provider object |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1281 if (m_progressEventTimer.isActive()) | 1281 if (m_progressEventTimer.isActive()) |
| 1282 return; | 1282 return; |
| 1283 | 1283 |
| 1284 m_previousProgressTime = WTF::currentTime(); | 1284 m_previousProgressTime = WTF::currentTime(); |
| 1285 // 350ms is not magic, it is in the spec! | 1285 // 350ms is not magic, it is in the spec! |
| 1286 m_progressEventTimer.startRepeating(0.350, BLINK_FROM_HERE); | 1286 m_progressEventTimer.startRepeating(0.350, BLINK_FROM_HERE); |
| 1287 } | 1287 } |
| 1288 | 1288 |
| 1289 void HTMLMediaElement::waitForSourceChange() | 1289 void HTMLMediaElement::waitForSourceChange() |
| 1290 { | 1290 { |
| 1291 WTF_LOG(Media, "HTMLMediaElement::waitForSourceChange(%p)", this); | 1291 DVLOG(1) << "HTMLMediaElement::waitForSourceChange(" << this << ")"; |
| 1292 | 1292 |
| 1293 stopPeriodicTimers(); | 1293 stopPeriodicTimers(); |
| 1294 m_loadState = WaitingForSource; | 1294 m_loadState = WaitingForSource; |
| 1295 | 1295 |
| 1296 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N O_SOURCE value | 1296 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N O_SOURCE value |
| 1297 setNetworkState(NETWORK_NO_SOURCE); | 1297 setNetworkState(NETWORK_NO_SOURCE); |
| 1298 | 1298 |
| 1299 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop s delaying the load event. | 1299 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop s delaying the load event. |
| 1300 setShouldDelayLoadEvent(false); | 1300 setShouldDelayLoadEvent(false); |
| 1301 | 1301 |
| 1302 updateDisplayState(); | 1302 updateDisplayState(); |
| 1303 | 1303 |
| 1304 if (layoutObject()) | 1304 if (layoutObject()) |
| 1305 layoutObject()->updateFromElement(); | 1305 layoutObject()->updateFromElement(); |
| 1306 } | 1306 } |
| 1307 | 1307 |
| 1308 void HTMLMediaElement::noneSupported() | 1308 void HTMLMediaElement::noneSupported() |
| 1309 { | 1309 { |
| 1310 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this); | 1310 DVLOG(1) << "HTMLMediaElement::noneSupported(" << this << ")"; |
| 1311 | 1311 |
| 1312 stopPeriodicTimers(); | 1312 stopPeriodicTimers(); |
| 1313 m_loadState = WaitingForSource; | 1313 m_loadState = WaitingForSource; |
| 1314 m_currentSourceNode = nullptr; | 1314 m_currentSourceNode = nullptr; |
| 1315 | 1315 |
| 1316 // 4.8.13.5 | 1316 // 4.8.13.5 |
| 1317 // The dedicated media source failure steps are the following steps: | 1317 // The dedicated media source failure steps are the following steps: |
| 1318 | 1318 |
| 1319 // 1 - Set the error attribute to a new MediaError object whose code attribu te is set to | 1319 // 1 - Set the error attribute to a new MediaError object whose code attribu te is set to |
| 1320 // MEDIA_ERR_SRC_NOT_SUPPORTED. | 1320 // MEDIA_ERR_SRC_NOT_SUPPORTED. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1365 | 1365 |
| 1366 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. | 1366 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. |
| 1367 setShouldDelayLoadEvent(false); | 1367 setShouldDelayLoadEvent(false); |
| 1368 | 1368 |
| 1369 // 6 - Abort the overall resource selection algorithm. | 1369 // 6 - Abort the overall resource selection algorithm. |
| 1370 m_currentSourceNode = nullptr; | 1370 m_currentSourceNode = nullptr; |
| 1371 } | 1371 } |
| 1372 | 1372 |
| 1373 void HTMLMediaElement::cancelPendingEventsAndCallbacks() | 1373 void HTMLMediaElement::cancelPendingEventsAndCallbacks() |
| 1374 { | 1374 { |
| 1375 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this ); | 1375 DVLOG(1) << "HTMLMediaElement::cancelPendingEventsAndCallbacks(" << this << ")"; |
| 1376 m_asyncEventQueue->cancelAllEvents(); | 1376 m_asyncEventQueue->cancelAllEvents(); |
| 1377 | 1377 |
| 1378 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) | 1378 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) |
| 1379 source->cancelPendingErrorEvent(); | 1379 source->cancelPendingErrorEvent(); |
| 1380 | 1380 |
| 1381 m_playPromiseResolveTask->cancel(); | 1381 m_playPromiseResolveTask->cancel(); |
| 1382 m_playPromiseRejectTask->cancel(); | 1382 m_playPromiseRejectTask->cancel(); |
| 1383 } | 1383 } |
| 1384 | 1384 |
| 1385 void HTMLMediaElement::networkStateChanged() | 1385 void HTMLMediaElement::networkStateChanged() |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1739 | 1739 |
| 1740 // 11 - Set the current playback position to the given new playback position . | 1740 // 11 - Set the current playback position to the given new playback position . |
| 1741 webMediaPlayer()->seek(time); | 1741 webMediaPlayer()->seek(time); |
| 1742 | 1742 |
| 1743 // 14-17 are handled, if necessary, when the engine signals a readystate cha nge or otherwise | 1743 // 14-17 are handled, if necessary, when the engine signals a readystate cha nge or otherwise |
| 1744 // satisfies seek completion and signals a time change. | 1744 // satisfies seek completion and signals a time change. |
| 1745 } | 1745 } |
| 1746 | 1746 |
| 1747 void HTMLMediaElement::finishSeek() | 1747 void HTMLMediaElement::finishSeek() |
| 1748 { | 1748 { |
| 1749 WTF_LOG(Media, "HTMLMediaElement::finishSeek(%p)", this); | 1749 DVLOG(1) << "HTMLMediaElement::finishSeek(" << this << ")"; |
| 1750 | 1750 |
| 1751 // 14 - Set the seeking IDL attribute to false. | 1751 // 14 - Set the seeking IDL attribute to false. |
| 1752 m_seeking = false; | 1752 m_seeking = false; |
| 1753 | 1753 |
| 1754 // 16 - Queue a task to fire a simple event named timeupdate at the element. | 1754 // 16 - Queue a task to fire a simple event named timeupdate at the element. |
| 1755 scheduleTimeupdateEvent(false); | 1755 scheduleTimeupdateEvent(false); |
| 1756 | 1756 |
| 1757 // 17 - Queue a task to fire a simple event named seeked at the element. | 1757 // 17 - Queue a task to fire a simple event named seeked at the element. |
| 1758 scheduleEvent(EventTypeNames::seeked); | 1758 scheduleEvent(EventTypeNames::seeked); |
| 1759 | 1759 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1785 void HTMLMediaElement::refreshCachedTime() const | 1785 void HTMLMediaElement::refreshCachedTime() const |
| 1786 { | 1786 { |
| 1787 if (!webMediaPlayer() || m_readyState < HAVE_METADATA) | 1787 if (!webMediaPlayer() || m_readyState < HAVE_METADATA) |
| 1788 return; | 1788 return; |
| 1789 | 1789 |
| 1790 m_cachedTime = webMediaPlayer()->currentTime(); | 1790 m_cachedTime = webMediaPlayer()->currentTime(); |
| 1791 } | 1791 } |
| 1792 | 1792 |
| 1793 void HTMLMediaElement::invalidateCachedTime() | 1793 void HTMLMediaElement::invalidateCachedTime() |
| 1794 { | 1794 { |
| 1795 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime(%p)", this); | 1795 DVLOG(1) << "HTMLMediaElement::invalidateCachedTime(" << this << ")"; |
| 1796 m_cachedTime = std::numeric_limits<double>::quiet_NaN(); | 1796 m_cachedTime = std::numeric_limits<double>::quiet_NaN(); |
| 1797 } | 1797 } |
| 1798 | 1798 |
| 1799 // playback state | 1799 // playback state |
| 1800 double HTMLMediaElement::currentTime() const | 1800 double HTMLMediaElement::currentTime() const |
| 1801 { | 1801 { |
| 1802 if (m_defaultPlaybackStartPosition) | 1802 if (m_defaultPlaybackStartPosition) |
| 1803 return m_defaultPlaybackStartPosition; | 1803 return m_defaultPlaybackStartPosition; |
| 1804 | 1804 |
| 1805 if (m_readyState == HAVE_NOTHING) | 1805 if (m_readyState == HAVE_NOTHING) |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2023 | 2023 |
| 2024 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | 2024 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; |
| 2025 ScriptPromise promise = resolver->promise(); | 2025 ScriptPromise promise = resolver->promise(); |
| 2026 | 2026 |
| 2027 m_playResolvers.append(resolver); | 2027 m_playResolvers.append(resolver); |
| 2028 return promise; | 2028 return promise; |
| 2029 } | 2029 } |
| 2030 | 2030 |
| 2031 Nullable<ExceptionCode> HTMLMediaElement::play() | 2031 Nullable<ExceptionCode> HTMLMediaElement::play() |
| 2032 { | 2032 { |
| 2033 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); | 2033 DVLOG(1) << "HTMLMediaElement::play(" << this << ")"; |
| 2034 | 2034 |
| 2035 m_autoplayHelper->playMethodCalled(); | 2035 m_autoplayHelper->playMethodCalled(); |
| 2036 | 2036 |
| 2037 if (!UserGestureIndicator::processingUserGesture()) { | 2037 if (!UserGestureIndicator::processingUserGesture()) { |
| 2038 if (m_userGestureRequiredForPlay) { | 2038 if (m_userGestureRequiredForPlay) { |
| 2039 recordAutoplayMetric(PlayMethodFailed); | 2039 recordAutoplayMetric(PlayMethodFailed); |
| 2040 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); | 2040 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); |
| 2041 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); | 2041 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); |
| 2042 return NotAllowedError; | 2042 return NotAllowedError; |
| 2043 } | 2043 } |
| 2044 } else { | 2044 } else { |
| 2045 UserGestureIndicator::utilizeUserGesture(); | 2045 UserGestureIndicator::utilizeUserGesture(); |
| 2046 // We ask the helper to remove the gesture requirement for us, so that | 2046 // We ask the helper to remove the gesture requirement for us, so that |
| 2047 // it can record the reason. | 2047 // it can record the reason. |
| 2048 Platform::current()->recordAction(UserMetricsAction("Media_Play_WithGest ure")); | 2048 Platform::current()->recordAction(UserMetricsAction("Media_Play_WithGest ure")); |
| 2049 m_autoplayHelper->removeUserGestureRequirement(GesturelessPlaybackEnable dByPlayMethod); | 2049 m_autoplayHelper->removeUserGestureRequirement(GesturelessPlaybackEnable dByPlayMethod); |
| 2050 } | 2050 } |
| 2051 | 2051 |
| 2052 if (m_error && m_error->code() == MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED) | 2052 if (m_error && m_error->code() == MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED) |
| 2053 return NotSupportedError; | 2053 return NotSupportedError; |
| 2054 | 2054 |
| 2055 playInternal(); | 2055 playInternal(); |
| 2056 | 2056 |
| 2057 return nullptr; | 2057 return nullptr; |
| 2058 } | 2058 } |
| 2059 | 2059 |
| 2060 void HTMLMediaElement::playInternal() | 2060 void HTMLMediaElement::playInternal() |
| 2061 { | 2061 { |
| 2062 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); | 2062 DVLOG(1) << "HTMLMediaElement::playInternal(" << this << ")"; |
| 2063 | 2063 |
| 2064 // Always return the buffering strategy to normal when not paused, | 2064 // Always return the buffering strategy to normal when not paused, |
| 2065 // regardless of the cause. (In contrast with aggressive buffering which is | 2065 // regardless of the cause. (In contrast with aggressive buffering which is |
| 2066 // only enabled by pause(), not pauseInternal().) | 2066 // only enabled by pause(), not pauseInternal().) |
| 2067 if (webMediaPlayer()) | 2067 if (webMediaPlayer()) |
| 2068 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal); | 2068 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal); |
| 2069 | 2069 |
| 2070 // 4.8.10.9. Playing the media resource | 2070 // 4.8.10.9. Playing the media resource |
| 2071 if (m_networkState == NETWORK_EMPTY) | 2071 if (m_networkState == NETWORK_EMPTY) |
| 2072 invokeResourceSelectionAlgorithm(); | 2072 invokeResourceSelectionAlgorithm(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2091 } | 2091 } |
| 2092 | 2092 |
| 2093 m_autoplaying = false; | 2093 m_autoplaying = false; |
| 2094 | 2094 |
| 2095 setIgnorePreloadNone(); | 2095 setIgnorePreloadNone(); |
| 2096 updatePlayState(); | 2096 updatePlayState(); |
| 2097 } | 2097 } |
| 2098 | 2098 |
| 2099 void HTMLMediaElement::pause() | 2099 void HTMLMediaElement::pause() |
| 2100 { | 2100 { |
| 2101 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this); | 2101 DVLOG(1) << "HTMLMediaElement::pause(" << this << ")"; |
| 2102 | 2102 |
| 2103 // Only buffer aggressively on a user-initiated pause. Other types of pauses | 2103 // Only buffer aggressively on a user-initiated pause. Other types of pauses |
| 2104 // (which go directly to pauseInternal()) should not cause this behavior. | 2104 // (which go directly to pauseInternal()) should not cause this behavior. |
| 2105 if (webMediaPlayer() && UserGestureIndicator::utilizeUserGesture()) | 2105 if (webMediaPlayer() && UserGestureIndicator::utilizeUserGesture()) |
| 2106 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Aggressive); | 2106 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Aggressive); |
| 2107 | 2107 |
| 2108 pauseInternal(); | 2108 pauseInternal(); |
| 2109 } | 2109 } |
| 2110 | 2110 |
| 2111 void HTMLMediaElement::pauseInternal() | 2111 void HTMLMediaElement::pauseInternal() |
| 2112 { | 2112 { |
| 2113 WTF_LOG(Media, "HTMLMediaElement::pauseInternal(%p)", this); | 2113 DVLOG(1) << "HTMLMediaElement::pauseInternal(" << this << ")"; |
| 2114 | 2114 |
| 2115 if (m_networkState == NETWORK_EMPTY) | 2115 if (m_networkState == NETWORK_EMPTY) |
| 2116 invokeResourceSelectionAlgorithm(); | 2116 invokeResourceSelectionAlgorithm(); |
| 2117 | 2117 |
| 2118 m_autoplayHelper->pauseMethodCalled(); | 2118 m_autoplayHelper->pauseMethodCalled(); |
| 2119 | 2119 |
| 2120 m_autoplaying = false; | 2120 m_autoplaying = false; |
| 2121 | 2121 |
| 2122 if (!m_paused) { | 2122 if (!m_paused) { |
| 2123 m_paused = true; | 2123 m_paused = true; |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2361 return 0; | 2361 return 0; |
| 2362 | 2362 |
| 2363 AudioTrack* audioTrack = AudioTrack::create(id, kindString, label, language, enabled); | 2363 AudioTrack* audioTrack = AudioTrack::create(id, kindString, label, language, enabled); |
| 2364 audioTracks().add(audioTrack); | 2364 audioTracks().add(audioTrack); |
| 2365 | 2365 |
| 2366 return audioTrack->trackId(); | 2366 return audioTrack->trackId(); |
| 2367 } | 2367 } |
| 2368 | 2368 |
| 2369 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) | 2369 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) |
| 2370 { | 2370 { |
| 2371 WTF_LOG(Media, "HTMLMediaElement::removeAudioTrack(%p)", this); | 2371 DVLOG(1) << "HTMLMediaElement::removeAudioTrack(" << this << ")"; |
| 2372 | 2372 |
| 2373 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2373 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2374 return; | 2374 return; |
| 2375 | 2375 |
| 2376 audioTracks().remove(trackId); | 2376 audioTracks().remove(trackId); |
| 2377 } | 2377 } |
| 2378 | 2378 |
| 2379 VideoTrackList& HTMLMediaElement::videoTracks() | 2379 VideoTrackList& HTMLMediaElement::videoTracks() |
| 2380 { | 2380 { |
| 2381 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2381 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2409 selected = false; | 2409 selected = false; |
| 2410 | 2410 |
| 2411 VideoTrack* videoTrack = VideoTrack::create(id, kindString, label, language, selected); | 2411 VideoTrack* videoTrack = VideoTrack::create(id, kindString, label, language, selected); |
| 2412 videoTracks().add(videoTrack); | 2412 videoTracks().add(videoTrack); |
| 2413 | 2413 |
| 2414 return videoTrack->trackId(); | 2414 return videoTrack->trackId(); |
| 2415 } | 2415 } |
| 2416 | 2416 |
| 2417 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) | 2417 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) |
| 2418 { | 2418 { |
| 2419 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this); | 2419 DVLOG(1) << "HTMLMediaElement::removeVideoTrack(" << this << ")"; |
| 2420 | 2420 |
| 2421 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2421 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2422 return; | 2422 return; |
| 2423 | 2423 |
| 2424 videoTracks().remove(trackId); | 2424 videoTracks().remove(trackId); |
| 2425 } | 2425 } |
| 2426 | 2426 |
| 2427 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) | 2427 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) |
| 2428 { | 2428 { |
| 2429 // 4.8.10.12.2 Sourcing in-band text tracks | 2429 // 4.8.10.12.2 Sourcing in-band text tracks |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2635 | 2635 |
| 2636 return nextURL.isValid(); | 2636 return nextURL.isValid(); |
| 2637 } | 2637 } |
| 2638 | 2638 |
| 2639 KURL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, InvalidUR LAction actionIfInvalid) | 2639 KURL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, InvalidUR LAction actionIfInvalid) |
| 2640 { | 2640 { |
| 2641 #if !LOG_DISABLED | 2641 #if !LOG_DISABLED |
| 2642 // Don't log if this was just called to find out if there are any valid <sou rce> elements. | 2642 // Don't log if this was just called to find out if there are any valid <sou rce> elements. |
| 2643 bool shouldLog = actionIfInvalid != DoNothing; | 2643 bool shouldLog = actionIfInvalid != DoNothing; |
| 2644 if (shouldLog) | 2644 if (shouldLog) |
| 2645 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p)", this); | 2645 DVLOG(1) << "HTMLMediaElement::selectNextSourceChild(" << this << ")"; |
| 2646 #endif | 2646 #endif |
| 2647 | 2647 |
| 2648 if (!m_nextChildNodeToConsider) { | 2648 if (!m_nextChildNodeToConsider) { |
| 2649 #if !LOG_DISABLED | 2649 #if !LOG_DISABLED |
| 2650 if (shouldLog) | 2650 if (shouldLog) |
| 2651 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) -> 0x000 0, \"\"", this); | 2651 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) -> 0x000 0, \"\"", this); |
| 2652 #endif | 2652 #endif |
| 2653 return KURL(); | 2653 return KURL(); |
| 2654 } | 2654 } |
| 2655 | 2655 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2810 // Clear the current source node pointer, but don't change the movie as the spec says: | 2810 // Clear the current source node pointer, but don't change the movie as the spec says: |
| 2811 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already | 2811 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already |
| 2812 // inserted in a video or audio element will have no effect. | 2812 // inserted in a video or audio element will have no effect. |
| 2813 m_currentSourceNode = nullptr; | 2813 m_currentSourceNode = nullptr; |
| 2814 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this); | 2814 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this); |
| 2815 } | 2815 } |
| 2816 } | 2816 } |
| 2817 | 2817 |
| 2818 void HTMLMediaElement::timeChanged() | 2818 void HTMLMediaElement::timeChanged() |
| 2819 { | 2819 { |
| 2820 WTF_LOG(Media, "HTMLMediaElement::timeChanged(%p)", this); | 2820 DVLOG(1) << "HTMLMediaElement::timeChanged(" << this << ")"; |
| 2821 | 2821 |
| 2822 cueTimeline().updateActiveCues(currentTime()); | 2822 cueTimeline().updateActiveCues(currentTime()); |
| 2823 | 2823 |
| 2824 invalidateCachedTime(); | 2824 invalidateCachedTime(); |
| 2825 | 2825 |
| 2826 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. | 2826 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. |
| 2827 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) | 2827 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) |
| 2828 finishSeek(); | 2828 finishSeek(); |
| 2829 | 2829 |
| 2830 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, | 2830 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 2860 } | 2860 } |
| 2861 } else { | 2861 } else { |
| 2862 m_sentEndEvent = false; | 2862 m_sentEndEvent = false; |
| 2863 } | 2863 } |
| 2864 | 2864 |
| 2865 updatePlayState(); | 2865 updatePlayState(); |
| 2866 } | 2866 } |
| 2867 | 2867 |
| 2868 void HTMLMediaElement::durationChanged() | 2868 void HTMLMediaElement::durationChanged() |
| 2869 { | 2869 { |
| 2870 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p)", this); | 2870 DVLOG(1) << "HTMLMediaElement::durationChanged(" << this << ")"; |
| 2871 // FIXME: Change WebMediaPlayer to convey the currentTime | 2871 // FIXME: Change WebMediaPlayer to convey the currentTime |
| 2872 // when the duration change occured. The current WebMediaPlayer | 2872 // when the duration change occured. The current WebMediaPlayer |
| 2873 // implementations always clamp currentTime() to duration() | 2873 // implementations always clamp currentTime() to duration() |
| 2874 // so the requestSeek condition here is always false. | 2874 // so the requestSeek condition here is always false. |
| 2875 durationChanged(duration(), currentTime() > duration()); | 2875 durationChanged(duration(), currentTime() > duration()); |
| 2876 } | 2876 } |
| 2877 | 2877 |
| 2878 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) | 2878 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) |
| 2879 { | 2879 { |
| 2880 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); | 2880 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2891 mediaControls()->reset(); | 2891 mediaControls()->reset(); |
| 2892 if (layoutObject()) | 2892 if (layoutObject()) |
| 2893 layoutObject()->updateFromElement(); | 2893 layoutObject()->updateFromElement(); |
| 2894 | 2894 |
| 2895 if (requestSeek) | 2895 if (requestSeek) |
| 2896 seek(duration); | 2896 seek(duration); |
| 2897 } | 2897 } |
| 2898 | 2898 |
| 2899 void HTMLMediaElement::playbackStateChanged() | 2899 void HTMLMediaElement::playbackStateChanged() |
| 2900 { | 2900 { |
| 2901 WTF_LOG(Media, "HTMLMediaElement::playbackStateChanged(%p)", this); | 2901 DVLOG(1) << "HTMLMediaElement::playbackStateChanged(" << this << ")"; |
| 2902 | 2902 |
| 2903 if (!webMediaPlayer()) | 2903 if (!webMediaPlayer()) |
| 2904 return; | 2904 return; |
| 2905 | 2905 |
| 2906 if (webMediaPlayer()->paused()) | 2906 if (webMediaPlayer()->paused()) |
| 2907 pauseInternal(); | 2907 pauseInternal(); |
| 2908 else | 2908 else |
| 2909 playInternal(); | 2909 playInternal(); |
| 2910 } | 2910 } |
| 2911 | 2911 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2954 if (m_webLayer) | 2954 if (m_webLayer) |
| 2955 m_webLayer->invalidate(); | 2955 m_webLayer->invalidate(); |
| 2956 | 2956 |
| 2957 updateDisplayState(); | 2957 updateDisplayState(); |
| 2958 if (layoutObject()) | 2958 if (layoutObject()) |
| 2959 layoutObject()->setShouldDoFullPaintInvalidation(); | 2959 layoutObject()->setShouldDoFullPaintInvalidation(); |
| 2960 } | 2960 } |
| 2961 | 2961 |
| 2962 void HTMLMediaElement::sizeChanged() | 2962 void HTMLMediaElement::sizeChanged() |
| 2963 { | 2963 { |
| 2964 WTF_LOG(Media, "HTMLMediaElement::sizeChanged(%p)", this); | 2964 DVLOG(1) << "HTMLMediaElement::sizeChanged(" << this << ")"; |
| 2965 | 2965 |
| 2966 ASSERT(hasVideo()); // "resize" makes no sense absent video. | 2966 ASSERT(hasVideo()); // "resize" makes no sense absent video. |
| 2967 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) | 2967 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) |
| 2968 scheduleEvent(EventTypeNames::resize); | 2968 scheduleEvent(EventTypeNames::resize); |
| 2969 | 2969 |
| 2970 if (layoutObject()) | 2970 if (layoutObject()) |
| 2971 layoutObject()->updateFromElement(); | 2971 layoutObject()->updateFromElement(); |
| 2972 } | 2972 } |
| 2973 | 2973 |
| 2974 TimeRanges* HTMLMediaElement::buffered() const | 2974 TimeRanges* HTMLMediaElement::buffered() const |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3147 m_playingRemotely = false; | 3147 m_playingRemotely = false; |
| 3148 if (mediaControls()) | 3148 if (mediaControls()) |
| 3149 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); | 3149 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); |
| 3150 | 3150 |
| 3151 if (layoutObject()) | 3151 if (layoutObject()) |
| 3152 layoutObject()->setShouldDoFullPaintInvalidation(); | 3152 layoutObject()->setShouldDoFullPaintInvalidation(); |
| 3153 } | 3153 } |
| 3154 | 3154 |
| 3155 void HTMLMediaElement::stop() | 3155 void HTMLMediaElement::stop() |
| 3156 { | 3156 { |
| 3157 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); | 3157 DVLOG(1) << "HTMLMediaElement::stop(" << this << ")"; |
| 3158 | 3158 |
| 3159 // Close the async event queue so that no events are enqueued. | 3159 // Close the async event queue so that no events are enqueued. |
| 3160 cancelPendingEventsAndCallbacks(); | 3160 cancelPendingEventsAndCallbacks(); |
| 3161 m_asyncEventQueue->close(); | 3161 m_asyncEventQueue->close(); |
| 3162 | 3162 |
| 3163 // Clear everything in the Media Element | 3163 // Clear everything in the Media Element |
| 3164 clearMediaPlayer(); | 3164 clearMediaPlayer(); |
| 3165 m_readyState = HAVE_NOTHING; | 3165 m_readyState = HAVE_NOTHING; |
| 3166 m_readyStateMaximum = HAVE_NOTHING; | 3166 m_readyStateMaximum = HAVE_NOTHING; |
| 3167 setNetworkState(NETWORK_EMPTY); | 3167 setNetworkState(NETWORK_EMPTY); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3214 return false; | 3214 return false; |
| 3215 } | 3215 } |
| 3216 | 3216 |
| 3217 bool HTMLMediaElement::isFullscreen() const | 3217 bool HTMLMediaElement::isFullscreen() const |
| 3218 { | 3218 { |
| 3219 return Fullscreen::isActiveFullScreenElement(*this); | 3219 return Fullscreen::isActiveFullScreenElement(*this); |
| 3220 } | 3220 } |
| 3221 | 3221 |
| 3222 void HTMLMediaElement::enterFullscreen() | 3222 void HTMLMediaElement::enterFullscreen() |
| 3223 { | 3223 { |
| 3224 WTF_LOG(Media, "HTMLMediaElement::enterFullscreen(%p)", this); | 3224 DVLOG(1) << "HTMLMediaElement::enterFullscreen(" << this << ")"; |
| 3225 | 3225 |
| 3226 Fullscreen::from(document()).requestFullscreen(*this, Fullscreen::PrefixedRe quest); | 3226 Fullscreen::from(document()).requestFullscreen(*this, Fullscreen::PrefixedRe quest); |
| 3227 } | 3227 } |
| 3228 | 3228 |
| 3229 void HTMLMediaElement::exitFullscreen() | 3229 void HTMLMediaElement::exitFullscreen() |
| 3230 { | 3230 { |
| 3231 WTF_LOG(Media, "HTMLMediaElement::exitFullscreen(%p)", this); | 3231 DVLOG(1) << "HTMLMediaElement::exitFullscreen(" << this << ")"; |
| 3232 | 3232 |
| 3233 Fullscreen::from(document()).exitFullscreen(); | 3233 Fullscreen::from(document()).exitFullscreen(); |
| 3234 } | 3234 } |
| 3235 | 3235 |
| 3236 void HTMLMediaElement::didBecomeFullscreenElement() | 3236 void HTMLMediaElement::didBecomeFullscreenElement() |
| 3237 { | 3237 { |
| 3238 if (mediaControls()) | 3238 if (mediaControls()) |
| 3239 mediaControls()->enteredFullscreen(); | 3239 mediaControls()->enteredFullscreen(); |
| 3240 // FIXME: There is no embedder-side handling in layout test mode. | 3240 // FIXME: There is no embedder-side handling in layout test mode. |
| 3241 if (webMediaPlayer() && !LayoutTestSupport::isRunningLayoutTest()) | 3241 if (webMediaPlayer() && !LayoutTestSupport::isRunningLayoutTest()) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3317 // so that they are rendered behind them. | 3317 // so that they are rendered behind them. |
| 3318 shadowRoot.insertBefore(textTrackContainer, firstChild); | 3318 shadowRoot.insertBefore(textTrackContainer, firstChild); |
| 3319 | 3319 |
| 3320 assertShadowRootChildren(shadowRoot); | 3320 assertShadowRootChildren(shadowRoot); |
| 3321 | 3321 |
| 3322 return *textTrackContainer; | 3322 return *textTrackContainer; |
| 3323 } | 3323 } |
| 3324 | 3324 |
| 3325 void HTMLMediaElement::updateTextTrackDisplay() | 3325 void HTMLMediaElement::updateTextTrackDisplay() |
| 3326 { | 3326 { |
| 3327 WTF_LOG(Media, "HTMLMediaElement::updateTextTrackDisplay(%p)", this); | 3327 DVLOG(1) << "HTMLMediaElement::updateTextTrackDisplay(" << this << ")"; |
| 3328 | 3328 |
| 3329 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidNotSt artExposingControls); | 3329 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidNotSt artExposingControls); |
| 3330 } | 3330 } |
| 3331 | 3331 |
| 3332 void HTMLMediaElement::mediaControlsDidBecomeVisible() | 3332 void HTMLMediaElement::mediaControlsDidBecomeVisible() |
| 3333 { | 3333 { |
| 3334 WTF_LOG(Media, "HTMLMediaElement::mediaControlsDidBecomeVisible(%p)", this); | 3334 DVLOG(1) << "HTMLMediaElement::mediaControlsDidBecomeVisible(" << this << ") "; |
| 3335 | 3335 |
| 3336 // When the user agent starts exposing a user interface for a video element, | 3336 // When the user agent starts exposing a user interface for a video element, |
| 3337 // the user agent should run the rules for updating the text track rendering | 3337 // the user agent should run the rules for updating the text track rendering |
| 3338 // of each of the text tracks in the video element's list of text tracks ... | 3338 // of each of the text tracks in the video element's list of text tracks ... |
| 3339 if (isHTMLVideoElement() && textTracksVisible()) | 3339 if (isHTMLVideoElement() && textTracksVisible()) |
| 3340 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls); | 3340 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls); |
| 3341 } | 3341 } |
| 3342 | 3342 |
| 3343 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen t* document) | 3343 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen t* document) |
| 3344 { | 3344 { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3476 CueTimeline& HTMLMediaElement::cueTimeline() | 3476 CueTimeline& HTMLMediaElement::cueTimeline() |
| 3477 { | 3477 { |
| 3478 if (!m_cueTimeline) | 3478 if (!m_cueTimeline) |
| 3479 m_cueTimeline = new CueTimeline(*this); | 3479 m_cueTimeline = new CueTimeline(*this); |
| 3480 return *m_cueTimeline; | 3480 return *m_cueTimeline; |
| 3481 } | 3481 } |
| 3482 | 3482 |
| 3483 void HTMLMediaElement::configureTextTrackDisplay() | 3483 void HTMLMediaElement::configureTextTrackDisplay() |
| 3484 { | 3484 { |
| 3485 ASSERT(m_textTracks); | 3485 ASSERT(m_textTracks); |
| 3486 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this); | 3486 DVLOG(1) << "HTMLMediaElement::configureTextTrackDisplay(" << this << ")"; |
| 3487 | 3487 |
| 3488 if (m_processingPreferenceChange) | 3488 if (m_processingPreferenceChange) |
| 3489 return; | 3489 return; |
| 3490 | 3490 |
| 3491 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); | 3491 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); |
| 3492 m_textTracksVisible = haveVisibleTextTrack; | 3492 m_textTracksVisible = haveVisibleTextTrack; |
| 3493 | 3493 |
| 3494 if (!haveVisibleTextTrack && !mediaControls()) | 3494 if (!haveVisibleTextTrack && !mediaControls()) |
| 3495 return; | 3495 return; |
| 3496 | 3496 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3850 | 3850 |
| 3851 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst | 3851 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst |
| 3852 { | 3852 { |
| 3853 IntRect result; | 3853 IntRect result; |
| 3854 if (LayoutObject* object = m_element->layoutObject()) | 3854 if (LayoutObject* object = m_element->layoutObject()) |
| 3855 result = object->absoluteBoundingBoxRect(); | 3855 result = object->absoluteBoundingBoxRect(); |
| 3856 return result; | 3856 return result; |
| 3857 } | 3857 } |
| 3858 | 3858 |
| 3859 } // namespace blink | 3859 } // namespace blink |
| OLD | NEW |