Commit 06af8b62 authored by liberato@chromium.org's avatar liberato@chromium.org

Enable mute button, even if preferring hidden volume slider.

Don't hide the mute button for anything with audio when using the new
media playback UI.  The old behavior is unchanged.

Note that on clank, we don't really know if an audio track is present,
so we always show the mute button.

BUG=521789

Review URL: https://codereview.chromium.org/1303553003

git-svn-id: svn://svn.chromium.org/blink/trunk@200908 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent bb1d48a2
......@@ -8,16 +8,13 @@ RUN(video.muted = false)
EXPECTED (getComputedStyle(muteButton).display != 'none') OK
EXPECTED (getComputedStyle(volumeSlider).display != 'none') OK
RUN(video.muted = true)
RUN(window.internals.setAllowHiddenVolumeControls(video, true))
EXPECTED (getComputedStyle(muteButton).display != 'none') OK
EXPECTED (getComputedStyle(volumeSlider).display != 'none') OK
RUN(window.internals.settings.setPreferHiddenVolumeControls(true))
RUN(video.muted = false)
RUN(window.internals.setAllowHiddenVolumeControls(video, true))
EXPECTED (getComputedStyle(muteButton).display == 'none') OK
EXPECTED (getComputedStyle(muteButton).display != 'none') OK
EXPECTED (getComputedStyle(volumeSlider).display == 'none') OK
RUN(video.muted = true)
RUN(window.internals.setAllowHiddenVolumeControls(video, true))
EXPECTED (getComputedStyle(muteButton).display != 'none') OK
EXPECTED (getComputedStyle(volumeSlider).display == 'none') OK
END OF TEST
......
......@@ -9,7 +9,7 @@
waitForEvent("canplaythrough", function () {
// Enable hidden audio preferences to take effect.
run("window.internals.setAllowHiddenVolumeControls(video, true)");
// Request non-hidden audio.
// Request non-hidden audio controls.
run("window.internals.settings.setPreferHiddenVolumeControls(false)");
run("video.muted = false");
muteButton = mediaControlsButton(video, "mute-button");
......@@ -19,11 +19,8 @@
testExpected("getComputedStyle(muteButton).display", "none", '!=');
testExpected("getComputedStyle(volumeSlider).display", "none", '!=');
// Switch to muted video. Both should still be visible. We then
// remind it that we'd like to allow hidden audio preferences, since
// that also resets some state.
// Switch to muted video. Both should still be visible.
run("video.muted = true");
run("window.internals.setAllowHiddenVolumeControls(video, true)");
testExpected("getComputedStyle(muteButton).display", "none", '!=');
testExpected("getComputedStyle(volumeSlider).display", "none", '!=');
......@@ -31,15 +28,14 @@
// Switch back to unmuted video.
run("video.muted = false");
run("window.internals.setAllowHiddenVolumeControls(video, true)");
testExpected("getComputedStyle(muteButton).display", "none", '==');
testExpected("getComputedStyle(muteButton).display", "none", '!=');
testExpected("getComputedStyle(volumeSlider).display", "none", '==');
// For muted video, the volume slider will hide but the mute
// button should come back, to let the user unmute.
// button should stay, since we always have it present for media
// which have audio.
run("video.muted = true");
run("window.internals.setAllowHiddenVolumeControls(video, true)");
testExpected("getComputedStyle(muteButton).display", "none", '!=');
testExpected("getComputedStyle(volumeSlider).display", "none", '==');
......
......@@ -118,7 +118,6 @@ MediaControls::MediaControls(HTMLMediaElement& mediaElement)
, m_panelWidthChangedTimer(this, &MediaControls::panelWidthChangedTimerFired)
, m_panelWidth(0)
, m_allowHiddenVolumeControls(RuntimeEnabledFeatures::newMediaPlaybackUiEnabled())
, m_keepMuteButton(false)
{
}
......@@ -201,8 +200,6 @@ void MediaControls::initializeControls()
RefPtrWillBeRawPtr<MediaControlMuteButtonElement> muteButton = MediaControlMuteButtonElement::create(*this);
m_muteButton = muteButton.get();
panel->appendChild(muteButton.release());
if (m_allowHiddenVolumeControls && preferHiddenVolumeControls(document()))
m_muteButton->setIsWanted(false);
RefPtrWillBeRawPtr<MediaControlVolumeSliderElement> slider = MediaControlVolumeSliderElement::create(*this);
m_volumeSlider = slider.get();
......@@ -235,7 +232,6 @@ void MediaControls::reset()
BatchedControlUpdate batch(this);
m_allowHiddenVolumeControls = useNewUi;
m_keepMuteButton = false;
const double duration = mediaElement().duration();
m_durationDisplay->setInnerText(LayoutTheme::theme().formatMediaControlsTime(duration), ASSERT_NO_EXCEPTION);
......@@ -443,14 +439,8 @@ void MediaControls::updateVolume()
// instead leave it to the CSS.
// Note that this is why m_allowHiddenVolumeControls isn't rolled into prefer...().
if (m_allowHiddenVolumeControls) {
// If there is no audio track, then hide the mute button. If there
// is an audio track, then we always show the mute button unless
// we prefer to hide it and the media isn't muted. If it's muted,
// then we show it to let the user unmute it. In this case, we don't
// want to re-hide the mute button later.
m_keepMuteButton |= mediaElement().muted();
m_muteButton->setIsWanted(mediaElement().hasAudio()
&& (!preferHiddenVolumeControls(document()) || m_keepMuteButton));
// If there is no audio track, then hide the mute button.
m_muteButton->setIsWanted(mediaElement().hasAudio());
}
// Invalidate the volume slider because it paints differently according to volume.
......@@ -729,8 +719,6 @@ void MediaControls::computeWhichControlsFit()
void MediaControls::setAllowHiddenVolumeControls(bool allow)
{
m_allowHiddenVolumeControls = allow;
// Clear the 'keep muted flag', for tests.
m_keepMuteButton = false;
// Update the controls visibility.
updateVolume();
}
......
......@@ -152,7 +152,6 @@ private:
int m_panelWidth;
bool m_allowHiddenVolumeControls : 1;
bool m_keepMuteButton : 1;
};
DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment