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 3619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3630 return true; | 3630 return true; |
3631 } | 3631 } |
3632 | 3632 |
3633 return false; | 3633 return false; |
3634 } | 3634 } |
3635 | 3635 |
3636 bool HTMLMediaElement::TextTracksVisible() const { | 3636 bool HTMLMediaElement::TextTracksVisible() const { |
3637 return text_tracks_visible_; | 3637 return text_tracks_visible_; |
3638 } | 3638 } |
3639 | 3639 |
3640 static void AssertShadowRootChildren(ShadowRoot& shadow_root) { | 3640 // static |
| 3641 void HTMLMediaElement::AssertShadowRootChildren(ShadowRoot& shadow_root) { |
3641 #if DCHECK_IS_ON() | 3642 #if DCHECK_IS_ON() |
3642 // There can be up to two children, either or both of the text | 3643 // There can be up to three children: media remoting interstitial, text track |
3643 // track container and media controls. If both are present, the | 3644 // container, and media controls. The media controls has to be the last child |
3644 // text track container must be the first child. | 3645 // if presend, and has to be the next sibling of the text track container if |
| 3646 // both present. When present, media remoting interstitial has to be the first |
| 3647 // child. |
3645 unsigned number_of_children = shadow_root.CountChildren(); | 3648 unsigned number_of_children = shadow_root.CountChildren(); |
3646 DCHECK_LE(number_of_children, 2u); | 3649 DCHECK_LE(number_of_children, 3u); |
3647 Node* first_child = shadow_root.FirstChild(); | 3650 Node* first_child = shadow_root.FirstChild(); |
3648 Node* last_child = shadow_root.LastChild(); | 3651 Node* last_child = shadow_root.LastChild(); |
3649 if (number_of_children == 1) { | 3652 if (number_of_children == 1) { |
3650 DCHECK(first_child->IsTextTrackContainer() || | 3653 DCHECK(first_child->IsTextTrackContainer() || |
3651 first_child->IsMediaControls()); | 3654 first_child->IsMediaControls() || |
| 3655 first_child->IsMediaRemotingInterstitial()); |
3652 } else if (number_of_children == 2) { | 3656 } else if (number_of_children == 2) { |
3653 DCHECK(first_child->IsTextTrackContainer()); | 3657 DCHECK(first_child->IsTextTrackContainer() || |
| 3658 first_child->IsMediaRemotingInterstitial()); |
| 3659 DCHECK(last_child->IsTextTrackContainer() || last_child->IsMediaControls()); |
| 3660 if (first_child->IsTextTrackContainer()) |
| 3661 DCHECK(last_child->IsMediaControls()); |
| 3662 } else if (number_of_children == 3) { |
| 3663 Node* second_child = first_child->nextSibling(); |
| 3664 DCHECK(first_child->IsMediaRemotingInterstitial()); |
| 3665 DCHECK(second_child->IsTextTrackContainer()); |
3654 DCHECK(last_child->IsMediaControls()); | 3666 DCHECK(last_child->IsMediaControls()); |
3655 } | 3667 } |
3656 #endif | 3668 #endif |
3657 } | 3669 } |
3658 | 3670 |
3659 TextTrackContainer& HTMLMediaElement::EnsureTextTrackContainer() { | 3671 TextTrackContainer& HTMLMediaElement::EnsureTextTrackContainer() { |
3660 ShadowRoot& shadow_root = EnsureUserAgentShadowRoot(); | 3672 ShadowRoot& shadow_root = EnsureUserAgentShadowRoot(); |
3661 AssertShadowRootChildren(shadow_root); | 3673 AssertShadowRootChildren(shadow_root); |
3662 | 3674 |
3663 Node* first_child = shadow_root.FirstChild(); | 3675 Node* first_child = shadow_root.FirstChild(); |
3664 if (first_child && first_child->IsTextTrackContainer()) | 3676 if (first_child && first_child->IsTextTrackContainer()) |
3665 return ToTextTrackContainer(*first_child); | 3677 return ToTextTrackContainer(*first_child); |
| 3678 Node* to_be_inserted = first_child; |
| 3679 |
| 3680 if (first_child && first_child->IsMediaRemotingInterstitial()) { |
| 3681 Node* second_child = first_child->nextSibling(); |
| 3682 if (second_child && second_child->IsTextTrackContainer()) |
| 3683 return ToTextTrackContainer(*second_child); |
| 3684 to_be_inserted = second_child; |
| 3685 } |
3666 | 3686 |
3667 TextTrackContainer* text_track_container = TextTrackContainer::Create(*this); | 3687 TextTrackContainer* text_track_container = TextTrackContainer::Create(*this); |
3668 | 3688 |
3669 // The text track container should be inserted before the media controls, | 3689 // The text track container should be inserted before the media controls, |
3670 // so that they are rendered behind them. | 3690 // so that they are rendered behind them. |
3671 shadow_root.InsertBefore(text_track_container, first_child); | 3691 shadow_root.InsertBefore(text_track_container, to_be_inserted); |
3672 | 3692 |
3673 AssertShadowRootChildren(shadow_root); | 3693 AssertShadowRootChildren(shadow_root); |
3674 | 3694 |
3675 return *text_track_container; | 3695 return *text_track_container; |
3676 } | 3696 } |
3677 | 3697 |
3678 void HTMLMediaElement::UpdateTextTrackDisplay() { | 3698 void HTMLMediaElement::UpdateTextTrackDisplay() { |
3679 BLINK_MEDIA_LOG << "updateTextTrackDisplay(" << (void*)this << ")"; | 3699 BLINK_MEDIA_LOG << "updateTextTrackDisplay(" << (void*)this << ")"; |
3680 | 3700 |
3681 EnsureTextTrackContainer().UpdateDisplay( | 3701 EnsureTextTrackContainer().UpdateDisplay( |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4269 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); | 4289 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); |
4270 } | 4290 } |
4271 | 4291 |
4272 void HTMLMediaElement::ViewportFillDebouncerTimerFired(TimerBase*) { | 4292 void HTMLMediaElement::ViewportFillDebouncerTimerFired(TimerBase*) { |
4273 mostly_filling_viewport_ = true; | 4293 mostly_filling_viewport_ = true; |
4274 if (web_media_player_) | 4294 if (web_media_player_) |
4275 web_media_player_->BecameDominantVisibleContent(mostly_filling_viewport_); | 4295 web_media_player_->BecameDominantVisibleContent(mostly_filling_viewport_); |
4276 } | 4296 } |
4277 | 4297 |
4278 } // namespace blink | 4298 } // namespace blink |
OLD | NEW |