AccessibilityAttachment.cpp [plain text]
#include "config.h"
#include "AccessibilityAttachment.h"
#include "HTMLAttachmentElement.h"
#include "HTMLNames.h"
#include "LocalizedStrings.h"
#include "RenderAttachment.h"
#if ENABLE(ATTACHMENT_ELEMENT)
namespace WebCore {
using namespace HTMLNames;
AccessibilityAttachment::AccessibilityAttachment(RenderAttachment* renderer)
: AccessibilityRenderObject(renderer)
{
}
Ref<AccessibilityAttachment> AccessibilityAttachment::create(RenderAttachment* renderer)
{
return adoptRef(*new AccessibilityAttachment(renderer));
}
bool AccessibilityAttachment::hasProgress(float* progress) const
{
auto& progressString = getAttribute(progressAttr);
bool validProgress;
float result = std::max<float>(std::min<float>(progressString.toFloat(&validProgress), 1), 0);
if (progress)
*progress = result;
return validProgress;
}
float AccessibilityAttachment::valueForRange() const
{
float progress = 0;
hasProgress(&progress);
return progress;
}
HTMLAttachmentElement* AccessibilityAttachment::attachmentElement() const
{
ASSERT(is<HTMLAttachmentElement>(node()));
if (!is<HTMLAttachmentElement>(node()))
return nullptr;
return downcast<HTMLAttachmentElement>(node());
}
String AccessibilityAttachment::roleDescription() const
{
return AXAttachmentRoleText();
}
bool AccessibilityAttachment::computeAccessibilityIsIgnored() const
{
return false;
}
void AccessibilityAttachment::accessibilityText(Vector<AccessibilityText>& textOrder)
{
HTMLAttachmentElement* attachmentElement = this->attachmentElement();
if (!attachmentElement)
return;
auto title = attachmentElement->attachmentTitle();
auto& subtitle = getAttribute(subtitleAttr);
auto& action = getAttribute(actionAttr);
if (action.length())
textOrder.append(AccessibilityText(action, ActionText));
if (title.length())
textOrder.append(AccessibilityText(title, TitleText));
if (subtitle.length())
textOrder.append(AccessibilityText(subtitle, SubtitleText));
}
}
#endif // ENABLE(ATTACHMENT_ELEMENT)