OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. |
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2011, 2012 Google Inc. All rights 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 , m_panel(nullptr) | 111 , m_panel(nullptr) |
112 , m_playButton(nullptr) | 112 , m_playButton(nullptr) |
113 , m_timeline(nullptr) | 113 , m_timeline(nullptr) |
114 , m_currentTimeDisplay(nullptr) | 114 , m_currentTimeDisplay(nullptr) |
115 , m_durationDisplay(nullptr) | 115 , m_durationDisplay(nullptr) |
116 , m_muteButton(nullptr) | 116 , m_muteButton(nullptr) |
117 , m_volumeSlider(nullptr) | 117 , m_volumeSlider(nullptr) |
118 , m_toggleClosedCaptionsButton(nullptr) | 118 , m_toggleClosedCaptionsButton(nullptr) |
119 , m_textTrackList(nullptr) | 119 , m_textTrackList(nullptr) |
120 , m_castButton(nullptr) | 120 , m_castButton(nullptr) |
121 , m_fullScreenButton(nullptr) | 121 , m_fullscreenButton(nullptr) |
122 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired
) | 122 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired
) |
123 , m_hideTimerBehaviorFlags(IgnoreNone) | 123 , m_hideTimerBehaviorFlags(IgnoreNone) |
124 , m_isMouseOverControls(false) | 124 , m_isMouseOverControls(false) |
125 , m_isPausedForScrubbing(false) | 125 , m_isPausedForScrubbing(false) |
126 , m_panelWidthChangedTimer(this, &MediaControls::panelWidthChangedTimerFired
) | 126 , m_panelWidthChangedTimer(this, &MediaControls::panelWidthChangedTimerFired
) |
127 , m_panelWidth(0) | 127 , m_panelWidth(0) |
128 , m_allowHiddenVolumeControls(RuntimeEnabledFeatures::newMediaPlaybackUiEnab
led()) | 128 , m_allowHiddenVolumeControls(RuntimeEnabledFeatures::newMediaPlaybackUiEnab
led()) |
129 { | 129 { |
130 } | 130 } |
131 | 131 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 MediaControlToggleClosedCaptionsButtonElement* toggleClosedCaptionsButton =
MediaControlToggleClosedCaptionsButtonElement::create(*this); | 224 MediaControlToggleClosedCaptionsButtonElement* toggleClosedCaptionsButton =
MediaControlToggleClosedCaptionsButtonElement::create(*this); |
225 m_toggleClosedCaptionsButton = toggleClosedCaptionsButton; | 225 m_toggleClosedCaptionsButton = toggleClosedCaptionsButton; |
226 panel->appendChild(toggleClosedCaptionsButton); | 226 panel->appendChild(toggleClosedCaptionsButton); |
227 | 227 |
228 MediaControlCastButtonElement* castButton = MediaControlCastButtonElement::c
reate(*this, false); | 228 MediaControlCastButtonElement* castButton = MediaControlCastButtonElement::c
reate(*this, false); |
229 m_castButton = castButton; | 229 m_castButton = castButton; |
230 panel->appendChild(castButton); | 230 panel->appendChild(castButton); |
231 | 231 |
232 MediaControlFullscreenButtonElement* fullscreenButton = MediaControlFullscre
enButtonElement::create(*this); | 232 MediaControlFullscreenButtonElement* fullscreenButton = MediaControlFullscre
enButtonElement::create(*this); |
233 m_fullScreenButton = fullscreenButton; | 233 m_fullscreenButton = fullscreenButton; |
234 panel->appendChild(fullscreenButton); | 234 panel->appendChild(fullscreenButton); |
235 | 235 |
236 m_panel = panel; | 236 m_panel = panel; |
237 enclosure->appendChild(panel); | 237 enclosure->appendChild(panel); |
238 | 238 |
239 m_enclosure = enclosure; | 239 m_enclosure = enclosure; |
240 appendChild(enclosure); | 240 appendChild(enclosure); |
241 | 241 |
242 MediaControlTextTrackListElement* textTrackList = MediaControlTextTrackListE
lement::create(*this); | 242 MediaControlTextTrackListElement* textTrackList = MediaControlTextTrackListE
lement::create(*this); |
243 m_textTrackList = textTrackList; | 243 m_textTrackList = textTrackList; |
(...skipping 30 matching lines...) Expand all Loading... |
274 | 274 |
275 updateCurrentTimeDisplay(); | 275 updateCurrentTimeDisplay(); |
276 | 276 |
277 m_timeline->setDuration(duration); | 277 m_timeline->setDuration(duration); |
278 m_timeline->setPosition(mediaElement().currentTime()); | 278 m_timeline->setPosition(mediaElement().currentTime()); |
279 | 279 |
280 updateVolume(); | 280 updateVolume(); |
281 | 281 |
282 refreshClosedCaptionsButtonVisibility(); | 282 refreshClosedCaptionsButtonVisibility(); |
283 | 283 |
284 m_fullScreenButton->setIsWanted(shouldShowFullscreenButton(mediaElement())); | 284 m_fullscreenButton->setIsWanted(shouldShowFullscreenButton(mediaElement())); |
285 | 285 |
286 refreshCastButtonVisibilityWithoutUpdate(); | 286 refreshCastButtonVisibilityWithoutUpdate(); |
287 } | 287 } |
288 | 288 |
289 LayoutObject* MediaControls::layoutObjectForTextTrackLayout() | 289 LayoutObject* MediaControls::layoutObjectForTextTrackLayout() |
290 { | 290 { |
291 return m_panel->layoutObject(); | 291 return m_panel->layoutObject(); |
292 } | 292 } |
293 | 293 |
294 void MediaControls::show() | 294 void MediaControls::show() |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 // overlay cast button if it needs to hide it from the panel. | 514 // overlay cast button if it needs to hide it from the panel. |
515 m_overlayCastButton->tryShowOverlay(); | 515 m_overlayCastButton->tryShowOverlay(); |
516 m_castButton->setIsWanted(false); | 516 m_castButton->setIsWanted(false); |
517 } else if (mediaElement().shouldShowControls()) { | 517 } else if (mediaElement().shouldShowControls()) { |
518 m_overlayCastButton->setIsWanted(false); | 518 m_overlayCastButton->setIsWanted(false); |
519 m_castButton->setIsWanted(true); | 519 m_castButton->setIsWanted(true); |
520 // Check that the cast button actually fits on the bar. For the | 520 // Check that the cast button actually fits on the bar. For the |
521 // newMediaPlaybackUiEnabled case, we let computeWhichControlsFit() | 521 // newMediaPlaybackUiEnabled case, we let computeWhichControlsFit() |
522 // handle this. | 522 // handle this. |
523 if ( !RuntimeEnabledFeatures::newMediaPlaybackUiEnabled() | 523 if ( !RuntimeEnabledFeatures::newMediaPlaybackUiEnabled() |
524 && m_fullScreenButton->getBoundingClientRect()->right() > m_panel->g
etBoundingClientRect()->right()) { | 524 && m_fullscreenButton->getBoundingClientRect()->right() > m_panel->g
etBoundingClientRect()->right()) { |
525 m_castButton->setIsWanted(false); | 525 m_castButton->setIsWanted(false); |
526 m_overlayCastButton->tryShowOverlay(); | 526 m_overlayCastButton->tryShowOverlay(); |
527 } | 527 } |
528 } | 528 } |
529 } | 529 } |
530 | 530 |
531 void MediaControls::showOverlayCastButtonIfNeeded() | 531 void MediaControls::showOverlayCastButtonIfNeeded() |
532 { | 532 { |
533 if (mediaElement().shouldShowControls() || !shouldShowCastButton(mediaElemen
t())) | 533 if (mediaElement().shouldShowControls() || !shouldShowCastButton(mediaElemen
t())) |
534 return; | 534 return; |
535 | 535 |
536 m_overlayCastButton->tryShowOverlay(); | 536 m_overlayCastButton->tryShowOverlay(); |
537 resetHideMediaControlsTimer(); | 537 resetHideMediaControlsTimer(); |
538 } | 538 } |
539 | 539 |
540 void MediaControls::enteredFullscreen() | 540 void MediaControls::enteredFullscreen() |
541 { | 541 { |
542 m_fullScreenButton->setIsFullscreen(true); | 542 m_fullscreenButton->setIsFullscreen(true); |
543 stopHideMediaControlsTimer(); | 543 stopHideMediaControlsTimer(); |
544 startHideMediaControlsTimer(); | 544 startHideMediaControlsTimer(); |
545 } | 545 } |
546 | 546 |
547 void MediaControls::exitedFullscreen() | 547 void MediaControls::exitedFullscreen() |
548 { | 548 { |
549 m_fullScreenButton->setIsFullscreen(false); | 549 m_fullscreenButton->setIsFullscreen(false); |
550 stopHideMediaControlsTimer(); | 550 stopHideMediaControlsTimer(); |
551 startHideMediaControlsTimer(); | 551 startHideMediaControlsTimer(); |
552 } | 552 } |
553 | 553 |
554 void MediaControls::startedCasting() | 554 void MediaControls::startedCasting() |
555 { | 555 { |
556 m_castButton->setIsPlayingRemotely(true); | 556 m_castButton->setIsPlayingRemotely(true); |
557 m_overlayCastButton->setIsPlayingRemotely(true); | 557 m_overlayCastButton->setIsPlayingRemotely(true); |
558 } | 558 } |
559 | 559 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 // Hide all controls that don't fit, and show the ones that do. | 682 // Hide all controls that don't fit, and show the ones that do. |
683 // This might be better suited for a layout, but since JS media controls | 683 // This might be better suited for a layout, but since JS media controls |
684 // won't benefit from that anwyay, we just do it here like JS will. | 684 // won't benefit from that anwyay, we just do it here like JS will. |
685 | 685 |
686 if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) | 686 if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) |
687 return; | 687 return; |
688 | 688 |
689 // Controls that we'll hide / show, in order of decreasing priority. | 689 // Controls that we'll hide / show, in order of decreasing priority. |
690 MediaControlElement* elements[] = { | 690 MediaControlElement* elements[] = { |
691 // Exclude m_playButton; we handle it specially. | 691 // Exclude m_playButton; we handle it specially. |
692 m_fullScreenButton.get(), | 692 m_fullscreenButton.get(), |
693 m_toggleClosedCaptionsButton.get(), | 693 m_toggleClosedCaptionsButton.get(), |
694 m_timeline.get(), | 694 m_timeline.get(), |
695 m_currentTimeDisplay.get(), | 695 m_currentTimeDisplay.get(), |
696 m_volumeSlider.get(), | 696 m_volumeSlider.get(), |
697 m_castButton.get(), | 697 m_castButton.get(), |
698 m_muteButton.get(), | 698 m_muteButton.get(), |
699 m_durationDisplay.get(), | 699 m_durationDisplay.get(), |
700 }; | 700 }; |
701 | 701 |
702 int usedWidth = 0; | 702 int usedWidth = 0; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 | 772 |
773 if (LayoutObject* layoutObject = element->layoutObject()) | 773 if (LayoutObject* layoutObject = element->layoutObject()) |
774 layoutObject->setShouldDoFullPaintInvalidation(); | 774 layoutObject->setShouldDoFullPaintInvalidation(); |
775 } | 775 } |
776 | 776 |
777 void MediaControls::networkStateChanged() | 777 void MediaControls::networkStateChanged() |
778 { | 778 { |
779 invalidate(m_playButton); | 779 invalidate(m_playButton); |
780 invalidate(m_overlayPlayButton); | 780 invalidate(m_overlayPlayButton); |
781 invalidate(m_muteButton); | 781 invalidate(m_muteButton); |
782 invalidate(m_fullScreenButton); | 782 invalidate(m_fullscreenButton); |
783 invalidate(m_timeline); | 783 invalidate(m_timeline); |
784 invalidate(m_volumeSlider); | 784 invalidate(m_volumeSlider); |
785 } | 785 } |
786 | 786 |
787 DEFINE_TRACE(MediaControls) | 787 DEFINE_TRACE(MediaControls) |
788 { | 788 { |
789 visitor->trace(m_mediaElement); | 789 visitor->trace(m_mediaElement); |
790 visitor->trace(m_panel); | 790 visitor->trace(m_panel); |
791 visitor->trace(m_overlayPlayButton); | 791 visitor->trace(m_overlayPlayButton); |
792 visitor->trace(m_overlayEnclosure); | 792 visitor->trace(m_overlayEnclosure); |
793 visitor->trace(m_playButton); | 793 visitor->trace(m_playButton); |
794 visitor->trace(m_currentTimeDisplay); | 794 visitor->trace(m_currentTimeDisplay); |
795 visitor->trace(m_timeline); | 795 visitor->trace(m_timeline); |
796 visitor->trace(m_muteButton); | 796 visitor->trace(m_muteButton); |
797 visitor->trace(m_volumeSlider); | 797 visitor->trace(m_volumeSlider); |
798 visitor->trace(m_toggleClosedCaptionsButton); | 798 visitor->trace(m_toggleClosedCaptionsButton); |
799 visitor->trace(m_fullScreenButton); | 799 visitor->trace(m_fullscreenButton); |
800 visitor->trace(m_durationDisplay); | 800 visitor->trace(m_durationDisplay); |
801 visitor->trace(m_enclosure); | 801 visitor->trace(m_enclosure); |
802 visitor->trace(m_textTrackList); | 802 visitor->trace(m_textTrackList); |
803 visitor->trace(m_castButton); | 803 visitor->trace(m_castButton); |
804 visitor->trace(m_overlayCastButton); | 804 visitor->trace(m_overlayCastButton); |
805 HTMLDivElement::trace(visitor); | 805 HTMLDivElement::trace(visitor); |
806 } | 806 } |
807 | 807 |
808 } // namespace blink | 808 } // namespace blink |
OLD | NEW |