Reviewed by Darin
authorharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Jan 2005 23:08:26 +0000 (23:08 +0000)
committerharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Jan 2005 23:08:26 +0000 (23:08 +0000)
        <rdar://problem/3850876> AX: button exposed as only an AXImage at http://appleseed.apple.com/ site (<input type=image>)

        * khtml/rendering/render_form.h:
        (khtml::RenderImageButton::isImageButton):
        New.
        * khtml/rendering/render_image.h:
        (khtml::RenderImage::isImageButton):
        New.
        * kwq/KWQAccObject.mm:
        (-[KWQAccObject isImageButton]):
        (-[KWQAccObject actionElement]):
        (-[KWQAccObject role]):
        (-[KWQAccObject accessibilityActionNames]):
        (-[KWQAccObject accessibilityPerformAction:]):
        Represent RenderImageButton elements as buttons instead of images.

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/rendering/render_form.h
WebCore/khtml/rendering/render_image.h
WebCore/kwq/KWQAccObject.mm

index 550a5634c3a4c5fcea806b226362169ae1e5b8bf..a660823a0cf57bfb4db37e095100054c1e534e52 100644 (file)
@@ -1,3 +1,23 @@
+2005-01-31  David Harrison  <harrison@apple.com>
+
+        Reviewed by Darin
+
+        <rdar://problem/3850876> AX: button exposed as only an AXImage at http://appleseed.apple.com/ site (<input type=image>)
+
+        * khtml/rendering/render_form.h:
+        (khtml::RenderImageButton::isImageButton):
+        New.
+        * khtml/rendering/render_image.h:
+        (khtml::RenderImage::isImageButton):
+        New.
+        * kwq/KWQAccObject.mm:
+        (-[KWQAccObject isImageButton]):
+        (-[KWQAccObject actionElement]):
+        (-[KWQAccObject role]):
+        (-[KWQAccObject accessibilityActionNames]):
+        (-[KWQAccObject accessibilityPerformAction:]):
+        Represent RenderImageButton elements as buttons instead of images.
+
 2005-01-31  David Harrison  <harrison@apple.com>
 
         Prevent nil dereference in debug code.
index 75c465863e80cd7b785fc5c249108ee56da73270..bf9508e842363ed513b1748cc1634d3bf2686fb8 100644 (file)
@@ -205,6 +205,7 @@ public:
     RenderImageButton(DOM::HTMLInputElementImpl *element);
 
     virtual const char *renderName() const { return "RenderImageButton"; }
+    virtual bool isImageButton() const { return true; }
 };
 
 
index 94af5b6c9872724312326567f170a68a010d8bdb..d5ae03fccb9552876b2e87c5aec624bd978fbd6d 100644 (file)
@@ -48,6 +48,7 @@ public:
     virtual const char *renderName() const { return "RenderImage"; }
 
     virtual bool isImage() const { return true; }
+    virtual bool isImageButton() const { return false; }
     
     virtual void paint(PaintInfo& i, int tx, int ty);
 
index a27ce5d79c463ece778d1cd0ab46a29073edac2b..354b2a9157f49ab93e079ae51ed997289be448d3 100644 (file)
@@ -46,6 +46,7 @@ extern "C" AXUIElementRef NSAccessibilityCreateAXUIElementRef(id element);
 
 #import "dom_docimpl.h"
 #import "dom_elementimpl.h"
+#import "html_formimpl.h"
 #import "html_inlineimpl.h"
 #import "html_imageimpl.h"
 #import "dom_string.h"
@@ -55,8 +56,8 @@ extern "C" AXUIElementRef NSAccessibilityCreateAXUIElementRef(id element);
 #import "khtmlview.h"
 #import "khtml_part.h"
 #import "render_canvas.h"
-#import "render_object.h"
 #import "render_image.h"
+#import "render_object.h"
 #import "render_list.h"
 #import "render_style.h"
 #import "render_text.h"
