Commit 1c2f02d1 authored by eric@webkit.org's avatar eric@webkit.org

2009-08-25 Alpha Lam <hclam@chromium.org>

        Reviewed by David Levin.

        Media controls panel does not have a volume control slider
        https://bugs.webkit.org/show_bug.cgi?id=28241

        Introduced "-webkit-media-controls-volume-slider",
        "-webkit-media-controls-volume-slider-container" and the supporting
        implementation. Also added appearances of "media-volume-slider" and
        "media-volume-slider-container".

        The implementation of the controls are in WebCore::MediaControlElements.
        Logic to trigger the display of the volume controls are in WebCore::RenderMedia.

        No new tests since this change doesn't have theme implementation and the
        volume slider is disabled by default.

        * accessibility/AccessibilitySlider.cpp:
        (WebCore::AccessibilitySlider::orientation): Marks that volume slider is vertical.
        * css/CSSPrimitiveValueMappings.h:
        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added corresponding CSS values.
        * css/CSSSelector.cpp:
        (WebCore::CSSSelector::extractPseudoType): ditto.
        * css/CSSSelector.h:
        (WebCore::CSSSelector::): ditto.
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): ditto.
        * css/CSSValueKeywords.in: ditto.
        * css/mediaControls.css: Makes the volume slider disabled by default.
        * platform/ThemeTypes.h: Defines theme parts for volume slider and its container.
        (WebCore::):
        * rendering/MediaControlElements.cpp:
        (WebCore::MediaControlVolumeSliderContainerElement::MediaControlVolumeSliderContainerElement):
        (WebCore::MediaControlVolumeSliderContainerElement::styleForElement):
        Adjust the CSS values for "display", "postion", "left" and "top" according to member variables.
        (WebCore::MediaControlVolumeSliderContainerElement::setVisible): Affects the "display" CSS value.
        (WebCore::MediaControlVolumeSliderContainerElement::setPosition): Affects the "left" and "top" CSS values.
        (WebCore::MediaControlVolumeSliderContainerElement::hitTest): Hit testing this element.
        (WebCore::MediaControlVolumeSliderElement::MediaControlVolumeSliderElement):
        (WebCore::MediaControlVolumeSliderElement::defaultEventHandler): Modifies the volume using the slider value, allows dragging.
        * rendering/MediaControlElements.h:
        (WebCore::): Added definition for MediaControlVolumeSliderElement and MediaControlVolumeSliderContainerElement.
        (WebCore::MediaControlVolumeSliderContainerElement::isVisible): Inline getter.
        * rendering/RenderMedia.cpp:
        (WebCore::RenderMedia::styleDidChange): Updates styles for volume container and volume slider.
        (WebCore::RenderMedia::createVolumeSliderContainer): Creates volume slider container and attach to panel.
        (WebCore::RenderMedia::createVolumeSlider): Creates volume slider and attach to volume slider container.
        (WebCore::RenderMedia::updateControls): Updates volume container and volume slider.
        (WebCore::RenderMedia::updateVolumeSliderContainer): Sets the visibility and position of volume slider container and its child.
        (WebCore::RenderMedia::forwardEvent):
        Hit testing the volume slider container and volume slider to toggle the visibility and forward events to slider.
        * rendering/RenderMedia.h:
        Added definition for RenderMedia::updateVolumeSliderContainer().
        * rendering/RenderMediaControls.cpp:
        (WebCore::RenderMediaControls::paintMediaControlsPart): Not implemented.
        * rendering/RenderSlider.cpp:
        (WebCore::RenderSlider::createThumbStyle): Makes volume slider vertical.
        (WebCore::RenderSlider::thumbRect): ditto.
        (WebCore::RenderSlider::mouseEventIsInThumb): ditto.
        (WebCore::RenderSlider::setValueForPosition): ditto.
        (WebCore::RenderSlider::positionForOffset): ditto.
        (WebCore::RenderSlider::currentPosition): ditto.
        (WebCore::RenderSlider::trackSize): ditto.
        * rendering/RenderTheme.cpp:
        (WebCore::RenderTheme::adjustStyle): Adjust style for volume slider thumb.
        (WebCore::RenderTheme::paint): Paints volume control parts using theme.
        * rendering/RenderTheme.h:
        (WebCore::RenderTheme::paintMediaVolumeSliderContainer): Naive implementation to be overridden.
        (WebCore::RenderTheme::paintMediaVolumeSliderTrack): ditto.
        (WebCore::RenderTheme::paintMediaVolumeSliderThumb): ditto.
        * rendering/style/RenderStyleConstants.h:
        (WebCore::): Constants for volume control parts.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47744 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5037ce75
2009-08-25 Alpha Lam <hclam@chromium.org>
Reviewed by David Levin.
Media controls panel does not have a volume control slider
https://bugs.webkit.org/show_bug.cgi?id=28241
Introduced "-webkit-media-controls-volume-slider",
"-webkit-media-controls-volume-slider-container" and the supporting
implementation. Also added appearances of "media-volume-slider" and
"media-volume-slider-container".
The implementation of the controls are in WebCore::MediaControlElements.
Logic to trigger the display of the volume controls are in WebCore::RenderMedia.
No new tests since this change doesn't have theme implementation and the
volume slider is disabled by default.
* accessibility/AccessibilitySlider.cpp:
(WebCore::AccessibilitySlider::orientation): Marks that volume slider is vertical.
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added corresponding CSS values.
* css/CSSSelector.cpp:
(WebCore::CSSSelector::extractPseudoType): ditto.
* css/CSSSelector.h:
(WebCore::CSSSelector::): ditto.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): ditto.
* css/CSSValueKeywords.in: ditto.
* css/mediaControls.css: Makes the volume slider disabled by default.
* platform/ThemeTypes.h: Defines theme parts for volume slider and its container.
(WebCore::):
* rendering/MediaControlElements.cpp:
(WebCore::MediaControlVolumeSliderContainerElement::MediaControlVolumeSliderContainerElement):
(WebCore::MediaControlVolumeSliderContainerElement::styleForElement):
Adjust the CSS values for "display", "postion", "left" and "top" according to member variables.
(WebCore::MediaControlVolumeSliderContainerElement::setVisible): Affects the "display" CSS value.
(WebCore::MediaControlVolumeSliderContainerElement::setPosition): Affects the "left" and "top" CSS values.
(WebCore::MediaControlVolumeSliderContainerElement::hitTest): Hit testing this element.
(WebCore::MediaControlVolumeSliderElement::MediaControlVolumeSliderElement):
(WebCore::MediaControlVolumeSliderElement::defaultEventHandler): Modifies the volume using the slider value, allows dragging.
* rendering/MediaControlElements.h:
(WebCore::): Added definition for MediaControlVolumeSliderElement and MediaControlVolumeSliderContainerElement.
(WebCore::MediaControlVolumeSliderContainerElement::isVisible): Inline getter.
* rendering/RenderMedia.cpp:
(WebCore::RenderMedia::styleDidChange): Updates styles for volume container and volume slider.
(WebCore::RenderMedia::createVolumeSliderContainer): Creates volume slider container and attach to panel.
(WebCore::RenderMedia::createVolumeSlider): Creates volume slider and attach to volume slider container.
(WebCore::RenderMedia::updateControls): Updates volume container and volume slider.
(WebCore::RenderMedia::updateVolumeSliderContainer): Sets the visibility and position of volume slider container and its child.
(WebCore::RenderMedia::forwardEvent):
Hit testing the volume slider container and volume slider to toggle the visibility and forward events to slider.
* rendering/RenderMedia.h:
Added definition for RenderMedia::updateVolumeSliderContainer().
* rendering/RenderMediaControls.cpp:
(WebCore::RenderMediaControls::paintMediaControlsPart): Not implemented.
* rendering/RenderSlider.cpp:
(WebCore::RenderSlider::createThumbStyle): Makes volume slider vertical.
(WebCore::RenderSlider::thumbRect): ditto.
(WebCore::RenderSlider::mouseEventIsInThumb): ditto.
(WebCore::RenderSlider::setValueForPosition): ditto.
(WebCore::RenderSlider::positionForOffset): ditto.
(WebCore::RenderSlider::currentPosition): ditto.
(WebCore::RenderSlider::trackSize): ditto.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::adjustStyle): Adjust style for volume slider thumb.
(WebCore::RenderTheme::paint): Paints volume control parts using theme.
* rendering/RenderTheme.h:
(WebCore::RenderTheme::paintMediaVolumeSliderContainer): Naive implementation to be overridden.
(WebCore::RenderTheme::paintMediaVolumeSliderTrack): ditto.
(WebCore::RenderTheme::paintMediaVolumeSliderThumb): ditto.
* rendering/style/RenderStyleConstants.h:
(WebCore::): Constants for volume control parts.
2009-08-25 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
Reviewed by Ariya Hidayat.
......@@ -75,6 +75,7 @@ AccessibilityOrientation AccessibilitySlider::orientation() const
case SliderThumbVerticalPart:
case SliderVerticalPart:
case MediaVolumeSliderPart:
return AccessibilityOrientationVertical;
default:
......
......@@ -228,6 +228,15 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e)
case MediaSliderThumbPart:
m_value.ident = CSSValueMediaSliderthumb;
break;
case MediaVolumeSliderContainerPart:
m_value.ident = CSSValueMediaVolumeSliderContainer;
break;
case MediaVolumeSliderPart:
m_value.ident = CSSValueMediaVolumeSlider;
break;
case MediaVolumeSliderThumbPart:
m_value.ident = CSSValueMediaVolumeSliderthumb;
break;
case MediaControlsBackgroundPart:
m_value.ident = CSSValueMediaControlsBackground;
break;
......
......@@ -108,6 +108,7 @@ void CSSSelector::extractPseudoType() const
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsMuteButton, ("-webkit-media-controls-mute-button"));
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsPlayButton, ("-webkit-media-controls-play-button"));
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsTimeline, ("-webkit-media-controls-timeline"));
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsVolumeSlider, ("-webkit-media-controls-volume-slider"));
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsSeekBackButton, ("-webkit-media-controls-seek-back-button"));
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsSeekForwardButton, ("-webkit-media-controls-seek-forward-button"));
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsRewindButton, ("-webkit-media-controls-rewind-button"));
......@@ -115,6 +116,7 @@ void CSSSelector::extractPseudoType() const
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsStatusDisplay, ("-webkit-media-controls-status-display"));
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsFullscreenButton, ("-webkit-media-controls-fullscreen-button"));
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsTimelineContainer, ("-webkit-media-controls-timeline-container"));
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsVolumeSliderContainer, ("-webkit-media-controls-volume-slider-container"));
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsCurrentTimeDisplay, ("-webkit-media-controls-current-time-display"));
DEFINE_STATIC_LOCAL(AtomicString, mediaControlsTimeRemainingDisplay, ("-webkit-media-controls-time-remaining-display"));
DEFINE_STATIC_LOCAL(AtomicString, notStr, ("not("));
......@@ -244,6 +246,9 @@ void CSSSelector::extractPseudoType() const
} else if (m_value == mediaControlsTimeline) {
m_pseudoType = PseudoMediaControlsTimeline;
element = true;
} else if (m_value == mediaControlsVolumeSlider) {
m_pseudoType = PseudoMediaControlsVolumeSlider;
element = true;
} else if (m_value == mediaControlsSeekBackButton) {
m_pseudoType = PseudoMediaControlsSeekBackButton;
element = true;
......@@ -265,6 +270,9 @@ void CSSSelector::extractPseudoType() const
} else if (m_value == mediaControlsTimelineContainer) {
m_pseudoType = PseudoMediaControlsTimelineContainer;
element = true;
} else if (m_value == mediaControlsVolumeSliderContainer) {
m_pseudoType = PseudoMediaControlsVolumeSliderContainer;
element = true;
} else if (m_value == notStr)
m_pseudoType = PseudoNot;
else if (m_value == nthChild)
......
......@@ -173,9 +173,11 @@ namespace WebCore {
PseudoMediaControlsMuteButton,
PseudoMediaControlsPlayButton,
PseudoMediaControlsTimelineContainer,
PseudoMediaControlsVolumeSliderContainer,
PseudoMediaControlsCurrentTimeDisplay,
PseudoMediaControlsTimeRemainingDisplay,
PseudoMediaControlsTimeline,
PseudoMediaControlsVolumeSlider,
PseudoMediaControlsSeekBackButton,
PseudoMediaControlsSeekForwardButton,
PseudoMediaControlsRewindButton,
......
......@@ -2507,7 +2507,10 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
return true;
case CSSSelector::PseudoMediaControlsTimelineContainer:
dynamicPseudo = MEDIA_CONTROLS_TIMELINE_CONTAINER;
return true;
return true;
case CSSSelector::PseudoMediaControlsVolumeSliderContainer:
dynamicPseudo = MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER;
return true;
case CSSSelector::PseudoMediaControlsCurrentTimeDisplay:
dynamicPseudo = MEDIA_CONTROLS_CURRENT_TIME_DISPLAY;
return true;
......@@ -2517,6 +2520,9 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
case CSSSelector::PseudoMediaControlsTimeline:
dynamicPseudo = MEDIA_CONTROLS_TIMELINE;
return true;
case CSSSelector::PseudoMediaControlsVolumeSlider:
dynamicPseudo = MEDIA_CONTROLS_VOLUME_SLIDER;
return true;
case CSSSelector::PseudoMediaControlsSeekBackButton:
dynamicPseudo = MEDIA_CONTROLS_SEEK_BACK_BUTTON;
return true;
......
......@@ -512,6 +512,9 @@ media-rewind-button
media-return-to-realtime-button
media-slider
media-sliderthumb
media-volume-slider-container
media-volume-slider
media-volume-sliderthumb
media-controls-background
media-current-time-display
media-time-remaining-display
......
......@@ -88,6 +88,14 @@ audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline {
padding: 0px 2px;
}
audio::-webkit-media-controls-volume-slider-container, video::-webkit-media-controls-volume-slider-container {
display: none;
}
audio::-webkit-media-controls-volume-slider, video::-webkit-media-controls-volume-slider {
display: none;
}
audio::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-back-button {
-webkit-appearance: media-seek-back-button;
display: -webkit-box;
......
......@@ -49,9 +49,8 @@ enum ControlPart {
ButtonBevelPart, DefaultButtonPart, ListboxPart, ListItemPart,
MediaFullscreenButtonPart, MediaMuteButtonPart, MediaPlayButtonPart, MediaSeekBackButtonPart,
MediaSeekForwardButtonPart, MediaRewindButtonPart, MediaReturnToRealtimeButtonPart,
MediaSliderPart,
MediaSliderThumbPart, MediaControlsBackgroundPart,
MediaCurrentTimePart, MediaTimeRemainingPart,
MediaSliderPart, MediaSliderThumbPart, MediaVolumeSliderContainerPart, MediaVolumeSliderPart, MediaVolumeSliderThumbPart,
MediaControlsBackgroundPart, MediaCurrentTimePart, MediaTimeRemainingPart,
MenulistPart, MenulistButtonPart, MenulistTextPart, MenulistTextFieldPart,
SliderHorizontalPart, SliderVerticalPart, SliderThumbHorizontalPart,
SliderThumbVerticalPart, CaretPart, SearchFieldPart, SearchFieldDecorationPart,
......
......@@ -183,7 +183,49 @@ bool MediaControlTimelineContainerElement::rendererIsNeeded(RenderStyle* style)
return !isnan(duration) && !isinf(duration);
}
// ----------------------------
MediaControlVolumeSliderContainerElement::MediaControlVolumeSliderContainerElement(Document* doc, HTMLMediaElement* element)
: MediaControlElement(doc, MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER, element)
, m_isVisible(false)
, m_x(0)
, m_y(0)
{
}
PassRefPtr<RenderStyle> MediaControlVolumeSliderContainerElement::styleForElement()
{
RefPtr<RenderStyle> style = MediaControlElement::styleForElement();
style->setPosition(AbsolutePosition);
style->setLeft(Length(m_x, Fixed));
style->setTop(Length(m_y, Fixed));
style->setDisplay(m_isVisible ? BLOCK : NONE);
return style;
}
void MediaControlVolumeSliderContainerElement::setVisible(bool visible)
{
if (visible == m_isVisible)
return;
m_isVisible = visible;
}
void MediaControlVolumeSliderContainerElement::setPosition(int x, int y)
{
if (x == m_x && y == m_y)
return;
m_x = x;
m_y = y;
}
bool MediaControlVolumeSliderContainerElement::hitTest(const IntPoint& absPoint)
{
if (renderer() && renderer()->style()->hasAppearance())
return renderer()->theme()->hitTestMediaControlPart(renderer(), absPoint);
return false;
}
// ----------------------------
MediaControlStatusDisplayElement::MediaControlStatusDisplayElement(Document* document, HTMLMediaElement* element)
......@@ -528,6 +570,33 @@ void MediaControlTimelineElement::update(bool updateDuration)
// ----------------------------
MediaControlVolumeSliderElement::MediaControlVolumeSliderElement(Document* document, HTMLMediaElement* element)
: MediaControlInputElement(document, MEDIA_CONTROLS_VOLUME_SLIDER, "range", element, MediaVolumeSlider)
{
setAttribute(maxAttr, "1");
}
void MediaControlVolumeSliderElement::defaultEventHandler(Event* event)
{
// Left button is 0. Rejects mouse events not from left button.
if (event->isMouseEvent() && static_cast<MouseEvent*>(event)->button())
return;
MediaControlInputElement::defaultEventHandler(event);
if (event->type() == eventNames().mouseoverEvent || event->type() == eventNames().mouseoutEvent || event->type() == eventNames().mousemoveEvent)
return;
float volume = narrowPrecisionToFloat(value().toDouble());
if (volume != m_mediaElement->volume()) {
ExceptionCode ec = 0;
m_mediaElement->setVolume(volume, ec);
ASSERT(!ec);
}
}
// ----------------------------
MediaControlFullscreenButtonElement::MediaControlFullscreenButtonElement(Document* document, HTMLMediaElement* element)
: MediaControlInputElement(document, MEDIA_CONTROLS_FULLSCREEN_BUTTON, "button", element, MediaFullscreenButton)
{
......
......@@ -57,10 +57,13 @@ enum MediaControlElementType {
MediaUnMuteButton,
MediaPauseButton,
MediaTimelineContainer,
MediaCurrentTimeDisplay,
MediaCurrentTimeDisplay,
MediaTimeRemainingDisplay,
MediaStatusDisplay,
MediaControlsPanel
MediaControlsPanel,
MediaVolumeSliderContainer,
MediaVolumeSlider,
MediaVolumeSliderThumb
};
class MediaControlShadowRootElement : public HTMLDivElement {
......@@ -104,6 +107,22 @@ public:
// ----------------------------
class MediaControlVolumeSliderContainerElement : public MediaControlElement {
public:
MediaControlVolumeSliderContainerElement(Document*, HTMLMediaElement*);
virtual PassRefPtr<RenderStyle> styleForElement();
void setVisible(bool);
bool isVisible() { return m_isVisible; }
void setPosition(int x, int y);
bool hitTest(const IntPoint& absPoint);
private:
bool m_isVisible;
int m_x, m_y;
};
// ----------------------------
class MediaControlStatusDisplayElement : public MediaControlElement {
public:
MediaControlStatusDisplayElement(Document*, HTMLMediaElement*);
......@@ -207,6 +226,14 @@ public:
// ----------------------------
class MediaControlVolumeSliderElement : public MediaControlInputElement {
public:
MediaControlVolumeSliderElement(Document*, HTMLMediaElement*);
virtual void defaultEventHandler(Event*);
};
// ----------------------------
class MediaControlFullscreenButtonElement : public MediaControlInputElement {
public:
MediaControlFullscreenButtonElement(Document*, HTMLMediaElement*);
......
......@@ -33,6 +33,7 @@
#include "HTMLNames.h"
#include "MediaControlElements.h"
#include "MouseEvent.h"
#include "RenderTheme.h"
#include <wtf/CurrentTime.h>
#include <wtf/MathExtras.h>
......@@ -132,6 +133,10 @@ void RenderMedia::styleDidChange(StyleDifference diff, const RenderStyle* oldSty
m_currentTimeDisplay->updateStyle();
if (m_timeRemainingDisplay)
m_timeRemainingDisplay->updateStyle();
if (m_volumeSliderContainer)
m_volumeSliderContainer->updateStyle();
if (m_volumeSlider)
m_volumeSlider->updateStyle();
}
}
......@@ -240,6 +245,21 @@ void RenderMedia::createTimeline()
m_timeline->attachToParent(m_timelineContainer.get());
}
void RenderMedia::createVolumeSliderContainer()
{
ASSERT(!m_volumeSliderContainer);
m_volumeSliderContainer = new MediaControlVolumeSliderContainerElement(document(), mediaElement());
m_volumeSliderContainer->attachToParent(m_panel.get());
}
void RenderMedia::createVolumeSlider()
{
ASSERT(!m_volumeSlider);
m_volumeSlider = new MediaControlVolumeSliderElement(document(), mediaElement());
m_volumeSlider->setAttribute(precisionAttr, "float");
m_volumeSlider->attachToParent(m_volumeSliderContainer.get());
}
void RenderMedia::createCurrentTimeDisplay()
{
ASSERT(!m_currentTimeDisplay);
......@@ -285,6 +305,8 @@ void RenderMedia::updateControls()
m_currentTimeDisplay = 0;
m_timeRemainingDisplay = 0;
m_fullscreenButton = 0;
m_volumeSliderContainer = 0;
m_volumeSlider = 0;
m_controlsShadowRoot = 0;
}
m_opacityAnimationTo = 1.0f;
......@@ -303,9 +325,12 @@ void RenderMedia::updateControls()
createReturnToRealtimeButton();
createStatusDisplay();
createTimelineContainer();
createVolumeSliderContainer();
createSeekBackButton();
createSeekForwardButton();
createFullscreenButton();
if (m_volumeSliderContainer)
createVolumeSlider();
if (m_timelineContainer) {
createCurrentTimeDisplay();
createTimeline();
......@@ -336,6 +361,8 @@ void RenderMedia::updateControls()
m_playButton->update();
if (m_timelineContainer)
m_timelineContainer->update();
if (m_volumeSliderContainer)
m_volumeSliderContainer->update();
if (m_timeline)
m_timeline->update();
if (m_currentTimeDisplay)
......@@ -354,6 +381,8 @@ void RenderMedia::updateControls()
m_statusDisplay->update();
if (m_fullscreenButton)
m_fullscreenButton->update();
if (m_volumeSlider)
m_volumeSlider->update();
updateTimeDisplay();
updateControlVisibility();
......@@ -463,13 +492,53 @@ void RenderMedia::opacityAnimationTimerFired(Timer<RenderMedia>*)
changeOpacity(m_panel.get(), opacity);
}
void RenderMedia::updateVolumeSliderContainer(bool visible)
{
if (!mediaElement()->hasAudio() || !m_volumeSliderContainer || !m_volumeSlider)
return;
if (visible && !m_volumeSliderContainer->isVisible()) {
if (!m_muteButton || !m_muteButton->renderer() || !m_muteButton->renderBox())
return;
RefPtr<RenderStyle> s = m_volumeSliderContainer->styleForElement();
int height = s->height().isPercent() ? 0 : s->height().value();
int x = m_muteButton->renderBox()->offsetLeft();
int y = m_muteButton->renderBox()->offsetTop() - height;
FloatPoint absPoint = m_muteButton->renderer()->localToAbsolute(FloatPoint(x, y), true, true);
if (absPoint.y() < 0)
y = m_muteButton->renderBox()->offsetTop() + m_muteButton->renderBox()->height();
m_volumeSliderContainer->setVisible(true);
m_volumeSliderContainer->setPosition(x, y);
m_volumeSliderContainer->update();
m_volumeSlider->update();
} else if (!visible && m_volumeSliderContainer->isVisible()) {
m_volumeSliderContainer->setVisible(false);
m_volumeSliderContainer->updateStyle();
}
}
void RenderMedia::forwardEvent(Event* event)
{
if (event->isMouseEvent() && m_controlsShadowRoot) {
MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
IntPoint point(mouseEvent->absoluteLocation());
if (m_muteButton && m_muteButton->hitTest(point))
bool showVolumeSlider = false;
if (m_muteButton && m_muteButton->hitTest(point)) {
m_muteButton->defaultEventHandler(event);
if (event->type() != eventNames().mouseoutEvent)
showVolumeSlider = true;
}
if (m_volumeSliderContainer && m_volumeSliderContainer->hitTest(point))
showVolumeSlider = true;
if (m_volumeSlider && m_volumeSlider->hitTest(point)) {
m_volumeSlider->defaultEventHandler(event);
showVolumeSlider = true;
}
updateVolumeSliderContainer(showVolumeSlider);
if (m_playButton && m_playButton->hitTest(point))
m_playButton->defaultEventHandler(event);
......
......@@ -41,10 +41,12 @@ class MediaControlSeekButtonElement;
class MediaControlRewindButtonElement;
class MediaControlReturnToRealtimeButtonElement;
class MediaControlTimelineElement;
class MediaControlVolumeSliderElement;
class MediaControlFullscreenButtonElement;
class MediaControlTimeDisplayElement;
class MediaControlStatusDisplayElement;
class MediaControlTimelineContainerElement;
class MediaControlVolumeSliderContainerElement;
class MediaControlElement;
class MediaPlayer;
......@@ -99,6 +101,8 @@ private:
void createStatusDisplay();
void createTimelineContainer();
void createTimeline();
void createVolumeSliderContainer();
void createVolumeSlider();
void createCurrentTimeDisplay();
void createTimeRemainingDisplay();
void createFullscreenButton();
......@@ -109,6 +113,8 @@ private:
void changeOpacity(HTMLElement*, float opacity);
void opacityAnimationTimerFired(Timer<RenderMedia>*);
void updateVolumeSliderContainer(bool visible);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
RefPtr<HTMLElement> m_controlsShadowRoot;
......@@ -120,8 +126,10 @@ private:
RefPtr<MediaControlRewindButtonElement> m_rewindButton;
RefPtr<MediaControlReturnToRealtimeButtonElement> m_returnToRealtimeButton;
RefPtr<MediaControlTimelineElement> m_timeline;
RefPtr<MediaControlVolumeSliderElement> m_volumeSlider;
RefPtr<MediaControlFullscreenButtonElement> m_fullscreenButton;
RefPtr<MediaControlTimelineContainerElement> m_timelineContainer;
RefPtr<MediaControlVolumeSliderContainerElement> m_volumeSliderContainer;
RefPtr<MediaControlTimeDisplayElement> m_currentTimeDisplay;
RefPtr<MediaControlTimeDisplayElement> m_timeRemainingDisplay;
RefPtr<MediaControlStatusDisplayElement> m_statusDisplay;
......
......@@ -128,6 +128,18 @@ bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, R
case MediaSliderThumb:
paintThemePart(SafariTheme::MediaSliderThumbPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
break;
case MediaVolumeSliderContainer:
// FIXME: Implement volume slider.
ASSERT_NOT_REACHED();
break;
case MediaVolumeSlider:
// FIXME: Implement volume slider.
ASSERT_NOT_REACHED();
break;
case MediaVolumeSliderThumb:
// FIXME: Implement volume slider.
ASSERT_NOT_REACHED();
break;
case MediaTimelineContainer:
ASSERT_NOT_REACHED();
break;
......
......@@ -281,6 +281,8 @@ PassRefPtr<RenderStyle> RenderSlider::createThumbStyle(const RenderStyle* parent
style->setAppearance(SliderThumbHorizontalPart);
else if (parentStyle->appearance() == MediaSliderPart)
style->setAppearance(MediaSliderThumbPart);
else if (parentStyle->appearance() == MediaVolumeSliderPart)
style->setAppearance(MediaVolumeSliderThumbPart);
return style.release();
}
......@@ -298,7 +300,7 @@ IntRect RenderSlider::thumbRect()
double fraction = sliderPosition(static_cast<HTMLInputElement*>(node()));
IntRect contentRect = contentBoxRect();
if (style()->appearance() == SliderVerticalPart) {
if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart) {
thumbRect.setX(contentRect.x() + (contentRect.width() - thumbRect.width()) / 2);
thumbRect.setY(contentRect.y() + static_cast<int>(nextafter((contentRect.height() - thumbRect.height()) + 1, 0) * (1 - fraction)));
} else {
......@@ -391,7 +393,7 @@ bool RenderSlider::mouseEventIsInThumb(MouseEvent* evt)
return false;
#if ENABLE(VIDEO)
if (style()->appearance() == MediaSliderPart) {
if (style()->appearance() == MediaSliderPart || style()->appearance() == MediaVolumeSliderPart) {
MediaControlInputElement *sliderThumb = static_cast<MediaControlInputElement*>(m_thumb->renderer()->node());
return sliderThumb->hitTest(evt->absoluteLocation());
}
......@@ -423,7 +425,7 @@ void RenderSlider::setValueForPosition(int position)
// Calculate the new value based on the position, and send it to the element.
SliderRange range(element);
double fraction = static_cast<double>(position) / trackSize();
if (style()->appearance() == SliderVerticalPart)
if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart)
fraction = 1 - fraction;
double value = range.clampValue(range.valueFromProportion(fraction));
element->setValueFromRenderer(String::number(value));
......@@ -444,7 +446,7 @@ int RenderSlider::positionForOffset(const IntPoint& p)
return 0;
int position;
if (style()->appearance() == SliderVerticalPart)
if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart)
position = p.y() - m_thumb->renderBox()->height() / 2;
else
position = p.x() - m_thumb->renderBox()->width() / 2;
......@@ -457,7 +459,7 @@ int RenderSlider::currentPosition()
ASSERT(m_thumb);
ASSERT(m_thumb->renderer());
if (style()->appearance() == SliderVerticalPart)
if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart)
return toRenderBox(m_thumb->renderer())->y() - contentBoxRect().y();
return toRenderBox(m_thumb->renderer())->x() - contentBoxRect().x();
}
......@@ -467,7 +469,7 @@ int RenderSlider::trackSize()
ASSERT(m_thumb);
ASSERT(m_thumb->renderer());
if (style()->appearance() == SliderVerticalPart)
if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart)
return contentHeight() - m_thumb->renderBox()->height();
return contentWidth() - m_thumb->renderBox()->width();
}
......
......@@ -183,6 +183,7 @@ void RenderTheme::adjustStyle(CSSStyleSelector* selector, RenderStyle* style, El
case MenulistButtonPart:
return adjustMenuListButtonStyle(selector, style, e);
case MediaSliderPart:
case MediaVolumeSliderPart:
case SliderHorizontalPart:
case SliderVerticalPart:
return adjustSliderTrackStyle(selector, style, e);
......@@ -278,6 +279,14 @@ bool RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& paintInf
if (o->parent()->isSlider())
return paintMediaSliderThumb(o, paintInfo, r);
break;
case MediaVolumeSliderContainerPart:
return paintMediaVolumeSliderContainer(o, paintInfo, r);
case MediaVolumeSliderPart:
return paintMediaVolumeSliderTrack(o, paintInfo, r);
case MediaVolumeSliderThumbPart:
if (o->parent()->isSlider())
return paintMediaVolumeSliderThumb(o, paintInfo, r);
break;
case MediaTimeRemainingPart:
return paintMediaTimeRemaining(o, paintInfo, r);
case MediaCurrentTimePart:
......
......@@ -244,6 +244,9 @@ protected: