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..d5b07781b5731bb74a34d16c1455a94fe3ff4897 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 |
+ 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 == container && |
+ focused_object->ActiveDescendant() == this); |
} |
// |