AX: re-organize fake elements to use new AccessibilityMockObject
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Oct 2011 19:12:59 +0000 (19:12 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Oct 2011 19:12:59 +0000 (19:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69588

This adds an AccessibilityMockObject for "fake" elements to descend from.
Its benefit is to consolidate the various ways that these fake elements are setting
and returning their parent objects.

No functional change, hence no new tests.

Reviewed by Jon Honeycutt.

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* accessibility/AccessibilityARIAGrid.cpp:
(WebCore::AccessibilityARIAGrid::addChildren):
* accessibility/AccessibilityImageMapLink.cpp:
(WebCore::AccessibilityImageMapLink::AccessibilityImageMapLink):
* accessibility/AccessibilityImageMapLink.h:
(WebCore::AccessibilityImageMapLink::node):
* accessibility/AccessibilityMenuList.cpp:
(WebCore::AccessibilityMenuList::addChildren):
* accessibility/AccessibilityMenuList.h:
(WebCore::toAccessibilityMenuList):
* accessibility/AccessibilityMenuListOption.cpp:
(WebCore::AccessibilityMenuListOption::AccessibilityMenuListOption):
(WebCore::AccessibilityMenuListOption::isVisible):
* accessibility/AccessibilityMenuListOption.h:
* accessibility/AccessibilityMenuListPopup.cpp:
(WebCore::AccessibilityMenuListPopup::AccessibilityMenuListPopup):
(WebCore::AccessibilityMenuListPopup::isOffScreen):
(WebCore::AccessibilityMenuListPopup::isEnabled):
(WebCore::AccessibilityMenuListPopup::menuListOptionAccessibilityObject):
(WebCore::AccessibilityMenuListPopup::press):
(WebCore::AccessibilityMenuListPopup::addChildren):
(WebCore::AccessibilityMenuListPopup::childrenChanged):
(WebCore::AccessibilityMenuListPopup::didUpdateActiveOption):
* accessibility/AccessibilityMenuListPopup.h:
* accessibility/AccessibilityMockObject.cpp: Added.
(WebCore::AccessibilityMockObject::AccessibilityMockObject):
(WebCore::AccessibilityMockObject::~AccessibilityMockObject):
* accessibility/AccessibilityMockObject.h: Added.
(WebCore::AccessibilityMockObject::parentObject):
(WebCore::AccessibilityMockObject::setParent):
(WebCore::AccessibilityMockObject::detachFromParent):
* accessibility/AccessibilitySlider.cpp:
(WebCore::AccessibilitySlider::addChildren):
(WebCore::AccessibilitySliderThumb::AccessibilitySliderThumb):
(WebCore::AccessibilitySliderThumb::elementRect):
* accessibility/AccessibilitySlider.h:
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::addChildren):
(WebCore::AccessibilityTable::headerContainer):
* accessibility/AccessibilityTable.h:
(WebCore::toAccessibilityTable):
* accessibility/AccessibilityTableColumn.cpp:
(WebCore::AccessibilityTableColumn::AccessibilityTableColumn):
(WebCore::AccessibilityTableColumn::setParent):
(WebCore::AccessibilityTableColumn::headerObject):
(WebCore::AccessibilityTableColumn::headerObjectForSection):
(WebCore::AccessibilityTableColumn::accessibilityIsIgnored):
(WebCore::AccessibilityTableColumn::addChildren):
* accessibility/AccessibilityTableColumn.h:
* accessibility/AccessibilityTableHeaderContainer.cpp:
(WebCore::AccessibilityTableHeaderContainer::AccessibilityTableHeaderContainer):
(WebCore::AccessibilityTableHeaderContainer::accessibilityIsIgnored):
(WebCore::AccessibilityTableHeaderContainer::addChildren):
* accessibility/AccessibilityTableHeaderContainer.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96966 268f45cc-cd09-0410-ab3c-d52691b4dbfc

26 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/accessibility/AccessibilityARIAGrid.cpp
Source/WebCore/accessibility/AccessibilityImageMapLink.cpp
Source/WebCore/accessibility/AccessibilityImageMapLink.h
Source/WebCore/accessibility/AccessibilityMenuList.cpp
Source/WebCore/accessibility/AccessibilityMenuList.h
Source/WebCore/accessibility/AccessibilityMenuListOption.cpp
Source/WebCore/accessibility/AccessibilityMenuListOption.h
Source/WebCore/accessibility/AccessibilityMenuListPopup.cpp
Source/WebCore/accessibility/AccessibilityMenuListPopup.h
Source/WebCore/accessibility/AccessibilityMockObject.cpp [new file with mode: 0644]
Source/WebCore/accessibility/AccessibilityMockObject.h [new file with mode: 0644]
Source/WebCore/accessibility/AccessibilitySlider.cpp
Source/WebCore/accessibility/AccessibilitySlider.h
Source/WebCore/accessibility/AccessibilityTable.cpp
Source/WebCore/accessibility/AccessibilityTable.h
Source/WebCore/accessibility/AccessibilityTableColumn.cpp
Source/WebCore/accessibility/AccessibilityTableColumn.h
Source/WebCore/accessibility/AccessibilityTableHeaderContainer.cpp
Source/WebCore/accessibility/AccessibilityTableHeaderContainer.h

index 536e6ce..49018fc 100644 (file)
@@ -401,6 +401,7 @@ SET(WebCore_SOURCES
     accessibility/AccessibilityMenuList.cpp
     accessibility/AccessibilityMenuListOption.cpp
     accessibility/AccessibilityMenuListPopup.cpp
+    accessibility/AccessibilityMockObject.cpp
     accessibility/AccessibilityObject.cpp
     accessibility/AccessibilityRenderObject.cpp
     accessibility/AccessibilityScrollbar.cpp
index e620274..712116c 100644 (file)
@@ -1,3 +1,77 @@
+2011-10-07  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: re-organize fake elements to use new AccessibilityMockObject
+        https://bugs.webkit.org/show_bug.cgi?id=69588
+
+        This adds an AccessibilityMockObject for "fake" elements to descend from.
+        Its benefit is to consolidate the various ways that these fake elements are setting
+        and returning their parent objects.
+
+        No functional change, hence no new tests.
+
+        Reviewed by Jon Honeycutt.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * accessibility/AccessibilityARIAGrid.cpp:
+        (WebCore::AccessibilityARIAGrid::addChildren):
+        * accessibility/AccessibilityImageMapLink.cpp:
+        (WebCore::AccessibilityImageMapLink::AccessibilityImageMapLink):
+        * accessibility/AccessibilityImageMapLink.h:
+        (WebCore::AccessibilityImageMapLink::node):
+        * accessibility/AccessibilityMenuList.cpp:
+        (WebCore::AccessibilityMenuList::addChildren):
+        * accessibility/AccessibilityMenuList.h:
+        (WebCore::toAccessibilityMenuList):
+        * accessibility/AccessibilityMenuListOption.cpp:
+        (WebCore::AccessibilityMenuListOption::AccessibilityMenuListOption):
+        (WebCore::AccessibilityMenuListOption::isVisible):
+        * accessibility/AccessibilityMenuListOption.h:
+        * accessibility/AccessibilityMenuListPopup.cpp:
+        (WebCore::AccessibilityMenuListPopup::AccessibilityMenuListPopup):
+        (WebCore::AccessibilityMenuListPopup::isOffScreen):
+        (WebCore::AccessibilityMenuListPopup::isEnabled):
+        (WebCore::AccessibilityMenuListPopup::menuListOptionAccessibilityObject):
+        (WebCore::AccessibilityMenuListPopup::press):
+        (WebCore::AccessibilityMenuListPopup::addChildren):
+        (WebCore::AccessibilityMenuListPopup::childrenChanged):
+        (WebCore::AccessibilityMenuListPopup::didUpdateActiveOption):
+        * accessibility/AccessibilityMenuListPopup.h:
+        * accessibility/AccessibilityMockObject.cpp: Added.
+        (WebCore::AccessibilityMockObject::AccessibilityMockObject):
+        (WebCore::AccessibilityMockObject::~AccessibilityMockObject):
+        * accessibility/AccessibilityMockObject.h: Added.
+        (WebCore::AccessibilityMockObject::parentObject):
+        (WebCore::AccessibilityMockObject::setParent):
+        (WebCore::AccessibilityMockObject::detachFromParent):
+        * accessibility/AccessibilitySlider.cpp:
+        (WebCore::AccessibilitySlider::addChildren):
+        (WebCore::AccessibilitySliderThumb::AccessibilitySliderThumb):
+        (WebCore::AccessibilitySliderThumb::elementRect):
+        * accessibility/AccessibilitySlider.h:
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::addChildren):
+        (WebCore::AccessibilityTable::headerContainer):
+        * accessibility/AccessibilityTable.h:
+        (WebCore::toAccessibilityTable):
+        * accessibility/AccessibilityTableColumn.cpp:
+        (WebCore::AccessibilityTableColumn::AccessibilityTableColumn):
+        (WebCore::AccessibilityTableColumn::setParent):
+        (WebCore::AccessibilityTableColumn::headerObject):
+        (WebCore::AccessibilityTableColumn::headerObjectForSection):
+        (WebCore::AccessibilityTableColumn::accessibilityIsIgnored):
+        (WebCore::AccessibilityTableColumn::addChildren):
+        * accessibility/AccessibilityTableColumn.h:
+        * accessibility/AccessibilityTableHeaderContainer.cpp:
+        (WebCore::AccessibilityTableHeaderContainer::AccessibilityTableHeaderContainer):
+        (WebCore::AccessibilityTableHeaderContainer::accessibilityIsIgnored):
+        (WebCore::AccessibilityTableHeaderContainer::addChildren):
+        * accessibility/AccessibilityTableHeaderContainer.h:
+
 2011-10-07  Nate Chapin  <japhet@chromium.org>
 
         Make IconLoader a CachedResourceClient instead of a SubresourceLoaderClient.
index 0eb46e8..5efb71d 100644 (file)
@@ -618,6 +618,8 @@ webcore_sources += \
        Source/WebCore/accessibility/AccessibilityMenuListOption.h \
        Source/WebCore/accessibility/AccessibilityMenuListPopup.cpp \
        Source/WebCore/accessibility/AccessibilityMenuListPopup.h \
+       Source/WebCore/accessibility/AccessibilityMockObject.cpp \
+       Source/WebCore/accessibility/AccessibilityMockObject.h \
        Source/WebCore/accessibility/AccessibilityObject.cpp \
        Source/WebCore/accessibility/AccessibilityObject.h \
        Source/WebCore/accessibility/AccessibilityProgressIndicator.cpp \
index 0d2fdda..11ab4eb 100644 (file)
             'accessibility/AccessibilityMenuListOption.h',
             'accessibility/AccessibilityMenuListPopup.cpp',
             'accessibility/AccessibilityMenuListPopup.h',
+            'accessibility/AccessibilityMockObject.cpp',
+            'accessibility/AccessibilityMockObject.h',
             'accessibility/AccessibilityObject.cpp',
             'accessibility/AccessibilityProgressIndicator.cpp',
             'accessibility/AccessibilityProgressIndicator.h',
index 0686495..064dc98 100644 (file)
@@ -33,6 +33,7 @@ SOURCES += \
     accessibility/AccessibilityMenuList.cpp \
     accessibility/AccessibilityMenuListOption.cpp \
     accessibility/AccessibilityMenuListPopup.cpp \
+    accessibility/AccessibilityMockObject.cpp \    
     accessibility/AccessibilityObject.cpp \    
     accessibility/AccessibilityList.cpp \    
     accessibility/AccessibilityListBox.cpp \    
index d1ecb5e..24b8e6a 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\accessibility\AccessibilityMockObject.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\accessibility\AccessibilityMockObject.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\accessibility\AccessibilityObject.cpp"
                                >
                                <FileConfiguration
index 8775b3c..d2a4241 100644 (file)
                29A812490FBB9CA900510293 /* WebAccessibilityObjectWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 29A812450FBB9CA900510293 /* WebAccessibilityObjectWrapper.h */; };
                29A8124A0FBB9CA900510293 /* WebAccessibilityObjectWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29A812460FBB9CA900510293 /* WebAccessibilityObjectWrapper.mm */; };
                29A8124B0FBB9CA900510293 /* AXObjectCacheMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29A812470FBB9CA900510293 /* AXObjectCacheMac.mm */; };
