Title: [93226] trunk
Revision
93226
Author
commit-qu...@webkit.org
Date
2011-08-17 11:28:02 -0700 (Wed, 17 Aug 2011)

Log Message

Source/WebCore: AccessibilityObject levels are inconsistent
https://bugs.webkit.org/show_bug.cgi?id=66180

Updated accessibilityTable to return level values consistent with other accessibilityObjects that
return level values. This means a value of 0 is now only returned when tableLevel() is called on a
non-table element.

Patch by Sam White <samuel.wh...@rochester.edu> on 2011-08-17
Reviewed by Chris Fleizach.

Test: platform/mac/accessibility/element-level.html

* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::tableLevel):
* accessibility/mac/AccessibilityObjectWrapper.mm:
(-[AccessibilityObjectWrapper accessibilityAttributeValue:]):

Tools: AccessibilityObject levels are inconsistent
https://bugs.webkit.org/show_bug.cgi?id=66180

Added the ability to get numeric attribute values using numberAttributeValue. This
function complements the existing stringAttributeValue and boolAttributeValue functions.
The addition of numberAttributeValue was necessary because the stringAttributeValue
function does a type check and will only return strings. This limitation made it
impossible to get values for attributes that returned an NSNumber.

Patch by Sam White <samuel.wh...@rochester.edu> on 2011-08-17
Reviewed by Chris Fleizach.

* DumpRenderTree/AccessibilityUIElement.cpp:
(numberAttributeValueCallback):
(AccessibilityUIElement::getJSClass):
* DumpRenderTree/AccessibilityUIElement.h:
* DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp:
(AccessibilityUIElement::numberAttributeValue):
* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(AccessibilityUIElement::numberAttributeValue):
* DumpRenderTree/win/AccessibilityUIElementWin.cpp:
(AccessibilityUIElement::numberAttributeValue):

LayoutTests: AccessibilityObject levels are inconsistent
https://bugs.webkit.org/show_bug.cgi?id=66180

This test ensures that all AccessibilityObjects that return a level value return consistent results.
For example, a level of 0 should only be returned by a level function when it is called on an
AccessibilityObject of the wrong type. It's especially important that we enforce this consistency
using layout tests because these level values are not defined by the W3C but are still used by
popular screen readers such as VoiceOver.

Patch by Sam White <samuel.wh...@rochester.edu> on 2011-08-17
Reviewed by Chris Fleizach.

* platform/mac/accessibility/element-level-expected.txt: Added.
* platform/mac/accessibility/element-level.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (93225 => 93226)


--- trunk/LayoutTests/ChangeLog	2011-08-17 18:21:26 UTC (rev 93225)
+++ trunk/LayoutTests/ChangeLog	2011-08-17 18:28:02 UTC (rev 93226)
@@ -1,3 +1,19 @@
+2011-08-17  Sam White  <samuel.wh...@rochester.edu>
+
+        AccessibilityObject levels are inconsistent
+        https://bugs.webkit.org/show_bug.cgi?id=66180
+        
+        This test ensures that all AccessibilityObjects that return a level value return consistent results.
+        For example, a level of 0 should only be returned by a level function when it is called on an
+        AccessibilityObject of the wrong type. It's especially important that we enforce this consistency
+        using layout tests because these level values are not defined by the W3C but are still used by
+        popular screen readers such as VoiceOver.
+
+        Reviewed by Chris Fleizach.
+
+        * platform/mac/accessibility/element-level-expected.txt: Added.
+        * platform/mac/accessibility/element-level.html: Added.
+
 2011-08-17  Ryosuke Niwa  <rn...@webkit.org>
 
         An arrow key collapses directionless selection range in the wrong direction in BiDi

Added: trunk/LayoutTests/platform/mac/accessibility/element-level-expected.txt (0 => 93226)


