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