| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 m_processingPreferenceChange(false), | 413 m_processingPreferenceChange(false), |
| 414 m_playingRemotely(false), | 414 m_playingRemotely(false), |
| 415 m_inOverlayFullscreenVideo(false), | 415 m_inOverlayFullscreenVideo(false), |
| 416 m_mostlyFillingViewport(false), | 416 m_mostlyFillingViewport(false), |
| 417 m_audioTracks(this, AudioTrackList::create(*this)), | 417 m_audioTracks(this, AudioTrackList::create(*this)), |
| 418 m_videoTracks(this, VideoTrackList::create(*this)), | 418 m_videoTracks(this, VideoTrackList::create(*this)), |
| 419 m_textTracks(this, nullptr), | 419 m_textTracks(this, nullptr), |
| 420 m_audioSourceNode(nullptr), | 420 m_audioSourceNode(nullptr), |
| 421 m_autoplayUmaHelper(AutoplayUmaHelper::create(this)), | 421 m_autoplayUmaHelper(AutoplayUmaHelper::create(this)), |
| 422 m_remotePlaybackClient(nullptr), | 422 m_remotePlaybackClient(nullptr), |
| 423 m_autoplayVisibilityObserver(nullptr) { | 423 m_autoplayVisibilityObserver(nullptr), |
| 424 m_mediaControls(nullptr) { |
| 424 BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; | 425 BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; |
| 425 | 426 |
| 426 m_lockedPendingUserGesture = computeLockedPendingUserGesture(document); | 427 m_lockedPendingUserGesture = computeLockedPendingUserGesture(document); |
| 427 m_lockedPendingUserGestureIfCrossOriginExperimentEnabled = | 428 m_lockedPendingUserGestureIfCrossOriginExperimentEnabled = |
| 428 isDocumentCrossOrigin(document); | 429 isDocumentCrossOrigin(document); |
| 429 | 430 |
| 430 LocalFrame* frame = document.frame(); | 431 LocalFrame* frame = document.frame(); |
| 431 if (frame) { | 432 if (frame) { |
| 432 m_remotePlaybackClient = | 433 m_remotePlaybackClient = |
| 433 frame->loader().client()->createWebRemotePlaybackClient(*this); | 434 frame->loader().client()->createWebRemotePlaybackClient(*this); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 << ", srcAttr, old=" << oldValue << ", new=" << value | 532 << ", srcAttr, old=" << oldValue << ", new=" << value |
| 532 << ")"; | 533 << ")"; |
| 533 // Trigger a reload, as long as the 'src' attribute is present. | 534 // Trigger a reload, as long as the 'src' attribute is present. |
| 534 if (!value.isNull()) { | 535 if (!value.isNull()) { |
| 535 m_ignorePreloadNone = false; | 536 m_ignorePreloadNone = false; |
| 536 invokeLoadAlgorithm(); | 537 invokeLoadAlgorithm(); |
| 537 } | 538 } |
| 538 } else if (name == controlsAttr) { | 539 } else if (name == controlsAttr) { |
| 539 UseCounter::count(document(), | 540 UseCounter::count(document(), |
| 540 UseCounter::HTMLMediaElementControlsAttribute); | 541 UseCounter::HTMLMediaElementControlsAttribute); |
| 541 configureMediaControls(); | 542 updateControlsVisibility(); |
| 542 } else if (name == preloadAttr) { | 543 } else if (name == preloadAttr) { |
| 543 setPlayerPreload(); | 544 setPlayerPreload(); |
| 544 } else if (name == disableremoteplaybackAttr) { | 545 } else if (name == disableremoteplaybackAttr) { |
| 545 // This attribute is an extension described in the Remote Playback API spec. | 546 // This attribute is an extension described in the Remote Playback API spec. |
| 546 // Please see: https://w3c.github.io/remote-playback | 547 // Please see: https://w3c.github.io/remote-playback |
| 547 UseCounter::count(document(), UseCounter::DisableRemotePlaybackAttribute); | 548 UseCounter::count(document(), UseCounter::DisableRemotePlaybackAttribute); |
| 548 if (oldValue != value) { | 549 if (oldValue != value) { |
| 549 if (m_webMediaPlayer) | 550 if (m_webMediaPlayer) |
| 550 m_webMediaPlayer->requestRemotePlaybackDisabled(!value.isNull()); | 551 m_webMediaPlayer->requestRemotePlaybackDisabled(!value.isNull()); |
| 551 // TODO(mlamouri): there is no direct API to expose if | 552 // TODO(mlamouri): there is no direct API to expose if |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 m_networkState == kNetworkEmpty) { | 587 m_networkState == kNetworkEmpty) { |
| 587 m_ignorePreloadNone = false; | 588 m_ignorePreloadNone = false; |
| 588 invokeLoadAlgorithm(); | 589 invokeLoadAlgorithm(); |
| 589 } | 590 } |
| 590 } | 591 } |
| 591 | 592 |
| 592 return InsertionShouldCallDidNotifySubtreeInsertions; | 593 return InsertionShouldCallDidNotifySubtreeInsertions; |
| 593 } | 594 } |
| 594 | 595 |
| 595 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() { | 596 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() { |
| 596 configureMediaControls(); | 597 updateControlsVisibility(); |
| 597 } | 598 } |
| 598 | 599 |
| 599 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) { | 600 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) { |
| 600 BLINK_MEDIA_LOG << "removedFrom(" << (void*)this << ", " << insertionPoint | 601 BLINK_MEDIA_LOG << "removedFrom(" << (void*)this << ", " << insertionPoint |
| 601 << ")"; | 602 << ")"; |
| 602 | 603 |
| 603 HTMLElement::removedFrom(insertionPoint); | 604 HTMLElement::removedFrom(insertionPoint); |
| 604 if (insertionPoint->inActiveDocument()) { | 605 if (insertionPoint->inActiveDocument()) { |
| 605 configureMediaControls(); | 606 updateControlsVisibility(); |
| 606 if (m_networkState > kNetworkEmpty) | 607 if (m_networkState > kNetworkEmpty) |
| 607 pauseInternal(); | 608 pauseInternal(); |
| 608 } | 609 } |
| 609 } | 610 } |
| 610 | 611 |
| 611 void HTMLMediaElement::attachLayoutTree(const AttachContext& context) { | 612 void HTMLMediaElement::attachLayoutTree(const AttachContext& context) { |
| 612 HTMLElement::attachLayoutTree(context); | 613 HTMLElement::attachLayoutTree(context); |
| 613 | 614 |
| 614 if (layoutObject()) | 615 if (layoutObject()) |
| 615 layoutObject()->updateFromElement(); | 616 layoutObject()->updateFromElement(); |
| (...skipping 2808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3424 return true; | 3425 return true; |
| 3425 | 3426 |
| 3426 return false; | 3427 return false; |
| 3427 } | 3428 } |
| 3428 | 3429 |
| 3429 bool HTMLMediaElement::isFullscreen() const { | 3430 bool HTMLMediaElement::isFullscreen() const { |
| 3430 return Fullscreen::isFullscreenElement(*this); | 3431 return Fullscreen::isFullscreenElement(*this); |
| 3431 } | 3432 } |
| 3432 | 3433 |
| 3433 void HTMLMediaElement::didEnterFullscreen() { | 3434 void HTMLMediaElement::didEnterFullscreen() { |
| 3434 configureMediaControls(); | 3435 updateControlsVisibility(); |
| 3436 |
| 3435 // FIXME: There is no embedder-side handling in layout test mode. | 3437 // FIXME: There is no embedder-side handling in layout test mode. |
| 3436 if (webMediaPlayer() && !LayoutTestSupport::isRunningLayoutTest()) | 3438 if (webMediaPlayer() && !LayoutTestSupport::isRunningLayoutTest()) |
| 3437 webMediaPlayer()->enteredFullscreen(); | 3439 webMediaPlayer()->enteredFullscreen(); |
| 3438 // Cache this in case the player is destroyed before leaving fullscreen. | 3440 // Cache this in case the player is destroyed before leaving fullscreen. |
| 3439 m_inOverlayFullscreenVideo = usesOverlayFullscreenVideo(); | 3441 m_inOverlayFullscreenVideo = usesOverlayFullscreenVideo(); |
| 3440 if (m_inOverlayFullscreenVideo) | 3442 if (m_inOverlayFullscreenVideo) |
| 3441 document().layoutViewItem().compositor()->setNeedsCompositingUpdate( | 3443 document().layoutViewItem().compositor()->setNeedsCompositingUpdate( |
| 3442 CompositingUpdateRebuildTree); | 3444 CompositingUpdateRebuildTree); |
| 3443 } | 3445 } |
| 3444 | 3446 |
| 3445 void HTMLMediaElement::didExitFullscreen() { | 3447 void HTMLMediaElement::didExitFullscreen() { |
| 3446 configureMediaControls(); | 3448 updateControlsVisibility(); |
| 3449 |
| 3447 if (webMediaPlayer()) | 3450 if (webMediaPlayer()) |
| 3448 webMediaPlayer()->exitedFullscreen(); | 3451 webMediaPlayer()->exitedFullscreen(); |
| 3449 if (m_inOverlayFullscreenVideo) | 3452 if (m_inOverlayFullscreenVideo) |
| 3450 document().layoutViewItem().compositor()->setNeedsCompositingUpdate( | 3453 document().layoutViewItem().compositor()->setNeedsCompositingUpdate( |
| 3451 CompositingUpdateRebuildTree); | 3454 CompositingUpdateRebuildTree); |
| 3452 m_inOverlayFullscreenVideo = false; | 3455 m_inOverlayFullscreenVideo = false; |
| 3453 } | 3456 } |
| 3454 | 3457 |
| 3455 WebLayer* HTMLMediaElement::platformLayer() const { | 3458 WebLayer* HTMLMediaElement::platformLayer() const { |
| 3456 return m_webLayer; | 3459 return m_webLayer; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3597 << boolString(shouldDelay) << ")"; | 3600 << boolString(shouldDelay) << ")"; |
| 3598 | 3601 |
| 3599 m_shouldDelayLoadEvent = shouldDelay; | 3602 m_shouldDelayLoadEvent = shouldDelay; |
| 3600 if (shouldDelay) | 3603 if (shouldDelay) |
| 3601 document().incrementLoadEventDelayCount(); | 3604 document().incrementLoadEventDelayCount(); |
| 3602 else | 3605 else |
| 3603 document().decrementLoadEventDelayCount(); | 3606 document().decrementLoadEventDelayCount(); |
| 3604 } | 3607 } |
| 3605 | 3608 |
| 3606 MediaControls* HTMLMediaElement::mediaControls() const { | 3609 MediaControls* HTMLMediaElement::mediaControls() const { |
| 3607 if (ShadowRoot* shadowRoot = userAgentShadowRoot()) { | 3610 return m_mediaControls; |
| 3608 Node* lastChild = shadowRoot->lastChild(); | |
| 3609 if (lastChild && lastChild->isMediaControls()) | |
| 3610 return toMediaControls(lastChild); | |
| 3611 } | |
| 3612 | |
| 3613 return nullptr; | |
| 3614 } | 3611 } |
| 3615 | 3612 |
| 3616 void HTMLMediaElement::ensureMediaControls() { | 3613 void HTMLMediaElement::ensureMediaControls() { |
| 3617 if (mediaControls()) | 3614 if (mediaControls()) |
| 3618 return; | 3615 return; |
| 3619 | 3616 |
| 3620 MediaControls* mediaControls = MediaControls::create(*this); | |
| 3621 mediaControls->reset(); | |
| 3622 | |
| 3623 ShadowRoot& shadowRoot = ensureUserAgentShadowRoot(); | 3617 ShadowRoot& shadowRoot = ensureUserAgentShadowRoot(); |
| 3624 assertShadowRootChildren(shadowRoot); | 3618 m_mediaControls = MediaControls::create(*this, shadowRoot); |
| 3625 | 3619 |
| 3626 // The media controls should be inserted after the text track container, | 3620 // The media controls should be inserted after the text track container, |
| 3627 // so that they are rendered in front of captions and subtitles. | 3621 // so that they are rendered in front of captions and subtitles. This check |
| 3628 shadowRoot.appendChild(mediaControls); | 3622 // is verifying the contract. |
| 3629 | |
| 3630 assertShadowRootChildren(shadowRoot); | 3623 assertShadowRootChildren(shadowRoot); |
| 3631 | |
| 3632 if (!shouldShowControls() || !isConnected()) | |
| 3633 mediaControls->hide(); | |
| 3634 } | 3624 } |
| 3635 | 3625 |
| 3636 void HTMLMediaElement::configureMediaControls() { | 3626 void HTMLMediaElement::updateControlsVisibility() { |
| 3637 if (!isConnected()) { | 3627 if (!isConnected()) { |
| 3638 if (mediaControls()) | 3628 if (mediaControls()) |
| 3639 mediaControls()->hide(); | 3629 mediaControls()->hide(); |
| 3640 return; | 3630 return; |
| 3641 } | 3631 } |
| 3642 | 3632 |
| 3643 ensureMediaControls(); | 3633 ensureMediaControls(); |
| 3634 // TODO(mlamouri): this doesn't sound needed but the following tests, on |
| 3635 // Android fails when removed: |
| 3636 // fullscreen/compositor-touch-hit-rects-fullscreen-video-controls.html |
| 3644 mediaControls()->reset(); | 3637 mediaControls()->reset(); |
| 3645 | 3638 |
| 3646 if (shouldShowControls(RecordMetricsBehavior::DoRecord)) | 3639 if (shouldShowControls(RecordMetricsBehavior::DoRecord)) |
| 3647 mediaControls()->show(); | 3640 mediaControls()->show(); |
| 3648 else | 3641 else |
| 3649 mediaControls()->hide(); | 3642 mediaControls()->hide(); |
| 3650 } | 3643 } |
| 3651 | 3644 |
| 3652 CueTimeline& HTMLMediaElement::cueTimeline() { | 3645 CueTimeline& HTMLMediaElement::cueTimeline() { |
| 3653 if (!m_cueTimeline) | 3646 if (!m_cueTimeline) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3751 visitor->trace(m_cueTimeline); | 3744 visitor->trace(m_cueTimeline); |
| 3752 visitor->trace(m_textTracks); | 3745 visitor->trace(m_textTracks); |
| 3753 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3746 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
| 3754 visitor->trace(m_playPromiseResolvers); | 3747 visitor->trace(m_playPromiseResolvers); |
| 3755 visitor->trace(m_playPromiseResolveList); | 3748 visitor->trace(m_playPromiseResolveList); |
| 3756 visitor->trace(m_playPromiseRejectList); | 3749 visitor->trace(m_playPromiseRejectList); |
| 3757 visitor->trace(m_audioSourceProvider); | 3750 visitor->trace(m_audioSourceProvider); |
| 3758 visitor->trace(m_autoplayUmaHelper); | 3751 visitor->trace(m_autoplayUmaHelper); |
| 3759 visitor->trace(m_srcObject); | 3752 visitor->trace(m_srcObject); |
| 3760 visitor->trace(m_autoplayVisibilityObserver); | 3753 visitor->trace(m_autoplayVisibilityObserver); |
| 3754 visitor->trace(m_mediaControls); |
| 3761 visitor->template registerWeakMembers<HTMLMediaElement, | 3755 visitor->template registerWeakMembers<HTMLMediaElement, |
| 3762 &HTMLMediaElement::clearWeakMembers>( | 3756 &HTMLMediaElement::clearWeakMembers>( |
| 3763 this); | 3757 this); |
| 3764 Supplementable<HTMLMediaElement>::trace(visitor); | 3758 Supplementable<HTMLMediaElement>::trace(visitor); |
| 3765 HTMLElement::trace(visitor); | 3759 HTMLElement::trace(visitor); |
| 3766 SuspendableObject::trace(visitor); | 3760 SuspendableObject::trace(visitor); |
| 3767 } | 3761 } |
| 3768 | 3762 |
| 3769 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) { | 3763 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) { |
| 3770 visitor->traceWrappers(m_videoTracks); | 3764 visitor->traceWrappers(m_videoTracks); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4112 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); | 4106 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); |
| 4113 } | 4107 } |
| 4114 | 4108 |
| 4115 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { | 4109 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { |
| 4116 m_mostlyFillingViewport = true; | 4110 m_mostlyFillingViewport = true; |
| 4117 if (m_webMediaPlayer) | 4111 if (m_webMediaPlayer) |
| 4118 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); | 4112 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); |
| 4119 } | 4113 } |
| 4120 | 4114 |
| 4121 } // namespace blink | 4115 } // namespace blink |
| OLD | NEW |