--- trunk/LayoutTests/platform/mac/accessibility/element-level-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/element-level-expected.txt	2011-08-17 18:28:02 UTC (rev 93226)
@@ -0,0 +1,26 @@
+blockquote level 1
+blockquote level 2
+heading level 1
+
+heading level 2
+
+table heading level 1
+table heading level 2
+table body level 2
+This tests elements' accessibility level value.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS body.childAtIndex(0).childAtIndex(0).numberAttributeValue('AXBlockQuoteLevel') is 1
+PASS body.childAtIndex(1).childAtIndex(0).numberAttributeValue('AXBlockQuoteLevel') is 2
+PASS body.childAtIndex(2).numberAttributeValue('AXBlockQuoteLevel') is 0
+PASS body.childAtIndex(2).numberAttributeValue('AXValue') is 1
+PASS body.childAtIndex(3).numberAttributeValue('AXValue') is 2
+PASS body.childAtIndex(4).numberAttributeValue('AXTableLevel') is 1
+PASS body.childAtIndex(4).childAtIndex(1).childAtIndex(0).childAtIndex(0).numberAttributeValue('AXTableLevel') is 2
+PASS body.childAtIndex(0).numberAttributeValue('AXTableLevel') is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/mac/accessibility/element-level.html (0 => 93226)


--- trunk/LayoutTests/platform/mac/accessibility/element-level.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/element-level.html	2011-08-17 18:28:02 UTC (rev 93226)
@@ -0,0 +1,65 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script>
+var successfullyParsed = false;
+</script>
+<script src=""
+</head>
+<body id="body">
+
+<blockquote>
+    blockquote level 1
+    <blockquote>
+        blockquote level 2
+    </blockquote>
+</blockquote>
+
+<h1>heading level 1</h1>
+<h2>heading level 2</h2>
+
+<!-- Table headings and bodies are included so these tables are identified as accessibility tables. -->
+<table>
+    <thead><tr><td>table heading level 1</td></tr></thead>
+    <tbody><tr><td><table>
+        <thead><tr><td>table heading level 2</td></tr></thead>
+        <tbody><tr><td>table body level 2</td></tr></tbody>
+    </table></td></tr></tbody>
+</table>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests elements' accessibility level value.");
+    
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var body = accessibilityController.focusedElement;
+        
+        // Blockquote levels.
+        shouldBe("body.childAtIndex(0).childAtIndex(0).numberAttributeValue('AXBlockQuoteLevel')", "1");
+        shouldBe("body.childAtIndex(1).childAtIndex(0).numberAttributeValue('AXBlockQuoteLevel')", "2");
+        // Non-blockquotes should return a blockquote level of 0.
+        shouldBe("body.childAtIndex(2).numberAttributeValue('AXBlockQuoteLevel')", "0");
+        
+        // Heading levels.
+        shouldBe("body.childAtIndex(2).numberAttributeValue('AXValue')", "1");
+        shouldBe("body.childAtIndex(3).numberAttributeValue('AXValue')", "2");
+        // Heading level is explicitly specified using a unique HTML tag and is not simply an attribute any element may have.
+        // Therefore, non-headings do not have a heading level that must be checked.
+        
+        // Table levels.
+        shouldBe("body.childAtIndex(4).numberAttributeValue('AXTableLevel')", "1");
+        shouldBe("body.childAtIndex(4).childAtIndex(1).childAtIndex(0).childAtIndex(0).numberAttributeValue('AXTableLevel')", "2");
+        // Non-tables should return a table level of 0.
+        shouldBe("body.childAtIndex(0).numberAttributeValue('AXTableLevel')", "0");
+    }
+    
+    successfullyParsed = true;
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (93225 => 93226)


