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

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

Issue 1034493005: Fire AX notifications on list box options. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@menu_list_more
Patch Set: Update expectations for other test that failed 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
« no previous file with comments | « Source/modules/accessibility/AXListBox.h ('k') | Source/modules/accessibility/AXListBoxOption.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/accessibility/AXListBox.cpp
diff --git a/Source/modules/accessibility/AXListBox.cpp b/Source/modules/accessibility/AXListBox.cpp
index 6048272a83bc53aceeec4e67dd1bf0bf8ee040a9..615f58677ab7af62afa945ad3dcc3a46e579e5fa 100644
--- a/Source/modules/accessibility/AXListBox.cpp
+++ b/Source/modules/accessibility/AXListBox.cpp
@@ -29,6 +29,8 @@
#include "config.h"
#include "modules/accessibility/AXListBox.h"
+#include "core/html/HTMLOptionElement.h"
+#include "core/html/HTMLSelectElement.h"
#include "core/layout/LayoutListBox.h"
#include "modules/accessibility/AXListBoxOption.h"
#include "modules/accessibility/AXObjectCacheImpl.h"
@@ -39,7 +41,9 @@ using namespace HTMLNames;
AXListBox::AXListBox(LayoutObject* layoutObject, AXObjectCacheImpl* axObjectCache)
: AXLayoutObject(layoutObject, axObjectCache)
+ , m_activeIndex(-1)
{
+ activeIndexChanged();
}
AXListBox::~AXListBox()
@@ -59,4 +63,41 @@ AccessibilityRole AXListBox::roleValue() const
return ListBoxRole;
}
+AXObject* AXListBox::activeDescendant() const
+{
+ if (!isHTMLSelectElement(node()))
+ return nullptr;
+
+ HTMLSelectElement* select = toHTMLSelectElement(node());
+ int activeIndex = select->activeSelectionEndListIndex();
+ if (activeIndex >= 0 && activeIndex < static_cast<int>(select->length())) {
+ HTMLOptionElement* option = select->item(m_activeIndex);
+ return axObjectCache()->get(option);
+ }
+
+ return nullptr;
+}
+
+void AXListBox::activeIndexChanged()
+{
+ if (!isHTMLSelectElement(node()))
+ return;
+
+ HTMLSelectElement* select = toHTMLSelectElement(node());
+ int activeIndex = select->activeSelectionEndListIndex();
+ if (activeIndex == m_activeIndex)
+ return;
+
+ m_activeIndex = activeIndex;
+ if (!select->focused())
+ return;
+
+ if (m_activeIndex >= 0 && m_activeIndex < static_cast<int>(select->length())) {
+ HTMLOptionElement* option = select->item(m_activeIndex);
+ axObjectCache()->postNotification(option, AXObjectCacheImpl::AXFocusedUIElementChanged);
+ } else {
+ axObjectCache()->postNotification(this, AXObjectCacheImpl::AXFocusedUIElementChanged);
+ }
+}
+
} // namespace blink
« no previous file with comments | « Source/modules/accessibility/AXListBox.h ('k') | Source/modules/accessibility/AXListBoxOption.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698