|
1 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "AccessibleWrap.h" |
|
7 |
|
8 #import <Cocoa/Cocoa.h> |
|
9 |
|
10 #import "mozAccessibleProtocol.h" |
|
11 |
|
12 @class mozRootAccessible; |
|
13 |
|
14 /** |
|
15 * All mozAccessibles are either abstract objects (that correspond to XUL |
|
16 * widgets, HTML frames, etc) or are attached to a certain view; for example |
|
17 * a document view. When we hand an object off to an AT, we always want |
|
18 * to give it the represented view, in the latter case. |
|
19 */ |
|
20 inline id <mozAccessible> |
|
21 GetObjectOrRepresentedView(id <mozAccessible> aObject) |
|
22 { |
|
23 return [aObject hasRepresentedView] ? [aObject representedView] : aObject; |
|
24 } |
|
25 |
|
26 inline mozAccessible* |
|
27 GetNativeFromGeckoAccessible(nsIAccessible* aAccessible) |
|
28 { |
|
29 mozAccessible* native = nil; |
|
30 aAccessible->GetNativeInterface((void**)&native); |
|
31 return native; |
|
32 } |
|
33 |
|
34 @interface mozAccessible : NSObject <mozAccessible> |
|
35 { |
|
36 /** |
|
37 * Weak reference; it owns us. |
|
38 */ |
|
39 mozilla::a11y::AccessibleWrap* mGeckoAccessible; |
|
40 |
|
41 /** |
|
42 * Strong ref to array of children |
|
43 */ |
|
44 NSMutableArray* mChildren; |
|
45 |
|
46 /** |
|
47 * Weak reference to the parent |
|
48 */ |
|
49 mozAccessible* mParent; |
|
50 |
|
51 /** |
|
52 * The nsIAccessible role of our gecko accessible. |
|
53 */ |
|
54 mozilla::a11y::role mRole; |
|
55 } |
|
56 |
|
57 // inits with the gecko owner. |
|
58 - (id)initWithAccessible:(mozilla::a11y::AccessibleWrap*)geckoParent; |
|
59 |
|
60 // our accessible parent (AXParent) |
|
61 - (id <mozAccessible>)parent; |
|
62 |
|
63 // a lazy cache of our accessible children (AXChildren). updated |
|
64 - (NSArray*)children; |
|
65 |
|
66 // returns the size of this accessible. |
|
67 - (NSValue*)size; |
|
68 |
|
69 // returns the position, in cocoa coordinates. |
|
70 - (NSValue*)position; |
|
71 |
|
72 // can be overridden to report another role name. |
|
73 - (NSString*)role; |
|
74 |
|
75 // a subrole is a more specialized variant of the role. for example, |
|
76 // the role might be "textfield", while the subrole is "password textfield". |
|
77 - (NSString*)subrole; |
|
78 |
|
79 // Return the role description, as there are a few exceptions. |
|
80 - (NSString*)roleDescription; |
|
81 |
|
82 // returns the native window we're inside. |
|
83 - (NSWindow*)window; |
|
84 |
|
85 // the accessible description of this particular instance. |
|
86 - (NSString*)customDescription; |
|
87 |
|
88 // the value of this element. |
|
89 - (id)value; |
|
90 |
|
91 // name that is associated with this accessible (for buttons, etc) |
|
92 - (NSString*)title; |
|
93 |
|
94 // help text associated with this element. |
|
95 - (NSString*)help; |
|
96 |
|
97 - (BOOL)isEnabled; |
|
98 |
|
99 // information about focus. |
|
100 - (BOOL)isFocused; |
|
101 - (BOOL)canBeFocused; |
|
102 |
|
103 // returns NO if for some reason we were unable to focus the element. |
|
104 - (BOOL)focus; |
|
105 |
|
106 // notifications sent out to listening accessible providers. |
|
107 - (void)didReceiveFocus; |
|
108 - (void)valueDidChange; |
|
109 - (void)selectedTextDidChange; |
|
110 |
|
111 #pragma mark - |
|
112 |
|
113 // invalidates and removes all our children from our cached array. |
|
114 - (void)invalidateChildren; |
|
115 |
|
116 /** |
|
117 * Append a child if they are already cached. |
|
118 */ |
|
119 - (void)appendChild:(mozilla::a11y::Accessible*)aAccessible; |
|
120 |
|
121 // makes ourselves "expired". after this point, we might be around if someone |
|
122 // has retained us (e.g., a third-party), but we really contain no information. |
|
123 - (void)expire; |
|
124 - (BOOL)isExpired; |
|
125 |
|
126 #ifdef DEBUG |
|
127 - (void)printHierarchy; |
|
128 - (void)printHierarchyWithLevel:(unsigned)numSpaces; |
|
129 |
|
130 - (void)sanityCheckChildren; |
|
131 - (void)sanityCheckChildren:(NSArray*)theChildren; |
|
132 #endif |
|
133 |
|
134 // ---- NSAccessibility methods ---- // |
|
135 |
|
136 // whether to skip this element when traversing the accessibility |
|
137 // hierarchy. |
|
138 - (BOOL)accessibilityIsIgnored; |
|
139 |
|
140 // called by third-parties to determine the deepest child element under the mouse |
|
141 - (id)accessibilityHitTest:(NSPoint)point; |
|
142 |
|
143 // returns the deepest unignored focused accessible element |
|
144 - (id)accessibilityFocusedUIElement; |
|
145 |
|
146 // a mozAccessible needs to at least provide links to its parent and |
|
147 // children. |
|
148 - (NSArray*)accessibilityAttributeNames; |
|
149 |
|
150 // value for the specified attribute |
|
151 - (id)accessibilityAttributeValue:(NSString*)attribute; |
|
152 |
|
153 - (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute; |
|
154 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute; |
|
155 |
|
156 @end |
|
157 |