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