AX: aria-hidden on container does not hide descendant popup buttons
[WebKit-https.git] / Source / WebCore / accessibility / AccessibilityMenuList.cpp
index 7621a22..05a5632 100644 (file)
@@ -37,6 +37,11 @@ AccessibilityMenuList::AccessibilityMenuList(RenderMenuList* renderer)
 {
 }
 
+PassRefPtr<AccessibilityMenuList> AccessibilityMenuList::create(RenderMenuList* renderer)
+{
+    return adoptRef(new AccessibilityMenuList(renderer));
+}
+
 bool AccessibilityMenuList::press() const
 {
     RenderMenuList* menuList = static_cast<RenderMenuList*>(m_renderer);
@@ -57,12 +62,12 @@ void AccessibilityMenuList::addChildren()
     if (!list)
         return;
 
-    if (list->accessibilityPlatformIncludesObject() == IgnoreObject) {
+    static_cast<AccessibilityMockObject*>(list)->setParent(this);
+    if (list->accessibilityIsIgnored()) {
         cache->remove(list->axObjectID());
         return;
     }
 
-    static_cast<AccessibilityMenuListPopup*>(list)->setMenuList(this);
     m_children.append(list);
 
     list->addChildren();
@@ -82,20 +87,29 @@ bool AccessibilityMenuList::isCollapsed() const
     return !static_cast<RenderMenuList*>(m_renderer)->popupIsVisible();
 }
 
-void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
+bool AccessibilityMenuList::canSetFocusAttribute() const
 {
-    const AccessibilityChildrenVector& childObjects = children();
-    if (childObjects.isEmpty())
-        return;
+    if (!node())
+        return false;
 
-    ASSERT(childObjects.size() == 1);
-    ASSERT(childObjects[0]->isMenuListPopup());
+    return toElement(node())->isEnabledFormControl();
+}
 
+void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
+{
     RefPtr<Document> document = m_renderer->document();
     AXObjectCache* cache = document->axObjectCache();
 
-    if (AccessibilityMenuListPopup* popup = static_cast<AccessibilityMenuListPopup*>(childObjects[0].get()))
-        popup->didUpdateActiveOption(optionIndex);
+    const AccessibilityChildrenVector& childObjects = children();
+    if (!childObjects.isEmpty()) {
+        ASSERT(childObjects.size() == 1);
+        ASSERT(childObjects[0]->isMenuListPopup());
+
+        if (childObjects[0]->isMenuListPopup()) {
+            if (AccessibilityMenuListPopup* popup = static_cast<AccessibilityMenuListPopup*>(childObjects[0].get()))
+                popup->didUpdateActiveOption(optionIndex);
+        }
+    }
 
     cache->postNotification(this, document.get(), AXObjectCache::AXMenuListValueChanged, true, PostSynchronously);
 }