<rdar://problem/6038106> AXChildren returned for this web area is null
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jul 2008 22:43:05 +0000 (22:43 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jul 2008 22:43:05 +0000 (22:43 +0000)
The accessibility of image maps needed to be brought inline with the new AX architecture

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

20 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/image-map1-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/image-map1.html [new file with mode: 0644]
LayoutTests/accessibility/image-map2-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/image-map2.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/page/AXObjectCache.cpp
WebCore/page/AccessibilityImageMapLink.cpp [new file with mode: 0644]
WebCore/page/AccessibilityImageMapLink.h [new file with mode: 0644]
WebCore/page/AccessibilityListBoxOption.h
WebCore/page/AccessibilityObject.cpp
WebCore/page/AccessibilityObject.h
WebCore/page/AccessibilityRenderObject.cpp
WebCore/page/AccessibilityRenderObject.h
WebCore/page/mac/AccessibilityObjectWrapper.mm
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/AccessibilityController.cpp
WebKitTools/DumpRenderTree/AccessibilityController.h
WebKitTools/DumpRenderTree/mac/AccessibilityControllerMac.mm

index 3509e39..10881db 100644 (file)
@@ -1,3 +1,13 @@
+2008-07-14  chris fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin
+        Tests for the accessibility of image maps (two variations)
+
+        * accessibility/image-map1-expected.txt: Added.
+        * accessibility/image-map1.html: Added.
+        * accessibility/image-map2-expected.txt: Added.
+        * accessibility/image-map2.html: Added.
+
 2008-07-14  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Geoff.
diff --git a/LayoutTests/accessibility/image-map1-expected.txt b/LayoutTests/accessibility/image-map1-expected.txt
new file mode 100644 (file)
index 0000000..5408f07
--- /dev/null
@@ -0,0 +1,93 @@
+Image map - test 1 - 3 Links
+----------------------
+AXRole: AXGroup
+AXSubrole: (null)
+AXRoleDescription: group
+AXChildren: <array of size 2>
+AXHelp: 
+AXParent: <AXGroup>
+AXSize: NSSize: {784, 36}
+AXTitle: 
+AXDescription: 
+AXValue: 
+AXFocused: 0
+AXEnabled: 1
+AXWindow: <AXGroup>
+AXSelectedTextMarkerRange: (null)
+AXStartTextMarker: <AXGroup>
+AXEndTextMarker: <AXGroup>
+AXVisited: 0
+AXLinkedUIElements: (null)
+AXSelected: 0
+AXBlockQuoteLevel: 0
+
+------------
+AXRole: AXLink
+AXSubrole: (null)
+AXRoleDescription: link
+AXChildren: <array of size 0>
+AXHelp: 
+AXParent: <AXLink: 'Link1'>
+AXSize: NSSize: {123, 62}
+AXTitle: Link1
+AXDescription: 
+AXValue: 
+AXFocused: 0
+AXEnabled: 0
+AXWindow: <AXLink: 'Link1'>
+AXSelectedTextMarkerRange: (null)
+AXStartTextMarker: (null)
+AXEndTextMarker: (null)
+AXVisited: 0
+AXLinkedUIElements: (null)
+AXSelected: 0
+AXBlockQuoteLevel: (null)
+
+------------
+AXRole: AXLink
+AXSubrole: (null)
+AXRoleDescription: link
+AXChildren: <array of size 0>
+AXHelp: 
+AXParent: <AXLink: 'Link2'>
+AXSize: NSSize: {122, 14}
+AXTitle: Link2
+AXDescription: 
+AXValue: 
+AXFocused: 0
+AXEnabled: 0
+AXWindow: <AXLink: 'Link2'>
+AXSelectedTextMarkerRange: (null)
+AXStartTextMarker: (null)
+AXEndTextMarker: (null)
+AXVisited: 0
+AXLinkedUIElements: (null)
+AXSelected: 0
+AXBlockQuoteLevel: (null)
+
+------------
+AXRole: AXLink
+AXSubrole: (null)
+AXRoleDescription: link
+AXChildren: <array of size 0>
+AXHelp: 
+AXParent: <AXLink: 'Link3'>
+AXSize: NSSize: {122, 14}
+AXTitle: Link3
+AXDescription: 
+AXValue: 
+AXFocused: 0
+AXEnabled: 0
+AXWindow: <AXLink: 'Link3'>
+AXSelectedTextMarkerRange: (null)
+AXStartTextMarker: (null)
+AXEndTextMarker: (null)
+AXVisited: 0
+AXLinkedUIElements: (null)
+AXSelected: 0
+AXBlockQuoteLevel: (null)
+
+------------
+
+
diff --git a/LayoutTests/accessibility/image-map1.html b/LayoutTests/accessibility/image-map1.html
new file mode 100644 (file)
index 0000000..36fd599
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+<body id="body">
+    
+    <div id="result"></div>
+    
+    <!-- Test image map -->
+    <map id="apple" name="imagemap1">
+      <area shape="rect" coords="10,10,133,72" href="http://www.apple.com" title="Link1" />
+      <area shape="rect" coords="12,74,134,88" href="http://www.apple.com" title="Link2" />
+      <area shape="rect" coords="11,91,133,105" href="http://www.apple.com" title="Link3" />
+      <area shape="default" nohref="nohref" alt="" />
+    </map>
+
+    <img src="resources/cake.png"  border="0" align="left" usemap="#imagemap1" vspace="1">
+
+     
+    <script>
+        if (window.accessibilityController) {
+            var result = document.getElementById("result");
+
+            var body = document.getElementById("body");
+            body.focus();
+            result.innerText += "Image map - test 1 - 3 Links\n";
+            result.innerText += "----------------------\n";
+            result.innerText += accessibilityController.attributesOfChildrenForFocusedElement() + "\n\n"; 
+        }
+    </script>
+</body>
+</html>
diff --git a/LayoutTests/accessibility/image-map2-expected.txt b/LayoutTests/accessibility/image-map2-expected.txt
new file mode 100644 (file)
index 0000000..2fd218b
--- /dev/null
@@ -0,0 +1,71 @@
+Image map - test 2 - 2 Links (alt tags)
+----------------------
+AXRole: AXGroup
+AXSubrole: (null)
+AXRoleDescription: group
+AXChildren: <array of size 2>
+AXHelp: 
+AXParent: <AXGroup>
+AXSize: NSSize: {784, 36}
+AXTitle: 
+AXDescription: 
+AXValue: 
+AXFocused: 0
+AXEnabled: 1
+AXWindow: <AXGroup>
+AXSelectedTextMarkerRange: (null)
+AXStartTextMarker: <AXGroup>
+AXEndTextMarker: <AXGroup>
+AXVisited: 0
+AXLinkedUIElements: (null)
+AXSelected: 0
+AXBlockQuoteLevel: 0
+
+------------
+AXRole: AXLink
+AXSubrole: (null)
+AXRoleDescription: link
+AXChildren: <array of size 0>
+AXHelp: 
+AXParent: <AXLink>
+AXSize: NSSize: {123, 62}
+AXTitle: 
+AXDescription: Link1
+AXValue: 
+AXFocused: 0
+AXEnabled: 0
+AXWindow: <AXLink>
+AXSelectedTextMarkerRange: (null)
+AXStartTextMarker: (null)
+AXEndTextMarker: (null)
+AXVisited: 0
+AXLinkedUIElements: (null)
+AXSelected: 0
+AXBlockQuoteLevel: (null)
+
+------------
+AXRole: AXLink
+AXSubrole: (null)
+AXRoleDescription: link
+AXChildren: <array of size 0>
+AXHelp: 
+AXParent: <AXLink>
+AXSize: NSSize: {122, 14}
+AXTitle: 
+AXDescription: Link2
+AXValue: 
+AXFocused: 0
+AXEnabled: 0
+AXWindow: <AXLink>
+AXSelectedTextMarkerRange: (null)
+AXStartTextMarker: (null)
+AXEndTextMarker: (null)
+AXVisited: 0
+AXLinkedUIElements: (null)
+AXSelected: 0
+AXBlockQuoteLevel: (null)
+
+------------
+
+
diff --git a/LayoutTests/accessibility/image-map2.html b/LayoutTests/accessibility/image-map2.html
new file mode 100644 (file)
index 0000000..f6508b6
--- /dev/null
@@ -0,0 +1,31 @@
+<html>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+<body id="body">
+    
+    <div id="result"></div>
+    
+    <!-- Test image map -->
+    <map id="apple" name="imagemap1">
+      <area shape="rect" coords="10,10,133,72" href="http://www.apple.com" alt="Link1" />
+      <area shape="rect" coords="12,74,134,88" href="http://www.apple.com" alt="Link2" />
+    </map>
+
+    <img src="resources/cake.png"  border="0" align="left" usemap="#imagemap1" vspace="1">
+
+     
+    <script>
+        if (window.accessibilityController) {
+            var result = document.getElementById("result");
+
+            var body = document.getElementById("body");
+            body.focus();
+            result.innerText += "Image map - test 2 - 2 Links (alt tags)\n";
+            result.innerText += "----------------------\n";
+            result.innerText += accessibilityController.attributesOfChildrenForFocusedElement() + "\n\n"; 
+        }
+    </script>
+</body>
+</html>
index cff57f2..8f59d1e 100644 (file)
@@ -1,3 +1,57 @@
+2008-07-14  chris fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin
+
+        <rdar://problem/6038106> AXChildren returned for this web area is null
+        Accessibility of image maps needed to be updated
+
+        Tests: accessibility/image-map1.html
+               accessibility/image-map2.html
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * page/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::get):
+        * page/AccessibilityImageMapLink.cpp: Added.
+        (WebCore::AccessibilityImageMapLink::AccessibilityImageMapLink):
+        (WebCore::AccessibilityImageMapLink::~AccessibilityImageMapLink):
+        (WebCore::AccessibilityImageMapLink::create):
+        (WebCore::AccessibilityImageMapLink::parentObject):
+        (WebCore::AccessibilityImageMapLink::anchorElement):
+        (WebCore::AccessibilityImageMapLink::accessibilityDescription):
+        (WebCore::AccessibilityImageMapLink::title):
+        (WebCore::AccessibilityImageMapLink::elementRect):
+        (WebCore::AccessibilityImageMapLink::size):
+        * page/AccessibilityImageMapLink.h: Added.
+        (WebCore::AccessibilityImageMapLink::setHTMLAreaElement):
+        (WebCore::AccessibilityImageMapLink::setHTMLMapElement):
+        (WebCore::AccessibilityImageMapLink::roleValue):
+        (WebCore::AccessibilityImageMapLink::accessibilityIsIgnored):
+        (WebCore::AccessibilityImageMapLink::isLink):
+        * page/AccessibilityListBoxOption.h:
+        * page/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::selectedChildren):
+        (WebCore::AccessibilityObject::visibleChildren):
+        * page/AccessibilityObject.h:
+        (WebCore::):
+        * page/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::parentObject):
+        (WebCore::AccessibilityRenderObject::isAnchor):
+        (WebCore::AccessibilityRenderObject::anchorElement):
+        (WebCore::AccessibilityRenderObject::helpText):
+        (WebCore::AccessibilityRenderObject::intValue):
+        (WebCore::AccessibilityRenderObject::stringValue):
+        (WebCore::AccessibilityRenderObject::title):
+        (WebCore::AccessibilityRenderObject::accessibilityDescription):
+        (WebCore::AccessibilityRenderObject::elementRect):
+        (WebCore::AccessibilityRenderObject::accessibilityIsIgnored):
+        (WebCore::AccessibilityRenderObject::roleValue):
+        (WebCore::AccessibilityRenderObject::canSetFocusAttribute):
+        (WebCore::AccessibilityRenderObject::addChildren):
+        * page/AccessibilityRenderObject.h:
+        * page/mac/AccessibilityObjectWrapper.mm:
+        (convertToNSArray):
+        (RoleEntry::):
+
 2008-07-14  Sam Weinig  <sam@webkit.org>
 
         Rubber-stamped by David Hyatt.