--- trunk/Source/WebCore/ChangeLog	2011-08-17 18:21:26 UTC (rev 93225)
+++ trunk/Source/WebCore/ChangeLog	2011-08-17 18:28:02 UTC (rev 93226)
@@ -1,3 +1,21 @@
+2011-08-17  Sam White  <samuel.wh...@rochester.edu>
+
+        AccessibilityObject levels are inconsistent
+        https://bugs.webkit.org/show_bug.cgi?id=66180
+        
+        Updated accessibilityTable to return level values consistent with other accessibilityObjects that
+        return level values. This means a value of 0 is now only returned when tableLevel() is called on a
+        non-table element.
+
+        Reviewed by Chris Fleizach.
+
+        Test: platform/mac/accessibility/element-level.html
+
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::tableLevel):
+        * accessibility/mac/AccessibilityObjectWrapper.mm:
+        (-[AccessibilityObjectWrapper accessibilityAttributeValue:]):
+
 2011-08-17  Ryosuke Niwa  <rn...@webkit.org>
 
         An arrow key collapses directionless selection range in the wrong direction in BiDi

Modified: trunk/Source/WebCore/accessibility/AccessibilityTable.cpp (93225 => 93226)


--- trunk/Source/WebCore/accessibility/AccessibilityTable.cpp	2011-08-17 18:21:26 UTC (rev 93225)
+++ trunk/Source/WebCore/accessibility/AccessibilityTable.cpp	2011-08-17 18:28:02 UTC (rev 93226)
@@ -450,7 +450,7 @@
 int AccessibilityTable::tableLevel() const
 {
     int level = 0;
-    for (AccessibilityObject* obj = parentObject(); obj; obj = obj->parentObject()) {
+    for (AccessibilityObject* obj = static_cast<AccessibilityObject*>(const_cast<AccessibilityTable*>(this)); obj; obj = obj->parentObject()) {
         if (obj->isAccessibilityTable())
             ++level;
     }

Modified: trunk/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm (93225 => 93226)


--- trunk/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm	2011-08-17 18:21:26 UTC (rev 93225)
+++ trunk/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm	2011-08-17 18:28:02 UTC (rev 93226)
@@ -2198,13 +2198,17 @@
 
         if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute])
             return [NSNumber numberWithInt:m_object->blockquoteLevel()];
+        if ([attributeName isEqualToString:@"AXTableLevel"])
+            return [NSNumber numberWithInt:m_object->tableLevel()];
     } else {
-        if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute]) {
-            AccessibilityObject* parent = m_object->parentObjectUnignored();
-            if (!parent)
-                return [NSNumber numberWithInt:0];
-            return [parent->wrapper() accessibilityAttributeValue:NSAccessibilityBlockQuoteLevelAttribute];        
-        }
+        AccessibilityObject* parent = m_object->parentObjectUnignored();
+        if (!parent)
+            return [NSNumber numberWithInt:0];
+        
+        if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute])
+            return [parent->wrapper() accessibilityAttributeValue:NSAccessibilityBlockQuoteLevelAttribute];
+        if ([attributeName isEqualToString:@"AXTableLevel"])
+            return [parent->wrapper() accessibilityAttributeValue:@"AXTableLevel"];
     }
     
     if ([attributeName isEqualToString: NSAccessibilityLinkedUIElementsAttribute]) {

Modified: trunk/Tools/ChangeLog (93225 => 93226)


--- trunk/Tools/ChangeLog	2011-08-17 18:21:26 UTC (rev 93225)
+++ trunk/Tools/ChangeLog	2011-08-17 18:28:02 UTC (rev 93226)
@@ -1,3 +1,27 @@
+2011-08-17  Sam White  <samuel.wh...@rochester.edu>
+
+        AccessibilityObject levels are inconsistent
+        https://bugs.webkit.org/show_bug.cgi?id=66180
+        
+        Added the ability to get numeric attribute values using numberAttributeValue. This
+        function complements the existing stringAttributeValue and boolAttributeValue functions.
+        The addition of numberAttributeValue was necessary because the stringAttributeValue
+        function does a type check and will only return strings. This limitation made it
+        impossible to get values for attributes that returned an NSNumber.
+
+        Reviewed by Chris Fleizach.
+
+        * DumpRenderTree/AccessibilityUIElement.cpp:
+        (numberAttributeValueCallback):
+        (AccessibilityUIElement::getJSClass):
+        * DumpRenderTree/AccessibilityUIElement.h:
+        * DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp:
+        (AccessibilityUIElement::numberAttributeValue):
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::numberAttributeValue):
+        * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
+        (AccessibilityUIElement::numberAttributeValue):
+
 2011-08-17  Adam Roben  <aro...@apple.com>
 
         Tell Trac logs always to display all specified revisions in a single page

