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
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/
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
15 * The Original Code is mozilla.org code.
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.
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.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef _nsRootAccessible_H_
39 #define _nsRootAccessible_H_
41 #include "nsDocAccessibleWrap.h"
42 #include "nsHashtable.h"
43 #include "nsIAccessibleDocument.h"
44 #include "nsCaretAccessible.h"
45 #include "nsIDocument.h"
46 #include "nsIDOMFocusListener.h"
47 #include "nsIDOMFormListener.h"
48 #include "nsIDOMXULListener.h"
51 #define NS_ROOTACCESSIBLE_IMPL_CID \
52 { /* 7565f0d1-1465-4b71-906c-a623ac279f5d */ \
56 { 0x90, 0x6c, 0xa6, 0x23, 0xac, 0x27, 0x9f, 0x5d } \
59 const PRInt32 SCROLL_HASH_START_SIZE
= 6;
61 class nsRootAccessible
: public nsDocAccessibleWrap
,
62 public nsIDOMEventListener
64 NS_DECL_ISUPPORTS_INHERITED
67 nsRootAccessible(nsIDOMNode
*aDOMNode
, nsIWeakReference
* aShell
);
68 virtual ~nsRootAccessible();
71 NS_IMETHOD
GetName(nsAString
& aName
);
72 NS_IMETHOD
GetParent(nsIAccessible
* *aParent
);
73 NS_IMETHOD
GetRole(PRUint32
*aRole
);
74 NS_IMETHOD
GetState(PRUint32
*aState
, PRUint32
*aExtraState
);
75 NS_IMETHOD
GetAccessibleRelated(PRUint32 aRelationType
,
76 nsIAccessible
**aRelated
);
78 // ----- nsPIAccessibleDocument -----------------------
79 NS_IMETHOD
FireDocLoadEvents(PRUint32 aEventType
);
81 // ----- nsIDOMEventListener --------------------------
82 NS_IMETHOD
HandleEvent(nsIDOMEvent
* aEvent
);
86 NS_IMETHOD
Shutdown();
90 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ROOTACCESSIBLE_IMPL_CID
)
93 * Fire an accessible focus event for the current focusAccssible
94 * and attach a new selection listener, if necessary.
95 * @param aFocusAccessible The accessible which has received focus.
96 * @param aFocusNode The DOM Node which has received focus.
97 * @param aFocusEvent DOM focus event that caused the node/accessible to receive focus
98 * @param aForceEvent Fire a focus event even if the last focused item was the same
99 * @return Boolean -- was a focus event actually fired
101 PRBool
FireAccessibleFocusEvent(nsIAccessible
*aFocusAccessible
,
102 nsIDOMNode
*aFocusNode
,
103 nsIDOMEvent
*aFocusEvent
,
104 PRBool aForceEvent
= PR_FALSE
,
105 PRBool aIsAsynch
= PR_FALSE
);
107 nsCaretAccessible
*GetCaretAccessible();
110 nsCOMPtr
<nsITimer
> mFireFocusTimer
;
111 static void FireFocusCallback(nsITimer
*aTimer
, void *aClosure
);
114 nsresult
AddEventListeners();
115 nsresult
RemoveEventListeners();
116 nsresult
HandleEventWithTarget(nsIDOMEvent
* aEvent
,
117 nsIDOMNode
* aTargetNode
);
118 static void GetTargetNode(nsIDOMEvent
*aEvent
, nsIDOMNode
**aTargetNode
);
119 void TryFireEarlyLoadEvent(nsIDOMNode
*aDocNode
);
120 void FireCurrentFocusEvent();
121 void GetChromeEventHandler(nsIDOMEventTarget
**aChromeTarget
);
124 * Handles 'TreeRowCountChanged' event. Used in HandleEventWithTarget().
126 nsresult
HandleTreeRowCountChangedEvent(nsIDOMEvent
*aEvent
,
127 nsIAccessible
*aAccessible
,
128 const nsAString
& aTargetName
);
131 * Handles 'TreeInvalidated' event. Used in HandleEventWithTarget().
133 nsresult
HandleTreeInvalidatedEvent(nsIDOMEvent
*aEvent
,
134 nsIAccessible
*aAccessible
,
135 const nsAString
& aTargetName
);
138 PRUint32
GetChromeFlags();
140 already_AddRefed
<nsIDocShellTreeItem
>
141 GetContentDocShell(nsIDocShellTreeItem
*aStart
);
142 nsRefPtr
<nsCaretAccessible
> mCaretAccessible
;
143 nsCOMPtr
<nsIDOMNode
> mCurrentARIAMenubar
;
146 NS_DEFINE_STATIC_IID_ACCESSOR(nsRootAccessible
, NS_ROOTACCESSIBLE_IMPL_CID
)