2 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #import <Cocoa/Cocoa.h>
10 #import "mozAccessibleProtocol.h"
11 #import "MOXAccessibleProtocol.h"
15 inline id
<mozAccessible
> GetObjectOrRepresentedView(id
<mozAccessible
> aObject
) {
16 if (!mozilla::a11y::ShouldA11yBeEnabled()) {
17 // If platform a11y is not enabled, don't return represented view.
18 // This is mostly for our mochitest environment because the represented
19 // ChildView checks `ShouldA11yBeEnabled` before proxying accessibility
20 // methods to mozAccessibles.
24 return [aObject hasRepresentedView
] ? [aObject representedView
] : aObject
;
27 @interface MOXAccessibleBase
: NSObject
<mozAccessible
, MOXAccessible
> {
31 #pragma mark - mozAccessible/widget
34 - (BOOL
)hasRepresentedView
;
37 - (id
)representedView
;
42 #pragma mark - mozAccessible/NSAccessibility
44 // The methods below interface with the platform through NSAccessibility.
45 // They should not be called directly or overridden in subclasses.
48 - (NSArray
*)accessibilityAttributeNames
;
51 - (id
)accessibilityAttributeValue
:(NSString
*)attribute
;
54 - (BOOL
)accessibilityIsAttributeSettable
:(NSString
*)attribute
;
57 - (void)accessibilitySetValue
:(id
)value forAttribute
:(NSString
*)attribute
;
60 - (NSArray
*)accessibilityActionNames
;
63 - (void)accessibilityPerformAction
:(NSString
*)action
;
66 - (NSString
*)accessibilityActionDescription
:(NSString
*)action
;
69 - (NSArray
*)accessibilityParameterizedAttributeNames
;
72 - (id
)accessibilityAttributeValue
:(NSString
*)attribute
73 forParameter
:(id
)parameter
;
76 - (id
)accessibilityHitTest
:(NSPoint
)point
;
79 - (id
)accessibilityFocusedUIElement
;
82 - (BOOL
)isAccessibilityElement
;
85 - (BOOL
)accessibilityNotifiesWhenDestroyed
;
87 #pragma mark - MOXAccessible protocol
90 - (id
)moxHitTest
:(NSPoint
)point
;
93 - (id
)moxFocusedUIElement
;
96 - (void)moxPostNotification
:(NSString
*)notification
;
99 - (void)moxPostNotification
:(NSString
*)notification
100 withUserInfo
:(NSDictionary
*)userInfo
;
103 - (BOOL
)moxBlockSelector
:(SEL
)selector
;
106 - (NSArray
*)moxUnignoredChildren
;
109 - (NSArray
*)moxChildren
;
112 - (id
<mozAccessible
>)moxUnignoredParent
;
115 - (id
<mozAccessible
>)moxParent
;
118 - (NSNumber
*)moxIndexForChildUIElement
:(id
)child
;
121 - (id
)moxTopLevelUIElement
;
124 - (id
<MOXTextMarkerSupport
>)moxTextMarkerDelegate
;
127 - (BOOL
)moxIsLiveRegion
;
130 - (id
<MOXAccessible
>)moxFindAncestor
:(BOOL (^)(id
<MOXAccessible
> moxAcc
,
131 BOOL
* stop
))findBlock
;
135 - (NSString
*)description
;
139 // makes ourselves "expired". after this point, we might be around if someone
140 // has retained us (e.g., a third-party), but we really contain no information.