1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/mac/mozAccessible.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,157 @@ 1.4 +/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "AccessibleWrap.h" 1.10 + 1.11 +#import <Cocoa/Cocoa.h> 1.12 + 1.13 +#import "mozAccessibleProtocol.h" 1.14 + 1.15 +@class mozRootAccessible; 1.16 + 1.17 +/** 1.18 + * All mozAccessibles are either abstract objects (that correspond to XUL 1.19 + * widgets, HTML frames, etc) or are attached to a certain view; for example 1.20 + * a document view. When we hand an object off to an AT, we always want 1.21 + * to give it the represented view, in the latter case. 1.22 + */ 1.23 +inline id <mozAccessible> 1.24 +GetObjectOrRepresentedView(id <mozAccessible> aObject) 1.25 +{ 1.26 + return [aObject hasRepresentedView] ? [aObject representedView] : aObject; 1.27 +} 1.28 + 1.29 +inline mozAccessible* 1.30 +GetNativeFromGeckoAccessible(nsIAccessible* aAccessible) 1.31 +{ 1.32 + mozAccessible* native = nil; 1.33 + aAccessible->GetNativeInterface((void**)&native); 1.34 + return native; 1.35 +} 1.36 + 1.37 +@interface mozAccessible : NSObject <mozAccessible> 1.38 +{ 1.39 + /** 1.40 + * Weak reference; it owns us. 1.41 + */ 1.42 + mozilla::a11y::AccessibleWrap* mGeckoAccessible; 1.43 + 1.44 + /** 1.45 + * Strong ref to array of children 1.46 + */ 1.47 + NSMutableArray* mChildren; 1.48 + 1.49 + /** 1.50 + * Weak reference to the parent 1.51 + */ 1.52 + mozAccessible* mParent; 1.53 + 1.54 + /** 1.55 + * The nsIAccessible role of our gecko accessible. 1.56 + */ 1.57 + mozilla::a11y::role mRole; 1.58 +} 1.59 + 1.60 +// inits with the gecko owner. 1.61 +- (id)initWithAccessible:(mozilla::a11y::AccessibleWrap*)geckoParent; 1.62 + 1.63 +// our accessible parent (AXParent) 1.64 +- (id <mozAccessible>)parent; 1.65 + 1.66 +// a lazy cache of our accessible children (AXChildren). updated 1.67 +- (NSArray*)children; 1.68 + 1.69 +// returns the size of this accessible. 1.70 +- (NSValue*)size; 1.71 + 1.72 +// returns the position, in cocoa coordinates. 1.73 +- (NSValue*)position; 1.74 + 1.75 +// can be overridden to report another role name. 1.76 +- (NSString*)role; 1.77 + 1.78 +// a subrole is a more specialized variant of the role. for example, 1.79 +// the role might be "textfield", while the subrole is "password textfield". 1.80 +- (NSString*)subrole; 1.81 + 1.82 +// Return the role description, as there are a few exceptions. 1.83 +- (NSString*)roleDescription; 1.84 + 1.85 +// returns the native window we're inside. 1.86 +- (NSWindow*)window; 1.87 + 1.88 +// the accessible description of this particular instance. 1.89 +- (NSString*)customDescription; 1.90 + 1.91 +// the value of this element. 1.92 +- (id)value; 1.93 + 1.94 +// name that is associated with this accessible (for buttons, etc) 1.95 +- (NSString*)title; 1.96 + 1.97 +// help text associated with this element. 1.98 +- (NSString*)help; 1.99 + 1.100 +- (BOOL)isEnabled; 1.101 + 1.102 +// information about focus. 1.103 +- (BOOL)isFocused; 1.104 +- (BOOL)canBeFocused; 1.105 + 1.106 +// returns NO if for some reason we were unable to focus the element. 1.107 +- (BOOL)focus; 1.108 + 1.109 +// notifications sent out to listening accessible providers. 1.110 +- (void)didReceiveFocus; 1.111 +- (void)valueDidChange; 1.112 +- (void)selectedTextDidChange; 1.113 + 1.114 +#pragma mark - 1.115 + 1.116 +// invalidates and removes all our children from our cached array. 1.117 +- (void)invalidateChildren; 1.118 + 1.119 +/** 1.120 + * Append a child if they are already cached. 1.121 + */ 1.122 +- (void)appendChild:(mozilla::a11y::Accessible*)aAccessible; 1.123 + 1.124 +// makes ourselves "expired". after this point, we might be around if someone 1.125 +// has retained us (e.g., a third-party), but we really contain no information. 1.126 +- (void)expire; 1.127 +- (BOOL)isExpired; 1.128 + 1.129 +#ifdef DEBUG 1.130 +- (void)printHierarchy; 1.131 +- (void)printHierarchyWithLevel:(unsigned)numSpaces; 1.132 + 1.133 +- (void)sanityCheckChildren; 1.134 +- (void)sanityCheckChildren:(NSArray*)theChildren; 1.135 +#endif 1.136 + 1.137 +// ---- NSAccessibility methods ---- // 1.138 + 1.139 +// whether to skip this element when traversing the accessibility 1.140 +// hierarchy. 1.141 +- (BOOL)accessibilityIsIgnored; 1.142 + 1.143 +// called by third-parties to determine the deepest child element under the mouse 1.144 +- (id)accessibilityHitTest:(NSPoint)point; 1.145 + 1.146 +// returns the deepest unignored focused accessible element 1.147 +- (id)accessibilityFocusedUIElement; 1.148 + 1.149 +// a mozAccessible needs to at least provide links to its parent and 1.150 +// children. 1.151 +- (NSArray*)accessibilityAttributeNames; 1.152 + 1.153 +// value for the specified attribute 1.154 +- (id)accessibilityAttributeValue:(NSString*)attribute; 1.155 + 1.156 +- (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute; 1.157 +- (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute; 1.158 + 1.159 +@end 1.160 +