+               29ACB212143E7128006BCA5F /* AccessibilityMockObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 29ACB211143E7128006BCA5F /* AccessibilityMockObject.h */; };
+               29ACB214143E7498006BCA5F /* AccessibilityMockObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29ACB213143E7498006BCA5F /* AccessibilityMockObject.cpp */; };
                2BE8E2C712A589EC00FAD550 /* HTMLMetaCharsetParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */; };
                2BE8E2C912A58A0100FAD550 /* HTMLMetaCharsetParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */; };
                2D3A0E3613A7D76100E85AF0 /* SVGParsingError.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */; settings = {ATTRIBUTES = (Private, ); }; };
                29A812450FBB9CA900510293 /* WebAccessibilityObjectWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAccessibilityObjectWrapper.h; sourceTree = "<group>"; };
                29A812460FBB9CA900510293 /* WebAccessibilityObjectWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAccessibilityObjectWrapper.mm; sourceTree = "<group>"; };
                29A812470FBB9CA900510293 /* AXObjectCacheMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AXObjectCacheMac.mm; sourceTree = "<group>"; };
+               29ACB211143E7128006BCA5F /* AccessibilityMockObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityMockObject.h; sourceTree = "<group>"; };
+               29ACB213143E7498006BCA5F /* AccessibilityMockObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityMockObject.cpp; sourceTree = "<group>"; };
                2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLMetaCharsetParser.h; path = parser/HTMLMetaCharsetParser.h; sourceTree = "<group>"; };
                2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLMetaCharsetParser.cpp; path = parser/HTMLMetaCharsetParser.cpp; sourceTree = "<group>"; };
                2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGParsingError.h; sourceTree = "<group>"; };
                                76CDD2F11103DA6600680521 /* AccessibilityMenuListOption.h */,
                                76CDD2EE1103DA6600680521 /* AccessibilityMenuListPopup.cpp */,
                                76CDD2EF1103DA6600680521 /* AccessibilityMenuListPopup.h */,