Modified: trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp (93225 => 93226)


--- trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp	2011-08-17 18:21:26 UTC (rev 93225)
+++ trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp	2011-08-17 18:28:02 UTC (rev 93226)
@@ -374,6 +374,18 @@
     return result;
 }
 
+static JSValueRef numberAttributeValueCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    JSStringRef attribute = 0;
+    if (argumentCount == 1)
+        attribute = JSValueToStringCopy(context, arguments[0], exception);
+    double val = toAXElement(thisObject)->numberAttributeValue(attribute);
+    JSValueRef result = JSValueMakeNumber(context, val);
+    if (attribute)
+        JSStringRelease(attribute);
+    return result;
+}
+
 static JSValueRef cellForColumnAndRowCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     unsigned column = 0, row = 0;
@@ -1008,6 +1020,7 @@
         { "titleUIElement", titleUIElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setSelectedTextRange", setSelectedTextRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "stringAttributeValue", stringAttributeValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "numberAttributeValue", numberAttributeValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "boolAttributeValue", boolAttributeValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "isAttributeSupported", isAttributeSupportedCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "isAttributeSettable", isAttributeSettableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },

Modified: trunk/Tools/DumpRenderTree/AccessibilityUIElement.h (93225 => 93226)


--- trunk/Tools/DumpRenderTree/AccessibilityUIElement.h	2011-08-17 18:21:26 UTC (rev 93225)
+++ trunk/Tools/DumpRenderTree/AccessibilityUIElement.h	2011-08-17 18:28:02 UTC (rev 93226)
@@ -104,6 +104,7 @@
 
     // Attributes - platform-independent implementations
     JSStringRef stringAttributeValue(JSStringRef attribute);
+    double numberAttributeValue(JSStringRef attribute);
     bool boolAttributeValue(JSStringRef attribute);
     bool isAttributeSupported(JSStringRef attribute);
     bool isAttributeSettable(JSStringRef attribute);

Modified: trunk/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp (93225 => 93226)


--- trunk/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp	2011-08-17 18:21:26 UTC (rev 93225)
+++ trunk/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp	2011-08-17 18:28:02 UTC (rev 93226)
@@ -614,6 +614,12 @@
     return JSStringCreateWithCharacters(0, 0);
 }
 
+double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
+{
+    // FIXME: implement
+    return 0.0f;
+}
+
 bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
 {
     // FIXME: implement

Modified: trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm (93225 => 93226)


--- trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm	2011-08-17 18:21:26 UTC (rev 93225)
+++ trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm	2011-08-17 18:28:02 UTC (rev 93226)
@@ -480,6 +480,17 @@
     return 0;
 }
 
+double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    id value = [m_element accessibilityAttributeValue:[NSString stringWithJSStringRef:attribute]];
+    if ([value isKindOfClass:[NSNumber class]])
+        return [value doubleValue];
+    END_AX_OBJC_EXCEPTIONS
+    
+    return 0;
+}
+
 bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
 {
     BEGIN_AX_OBJC_EXCEPTIONS

Modified: trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp (93225 => 93226)


--- trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp	2011-08-17 18:21:26 UTC (rev 93225)
+++ trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp	2011-08-17 18:28:02 UTC (rev 93226)
@@ -513,6 +513,12 @@
     return JSStringCreateWithCharacters(0, 0);
 }
 
+double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
+{
+    // FIXME: implement
+    return 0;
+}
+
 bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
 {
     // FIXME: implement
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to