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..d8be96ee29478986bc45cda7975ec231421b29e0 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
@@ -3562,19 +3562,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 +3599,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); |