index 1584644..06692fc 100644 (file)
                1CFCEED50AACC66900348750 /* DOMHTMLOptionsCollectionPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 1CFCEED40AACC65D00348750 /* DOMHTMLOptionsCollectionPrivate.h */; };
                1CFCEEDF0AACC6A300348750 /* DOMHTMLPreElementPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 1CFCEEDA0AACC68300348750 /* DOMHTMLPreElementPrivate.h */; };
                1CFCEEFA0AACC7A700348750 /* DOMHTMLInputElementPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 1CFCEEF90AACC79000348750 /* DOMHTMLInputElementPrivate.h */; };
+               2955BE2C0E2548EC00893AB5 /* AccessibilityImageMapLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 2955BE2A0E2548EC00893AB5 /* AccessibilityImageMapLink.h */; };
+               2955BE2D0E2548EC00893AB5 /* AccessibilityImageMapLink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2955BE2B0E2548EC00893AB5 /* AccessibilityImageMapLink.cpp */; };
                299984BD0DC8598500F8D261 /* AccessibilityRenderObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299984BB0DC8598500F8D261 /* AccessibilityRenderObject.cpp */; };
                299984BE0DC8598500F8D261 /* AccessibilityRenderObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 299984BC0DC8598500F8D261 /* AccessibilityRenderObject.h */; };
                2999869E0DD0DEEA00F8D261 /* AccessibilityListBoxOption.h in Headers */ = {isa = PBXBuildFile; fileRef = 2999869A0DD0DEEA00F8D261 /* AccessibilityListBoxOption.h */; };
                1CFCEED40AACC65D00348750 /* DOMHTMLOptionsCollectionPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHTMLOptionsCollectionPrivate.h; sourceTree = "<group>"; };
                1CFCEEDA0AACC68300348750 /* DOMHTMLPreElementPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHTMLPreElementPrivate.h; sourceTree = "<group>"; };
                1CFCEEF90AACC79000348750 /* DOMHTMLInputElementPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHTMLInputElementPrivate.h; sourceTree = "<group>"; };
+               2955BE2A0E2548EC00893AB5 /* AccessibilityImageMapLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityImageMapLink.h; sourceTree = "<group>"; };
+               2955BE2B0E2548EC00893AB5 /* AccessibilityImageMapLink.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityImageMapLink.cpp; sourceTree = "<group>"; };
                299984BB0DC8598500F8D261 /* AccessibilityRenderObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityRenderObject.cpp; sourceTree = "<group>"; };
                299984BC0DC8598500F8D261 /* AccessibilityRenderObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityRenderObject.h; sourceTree = "<group>"; };
                2999869A0DD0DEEA00F8D261 /* AccessibilityListBoxOption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityListBoxOption.h; sourceTree = "<group>"; };
                                93C09A820B064F05005ABD4D /* mac */,
                                06693F450BFBC91600216072 /* inspector */,
                                8538F0000AD71770006A81D1 /* AbstractView.idl */,