@@ -71,28 +72,29 @@ extern "C" AXUIElementRef NSAccessibilityCreateAXUIElementRef(id element);
 #import "DOMInternal.h"
 
 using DOM::DocumentImpl;
+using DOM::DOMString;
 using DOM::ElementImpl;
 using DOM::HTMLAnchorElementImpl;
-using DOM::HTMLMapElementImpl;
 using DOM::HTMLAreaElementImpl;
 using DOM::HTMLCollection;
 using DOM::HTMLCollectionImpl;
+using DOM::HTMLInputElementImpl;
+using DOM::HTMLMapElementImpl;
 using DOM::Node;
 using DOM::NodeImpl;
 using DOM::Position;
 using DOM::Range;
-using DOM::DOMString;
 
-using khtml::plainText;
 using khtml::EVerticalAlign;
-using khtml::RenderObject;
-using khtml::RenderWidget;
-using khtml::RenderCanvas;
-using khtml::RenderText;
+using khtml::plainText;
 using khtml::RenderBlock;
-using khtml::RenderListMarker;
+using khtml::RenderCanvas;
 using khtml::RenderImage;
+using khtml::RenderListMarker;
+using khtml::RenderObject;
 using khtml::RenderStyle;
+using khtml::RenderText;
+using khtml::RenderWidget;
 using khtml::Selection;
 using khtml::TextIterator;
 using khtml::VisiblePosition;
@@ -180,6 +182,19 @@ extern "C" void NSAccessibilityUnregisterUniqueIdForUIElement(id element);
     return 0;
 }
 
+-(BOOL)isImageButton
+{
+    return m_renderer->isImage() && static_cast<RenderImage*>(m_renderer)->isImageButton();
+}
+
+-(ElementImpl *)actionElement
+{
+    if ([self isImageButton])
+        return static_cast<ElementImpl*>(m_renderer->element());
+
+    return [self anchorElement];
+}
+
 -(KWQAccObject*)firstChild
 {
     if (!m_renderer || !m_renderer->firstChild())
@@ -338,8 +353,11 @@ extern "C" void NSAccessibilityUnregisterUniqueIdForUIElement(id element);
         return NSAccessibilityButtonRole;
     if (m_renderer->isText())
         return NSAccessibilityStaticTextRole;
-    if (m_renderer->isImage())
+    if (m_renderer->isImage()) {
+        if ([self isImageButton])
+            return NSAccessibilityButtonRole;
         return NSAccessibilityImageRole;
+    }
     if (m_renderer->isCanvas())
         return @"AXWebArea";
     if (m_renderer->isBlockFlow())
@@ -688,7 +706,8 @@ static QRect boundingBoxRect(RenderObject* obj)
 - (NSArray*)accessibilityActionNames
 {
     static NSArray* actions = nil;
-    if ([self anchorElement]) {
+    
+    if ([self actionElement]) {
         if (actions == nil)
             actions = [[NSArray alloc] initWithObjects: NSAccessibilityPressAction, nil];
         return actions;
@@ -712,12 +731,11 @@ static QRect boundingBoxRect(RenderObject* obj)
 - (void)accessibilityPerformAction:(NSString *)action
 {
     if ([action isEqualToString:NSAccessibilityPressAction]) {
-        // Locate the anchor element. If it doesn't exist, just bail.
-        HTMLAnchorElementImpl* anchorElt = [self anchorElement];
-        if (!anchorElt)
+        ElementImpl *actionElement = [self actionElement];
+        if (!actionElement)
             return;
 
-        DocumentImpl* d = anchorElt->getDocument();
+        DocumentImpl* d = actionElement->getDocument();
         if (d) {
             KHTMLPart* p = d->part();
             if (p) {
@@ -725,7 +743,7 @@ static QRect boundingBoxRect(RenderObject* obj)
             }
         }
 
-        anchorElt->accessKeyAction();
+        actionElement->accessKeyAction();
     }
 }