summaryrefslogtreecommitdiff
path: root/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/accessibility/AccessibilityRenderObject.cpp')
-rw-r--r--Source/WebCore/accessibility/AccessibilityRenderObject.cpp79
1 files changed, 51 insertions, 28 deletions
diff --git a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
index 74c2b03fa..31e64e7dc 100644
--- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
+++ b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
@@ -1363,7 +1363,7 @@ String AccessibilityRenderObject::title() const
if (isInputTag) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(node);
if (input->isTextButton())
- return input->value();
+ return input->valueWithDefault();
}
if (isInputTag || AccessibilityObject::isARIAInput(ariaRoleAttribute()) || isControl()) {
@@ -1413,6 +1413,53 @@ String AccessibilityRenderObject::ariaAccessibilityDescription() const
return String();
}
+String AccessibilityRenderObject::webAreaAccessibilityDescription() const
+{
+ // The WebArea description should follow this order:
+ // aria-label on the <html>
+ // title on the <html>
+ // <title> inside the <head> (of it was set through JS)
+ // name on the <html>
+ // For iframes:
+ // aria-label on the <iframe>
+ // title on the <iframe>
+ // name on the <iframe>
+
+ if (!m_renderer)
+ return String();
+
+ Document* document = m_renderer->document();
+
+ // Check if the HTML element has an aria-label for the webpage.
+ if (Element* documentElement = document->documentElement()) {
+ const AtomicString& ariaLabel = documentElement->getAttribute(aria_labelAttr);
+ if (!ariaLabel.isEmpty())
+ return ariaLabel;
+ }
+
+ Node* owner = document->ownerElement();
+ if (owner) {
+ if (owner->hasTagName(frameTag) || owner->hasTagName(iframeTag)) {
+ const AtomicString& title = static_cast<HTMLFrameElementBase*>(owner)->getAttribute(titleAttr);
+ if (!title.isEmpty())
+ return title;
+ return static_cast<HTMLFrameElementBase*>(owner)->getNameAttribute();
+ }
+ if (owner->isHTMLElement())
+ return toHTMLElement(owner)->getNameAttribute();
+ }
+
+ String documentTitle = document->title();
+ if (!documentTitle.isEmpty())
+ return documentTitle;
+
+ owner = document->body();
+ if (owner && owner->isHTMLElement())
+ return toHTMLElement(owner)->getNameAttribute();
+
+ return String();
+}
+
String AccessibilityRenderObject::accessibilityDescription() const
{
if (!m_renderer)
@@ -1441,33 +1488,9 @@ String AccessibilityRenderObject::accessibilityDescription() const
return getAttribute(MathMLNames::alttextAttr);
#endif
- if (isWebArea()) {
- Document* document = m_renderer->document();
-
- // Check if the HTML element has an aria-label for the webpage.
- Element* documentElement = document->documentElement();
- if (documentElement) {
- const AtomicString& ariaLabel = documentElement->getAttribute(aria_labelAttr);
- if (!ariaLabel.isEmpty())
- return ariaLabel;
- }
-
- Node* owner = document->ownerElement();
- if (owner) {
- if (owner->hasTagName(frameTag) || owner->hasTagName(iframeTag)) {
- const AtomicString& title = static_cast<HTMLFrameElementBase*>(owner)->getAttribute(titleAttr);
- if (!title.isEmpty())
- return title;
- return static_cast<HTMLFrameElementBase*>(owner)->getNameAttribute();
- }
- if (owner->isHTMLElement())
- return toHTMLElement(owner)->getNameAttribute();
- }
- owner = document->body();
- if (owner && owner->isHTMLElement())
- return toHTMLElement(owner)->getNameAttribute();
- }
-
+ if (isWebArea())
+ return webAreaAccessibilityDescription();
+
return String();
}