Chromium Code Reviews| Index: third_party/WebKit/Source/modules/accessibility/AXObject.cpp |
| diff --git a/third_party/WebKit/Source/modules/accessibility/AXObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXObject.cpp |
| index f7145d1222ce32544ce1452749a5150af2eccd15..9b57268a1c7413016d765461dcacf817af08ca56 100644 |
| --- a/third_party/WebKit/Source/modules/accessibility/AXObject.cpp |
| +++ b/third_party/WebKit/Source/modules/accessibility/AXObject.cpp |
| @@ -392,6 +392,25 @@ Element* AXObject::GetAOMPropertyOrARIAAttribute( |
| return target ? target->element() : nullptr; |
| } |
| +bool AXObject::HasAOMProperty(AOMRelationListProperty property, |
| + HeapVector<Member<Element>>& result) const { |
| + Element* element = this->GetElement(); |
| + if (!element) |
| + return false; |
| + |
| + return AccessibleNode::GetProperty(element, property, result); |
| +} |
| + |
| +bool AXObject::HasAOMPropertyOrARIAAttribute( |
| + AOMRelationListProperty property, |
| + HeapVector<Member<Element>>& result) const { |
| + Element* element = this->GetElement(); |
| + if (!element) |
| + return false; |
| + |
| + return AccessibleNode::GetPropertyOrARIAAttribute(element, property, result); |
| +} |
| + |
| bool AXObject::HasAOMPropertyOrARIAAttribute(AOMBooleanProperty property, |
| bool& result) const { |
| Element* element = this->GetElement(); |
| @@ -975,6 +994,43 @@ String AXObject::AriaTextAlternative(bool recursive, |
| } |
| // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 |
| + // AOM version |
| + // If you change this logic, update AXNodeObject::nameFromLabelElement, too. |
| + if (!in_aria_labelled_by_traversal && !already_visited) { |
| + name_from = kAXNameFromRelatedElement; |
| + if (name_sources) { |
| + name_sources->push_back( |
| + NameSource(*found_text_alternative, aria_labeledbyAttr)); |
|
aboxhall
2017/07/06 05:37:14
Hm, I think we should have a different source for
dmazzoni
2017/07/06 06:34:25
For aria-label and almost every other place in the
aboxhall
2017/07/06 06:55:15
Makes sense!
|
| + name_sources->back().type = name_from; |
| + } |
| + |
| + HeapVector<Member<Element>> elements; |
| + if (HasAOMProperty(AOMRelationListProperty::kLabeledBy, elements)) { |
| + // Operate on a copy of |visited| so that if |nameSources| is not null, |
| + // the set of visited objects is preserved unmodified for future |
| + // calculations. |
| + AXObjectSet visited_copy = visited; |
| + text_alternative = |
| + TextFromElements(true, visited_copy, elements, related_objects); |
| + if (!text_alternative.IsNull()) { |
| + if (name_sources) { |
| + NameSource& source = name_sources->back(); |
| + source.type = name_from; |
| + source.related_objects = *related_objects; |
| + source.text = text_alternative; |
| + *found_text_alternative = true; |
| + } else { |
| + *found_text_alternative = true; |
| + return text_alternative; |
| + } |
| + } else if (name_sources) { |
| + name_sources->back().invalid = true; |
| + } |
| + } |
| + } |
| + |
| + // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 |
| + // ARIA version |
| // If you change this logic, update AXNodeObject::nameFromLabelElement, too. |
| if (!in_aria_labelled_by_traversal && !already_visited) { |
| const QualifiedName& attr = |