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) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef _nsRootAccessible_H_
39 : #define _nsRootAccessible_H_
40 :
41 : #include "nsCaretAccessible.h"
42 : #include "nsDocAccessibleWrap.h"
43 :
44 : #ifdef MOZ_XUL
45 : #include "nsXULTreeAccessible.h"
46 : #endif
47 :
48 : #include "nsHashtable.h"
49 : #include "nsCaretAccessible.h"
50 : #include "nsIDocument.h"
51 : #include "nsIDOMEventListener.h"
52 :
53 : class Relation;
54 :
55 : #define NS_ROOTACCESSIBLE_IMPL_CID \
56 : { /* eaba2cf0-21b1-4e2b-b711-d3a89dcd5e1a */ \
57 : 0xeaba2cf0, \
58 : 0x21b1, \
59 : 0x4e2b, \
60 : { 0xb7, 0x11, 0xd3, 0xa8, 0x9d, 0xcd, 0x5e, 0x1a } \
61 : }
62 :
63 : const PRInt32 SCROLL_HASH_START_SIZE = 6;
64 :
65 : class nsRootAccessible : public nsDocAccessibleWrap,
66 : public nsIDOMEventListener
67 : {
68 : NS_DECL_ISUPPORTS_INHERITED
69 :
70 : public:
71 : nsRootAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
72 : nsIPresShell* aPresShell);
73 : virtual ~nsRootAccessible();
74 :
75 : // nsIAccessible
76 : NS_IMETHOD GetName(nsAString& aName);
77 :
78 : // nsIDOMEventListener
79 : NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
80 :
81 : // nsAccessNode
82 : virtual void Shutdown();
83 :
84 : // nsAccessible
85 : virtual Relation RelationByType(PRUint32 aType);
86 : virtual mozilla::a11y::role NativeRole();
87 : virtual PRUint64 NativeState();
88 :
89 : // nsRootAccessible
90 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_ROOTACCESSIBLE_IMPL_CID)
91 :
92 : nsCaretAccessible *GetCaretAccessible();
93 :
94 : /**
95 : * Notify that the sub document presshell was activated.
96 : */
97 : virtual void DocumentActivated(nsDocAccessible* aDocument);
98 :
99 : protected:
100 :
101 : /**
102 : * Add/remove DOM event listeners.
103 : */
104 : virtual nsresult AddEventListeners();
105 : virtual nsresult RemoveEventListeners();
106 :
107 : /**
108 : * Process the DOM event.
109 : */
110 : void ProcessDOMEvent(nsIDOMEvent* aEvent);
111 :
112 : /**
113 : * Process "popupshown" event. Used by HandleEvent().
114 : */
115 : void HandlePopupShownEvent(nsAccessible* aAccessible);
116 :
117 : /*
118 : * Process "popuphiding" event. Used by HandleEvent().
119 : */
120 : void HandlePopupHidingEvent(nsINode* aNode);
121 :
122 : #ifdef MOZ_XUL
123 : void HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
124 : nsXULTreeAccessible* aAccessible);
125 : void HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent,
126 : nsXULTreeAccessible* aAccessible);
127 :
128 : PRUint32 GetChromeFlags();
129 : #endif
130 :
131 : nsRefPtr<nsCaretAccessible> mCaretAccessible;
132 : };
133 :
134 : NS_DEFINE_STATIC_IID_ACCESSOR(nsRootAccessible, NS_ROOTACCESSIBLE_IMPL_CID)
135 :
136 : inline nsRootAccessible*
137 0 : nsAccessible::AsRoot()
138 : {
139 : return mFlags & eRootAccessible ?
140 0 : static_cast<nsRootAccessible*>(this) : nsnull;
141 : }
142 :
143 : #endif
|