+                               2955BE2B0E2548EC00893AB5 /* AccessibilityImageMapLink.cpp */,
+                               2955BE2A0E2548EC00893AB5 /* AccessibilityImageMapLink.h */,
                                2999869D0DD0DEEA00F8D261 /* AccessibilityListBox.cpp */,
                                2999869C0DD0DEEA00F8D261 /* AccessibilityListBox.h */,
                                2999869B0DD0DEEA00F8D261 /* AccessibilityListBoxOption.cpp */,
                                A75E8B8B0E1DE2D6007F2481 /* FEColorMatrix.h in Headers */,
                                A75E8B8D0E1DE2D6007F2481 /* FEComponentTransfer.h in Headers */,
                                A75E8B8F0E1DE2D6007F2481 /* FEComposite.h in Headers */,
+                               2955BE2C0E2548EC00893AB5 /* AccessibilityImageMapLink.h in Headers */,
                                31611E5B0E1C4DE000F6A579 /* JSWebKitCSSTransformValue.h in Headers */,
                                31611E610E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.h in Headers */,
                                31611E630E1C4E1400F6A579 /* DOMWebKitCSSTransformValueInternal.h in Headers */,
                                A75E8B8A0E1DE2D6007F2481 /* FEColorMatrix.cpp in Sources */,
                                A75E8B8C0E1DE2D6007F2481 /* FEComponentTransfer.cpp in Sources */,
                                A75E8B8E0E1DE2D6007F2481 /* FEComposite.cpp in Sources */,
