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