Bug 25452: AX: Don't create addition space AXStaticText element for every bold or...
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Apr 2009 19:14:05 +0000 (19:14 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Apr 2009 19:14:05 +0000 (19:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=25452

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

LayoutTests/ChangeLog
LayoutTests/accessibility/ignore-spacer-elements-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/ignore-spacer-elements.html [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/internal-link-anchors2-expected.txt
WebCore/ChangeLog
WebCore/page/AccessibilityRenderObject.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp
WebKitTools/DumpRenderTree/AccessibilityUIElement.h
WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp

index 82649c2..fc37887 100644 (file)
@@ -2,6 +2,17 @@
 
         Reviewed by Darin Adler.
 
+        Bug 25452: AX: Don't create addition space AXStaticText element for every bold or link tag
+        https://bugs.webkit.org/show_bug.cgi?id=25452
+        * accessibility/ignore-spacer-elements-expected.txt: Added.
+        * accessibility/ignore-spacer-elements.html: Added.
+        * platform/mac/accessibility/internal-link-anchors2-expected.txt:
+
+2009-04-28  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Darin Adler.
+
         Bug 25449: AX: Respect the alt tag of ARIA button as AXDescription
         https://bugs.webkit.org/show_bug.cgi?id=25449
 
diff --git a/LayoutTests/accessibility/ignore-spacer-elements-expected.txt b/LayoutTests/accessibility/ignore-spacer-elements-expected.txt
new file mode 100644 (file)
index 0000000..7453d17
--- /dev/null
@@ -0,0 +1,3 @@
+First Second Apple Yahoo
+Test passed
+
diff --git a/LayoutTests/accessibility/ignore-spacer-elements.html b/LayoutTests/accessibility/ignore-spacer-elements.html
new file mode 100644 (file)
index 0000000..961885f
--- /dev/null
@@ -0,0 +1,36 @@
+<html>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+<body id="body">
+    <!-- This test makes sure that spacer elements are not returned as elements. There should only be 4 elements returned -->
+   <b>First</b>
+   <b>Second</b>
+   <a href="http://www.apple.com">Apple</a>
+   <a href="http://www.yahoo.com">Yahoo</a>
+
+    
+    <div id="result"></div>
+
+     
+    <script>
+        if (window.accessibilityController) {
+            var result = document.getElementById("result");
+
+            var body = document.getElementById("body");
+            body.focus();
+            var container = accessibilityController.focusedElement.childAtIndex(0);
+            
+            if (container.childrenCount == 4) {
+                result.innerText += "Test passed\n";
+            }
+            else {
+                 result.innerText += "Test failed\n";
+            }
+        }
+    </script>
+</body>
+</html>
index e010e3a..8a1b6dc 100644 (file)
@@ -3,7 +3,7 @@ Anchor Tests
 AXRole: AXHeading
 AXSubrole: (null)
 AXRoleDescription: heading
-AXChildren: <array of size 5>
+AXChildren: <array of size 4>
 AXHelp: 
 AXParent: <AXHeading: '[edit] Tourette syndrome'>
 AXSize: NSSize: {769, 22}
@@ -25,27 +25,28 @@ AXTopLevelUIElement: <AXHeading: '[edit] Tourette syndrome'>
 ------------
 
 
-AXRole: AXStaticText
+AXRole: AXGroup
 AXSubrole: (null)
-AXRoleDescription: text
-AXChildren: <array of size 0>
+AXRoleDescription: group
+AXChildren: <array of size 1>
 AXHelp: 
-AXParent: <AXStaticText>
-AXSize: NSSize: {4, 18}
+AXParent: <AXGroup>
+AXSize: NSSize: {769, 18}
 AXTitle: 
 AXDescription: 
 AXValue: 
 AXFocused: 0
 AXEnabled: 1
-AXWindow: <AXStaticText>
+AXWindow: <AXGroup>
 AXSelectedTextMarkerRange: (null)
-AXStartTextMarker: <AXStaticText>
-AXEndTextMarker: <AXStaticText>
+AXStartTextMarker: <AXGroup>
+AXEndTextMarker: <AXGroup>
 AXVisited: 0
 AXLinkedUIElements: (null)
 AXSelected: 0
 AXBlockQuoteLevel: 0
-AXTopLevelUIElement: <AXStaticText>
+AXTopLevelUIElement: <AXGroup>
+AXTitleUIElement: (null)
 
 ------------
 
index 15c9f94..ec4e4d9 100644 (file)
@@ -1,3 +1,15 @@
+2009-04-28  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Bug 25452: AX: Don't create addition space AXStaticText element for every bold or link tag
+        https://bugs.webkit.org/show_bug.cgi?id=25452
+
+        Test: accessibility/ignore-spacer-elements.html
+
+        * page/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::accessibilityIsIgnored):
+
 2009-04-28  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Sam Weinig.
index eb6479e..5222563 100644 (file)
@@ -1184,7 +1184,12 @@ bool AccessibilityRenderObject::accessibilityIsIgnored() const
         if (parentObjectUnignored()->ariaRoleAttribute() == MenuItemRole ||
             parentObjectUnignored()->ariaRoleAttribute() == MenuButtonRole)
             return true;
-         return m_renderer->isBR() || !toRenderText(m_renderer)->firstTextBox();
+        RenderText* renderText = toRenderText(m_renderer);
+        if (m_renderer->isBR() || !renderText->firstTextBox())
+            return true;
+        
+        // text elements that are just empty whitespace should not be returned
+        return renderText->text()->containsOnlyWhitespace();
     }
     
     if (isHeading())
index 44a0701..10fbb0c 100644 (file)
@@ -1,3 +1,18 @@
+2009-04-28  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Add ability to get the children count of an AX element.
+
+        * DumpRenderTree/AccessibilityUIElement.cpp:
+        (getChildrenCountCallback):
+        (AccessibilityUIElement::getJSClass):
+        * DumpRenderTree/AccessibilityUIElement.h:
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::childrenCount):
+        * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
+        (AccessibilityUIElement::childrenCount):
+
 2009-04-27  Jan Michael Alonzo  <jmalonzo@webkit.org>
 
         Reviewed by Gustavo Noronha.