+                               2955BE2D0E2548EC00893AB5 /* AccessibilityImageMapLink.cpp in Sources */,
                                BC1DEA4F0E268EB60083A73F /* JSDocumentFragmentCustom.cpp in Sources */,
                                31611E5A0E1C4DE000F6A579 /* JSWebKitCSSTransformValue.cpp in Sources */,
                                31611E620E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.mm in Sources */,
index 014f574..875f8d2 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "AccessibilityListBox.h"
 #include "AccessibilityListBoxOption.h"
+#include "AccessibilityImageMapLink.h"
 #include "AccessibilityRenderObject.h"
 #include "RenderObject.h"
 
@@ -88,6 +89,9 @@ AccessibilityObject* AXObjectCache::get(AccessibilityRole role)
         case ListBoxOptionRole:
             obj = AccessibilityListBoxOption::create();
             break;
+        case ImageMapLinkRole:
+            obj = AccessibilityImageMapLink::create();
+            break;
         default:
             obj = 0;
     }
diff --git a/WebCore/page/AccessibilityImageMapLink.cpp b/WebCore/page/AccessibilityImageMapLink.cpp
new file mode 100644 (file)
index 0000000..3efddcd
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2008 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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * 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 "AccessibilityImageMapLink.h"
+
+#include "AXObjectCache.h"
+#include "Document.h"
+#include "HTMLNames.h"
+#include "IntRect.h"
+
+using namespace std;
+
+namespace WebCore {
+    
+using namespace HTMLNames;
+
+AccessibilityImageMapLink::AccessibilityImageMapLink()
+    : m_areaElement(0), 
+      m_mapElement(0)
+{
+}
+
+AccessibilityImageMapLink::~AccessibilityImageMapLink()
+{
+}    
+
+PassRefPtr<AccessibilityImageMapLink> AccessibilityImageMapLink::create()
+{
+    return adoptRef(new AccessibilityImageMapLink());
+}
+
+AccessibilityObject* AccessibilityImageMapLink::parentObject() const
+{
+    if (!m_mapElement || !m_mapElement->renderer())
+        return 0;
+    
+    return m_mapElement->document()->axObjectCache()->get(m_mapElement->renderer());
+}
+    
+HTMLAnchorElement* AccessibilityImageMapLink::anchorElement() const
+{
+    return m_areaElement;
+}
+
+String AccessibilityImageMapLink::accessibilityDescription() const
+{
+    if (!m_areaElement)
+        return String();
+
+    const AtomicString& alt = m_areaElement->getAttribute(altAttr);
+    if (!alt.isEmpty())
+        return alt;
+
+    return String();
+}
+    
+String AccessibilityImageMapLink::title() const
+{
+    if (!m_areaElement)
+        return String();
+    
+    const AtomicString& title = m_areaElement->getAttribute(titleAttr);
+    if (!title.isEmpty())
+        return title;
+    const AtomicString& summary = m_areaElement->getAttribute(summaryAttr);
+    if (!summary.isEmpty())
+        return summary;
+
+    return String();
+}
+    
+IntRect AccessibilityImageMapLink::elementRect() const
+{
+    if (!m_areaElement)
+        return IntRect();
+    
+    return m_areaElement->getRect(m_mapElement->renderer());
+}
+    
+IntSize AccessibilityImageMapLink::size() const
+{
+    return elementRect().size();
+}
+    
+} // namespace WebCore
diff --git a/WebCore/page/AccessibilityImageMapLink.h b/WebCore/page/AccessibilityImageMapLink.h
new file mode 100644 (file)
index 0000000..b9cffd8
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2008 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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * 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 AccessibilityImageMapLink_h
+#define AccessibilityImageMapLink_h
+
+#include "AccessibilityObject.h"
+#include "HTMLAreaElement.h"
+#include "HTMLMapElement.h"
+
+namespace WebCore {
+    
+class AccessibilityImageMapLink : public AccessibilityObject {
+        
+private:
+    AccessibilityImageMapLink();
+public:
+    static PassRefPtr<AccessibilityImageMapLink> create();
+    virtual ~AccessibilityImageMapLink();
+    
+    void setHTMLAreaElement(HTMLAreaElement* element) { m_areaElement = element; }
+    void setHTMLMapElement(HTMLMapElement* element) { m_mapElement = element; }
+    
+    virtual AccessibilityRole roleValue() const { return WebCoreLinkRole; }
+    virtual bool accessibilityIsIgnored() const { return false; }
+
+    virtual AccessibilityObject* parentObject() const;
+    virtual HTMLAnchorElement* anchorElement() const;
+    virtual bool isLink() const { return true; } 
+    virtual String title() const;
+    virtual String accessibilityDescription() const;
+    
+    virtual IntSize size() const;
+    virtual IntRect elementRect() const;
+
+private:    
+    HTMLAreaElement* m_areaElement;
+    HTMLMapElement* m_mapElement;
+};
+    
+} // namespace WebCore
+
+#endif // AccessibilityImageMapLink_h
index e58e96c..1b588cd 100644 (file)
@@ -65,12 +65,8 @@ public:
     virtual AccessibilityObject* parentObject() const;
     bool isListBoxOption() const { return true; };
     
