Bug 1734067 [wpt PR 31108] - Update wpt metadata, a=testonly
[gecko.git] / accessible / mac / mozRootAccessible.mm
blobdad61f8bbcce6e9d9aa3b3ac718075a78804a8ed
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 // This must be included last:
15 #include "nsObjCExceptions.h"
17 using namespace mozilla::a11y;
19 static id<mozAccessible, mozView> getNativeViewFromRootAccessible(
20     LocalAccessible* aAccessible) {
21   RootAccessibleWrap* root =
22       static_cast<RootAccessibleWrap*>(aAccessible->AsRoot());
23   id<mozAccessible, mozView> nativeView = nil;
24   root->GetNativeWidget((void**)&nativeView);
25   return nativeView;
28 #pragma mark -
30 @implementation mozRootAccessible
32 - (id)initWithAccessible:(mozilla::a11y::Accessible*)aAcc {
33   NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
35   MOZ_ASSERT(!aAcc->IsRemote(), "mozRootAccessible is never a proxy");
37   mParallelView = getNativeViewFromRootAccessible(aAcc->AsLocal());
39   return [super initWithAccessible:aAcc];
41   NS_OBJC_END_TRY_BLOCK_RETURN(nil);
44 - (NSNumber*)moxMain {
45   return @([[self moxWindow] isMainWindow]);
48 - (NSNumber*)moxMinimized {
49   return @([[self moxWindow] isMiniaturized]);
52 // return the AXParent that our parallell NSView tells us about.
53 - (id)moxUnignoredParent {
54   NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
56   // If there is no represented view (eg. headless), this will return nil.
57   return [[self representedView]
58       accessibilityAttributeValue:NSAccessibilityParentAttribute];
60   NS_OBJC_END_TRY_BLOCK_RETURN(nil);
63 - (BOOL)hasRepresentedView {
64   return YES;
67 // this will return our parallell NSView. see mozDocAccessible.h
68 - (id)representedView {
69   NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
71   MOZ_ASSERT(mParallelView,
72              "root accessible does not have a native parallel view.");
74   return mParallelView;
76   NS_OBJC_END_TRY_BLOCK_RETURN(nil);
79 - (BOOL)isRoot {
80   return YES;
83 @end