Commit 7783493e authored by cfleizach@apple.com's avatar cfleizach@apple.com

<rdar://problem/5060458> Elements without AXActions should not return kAXErrorFailure

<rdar://problem/3438014> Might need accessibility solution for context menus in web pages



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cf48a173
2008-05-20 chris fleizach <cfleizach@apple.com>
Reviewed by Darin Adler, Alice Liu
<rdar://problem/3438014> Might need accessibility solution for context menus in web pages
<rdar://problem/5060458> Elements without AXActions should not return kAXErrorFailure
* page/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::clickPoint):
* page/AccessibilityObject.h:
* page/mac/AccessibilityObjectWrapper.mm:
(-[AccessibilityObjectWrapper accessibilityActionNames]):
(-[AccessibilityObjectWrapper accessibilityPerformPressAction]):
(-[AccessibilityObjectWrapper accessibilityPerformShowMenuAction]):
(-[AccessibilityObjectWrapper accessibilityShowContextMenu]):
(-[AccessibilityObjectWrapper accessibilityPerformAction:]):
2008-05-20 Timothy Hatcher <timothy@apple.com>
Expose the ProfileNode functionName sorting functions on
......@@ -196,6 +196,12 @@ IntSize AccessibilityObject::size() const
return IntSize();
}
IntPoint AccessibilityObject::clickPoint() const
{
IntRect rect = elementRect();
return IntPoint(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2);
}
// the closest object for an internal anchor
AccessibilityObject* AccessibilityObject::linkedUIElement() const
{
......
......@@ -256,6 +256,7 @@ public:
virtual IntRect boundingBoxRect() const;
virtual IntRect elementRect() const;
virtual IntSize size() const;
IntPoint clickPoint() const;
virtual KURL url() const;
virtual PlainTextRange selectedTextRange() const;
......
......@@ -503,14 +503,16 @@ static WebCoreTextMarkerRange* textMarkerRangeFromVisiblePositions(VisiblePositi
- (NSArray*)accessibilityActionNames
{
static NSArray* actions = nil;
static NSArray* actionElementActions = [[NSArray alloc] initWithObjects: NSAccessibilityPressAction, NSAccessibilityShowMenuAction, nil];
static NSArray* defaultElementActions = [[NSArray alloc] initWithObjects: NSAccessibilityShowMenuAction, nil];
if (actions == nil) {
if (m_object->actionElement())
actions = [[NSArray alloc] initWithObjects: NSAccessibilityPressAction, nil];
else if (m_object->isAttachment())
actions = [[[self attachmentView] accessibilityActionNames] retain];
}
NSArray *actions;
if (m_object->actionElement())
actions = actionElementActions;
else if (m_object->isAttachment())
actions = [[self attachmentView] accessibilityActionNames];
else
actions = defaultElementActions;
return actions;
}
......@@ -1139,15 +1141,48 @@ static NSString* roleValueToNSString(AccessibilityRole value)
return paramAttrs;
}
- (void)accessibilityPerformAction:(NSString*)action
- (void)accessibilityPerformPressAction
{
if (![action isEqualToString:NSAccessibilityPressAction])
return;
if (m_object->isAttachment())
[[self attachmentView] accessibilityPerformAction:NSAccessibilityPressAction];
m_object->press();
}
- (void)accessibilityPerformShowMenuAction
{
// This needs to be performed in an iteration of the run loop that did not start from an AX call.
// If it's the same run loop iteration, the menu open notification won't be sent
[self performSelector:@selector(accessibilityShowContextMenu) withObject:nil afterDelay:0.0];
}
m_object->press();
- (void)accessibilityShowContextMenu
{
FrameView* frameView = m_object->documentFrameView();
if (!frameView)
return;
// simulate a click in the middle of the object
IntPoint clickPoint = m_object->clickPoint();
NSPoint nsClickPoint = NSMakePoint(clickPoint.x(), clickPoint.y());
NSView* view = frameView->documentView();
NSPoint nsScreenPoint = [view convertPoint:nsClickPoint toView:nil];
// Simulate a context menu event with a right click. This has to be sent through the window, because AppKit is responsible
// for eventually showing the context menu, even though WebCore creates the context menu
NSEvent* event = [NSEvent mouseEventWithType:NSRightMouseDown location:nsScreenPoint modifierFlags:0 timestamp:0 windowNumber:[[view window] windowNumber] context:0 eventNumber:0 clickCount:1 pressure:1];
[[view window] sendEvent:event];
}
- (void)accessibilityPerformAction:(NSString*)action
{
if ([action isEqualToString:NSAccessibilityPressAction])
[self accessibilityPerformPressAction];
else if ([action isEqualToString:NSAccessibilityShowMenuAction])
[self accessibilityPerformShowMenuAction];
}
- (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attributeName
......
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