Index: Source/modules/accessibility/AXMenuListPopup.cpp |
diff --git a/Source/modules/accessibility/AXMenuListPopup.cpp b/Source/modules/accessibility/AXMenuListPopup.cpp |
index 907464056a7b69b4903c731f9d0dd6ef90f9b844..88021c39f68164e9b5eb8287a439a5385f514af6 100644 |
--- a/Source/modules/accessibility/AXMenuListPopup.cpp |
+++ b/Source/modules/accessibility/AXMenuListPopup.cpp |
@@ -35,7 +35,7 @@ namespace blink { |
using namespace HTMLNames; |
AXMenuListPopup::AXMenuListPopup(AXObjectCacheImpl* axObjectCache) |
- : AXMockObject(axObjectCache) |
+ : AXMockObject(axObjectCache), m_activeIndex(-1) |
{ |
} |
@@ -100,7 +100,9 @@ void AXMenuListPopup::addChildren() |
m_haveChildren = true; |
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = toHTMLSelectElement(selectNode)->listItems(); |
+ HTMLSelectElement* htmlSelectElement = toHTMLSelectElement(selectNode); |
+ m_activeIndex = htmlSelectElement->selectedIndex(); |
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = htmlSelectElement->listItems(); |
unsigned length = listItems.size(); |
for (unsigned i = 0; i < length; i++) { |
AXMenuListOption* option = menuListOptionAXObject(listItems[i]); |
@@ -141,10 +143,15 @@ void AXMenuListPopup::didUpdateActiveOption(int optionIndex) |
ASSERT_ARG(optionIndex, optionIndex < static_cast<int>(m_children.size())); |
AXObjectCacheImpl* cache = axObjectCache(); |
- RefPtr<AXObject> child = m_children[optionIndex].get(); |
+ if (m_activeIndex >= 0 && m_activeIndex < static_cast<int>(m_children.size())) { |
+ RefPtr<AXObject> previousChild = m_children[m_activeIndex].get(); |
+ cache->postNotification(previousChild.get(), document(), AXObjectCacheImpl::AXMenuListItemUnselected, true); |
+ } |
+ RefPtr<AXObject> child = m_children[optionIndex].get(); |
cache->postNotification(child.get(), document(), AXObjectCacheImpl::AXFocusedUIElementChanged, true); |
cache->postNotification(child.get(), document(), AXObjectCacheImpl::AXMenuListItemSelected, true); |
+ m_activeIndex = optionIndex; |
} |
} // namespace blink |