| Index: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
|
| diff --git a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
|
| index aaa46e3ea0a8703470793d30537c921900e69948..451fc90cb8ee77c1740dba22c93fa76f4bcf622d 100644
|
| --- a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
|
| +++ b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
|
| @@ -2369,19 +2369,41 @@ String AXNodeObject::nativeTextAlternative(
|
| NameSource& source = nameSources->last();
|
| source.type = nameFrom;
|
| }
|
| - HTMLElement* element = toHTMLElement(getNode());
|
| - const AtomicString& placeholder =
|
| - element->fastGetAttribute(placeholderAttr);
|
| + const String placeholder = placeholderFromNativeAttribute();
|
| if (!placeholder.isEmpty()) {
|
| textAlternative = placeholder;
|
| if (nameSources) {
|
| NameSource& source = nameSources->last();
|
| source.text = textAlternative;
|
| - source.attributeValue = placeholder;
|
| + source.attributeValue = htmlElement->fastGetAttribute(placeholderAttr);
|
| + *foundTextAlternative = true;
|
| } else {
|
| return textAlternative;
|
| }
|
| }
|
| +
|
| + // Also check for aria-placeholder.
|
| + nameFrom = AXNameFromPlaceholder;
|
| + if (nameSources) {
|
| + nameSources->append(
|
| + NameSource(*foundTextAlternative, aria_placeholderAttr));
|
| + NameSource& source = nameSources->last();
|
| + source.type = nameFrom;
|
| + }
|
| + const AtomicString& ariaPlaceholder =
|
| + htmlElement->fastGetAttribute(aria_placeholderAttr);
|
| + if (!ariaPlaceholder.isEmpty()) {
|
| + textAlternative = ariaPlaceholder;
|
| + if (nameSources) {
|
| + NameSource& source = nameSources->last();
|
| + source.text = textAlternative;
|
| + source.attributeValue = ariaPlaceholder;
|
| + *foundTextAlternative = true;
|
| + } else {
|
| + return textAlternative;
|
| + }
|
| + }
|
| +
|
| return textAlternative;
|
| }
|
|
|
| @@ -2705,33 +2727,6 @@ String AXNodeObject::description(AXNameFrom nameFrom,
|
| if (getNode()->isHTMLElement())
|
| htmlElement = toHTMLElement(getNode());
|
|
|
| - // placeholder, 5.1.2 from:
|
| - // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html
|
| - if (nameFrom != AXNameFromPlaceholder && htmlElement &&
|
| - htmlElement->isTextFormControl()) {
|
| - descriptionFrom = AXDescriptionFromPlaceholder;
|
| - if (descriptionSources) {
|
| - descriptionSources->append(
|
| - DescriptionSource(foundDescription, placeholderAttr));
|
| - DescriptionSource& source = descriptionSources->last();
|
| - source.type = descriptionFrom;
|
| - }
|
| - HTMLElement* element = toHTMLElement(getNode());
|
| - const AtomicString& placeholder =
|
| - element->fastGetAttribute(placeholderAttr);
|
| - if (!placeholder.isEmpty()) {
|
| - description = placeholder;
|
| - if (descriptionSources) {
|
| - DescriptionSource& source = descriptionSources->last();
|
| - source.text = description;
|
| - source.attributeValue = placeholder;
|
| - foundDescription = true;
|
| - } else {
|
| - return description;
|
| - }
|
| - }
|
| - }
|
| -
|
| const HTMLInputElement* inputElement = nullptr;
|
| if (isHTMLInputElement(getNode()))
|
| inputElement = toHTMLInputElement(getNode());
|
| @@ -2882,18 +2877,27 @@ String AXNodeObject::placeholder(AXNameFrom nameFrom,
|
| if (descriptionFrom == AXDescriptionFromPlaceholder)
|
| return String();
|
|
|
| - if (!getNode())
|
| + Node* node = getNode();
|
| + if (!node || !node->isHTMLElement())
|
| return String();
|
|
|
| - String placeholder;
|
| - if (isHTMLInputElement(*getNode())) {
|
| - HTMLInputElement* inputElement = toHTMLInputElement(getNode());
|
| - placeholder = inputElement->strippedPlaceholder();
|
| - } else if (isHTMLTextAreaElement(*getNode())) {
|
| - HTMLTextAreaElement* textAreaElement = toHTMLTextAreaElement(getNode());
|
| - placeholder = textAreaElement->strippedPlaceholder();
|
| - }
|
| - return placeholder;
|
| + String nativePlaceholder = placeholderFromNativeAttribute();
|
| + if (!nativePlaceholder.isEmpty())
|
| + return nativePlaceholder;
|
| +
|
| + const AtomicString& ariaPlaceholder =
|
| + toHTMLElement(node)->fastGetAttribute(aria_placeholderAttr);
|
| + if (!ariaPlaceholder.isEmpty())
|
| + return ariaPlaceholder;
|
| +
|
| + return String();
|
| +}
|
| +
|
| +String AXNodeObject::placeholderFromNativeAttribute() const {
|
| + Node* node = getNode();
|
| + if (!node || !isHTMLTextFormControlElement(node))
|
| + return String();
|
| + return toHTMLTextFormControlElement(node)->strippedPlaceholder();
|
| }
|
|
|
| DEFINE_TRACE(AXNodeObject) {
|
|
|