Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
index d47769d14bf154d0ffefddded40d5b40f2ba60f8..3d226854c8f5d3244ad70c409ec655b2673cf6a7 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
@@ -57,6 +57,7 @@ |
#include "core/html/MediaFragmentURIParser.h" |
#include "core/html/TimeRanges.h" |
#include "core/html/shadow/MediaControls.h" |
+#include "core/html/shadow/MediaRemotingInterstitial.h" |
#include "core/html/track/AudioTrack.h" |
#include "core/html/track/AudioTrackList.h" |
#include "core/html/track/AutomaticTrackSelection.h" |
@@ -466,6 +467,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, |
m_playingRemotely(false), |
m_inOverlayFullscreenVideo(false), |
m_mostlyFillingViewport(false), |
+ m_mediaRemotingDisabled(false), |
m_audioTracks(this, AudioTrackList::create(*this)), |
m_videoTracks(this, VideoTrackList::create(*this)), |
m_textTracks(this, nullptr), |
@@ -475,6 +477,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, |
m_autoplayVisibilityObserver(nullptr), |
m_mediaControls(nullptr), |
m_controlsList(HTMLMediaElementControlsList::create(this)), |
+ m_remotingInterstitial(nullptr), |
m_isPersistentVideo(false) { |
BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; |
@@ -624,7 +627,7 @@ void HTMLMediaElement::parseAttribute( |
// Please see: https://w3c.github.io/remote-playback |
UseCounter::count(document(), UseCounter::DisableRemotePlaybackAttribute); |
if (params.oldValue != params.newValue) { |
- if (m_webMediaPlayer) { |
+ if (m_webMediaPlayer && !m_mediaRemotingDisabled) { |
m_webMediaPlayer->requestRemotePlaybackDisabled( |
!params.newValue.isNull()); |
} |
@@ -3611,27 +3614,27 @@ bool HTMLMediaElement::textTracksVisible() const { |
return m_textTracksVisible; |
} |
-static void assertShadowRootChildren(ShadowRoot& shadowRoot) { |
+static void assertShadowRootChildren(ShadowRoot& shadowRoot, |
+ Node* mediaControls) { |
#if DCHECK_IS_ON() |
- // There can be up to two children, either or both of the text |
- // track container and media controls. If both are present, the |
- // text track container must be the first child. |
+ // There can be up to three children: text track container, media controls, |
+ // and media remoting UI. The |mediaControls| has to be the last child if |
+ // present. |
unsigned numberOfChildren = shadowRoot.countChildren(); |
- DCHECK_LE(numberOfChildren, 2u); |
+ DCHECK_LE(numberOfChildren, 3u); |
Node* firstChild = shadowRoot.firstChild(); |
- Node* lastChild = shadowRoot.lastChild(); |
if (numberOfChildren == 1) { |
DCHECK(firstChild->isTextTrackContainer() || firstChild->isMediaControls()); |
- } else if (numberOfChildren == 2) { |
- DCHECK(firstChild->isTextTrackContainer()); |
- DCHECK(lastChild->isMediaControls()); |
+ } else if (mediaControls) { |
+ Node* lastChild = shadowRoot.lastChild(); |
+ DCHECK(lastChild == mediaControls); |
} |
#endif |
} |
TextTrackContainer& HTMLMediaElement::ensureTextTrackContainer() { |
ShadowRoot& shadowRoot = ensureUserAgentShadowRoot(); |
- assertShadowRootChildren(shadowRoot); |
+ assertShadowRootChildren(shadowRoot, m_mediaControls); |
Node* firstChild = shadowRoot.firstChild(); |
if (firstChild && firstChild->isTextTrackContainer()) |
@@ -3644,7 +3647,7 @@ TextTrackContainer& HTMLMediaElement::ensureTextTrackContainer() { |
// so that they are rendered behind them. |
shadowRoot.insertBefore(textTrackContainer, firstChild); |
- assertShadowRootChildren(shadowRoot); |
+ assertShadowRootChildren(shadowRoot, m_mediaControls); |
return *textTrackContainer; |
} |
@@ -3756,7 +3759,7 @@ void HTMLMediaElement::ensureMediaControls() { |
// The media controls should be inserted after the text track container, |
// so that they are rendered in front of captions and subtitles. This check |
// is verifying the contract. |
- assertShadowRootChildren(shadowRoot); |
+ assertShadowRootChildren(shadowRoot, m_mediaControls); |
} |
void HTMLMediaElement::updateControlsVisibility() { |
@@ -3889,6 +3892,7 @@ DEFINE_TRACE(HTMLMediaElement) { |
visitor->trace(m_autoplayVisibilityObserver); |
visitor->trace(m_mediaControls); |
visitor->trace(m_controlsList); |
+ visitor->trace(m_remotingInterstitial); |
visitor->template registerWeakMembers<HTMLMediaElement, |
&HTMLMediaElement::clearWeakMembers>( |
this); |
@@ -4247,4 +4251,34 @@ void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { |
m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); |
} |
+void HTMLMediaElement::mediaRemotingStarted() { |
+ if (!m_remotingInterstitial) { |
+ m_remotingInterstitial = new MediaRemotingInterstitial(*this); |
+ ShadowRoot& shadowRoot = ensureUserAgentShadowRoot(); |
+ assertShadowRootChildren(shadowRoot, m_mediaControls); |
+ // Ensure the default mediaControls is the last child of the |shadowRoot|. |
+ Node* lastChild = shadowRoot.lastChild(); |
+ if (lastChild && lastChild->isMediaControls()) |
+ shadowRoot.insertBefore(m_remotingInterstitial, lastChild); |
+ else |
+ shadowRoot.appendChild(m_remotingInterstitial); |
+ assertShadowRootChildren(shadowRoot, m_mediaControls); |
+ } |
+ if (m_remotingInterstitial) |
+ m_remotingInterstitial->show(); |
+} |
+ |
+void HTMLMediaElement::mediaRemotingStopped() { |
+ if (m_remotingInterstitial) |
+ m_remotingInterstitial->hide(); |
+} |
+ |
+void HTMLMediaElement::disableMediaRemoting() { |
+ if (m_webMediaPlayer) |
+ m_webMediaPlayer->requestRemotePlaybackDisabled(true); |
+ m_mediaRemotingDisabled = true; |
+ if (m_remotingInterstitial) |
+ m_remotingInterstitial->hide(); |
+} |
+ |
} // namespace blink |