| 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_toggleClosedCaptionsButton(nullptr) | 111 , m_toggleClosedCaptionsButton(nullptr) |
| 112 , m_castButton(nullptr) | 112 , m_castButton(nullptr) |
| 113 , m_fullScreenButton(nullptr) | 113 , m_fullScreenButton(nullptr) |
| 114 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired
) | 114 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired
) |
| 115 , m_hideTimerBehaviorFlags(IgnoreNone) | 115 , m_hideTimerBehaviorFlags(IgnoreNone) |
| 116 , m_isMouseOverControls(false) | 116 , m_isMouseOverControls(false) |
| 117 , m_isPausedForScrubbing(false) | 117 , m_isPausedForScrubbing(false) |
| 118 , m_panelWidthChangedTimer(this, &MediaControls::panelWidthChangedTimerFired
) | 118 , m_panelWidthChangedTimer(this, &MediaControls::panelWidthChangedTimerFired
) |
| 119 , m_panelWidth(0) | 119 , m_panelWidth(0) |
| 120 , m_allowHiddenVolumeControls(RuntimeEnabledFeatures::newMediaPlaybackUiEnab
led()) | 120 , m_allowHiddenVolumeControls(RuntimeEnabledFeatures::newMediaPlaybackUiEnab
led()) |
| 121 , m_keepMuteButton(false) | |
| 122 { | 121 { |
| 123 } | 122 } |
| 124 | 123 |
| 125 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me
diaElement) | 124 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me
diaElement) |
| 126 { | 125 { |
| 127 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon
trols(mediaElement)); | 126 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon
trols(mediaElement)); |
| 128 controls->setShadowPseudoId(AtomicString("-webkit-media-controls", AtomicStr
ing::ConstructFromLiteral)); | 127 controls->setShadowPseudoId(AtomicString("-webkit-media-controls", AtomicStr
ing::ConstructFromLiteral)); |
| 129 controls->initializeControls(); | 128 controls->initializeControls(); |
| 130 return controls.release(); | 129 return controls.release(); |
| 131 } | 130 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 m_durationDisplay = durationDisplay.get(); | 193 m_durationDisplay = durationDisplay.get(); |
| 195 panel->appendChild(durationDisplay.release()); | 194 panel->appendChild(durationDisplay.release()); |
| 196 | 195 |
| 197 // Timeline is after the time / duration text if newMediaPlaybackUiEnabled. | 196 // Timeline is after the time / duration text if newMediaPlaybackUiEnabled. |
| 198 if (useNewUi) | 197 if (useNewUi) |
| 199 panel->appendChild(timeline.release()); | 198 panel->appendChild(timeline.release()); |
| 200 | 199 |
| 201 RefPtrWillBeRawPtr<MediaControlMuteButtonElement> muteButton = MediaControlM
uteButtonElement::create(*this); | 200 RefPtrWillBeRawPtr<MediaControlMuteButtonElement> muteButton = MediaControlM
uteButtonElement::create(*this); |
| 202 m_muteButton = muteButton.get(); | 201 m_muteButton = muteButton.get(); |
| 203 panel->appendChild(muteButton.release()); | 202 panel->appendChild(muteButton.release()); |
| 204 if (m_allowHiddenVolumeControls && preferHiddenVolumeControls(document())) | |
| 205 m_muteButton->setIsWanted(false); | |
| 206 | 203 |
| 207 RefPtrWillBeRawPtr<MediaControlVolumeSliderElement> slider = MediaControlVol
umeSliderElement::create(*this); | 204 RefPtrWillBeRawPtr<MediaControlVolumeSliderElement> slider = MediaControlVol
umeSliderElement::create(*this); |
| 208 m_volumeSlider = slider.get(); | 205 m_volumeSlider = slider.get(); |
| 209 panel->appendChild(slider.release()); | 206 panel->appendChild(slider.release()); |
| 210 if (m_allowHiddenVolumeControls && preferHiddenVolumeControls(document())) | 207 if (m_allowHiddenVolumeControls && preferHiddenVolumeControls(document())) |
| 211 m_volumeSlider->setIsWanted(false); | 208 m_volumeSlider->setIsWanted(false); |
| 212 | 209 |
| 213 RefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> toggleClos
edCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(*this); | 210 RefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> toggleClos
edCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(*this); |
| 214 m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.get(); | 211 m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.get(); |
| 215 panel->appendChild(toggleClosedCaptionsButton.release()); | 212 panel->appendChild(toggleClosedCaptionsButton.release()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 228 m_enclosure = enclosure.get(); | 225 m_enclosure = enclosure.get(); |
| 229 appendChild(enclosure.release()); | 226 appendChild(enclosure.release()); |
| 230 } | 227 } |
| 231 | 228 |
| 232 void MediaControls::reset() | 229 void MediaControls::reset() |
| 233 { | 230 { |
| 234 const bool useNewUi = RuntimeEnabledFeatures::newMediaPlaybackUiEnabled(); | 231 const bool useNewUi = RuntimeEnabledFeatures::newMediaPlaybackUiEnabled(); |
| 235 BatchedControlUpdate batch(this); | 232 BatchedControlUpdate batch(this); |
| 236 | 233 |
| 237 m_allowHiddenVolumeControls = useNewUi; | 234 m_allowHiddenVolumeControls = useNewUi; |
| 238 m_keepMuteButton = false; | |
| 239 | 235 |
| 240 const double duration = mediaElement().duration(); | 236 const double duration = mediaElement().duration(); |
| 241 m_durationDisplay->setInnerText(LayoutTheme::theme().formatMediaControlsTime
(duration), ASSERT_NO_EXCEPTION); | 237 m_durationDisplay->setInnerText(LayoutTheme::theme().formatMediaControlsTime
(duration), ASSERT_NO_EXCEPTION); |
| 242 m_durationDisplay->setCurrentValue(duration); | 238 m_durationDisplay->setCurrentValue(duration); |
| 243 | 239 |
| 244 if (useNewUi) { | 240 if (useNewUi) { |
| 245 // Show everything that we might hide. | 241 // Show everything that we might hide. |
| 246 // If we don't have a duration, then mark it to be hidden. For the | 242 // If we don't have a duration, then mark it to be hidden. For the |
| 247 // old UI case, want / don't want is the same as show / hide since | 243 // old UI case, want / don't want is the same as show / hide since |
| 248 // it is never marked as not fitting. | 244 // it is never marked as not fitting. |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 BatchedControlUpdate batch(this); | 432 BatchedControlUpdate batch(this); |
| 437 m_volumeSlider->setIsWanted(mediaElement().hasAudio() | 433 m_volumeSlider->setIsWanted(mediaElement().hasAudio() |
| 438 && !(m_allowHiddenVolumeControls && preferHiddenVolumeControls(document(
)))); | 434 && !(m_allowHiddenVolumeControls && preferHiddenVolumeControls(document(
)))); |
| 439 | 435 |
| 440 // The mute button is a little more complicated. If enableNewMediaPlaybackU
i | 436 // The mute button is a little more complicated. If enableNewMediaPlaybackU
i |
| 441 // is true, then we choose to hide or show the mute button to save space. | 437 // is true, then we choose to hide or show the mute button to save space. |
| 442 // If enableNew* is not set, then we never touch the mute button, and | 438 // If enableNew* is not set, then we never touch the mute button, and |
| 443 // instead leave it to the CSS. | 439 // instead leave it to the CSS. |
| 444 // Note that this is why m_allowHiddenVolumeControls isn't rolled into prefe
r...(). | 440 // Note that this is why m_allowHiddenVolumeControls isn't rolled into prefe
r...(). |
| 445 if (m_allowHiddenVolumeControls) { | 441 if (m_allowHiddenVolumeControls) { |
| 446 // If there is no audio track, then hide the mute button. If there | 442 // If there is no audio track, then hide the mute button. |
| 447 // is an audio track, then we always show the mute button unless | 443 m_muteButton->setIsWanted(mediaElement().hasAudio()); |
| 448 // we prefer to hide it and the media isn't muted. If it's muted, | |
| 449 // then we show it to let the user unmute it. In this case, we don't | |
| 450 // want to re-hide the mute button later. | |
| 451 m_keepMuteButton |= mediaElement().muted(); | |
| 452 m_muteButton->setIsWanted(mediaElement().hasAudio() | |
| 453 && (!preferHiddenVolumeControls(document()) || m_keepMuteButton)); | |
| 454 } | 444 } |
| 455 | 445 |
| 456 // Invalidate the volume slider because it paints differently according to v
olume. | 446 // Invalidate the volume slider because it paints differently according to v
olume. |
| 457 if (LayoutObject* layoutObject = m_volumeSlider->layoutObject()) | 447 if (LayoutObject* layoutObject = m_volumeSlider->layoutObject()) |
| 458 layoutObject->setShouldDoFullPaintInvalidation(); | 448 layoutObject->setShouldDoFullPaintInvalidation(); |
| 459 } | 449 } |
| 460 | 450 |
| 461 void MediaControls::changedClosedCaptionsVisibility() | 451 void MediaControls::changedClosedCaptionsVisibility() |
| 462 { | 452 { |
| 463 m_toggleClosedCaptionsButton->updateDisplayType(); | 453 m_toggleClosedCaptionsButton->updateDisplayType(); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 | 712 |
| 723 // Special case for cast: if we want a cast button but dropped it, then | 713 // Special case for cast: if we want a cast button but dropped it, then |
| 724 // show the overlay cast button instead. | 714 // show the overlay cast button instead. |
| 725 if (m_castButton->isWanted()) | 715 if (m_castButton->isWanted()) |
| 726 m_overlayCastButton->setIsWanted(droppedCastButton); | 716 m_overlayCastButton->setIsWanted(droppedCastButton); |
| 727 } | 717 } |
| 728 | 718 |
| 729 void MediaControls::setAllowHiddenVolumeControls(bool allow) | 719 void MediaControls::setAllowHiddenVolumeControls(bool allow) |
| 730 { | 720 { |
| 731 m_allowHiddenVolumeControls = allow; | 721 m_allowHiddenVolumeControls = allow; |
| 732 // Clear the 'keep muted flag', for tests. | |
| 733 m_keepMuteButton = false; | |
| 734 // Update the controls visibility. | 722 // Update the controls visibility. |
| 735 updateVolume(); | 723 updateVolume(); |
| 736 } | 724 } |
| 737 | 725 |
| 738 DEFINE_TRACE(MediaControls) | 726 DEFINE_TRACE(MediaControls) |
| 739 { | 727 { |
| 740 visitor->trace(m_mediaElement); | 728 visitor->trace(m_mediaElement); |
| 741 visitor->trace(m_panel); | 729 visitor->trace(m_panel); |
| 742 visitor->trace(m_overlayPlayButton); | 730 visitor->trace(m_overlayPlayButton); |
| 743 visitor->trace(m_overlayEnclosure); | 731 visitor->trace(m_overlayEnclosure); |
| 744 visitor->trace(m_playButton); | 732 visitor->trace(m_playButton); |
| 745 visitor->trace(m_currentTimeDisplay); | 733 visitor->trace(m_currentTimeDisplay); |
| 746 visitor->trace(m_timeline); | 734 visitor->trace(m_timeline); |
| 747 visitor->trace(m_muteButton); | 735 visitor->trace(m_muteButton); |
| 748 visitor->trace(m_volumeSlider); | 736 visitor->trace(m_volumeSlider); |
| 749 visitor->trace(m_toggleClosedCaptionsButton); | 737 visitor->trace(m_toggleClosedCaptionsButton); |
| 750 visitor->trace(m_fullScreenButton); | 738 visitor->trace(m_fullScreenButton); |
| 751 visitor->trace(m_durationDisplay); | 739 visitor->trace(m_durationDisplay); |
| 752 visitor->trace(m_enclosure); | 740 visitor->trace(m_enclosure); |
| 753 visitor->trace(m_castButton); | 741 visitor->trace(m_castButton); |
| 754 visitor->trace(m_overlayCastButton); | 742 visitor->trace(m_overlayCastButton); |
| 755 HTMLDivElement::trace(visitor); | 743 HTMLDivElement::trace(visitor); |
| 756 } | 744 } |
| 757 | 745 |
| 758 } | 746 } |
| OLD | NEW |