Index: third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp |
diff --git a/third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp b/third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp |
index 1b6ab5ef6c28c75678b977f027a140049ba61dc1..15c14aa20fa614c2ca42dfdf146b3c810b8b3b67 100644 |
--- a/third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp |
+++ b/third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp |
@@ -568,24 +568,29 @@ void AXObjectCacheImpl::RemoveAXID(AXObjectImpl* object) { |
aria_owner_to_ids_mapping_.erase(obj_id); |
} |
-void AXObjectCacheImpl::SelectionChanged(Node* node) { |
+AXObjectImpl* AXObjectCacheImpl::NearestExistingAncestor(Node* node) { |
// Find the nearest ancestor that already has an accessibility object, since |
// we might be in the middle of a layout. |
while (node) { |
- if (AXObjectImpl* obj = Get(node)) { |
- obj->SelectionChanged(); |
- return; |
- } |
+ if (AXObjectImpl* obj = Get(node)) |
+ return obj; |
node = node->parentNode(); |
} |
+ return nullptr; |
+} |
+ |
+void AXObjectCacheImpl::SelectionChanged(Node* node) { |
+ AXObjectImpl* nearestAncestor = NearestExistingAncestor(node); |
+ if (nearestAncestor) |
+ nearestAncestor->SelectionChanged(); |
} |
void AXObjectCacheImpl::TextChanged(Node* node) { |
- TextChanged(GetOrCreate(node)); |
+ TextChanged(Get(node)); |
} |
void AXObjectCacheImpl::TextChanged(LayoutObject* layout_object) { |
- TextChanged(GetOrCreate(layout_object)); |
+ TextChanged(Get(layout_object)); |
} |
void AXObjectCacheImpl::TextChanged(AXObjectImpl* obj) { |
@@ -1155,7 +1160,7 @@ void AXObjectCacheImpl::HandleValueChanged(Node* node) { |
void AXObjectCacheImpl::HandleUpdateActiveMenuOption(LayoutMenuList* menu_list, |
int option_index) { |
- AXObjectImpl* obj = Get(menu_list); |
+ AXObjectImpl* obj = GetOrCreate(menu_list); |
if (!obj || !obj->IsMenuList()) |
return; |