Index: Source/core/accessibility/AXNodeObject.cpp |
diff --git a/Source/core/accessibility/AXNodeObject.cpp b/Source/core/accessibility/AXNodeObject.cpp |
index edd8bb8f1e19461189d2a129925fd33f77096a82..283a5a9623ff5922d834514869ea53b612c8dd94 100644 |
--- a/Source/core/accessibility/AXNodeObject.cpp |
+++ b/Source/core/accessibility/AXNodeObject.cpp |
@@ -38,6 +38,7 @@ |
#include "core/html/HTMLLabelElement.h" |
#include "core/html/HTMLLegendElement.h" |
#include "core/html/HTMLSelectElement.h" |
+#include "core/html/HTMLTextAreaElement.h" |
#include "core/rendering/RenderObject.h" |
#include "platform/UserGestureIndicator.h" |
#include "wtf/text/StringBuilder.h" |
@@ -76,8 +77,8 @@ static String accessibleNameForNode(Node* node) |
if (node->isTextNode()) |
return toText(node)->data(); |
- if (node->hasTagName(inputTag)) |
- return toHTMLInputElement(node)->value(); |
+ if (isHTMLInputElement(*node)) |
+ return toHTMLInputElement(*node).value(); |
if (node->isHTMLElement()) { |
const AtomicString& alt = toHTMLElement(node)->getAttribute(altAttr); |
@@ -186,28 +187,28 @@ AccessibilityRole AXNodeObject::determineAccessibilityRole() |
return StaticTextRole; |
if (node()->hasTagName(buttonTag)) |
return buttonRoleType(); |
- if (node()->hasTagName(inputTag)) { |
- HTMLInputElement* input = toHTMLInputElement(node()); |
- if (input->isCheckbox()) |
+ if (isHTMLInputElement(*node())) { |
+ HTMLInputElement& input = toHTMLInputElement(*node()); |
+ if (input.isCheckbox()) |
return CheckBoxRole; |
- if (input->isRadioButton()) |
+ if (input.isRadioButton()) |
return RadioButtonRole; |
- if (input->isTextButton()) |
+ if (input.isTextButton()) |
return buttonRoleType(); |
- if (input->isRangeControl()) |
+ if (input.isRangeControl()) |
return SliderRole; |
- const AtomicString& type = input->getAttribute(typeAttr); |
+ const AtomicString& type = input.getAttribute(typeAttr); |
if (equalIgnoringCase(type, "color")) |
return ColorWellRole; |
return TextFieldRole; |
} |
- if (node()->hasTagName(selectTag)) { |
- HTMLSelectElement* selectElement = toHTMLSelectElement(node()); |
- return selectElement->multiple() ? ListBoxRole : PopUpButtonRole; |
+ if (isHTMLSelectElement(*node())) { |
+ HTMLSelectElement& selectElement = toHTMLSelectElement(*node()); |
+ return selectElement.multiple() ? ListBoxRole : PopUpButtonRole; |
} |
- if (node()->hasTagName(textareaTag)) |
+ if (isHTMLTextAreaElement(*node())) |
return TextAreaRole; |
if (headingLevel()) |
return HeadingRole; |
@@ -506,11 +507,8 @@ bool AXNodeObject::isImageButton() const |
bool AXNodeObject::isInputImage() const |
{ |
Node* node = this->node(); |
- if (!node) |
- return false; |
- |
- if (roleValue() == ButtonRole && node->hasTagName(inputTag)) |
- return toHTMLInputElement(node)->isImageButton(); |
+ if (roleValue() == ButtonRole && isHTMLInputElement(node)) |
+ return toHTMLInputElement(*node).isImageButton(); |
return false; |
} |
@@ -538,13 +536,13 @@ bool AXNodeObject::isMultiSelectable() const |
if (equalIgnoringCase(ariaMultiSelectable, "false")) |
return false; |
- return node() && node()->hasTagName(selectTag) && toHTMLSelectElement(node())->multiple(); |
+ return isHTMLSelectElement(node()) && toHTMLSelectElement(*node()).multiple(); |
} |
bool AXNodeObject::isNativeCheckboxOrRadio() const |
{ |
Node* node = this->node(); |
- if (!node || !node->hasTagName(inputTag)) |
+ if (!isHTMLInputElement(node)) |
return false; |
HTMLInputElement* input = toHTMLInputElement(node); |
@@ -563,8 +561,8 @@ bool AXNodeObject::isNativeImage() const |
if (node->hasTagName(appletTag) || node->hasTagName(embedTag) || node->hasTagName(objectTag)) |
return true; |
- if (node->hasTagName(inputTag)) |
- return toHTMLInputElement(node)->isImageButton(); |
+ if (isHTMLInputElement(*node)) |
+ return toHTMLInputElement(*node).isImageButton(); |
return false; |
} |
@@ -575,10 +573,10 @@ bool AXNodeObject::isNativeTextControl() const |
if (!node) |
return false; |
- if (node->hasTagName(textareaTag)) |
+ if (isHTMLTextAreaElement(*node)) |
return true; |
- if (node->hasTagName(inputTag)) { |
+ if (isHTMLInputElement(*node)) { |
HTMLInputElement* input = toHTMLInputElement(node); |
return input->isText() || input->isNumberField(); |
} |
@@ -603,7 +601,7 @@ bool AXNodeObject::isNonNativeTextControl() const |
bool AXNodeObject::isPasswordField() const |
{ |
Node* node = this->node(); |
- if (!node || !node->hasTagName(inputTag)) |
+ if (!isHTMLInputElement(node)) |
return false; |
if (ariaRoleAttribute() != UnknownRole) |
@@ -629,8 +627,8 @@ bool AXNodeObject::isChecked() const |
return false; |
// First test for native checkedness semantics |
- if (node->hasTagName(inputTag)) |
- return toHTMLInputElement(node)->shouldAppearChecked(); |
+ if (isHTMLInputElement(*node)) |
+ return toHTMLInputElement(*node).shouldAppearChecked(); |
// Else, if this is an ARIA checkbox or radio, respect the aria-checked attribute |
AccessibilityRole ariaRole = ariaRoleAttribute(); |
@@ -673,7 +671,7 @@ bool AXNodeObject::isEnabled() const |
bool AXNodeObject::isIndeterminate() const |
{ |
Node* node = this->node(); |
- if (!node || !node->hasTagName(inputTag)) |
+ if (!isHTMLInputElement(node)) |
return false; |
return toHTMLInputElement(node)->shouldAppearIndeterminate(); |
@@ -704,13 +702,13 @@ bool AXNodeObject::isReadOnly() const |
if (!node) |
return true; |
- if (node->hasTagName(textareaTag)) |
- return toHTMLFormControlElement(node)->isReadOnly(); |
+ if (isHTMLTextAreaElement(*node)) |
+ return toHTMLTextAreaElement(*node).isReadOnly(); |
- if (node->hasTagName(inputTag)) { |
- HTMLInputElement* input = toHTMLInputElement(node); |
- if (input->isTextField()) |
- return input->isReadOnly(); |
+ if (isHTMLInputElement(*node)) { |
+ HTMLInputElement& input = toHTMLInputElement(*node); |
+ if (input.isTextField()) |
+ return input.isReadOnly(); |
} |
return !node->rendererIsEditable(); |
@@ -881,8 +879,8 @@ String AXNodeObject::text() const |
if (!node) |
return String(); |
- if (isNativeTextControl() && (node->hasTagName(textareaTag) || node->hasTagName(inputTag))) |
- return toHTMLTextFormControlElement(node)->value(); |
+ if (isNativeTextControl() && (isHTMLTextAreaElement(*node) || isHTMLInputElement(*node))) |
+ return toHTMLTextFormControlElement(*node).value(); |
if (!node->isElementNode()) |
return String(); |
@@ -922,7 +920,7 @@ void AXNodeObject::colorValue(int& r, int& g, int& b) const |
if (!isColorWell()) |
return; |
- if (!node() || !node()->hasTagName(inputTag)) |
+ if (!isHTMLInputElement(node())) |
return; |
HTMLInputElement* input = toHTMLInputElement(node()); |
@@ -952,10 +950,10 @@ float AXNodeObject::valueForRange() const |
if (hasAttribute(aria_valuenowAttr)) |
return getAttribute(aria_valuenowAttr).toFloat(); |
- if (node() && node()->hasTagName(inputTag)) { |
- HTMLInputElement* input = toHTMLInputElement(node()); |
- if (input->isRangeControl()) |
- return input->valueAsNumber(); |
+ if (isHTMLInputElement(node())) { |
+ HTMLInputElement& input = toHTMLInputElement(*node()); |
+ if (input.isRangeControl()) |
+ return input.valueAsNumber(); |
} |
return 0.0; |
@@ -966,10 +964,10 @@ float AXNodeObject::maxValueForRange() const |
if (hasAttribute(aria_valuemaxAttr)) |
return getAttribute(aria_valuemaxAttr).toFloat(); |
- if (node() && node()->hasTagName(inputTag)) { |
- HTMLInputElement* input = toHTMLInputElement(node()); |
- if (input->isRangeControl()) |
- return input->maximum(); |
+ if (isHTMLInputElement(node())) { |
+ HTMLInputElement& input = toHTMLInputElement(*node()); |
+ if (input.isRangeControl()) |
+ return input.maximum(); |
} |
return 0.0; |
@@ -980,10 +978,10 @@ float AXNodeObject::minValueForRange() const |
if (hasAttribute(aria_valueminAttr)) |
return getAttribute(aria_valueminAttr).toFloat(); |
- if (node() && node()->hasTagName(inputTag)) { |
- HTMLInputElement* input = toHTMLInputElement(node()); |
- if (input->isRangeControl()) |
- return input->minimum(); |
+ if (isHTMLInputElement(node())) { |
+ HTMLInputElement& input = toHTMLInputElement(*node()); |
+ if (input.isRangeControl()) |
+ return input.minimum(); |
} |
return 0.0; |
@@ -1010,17 +1008,17 @@ String AXNodeObject::stringValue() const |
if (node->isTextNode()) |
return textUnderElement(); |
- if (node->hasTagName(selectTag)) { |
- HTMLSelectElement* selectElement = toHTMLSelectElement(node); |
- int selectedIndex = selectElement->selectedIndex(); |
- const Vector<HTMLElement*> listItems = selectElement->listItems(); |
+ if (isHTMLSelectElement(*node)) { |
+ HTMLSelectElement& selectElement = toHTMLSelectElement(*node); |
+ int selectedIndex = selectElement.selectedIndex(); |
+ const Vector<HTMLElement*> listItems = selectElement.listItems(); |
if (selectedIndex >= 0 && static_cast<size_t>(selectedIndex) < listItems.size()) { |
const AtomicString& overriddenDescription = listItems[selectedIndex]->fastGetAttribute(aria_labelAttr); |
if (!overriddenDescription.isNull()) |
return overriddenDescription; |
} |
- if (!selectElement->multiple()) |
- return selectElement->value(); |
+ if (!selectElement.multiple()) |
+ return selectElement.value(); |
return String(); |
} |
@@ -1164,27 +1162,27 @@ String AXNodeObject::title() const |
if (!node) |
return String(); |
- bool isInputTag = node->hasTagName(inputTag); |
- if (isInputTag) { |
- HTMLInputElement* input = toHTMLInputElement(node); |
- if (input->isTextButton()) |
- return input->valueWithDefault(); |
+ bool isInputElement = isHTMLInputElement(*node); |
+ if (isInputElement) { |
+ HTMLInputElement& input = toHTMLInputElement(*node); |
+ if (input.isTextButton()) |
+ return input.valueWithDefault(); |
} |
- if (isInputTag || AXObject::isARIAInput(ariaRoleAttribute()) || isControl()) { |
+ if (isInputElement || AXObject::isARIAInput(ariaRoleAttribute()) || isControl()) { |
HTMLLabelElement* label = labelForElement(toElement(node)); |
if (label && !exposesTitleUIElement()) |
return label->innerText(); |
} |
// If this node isn't rendered, there's no inner text we can extract from a select element. |
- if (!isAXRenderObject() && node->hasTagName(selectTag)) |
+ if (!isAXRenderObject() && isHTMLSelectElement(*node)) |
return String(); |
switch (roleValue()) { |
case PopUpButtonRole: |
// Native popup buttons should not use their button children's text as a title. That value is retrieved through stringValue(). |
- if (node->hasTagName(selectTag)) |
+ if (isHTMLSelectElement(*node)) |
return String(); |
case ButtonRole: |
case ToggleButtonRole: |
@@ -1398,10 +1396,10 @@ Element* AXNodeObject::actionElement() const |
if (!node) |
return 0; |
- if (node->hasTagName(inputTag)) { |
- HTMLInputElement* input = toHTMLInputElement(node); |
- if (!input->isDisabledFormControl() && (isCheckboxOrRadio() || input->isTextButton())) |
- return input; |
+ if (isHTMLInputElement(*node)) { |
+ HTMLInputElement& input = toHTMLInputElement(*node); |
+ if (!input.isDisabledFormControl() && (isCheckboxOrRadio() || input.isTextButton())) |
+ return &input; |
} else if (node->hasTagName(buttonTag)) { |
return toElement(node); |
} |
@@ -1764,11 +1762,10 @@ void AXNodeObject::visibleText(Vector<AccessibilityText>& textOrder) const |
if (!node) |
return; |
- bool isInputTag = node->hasTagName(inputTag); |
- if (isInputTag) { |
- HTMLInputElement* input = toHTMLInputElement(node); |
- if (input->isTextButton()) { |
- textOrder.append(AccessibilityText(input->valueWithDefault(), VisibleText)); |
+ if (isHTMLInputElement(*node)) { |
+ HTMLInputElement& input = toHTMLInputElement(*node); |
+ if (input.isTextButton()) { |
+ textOrder.append(AccessibilityText(input.valueWithDefault(), VisibleText)); |
return; |
} |
} |