Chromium Code Reviews| 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..35150770b54cd2a7921997d856bfb5c2fea1e10d 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 = placeholderFromAttribute(); |
| 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; |
| } |
| @@ -2716,15 +2738,35 @@ String AXNodeObject::description(AXNameFrom nameFrom, |
| DescriptionSource& source = descriptionSources->last(); |
| source.type = descriptionFrom; |
| } |
| - HTMLElement* element = toHTMLElement(getNode()); |
| - const AtomicString& placeholder = |
| - element->fastGetAttribute(placeholderAttr); |
| + const String placeholder = placeholderFromAttribute(); |
| if (!placeholder.isEmpty()) { |
| - description = placeholder; |
| + description = AtomicString(placeholder); |
| + if (descriptionSources) { |
| + DescriptionSource& source = descriptionSources->last(); |
| + source.text = description; |
| + source.attributeValue = htmlElement->fastGetAttribute(placeholderAttr); |
| + foundDescription = true; |
| + } else { |
| + return description; |
| + } |
| + } |
| + |
| + // Also check for aria-placeholder. |
| + descriptionFrom = AXDescriptionFromPlaceholder; |
| + if (descriptionSources) { |
| + descriptionSources->append( |
| + DescriptionSource(foundDescription, aria_placeholderAttr)); |
| + DescriptionSource& source = descriptionSources->last(); |
| + source.type = descriptionFrom; |
| + } |
| + const AtomicString& ariaPlaceholder = |
| + htmlElement->fastGetAttribute(aria_placeholderAttr); |
| + if (!ariaPlaceholder.isEmpty()) { |
| + description = ariaPlaceholder; |
| if (descriptionSources) { |
| DescriptionSource& source = descriptionSources->last(); |
| source.text = description; |
| - source.attributeValue = placeholder; |
| + source.attributeValue = ariaPlaceholder; |
| foundDescription = true; |
| } else { |
| return description; |
| @@ -2885,15 +2927,18 @@ String AXNodeObject::placeholder(AXNameFrom nameFrom, |
| if (!getNode()) |
| return String(); |
| - String placeholder; |
| + return placeholderFromAttribute(); |
| +} |
| + |
| +String AXNodeObject::placeholderFromAttribute() const { |
| if (isHTMLInputElement(*getNode())) { |
|
dmazzoni
2016/11/15 18:11:15
You can clean up this code slightly, use isHTMLTex
|
| HTMLInputElement* inputElement = toHTMLInputElement(getNode()); |
| - placeholder = inputElement->strippedPlaceholder(); |
| + return inputElement->strippedPlaceholder(); |
| } else if (isHTMLTextAreaElement(*getNode())) { |
| HTMLTextAreaElement* textAreaElement = toHTMLTextAreaElement(getNode()); |
| - placeholder = textAreaElement->strippedPlaceholder(); |
| + return textAreaElement->strippedPlaceholder(); |
| } |
| - return placeholder; |
| + return String(); |
| } |
| DEFINE_TRACE(AXNodeObject) { |