Hookup cocoa widgets to new accessibility support. r=josh, b=342146

Off by default, and cocoa-only.
This commit is contained in:
hwaara%gmail.com 2006-09-11 15:47:35 +00:00
Родитель f03a2c9249
Коммит 7a8095aba3
4 изменённых файлов: 187 добавлений и 3 удалений

Просмотреть файл

@ -82,6 +82,10 @@ REQUIRES += glitz glitzagl
endif
endif
ifdef ACCESSIBILITY
REQUIRES += accessibility
endif
EXPORTS = \
mozView.h \
$(NULL)

Просмотреть файл

@ -38,7 +38,11 @@
#ifndef nsChildView_h__
#define nsChildView_h__
// formal protocols
#import "mozView.h"
#ifdef ACCESSIBILITY
#import "mozAccessibleProtocol.h"
#endif
#include "nsAutoPtr.h"
#include "nsISupports.h"
@ -60,6 +64,7 @@
#include "nsplugindefs.h"
#include <Quickdraw.h>
#ifdef MOZ_CAIRO_GFX
class gfxASurface;
#endif
@ -74,12 +79,18 @@ struct nsPluginPort;
class nsChildView;
// Depending on whether we're on cairo, and if accessibility is on, we support different @protocols
// and have a different superclass.
@interface ChildView :
#ifdef MOZ_CAIRO_GFX
@interface ChildView : NSView<mozView, NSTextInput>
NSView<
#else
@interface ChildView : NSQuickDrawView<mozView, NSTextInput>
NSQuickDrawView<
#endif
#ifdef ACCESSIBILITY
mozAccessible,
#endif
mozView, NSTextInput>
{
@private
NSWindow* mWindow; // shortcut to the top window, [WEAK]
@ -106,6 +117,7 @@ class nsChildView;
// hand scroll locations
NSPoint mHandScrollStartMouseLoc;
nscoord mHandScrollStartScrollX, mHandScrollStartScrollY;
// when menuForEvent: is called, we store its event here (strong)
NSEvent* mLastMenuForEventEvent;
}
@ -263,6 +275,11 @@ public:
void LiveResizeStarted();
void LiveResizeEnded();
#ifdef ACCESSIBILITY
PRBool DispatchAccessibleEvent(nsIAccessible** aAccessible);
void GetDocumentAccessible(nsIAccessible** aAccessible);
#endif
#ifdef MOZ_CAIRO_GFX
virtual gfxASurface* GetThebesSurface();

Просмотреть файл

@ -79,6 +79,14 @@ CG_EXTERN void CGContextResetClip (CGContextRef);
#include "nsGfxUtils.h" // for StPortSetter
#endif
#ifdef ACCESSIBILITY
#include "nsIAccessible.h"
// import the accessible protocol so we can connect the root accessible as a the
// direct accessible child of our top ChildView.
#import "mozAccessibleProtocol.h"
#endif
static NSView* sLastViewEntered = nil;
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
@ -134,6 +142,10 @@ static NSView* sLastViewEntered = nil;
- (void)clickHoldCallback:(id)inEvent;
#endif
#ifdef ACCESSIBILITY
- (id<mozAccessible>)accessible;
#endif
@end
#pragma mark -
@ -2051,6 +2063,40 @@ nsChildView::GetThebesSurface()
}
#endif
#ifdef ACCESSIBILITY
PRBool
nsChildView::DispatchAccessibleEvent(nsIAccessible** aAccessible)
{
PRBool result = PR_FALSE;
nsAccessibleEvent event(PR_TRUE, NS_GETACCESSIBLE, this);
*aAccessible = nsnull;
nsEventStatus status;
DispatchEvent(&event, status);
result = (nsEventStatus_eConsumeNoDefault == status) ? PR_TRUE : PR_FALSE;
// if the event returned an accessible get it.
if (event.accessible)
*aAccessible = event.accessible;
return result;
}
void
nsChildView::GetDocumentAccessible(nsIAccessible** aAccessible)
{
*aAccessible = nsnull;
// maybe we can figure out a way to cache this?
nsIAccessible *acc = nsnull;
DispatchAccessibleEvent(&acc);
NS_IF_ADDREF(*aAccessible = acc);
return;
}
#endif
#pragma mark -
@ -3890,4 +3936,113 @@ static PRBool IsSpecialRaptorKey(UInt32 macKeyCode)
return [scroller floatValue];
}
#ifdef ACCESSIBILITY
/* Every ChildView has a corresponding mozDocAccessible object that is doing all
the heavy lifting. The topmost ChildView corresponds to a mozRootAccessible
object.
All ChildView needs to do is to route all accessibility calls (from the NSAccessibility APIs)
down to its object, pretending that they are the same.
*/
- (id<mozAccessible>)accessible
{
id <mozAccessible> nativeAccessible = nil;
nsCOMPtr<nsIAccessible> accessible;
mGeckoChild->GetDocumentAccessible (getter_AddRefs (accessible));
accessible->GetNativeInterface ((void**)&nativeAccessible);
#if 0
static PRBool testInit = PR_FALSE;
if (!testInit && [[nativeAccessible role] isEqualToString:@"mozRootAccessible"]) {
[nativeAccessible printHierarchy];
testInit = PR_TRUE;
}
#endif
return nativeAccessible;
}
/* Implementation of formal mozAccessible formal protocol (enabling mozViews
to talk to mozAccessible objects in the accessibility module). */
- (NSString*)role
{
return [[self accessible] role];
}
#ifdef DEBUG
- (void)printHierarchy
{
[[self accessible] printHierarchy];
}
#endif
#pragma mark -
// general
- (BOOL)accessibilityIsIgnored
{
return [[self accessible] accessibilityIsIgnored];
}
- (id)accessibilityHitTest:(NSPoint)point
{
return [[self accessible] accessibilityHitTest:point];
}
- (id)accessibilityFocusedUIElement
{
return [[self accessible] accessibilityFocusedUIElement];
}
// actions
- (NSArray*)accessibilityActionNames
{
return [[self accessible] accessibilityActionNames];
}
- (NSString*)accessibilityActionDescription:(NSString*)action
{
return [[self accessible] accessibilityActionDescription:action];
}
- (void)accessibilityPerformAction:(NSString*)action
{
return [[self accessible] accessibilityPerformAction:action];
}
// attributes
- (NSArray*)accessibilityAttributeNames
{
return [[self accessible] accessibilityAttributeNames];
}
- (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute
{
return [[self accessible] accessibilityIsAttributeSettable:attribute];
}
- (id)accessibilityAttributeValue:(NSString*)attribute
{
id <mozAccessible> accessible = [self accessible];
// if we're the root (topmost) accessible, we need to return our native AXParent as we
// traverse outside to the hierarchy of whoever embeds us. thus, fall back on NSView's
// default implementation for this attribute.
if ([attribute isEqualToString:NSAccessibilityParentAttribute] &&
[[accessible role] isEqualToString:@"mozRootAccessible"]) {
id parentAccessible = [super accessibilityAttributeValue:attribute];
return parentAccessible;
}
return [accessible accessibilityAttributeValue:attribute];
}
#endif /* ACCESSIBILITY */
@end

Просмотреть файл

@ -729,5 +729,13 @@ nsNativeScrollbar::UpdateScroller()
mInTracking = NO;
}
#ifdef ACCESSIBILITY
// XXXhakan: need to find out what needs to be done here to make these scrollbars accessible.
- (BOOL)accessibilityIsIgnored
{
return YES;
}
#endif
@end