Index: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
diff --git a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
index 803370747873c15192e64a72b909aa4aea3faaa8..1d61300aa072ec93cf624494b1b718e3ab5f8b46 100644 |
--- a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
+++ b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
@@ -457,22 +457,28 @@ bool AXLayoutObject::IsFocused() const { |
} |
bool AXLayoutObject::IsSelected() const { |
- if (!GetLayoutObject() || !GetNode()) |
+ if (!GetLayoutObject() || !GetNode() || !CanSetSelectedAttribute()) |
return false; |
- if (AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kSelected)) |
- return true; |
- |
- AXObjectImpl* focused_object = AxObjectCache().FocusedObject(); |
- if (AriaRoleAttribute() == kListBoxOptionRole && focused_object && |
- focused_object->ActiveDescendant() == this) { |
- return true; |
- } |
+ // aria-selected overrides automatic behaviors |
David Tseng
2017/06/06 20:58:30
Note that this doesn't actually happen because the
|
+ bool is_selected; |
+ if (HasAOMPropertyOrARIAAttribute(AOMBooleanProperty::kSelected, is_selected)) |
+ return is_selected; |
+ // Tab item with focus in the associated tab |
if (IsTabItem() && IsTabItemSelected()) |
return true; |
- return false; |
+ // Selection follows focus, but ONLY in single selection containers, |
+ // and only if aria-selected was not present to override |
+ |
+ AXObjectImpl* container = ContainerWidget(); |
+ if (!container || container->IsMultiSelectable()) |
+ return false; |
+ |
+ AXObjectImpl* focused_object = AxObjectCache().FocusedObject(); |
+ return focused_object == this || |
+ (focused_object && focused_object->ActiveDescendant() == this); |
} |
// |