| 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
|
|
|