Reviewed by Dave.
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Dec 2004 00:37:10 +0000 (00:37 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Dec 2004 00:37:10 +0000 (00:37 +0000)
        - fixed <rdar://problem/3731099> Move AXTitle string for image elements to AXDescription

        * kwq/KWQAccObject.mm:
        (-[KWQAccObject title]): moved image alt tag code out of here
        (-[KWQAccObject accessibilityDescription]): moved image alt tag code into this new method
        (-[KWQAccObject accessibilityAttributeNames]): include AXDescription in the set of attributes
        that ordinary elements return; this means that ordinary elements that aren't images will return
        a nil description, which isn't ideal, but is in keeping with the way the rest of these attributes
        work here.
        (-[KWQAccObject accessibilityAttributeValue:]):
        call accessibilityDescription when asked for AXDescription

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

WebCore/ChangeLog-2005-08-23
WebCore/kwq/KWQAccObject.mm

index e7cf5fd..ad29ff3 100644 (file)
@@ -1,3 +1,19 @@
+2004-12-09  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Dave.
+        
+        - fixed <rdar://problem/3731099> Move AXTitle string for image elements to AXDescription
+
+        * kwq/KWQAccObject.mm:
+        (-[KWQAccObject title]): moved image alt tag code out of here
+        (-[KWQAccObject accessibilityDescription]): moved image alt tag code into this new method
+        (-[KWQAccObject accessibilityAttributeNames]): include AXDescription in the set of attributes
+        that ordinary elements return; this means that ordinary elements that aren't images will return
+        a nil description, which isn't ideal, but is in keeping with the way the rest of these attributes
+        work here.
+        (-[KWQAccObject accessibilityAttributeValue:]):
+        call accessibilityDescription when asked for AXDescription
+
 2004-12-09  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Harrison
index cdea370..814b9d8 100644 (file)
@@ -68,6 +68,13 @@ using khtml::RenderBlock;
 using khtml::RenderListMarker;
 using khtml::RenderImage;
 
+/* NSAccessibilityDescriptionAttribute is only defined on 10.4 and newer */
+#if BUILDING_ON_PANTHER
+#define ACCESSIBILITY_DESCRIPTION_ATTRIBUTE @"AXDescription"
+#else
+#define ACCESSIBILITY_DESCRIPTION_ATTRIBUTE NSAccessibilityDescriptionAttribute
+#endif
+
 // FIXME: This will eventually need to really localize.
 #define UI_STRING(string, comment) ((NSString *)[NSString stringWithUTF8String:(string)])
 
@@ -379,19 +386,28 @@ using khtml::RenderImage;
 {
     if (!m_renderer || m_areaElement)
         return nil;
+    
+    if (m_renderer->element() && m_renderer->element()->isHTMLElement() &&
+             Node(m_renderer->element()).elementId() == ID_BUTTON)
+        return [self textUnderElement];
+    else if (m_renderer->element() && m_renderer->element()->hasAnchor())
+        return [self textUnderElement];
+    
+    return nil;
+}
 
+-(NSString*)accessibilityDescription
+{
+    if (!m_renderer || m_areaElement)
+        return nil;
+    
     if (m_renderer->isImage()) {
         if (m_renderer->element() && m_renderer->element()->isHTMLElement()) {
             QString alt = static_cast<ElementImpl*>(m_renderer->element())->getAttribute(ATTR_ALT).string();
             return !alt.isEmpty() ? alt.getNSString() : nil;
         }
     }
-    else if (m_renderer->element() && m_renderer->element()->isHTMLElement() &&
-             Node(m_renderer->element()).elementId() == ID_BUTTON)
-        return [self textUnderElement];
-    else if (m_renderer->element() && m_renderer->element()->hasAnchor())
-        return [self textUnderElement];
-
+    
     return nil;
 }
 
@@ -471,6 +487,7 @@ static QRect boundingBoxRect(RenderObject* obj)
             NSAccessibilityPositionAttribute,
             NSAccessibilitySizeAttribute,
             NSAccessibilityTitleAttribute,
+            ACCESSIBILITY_DESCRIPTION_ATTRIBUTE,
             NSAccessibilityValueAttribute,
             NSAccessibilityFocusedAttribute,
             NSAccessibilityEnabledAttribute,
@@ -629,6 +646,9 @@ static QRect boundingBoxRect(RenderObject* obj)
     if ([attributeName isEqualToString: NSAccessibilityTitleAttribute])
         return [self title];
     
+    if ([attributeName isEqualToString: ACCESSIBILITY_DESCRIPTION_ATTRIBUTE])
+        return [self accessibilityDescription];
+    
     if ([attributeName isEqualToString: NSAccessibilityValueAttribute])
         return [self value];