2006-09-11 15:44:00 +00:00
|
|
|
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2003-04-01 22:18:29 +00:00
|
|
|
|
2012-05-04 06:09:22 +00:00
|
|
|
#include "RootAccessibleWrap.h"
|
2003-04-01 22:18:29 +00:00
|
|
|
|
2006-09-11 15:44:00 +00:00
|
|
|
#import "mozDocAccessible.h"
|
2003-04-01 22:18:29 +00:00
|
|
|
|
2006-09-11 15:44:00 +00:00
|
|
|
#import "mozView.h"
|
|
|
|
|
2013-01-15 12:22:03 +00:00
|
|
|
// This must be included last:
|
|
|
|
#include "nsObjCExceptions.h"
|
|
|
|
|
2012-05-04 06:09:22 +00:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2015-06-08 14:59:19 +00:00
|
|
|
static id <mozAccessible, mozView>
|
2012-05-29 01:18:45 +00:00
|
|
|
getNativeViewFromRootAccessible(Accessible* aAccessible)
|
2006-09-11 15:44:00 +00:00
|
|
|
{
|
2012-05-04 06:09:22 +00:00
|
|
|
RootAccessibleWrap* root =
|
|
|
|
static_cast<RootAccessibleWrap*>(aAccessible->AsRoot());
|
2006-09-11 15:44:00 +00:00
|
|
|
id <mozAccessible, mozView> nativeView = nil;
|
|
|
|
root->GetNativeWidget ((void**)&nativeView);
|
|
|
|
return nativeView;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
@implementation mozRootAccessible
|
|
|
|
|
2011-12-08 21:19:29 +00:00
|
|
|
- (NSArray*)accessibilityAttributeNames
|
|
|
|
{
|
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
2015-06-08 14:59:19 +00:00
|
|
|
|
2011-12-08 21:19:29 +00:00
|
|
|
// if we're expired, we don't support any attributes.
|
2015-05-22 14:59:26 +00:00
|
|
|
if (![self getGeckoAccessible])
|
2011-12-08 21:19:29 +00:00
|
|
|
return [NSArray array];
|
2015-06-08 14:59:19 +00:00
|
|
|
|
2011-12-08 21:19:29 +00:00
|
|
|
// standard attributes that are shared and supported by root accessible (AXMain) elements.
|
|
|
|
static NSMutableArray* attributes = nil;
|
2015-06-08 14:59:19 +00:00
|
|
|
|
2011-12-08 21:19:29 +00:00
|
|
|
if (!attributes) {
|
|
|
|
attributes = [[super accessibilityAttributeNames] mutableCopy];
|
|
|
|
[attributes addObject:NSAccessibilityMainAttribute];
|
|
|
|
[attributes addObject:NSAccessibilityMinimizedAttribute];
|
|
|
|
}
|
|
|
|
|
|
|
|
return attributes;
|
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)accessibilityAttributeValue:(NSString *)attribute
|
|
|
|
{
|
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
2015-06-08 14:59:19 +00:00
|
|
|
|
2011-12-09 07:53:05 +00:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityMainAttribute])
|
2011-12-08 21:19:29 +00:00
|
|
|
return [NSNumber numberWithBool:[[self window] isMainWindow]];
|
2011-12-09 07:53:05 +00:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityMinimizedAttribute])
|
2011-12-08 21:19:29 +00:00
|
|
|
return [NSNumber numberWithBool:[[self window] isMiniaturized]];
|
2011-12-09 07:53:05 +00:00
|
|
|
|
2011-12-08 21:19:29 +00:00
|
|
|
return [super accessibilityAttributeValue:attribute];
|
2015-06-08 14:59:19 +00:00
|
|
|
|
2011-12-08 21:19:29 +00:00
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-11 15:44:00 +00:00
|
|
|
// return the AXParent that our parallell NSView tells us about.
|
|
|
|
- (id)parent
|
|
|
|
{
|
2008-02-22 20:13:17 +00:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2006-09-11 16:22:22 +00:00
|
|
|
if (!mParallelView)
|
2006-11-15 11:08:14 +00:00
|
|
|
mParallelView = (id<mozView, mozAccessible>)[self representedView];
|
2015-06-08 14:59:19 +00:00
|
|
|
|
2006-11-15 11:08:14 +00:00
|
|
|
if (mParallelView)
|
|
|
|
return [mParallelView accessibilityAttributeValue:NSAccessibilityParentAttribute];
|
2015-06-08 14:59:19 +00:00
|
|
|
|
2006-11-15 11:08:14 +00:00
|
|
|
NSAssert(mParallelView, @"we're a root accessible w/o native view?");
|
|
|
|
return [super parent];
|
2008-02-22 20:13:17 +00:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-11-15 11:08:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)hasRepresentedView
|
|
|
|
{
|
|
|
|
return YES;
|
2006-09-11 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// this will return our parallell NSView. see mozDocAccessible.h
|
2006-11-15 11:08:14 +00:00
|
|
|
- (id)representedView
|
2003-04-01 22:18:29 +00:00
|
|
|
{
|
2008-02-22 20:13:17 +00:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2006-09-11 16:22:22 +00:00
|
|
|
if (mParallelView)
|
|
|
|
return (id)mParallelView;
|
2015-06-08 14:59:19 +00:00
|
|
|
|
2015-05-22 14:59:26 +00:00
|
|
|
mParallelView = getNativeViewFromRootAccessible ([self getGeckoAccessible]);
|
2015-06-08 14:59:19 +00:00
|
|
|
|
2006-12-01 10:53:52 +00:00
|
|
|
NSAssert(mParallelView, @"can't return root accessible's native parallel view.");
|
2006-09-11 16:22:22 +00:00
|
|
|
return mParallelView;
|
2008-02-22 20:13:17 +00:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2003-04-01 22:18:29 +00:00
|
|
|
}
|
|
|
|
|
2006-09-19 08:48:33 +00:00
|
|
|
- (BOOL)isRoot
|
2003-04-01 22:18:29 +00:00
|
|
|
{
|
2006-09-19 08:48:33 +00:00
|
|
|
return YES;
|
2003-04-01 22:18:29 +00:00
|
|
|
}
|
|
|
|
|
2006-09-11 15:44:00 +00:00
|
|
|
@end
|