+                               29ACB213143E7498006BCA5F /* AccessibilityMockObject.cpp */,
+                               29ACB211143E7128006BCA5F /* AccessibilityMockObject.h */,
                                2981CAA5131822EC00D12F2A /* AccessibilityObject.cpp */,
                                29A812180FBB9C1D00510293 /* AccessibilityObject.h */,
                                A409C982116D0DDD007197BD /* AccessibilityProgressIndicator.cpp */,
                                310603751432819C00ABF4BA /* JSWebKitCSSFilterValue.h in Headers */,
                                31060379143281CD00ABF4BA /* DOMWebKitCSSFilterValue.h in Headers */,
                                3106037B143281CD00ABF4BA /* DOMWebKitCSSFilterValueInternal.h in Headers */,
+                               29ACB212143E7128006BCA5F /* AccessibilityMockObject.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                3106036F14327D2E00ABF4BA /* WebKitCSSFilterValue.cpp in Sources */,
                                310603741432819C00ABF4BA /* JSWebKitCSSFilterValue.cpp in Sources */,
                                3106037A143281CD00ABF4BA /* DOMWebKitCSSFilterValue.mm in Sources */,
+                               29ACB214143E7498006BCA5F /* AccessibilityMockObject.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 645b4cc..cc12c3e 100644 (file)
@@ -126,7 +126,7 @@ void AccessibilityARIAGrid::addChildren()
     for (unsigned i = 0; i < columnCount; ++i) {
         AccessibilityTableColumn* column = static_cast<AccessibilityTableColumn*>(axCache->getOrCreate(ColumnRole));
         column->setColumnIndex((int)i);
-        column->setParentTable(this);
+        column->setParent(this);
         m_columns.append(column);
         if (!column->accessibilityIsIgnored())
             m_children.append(column);
index 5b6d3a7..13ff212 100644 (file)
@@ -42,7 +42,6 @@ using namespace HTMLNames;
 AccessibilityImageMapLink::AccessibilityImageMapLink()
     : m_areaElement(0)
     , m_mapElement(0)
-    , m_parent(0)
 {
 }
 
index 6d14f0d..bc6ce3c 100644 (file)
 #ifndef AccessibilityImageMapLink_h
 #define AccessibilityImageMapLink_h
 
-#include "AccessibilityObject.h"
+#include "AccessibilityMockObject.h"
 #include "HTMLAreaElement.h"
 #include "HTMLMapElement.h"
 
 namespace WebCore {
     
-class AccessibilityImageMapLink : public AccessibilityObject {
+class AccessibilityImageMapLink : public AccessibilityMockObject {
         
 private:
     AccessibilityImageMapLink();
@@ -50,13 +50,11 @@ public:
     HTMLMapElement* mapElement() const { return m_mapElement.get(); }
     
     virtual Node* node() const { return m_areaElement.get(); }
-    void setParent(AccessibilityObject* parent) { m_parent = parent; }
         
     virtual AccessibilityRole roleValue() const;
     virtual bool accessibilityIsIgnored() const { return false; }
     virtual bool isEnabled() const { return true; }
     
-    virtual AccessibilityObject* parentObject() const;
     virtual Element* anchorElement() const;
     virtual Element* actionElement() const;
     virtual KURL url() const;
@@ -64,7 +62,8 @@ public:
     virtual bool isLinked() const { return true; }
     virtual String title() const;
     virtual String accessibilityDescription() const;
-
+    virtual AccessibilityObject* parentObject() const;
+    
     virtual String stringValueForMSAA() const;
     virtual String nameForMSAA() const;
 
@@ -73,7 +72,6 @@ public:
 private:    
     RefPtr<HTMLAreaElement> m_areaElement;
     RefPtr<HTMLMapElement> m_mapElement;
-    AccessibilityObject* m_parent;
     
     virtual bool isImageMapLink() const { return true; }
 };
index 7621a22..2cbc377 100644 (file)
@@ -62,7 +62,7 @@ void AccessibilityMenuList::addChildren()
         return;
     }
 
-    static_cast<AccessibilityMenuListPopup*>(list)->setMenuList(this);
+    static_cast<AccessibilityMockObject*>(list)->setParent(this);
     m_children.append(list);
 
     list->addChildren();
index 68f424f..8a3016a 100644 (file)
@@ -56,6 +56,12 @@ private:
     virtual void childrenChanged();
 };
 
+inline AccessibilityMenuList* toAccessibilityMenuList(AccessibilityObject* object)
+{
+    ASSERT(!object || object->isMenuList());
+    return static_cast<AccessibilityMenuList*>(object);
+}
+
 } // namespace WebCore
 
 #endif // AccessibilityMenuList_h
index c706512..3d4f562 100644 (file)
@@ -36,7 +36,6 @@ namespace WebCore {
 using namespace HTMLNames;
 
 AccessibilityMenuListOption::AccessibilityMenuListOption()
-    : m_popup(0)
 {
 }
 
@@ -50,12 +49,7 @@ Element* AccessibilityMenuListOption::actionElement() const
 {
     return m_element.get();
 }
-
-AccessibilityObject* AccessibilityMenuListOption::parentObject() const
-{
-    return m_popup;
-}
-
+    
 bool AccessibilityMenuListOption::isEnabled() const
 {
     // disabled() returns true if the parent <select> element is disabled,
@@ -67,7 +61,7 @@ bool AccessibilityMenuListOption::isVisible() const
 {
     // In a single-option select with the popup collapsed, only the selected
     // item is considered visible.
-    return !m_popup->isOffScreen() || isSelected();
+    return !m_parent->isOffScreen() || isSelected();
 }
 
 bool AccessibilityMenuListOption::isOffScreen() const
index f225927..d2c4613 100644 (file)
 #ifndef AccessibilityMenuListOption_h
 #define AccessibilityMenuListOption_h
 
-#include "AccessibilityObject.h"
+#include "AccessibilityMockObject.h"
 
 namespace WebCore {
 
 class AccessibilityMenuListPopup;
 class HTMLElement;
 
-class AccessibilityMenuListOption : public AccessibilityObject {
+class AccessibilityMenuListOption : public AccessibilityMockObject {
 public:
     static PassRefPtr<AccessibilityMenuListOption> create() { return adoptRef(new AccessibilityMenuListOption); }
 
     void setElement(HTMLElement*);
-    void setParent(AccessibilityMenuListPopup* popup) { m_popup = popup; }
 
 private:
     AccessibilityMenuListOption();
@@ -50,7 +49,6 @@ private:
     virtual LayoutSize size() const { return elementRect().size(); }
 
     virtual Element* actionElement() const;
-    virtual AccessibilityObject* parentObject() const;
     virtual bool isEnabled() const;
     virtual bool isVisible() const;
     virtual bool isOffScreen() const;
@@ -62,7 +60,6 @@ private:
     virtual String stringValue() const;
 
     RefPtr<HTMLElement> m_element;
-    AccessibilityMenuListPopup* m_popup;
 };
 
 } // namespace WebCore
index 7cf8918..d982677 100644 (file)
@@ -38,7 +38,6 @@ namespace WebCore {
 using namespace HTMLNames;
 
 AccessibilityMenuListPopup::AccessibilityMenuListPopup()
-    : m_menuList(0)
 {
 }
 
@@ -49,17 +48,12 @@ bool AccessibilityMenuListPopup::isVisible() const
 
 bool AccessibilityMenuListPopup::isOffScreen() const
 {
-    return m_menuList->isCollapsed();
-}
-
-AccessibilityObject* AccessibilityMenuListPopup::parentObject() const
-{
-    return m_menuList;
+    return m_parent->isCollapsed();
 }
 
 bool AccessibilityMenuListPopup::isEnabled() const
 {
-    return m_menuList->isEnabled();
+    return m_parent->isEnabled();
 }
 
 AccessibilityMenuListOption* AccessibilityMenuListPopup::menuListOptionAccessibilityObject(HTMLElement* element) const
@@ -67,7 +61,7 @@ AccessibilityMenuListOption* AccessibilityMenuListPopup::menuListOptionAccessibi
     if (!element || !element->hasTagName(optionTag))
         return 0;
 
-    AccessibilityObject* object = m_menuList->renderer()->document()->axObjectCache()->getOrCreate(MenuListOptionRole);
+    AccessibilityObject* object = document()->axObjectCache()->getOrCreate(MenuListOptionRole);
     ASSERT(object->isMenuListOption());
 
     AccessibilityMenuListOption* option = static_cast<AccessibilityMenuListOption*>(object);
@@ -78,13 +72,13 @@ AccessibilityMenuListOption* AccessibilityMenuListPopup::menuListOptionAccessibi
 
 bool AccessibilityMenuListPopup::press() const
 {
-    m_menuList->press();
+    m_parent->press();
     return true;
 }
 
 void AccessibilityMenuListPopup::addChildren()
 {
-    Node* selectNode = m_menuList->renderer()->node();
+    Node* selectNode = m_parent->node();
     if (!selectNode)
         return;
 
@@ -105,35 +99,28 @@ void AccessibilityMenuListPopup::addChildren()
 
 void AccessibilityMenuListPopup::childrenChanged()
 {
+    AXObjectCache* cache = axObjectCache();
     for (size_t i = m_children.size(); i > 0 ; --i) {
         AccessibilityObject* child = m_children[i - 1].get();
-        if (child->actionElement() && !child->actionElement()->attached()) {
-            m_menuList->renderer()->document()->axObjectCache()->remove(child->axObjectID());
-        }
+        if (child->actionElement() && !child->actionElement()->attached())
+            cache->remove(child->axObjectID());
     }
+    
     m_children.clear();
     m_haveChildren = false;
     addChildren();
 }
 
-void AccessibilityMenuListPopup::setMenuList(AccessibilityMenuList* menuList)
-{
-    ASSERT_ARG(menuList, menuList);
-    ASSERT(!m_menuList);
-    m_menuList = menuList;
-}
-
 void AccessibilityMenuListPopup::didUpdateActiveOption(int optionIndex)
 {
     ASSERT_ARG(optionIndex, optionIndex >= 0);
     ASSERT_ARG(optionIndex, optionIndex < static_cast<int>(m_children.size()));
 
-    RefPtr<Document> document = m_menuList->renderer()->document();
-    AXObjectCache* cache = document->axObjectCache();
+    AXObjectCache* cache = axObjectCache();
     RefPtr<AccessibilityObject> child = m_children[optionIndex].get();
 
-    cache->postNotification(child.get(), document.get(), AXObjectCache::AXFocusedUIElementChanged, true, PostSynchronously);
-    cache->postNotification(child.get(), document.get(), AXObjectCache::AXMenuListItemSelected, true, PostSynchronously);
+    cache->postNotification(child.get(), document(), AXObjectCache::AXFocusedUIElementChanged, true, PostSynchronously);
+    cache->postNotification(child.get(), document(), AXObjectCache::AXMenuListItemSelected, true, PostSynchronously);
 }
 
 } // namespace WebCore
index 6cd1bea..2a03211 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef AccessibilityMenuListPopup_h
 #define AccessibilityMenuListPopup_h
 
-#include "AccessibilityObject.h"
+#include "AccessibilityMockObject.h"
 
 namespace WebCore {
 
@@ -35,12 +35,10 @@ class AccessibilityMenuListOption;
 class HTMLElement;
 class HTMLSelectElement;
 
-class AccessibilityMenuListPopup : public AccessibilityObject {
+class AccessibilityMenuListPopup : public AccessibilityMockObject {
 public:
     static PassRefPtr<AccessibilityMenuListPopup> create() { return adoptRef(new AccessibilityMenuListPopup); }
 
-    void setMenuList(AccessibilityMenuList*);
-
     virtual bool isEnabled() const;
     virtual bool isOffScreen() const;
 
@@ -56,14 +54,11 @@ private:
     virtual AccessibilityRole roleValue() const { return MenuListPopupRole; }
 
     virtual bool isVisible() const;
-    virtual AccessibilityObject* parentObject() const;
     virtual bool press() const;
     virtual void addChildren();
     virtual void childrenChanged();
 
     AccessibilityMenuListOption* menuListOptionAccessibilityObject(HTMLElement*) const;
-
-    AccessibilityMenuList* m_menuList;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/accessibility/AccessibilityMockObject.cpp b/Source/WebCore/accessibility/AccessibilityMockObject.cpp
new file mode 100644 (file)
index 0000000..f500404
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AccessibilityMockObject.h"
+
+namespace WebCore {
+    
+AccessibilityMockObject::AccessibilityMockObject()
+    : m_parent(0)
+{
+}
+
+AccessibilityMockObject::~AccessibilityMockObject()
+{
+}
+    
+}
diff --git a/Source/WebCore/accessibility/AccessibilityMockObject.h b/Source/WebCore/accessibility/AccessibilityMockObject.h
new file mode 100644 (file)
index 0000000..e397568
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AccessibilityMockObject_h
+#define AccessibilityMockObject_h
+
+#include "AccessibilityObject.h"
+
+namespace WebCore {
+    
+class AccessibilityMockObject : public AccessibilityObject {
+    
+protected:
+    AccessibilityMockObject();
+public:
+    virtual ~AccessibilityMockObject();
+    
+    virtual AccessibilityObject* parentObject() const { return m_parent; }
+    virtual void setParent(AccessibilityObject* parent) { m_parent = parent; };
+    
+    // Must be called when the parent object clears its children.
+    void detachFromParent() { m_parent = 0; }
+    
+protected:
+    AccessibilityObject* m_parent;
+}; 
+    
+} // namespace WebCore 
+
+#endif // AccessibilityMockObject_h
index f80adc7..fabe45a 100644 (file)
@@ -93,7 +93,7 @@ void AccessibilitySlider::addChildren()
     AXObjectCache* cache = m_renderer->document()->axObjectCache();
 
     AccessibilitySliderThumb* thumb = static_cast<AccessibilitySliderThumb*>(cache->getOrCreate(SliderThumbRole));
-    thumb->setParentObject(this);
+    thumb->setParent(this);
 
     // Before actually adding the value indicator to the hierarchy,
     // allow the platform to make a final decision about it.
@@ -165,7 +165,6 @@ HTMLInputElement* AccessibilitySlider::element() const
 
 
 AccessibilitySliderThumb::AccessibilitySliderThumb()
-    : m_parentSlider(0)
 {
 }
 
@@ -176,7 +175,7 @@ PassRefPtr<AccessibilitySliderThumb> AccessibilitySliderThumb::create()
     
 LayoutRect AccessibilitySliderThumb::elementRect() const
 {
-    RenderObject* sliderRenderer = m_parentSlider->renderer();
+    RenderObject* sliderRenderer = m_parent->renderer();
     if (!sliderRenderer || !sliderRenderer->isSlider())
         return LayoutRect();
     return sliderThumbElementOf(sliderRenderer->node())->getRect();
index 8d260bb..fbd27ca 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef AccessibilitySlider_h
 #define AccessibilitySlider_h
 
+#include "AccessibilityMockObject.h"
 #include "AccessibilityRenderObject.h"
 
 namespace WebCore {
@@ -66,7 +67,7 @@ private:
     virtual AccessibilityOrientation orientation() const;    
 };
 
-class AccessibilitySliderThumb : public AccessibilityObject {
+class AccessibilitySliderThumb : public AccessibilityMockObject {
     
 public:
     static PassRefPtr<AccessibilitySliderThumb> create();
@@ -74,9 +75,6 @@ public:
 
     virtual AccessibilityRole roleValue() const { return SliderThumbRole; }
 
-    void setParentObject(AccessibilitySlider* slider) { m_parentSlider = slider; }
-    virtual AccessibilityObject* parentObject() const { return m_parentSlider; }
-
     virtual LayoutSize size() const;
     virtual LayoutRect elementRect() const;
 
@@ -84,8 +82,6 @@ public:
 
 private:
     AccessibilitySliderThumb();
-
-    AccessibilitySlider* m_parentSlider;
 };
 
 
index 5004c76..65619d0 100644 (file)
@@ -352,7 +352,7 @@ void AccessibilityTable::addChildren()
     for (unsigned i = 0; i < length; ++i) {
         AccessibilityTableColumn* column = static_cast<AccessibilityTableColumn*>(axCache->getOrCreate(ColumnRole));
         column->setColumnIndex((int)i);
-        column->setParentTable(this);
+        column->setParent(this);
         m_columns.append(column);
         if (!column->accessibilityIsIgnored())
             m_children.append(column);
@@ -369,7 +369,7 @@ AccessibilityObject* AccessibilityTable::headerContainer()
         return m_headerContainer;
     
     m_headerContainer = static_cast<AccessibilityTableHeaderContainer*>(axObjectCache()->getOrCreate(TableHeaderContainerRole));
-    m_headerContainer->setParentTable(this);
+    m_headerContainer->setParent(this);
     
     return m_headerContainer;
 }
index b2ff519..14690c7 100644 (file)
@@ -92,7 +92,13 @@ protected:
     bool hasARIARole() const;
     bool isTableExposableThroughAccessibility() const;
 };
-
+    
+inline AccessibilityTable* toAccessibilityTable(AccessibilityObject* object)
+{
+    ASSERT(!object || object->isAccessibilityTable());
+    return static_cast<AccessibilityTable*>(object);
+}
+    
 } // namespace WebCore 
 
 #endif // AccessibilityTable_h
index da1694d..1612438 100644 (file)
@@ -43,7 +43,6 @@ namespace WebCore {
 using namespace HTMLNames;
 
 AccessibilityTableColumn::AccessibilityTableColumn()
-    : m_parentTable(0)
 {
 }
 
@@ -56,9 +55,9 @@ PassRefPtr<AccessibilityTableColumn> AccessibilityTableColumn::create()
     return adoptRef(new AccessibilityTableColumn());
 }
 
-void AccessibilityTableColumn::setParentTable(AccessibilityTable* table)
+void AccessibilityTableColumn::setParent(AccessibilityObject* parent)
 {
-    m_parentTable = table;
+    AccessibilityMockObject::setParent(parent);
     
     clearChildren();
 }
@@ -83,14 +82,18 @@ const AccessibilityObject::AccessibilityChildrenVector& AccessibilityTableColumn
     
 AccessibilityObject* AccessibilityTableColumn::headerObject()
 {
-    if (!m_parentTable)
+    if (!m_parent)
         return 0;
     
-    RenderObject* renderer = m_parentTable->renderer();
+    RenderObject* renderer = m_parent->renderer();
     if (!renderer)
         return 0;
     
-    if (m_parentTable->isAriaTable()) {
+    if (!m_parent->isAccessibilityTable())
+        return 0;
+    
+    AccessibilityTable* parentTable = toAccessibilityTable(m_parent);
+    if (parentTable->isAriaTable()) {
         AccessibilityChildrenVector rowChildren = children();
         unsigned childrenCount = rowChildren.size();
         for (unsigned i = 0; i < childrenCount; ++i) {
@@ -158,19 +161,19 @@ AccessibilityObject* AccessibilityTableColumn::headerObjectForSection(RenderTabl
     if (!cell)
         return 0;
 
-    return m_parentTable->axObjectCache()->getOrCreate(cell);
+    return m_parent->axObjectCache()->getOrCreate(cell);
 }
     
 bool AccessibilityTableColumn::accessibilityIsIgnored() const
 {
-    if (!m_parentTable)
+    if (!m_parent)
         return true;
     
 #if PLATFORM(GTK)
     return true;
 #endif
     
-    return m_parentTable->accessibilityIsIgnored();
+    return m_parent->accessibilityIsIgnored();
 }
     
 void AccessibilityTableColumn::addChildren()
@@ -178,13 +181,14 @@ void AccessibilityTableColumn::addChildren()
     ASSERT(!m_haveChildren); 
     
     m_haveChildren = true;
-    if (!m_parentTable)
+    if (!m_parent || !m_parent->isAccessibilityTable())
         return;
     
-    int numRows = m_parentTable->rowCount();
+    AccessibilityTable* parentTable = toAccessibilityTable(m_parent);
+    int numRows = parentTable->rowCount();
     
     for (int i = 0; i < numRows; i++) {
-        AccessibilityTableCell* cell = m_parentTable->cellForColumnAndRow(m_columnIndex, i);
+        AccessibilityTableCell* cell = parentTable->cellForColumnAndRow(m_columnIndex, i);
         if (!cell)
             continue;
         
index 1706e5a..5c60396 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef AccessibilityTableColumn_h
 #define AccessibilityTableColumn_h
 
-#include "AccessibilityObject.h"
+#include "AccessibilityMockObject.h"
 #include "AccessibilityTable.h"
 #include "IntRect.h"
 
@@ -37,7 +37,7 @@ namespace WebCore {
     
 class RenderTableSection;
 
-class AccessibilityTableColumn : public AccessibilityObject {
+class AccessibilityTableColumn : public AccessibilityMockObject {
     
 private:
     AccessibilityTableColumn();
@@ -45,8 +45,6 @@ public:
     static PassRefPtr<AccessibilityTableColumn> create();
     virtual ~AccessibilityTableColumn();
     
-    void setParentTable(AccessibilityTable*);
-    virtual AccessibilityObject* parentObject() const { return m_parentTable; }
     AccessibilityObject* headerObject();
         
     virtual bool accessibilityIsIgnored() const;
@@ -58,12 +56,12 @@ public:
     
     virtual const AccessibilityChildrenVector& children();
     virtual void addChildren();
+    virtual void setParent(AccessibilityObject*);
     
     virtual LayoutSize size() const;
     virtual LayoutRect elementRect() const;
     
 private:    
-    AccessibilityTable* m_parentTable;
     int m_columnIndex;
     LayoutRect m_columnRect;
     
index c7a8c95..7c3c5e2 100644 (file)
@@ -37,7 +37,6 @@ using namespace std;
 namespace WebCore {
 
 AccessibilityTableHeaderContainer::AccessibilityTableHeaderContainer()
-    : m_parentTable(0)
 {
 }
 
@@ -70,14 +69,14 @@ LayoutSize AccessibilityTableHeaderContainer::size() const
 
 bool AccessibilityTableHeaderContainer::accessibilityIsIgnored() const
 {
-    if (!m_parentTable)
+    if (!m_parent)
         return true;
     
 #if PLATFORM(GTK)
     return true;
 #endif
 
-    return m_parentTable->accessibilityIsIgnored();
+    return m_parent->accessibilityIsIgnored();
 }
 
 void AccessibilityTableHeaderContainer::addChildren()
@@ -85,10 +84,10 @@ void AccessibilityTableHeaderContainer::addChildren()
     ASSERT(!m_haveChildren); 
     
     m_haveChildren = true;
-    if (!m_parentTable || !m_parentTable->isAccessibilityTable())
+    if (!m_parent || !m_parent->isAccessibilityTable())
         return;
     
-    static_cast<AccessibilityTable*>(m_parentTable)->columnHeaders(m_children);
+    static_cast<AccessibilityTable*>(m_parent)->columnHeaders(m_children);
     
     unsigned length = m_children.size();
     for (unsigned k = 0; k < length; ++k)
index 2e73372..7babe68 100644 (file)
 #ifndef AccessibilityTableHeaderContainer_h
 #define AccessibilityTableHeaderContainer_h
 
-#include "AccessibilityObject.h"
+#include "AccessibilityMockObject.h"
 #include "AccessibilityTable.h"
 #include "IntRect.h"
 
 namespace WebCore {
 
-class AccessibilityTableHeaderContainer : public AccessibilityObject {
+class AccessibilityTableHeaderContainer : public AccessibilityMockObject {
     
 private:
     AccessibilityTableHeaderContainer();
@@ -45,9 +45,6 @@ public:
     
     virtual AccessibilityRole roleValue() const { return TableHeaderContainerRole; }
     
-    void setParentTable(AccessibilityTable* table) { m_parentTable = table; }
-    virtual AccessibilityObject* parentObject() const { return m_parentTable; }
-    
     virtual const AccessibilityChildrenVector& children();
     virtual void addChildren();
     
@@ -55,7 +52,6 @@ public:
     virtual LayoutRect elementRect() const;
     
 private:
-    AccessibilityTable* m_parentTable;
     LayoutRect m_headerRect;
     
     virtual bool accessibilityIsIgnored() const;