Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2767823002: Media Remoting: Add interstitial elements to media element shadow dom. (Closed)
Patch Set: Updated with new UX design. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3618 matching lines...) Expand 10 before | Expand all | Expand 10 after
3629 return true; 3629 return true;
3630 } 3630 }
3631 3631
3632 return false; 3632 return false;
3633 } 3633 }
3634 3634
3635 bool HTMLMediaElement::TextTracksVisible() const { 3635 bool HTMLMediaElement::TextTracksVisible() const {
3636 return text_tracks_visible_; 3636 return text_tracks_visible_;
3637 } 3637 }
3638 3638
3639 static void AssertShadowRootChildren(ShadowRoot& shadow_root) { 3639 // static
3640 void HTMLMediaElement::AssertShadowRootChildren(ShadowRoot& shadow_root) {
3640 #if DCHECK_IS_ON() 3641 #if DCHECK_IS_ON()
3641 // There can be up to two children, either or both of the text 3642 // There can be up to two children, either or both of the text
liberato (no reviews please) 2017/04/12 21:57:44 s/two/three/
xjz 2017/04/13 00:08:48 Done. Also rewrite the comment. I missed this afte
3642 // track container and media controls. If both are present, the 3643 // track container and media controls. If both are present, the
3643 // text track container must be the first child. 3644 // text track container must be the first child.
3644 unsigned number_of_children = shadow_root.CountChildren(); 3645 unsigned number_of_children = shadow_root.CountChildren();
3645 DCHECK_LE(number_of_children, 2u); 3646 DCHECK_LE(number_of_children, 3u);
3646 Node* first_child = shadow_root.FirstChild(); 3647 Node* first_child = shadow_root.FirstChild();
3647 Node* last_child = shadow_root.LastChild(); 3648 Node* last_child = shadow_root.LastChild();
3648 if (number_of_children == 1) { 3649 if (number_of_children == 1) {
3649 DCHECK(first_child->IsTextTrackContainer() || 3650 DCHECK(first_child->IsTextTrackContainer() ||
3650 first_child->IsMediaControls()); 3651 first_child->IsMediaControls() ||
3652 first_child->IsMediaRemotingInterstitial());
3651 } else if (number_of_children == 2) { 3653 } else if (number_of_children == 2) {
3652 DCHECK(first_child->IsTextTrackContainer()); 3654 DCHECK(first_child->IsTextTrackContainer() ||
3655 first_child->IsMediaRemotingInterstitial());
3656 DCHECK(last_child->IsTextTrackContainer() || last_child->IsMediaControls());
3657 if (first_child->IsTextTrackContainer())
3658 DCHECK(last_child->IsMediaControls());
3659 } else if (number_of_children == 3) {
3660 Node* second_child = first_child->nextSibling();
3661 DCHECK(first_child->IsMediaRemotingInterstitial());
3662 DCHECK(second_child->IsTextTrackContainer());
3653 DCHECK(last_child->IsMediaControls()); 3663 DCHECK(last_child->IsMediaControls());
3654 } 3664 }
3655 #endif 3665 #endif
3656 } 3666 }
3657 3667
3658 TextTrackContainer& HTMLMediaElement::EnsureTextTrackContainer() { 3668 TextTrackContainer& HTMLMediaElement::EnsureTextTrackContainer() {
3659 ShadowRoot& shadow_root = EnsureUserAgentShadowRoot(); 3669 ShadowRoot& shadow_root = EnsureUserAgentShadowRoot();
3660 AssertShadowRootChildren(shadow_root); 3670 AssertShadowRootChildren(shadow_root);
3661 3671
3662 Node* first_child = shadow_root.FirstChild(); 3672 Node* first_child = shadow_root.FirstChild();
3663 if (first_child && first_child->IsTextTrackContainer()) 3673 if (first_child && first_child->IsTextTrackContainer())
3664 return ToTextTrackContainer(*first_child); 3674 return ToTextTrackContainer(*first_child);
3675 Node* to_be_inserted = first_child;
3676
3677 if (first_child && first_child->IsMediaRemotingInterstitial()) {
3678 Node* second_child = first_child->nextSibling();
3679 if (second_child && second_child->IsTextTrackContainer())
3680 return ToTextTrackContainer(*second_child);
3681 to_be_inserted = second_child;
3682 }
3665 3683
3666 TextTrackContainer* text_track_container = TextTrackContainer::Create(*this); 3684 TextTrackContainer* text_track_container = TextTrackContainer::Create(*this);
3667 3685
3668 // The text track container should be inserted before the media controls, 3686 // The text track container should be inserted before the media controls,
3669 // so that they are rendered behind them. 3687 // so that they are rendered behind them.
3670 shadow_root.InsertBefore(text_track_container, first_child); 3688 shadow_root.InsertBefore(text_track_container, to_be_inserted);
3671 3689
3672 AssertShadowRootChildren(shadow_root); 3690 AssertShadowRootChildren(shadow_root);
3673 3691
3674 return *text_track_container; 3692 return *text_track_container;
3675 } 3693 }
3676 3694
3677 void HTMLMediaElement::UpdateTextTrackDisplay() { 3695 void HTMLMediaElement::UpdateTextTrackDisplay() {
3678 BLINK_MEDIA_LOG << "updateTextTrackDisplay(" << (void*)this << ")"; 3696 BLINK_MEDIA_LOG << "updateTextTrackDisplay(" << (void*)this << ")";
3679 3697
3680 EnsureTextTrackContainer().UpdateDisplay( 3698 EnsureTextTrackContainer().UpdateDisplay(
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
4268 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); 4286 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE);
4269 } 4287 }
4270 4288
4271 void HTMLMediaElement::ViewportFillDebouncerTimerFired(TimerBase*) { 4289 void HTMLMediaElement::ViewportFillDebouncerTimerFired(TimerBase*) {
4272 mostly_filling_viewport_ = true; 4290 mostly_filling_viewport_ = true;
4273 if (web_media_player_) 4291 if (web_media_player_)
4274 web_media_player_->BecameDominantVisibleContent(mostly_filling_viewport_); 4292 web_media_player_->BecameDominantVisibleContent(mostly_filling_viewport_);
4275 } 4293 }
4276 4294
4277 } // namespace blink 4295 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698