AccessibilityMenuList.cpp [plain text]
#include "config.h"
#include "AccessibilityMenuList.h"
#include "AXObjectCache.h"
#include "AccessibilityMenuListPopup.h"
#include "RenderMenuList.h"
namespace WebCore {
AccessibilityMenuList::AccessibilityMenuList(RenderMenuList* renderer)
: AccessibilityRenderObject(renderer)
{
}
bool AccessibilityMenuList::press() const
{
RenderMenuList* menuList = static_cast<RenderMenuList*>(m_renderer);
if (menuList->popupIsVisible())
menuList->hidePopup();
else
menuList->showPopup();
return true;
}
void AccessibilityMenuList::addChildren()
{
m_haveChildren = true;
AXObjectCache* cache = m_renderer->document()->axObjectCache();
AccessibilityObject* list = cache->getOrCreate(MenuListPopupRole);
if (!list)
return;
if (list->accessibilityPlatformIncludesObject() == IgnoreObject) {
cache->remove(list->axObjectID());
return;
}
static_cast<AccessibilityMockObject*>(list)->setParent(this);
m_children.append(list);
list->addChildren();
}
void AccessibilityMenuList::childrenChanged()
{
if (m_children.isEmpty())
return;
ASSERT(m_children.size() == 1);
m_children[0]->childrenChanged();
}
bool AccessibilityMenuList::isCollapsed() const
{
return !static_cast<RenderMenuList*>(m_renderer)->popupIsVisible();
}
void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
{
const AccessibilityChildrenVector& childObjects = children();
if (childObjects.isEmpty())
return;
ASSERT(childObjects.size() == 1);
ASSERT(childObjects[0]->isMenuListPopup());
RefPtr<Document> document = m_renderer->document();
AXObjectCache* cache = document->axObjectCache();
if (AccessibilityMenuListPopup* popup = static_cast<AccessibilityMenuListPopup*>(childObjects[0].get()))
popup->didUpdateActiveOption(optionIndex);
cache->postNotification(this, document.get(), AXObjectCache::AXMenuListValueChanged, true, PostSynchronously);
}
}