Commit b012c5ea authored by cfleizach@apple.com's avatar cfleizach@apple.com
Browse files

WAI-ARIA: implement support for ARIA drag and drop

https://bugs.webkit.org/show_bug.cgi?id=32007

Reviewed by Darin Adler.

WebCore: 

Test: platform/mac/accessibility/aria-drag-drop.html

* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::supportsARIADropping):
(WebCore::AccessibilityObject::supportsARIADragging):
(WebCore::AccessibilityObject::isARIAGrabbed):
(WebCore::AccessibilityObject::setARIAGrabbed):
(WebCore::AccessibilityObject::determineARIADropEffects):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::supportsARIADropping):
(WebCore::AccessibilityRenderObject::supportsARIADragging):
(WebCore::AccessibilityRenderObject::isARIAGrabbed):
(WebCore::AccessibilityRenderObject::setARIAGrabbed):
(WebCore::AccessibilityRenderObject::determineARIADropEffects):
* accessibility/AccessibilityRenderObject.h:
* accessibility/mac/AccessibilityObjectWrapper.mm:
(-[AccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
(-[AccessibilityObjectWrapper accessibilityAttributeValue:]):
(-[AccessibilityObjectWrapper accessibilityIsAttributeSettable:]):
(-[AccessibilityObjectWrapper accessibilitySetValue:forAttribute:]):
* html/HTMLAttributeNames.in:

WebKitTools: 

* DumpRenderTree/AccessibilityUIElement.cpp:
(getARIADropEffectsCallback):
(getARIAIsGrabbedCallback):
(AccessibilityUIElement::getJSClass):
* DumpRenderTree/AccessibilityUIElement.h:
* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(AccessibilityUIElement::ariaIsGrabbed):
(AccessibilityUIElement::ariaDropEffects):

LayoutTests: 

* platform/mac/accessibility/aria-drag-drop-expected.txt: Added.
* platform/mac/accessibility/aria-drag-drop.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 344da20d
2009-12-01 Chris Fleizach <cfleizach@apple.com>
Reviewed by Darin Adler.
WAI-ARIA: implement support for ARIA drag and drop
https://bugs.webkit.org/show_bug.cgi?id=32007
* platform/mac/accessibility/aria-drag-drop-expected.txt: Added.
* platform/mac/accessibility/aria-drag-drop.html: Added.
2009-12-01 Adam Barth <abarth@webkit.org>
 
Reviewed by Darin Adler.
drop
grab
grab
This tests that the ARIA drag and drop attributes work as intended.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS body.childAtIndex(0).ariaDropEffects is 'copy,move'
PASS body.childAtIndex(1).ariaIsGrabbed is true
PASS body.childAtIndex(2).ariaIsGrabbed is false
PASS body.childAtIndex(1).isAttributeSettable('AXGrabbed') is true
PASS body.childAtIndex(2).isAttributeSettable('AXGrabbed') is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
<script>
var successfullyParsed = false;
</script>
<script src="../../../fast/js/resources/js-test-pre.js"></script>
</head>
<body id="body">
<div tabindex=0 aria-dropeffect="copy move" role="button" aria-label="drop">drop</div>
<div tabindex=0 aria-grabbed=true role="button" aria-label="grab1">grab</div>
<div tabindex=0 aria-grabbed=false role="button" aria-label="grab2">grab</div>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that the ARIA drag and drop attributes work as intended.");
if (window.accessibilityController) {
var body = document.getElementById("body");
body.focus();
body = accessibilityController.focusedElement;
shouldBe("body.childAtIndex(0).ariaDropEffects", "'copy,move'");
shouldBe("body.childAtIndex(1).ariaIsGrabbed", "true");
shouldBe("body.childAtIndex(2).ariaIsGrabbed", "false");
shouldBe("body.childAtIndex(1).isAttributeSettable('AXGrabbed')", "true");
shouldBe("body.childAtIndex(2).isAttributeSettable('AXGrabbed')", "true");
}
successfullyParsed = true;
</script>
<script src="../../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
2009-12-01 Chris Fleizach <cfleizach@apple.com>
Reviewed by Darin Adler.
WAI-ARIA: implement support for ARIA drag and drop
https://bugs.webkit.org/show_bug.cgi?id=32007
Test: platform/mac/accessibility/aria-drag-drop.html
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::supportsARIADropping):
(WebCore::AccessibilityObject::supportsARIADragging):
(WebCore::AccessibilityObject::isARIAGrabbed):
(WebCore::AccessibilityObject::setARIAGrabbed):
(WebCore::AccessibilityObject::determineARIADropEffects):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::supportsARIADropping):
(WebCore::AccessibilityRenderObject::supportsARIADragging):
(WebCore::AccessibilityRenderObject::isARIAGrabbed):
(WebCore::AccessibilityRenderObject::setARIAGrabbed):
(WebCore::AccessibilityRenderObject::determineARIADropEffects):
* accessibility/AccessibilityRenderObject.h:
* accessibility/mac/AccessibilityObjectWrapper.mm:
(-[AccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
(-[AccessibilityObjectWrapper accessibilityAttributeValue:]):
(-[AccessibilityObjectWrapper accessibilityIsAttributeSettable:]):
(-[AccessibilityObjectWrapper accessibilitySetValue:forAttribute:]):
* html/HTMLAttributeNames.in:
2009-12-01 Adam Barth <abarth@webkit.org>
 
https://bugs.webkit.org/show_bug.cgi?id=21288
......@@ -331,6 +331,13 @@ public:
virtual bool supportsARIAFlowTo() const { return false; }
virtual void ariaFlowToElements(AccessibilityChildrenVector&) const { }
// ARIA drag and drop
virtual bool supportsARIADropping() { return false; }
virtual bool supportsARIADragging() { return false; }
virtual bool isARIAGrabbed() { return false; }
virtual void setARIAGrabbed(bool) { }
virtual void determineARIADropEffects(Vector<String>&) { }
virtual AccessibilityObject* doAccessibilityHitTest(const IntPoint&) const { return 0; }
virtual AccessibilityObject* focusedUIElement() const { return 0; }
......
......@@ -1309,6 +1309,40 @@ void AccessibilityRenderObject::ariaFlowToElements(AccessibilityChildrenVector&
}
bool AccessibilityRenderObject::supportsARIADropping()
{
const AtomicString& dropEffect = getAttribute(aria_dropeffectAttr).string();
return !dropEffect.isEmpty();
}
bool AccessibilityRenderObject::supportsARIADragging()
{
const AtomicString& grabbed = getAttribute(aria_grabbedAttr).string();
return equalIgnoringCase(grabbed, "true") || equalIgnoringCase(grabbed, "false");
}
bool AccessibilityRenderObject::isARIAGrabbed()
{
return elementAttributeValue(aria_grabbedAttr);
}
void AccessibilityRenderObject::setARIAGrabbed(bool grabbed)
{
setElementAttributeValue(aria_grabbedAttr, grabbed);
}
void AccessibilityRenderObject::determineARIADropEffects(Vector<String>& effects)
{
String dropEffects = getAttribute(aria_dropeffectAttr).string();
if (dropEffects.isEmpty()) {
effects.clear();
return;
}
dropEffects.replace('\n', ' ');
dropEffects.split(' ', effects);
}
bool AccessibilityRenderObject::exposesTitleUIElement() const
{
if (!isControl())
......
......@@ -222,6 +222,12 @@ public:
virtual bool supportsARIAFlowTo() const;
virtual void ariaFlowToElements(AccessibilityChildrenVector&) const;
virtual bool supportsARIADropping();
virtual bool supportsARIADragging();
virtual bool isARIAGrabbed();
virtual void setARIAGrabbed(bool);
virtual void determineARIADropEffects(Vector<String>&);
virtual VisiblePosition visiblePositionForPoint(const IntPoint&) const;
virtual VisiblePosition visiblePositionForIndex(unsigned indexValue, bool lastIndexOK) const;
virtual int index(const VisiblePosition&) const;
......
......@@ -123,6 +123,14 @@ using namespace std;
#define NSAccessibilityOwnsAttribute @"AXOwns"
#endif
#ifndef NSAccessibilityGrabbedAttribute
#define NSAccessibilityGrabbedAttribute @"AXGrabbed"
#endif
#ifndef NSAccessibilityDropEffectsAttribute
#define NSAccessibilityDropEffectsAttribute @"AXDropEffects"
#endif
#ifdef BUILDING_ON_TIGER
typedef unsigned NSUInteger;
#define NSAccessibilityValueDescriptionAttribute @"AXValueDescription"
......@@ -582,6 +590,12 @@ static WebCoreTextMarkerRange* textMarkerRangeFromVisiblePositions(VisiblePositi
if (m_object->supportsARIAOwns())
[additional addObject:NSAccessibilityOwnsAttribute];
if (m_object->supportsARIADragging())
[additional addObject:NSAccessibilityGrabbedAttribute];
if (m_object->supportsARIADropping())
[additional addObject:NSAccessibilityDropEffectsAttribute];
return additional;
}
......@@ -1739,6 +1753,20 @@ static NSString* roleValueToNSString(AccessibilityRole value)
return convertToNSArray(ariaOwns);
}
if ([attributeName isEqualToString:NSAccessibilityGrabbedAttribute])
return [NSNumber numberWithBool:m_object->isARIAGrabbed()];
if ([attributeName isEqualToString:NSAccessibilityDropEffectsAttribute]) {
Vector<String> dropEffects;
m_object->determineARIADropEffects(dropEffects);
size_t length = dropEffects.size();
NSMutableArray* dropEffectsArray = [NSMutableArray arrayWithCapacity:length];
for (size_t i = 0; i < length; ++i)
[dropEffectsArray addObject:dropEffects[i]];
return dropEffectsArray;
}
// this is used only by DumpRenderTree for testing
if ([attributeName isEqualToString:@"AXClickPoint"])
return [NSValue valueWithPoint:m_object->clickPoint()];
......@@ -1813,6 +1841,9 @@ static NSString* roleValueToNSString(AccessibilityRole value)
[attributeName isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute])
return m_object->canSetTextRangeAttributes();
if ([attributeName isEqualToString:NSAccessibilityGrabbedAttribute])
return YES;
return NO;
}
......@@ -2101,7 +2132,8 @@ static NSString* roleValueToNSString(AccessibilityRole value)
convertToVector(array, selectedRows);
if (m_object->isTree())
m_object->setSelectedRows(selectedRows);
}
} else if ([attributeName isEqualToString:NSAccessibilityGrabbedAttribute])
m_object->setARIAGrabbed([number boolValue]);
}
static RenderObject* rendererForView(NSView* view)
......
......@@ -17,8 +17,10 @@ aria-checked
aria-controls
aria-describedby
aria-disabled
aria-dropeffect
aria-expanded
aria-flowto
aria-grabbed
aria-hidden
aria-label
aria-labeledby
......
2009-12-01 Chris Fleizach <cfleizach@apple.com>
Reviewed by Darin Adler.
WAI-ARIA: implement support for ARIA drag and drop
https://bugs.webkit.org/show_bug.cgi?id=32007
* DumpRenderTree/AccessibilityUIElement.cpp:
(getARIADropEffectsCallback):
(getARIAIsGrabbedCallback):
(AccessibilityUIElement::getJSClass):
* DumpRenderTree/AccessibilityUIElement.h:
* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(AccessibilityUIElement::ariaIsGrabbed):
(AccessibilityUIElement::ariaDropEffects):
2009-12-01 Nikolas Zimmermann <nzimmermann@rim.com>
Not reviewed. GTK DRT try 2.
......
......@@ -313,6 +313,17 @@ static JSValueRef showMenuCallback(JSContextRef context, JSObjectRef function, J
// Static Value Getters
static JSValueRef getARIADropEffectsCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
{
JSRetainPtr<JSStringRef> dropEffects(Adopt, toAXElement(thisObject)->ariaDropEffects());
return JSValueMakeString(context, dropEffects.get());
}
static JSValueRef getARIAIsGrabbedCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
{
return JSValueMakeBoolean(context, toAXElement(thisObject)->ariaIsGrabbed());
}
static JSValueRef getIsValidCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
{
AccessibilityUIElement* uiElement = toAXElement(thisObject);
......@@ -515,6 +526,8 @@ JSClassRef AccessibilityUIElement::getJSClass()
{ "documentEncoding", getDocumentEncodingCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "documentURI", getDocumentURICallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "isValid", getIsValidCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "ariaIsGrabbed", getARIAIsGrabbedCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "ariaDropEffects", getARIADropEffectsCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ 0, 0, 0, 0 }
};
......
......@@ -135,6 +135,11 @@ public:
AccessibilityUIElement ariaOwnsElementAtIndex(unsigned);
AccessibilityUIElement ariaFlowToElementAtIndex(unsigned);
// ARIA Drag and Drop
bool ariaIsGrabbed() const;
// A space concatentated string of all the drop effects.
JSStringRef ariaDropEffects() const;
// Parameterized attributes
int lineForIndex(int);
JSStringRef boundsForRange(unsigned location, unsigned length);
......
......@@ -44,6 +44,14 @@
#define NSAccessibilityOwnsAttribute @"AXOwns"
#endif
#ifndef NSAccessibilityGrabbedAttribute
#define NSAccessibilityGrabbedAttribute @"AXGrabbed"
#endif
#ifndef NSAccessibilityDropEffectsAttribute
#define NSAccessibilityDropEffectsAttribute @"AXDropEffects"
#endif
@interface NSObject (WebKitAccessibilityArrayCategory)
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
@end
......@@ -512,6 +520,31 @@ int AccessibilityUIElement::hierarchicalLevel() const
return 0;
}
bool AccessibilityUIElement::ariaIsGrabbed() const
{
id value = [m_element accessibilityAttributeValue:NSAccessibilityGrabbedAttribute];
if ([value isKindOfClass:[NSNumber class]])
return [value boolValue];
return false;
}
JSStringRef AccessibilityUIElement::ariaDropEffects() const
{
id value = [m_element accessibilityAttributeValue:NSAccessibilityDropEffectsAttribute];
if (![value isKindOfClass:[NSArray class]])
return 0;
NSMutableString* dropEffects = [NSMutableString string];
NSInteger length = [value count];
for (NSInteger k = 0; k < length; ++k) {
[dropEffects appendString:[value objectAtIndex:k]];
if (k < length - 1)
[dropEffects appendString:@","];
}
return [dropEffects createJSStringRef];
}
// parameterized attributes
int AccessibilityUIElement::lineForIndex(int index)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment