2009-06-16 Eric Carlson <eric.carlson@apple.com>

        Reviewed by Simon Fraser.

        Fix for <rdar://problem/6890126> Theme code should fetch the MediaControlElementType from 
        the MediaControlInputElement, rather than computing it again

        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::percentLoaded): New, utility function for controller implementation.
        * html/HTMLMediaElement.h:

        * rendering/MediaControlElements.h:
        (WebCore::MediaControlInputElement::displayType): New, return m_displayType.

        * rendering/RenderMediaControls.cpp:
        (WebCore::RenderMediaControls::paintMediaControlsPart): Stop using MediaPlayer object, get button
        state from the button itself and get movie state from HTMLMediaElement.

        * rendering/RenderThemeMac.mm:
        (WebCore::RenderThemeMac::paintMediaMuteButton): Get state from button instead of MediaPlayer.
        (WebCore::RenderThemeMac::paintMediaPlayButton): Ditto.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44738 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9950f55a
2009-06-16 Eric Carlson <eric.carlson@apple.com>
Reviewed by Simon Fraser.
Fix for <rdar://problem/6890126> Theme code should fetch the MediaControlElementType from
the MediaControlInputElement, rather than computing it again
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::percentLoaded): New, utility function for controller implementation.
* html/HTMLMediaElement.h:
* rendering/MediaControlElements.h:
(WebCore::MediaControlInputElement::displayType): New, return m_displayType.
* rendering/RenderMediaControls.cpp:
(WebCore::RenderMediaControls::paintMediaControlsPart): Stop using MediaPlayer object, get button
state from the button itself and get movie state from HTMLMediaElement.
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintMediaMuteButton): Get state from button instead of MediaPlayer.
(WebCore::RenderThemeMac::paintMediaPlayButton): Ditto.
2009-06-16 Jian Li <jianli@chromium.org>
Reviewed by David Levin.
......
......@@ -1130,6 +1130,14 @@ bool HTMLMediaElement::canPlay() const
return paused() || ended() || m_readyState < HAVE_METADATA;
}
float HTMLMediaElement::percentLoaded() const
{
if (!m_player)
return 0;
float duration = m_player->duration();
return duration ? m_player->maxTimeBuffered() / duration : 0;
}
bool HTMLMediaElement::havePotentialSourceChild()
{
// Stash the current <source> node so we can restore it after checking
......
......@@ -131,6 +131,8 @@ public:
bool canPlay() const;
float percentLoaded() const;
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
void setNeedWidgetUpdate(bool needWidgetUpdate) { m_needWidgetUpdate = needWidgetUpdate; }
void deliverNotification(MediaPlayerProxyNotificationType notification);
......
......@@ -93,6 +93,7 @@ public:
void update();
void updateStyle();
bool hitTest(const IntPoint& absPoint);
MediaControlElementType displayType() const { return m_displayType; }
protected:
virtual void updateDisplayType() { }
......
......@@ -101,13 +101,17 @@ bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, R
break;
case MediaMuteButton:
case MediaUnMuteButton:
if (HTMLMediaElement* mediaElement = parentMediaElement(o))
paintThemePart(mediaElement->muted() ? SafariTheme::MediaUnMuteButtonPart : SafariTheme::MediaMuteButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
if (MediaControlMuteButtonElement* btn = static_cast<MediaControlMuteButtonElement*>(o->node())) {
bool audioEnabled = btn->displayType() == MediaMuteButton;
paintThemePart(audioEnabled ? SafariTheme::MediaMuteButtonPart : SafariTheme::MediaUnMuteButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
}
break;
case MediaPauseButton:
case MediaPlayButton:
if (HTMLMediaElement* mediaElement = parentMediaElement(o))
paintThemePart(mediaElement->canPlay() ? SafariTheme::MediaPlayButtonPart : SafariTheme::MediaPauseButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(o->node())) {
bool currentlyPlaying = btn->displayType() == MediaPlayButton;
paintThemePart(currentlyPlaying ? SafariTheme::MediaPauseButtonPart : SafariTheme::MediaPlayButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
}
break;
case MediaSeekBackButton:
paintThemePart(SafariTheme::MediaSeekBackButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
......@@ -116,15 +120,8 @@ bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, R
paintThemePart(SafariTheme::MediaSeekForwardButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
break;
case MediaSlider: {
HTMLMediaElement* mediaElement = parentMediaElement(o);
if (!mediaElement)
break;
MediaPlayer* player = mediaElement->player();
float duration = player ? player->duration() : 0;
float percentLoaded = duration ? player->maxTimeBuffered() /duration : 0;
STPaintProgressIndicator(SafariTheme::MediaType, paintInfo.context->platformContext(), r, NSRegularControlSize, 0, percentLoaded);
if (HTMLMediaElement* mediaElement = parentMediaElement(o))
STPaintProgressIndicator(SafariTheme::MediaType, paintInfo.context->platformContext(), r, NSRegularControlSize, 0, mediaElement->percentLoaded());
break;
}
case MediaSliderThumb:
......
......@@ -1478,12 +1478,10 @@ bool RenderThemeMac::paintMediaMuteButton(RenderObject* o, const RenderObject::P
if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagName(audioTag)))
return false;
HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode);
if (!mediaElement)
return false;
LocalCurrentGraphicsContext localContext(paintInfo.context);
wkDrawMediaUIPart(mediaElement->muted() ? MediaUnMuteButton : MediaMuteButton, mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(node)) {
LocalCurrentGraphicsContext localContext(paintInfo.context);
wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
}
return false;
}
......@@ -1494,12 +1492,10 @@ bool RenderThemeMac::paintMediaPlayButton(RenderObject* o, const RenderObject::P
if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagName(audioTag)))
return false;
HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode);
if (!mediaElement)
return false;
LocalCurrentGraphicsContext localContext(paintInfo.context);
wkDrawMediaUIPart(mediaElement->canPlay() ? MediaPlayButton : MediaPauseButton, mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(node)) {
LocalCurrentGraphicsContext localContext(paintInfo.context);
wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
}
return false;
}
......
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