2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
#include "AccessibleWrap.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
|
|
|
#import "mozAccessibleProtocol.h"
|
|
|
|
|
|
|
|
@class mozRootAccessible;
|
|
|
|
|
2012-03-23 11:54:55 -07:00
|
|
|
/**
|
|
|
|
* All mozAccessibles are either abstract objects (that correspond to XUL
|
|
|
|
* widgets, HTML frames, etc) or are attached to a certain view; for example
|
|
|
|
* a document view. When we hand an object off to an AT, we always want
|
|
|
|
* to give it the represented view, in the latter case.
|
|
|
|
*/
|
|
|
|
inline id <mozAccessible>
|
|
|
|
GetObjectOrRepresentedView(id <mozAccessible> aObject)
|
|
|
|
{
|
|
|
|
return [aObject hasRepresentedView] ? [aObject representedView] : aObject;
|
|
|
|
}
|
|
|
|
|
2012-06-28 16:04:50 -07:00
|
|
|
inline mozAccessible*
|
|
|
|
GetNativeFromGeckoAccessible(nsIAccessible* aAccessible)
|
|
|
|
{
|
|
|
|
mozAccessible* native = nil;
|
|
|
|
aAccessible->GetNativeInterface((void**)&native);
|
|
|
|
return native;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
@interface mozAccessible : NSObject <mozAccessible>
|
|
|
|
{
|
2011-12-08 13:19:31 -08:00
|
|
|
/**
|
|
|
|
* Weak reference; it owns us.
|
|
|
|
*/
|
2012-11-17 18:01:44 -08:00
|
|
|
mozilla::a11y::AccessibleWrap* mGeckoAccessible;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-08 13:19:31 -08:00
|
|
|
/**
|
|
|
|
* Strong ref to array of children
|
|
|
|
*/
|
|
|
|
NSMutableArray* mChildren;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Weak reference to the parent
|
|
|
|
*/
|
|
|
|
mozAccessible* mParent;
|
2012-06-29 14:12:02 -07:00
|
|
|
|
2011-12-08 13:19:31 -08:00
|
|
|
/**
|
|
|
|
* The nsIAccessible role of our gecko accessible.
|
|
|
|
*/
|
2012-01-11 20:42:47 -08:00
|
|
|
mozilla::a11y::role mRole;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// inits with the gecko owner.
|
2012-11-17 18:01:44 -08:00
|
|
|
- (id)initWithAccessible:(mozilla::a11y::AccessibleWrap*)geckoParent;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// our accessible parent (AXParent)
|
|
|
|
- (id <mozAccessible>)parent;
|
|
|
|
|
|
|
|
// a lazy cache of our accessible children (AXChildren). updated
|
|
|
|
- (NSArray*)children;
|
|
|
|
|
|
|
|
// returns the size of this accessible.
|
|
|
|
- (NSValue*)size;
|
|
|
|
|
|
|
|
// returns the position, in cocoa coordinates.
|
|
|
|
- (NSValue*)position;
|
|
|
|
|
|
|
|
// can be overridden to report another role name.
|
|
|
|
- (NSString*)role;
|
|
|
|
|
|
|
|
// a subrole is a more specialized variant of the role. for example,
|
|
|
|
// the role might be "textfield", while the subrole is "password textfield".
|
|
|
|
- (NSString*)subrole;
|
|
|
|
|
2012-04-17 17:31:03 -07:00
|
|
|
// Return the role description, as there are a few exceptions.
|
|
|
|
- (NSString*)roleDescription;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// returns the native window we're inside.
|
|
|
|
- (NSWindow*)window;
|
|
|
|
|
|
|
|
// the accessible description of this particular instance.
|
|
|
|
- (NSString*)customDescription;
|
|
|
|
|
|
|
|
// the value of this element.
|
|
|
|
- (id)value;
|
|
|
|
|
|
|
|
// name that is associated with this accessible (for buttons, etc)
|
|
|
|
- (NSString*)title;
|
|
|
|
|
|
|
|
// help text associated with this element.
|
|
|
|
- (NSString*)help;
|
|
|
|
|
|
|
|
- (BOOL)isEnabled;
|
|
|
|
|
|
|
|
// information about focus.
|
|
|
|
- (BOOL)isFocused;
|
|
|
|
- (BOOL)canBeFocused;
|
|
|
|
|
|
|
|
// returns NO if for some reason we were unable to focus the element.
|
|
|
|
- (BOOL)focus;
|
|
|
|
|
|
|
|
// notifications sent out to listening accessible providers.
|
|
|
|
- (void)didReceiveFocus;
|
|
|
|
- (void)valueDidChange;
|
2012-04-02 10:15:00 -07:00
|
|
|
- (void)selectedTextDidChange;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
// invalidates and removes all our children from our cached array.
|
|
|
|
- (void)invalidateChildren;
|
|
|
|
|
2011-12-22 14:31:06 -08:00
|
|
|
/**
|
|
|
|
* Append a child if they are already cached.
|
|
|
|
*/
|
2012-11-17 18:01:44 -08:00
|
|
|
- (void)appendChild:(mozilla::a11y::Accessible*)aAccessible;
|
2011-12-22 14:31:06 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// makes ourselves "expired". after this point, we might be around if someone
|
|
|
|
// has retained us (e.g., a third-party), but we really contain no information.
|
|
|
|
- (void)expire;
|
|
|
|
- (BOOL)isExpired;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
- (void)printHierarchy;
|
|
|
|
- (void)printHierarchyWithLevel:(unsigned)numSpaces;
|
|
|
|
|
|
|
|
- (void)sanityCheckChildren;
|
2011-12-08 13:19:31 -08:00
|
|
|
- (void)sanityCheckChildren:(NSArray*)theChildren;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// ---- NSAccessibility methods ---- //
|
|
|
|
|
|
|
|
// whether to skip this element when traversing the accessibility
|
|
|
|
// hierarchy.
|
|
|
|
- (BOOL)accessibilityIsIgnored;
|
|
|
|
|
|
|
|
// called by third-parties to determine the deepest child element under the mouse
|
|
|
|
- (id)accessibilityHitTest:(NSPoint)point;
|
|
|
|
|
|
|
|
// returns the deepest unignored focused accessible element
|
|
|
|
- (id)accessibilityFocusedUIElement;
|
|
|
|
|
|
|
|
// a mozAccessible needs to at least provide links to its parent and
|
|
|
|
// children.
|
|
|
|
- (NSArray*)accessibilityAttributeNames;
|
|
|
|
|
|
|
|
// value for the specified attribute
|
|
|
|
- (id)accessibilityAttributeValue:(NSString*)attribute;
|
|
|
|
|
|
|
|
- (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute;
|
|
|
|
- (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|