Chromium Code Reviews| Index: Source/modules/accessibility/AXListBox.cpp |
| diff --git a/Source/modules/accessibility/AXListBox.cpp b/Source/modules/accessibility/AXListBox.cpp |
| index 6048272a83bc53aceeec4e67dd1bf0bf8ee040a9..8d7c4b4b50382ea06934a13bc05b59cad5af358c 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 (!node() || !isHTMLSelectElement(node())) |
|
je_julie(Not used)
2015/03/31 03:51:04
When we use isHTMLXXXElement(const Node* node), we
dmazzoni
2015/03/31 06:57:37
Thanks!
|
| + 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 (!node() || !isHTMLSelectElement(node())) |
|
je_julie(Not used)
2015/03/31 03:51:04
Ditto.
dmazzoni
2015/03/31 06:57:37
Done.
|
| + 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 |