#include "config.h"
#include "core/accessibility/AXNodeObject.h"
+#include "core/InputTypeNames.h"
#include "core/accessibility/AXObjectCache.h"
#include "core/dom/NodeTraversal.h"
#include "core/dom/Text.h"
return StaticTextRole;
if (isHTMLButtonElement(*node()))
return buttonRoleType();
+ if (isHTMLDetailsElement(*node()))
+ return DetailsRole;
+ if (isHTMLSummaryElement(*node())) {
+ if (node()->parentNode() && isHTMLDetailsElement(node()->parentNode()))
+ return DisclosureTriangleRole;
+ return UnknownRole;
+ }
+
if (isHTMLInputElement(*node())) {
HTMLInputElement& input = toHTMLInputElement(*node());
- if (input.isCheckbox())
+ const AtomicString& type = input.type();
+ if (type == InputTypeNames::checkbox)
return CheckBoxRole;
- if (input.isRadioButton())
+ if (type == InputTypeNames::radio)
return RadioButtonRole;
if (input.isTextButton())
return buttonRoleType();
- if (input.isRangeControl())
+ if (type == InputTypeNames::range)
return SliderRole;
-
- const AtomicString& type = input.getAttribute(typeAttr);
- if (equalIgnoringCase(type, "color"))
+ if (type == InputTypeNames::color)
return ColorWellRole;
-
return TextFieldRole;
}
if (isHTMLSelectElement(*node())) {
return ParagraphRole;
if (isHTMLLabelElement(*node()))
return LabelRole;
+ if (node()->isElementNode() && node()->hasTagName(figcaptionTag))
+ return FigcaptionRole;
+ if (node()->isElementNode() && node()->hasTagName(figureTag))
+ return FigureRole;
if (node()->isElementNode() && toElement(node())->isFocusable())
return GroupRole;
if (isHTMLAnchorElement(*node()) && isClickable())
AccessibilityRole role = ariaRoleToWebCoreRole(ariaRole);
// ARIA states if an item can get focus, it should not be presentational.
- if (role == PresentationalRole && canSetFocusAttribute())
+ if ((role == NoneRole || role == PresentationalRole) && canSetFocusAttribute())
return UnknownRole;
if (role == ButtonRole)
return label;
}
- for (Element* parent = element->parentElement(); parent; parent = parent->parentElement()) {
- if (isHTMLLabelElement(*parent))
- return toHTMLLabelElement(parent);
- }
-
- return 0;
+ return Traversal<HTMLLabelElement>::firstAncestor(*element);
}
AXObject* AXNodeObject::menuButtonForMenu() const
return 0;
// check if our parent is a mouse button listener
- while (node && !node->isElementNode())
- node = node->parentNode();
+ if (!node->isElementNode())
+ node = node->parentElement();
if (!node)
return 0;
{
Node* node = this->node();
if (roleValue() == ButtonRole && isHTMLInputElement(node))
- return toHTMLInputElement(*node).isImageButton();
+ return toHTMLInputElement(*node).type() == InputTypeNames::image;
return false;
}
return false;
HTMLInputElement* input = toHTMLInputElement(node);
- return input->isCheckbox() || input->isRadioButton();
+ return input->type() == InputTypeNames::checkbox || input->type() == InputTypeNames::radio;
}
bool AXNodeObject::isNativeImage() const
return true;
if (isHTMLInputElement(*node))
- return toHTMLInputElement(*node).isImageButton();
+ return toHTMLInputElement(*node).type() == InputTypeNames::image;
return false;
}
if (isHTMLTextAreaElement(*node))
return true;
- if (isHTMLInputElement(*node)) {
- HTMLInputElement* input = toHTMLInputElement(node);
- return input->isText() || input->isNumberField();
- }
+ if (isHTMLInputElement(*node))
+ return toHTMLInputElement(node)->isTextField();
return false;
}
if (ariaRoleAttribute() != UnknownRole)
return false;
- return toHTMLInputElement(node)->isPasswordField();
+ return toHTMLInputElement(node)->type() == InputTypeNames::password;
}
bool AXNodeObject::isProgressIndicator() const
if (isHTMLInputElement(node())) {
HTMLInputElement& input = toHTMLInputElement(*node());
- if (input.isRangeControl())
+ if (input.type() == InputTypeNames::range)
return input.valueAsNumber();
}
if (isHTMLInputElement(node())) {
HTMLInputElement& input = toHTMLInputElement(*node());
- if (input.isRangeControl())
+ if (input.type() == InputTypeNames::range)
return input.maximum();
}
if (isHTMLInputElement(node())) {
HTMLInputElement& input = toHTMLInputElement(*node());
- if (input.isRangeControl())
+ if (input.type() == InputTypeNames::range)
return input.minimum();
}
case ScrollBarRole:
return false;
case StaticTextRole:
- if (!axObjectCache()->inlineTextBoxAccessibility())
+ if (!axObjectCache()->inlineTextBoxAccessibilityEnabled())
return false;
default:
return true;
return ariaLabel;
}
- Node* owner = document->ownerElement();
- if (owner) {
+ if (HTMLFrameOwnerElement* owner = document->ownerElement()) {
if (isHTMLFrameElementBase(*owner)) {
- const AtomicString& title = toElement(owner)->getAttribute(titleAttr);
+ const AtomicString& title = owner->getAttribute(titleAttr);
if (!title.isEmpty())
return title;
- return toElement(owner)->getNameAttribute();
}
- if (owner->isHTMLElement())
- return toHTMLElement(owner)->getNameAttribute();
+ return owner->getNameAttribute();
}
String documentTitle = document->title();
if (!documentTitle.isEmpty())
return documentTitle;
- owner = document->body();
- if (owner && owner->isHTMLElement())
- return toHTMLElement(owner)->getNameAttribute();
+ if (HTMLElement* body = document->body())
+ return body->getNameAttribute();
return String();
}