-    virtual void selectedChildren(AccessibilityChildrenVector&) { }
-    virtual void visibleChildren(AccessibilityChildrenVector&) { }
-    
 private:
     HTMLElement* m_optionElement;
-    AccessibilityListBox* m_listBoxParent;
     
     HTMLSelectElement* listBoxOptionParentNode() const;
     int listBoxOptionIndex() const;
index bf5b080..0bd4c8c 100644 (file)
@@ -981,6 +981,14 @@ void AccessibilityObject::addChildren()
 {
 }
 
+void AccessibilityObject::selectedChildren(AccessibilityChildrenVector&)
+{
+}
+
+void AccessibilityObject::visibleChildren(AccessibilityChildrenVector&)
+{
+}
+    
 unsigned AccessibilityObject::axObjectID() const
 {
     return m_id;
index 03fbf4c..786a4bf 100644 (file)
@@ -138,6 +138,7 @@ enum AccessibilityRole {
 
     // WebCore-specific roles
     WebCoreLinkRole,
+    ImageMapLinkRole,
     ImageMapRole,
     ListMarkerRole,
     WebAreaRole,
@@ -311,8 +312,8 @@ public:
     virtual const AccessibilityChildrenVector& children() { return m_children; }
     virtual void addChildren();
     virtual bool hasChildren() const { return m_haveChildren; };
-    virtual void selectedChildren(AccessibilityChildrenVector&) = 0;
-    virtual void visibleChildren(AccessibilityChildrenVector&) = 0;
+    virtual void selectedChildren(AccessibilityChildrenVector&);
+    virtual void visibleChildren(AccessibilityChildrenVector&);
     virtual bool shouldFocusActiveDescendant() const { return false; }
     virtual AccessibilityObject* activeDescendant() const { return 0; }    
     virtual void handleActiveDescendantChanged() { }
index b2adbbd..a717069 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "AXObjectCache.h"
 #include "AccessibilityListBox.h"
+#include "AccessibilityImageMapLink.h"
 #include "CharacterNames.h"
 #include "EventNames.h"
 #include "FloatRect.h"
@@ -161,9 +162,6 @@ AccessibilityObject* AccessibilityRenderObject::parentObject() const
     if (!m_renderer)
         return 0;
     
-    if (m_areaElement)
-        return m_renderer->document()->axObjectCache()->get(m_renderer);
-    
     RenderObject *parent = m_renderer->parent();
     if (!parent)
         return 0;
@@ -193,7 +191,7 @@ bool AccessibilityRenderObject::isImageButton() const
 
 bool AccessibilityRenderObject::isAnchor() const
 {
-    return m_areaElement || (!isNativeImage() && isLink());
+    return !isNativeImage() && isLink();
 }
 
 bool AccessibilityRenderObject::isNativeTextControl() const
@@ -437,9 +435,7 @@ HTMLAnchorElement* AccessibilityRenderObject::anchorElement() const
 {
     // FIXME: In XHTML 2.0, any HTML element can have an href attribute. We will need to implement this to fully
     // support ARIA links.
-    if (m_areaElement)
-        return m_areaElement.get();
-    
+
     // Search up the render tree for a RenderObject with a DOM node.  Defer to an earlier continuation, though.
     RenderObject* currRenderer;
     for (currRenderer = m_renderer; currRenderer && !currRenderer->element(); currRenderer = currRenderer->parent()) {
@@ -562,15 +558,6 @@ String AccessibilityRenderObject::helpText() const
     if (!m_renderer)
         return String();
     
-    if (m_areaElement) {
-        const AtomicString& summary = m_areaElement->getAttribute(summaryAttr);
-        if (!summary.isEmpty())
-            return summary;
-        const AtomicString& title = m_areaElement->getAttribute(titleAttr);
-        if (!title.isEmpty())
-            return title;
-    }
-    
     for (RenderObject* curr = m_renderer; curr; curr = curr->parent()) {
         if (curr->element() && curr->element()->isHTMLElement()) {
             const AtomicString& summary = static_cast<Element*>(curr->element())->getAttribute(summaryAttr);
@@ -623,7 +610,7 @@ bool AccessibilityRenderObject::hasIntValue() const
 
 int AccessibilityRenderObject::intValue() const
 {
-    if (!m_renderer || m_areaElement || isPasswordField())
+    if (!m_renderer || isPasswordField())
         return 0;
     
     if (isHeading())
@@ -670,7 +657,7 @@ float AccessibilityRenderObject::minValueForRange() const
 
 String AccessibilityRenderObject::stringValue() const
 {
-    if (!m_renderer || m_areaElement || isPasswordField())
+    if (!m_renderer || isPasswordField())
         return String();
     
     if (m_renderer->isText())
@@ -816,7 +803,7 @@ String AccessibilityRenderObject::title() const
 {
     AccessibilityRole ariaRole = ariaRoleAttribute();
     
-    if (!m_renderer || m_areaElement)
+    if (!m_renderer)
         return String();
 
     Node* node = m_renderer->element();
@@ -868,7 +855,7 @@ String AccessibilityRenderObject::ariaDescribedByAttribute() const
 
 String AccessibilityRenderObject::accessibilityDescription() const
 {
-    if (!m_renderer || m_areaElement)
+    if (!m_renderer)
         return String();
 
     String ariaDescription = ariaDescribedByAttribute();
@@ -945,9 +932,6 @@ IntRect AccessibilityRenderObject::checkboxOrRadioRect() const
 
 IntRect AccessibilityRenderObject::elementRect() const
 {
-    if (m_areaElement)
-        return m_areaElement->getRect(m_renderer);
-    
     // a checkbox or radio button should encompass its label
     if (isCheckboxOrRadio())
         return checkboxOrRadioRect();
@@ -1108,7 +1092,7 @@ bool AccessibilityRenderObject::accessibilityIsIgnored() const
     if (isHeading())
         return false;
     
-    if (m_areaElement || isLink())
+    if (isLink())
         return false;
     
     // all controls are accessible
@@ -2013,8 +1997,6 @@ AccessibilityRole AccessibilityRenderObject::roleValue() const
     if (ariaRole != UnknownRole)
         return ariaRole;
     
-    if (m_areaElement)
-        return WebCoreLinkRole;
     if (node && node->isLink()) {
         if (m_renderer->isImage())
             return ImageMapRole;
@@ -2101,6 +2083,7 @@ bool AccessibilityRenderObject::canSetFocusAttribute() const
     
     switch (roleValue()) {
         case WebCoreLinkRole:
+        case ImageMapLinkRole:
         case TextFieldRole:
         case TextAreaRole:
         case ButtonRole:
@@ -2218,17 +2201,18 @@ void AccessibilityRenderObject::addChildren()
     }
     
     // for a RenderImage, add the <area> elements as individual accessibility objects
-    if (m_renderer->isRenderImage() && !m_areaElement) {
+    if (m_renderer->isRenderImage()) {
         HTMLMapElement* map = static_cast<RenderImage*>(m_renderer)->imageMap();
         if (map) {
             for (Node* current = map->firstChild(); current; current = current->traverseNextNode(map)) {
+
                 // add an <area> element for this child if it has a link
-                // NOTE: can't cache these because they all have the same renderer, which is the cache key, right?
-                // plus there may be little reason to since they are being added to the handy array
                 if (current->isLink()) {
-                    RefPtr<AccessibilityRenderObject> obj = new AccessibilityRenderObject(m_renderer);
-                    obj->m_areaElement = static_cast<HTMLAreaElement*>(current);
-                    m_children.append(obj);
+                    AccessibilityObject* areaObject = m_renderer->document()->axObjectCache()->get(ImageMapLinkRole);
+                    static_cast<AccessibilityImageMapLink*>(areaObject)->setHTMLAreaElement(static_cast<HTMLAreaElement*>(current));
+                    static_cast<AccessibilityImageMapLink*>(areaObject)->setHTMLMapElement(map);
+
+                    m_children.append(areaObject);
                 }
             }
         }
index d3cffd4..591e493 100644 (file)
@@ -42,6 +42,7 @@ class HTMLAnchorElement;
 class HTMLAreaElement;
 class HTMLElement;
 class HTMLLabelElement;
+class HTMLMapElement;
 class HTMLSelectElement;
 class IntPoint;
 class IntSize;
@@ -134,7 +135,6 @@ public:
     Element* mouseButtonListener() const;
     FrameView* frameViewIfRenderView() const;
     virtual HTMLAnchorElement* anchorElement() const;
-    HTMLAreaElement* areaElement() const { return m_areaElement.get(); }
     AccessibilityObject* menuForMenuButton() const;
     AccessibilityObject* menuButtonForMenu() const;
     
@@ -207,7 +207,6 @@ public:
     
 protected:
     RenderObject* m_renderer;
-    RefPtr<HTMLAreaElement> m_areaElement;
     AccessibilityRole m_ariaRole;
     
     void setRenderObject(RenderObject* renderer) { m_renderer = renderer; }
index 9c62730..5b4266d 100644 (file)
@@ -732,8 +732,11 @@ static NSMutableArray* convertToNSArray(const AccessibilityObject::Accessibility
 {
     unsigned length = vector.size();
     NSMutableArray* array = [NSMutableArray arrayWithCapacity: length];
-    for (unsigned i = 0; i < length; ++i)
-        [array addObject:vector[i]->wrapper()];
+    for (unsigned i = 0; i < length; ++i) {
+        ASSERT(vector[i]->wrapper());
+        if (vector[i]->wrapper())
+            [array addObject:vector[i]->wrapper()];
+    }
     return array;
 }
 
@@ -819,7 +822,8 @@ static const AccessibilityRoleMap& createAccessibilityRoleMap()
         { DisclosureTriangleRole, NSAccessibilityDisclosureTriangleRole },
         { GridRole, NSAccessibilityGridRole },
 #endif
-        { WebCoreLinkRole, @"AXLink" }, // why isn't this just NSAccessibilityLinkRole ?
+        { WebCoreLinkRole, NSAccessibilityLinkRole }, 
+        { ImageMapLinkRole, NSAccessibilityLinkRole },
         { ImageMapRole, @"AXImageMap" },
         { ListMarkerRole, @"AXListMarker" },
         { WebAreaRole, @"AXWebArea" },
index 3235e70..fe9521d 100644 (file)
@@ -1,3 +1,17 @@
+2008-07-14  chris fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin
+
+        Add support to get attributes of the AXChildren of an objecty
+
+        * DumpRenderTree/AccessibilityController.cpp:
+        (attributesOfChildrenForFocusedElementCallback):
+        (AccessibilityController::staticFunctions):
+        * DumpRenderTree/AccessibilityController.h:
+        * DumpRenderTree/mac/AccessibilityControllerMac.mm:
+        (descriptionOfValue):
+        (AccessibilityController::attributesOfChildrenForFocusedElement):
+
 2008-07-14  Steve Falkenburg  <sfalken@apple.com>
 
         Build fix.
index 2b0c85e..2df25a9 100644 (file)
@@ -70,6 +70,13 @@ static JSValueRef attributesOfLinkedUIElementsForFocusedElementCallback(JSContex
     return JSValueMakeString(context, linkedUIDescription.get());
 }
 
+static JSValueRef attributesOfChildrenForFocusedElementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    AccessibilityController* controller = reinterpret_cast<AccessibilityController*>(JSObjectGetPrivate(thisObject));
+    JSRetainPtr<JSStringRef> childrenDescription(Adopt, controller->attributesOfChildrenForFocusedElement());
+    return JSValueMakeString(context, childrenDescription.get());
+}
+
 static JSValueRef widthOfFocusedElementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     AccessibilityController* controller = reinterpret_cast<AccessibilityController*>(JSObjectGetPrivate(thisObject));
@@ -139,6 +146,7 @@ JSStaticFunction* AccessibilityController::staticFunctions()
         { "titleOfFocusedElement", titleOfFocusedElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "descriptionOfFocusedElement", descriptionOfFocusedElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "attributesOfLinkedUIElementsForFocusedElement", attributesOfLinkedUIElementsForFocusedElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "attributesOfChildrenForFocusedElement", attributesOfChildrenForFocusedElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "widthOfFocusedElement", widthOfFocusedElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "heightOfFocusedElement", heightOfFocusedElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "intValueOfFocusedElement", intValueOfFocusedElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index c554d0c..540ae45 100644 (file)
@@ -41,6 +41,8 @@ public:
     JSStringRef titleOfFocusedElement();
     JSStringRef descriptionOfFocusedElement(); 
     JSStringRef attributesOfLinkedUIElementsForFocusedElement();
+    JSStringRef attributesOfChildrenForFocusedElement();
+    
     double widthOfFocusedElement();
     double heightOfFocusedElement();
     float intValueOfFocusedElement();
index 5d90528..842e0f8 100644 (file)
@@ -68,7 +68,7 @@ static NSString* descriptionOfValue(id valueObject, id focusedAccessibilityObjec
         return [description substringFromIndex:range.location];
 
     // Strip pointer locations
-    if ([description rangeOfString:@"0x"].length) {
+    if ([description rangeOfString:@"0x"].length) {
         NSString* role = [focusedAccessibilityObject accessibilityAttributeValue:@"AXRole"];
         NSString* title = [focusedAccessibilityObject accessibilityAttributeValue:@"AXTitle"];
         if ([title length])
@@ -95,6 +95,21 @@ JSStringRef AccessibilityController::attributesOfLinkedUIElementsForFocusedEleme
     return nsStringToJSStringRef(allElementString);
 }
 
+JSStringRef AccessibilityController::attributesOfChildrenForFocusedElement()
+{
+    WebHTMLView* view = [[mainFrame frameView] documentView];
+    id accessibilityObject = [view accessibilityFocusedUIElement];
+    
+    NSArray* children = [accessibilityObject accessibilityAttributeValue:NSAccessibilityChildrenAttribute];
+    NSMutableString* allElementString = [NSMutableString string];
+    NSUInteger i = 0, count = [children count];
+    for (; i < count; ++i) {
+        NSString* attributes = attributesOfElement([children objectAtIndex:i]);
+        [allElementString appendFormat:@"%@\n------------\n",attributes];
+    }
+    
+    return nsStringToJSStringRef(allElementString);
+}
 
 JSStringRef AccessibilityController::allAttributesOfFocusedElement()
 {