 Chromium Code Reviews
 Chromium Code Reviews Issue 2767823002:
  Media Remoting: Add interstitial elements to media element shadow dom.  (Closed)
    
  
    Issue 2767823002:
  Media Remoting: Add interstitial elements to media element shadow dom.  (Closed) 
  | 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 aba444552a10ad8c40c4d51f4bace25aa00ea1fd..caf5e25c8a4eb09d3fb4831e4d822fc2d09b33a9 100644 | 
| --- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp | 
| +++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp | 
| @@ -617,7 +617,9 @@ void HTMLMediaElement::parseAttribute( | 
| // Please see: https://w3c.github.io/remote-playback | 
| UseCounter::count(document(), UseCounter::DisableRemotePlaybackAttribute); | 
| if (params.oldValue != params.newValue) { | 
| - if (m_webMediaPlayer) { | 
| + // Don't inform |m_webMediaPlayer| this change if Media Remoting is | 
| + // explicitly disabled by user. | 
| + if (m_webMediaPlayer && !isMediaRemotingDisabled()) { | 
| 
mlamouri (slow - plz ping)
2017/04/07 13:18:32
Instead of leaking the media remoting logic into H
 
xjz
2017/04/07 23:07:01
Done. Removed the check. Yes, this is already hand
 | 
| m_webMediaPlayer->requestRemotePlaybackDisabled( | 
| !params.newValue.isNull()); | 
| } | 
| @@ -3562,19 +3564,31 @@ bool HTMLMediaElement::textTracksVisible() const { | 
| return m_textTracksVisible; | 
| } | 
| -static void assertShadowRootChildren(ShadowRoot& shadowRoot) { | 
| +// static | 
| +void HTMLMediaElement::assertShadowRootChildren(ShadowRoot& shadowRoot) { | 
| #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: media remoting interstitial, text track | 
| + // container, media controls. The mediaControls has to be the last child if | 
| + // present, and has to be the next sibling of the text track container if both | 
| + // 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()); | 
| + DCHECK(firstChild->isTextTrackContainer() || | 
| + firstChild->isMediaControls() || | 
| + firstChild->isMediaRemotingInterstitial()); | 
| } else if (numberOfChildren == 2) { | 
| - DCHECK(firstChild->isTextTrackContainer()); | 
| + DCHECK(firstChild->isTextTrackContainer() || | 
| + firstChild->isMediaRemotingInterstitial()); | 
| + DCHECK(lastChild->isTextTrackContainer() || lastChild->isMediaControls()); | 
| + if (firstChild->isTextTrackContainer()) | 
| + DCHECK(lastChild->isMediaControls()); | 
| + } else if (numberOfChildren == 3) { | 
| + Node* secondChild = firstChild->nextSibling(); | 
| + DCHECK(firstChild->isMediaRemotingInterstitial()); | 
| + DCHECK(secondChild->isTextTrackContainer()); | 
| DCHECK(lastChild->isMediaControls()); | 
| } | 
| #endif | 
| @@ -3587,13 +3601,21 @@ TextTrackContainer& HTMLMediaElement::ensureTextTrackContainer() { | 
| Node* firstChild = shadowRoot.firstChild(); | 
| if (firstChild && firstChild->isTextTrackContainer()) | 
| return toTextTrackContainer(*firstChild); | 
| + Node* toBeInsertedBefore = firstChild; | 
| + | 
| + if (firstChild->isMediaRemotingInterstitial()) { | 
| + Node* secondChild = firstChild->nextSibling(); | 
| + if (secondChild && secondChild->isTextTrackContainer()) | 
| + return toTextTrackContainer(*secondChild); | 
| + toBeInsertedBefore = secondChild; | 
| + } | 
| TextTrackContainer* textTrackContainer = | 
| TextTrackContainer::create(document()); | 
| // The text track container should be inserted before the media controls, | 
| // so that they are rendered behind them. | 
| - shadowRoot.insertBefore(textTrackContainer, firstChild); | 
| + shadowRoot.insertBefore(textTrackContainer, toBeInsertedBefore); | 
| assertShadowRootChildren(shadowRoot); |