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 #import <Cocoa/Cocoa.h>
7 
8 #import "mozAccessibleProtocol.h"
9 #import "MOXAccessibleProtocol.h"
10 
11 #include "Platform.h"
12 
GetObjectOrRepresentedView(id<mozAccessible> aObject)13 inline id<mozAccessible> GetObjectOrRepresentedView(id<mozAccessible> aObject) {
14   if (!mozilla::a11y::ShouldA11yBeEnabled()) {
15     // If platform a11y is not enabled, don't return represented view.
16     // This is mostly for our mochitest environment because the represented
17     // ChildView checks `ShouldA11yBeEnabled` before proxying accessibility
18     // methods to mozAccessibles.
19     return aObject;
20   }
21 
22   return [aObject hasRepresentedView] ? [aObject representedView] : aObject;
23 }
24 
25 @interface MOXAccessibleBase : NSObject <mozAccessible, MOXAccessible> {
26   BOOL mIsExpired;
27 }
28 
29 #pragma mark - mozAccessible/widget
30 
31 // override
32 - (BOOL)hasRepresentedView;
33 
34 // override
35 - (id)representedView;
36 
37 // override
38 - (BOOL)isRoot;
39 
40 #pragma mark - mozAccessible/NSAccessibility
41 
42 // The methods below interface with the platform through NSAccessibility.
43 // They should not be called directly or overridden in subclasses.
44 
45 // override, final
46 - (NSArray*)accessibilityAttributeNames;
47 
48 // override, final
49 - (id)accessibilityAttributeValue:(NSString*)attribute;
50 
51 // override, final
52 - (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute;
53 
54 // override, final
55 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute;
56 
57 // override, final
58 - (NSArray*)accessibilityActionNames;
59 
60 // override, final
61 - (void)accessibilityPerformAction:(NSString*)action;
62 
63 // override, final
64 - (NSString*)accessibilityActionDescription:(NSString*)action;
65 
66 // override, final
67 - (NSArray*)accessibilityParameterizedAttributeNames;
68 
69 // override, final
70 - (id)accessibilityAttributeValue:(NSString*)attribute forParameter:(id)parameter;
71 
72 // override, final
73 - (id)accessibilityHitTest:(NSPoint)point;
74 
75 // override, final
76 - (id)accessibilityFocusedUIElement;
77 
78 // override, final
79 - (BOOL)isAccessibilityElement;
80 
81 // final
82 - (BOOL)accessibilityNotifiesWhenDestroyed;
83 
84 #pragma mark - MOXAccessible protocol
85 
86 // override
87 - (id)moxHitTest:(NSPoint)point;
88 
89 // override
90 - (id)moxFocusedUIElement;
91 
92 // override
93 - (void)moxPostNotification:(NSString*)notification;
94 
95 // override
96 - (BOOL)moxBlockSelector:(SEL)selector;
97 
98 #pragma mark -
99 
100 - (BOOL)isExpired;
101 
102 // makes ourselves "expired". after this point, we might be around if someone
103 // has retained us (e.g., a third-party), but we really contain no information.
104 - (void)expire;
105 
106 @end
107