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