This source file includes following definitions.
- queryString
- create
- controlType
- title
- accessibilityDescription
- helpText
- computeAccessibilityIsIgnored
- roleValue
- create
- accessibilityDescription
- helpText
- controllingVideoElement
- computeAccessibilityIsIgnored
- localizedMediaTimeDescription
- create
- valueDescription
- helpText
- create
- computeAccessibilityIsIgnored
- accessibilityDescription
- stringValue
#include "config.h"
#include "core/accessibility/AXMediaControls.h"
#include "core/html/HTMLMediaElement.h"
#include "platform/text/PlatformLocale.h"
namespace WebCore {
using blink::WebLocalizedString;
using namespace HTMLNames;
static inline String queryString(WebLocalizedString::Name name)
{
return Locale::defaultLocale().queryString(name);
}
AccessibilityMediaControl::AccessibilityMediaControl(RenderObject* renderer)
: AXRenderObject(renderer)
{
}
PassRefPtr<AXObject> AccessibilityMediaControl::create(RenderObject* renderer)
{
ASSERT(renderer->node());
switch (mediaControlElementType(renderer->node())) {
case MediaSlider:
return AccessibilityMediaTimeline::create(renderer);
case MediaCurrentTimeDisplay:
case MediaTimeRemainingDisplay:
return AccessibilityMediaTimeDisplay::create(renderer);
case MediaControlsPanel:
return AXMediaControlsContainer::create(renderer);
default:
return adoptRef(new AccessibilityMediaControl(renderer));
}
}
MediaControlElementType AccessibilityMediaControl::controlType() const
{
if (!renderer() || !renderer()->node())
return MediaTimelineContainer;
return mediaControlElementType(renderer()->node());
}
String AccessibilityMediaControl::title() const
{
if (controlType() == MediaControlsPanel)
return queryString(WebLocalizedString::AXMediaDefault);
return AXRenderObject::title();
}
String AccessibilityMediaControl::accessibilityDescription() const
{
switch (controlType()) {
case MediaEnterFullscreenButton:
return queryString(WebLocalizedString::AXMediaEnterFullscreenButton);
case MediaExitFullscreenButton:
return queryString(WebLocalizedString::AXMediaExitFullscreenButton);
case MediaMuteButton:
return queryString(WebLocalizedString::AXMediaMuteButton);
case MediaPlayButton:
return queryString(WebLocalizedString::AXMediaPlayButton);
case MediaUnMuteButton:
return queryString(WebLocalizedString::AXMediaUnMuteButton);
case MediaPauseButton:
return queryString(WebLocalizedString::AXMediaPauseButton);
case MediaStatusDisplay:
return queryString(WebLocalizedString::AXMediaStatusDisplay);
case MediaCurrentTimeDisplay:
return queryString(WebLocalizedString::AXMediaCurrentTimeDisplay);
case MediaTimeRemainingDisplay:
return queryString(WebLocalizedString::AXMediaTimeRemainingDisplay);
case MediaShowClosedCaptionsButton:
return queryString(WebLocalizedString::AXMediaShowClosedCaptionsButton);
case MediaHideClosedCaptionsButton:
return queryString(WebLocalizedString::AXMediaHideClosedCaptionsButton);
default:
return queryString(WebLocalizedString::AXMediaDefault);
}
}
String AccessibilityMediaControl::helpText() const
{
switch (controlType()) {
case MediaEnterFullscreenButton:
return queryString(WebLocalizedString::AXMediaEnterFullscreenButtonHelp);
case MediaExitFullscreenButton:
return queryString(WebLocalizedString::AXMediaExitFullscreenButtonHelp);
case MediaMuteButton:
return queryString(WebLocalizedString::AXMediaMuteButtonHelp);
case MediaPlayButton:
return queryString(WebLocalizedString::AXMediaPlayButtonHelp);
case MediaUnMuteButton:
return queryString(WebLocalizedString::AXMediaUnMuteButtonHelp);
case MediaPauseButton:
return queryString(WebLocalizedString::AXMediaPauseButtonHelp);
case MediaStatusDisplay:
return queryString(WebLocalizedString::AXMediaStatusDisplayHelp);
case MediaCurrentTimeDisplay:
return queryString(WebLocalizedString::AXMediaCurrentTimeDisplayHelp);
case MediaTimeRemainingDisplay:
return queryString(WebLocalizedString::AXMediaTimeRemainingDisplayHelp);
case MediaShowClosedCaptionsButton:
return queryString(WebLocalizedString::AXMediaShowClosedCaptionsButtonHelp);
case MediaHideClosedCaptionsButton:
return queryString(WebLocalizedString::AXMediaHideClosedCaptionsButtonHelp);
default:
return queryString(WebLocalizedString::AXMediaDefault);
}
}
bool AccessibilityMediaControl::computeAccessibilityIsIgnored() const
{
if (!m_renderer || !m_renderer->style() || m_renderer->style()->visibility() != VISIBLE || controlType() == MediaTimelineContainer)
return true;
return accessibilityIsIgnoredByDefault();
}
AccessibilityRole AccessibilityMediaControl::roleValue() const
{
switch (controlType()) {
case MediaEnterFullscreenButton:
case MediaExitFullscreenButton:
case MediaMuteButton:
case MediaPlayButton:
case MediaUnMuteButton:
case MediaPauseButton:
case MediaShowClosedCaptionsButton:
case MediaHideClosedCaptionsButton:
return ButtonRole;
case MediaStatusDisplay:
return StaticTextRole;
case MediaTimelineContainer:
return GroupRole;
default:
break;
}
return UnknownRole;
}
AXMediaControlsContainer::AXMediaControlsContainer(RenderObject* renderer)
: AccessibilityMediaControl(renderer)
{
}
PassRefPtr<AXObject> AXMediaControlsContainer::create(RenderObject* renderer)
{
return adoptRef(new AXMediaControlsContainer(renderer));
}
String AXMediaControlsContainer::accessibilityDescription() const
{
return queryString(controllingVideoElement() ? WebLocalizedString::AXMediaVideoElement : WebLocalizedString::AXMediaAudioElement);
}
String AXMediaControlsContainer::helpText() const
{
return queryString(controllingVideoElement() ? WebLocalizedString::AXMediaVideoElementHelp : WebLocalizedString::AXMediaAudioElementHelp);
}
bool AXMediaControlsContainer::controllingVideoElement() const
{
if (!m_renderer->node())
return true;
MediaControlTimeDisplayElement* element = static_cast<MediaControlTimeDisplayElement*>(m_renderer->node());
return isHTMLVideoElement(toParentMediaElement(element));
}
bool AXMediaControlsContainer::computeAccessibilityIsIgnored() const
{
return accessibilityIsIgnoredByDefault();
}
static String localizedMediaTimeDescription(float )
{
return String();
}
AccessibilityMediaTimeline::AccessibilityMediaTimeline(RenderObject* renderer)
: AXSlider(renderer)
{
}
PassRefPtr<AXObject> AccessibilityMediaTimeline::create(RenderObject* renderer)
{
return adoptRef(new AccessibilityMediaTimeline(renderer));
}
String AccessibilityMediaTimeline::valueDescription() const
{
Node* node = m_renderer->node();
if (!isHTMLInputElement(node))
return String();
return localizedMediaTimeDescription(toHTMLInputElement(node)->value().toFloat());
}
String AccessibilityMediaTimeline::helpText() const
{
return queryString(WebLocalizedString::AXMediaSliderHelp);
}
AccessibilityMediaTimeDisplay::AccessibilityMediaTimeDisplay(RenderObject* renderer)
: AccessibilityMediaControl(renderer)
{
}
PassRefPtr<AXObject> AccessibilityMediaTimeDisplay::create(RenderObject* renderer)
{
return adoptRef(new AccessibilityMediaTimeDisplay(renderer));
}
bool AccessibilityMediaTimeDisplay::computeAccessibilityIsIgnored() const
{
if (!m_renderer || !m_renderer->style() || m_renderer->style()->visibility() != VISIBLE)
return true;
if (!m_renderer->style()->width().value())
return true;
return accessibilityIsIgnoredByDefault();
}
String AccessibilityMediaTimeDisplay::accessibilityDescription() const
{
if (controlType() == MediaCurrentTimeDisplay)
return queryString(WebLocalizedString::AXMediaCurrentTimeDisplay);
return queryString(WebLocalizedString::AXMediaTimeRemainingDisplay);
}
String AccessibilityMediaTimeDisplay::stringValue() const
{
if (!m_renderer || !m_renderer->node())
return String();
MediaControlTimeDisplayElement* element = static_cast<MediaControlTimeDisplayElement*>(m_renderer->node());
float time = element->currentValue();
return localizedMediaTimeDescription(fabsf(time));
}
}