accessible/src/mac/AccessibleWrap.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:1823bb2b072a
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/. */
5
6 /* For documentation of the accessibility architecture,
7 * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
8 */
9
10 #ifndef _AccessibleWrap_H_
11 #define _AccessibleWrap_H_
12
13 #include <objc/objc.h>
14
15 #include "Accessible.h"
16 #include "States.h"
17
18 #include "nsCOMPtr.h"
19
20 #include "nsTArray.h"
21 #include "nsAutoPtr.h"
22
23 #if defined(__OBJC__)
24 @class mozAccessible;
25 #endif
26
27 namespace mozilla {
28 namespace a11y {
29
30 class AccessibleWrap : public Accessible
31 {
32 public: // construction, destruction
33 AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
34 virtual ~AccessibleWrap();
35
36 /**
37 * Get the native Obj-C object (mozAccessible).
38 */
39 NS_IMETHOD GetNativeInterface (void** aOutAccessible);
40
41 /**
42 * The objective-c |Class| type that this accessible's native object
43 * should be instantied with. used on runtime to determine the
44 * right type for this accessible's associated native object.
45 */
46 virtual Class GetNativeType ();
47
48 virtual void Shutdown ();
49 virtual void InvalidateChildren();
50
51 virtual bool InsertChildAt(uint32_t aIdx, Accessible* aChild) MOZ_OVERRIDE;
52 virtual bool RemoveChild(Accessible* aAccessible);
53
54 virtual nsresult HandleAccEvent(AccEvent* aEvent);
55
56 /**
57 * Ignored means that the accessible might still have children, but is not
58 * displayed to the user. it also has no native accessible object represented
59 * for it.
60 */
61 bool IsIgnored();
62
63 inline bool HasPopup ()
64 { return (NativeState() & mozilla::a11y::states::HASPOPUP); }
65
66 /**
67 * Returns this accessible's all children, adhering to "flat" accessibles by
68 * not returning their children.
69 */
70 void GetUnignoredChildren(nsTArray<Accessible*>* aChildrenArray);
71 Accessible* GetUnignoredParent() const;
72
73 protected:
74
75 /**
76 * Return true if the parent doesn't have children to expose to AT.
77 */
78 bool AncestorIsFlat();
79
80 /**
81 * Get the native object. Create it if needed.
82 */
83 #if defined(__OBJC__)
84 mozAccessible* GetNativeObject();
85 #else
86 id GetNativeObject();
87 #endif
88
89 private:
90
91 /**
92 * Our native object. Private because its creation is done lazily.
93 * Don't access it directly. Ever. Unless you are GetNativeObject() or
94 * Shutdown()
95 */
96 #if defined(__OBJC__)
97 // if we are in Objective-C, we use the actual Obj-C class.
98 mozAccessible* mNativeObject;
99 #else
100 id mNativeObject;
101 #endif
102
103 /**
104 * We have created our native. This does not mean there is one.
105 * This can never go back to false.
106 * We need it because checking whether we need a native object cost time.
107 */
108 bool mNativeInited;
109 };
110
111 } // namespace a11y
112 } // namespace mozilla
113
114 #endif

mercurial