1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 2003
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Original Author: Aaron Leventhal (aaronl@netscape.com)
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either of the GNU General Public License Version 2 or later (the "GPL"),
27 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : /* For documentation of the accessibility architecture,
40 : * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
41 : */
42 :
43 : #ifndef _nsAccessNode_H_
44 : #define _nsAccessNode_H_
45 :
46 : #include "nsIAccessibleTypes.h"
47 :
48 : #include "a11yGeneric.h"
49 :
50 : #include "nsIContent.h"
51 : #include "nsIDOMNode.h"
52 : #include "nsINameSpaceManager.h"
53 : #include "nsIStringBundle.h"
54 : #include "nsWeakReference.h"
55 :
56 : class nsAccessNode;
57 : class nsApplicationAccessible;
58 : class nsDocAccessible;
59 : class nsIAccessibleDocument;
60 : class nsRootAccessible;
61 :
62 : class nsIPresShell;
63 : class nsPresContext;
64 : class nsIFrame;
65 : class nsIDocShellTreeItem;
66 :
67 : #define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties"
68 : #define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties"
69 :
70 : class nsAccessNode: public nsISupports
71 : {
72 : public:
73 :
74 : nsAccessNode(nsIContent* aContent, nsDocAccessible* aDoc);
75 : virtual ~nsAccessNode();
76 :
77 0 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
78 11712 : NS_DECL_CYCLE_COLLECTION_CLASS(nsAccessNode)
79 :
80 : static void InitXPAccessibility();
81 : static void ShutdownXPAccessibility();
82 :
83 : /**
84 : * Return an application accessible.
85 : */
86 : static nsApplicationAccessible* GetApplicationAccessible();
87 :
88 : /**
89 : * Return the document accessible for this access node.
90 : */
91 0 : nsDocAccessible* Document() const { return mDoc; }
92 :
93 : /**
94 : * Return the root document accessible for this accessnode.
95 : */
96 : nsRootAccessible* RootAccessible() const;
97 :
98 : /**
99 : * Initialize the access node object, add it to the cache.
100 : */
101 : virtual bool Init();
102 :
103 : /**
104 : * Shutdown the access node object.
105 : */
106 : virtual void Shutdown();
107 :
108 : /**
109 : * Returns true when the accessible is defunct.
110 : */
111 : virtual bool IsDefunct() const;
112 :
113 : /**
114 : * Return frame for the given access node object.
115 : */
116 : virtual nsIFrame* GetFrame() const;
117 : /**
118 : * Return DOM node associated with the accessible.
119 : */
120 0 : virtual nsINode* GetNode() const { return mContent; }
121 0 : nsIContent* GetContent() const { return mContent; }
122 0 : virtual nsIDocument* GetDocumentNode() const
123 0 : { return mContent ? mContent->OwnerDoc() : nsnull; }
124 :
125 : /**
126 : * Return node type information of DOM node associated with the accessible.
127 : */
128 0 : bool IsContent() const
129 : {
130 0 : return GetNode() && GetNode()->IsNodeOfType(nsINode::eCONTENT);
131 : }
132 0 : bool IsElement() const
133 : {
134 0 : nsINode* node = GetNode();
135 0 : return node && node->IsElement();
136 : }
137 0 : bool IsDocumentNode() const
138 : {
139 0 : return GetNode() && GetNode()->IsNodeOfType(nsINode::eDOCUMENT);
140 : }
141 :
142 : /**
143 : * Return the unique identifier of the accessible.
144 : */
145 0 : void* UniqueID() { return static_cast<void*>(this); }
146 :
147 : /**
148 : * Return true if the accessible is primary accessible for the given DOM node.
149 : *
150 : * Accessible hierarchy may be complex for single DOM node, in this case
151 : * these accessibles share the same DOM node. The primary accessible "owns"
152 : * that DOM node in terms it gets stored in the accessible to node map.
153 : */
154 : virtual bool IsPrimaryForNode() const;
155 :
156 : /**
157 : * Interface methods on nsIAccessible shared with ISimpleDOM.
158 : */
159 : void Language(nsAString& aLocale);
160 : void ScrollTo(PRUint32 aType);
161 :
162 : protected:
163 : nsPresContext* GetPresContext();
164 :
165 : void LastRelease();
166 :
167 : nsCOMPtr<nsIContent> mContent;
168 : nsDocAccessible* mDoc;
169 :
170 : /**
171 : * Notify global nsIObserver's that a11y is getting init'd or shutdown
172 : */
173 : static void NotifyA11yInitOrShutdown(bool aIsInit);
174 :
175 : // Static data, we do our own refcounting for our static data
176 : static nsIStringBundle *gStringBundle;
177 :
178 : static bool gIsFormFillEnabled;
179 :
180 : private:
181 : nsAccessNode() MOZ_DELETE;
182 : nsAccessNode(const nsAccessNode&) MOZ_DELETE;
183 : nsAccessNode& operator =(const nsAccessNode&) MOZ_DELETE;
184 :
185 : static nsApplicationAccessible *gApplicationAccessible;
186 : };
187 :
188 : #endif
189 :
|