This source file includes following definitions.
- create
- press
- addChildren
- childrenChanged
- isCollapsed
- canSetFocusAttribute
- didUpdateActiveOption
#include "config.h"
#include "core/accessibility/AXMenuList.h"
#include "core/accessibility/AXMenuListPopup.h"
#include "core/accessibility/AXObjectCache.h"
#include "core/rendering/RenderMenuList.h"
namespace WebCore {
AXMenuList::AXMenuList(RenderMenuList* renderer)
: AXRenderObject(renderer)
{
}
PassRefPtr<AXMenuList> AXMenuList::create(RenderMenuList* renderer)
{
return adoptRef(new AXMenuList(renderer));
}
bool AXMenuList::press() const
{
RenderMenuList* menuList = toRenderMenuList(m_renderer);
if (menuList->popupIsVisible())
menuList->hidePopup();
else
menuList->showPopup();
return true;
}
void AXMenuList::addChildren()
{
m_haveChildren = true;
AXObjectCache* cache = m_renderer->document().axObjectCache();
AXObject* list = cache->getOrCreate(MenuListPopupRole);
if (!list)
return;
toAXMockObject(list)->setParent(this);
if (list->accessibilityIsIgnored()) {
cache->remove(list->axObjectID());
return;
}
m_children.append(list);
list->addChildren();
}
void AXMenuList::childrenChanged()
{
if (m_children.isEmpty())
return;
ASSERT(m_children.size() == 1);
m_children[0]->childrenChanged();
}
bool AXMenuList::isCollapsed() const
{
return !toRenderMenuList(m_renderer)->popupIsVisible();
}
bool AXMenuList::canSetFocusAttribute() const
{
if (!node())
return false;
return !toElement(node())->isDisabledFormControl();
}
void AXMenuList::didUpdateActiveOption(int optionIndex)
{
RefPtr<Document> document(m_renderer->document());
AXObjectCache* cache = document->axObjectCache();
const AccessibilityChildrenVector& childObjects = children();
if (!childObjects.isEmpty()) {
ASSERT(childObjects.size() == 1);
ASSERT(childObjects[0]->isMenuListPopup());
if (childObjects[0]->isMenuListPopup()) {
if (AXMenuListPopup* popup = toAXMenuListPopup(childObjects[0].get()))
popup->didUpdateActiveOption(optionIndex);
}
}
cache->postNotification(this, document.get(), AXObjectCache::AXMenuListValueChanged, true, PostSynchronously);
}
}