no bug - Correct some typos in the comments. a=typo-fix
[gecko.git] / accessible / mac / mozRootAccessible.mm
blob3f171ada8cacb0d7989fc9891b618eb61eee5413
1 /* clang-format off */
2 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 /* clang-format on */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "RootAccessibleWrap.h"
10 #import "mozRootAccessible.h"
12 #import "mozView.h"
14 #include "gfxPlatform.h"
15 // This must be included last:
16 #include "nsObjCExceptions.h"
18 using namespace mozilla::a11y;
20 static id<mozAccessible, mozView> getNativeViewFromRootAccessible(
21     LocalAccessible* aAccessible) {
22   RootAccessibleWrap* root =
23       static_cast<RootAccessibleWrap*>(aAccessible->AsRoot());
24   id<mozAccessible, mozView> nativeView = nil;
25   root->GetNativeWidget((void**)&nativeView);
26   return nativeView;
29 #pragma mark -
31 @implementation mozRootAccessible
33 - (id)initWithAccessible:(mozilla::a11y::Accessible*)aAcc {
34   NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
36   MOZ_ASSERT(!aAcc->IsRemote(), "mozRootAccessible is never a proxy");
38   mParallelView = getNativeViewFromRootAccessible(aAcc->AsLocal());
40   return [super initWithAccessible:aAcc];
42   NS_OBJC_END_TRY_BLOCK_RETURN(nil);
45 - (NSNumber*)moxMain {
46   return @([[self moxWindow] isMainWindow]);
49 - (NSNumber*)moxMinimized {
50   return @([[self moxWindow] isMiniaturized]);
53 // return the AXParent that our parallell NSView tells us about.
54 - (id)moxUnignoredParent {
55   NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
57   // If there is no represented view (eg. headless), this will return nil.
58   return [[self representedView]
59       accessibilityAttributeValue:NSAccessibilityParentAttribute];
61   NS_OBJC_END_TRY_BLOCK_RETURN(nil);
64 - (BOOL)hasRepresentedView {
65   return YES;
68 // this will return our parallell NSView. see mozDocAccessible.h
69 - (id)representedView {
70   NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
72   MOZ_ASSERT(mParallelView || gfxPlatform::IsHeadless(),
73              "root accessible does not have a native parallel view.");
75   return mParallelView;
77   NS_OBJC_END_TRY_BLOCK_RETURN(nil);
80 - (BOOL)isRoot {
81   return YES;
84 @end