This source file includes following definitions.
- isVisible
- isOffScreen
- isEnabled
- computeAccessibilityIsIgnored
- menuListOptionAXObject
- press
- addChildren
- childrenChanged
- didUpdateActiveOption
#include "config.h"
#include "core/accessibility/AXMenuListPopup.h"
#include "core/accessibility/AXMenuListOption.h"
#include "core/accessibility/AXObjectCache.h"
#include "core/html/HTMLSelectElement.h"
namespace WebCore {
using namespace HTMLNames;
AXMenuListPopup::AXMenuListPopup()
{
}
bool AXMenuListPopup::isVisible() const
{
return false;
}
bool AXMenuListPopup::isOffScreen() const
{
if (!m_parent)
return true;
return m_parent->isCollapsed();
}
bool AXMenuListPopup::isEnabled() const
{
if (!m_parent)
return false;
return m_parent->isEnabled();
}
bool AXMenuListPopup::computeAccessibilityIsIgnored() const
{
return accessibilityIsIgnoredByDefault();
}
AXMenuListOption* AXMenuListPopup::menuListOptionAXObject(HTMLElement* element) const
{
ASSERT(element);
if (!isHTMLOptionElement(*element))
return 0;
AXObject* object = document()->axObjectCache()->getOrCreate(MenuListOptionRole);
ASSERT_WITH_SECURITY_IMPLICATION(object->isMenuListOption());
AXMenuListOption* option = toAXMenuListOption(object);
option->setElement(element);
return option;
}
bool AXMenuListPopup::press() const
{
if (!m_parent)
return false;
m_parent->press();
return true;
}
void AXMenuListPopup::addChildren()
{
if (!m_parent)
return;
Node* selectNode = m_parent->node();
if (!selectNode)
return;
m_haveChildren = true;
const Vector<HTMLElement*>& listItems = toHTMLSelectElement(selectNode)->listItems();
unsigned length = listItems.size();
for (unsigned i = 0; i < length; i++) {
AXMenuListOption* option = menuListOptionAXObject(listItems[i]);
if (option) {
option->setParent(this);
m_children.append(option);
}
}
}
void AXMenuListPopup::childrenChanged()
{
AXObjectCache* cache = axObjectCache();
for (size_t i = m_children.size(); i > 0 ; --i) {
AXObject* child = m_children[i - 1].get();
if (child->actionElement()) {
child->detachFromParent();
cache->remove(child->axObjectID());
}
}
m_children.clear();
m_haveChildren = false;
}
void AXMenuListPopup::didUpdateActiveOption(int optionIndex)
{
if (!m_haveChildren)
addChildren();
ASSERT_ARG(optionIndex, optionIndex >= 0);
ASSERT_ARG(optionIndex, optionIndex < static_cast<int>(m_children.size()));
AXObjectCache* cache = axObjectCache();
RefPtr<AXObject> child = m_children[optionIndex].get();
cache->postNotification(child.get(), document(), AXObjectCache::AXFocusedUIElementChanged, true, PostSynchronously);
cache->postNotification(child.get(), document(), AXObjectCache::AXMenuListItemSelected, true, PostSynchronously);
}
}