<rdar://problem/6211041> Expose legend tag in accessibility
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Sep 2008 20:24:48 +0000 (20:24 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Sep 2008 20:24:48 +0000 (20:24 +0000)
Makes the <legend> tag the titleUIElement of the field set.

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/legend-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/legend.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/page/AccessibilityObject.h
WebCore/page/AccessibilityRenderObject.cpp
WebCore/page/AccessibilityRenderObject.h
WebCore/rendering/RenderFieldset.h
WebCore/rendering/RenderObject.h
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp
WebKitTools/DumpRenderTree/AccessibilityUIElement.h
WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm

index 2777fcc..258226a 100644 (file)
@@ -1,3 +1,12 @@
+2008-09-18  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Tests for <rdar://problem/6211041> Expose legend tag in accessibility
+
+        * accessibility/legend-expected.txt: Added.
+        * accessibility/legend.html: Added.
+
 2008-09-18  Darin Adler  <darin@apple.com>
 
         Reviewed by Maciej Stachowiak.
diff --git a/LayoutTests/accessibility/legend-expected.txt b/LayoutTests/accessibility/legend-expected.txt
new file mode 100644 (file)
index 0000000..353c9e9
--- /dev/null
@@ -0,0 +1,54 @@
+Choose a shipping method:
+Overnight
+AXRole: AXGroup
+AXSubrole: (null)
+AXRoleDescription: group
+AXChildren: <array of size 2>
+AXHelp: 
+AXParent: <AXGroup>
+AXSize: NSSize: {780, 54}
+AXTitle: 
+AXDescription: 
+AXValue: 
+AXFocused: 0
+AXEnabled: 1
+AXWindow: <AXGroup>
+AXSelectedTextMarkerRange: (null)
+AXStartTextMarker: <AXGroup>
+AXEndTextMarker: <AXGroup>
+AXVisited: 0
+AXLinkedUIElements: (null)
+AXSelected: 0
+AXBlockQuoteLevel: 0
+AXTopLevelUIElement: <AXGroup>
+AXTitleUIElement: <AXGroup>
+
+
+-----------------------------
+
+AXRole: AXStaticText
+AXSubrole: (null)
+AXRoleDescription: text
+AXChildren: <array of size 0>
+AXHelp: 
+AXParent: <AXStaticText>
+AXSize: NSSize: {172, 18}
+AXTitle: 
+AXDescription: 
+AXValue: Choose a shipping method:
+AXFocused: 0
+AXEnabled: 1
+AXWindow: <AXStaticText>
+AXSelectedTextMarkerRange: (null)
+AXStartTextMarker: <AXStaticText>
+AXEndTextMarker: <AXStaticText>
+AXVisited: 0
+AXLinkedUIElements: (null)
+AXSelected: 0
+AXBlockQuoteLevel: 0
+AXTopLevelUIElement: <AXStaticText>
+
+------------
+
+
+
diff --git a/LayoutTests/accessibility/legend.html b/LayoutTests/accessibility/legend.html
new file mode 100644 (file)
index 0000000..e554138
--- /dev/null
@@ -0,0 +1,35 @@
+<html>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+<body id="body">
+    <!-- this test should output the attributes of the fieldset which should be a group
+         and it's title ui element's children, which should be the <legend> tag's static text -->
+
+    <fieldset>
+        <legend>Choose a shipping method:</legend>
+        <input id="overnight" type="radio" name="shipping" value="overnight" />Overnight
+    </fieldset>
+
+    
+    <div id="result"></div>
+
+     
+    <script>
+        if (window.accessibilityController) {
+            var result = document.getElementById("result");
+
+            var body = document.getElementById("body");
+            body.focus();
+            var fieldset = accessibilityController.focusedElement.childAtIndex(0);
+            var titleUIElement = fieldset.titleUIElement();
+
+            result.innerText += fieldset.allAttributes() + "\n\n";
+            result.innerText += "-----------------------------\n\n"; 
+            result.innerText += titleUIElement.attributesOfChildren() + "\n\n"; 
+        }
+    </script>
+</body>
+</html>
index 4154ddd..a248841 100644 (file)
@@ -1,3 +1,21 @@
+2008-09-18  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/6211041> Expose legend tag in accessibility
+
+        Exposes the legend tag as the titleUIElement of a fieldset
+
+        Test: accessibility/legend.html
+
+        * page/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::isFieldset):
+        * page/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::isFieldset):
+        (WebCore::AccessibilityRenderObject::titleUIElement):
+        * page/AccessibilityRenderObject.h:
+        * rendering/RenderFieldset.h:
+
 2008-09-19  Chris Fleizach  <cfleizach@apple.com>
 
         Reviewed by Darin Adler.
index b5f0f8a..c3fe209 100644 (file)
@@ -219,6 +219,7 @@ public:
     virtual bool isTableRow() const { return false; };
     virtual bool isTableColumn() const { return false; };
     virtual bool isTableCell() const { return false; };
+    virtual bool isFieldset() const { return false; };
     
     virtual bool isChecked() const { return false; };
     virtual bool isEnabled() const { return false; };
index ee1b6cb..409c81d 100644 (file)
@@ -55,6 +55,7 @@
 #include "NodeList.h"
 #include "NotImplemented.h"
 #include "Page.h"
