Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(969)

Unified Diff: Source/modules/accessibility/AXMenuListPopup.cpp

Issue 1020473004: Fire an event when a menu list option becomes unselected. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698