2006-09-11 19:44:00 +04:00
|
|
|
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-09-11 19:44:00 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
#include "AccessibleWrap.h"
|
2015-06-08 17:42:33 +03:00
|
|
|
#include "ProxyAccessible.h"
|
2020-05-27 18:50:47 +03:00
|
|
|
#include "AccessibleOrProxy.h"
|
2020-05-16 00:27:57 +03:00
|
|
|
#include "Platform.h"
|
2006-09-11 19:44:00 +04:00
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
|
|
|
#import "mozAccessibleProtocol.h"
|
|
|
|
|
|
|
|
@class mozRootAccessible;
|
|
|
|
|
2012-03-23 22:54:55 +04:00
|
|
|
/**
|
|
|
|
* All mozAccessibles are either abstract objects (that correspond to XUL
|
|
|
|
* widgets, HTML frames, etc) or are attached to a certain view; for example
|
|
|
|
* a document view. When we hand an object off to an AT, we always want
|
|
|
|
* to give it the represented view, in the latter case.
|
|
|
|
*/
|
2015-07-15 07:50:14 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2012-03-23 22:54:55 +04:00
|
|
|
inline id<mozAccessible> GetObjectOrRepresentedView(id<mozAccessible> aObject) {
|
2020-05-16 00:27:57 +03:00
|
|
|
if (!ShouldA11yBeEnabled()) {
|
|
|
|
// If platform a11y is not enabled, don't return represented view.
|
|
|
|
// This is mostly for our mochitest environment because the represented
|
|
|
|
// ChildView checks `ShouldA11yBeEnabled` before proxying accessibility
|
|
|
|
// methods to mozAccessibles.
|
|
|
|
return aObject;
|
|
|
|
}
|
|
|
|
|
2012-03-23 22:54:55 +04:00
|
|
|
return [aObject hasRepresentedView] ? [aObject representedView] : aObject;
|
|
|
|
}
|
|
|
|
|
2020-05-27 18:50:47 +03:00
|
|
|
inline mozAccessible* GetNativeFromGeckoAccessible(mozilla::a11y::AccessibleOrProxy aAccOrProxy) {
|
|
|
|
MOZ_ASSERT(!aAccOrProxy.IsNull(), "Cannot get native from null accessible");
|
|
|
|
if (Accessible* acc = aAccOrProxy.AsAccessible()) {
|
|
|
|
mozAccessible* native = nil;
|
|
|
|
acc->GetNativeInterface((void**)&native);
|
|
|
|
return native;
|
|
|
|
}
|
2012-06-29 03:04:50 +04:00
|
|
|
|
2020-05-27 18:50:47 +03:00
|
|
|
ProxyAccessible* proxy = aAccOrProxy.AsProxy();
|
|
|
|
return reinterpret_cast<mozAccessible*>(proxy->GetWrapper());
|
2015-06-08 17:42:33 +03:00
|
|
|
}
|
|
|
|
|
2015-07-15 07:50:14 +03:00
|
|
|
} // a11y
|
|
|
|
} // mozilla
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
@interface mozAccessible : NSObject <mozAccessible> {
|
2011-12-09 01:19:31 +04:00
|
|
|
/**
|
2020-05-27 18:50:47 +03:00
|
|
|
* Reference to the accessible we were created with;
|
|
|
|
* either a proxy accessible or an accessible wrap.
|
2011-12-09 01:19:31 +04:00
|
|
|
*/
|
2020-05-27 18:50:47 +03:00
|
|
|
mozilla::a11y::AccessibleOrProxy mGeckoAccessible;
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2011-12-09 01:19:31 +04:00
|
|
|
/**
|
2014-10-22 04:49:28 +04:00
|
|
|
* The role of our gecko accessible.
|
2011-12-09 01:19:31 +04:00
|
|
|
*/
|
2012-01-12 08:42:47 +04:00
|
|
|
mozilla::a11y::role mRole;
|
2020-04-02 19:42:46 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A cache of a subset of our states.
|
|
|
|
*/
|
|
|
|
uint64_t mCachedState;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2020-05-27 18:50:47 +03:00
|
|
|
// inits with the given wrap or proxy accessible
|
|
|
|
- (id)initWithAccessible:(mozilla::a11y::AccessibleOrProxy)aAccOrProxy;
|
2015-05-22 17:59:26 +03:00
|
|
|
|
2020-05-27 18:50:47 +03:00
|
|
|
// allows for gecko accessible access outside of the class
|
|
|
|
- (mozilla::a11y::AccessibleOrProxy)geckoAccessible;
|
2006-09-11 19:44:00 +04:00
|
|
|
|
|
|
|
// our accessible parent (AXParent)
|
|
|
|
- (id<mozAccessible>)parent;
|
|
|
|
|
|
|
|
// a lazy cache of our accessible children (AXChildren). updated
|
|
|
|
- (NSArray*)children;
|
|
|
|
|
|
|
|
// returns the size of this accessible.
|
|
|
|
- (NSValue*)size;
|
|
|
|
|
|
|
|
// returns the position, in cocoa coordinates.
|
|
|
|
- (NSValue*)position;
|
|
|
|
|
|
|
|
// can be overridden to report another role name.
|
|
|
|
- (NSString*)role;
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
// a subrole is a more specialized variant of the role. for example,
|
|
|
|
// the role might be "textfield", while the subrole is "password textfield".
|
|
|
|
- (NSString*)subrole;
|
|
|
|
|
2012-04-18 04:31:03 +04:00
|
|
|
// Return the role description, as there are a few exceptions.
|
|
|
|
- (NSString*)roleDescription;
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
// returns the native window we're inside.
|
|
|
|
- (NSWindow*)window;
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
// the value of this element.
|
|
|
|
- (id)value;
|
2006-09-11 19:44:00 +04:00
|
|
|
|
|
|
|
// name that is associated with this accessible (for buttons, etc)
|
|
|
|
- (NSString*)title;
|
|
|
|
|
2015-08-26 17:28:05 +03:00
|
|
|
// the accessible description (help text) of this particular instance.
|
2006-11-15 14:08:14 +03:00
|
|
|
- (NSString*)help;
|
|
|
|
|
2017-06-27 12:26:00 +03:00
|
|
|
// returns the orientation (vertical, horizontal, or undefined)
|
|
|
|
- (NSString*)orientation;
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
- (BOOL)isEnabled;
|
|
|
|
|
2020-05-13 02:28:34 +03:00
|
|
|
// should a child be disabled
|
|
|
|
- (BOOL)disableChild:(mozAccessible*)child;
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
// information about focus.
|
|
|
|
- (BOOL)isFocused;
|
|
|
|
- (BOOL)canBeFocused;
|
|
|
|
|
|
|
|
// returns NO if for some reason we were unable to focus the element.
|
|
|
|
- (BOOL)focus;
|
|
|
|
|
2020-03-27 20:12:33 +03:00
|
|
|
// Given a gecko accessibility event type, post the relevant
|
|
|
|
// system accessibility notification.
|
2020-04-10 01:57:47 +03:00
|
|
|
- (void)handleAccessibleEvent:(uint32_t)eventType;
|
2020-03-27 20:12:33 +03:00
|
|
|
|
|
|
|
// Post the given accessibility system notification
|
|
|
|
- (void)postNotification:(NSString*)notification;
|
2006-09-27 16:56:28 +04:00
|
|
|
|
2015-06-23 19:17:00 +03:00
|
|
|
// internal method to retrieve a child at a given index.
|
|
|
|
- (id)childAt:(uint32_t)i;
|
|
|
|
|
2020-04-02 08:47:43 +03:00
|
|
|
// Get gecko accessible's state.
|
2020-03-12 20:28:35 +03:00
|
|
|
- (uint64_t)state;
|
|
|
|
|
2020-04-02 08:47:43 +03:00
|
|
|
// Get gecko accessible's state filtered through given mask.
|
|
|
|
- (uint64_t)stateWithMask:(uint64_t)mask;
|
|
|
|
|
2020-04-02 19:42:46 +03:00
|
|
|
// Notify of a state change, so the cache can be altered.
|
|
|
|
- (void)stateChanged:(uint64_t)state isEnabled:(BOOL)enabled;
|
|
|
|
|
|
|
|
// Invalidate cached state.
|
|
|
|
- (void)invalidateState;
|
|
|
|
|
2020-05-12 22:06:02 +03:00
|
|
|
// This is called by isAccessibilityElement. If a subclass wants
|
|
|
|
// to alter the isAccessibilityElement return value, it should
|
|
|
|
// override this and not isAccessibilityElement directly.
|
|
|
|
- (BOOL)ignoreWithParent:(mozAccessible*)parent;
|
|
|
|
|
|
|
|
// Should the child be ignored. This allows subclasses to determine
|
|
|
|
// what kinds of accessibles are valid children. This causes the child
|
|
|
|
// to be skipped, but the unignored descendants will be added to the
|
|
|
|
// container in the default children getter.
|
|
|
|
- (BOOL)ignoreChild:(mozAccessible*)child;
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
// makes ourselves "expired". after this point, we might be around if someone
|
|
|
|
// has retained us (e.g., a third-party), but we really contain no information.
|
|
|
|
- (void)expire;
|
2006-11-15 14:08:14 +03:00
|
|
|
- (BOOL)isExpired;
|
2006-09-11 19:44:00 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
- (void)printHierarchy;
|
|
|
|
- (void)printHierarchyWithLevel:(unsigned)numSpaces;
|
2006-12-01 13:53:52 +03:00
|
|
|
|
|
|
|
- (void)sanityCheckChildren;
|
2011-12-09 01:19:31 +04:00
|
|
|
- (void)sanityCheckChildren:(NSArray*)theChildren;
|
2006-09-11 19:44:00 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// ---- NSAccessibility methods ---- //
|
|
|
|
|
2020-05-12 20:39:18 +03:00
|
|
|
// whether to include this element in the platform's tree
|
|
|
|
- (BOOL)isAccessibilityElement;
|
2006-09-11 19:44:00 +04:00
|
|
|
|
|
|
|
// called by third-parties to determine the deepest child element under the mouse
|
|
|
|
- (id)accessibilityHitTest:(NSPoint)point;
|
|
|
|
|
|
|
|
// returns the deepest unignored focused accessible element
|
|
|
|
- (id)accessibilityFocusedUIElement;
|
|
|
|
|
|
|
|
// a mozAccessible needs to at least provide links to its parent and
|
|
|
|
// children.
|
|
|
|
- (NSArray*)accessibilityAttributeNames;
|
|
|
|
|
|
|
|
// value for the specified attribute
|
|
|
|
- (id)accessibilityAttributeValue:(NSString*)attribute;
|
|
|
|
|
|
|
|
- (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute;
|
|
|
|
- (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute;
|
|
|
|
|
|
|
|
@end
|