AccessibleWrap.h (2454B)
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/. */ 7 8 /* For documentation of the accessibility architecture, 9 * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html 10 */ 11 12 #ifndef _AccessibleWrap_H_ 13 #define _AccessibleWrap_H_ 14 15 #include <objc/objc.h> 16 17 #include "LocalAccessible.h" 18 #include "PlatformExtTypes.h" 19 #include "States.h" 20 21 #include "nsCOMPtr.h" 22 23 #include "nsTArray.h" 24 25 #if defined(__OBJC__) 26 @class mozAccessible; 27 #endif 28 29 namespace mozilla { 30 namespace a11y { 31 32 /** 33 * Mac specific functionality for an accessibility tree node that originated in 34 * mDoc's content process. 35 */ 36 class AccessibleWrap : public LocalAccessible { 37 public: // construction, destruction 38 AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc); 39 virtual ~AccessibleWrap(); 40 41 /** 42 * Get the native Obj-C object (mozAccessible). 43 */ 44 virtual void GetNativeInterface(void** aOutAccessible) override; 45 46 /** 47 * The objective-c |Class| type that this accessible's native object 48 * should be instantied with. used on runtime to determine the 49 * right type for this accessible's associated native object. 50 */ 51 virtual Class GetNativeType(); 52 53 virtual void Shutdown() override; 54 55 virtual nsresult HandleAccEvent(AccEvent* aEvent) override; 56 57 static bool IsLiveRegion(nsIContent* aContent); 58 59 protected: 60 friend class xpcAccessibleMacInterface; 61 62 /** 63 * Get the native object. Create it if needed. 64 */ 65 #if defined(__OBJC__) 66 mozAccessible* GetNativeObject(); 67 #else 68 id GetNativeObject(); 69 #endif 70 71 private: 72 /** 73 * Our native object. Private because its creation is done lazily. 74 * Don't access it directly. Ever. Unless you are GetNativeObject() or 75 * Shutdown() 76 */ 77 #if defined(__OBJC__) 78 // if we are in Objective-C, we use the actual Obj-C class. 79 mozAccessible* mNativeObject; 80 #else 81 id mNativeObject; 82 #endif 83 84 /** 85 * We have created our native. This does not mean there is one. 86 * This can never go back to false. 87 * We need it because checking whether we need a native object cost time. 88 */ 89 bool mNativeInited; 90 }; 91 92 Class GetTypeFromRole(roles::Role aRole); 93 94 } // namespace a11y 95 } // namespace mozilla 96 97 #endif