+#include "RenderFieldset.h"
 #include "RenderFileUploadControl.h"
 #include "RenderImage.h"
 #include "RenderListBox.h"
@@ -418,6 +419,14 @@ bool AccessibilityRenderObject::isControl() const
     return node && (node->isControl() || AccessibilityObject::isARIAControl(ariaRoleAttribute()));
 }
 
+bool AccessibilityRenderObject::isFieldset() const
+{
+    if (!m_renderer)
+        return false;
+    
+    return m_renderer->isFieldset();
+}
+    
 const AtomicString& AccessibilityRenderObject::getAttribute(const QualifiedName& attribute) const
 {
     Node* node = m_renderer->element();
@@ -1048,6 +1057,10 @@ AccessibilityObject* AccessibilityRenderObject::titleUIElement() const
     if (!m_renderer)
         return 0;
     
+    // if isFieldset is true, the renderer is guaranteed to be a RenderFieldset
+    if (isFieldset())
+        return axObjectCache()->get(static_cast<RenderFieldset*>(m_renderer)->findLegend());
+    
     // checkbox and radio hide their labels. Only controls get titleUIElements for now
     if (isCheckboxOrRadio() || !isControl())
         return 0;
index 591e493..5e84660 100644 (file)
@@ -84,6 +84,7 @@ public:
     virtual bool isMenuButton() const;
     virtual bool isMenuItem() const;
     virtual bool isControl() const;
+    virtual bool isFieldset() const;
 
     virtual bool isEnabled() const;
     virtual bool isSelected() const;
index b989e98..46c97ce 100644 (file)
@@ -37,6 +37,7 @@ public:
     RenderFieldset(HTMLFormControlElement*);
 
     virtual const char* renderName() const { return "RenderFieldSet"; }
+    virtual bool isFieldset() const { return true; }
 
     virtual RenderObject* layoutLegend(bool relayoutChildren);
 
@@ -47,11 +48,12 @@ public:
     virtual bool expandsToEncloseOverhangingFloats() const { return style()->height().isAuto(); }
     virtual bool stretchesToMinIntrinsicWidth() const { return true; }
 
+    RenderObject* findLegend() const;
+
 private:
     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
     virtual void paintMask(PaintInfo& paintInfo, int tx, int ty);
     void paintBorderMinusLegend(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, int lx, int lw, int lb);
-    RenderObject* findLegend() const;
 };
 
 } // namespace WebCore
index d5082ba..999c635 100644 (file)
@@ -263,6 +263,7 @@ public:
     virtual bool isBR() const { return false; }
     virtual bool isBlockFlow() const { return false; }
     virtual bool isCounter() const { return false; }
+    virtual bool isFieldset() const { return false; }
     virtual bool isFrame() const { return false; }
     virtual bool isFrameSet() const { return false; }
     virtual bool isImage() const { return false; }
index 6e7b691..4c83926 100644 (file)
@@ -1,3 +1,17 @@
+2008-09-18  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Expose titleUIElement call for DumpRenderTree
+
+        * ChangeLog:
+        * DumpRenderTree/AccessibilityUIElement.cpp:
+        (titleUIElementCallback):
+        (AccessibilityUIElement::getJSClass):
+        * DumpRenderTree/AccessibilityUIElement.h:
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::titleUIElement):
+
 2008-09-18  Darin Adler  <darin@apple.com>
 
         * Scripts/do-webcore-rename: More renaming plans.
index aeeaa6d..10cf252 100644 (file)
@@ -153,6 +153,10 @@ static JSValueRef cellForColumnAndRowCallback(JSContextRef context, JSObjectRef
     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->cellForColumnAndRow(column, row));
 }
 
+static JSValueRef titleUIElementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->titleUIElement());
+}
 // Static Value Getters
 
 static JSValueRef getRoleCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
@@ -250,6 +254,7 @@ JSClassRef AccessibilityUIElement::getJSClass()
         { "rowIndexRange", rowIndexRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "columnIndexRange", columnIndexRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "cellForColumnAndRow", cellForColumnAndRowCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "titleUIElement", titleUIElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { 0, 0, 0 }
     };
 
index 83e79ff..96c5c5c 100644 (file)
@@ -61,6 +61,7 @@ public:
     void getLinkedUIElements(Vector<AccessibilityUIElement>&);
     void getChildren(Vector<AccessibilityUIElement>&);
     AccessibilityUIElement getChildAtIndex(unsigned);
+    AccessibilityUIElement titleUIElement();
     
     // Methods - platform-independent implementations
     JSStringRef allAttributes();
index 6961e97..b2f95c8 100644 (file)
@@ -183,6 +183,15 @@ AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index)
     return nil;
 }
 
+AccessibilityUIElement AccessibilityUIElement::titleUIElement()
+{
+    id accessibilityObject = [m_element accessibilityAttributeValue:NSAccessibilityTitleUIElementAttribute];
+    if (accessibilityObject)
+        return AccessibilityUIElement(accessibilityObject);
+    
+    return nil;
+}
+
 JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements()
 {
     Vector<AccessibilityUIElement> linkedElements;