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 da4d72af218316f257065688ce9d7808d3255574..b84837dbe22b10ad763ea87de56e9c7fffa131a0 100644 |
--- a/third_party/WebKit/Source/modules/accessibility/AXObject.cpp |
+++ b/third_party/WebKit/Source/modules/accessibility/AXObject.cpp |
@@ -748,6 +748,9 @@ String AXObject::name(NameSources* nameSources) const |
String AXObject::recursiveTextAlternative(const AXObject& axObj, bool inAriaLabelledByTraversal, AXObjectSet& visited) |
{ |
+ if (visited.contains(&axObj) && !inAriaLabelledByTraversal) |
+ return String(); |
+ |
AXNameFrom tmpNameFrom; |
return axObj.textAlternative(true, inAriaLabelledByTraversal, visited, tmpNameFrom, nullptr, nullptr); |
} |
@@ -802,8 +805,10 @@ String AXObject::ariaTextAlternative(bool recursive, bool inAriaLabelledByTraver |
if (nameSources) |
nameSources->last().attributeValue = ariaLabelledby; |
- textAlternative = textFromAriaLabelledby(visited, relatedObjects); |
- |
+ // 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 visitedCopy = visited; |
+ textAlternative = textFromAriaLabelledby(visitedCopy, relatedObjects); |
if (!textAlternative.isNull()) { |
if (nameSources) { |
NameSource& source = nameSources->last(); |