accessible/src/mac/mozDocAccessible.mm

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "RootAccessibleWrap.h"
michael@0 7
michael@0 8 #import "mozDocAccessible.h"
michael@0 9
michael@0 10 #import "mozView.h"
michael@0 11
michael@0 12 // This must be included last:
michael@0 13 #include "nsObjCExceptions.h"
michael@0 14
michael@0 15 using namespace mozilla::a11y;
michael@0 16
michael@0 17 static id <mozAccessible, mozView>
michael@0 18 getNativeViewFromRootAccessible(Accessible* aAccessible)
michael@0 19 {
michael@0 20 RootAccessibleWrap* root =
michael@0 21 static_cast<RootAccessibleWrap*>(aAccessible->AsRoot());
michael@0 22 id <mozAccessible, mozView> nativeView = nil;
michael@0 23 root->GetNativeWidget ((void**)&nativeView);
michael@0 24 return nativeView;
michael@0 25 }
michael@0 26
michael@0 27 #pragma mark -
michael@0 28
michael@0 29 @implementation mozRootAccessible
michael@0 30
michael@0 31 - (NSArray*)accessibilityAttributeNames
michael@0 32 {
michael@0 33 NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
michael@0 34
michael@0 35 // if we're expired, we don't support any attributes.
michael@0 36 if (!mGeckoAccessible)
michael@0 37 return [NSArray array];
michael@0 38
michael@0 39 // standard attributes that are shared and supported by root accessible (AXMain) elements.
michael@0 40 static NSMutableArray* attributes = nil;
michael@0 41
michael@0 42 if (!attributes) {
michael@0 43 attributes = [[super accessibilityAttributeNames] mutableCopy];
michael@0 44 [attributes addObject:NSAccessibilityMainAttribute];
michael@0 45 [attributes addObject:NSAccessibilityMinimizedAttribute];
michael@0 46 }
michael@0 47
michael@0 48 return attributes;
michael@0 49
michael@0 50 NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
michael@0 51 }
michael@0 52
michael@0 53 - (id)accessibilityAttributeValue:(NSString *)attribute
michael@0 54 {
michael@0 55 NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
michael@0 56
michael@0 57 if ([attribute isEqualToString:NSAccessibilityMainAttribute])
michael@0 58 return [NSNumber numberWithBool:[[self window] isMainWindow]];
michael@0 59 if ([attribute isEqualToString:NSAccessibilityMinimizedAttribute])
michael@0 60 return [NSNumber numberWithBool:[[self window] isMiniaturized]];
michael@0 61
michael@0 62 return [super accessibilityAttributeValue:attribute];
michael@0 63
michael@0 64 NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
michael@0 65 }
michael@0 66
michael@0 67
michael@0 68 // return the AXParent that our parallell NSView tells us about.
michael@0 69 - (id)parent
michael@0 70 {
michael@0 71 NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
michael@0 72
michael@0 73 if (!mParallelView)
michael@0 74 mParallelView = (id<mozView, mozAccessible>)[self representedView];
michael@0 75
michael@0 76 if (mParallelView)
michael@0 77 return [mParallelView accessibilityAttributeValue:NSAccessibilityParentAttribute];
michael@0 78
michael@0 79 NSAssert(mParallelView, @"we're a root accessible w/o native view?");
michael@0 80 return [super parent];
michael@0 81
michael@0 82 NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
michael@0 83 }
michael@0 84
michael@0 85 - (BOOL)hasRepresentedView
michael@0 86 {
michael@0 87 return YES;
michael@0 88 }
michael@0 89
michael@0 90 // this will return our parallell NSView. see mozDocAccessible.h
michael@0 91 - (id)representedView
michael@0 92 {
michael@0 93 NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
michael@0 94
michael@0 95 if (mParallelView)
michael@0 96 return (id)mParallelView;
michael@0 97
michael@0 98 mParallelView = getNativeViewFromRootAccessible (mGeckoAccessible);
michael@0 99
michael@0 100 NSAssert(mParallelView, @"can't return root accessible's native parallel view.");
michael@0 101 return mParallelView;
michael@0 102
michael@0 103 NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
michael@0 104 }
michael@0 105
michael@0 106 - (BOOL)isRoot
michael@0 107 {
michael@0 108 return YES;
michael@0 109 }
michael@0 110
michael@0 111 @end

mercurial