Bug 1832284 - Fix rooting hazard in JSObject::swap r=sfink
[gecko.git] / accessible / mac / MOXAccessibleProtocol.h
blob117bce79e7c873ef07f345377df81680a4d7047e
1 /* clang-format off */
2 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 /* clang-format on */
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 #include "SDKDeclarations.h"
10 @protocol MOXTextMarkerSupport;
11 @protocol mozAccessible;
13 // This protocol's primary use is for abstracting the NSAccessibility informal
14 // protocol into a formal internal API. Conforming classes get to choose a
15 // subset of the optional methods to implement. Those methods will be mapped to
16 // NSAccessibility attributes or actions. A conforming class can implement
17 // moxBlockSelector to control which of its implemented methods should be
18 // exposed to NSAccessibility.
20 @protocol MOXAccessible
22 // The deepest descendant of the accessible subtree that contains the specified
23 // point. Forwarded from accessibilityHitTest.
24 - (id _Nullable)moxHitTest:(NSPoint)point;
26 // The deepest descendant of the accessible subtree that has the focus.
27 // Forwarded from accessibilityFocusedUIElement.
28 - (id _Nullable)moxFocusedUIElement;
30 // Sends a notification to any observing assistive applications.
31 - (void)moxPostNotification:(NSString* _Nonnull)notification;
33 - (void)moxPostNotification:(NSString* _Nonnull)notification
34 withUserInfo:(NSDictionary* _Nullable)userInfo;
36 // Return YES if selector should be considered not supported.
37 // Used in implementations such as:
38 // - accessibilityAttributeNames
39 // - accessibilityActionNames
40 // - accessibilityIsAttributeSettable
41 - (BOOL)moxBlockSelector:(SEL _Nonnull)selector;
43 // Returns a list of all children, doesn't do ignore filtering.
44 - (NSArray* _Nullable)moxChildren;
46 // Returns our parent, doesn't do ignore filtering.
47 - (id<mozAccessible> _Nullable)moxParent;
49 // This is called by isAccessibilityElement. If a subclass wants
50 // to alter the isAccessibilityElement return value, it must
51 // override this and not isAccessibilityElement directly.
52 - (BOOL)moxIgnoreWithParent:(id<MOXAccessible> _Nullable)parent;
54 // Should the child be ignored. This allows subclasses to determine
55 // what kinds of accessibles are valid children. This causes the child
56 // to be skipped, but the unignored descendants will be added to the
57 // container in the default children getter.
58 - (BOOL)moxIgnoreChild:(id<MOXAccessible> _Nullable)child;
60 // Return text delegate if it exists.
61 - (id<MOXTextMarkerSupport> _Nullable)moxTextMarkerDelegate;
63 // Return true if this accessible is a live region
64 - (BOOL)moxIsLiveRegion;
66 // Find the nearest ancestor that returns true with the given block function
67 - (id<MOXAccessible> _Nullable)moxFindAncestor:
68 (BOOL (^_Nonnull)(id<MOXAccessible> _Nonnull moxAcc,
69 BOOL* _Nonnull stop))findBlock;
71 @optional
73 #pragma mark - AttributeGetters
75 // AXChildren
76 - (NSArray* _Nullable)moxUnignoredChildren;
78 // AXParent
79 - (id _Nullable)moxUnignoredParent;
81 // AXRole
82 - (NSString* _Nullable)moxRole;
84 // AXRoleDescription
85 - (NSString* _Nullable)moxRoleDescription;
87 // AXSubrole
88 - (NSString* _Nullable)moxSubrole;
90 // AXTitle
91 - (NSString* _Nullable)moxTitle;
93 // AXDescription
94 - (NSString* _Nullable)moxLabel;
96 // AXHelp
97 - (NSString* _Nullable)moxHelp;
99 // AXValue
100 - (id _Nullable)moxValue;
102 // AXValueDescription
103 - (NSString* _Nullable)moxValueDescription;
105 // AXSize
106 - (NSValue* _Nullable)moxSize;
108 // AXPosition
109 - (NSValue* _Nullable)moxPosition;
111 // AXEnabled
112 - (NSNumber* _Nullable)moxEnabled;
114 // AXFocused
115 - (NSNumber* _Nullable)moxFocused;
117 // AXWindow
118 - (id _Nullable)moxWindow;
120 // AXFrame
121 - (NSValue* _Nullable)moxFrame;
123 // AXTitleUIElement
124 - (id _Nullable)moxTitleUIElement;
126 // AXTopLevelUIElement
127 - (id _Nullable)moxTopLevelUIElement;
129 // AXHasPopup
130 - (NSNumber* _Nullable)moxHasPopup;
132 // AXARIACurrent
133 - (NSString* _Nullable)moxARIACurrent;
135 // AXSelected
136 - (NSNumber* _Nullable)moxSelected;
138 // AXRequired
139 - (NSNumber* _Nullable)moxRequired;
141 // AXElementBusy
142 - (NSNumber* _Nullable)moxElementBusy;
144 // AXLinkedUIElements
145 - (NSArray* _Nullable)moxLinkedUIElements;
147 // AXARIAControls
148 - (NSArray* _Nullable)moxARIAControls;
150 // AXDOMIdentifier
151 - (NSString* _Nullable)moxDOMIdentifier;
153 // AXURL
154 - (NSURL* _Nullable)moxURL;
156 // AXLinkUIElements
157 - (NSArray* _Nullable)moxLinkUIElements;
159 // AXPopupValue
160 - (NSString* _Nullable)moxPopupValue;
162 // AXVisited
163 - (NSNumber* _Nullable)moxVisited;
165 // AXExpanded
166 - (NSNumber* _Nullable)moxExpanded;
168 // AXMain
169 - (NSNumber* _Nullable)moxMain;
171 // AXMinimized
172 - (NSNumber* _Nullable)moxMinimized;
174 // AXSelectedChildren
175 - (NSArray* _Nullable)moxSelectedChildren;
177 // AXTabs
178 - (NSArray* _Nullable)moxTabs;
180 // AXContents
181 - (NSArray* _Nullable)moxContents;
183 // AXOrientation
184 - (NSString* _Nullable)moxOrientation;
186 // AXMenuItemMarkChar
187 - (NSString* _Nullable)moxMenuItemMarkChar;
189 // AXLoaded
190 - (NSNumber* _Nullable)moxLoaded;
192 // AXLoadingProgress
193 - (NSNumber* _Nullable)moxLoadingProgress;
195 // AXMinValue
196 - (id _Nullable)moxMinValue;
198 // AXMaxValue
199 - (id _Nullable)moxMaxValue;
201 // Webkit also implements the following:
202 // // AXCaretBrowsingEnabled
203 // - (NSString* _Nullable)moxCaretBrowsingEnabled;
205 // // AXLayoutCount
206 // - (NSString* _Nullable)moxLayoutCount;
208 // // AXWebSessionID
209 // - (NSString* _Nullable)moxWebSessionID;
211 // // AXPreventKeyboardDOMEventDispatch
212 // - (NSString* _Nullable)moxPreventKeyboardDOMEventDispatch;
214 // Table Attributes
216 // AXRowCount
217 - (NSNumber* _Nullable)moxRowCount;
219 // AXColumnCount
220 - (NSNumber* _Nullable)moxColumnCount;
222 // AXRows
223 - (NSArray* _Nullable)moxRows;
225 // AXColumns
226 - (NSArray* _Nullable)moxColumns;
228 // AXIndex
229 - (NSNumber* _Nullable)moxIndex;
231 // AXRowIndexRange
232 - (NSValue* _Nullable)moxRowIndexRange;
234 // AXColumnIndexRange
235 - (NSValue* _Nullable)moxColumnIndexRange;
237 // AXRowHeaderUIElements
238 - (NSArray* _Nullable)moxRowHeaderUIElements;
240 // AXColumnHeaderUIElements
241 - (NSArray* _Nullable)moxColumnHeaderUIElements;
243 // AXIdentifier
244 - (NSString* _Nullable)moxIdentifier;
246 // AXVisibleChildren
247 - (NSArray* _Nullable)moxVisibleChildren;
249 // Outline Attributes
251 // AXDisclosing
252 - (NSNumber* _Nullable)moxDisclosing;
254 // AXDisclosedByRow
255 - (id _Nullable)moxDisclosedByRow;
257 // AXDisclosureLevel
258 - (NSNumber* _Nullable)moxDisclosureLevel;
260 // AXDisclosedRows
261 - (NSArray* _Nullable)moxDisclosedRows;
263 // AXSelectedRows
264 - (NSArray* _Nullable)moxSelectedRows;
266 // Math Attributes
268 // AXMathRootRadicand
269 - (id _Nullable)moxMathRootRadicand;
271 // AXMathRootIndex
272 - (id _Nullable)moxMathRootIndex;
274 // AXMathFractionNumerator
275 - (id _Nullable)moxMathFractionNumerator;
277 // AXMathFractionDenominator
278 - (id _Nullable)moxMathFractionDenominator;
280 // AXMathLineThickness
281 - (NSNumber* _Nullable)moxMathLineThickness;
283 // AXMathBase
284 - (id _Nullable)moxMathBase;
286 // AXMathSubscript
287 - (id _Nullable)moxMathSubscript;
289 // AXMathSuperscript
290 - (id _Nullable)moxMathSuperscript;
292 // AXMathUnder
293 - (id _Nullable)moxMathUnder;
295 // AXMathOver
296 - (id _Nullable)moxMathOver;
298 // AXInvalid
299 - (NSString* _Nullable)moxInvalid;
301 // AXSelectedText
302 - (NSString* _Nullable)moxSelectedText;
304 // AXSelectedTextRange
305 - (NSValue* _Nullable)moxSelectedTextRange;
307 // AXNumberOfCharacters
308 - (NSNumber* _Nullable)moxNumberOfCharacters;
310 // AXVisibleCharacterRange
311 - (NSValue* _Nullable)moxVisibleCharacterRange;
313 // AXInsertionPointLineNumber
314 - (NSNumber* _Nullable)moxInsertionPointLineNumber;
316 // AXEditableAncestor
317 - (id _Nullable)moxEditableAncestor;
319 // AXHighestEditableAncestor
320 - (id _Nullable)moxHighestEditableAncestor;
322 // AXFocusableAncestor
323 - (id _Nullable)moxFocusableAncestor;
325 // AXARIAAtomic
326 - (NSNumber* _Nullable)moxARIAAtomic;
328 // AXARIALive
329 - (NSString* _Nullable)moxARIALive;
331 // AXARIARelevant
332 - (NSString* _Nullable)moxARIARelevant;
334 // AXMozDebugDescription
335 - (NSString* _Nullable)moxMozDebugDescription;
337 #pragma mark - AttributeSetters
339 // AXDisclosing
340 - (void)moxSetDisclosing:(NSNumber* _Nullable)disclosing;
342 // AXValue
343 - (void)moxSetValue:(id _Nullable)value;
345 // AXFocused
346 - (void)moxSetFocused:(NSNumber* _Nullable)focused;
348 // AXSelected
349 - (void)moxSetSelected:(NSNumber* _Nullable)selected;
351 // AXSelectedChildren
352 - (void)moxSetSelectedChildren:(NSArray* _Nullable)selectedChildren;
354 // AXSelectedText
355 - (void)moxSetSelectedText:(NSString* _Nullable)selectedText;
357 // AXSelectedTextRange
358 - (void)moxSetSelectedTextRange:(NSValue* _Nullable)selectedTextRange;
360 // AXVisibleCharacterRange
361 - (void)moxSetVisibleCharacterRange:(NSValue* _Nullable)visibleCharacterRange;
363 #pragma mark - Actions
365 // AXPress
366 - (void)moxPerformPress;
368 // AXShowMenu
369 - (void)moxPerformShowMenu;
371 // AXScrollToVisible
372 - (void)moxPerformScrollToVisible;
374 // AXIncrement
375 - (void)moxPerformIncrement;
377 // AXDecrement
378 - (void)moxPerformDecrement;
380 #pragma mark - ParameterizedAttributeGetters
382 // AXLineForIndex
383 - (NSNumber* _Nullable)moxLineForIndex:(NSNumber* _Nonnull)index;
385 // AXRangeForLine
386 - (NSValue* _Nullable)moxRangeForLine:(NSNumber* _Nonnull)line;
388 // AXStringForRange
389 - (NSString* _Nullable)moxStringForRange:(NSValue* _Nonnull)range;
391 // AXRangeForPosition
392 - (NSValue* _Nullable)moxRangeForPosition:(NSValue* _Nonnull)position;
394 // AXRangeForIndex
395 - (NSValue* _Nullable)moxRangeForIndex:(NSNumber* _Nonnull)index;
397 // AXBoundsForRange
398 - (NSValue* _Nullable)moxBoundsForRange:(NSValue* _Nonnull)range;
400 // AXRTFForRange
401 - (NSData* _Nullable)moxRTFForRange:(NSValue* _Nonnull)range;
403 // AXStyleRangeForIndex
404 - (NSValue* _Nullable)moxStyleRangeForIndex:(NSNumber* _Nonnull)index;
406 // AXAttributedStringForRange
407 - (NSAttributedString* _Nullable)moxAttributedStringForRange:
408 (NSValue* _Nonnull)range;
410 // AXUIElementsForSearchPredicate
411 - (NSArray* _Nullable)moxUIElementsForSearchPredicate:
412 (NSDictionary* _Nonnull)searchPredicate;
414 // AXUIElementCountForSearchPredicate
415 - (NSNumber* _Nullable)moxUIElementCountForSearchPredicate:
416 (NSDictionary* _Nonnull)searchPredicate;
418 // AXCellForColumnAndRow
419 - (id _Nullable)moxCellForColumnAndRow:(NSArray* _Nonnull)columnAndRow;
421 // AXIndexForChildUIElement
422 - (NSNumber* _Nullable)moxIndexForChildUIElement:(id _Nonnull)child;
424 @end
426 // This protocol maps text marker and text marker range parameters to
427 // methods. It is implemented by a delegate of a MOXAccessible.
428 @protocol MOXTextMarkerSupport
430 #pragma mark - TextAttributeGetters
432 // AXStartTextMarker
433 - (AXTextMarkerRef _Nullable)moxStartTextMarker;
435 // AXEndTextMarker
436 - (AXTextMarkerRef _Nullable)moxEndTextMarker;
438 // AXSelectedTextMarkerRange
439 - (AXTextMarkerRangeRef _Nullable)moxSelectedTextMarkerRange;
441 #pragma mark - ParameterizedTextAttributeGetters
443 // AXLengthForTextMarkerRange
444 - (NSNumber* _Nullable)moxLengthForTextMarkerRange:
445 (AXTextMarkerRangeRef _Nonnull)textMarkerRange;
447 // AXStringForTextMarkerRange
448 - (NSString* _Nullable)moxStringForTextMarkerRange:
449 (AXTextMarkerRangeRef _Nonnull)textMarkerRange;
451 // AXTextMarkerRangeForUnorderedTextMarkers
452 - (AXTextMarkerRangeRef _Nullable)moxTextMarkerRangeForUnorderedTextMarkers:
453 (NSArray* _Nonnull)textMarkers;
455 // AXLeftWordTextMarkerRangeForTextMarker
456 - (AXTextMarkerRangeRef _Nullable)moxLeftWordTextMarkerRangeForTextMarker:
457 (AXTextMarkerRef _Nonnull)textMarker;
459 // AXRightWordTextMarkerRangeForTextMarker
460 - (AXTextMarkerRangeRef _Nullable)moxRightWordTextMarkerRangeForTextMarker:
461 (AXTextMarkerRef _Nonnull)textMarker;
463 // AXStartTextMarkerForTextMarkerRange
464 - (AXTextMarkerRef _Nullable)moxStartTextMarkerForTextMarkerRange:
465 (AXTextMarkerRangeRef _Nonnull)textMarkerRange;
467 // AXEndTextMarkerForTextMarkerRange
468 - (AXTextMarkerRef _Nullable)moxEndTextMarkerForTextMarkerRange:
469 (AXTextMarkerRangeRef _Nonnull)textMarkerRange;
471 // AXNextTextMarkerForTextMarker
472 - (AXTextMarkerRef _Nullable)moxNextTextMarkerForTextMarker:
473 (AXTextMarkerRef _Nonnull)textMarker;
475 // AXPreviousTextMarkerForTextMarker
476 - (AXTextMarkerRef _Nullable)moxPreviousTextMarkerForTextMarker:
477 (AXTextMarkerRef _Nonnull)textMarker;
479 // AXAttributedStringForTextMarkerRange
480 - (NSAttributedString* _Nullable)moxAttributedStringForTextMarkerRange:
481 (AXTextMarkerRangeRef _Nonnull)textMarkerRange;
483 // AXBoundsForTextMarkerRange
484 - (NSValue* _Nullable)moxBoundsForTextMarkerRange:
485 (AXTextMarkerRangeRef _Nonnull)textMarkerRange;
487 // AXIndexForTextMarker
488 - (NSNumber* _Nullable)moxIndexForTextMarker:
489 (AXTextMarkerRef _Nonnull)textMarker;
491 // AXTextMarkerForIndex
492 - (AXTextMarkerRef _Nullable)moxTextMarkerForIndex:(NSNumber* _Nonnull)index;
494 // AXUIElementForTextMarker
495 - (id _Nullable)moxUIElementForTextMarker:(AXTextMarkerRef _Nonnull)textMarker;
497 // AXTextMarkerRangeForUIElement
498 - (AXTextMarkerRangeRef _Nullable)moxTextMarkerRangeForUIElement:
499 (id _Nonnull)element;
501 // AXLineTextMarkerRangeForTextMarker
502 - (AXTextMarkerRangeRef _Nullable)moxLineTextMarkerRangeForTextMarker:
503 (AXTextMarkerRef _Nonnull)textMarker;
505 // AXLeftLineTextMarkerRangeForTextMarker
506 - (AXTextMarkerRangeRef _Nullable)moxLeftLineTextMarkerRangeForTextMarker:
507 (AXTextMarkerRef _Nonnull)textMarker;
509 // AXRightLineTextMarkerRangeForTextMarker
510 - (AXTextMarkerRangeRef _Nullable)moxRightLineTextMarkerRangeForTextMarker:
511 (AXTextMarkerRef _Nonnull)textMarker;
513 // AXParagraphTextMarkerRangeForTextMarker
514 - (AXTextMarkerRangeRef _Nullable)moxParagraphTextMarkerRangeForTextMarker:
515 (AXTextMarkerRef _Nonnull)textMarker;
517 // AXStyleTextMarkerRangeForTextMarker
518 - (AXTextMarkerRangeRef _Nullable)moxStyleTextMarkerRangeForTextMarker:
519 (AXTextMarkerRef _Nonnull)textMarker;
521 // AXMozDebugDescriptionForTextMarker
522 - (NSString* _Nullable)moxMozDebugDescriptionForTextMarker:
523 (AXTextMarkerRef _Nonnull)textMarker;
525 // AXMozDebugDescriptionForTextMarkerRange
526 - (NSString* _Nullable)moxMozDebugDescriptionForTextMarkerRange:
527 (AXTextMarkerRangeRef _Nonnull)textMarkerRange;
529 #pragma mark - TextAttributeSetters
531 // AXSelectedTextMarkerRange
532 - (void)moxSetSelectedTextMarkerRange:(id _Nullable)textMarkerRange;
534 @end