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.

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

mercurial