Bug 22112: if a <body> has contenteditable=true, it should report a writable AXValue
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Nov 2008 22:16:27 +0000 (22:16 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Nov 2008 22:16:27 +0000 (22:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=22112

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

LayoutTests/ChangeLog
LayoutTests/accessibility/content-editable-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/content-editable.html [new file with mode: 0644]
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 3f8a8b2..6622181 100644 (file)
@@ -1,3 +1,13 @@
+2008-11-06  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        Test for Bug 22112: if a <body> has contenteditable=true, it should report a writable AXValue
+        https://bugs.webkit.org/show_bug.cgi?id=22112
+
+        * accessibility/content-editable-expected.txt: Added.
+        * accessibility/content-editable.html: Added.
+
 2008-11-06  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Antti Koivisto
diff --git a/LayoutTests/accessibility/content-editable-expected.txt b/LayoutTests/accessibility/content-editable-expected.txt
new file mode 100644 (file)
index 0000000..96884a3
--- /dev/null
@@ -0,0 +1,4 @@
+Text
+Is settable: 1
+
+
diff --git a/LayoutTests/accessibility/content-editable.html b/LayoutTests/accessibility/content-editable.html
new file mode 100644 (file)
index 0000000..d6e6b2c
--- /dev/null
@@ -0,0 +1,28 @@
+<html>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+<body id="body" contenteditable>
+    <!-- this test should show that the iframe has a writable AXValue because it has a 
+         contenteditable attribute -->
+
+    Text
+    
+    <div id="result"></div>
+
+     
+    <script>
+        if (window.accessibilityController) {
+            var result = document.getElementById("result");
+
+            var body = document.getElementById("body");
+            body.focus();
+            body = accessibilityController.focusedElement;
+            
+            result.innerText += "Is settable: "  + body.isAttributeSettable("AXValue") + "\n\n";
+        }
+    </script>
+</body>
+</html>
index d702c1e..4e2ed7d 100644 (file)
@@ -1,3 +1,15 @@
+2008-11-06  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        Bug 22112: if a <body> has contenteditable=true, it should report a writable AXValue
+        https://bugs.webkit.org/show_bug.cgi?id=22112
+
+        Test: accessibility/content-editable.html
+
+        * page/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::isReadOnly):
+
 2008-11-06  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Alice Liu.
index 7f09e83..edd2648 100644 (file)
@@ -341,6 +341,10 @@ bool AccessibilityRenderObject::isReadOnly() const
         if (!document)
             return true;
         
+        HTMLElement* body = document->body();
+        if (body && body->isContentEditable())
+            return false;
+        
         Frame* frame = document->frame();
         if (!frame)
             return true;
index 8e6dd66..51ea81a 100644 (file)
@@ -1,3 +1,23 @@
+2008-11-06  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        Add ability to query an attribute's settable status and the
+        ability to retrieve a single attribute from an AXObject
+
+        * DumpRenderTree/AccessibilityUIElement.cpp:
+        (isAttributeSettableCallback):
+        (attributeValueCallback):
+        (AccessibilityUIElement::getJSClass):
+        * DumpRenderTree/AccessibilityUIElement.h:
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (+[NSString stringWithJSStringRef:]):
+        (AccessibilityUIElement::attributeValue):
+        (AccessibilityUIElement::isAttributeSettable):
+        * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
+        (AccessibilityUIElement::attributeValue):
+        (AccessibilityUIElement::isAttributeSettable):
+
 2008-11-06  Greg Bolsinga  <bolsinga@apple.com>
 
         Reviewed by Darin Adler.
index 02d2dfa..01e6cf3 100644 (file)
@@ -149,6 +149,24 @@ static JSValueRef childAtIndexCallback(JSContextRef context, JSObjectRef functio
     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->getChildAtIndex(indexNumber));
 }
 
+static JSValueRef isAttributeSettableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    JSStringRef attribute = NULL;
+    if (argumentCount == 1)
+        attribute = JSValueToStringCopy(context, arguments[0], exception);
+    
+    return JSValueMakeNumber(context, toAXElement(thisObject)->isAttributeSettable(attribute));
+}
+
+static JSValueRef attributeValueCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    JSStringRef attribute = NULL;
+    if (argumentCount == 1)
+        attribute = JSValueToStringCopy(context, arguments[0], exception);
+    
+    return JSValueMakeString(context, toAXElement(thisObject)->attributeValue(attribute));
+}
+
 static JSValueRef cellForColumnAndRowCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     unsigned column = 0, row = 0;
@@ -290,6 +308,8 @@ JSClassRef AccessibilityUIElement::getJSClass()
         { "cellForColumnAndRow", cellForColumnAndRowCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "titleUIElement", titleUIElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setSelectedTextRange", setSelectedTextRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "attributeValue", attributeValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "isAttributeSettable", isAttributeSettableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { 0, 0, 0 }
     };
 
index 064829f..09a1dd2 100644 (file)
@@ -71,6 +71,8 @@ public:
     JSStringRef parameterizedAttributeNames();
     
     // Attributes - platform-independent implementations
+    JSStringRef attributeValue(JSStringRef attribute);
+    bool isAttributeSettable(JSStringRef attribute);
     JSStringRef role();
     JSStringRef title();
     JSStringRef description();
index 81edd99..719176c 100644 (file)
@@ -53,11 +53,21 @@ AccessibilityUIElement::~AccessibilityUIElement()
 }
 
 @interface NSString (JSStringRefAdditions)
++ (NSString *)stringWithJSStringRef:(JSStringRef)jsStringRef;
 - (JSStringRef)createJSStringRef;
 @end
 
 @implementation NSString (JSStringRefAdditions)
 
++ (NSString *)stringWithJSStringRef:(JSStringRef)jsStringRef
+{
+    if (!jsStringRef)
+        return NULL;
+    
+    CFStringRef cfString = JSStringCopyCFString(kCFAllocatorDefault, jsStringRef);
+    return [(NSString *)cfString autorelease];
+}
+
 - (JSStringRef)createJSStringRef
 {
     return JSStringCreateWithCFString((CFStringRef)self);
@@ -225,6 +235,19 @@ JSStringRef AccessibilityUIElement::allAttributes()
     return [attributes createJSStringRef];
 }
 
+JSStringRef AccessibilityUIElement::attributeValue(JSStringRef attribute)
+{
+    id value = [m_element accessibilityAttributeValue:[NSString stringWithJSStringRef:attribute]];
+    if (![value isKindOfClass:[NSString class]])
+        return NULL;
+    return [value createJSStringRef];
+}
+
+bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute)
+{
+    return [m_element accessibilityIsAttributeSettable:[NSString stringWithJSStringRef:attribute]];
+}
+
 JSStringRef AccessibilityUIElement::parameterizedAttributeNames()
 {
     NSArray* supportedParameterizedAttributes = [m_element accessibilityParameterizedAttributeNames];
index d835bb3..9c4a935 100644 (file)
@@ -264,3 +264,14 @@ JSStringRef AccessibilityUIElement::selectedTextRange()
 void AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length)
 {
 }
+
+JSStringRef AccessibilityUIElement::attributeValue(JSStringRef attribute)
+{
+    return JSStringCreateWithCharacters(0, 0);
+}
+
+bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute)
+{
+    return false;
+}
+