index 040de93..1051386 100644 (file)
@@ -224,6 +224,11 @@ static JSValueRef getDescriptionCallback(JSContextRef context, JSObjectRef thisO
     return JSValueMakeString(context, description.get());
 }
 
+static JSValueRef getChildrenCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
+{
+    return JSValueMakeNumber(context, toAXElement(thisObject)->childrenCount());
+}
+
 static JSValueRef getWidthCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
     return JSValueMakeNumber(context, toAXElement(thisObject)->width());
@@ -290,6 +295,7 @@ JSClassRef AccessibilityUIElement::getJSClass()
         { "intValue", getIntValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "minValue", getMinValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "maxValue", getMaxValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "childrenCount", getChildrenCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "insertionPointLineNumber", getInsertionPointLineNumberCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "selectedTextRange", getSelectedTextRangeCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "supportsPressAction", getSupportsPressActionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index a7b4c8c..95b494c 100644 (file)
@@ -63,6 +63,7 @@ public:
     void getChildrenWithRange(Vector<AccessibilityUIElement>&, unsigned location, unsigned length);
     
     AccessibilityUIElement getChildAtIndex(unsigned);
+    int childrenCount();
     AccessibilityUIElement titleUIElement();
     AccessibilityUIElement parentElement();
     
index 2c4546d..391648f 100644 (file)
@@ -203,6 +203,14 @@ void AccessibilityUIElement::getChildrenWithRange(Vector<AccessibilityUIElement>
     convertNSArrayToVector(children, elementVector);
 }
 
+int AccessibilityUIElement::childrenCount()
+{
+    Vector<AccessibilityUIElement> children;
+    getChildren(children);
+    
+    return children.size();
+}
+
 AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index)
 {
     Vector<AccessibilityUIElement> children;
index 952ce5d..a391880 100644 (file)
@@ -73,6 +73,13 @@ void AccessibilityUIElement::getChildrenWithRange(Vector<AccessibilityUIElement>
         elementVector.append(getChildAtIndex(i));
 }
 
+int AccessibilityUIElement::childrenCount()
+{
+    long childCount;
+    m_element->get_accChildCount(&childCount);
+    return childCount;
+}
+
 AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index)
 {
     COMPtr<IDispatch> child;