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 "nsCaretAccessible.h"
42 #include "nsDocAccessibleWrap.h"
44 #include "nsIAccessibleDocument.h"
46 #include "nsIAccessibleTreeCache.h"
49 #include "nsHashtable.h"
50 #include "nsCaretAccessible.h"
51 #include "nsIDocument.h"
52 #include "nsIDOMFocusListener.h"
53 #include "nsIDOMFormListener.h"
54 #include "nsIDOMXULListener.h"
57 #define NS_ROOTACCESSIBLE_IMPL_CID \
58 { /* 7565f0d1-1465-4b71-906c-a623ac279f5d */ \
62 { 0x90, 0x6c, 0xa6, 0x23, 0xac, 0x27, 0x9f, 0x5d } \
65 const PRInt32 SCROLL_HASH_START_SIZE
= 6;
67 class nsRootAccessible
: public nsDocAccessibleWrap
,
68 public nsIDOMEventListener
70 NS_DECL_ISUPPORTS_INHERITED
73 nsRootAccessible(nsIDOMNode
*aDOMNode
, nsIWeakReference
* aShell
);
74 virtual ~nsRootAccessible();
77 NS_IMETHOD
GetName(nsAString
& aName
);
78 NS_IMETHOD
GetParent(nsIAccessible
* *aParent
);
79 NS_IMETHOD
GetRole(PRUint32
*aRole
);
80 NS_IMETHOD
GetState(PRUint32
*aState
, PRUint32
*aExtraState
);
81 NS_IMETHOD
GetAccessibleRelated(PRUint32 aRelationType
,
82 nsIAccessible
**aRelated
);
84 // ----- nsPIAccessibleDocument -----------------------
85 NS_IMETHOD
FireDocLoadEvents(PRUint32 aEventType
);
87 // ----- nsIDOMEventListener --------------------------
88 NS_IMETHOD
HandleEvent(nsIDOMEvent
* aEvent
);
92 NS_IMETHOD
Shutdown();
96 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ROOTACCESSIBLE_IMPL_CID
)
99 * Fire an accessible focus event for the current focusAccssible
100 * and attach a new selection listener, if necessary.
101 * @param aFocusAccessible The accessible which has received focus.
102 * @param aFocusNode The DOM Node which has received focus.
103 * @param aFocusEvent DOM focus event that caused the node/accessible to receive focus
104 * @param aForceEvent Fire a focus event even if the last focused item was the same
105 * @return Boolean -- was a focus event actually fired
107 PRBool
FireAccessibleFocusEvent(nsIAccessible
*aFocusAccessible
,
108 nsIDOMNode
*aFocusNode
,
109 nsIDOMEvent
*aFocusEvent
,
110 PRBool aForceEvent
= PR_FALSE
,
111 PRBool aIsAsynch
= PR_FALSE
);
113 * Fire an accessible focus event for the current focused node,
114 * if there is a focus.
116 void FireCurrentFocusEvent();
118 nsCaretAccessible
*GetCaretAccessible();
121 nsCOMPtr
<nsITimer
> mFireFocusTimer
;
122 static void FireFocusCallback(nsITimer
*aTimer
, void *aClosure
);
125 nsresult
AddEventListeners();
126 nsresult
RemoveEventListeners();
127 nsresult
HandleEventWithTarget(nsIDOMEvent
* aEvent
,
128 nsIDOMNode
* aTargetNode
);
129 static void GetTargetNode(nsIDOMEvent
*aEvent
, nsIDOMNode
**aTargetNode
);
130 void TryFireEarlyLoadEvent(nsIDOMNode
*aDocNode
);
131 void GetChromeEventHandler(nsIDOMEventTarget
**aChromeTarget
);
134 * Handles 'TreeRowCountChanged' event. Used in HandleEventWithTarget().
137 nsresult
HandleTreeRowCountChangedEvent(nsIDOMEvent
*aEvent
,
138 nsIAccessibleTreeCache
*aAccessible
);
141 * Handles 'TreeInvalidated' event. Used in HandleEventWithTarget().
143 nsresult
HandleTreeInvalidatedEvent(nsIDOMEvent
*aEvent
,
144 nsIAccessibleTreeCache
*aAccessible
);
146 PRUint32
GetChromeFlags();
148 already_AddRefed
<nsIDocShellTreeItem
>
149 GetContentDocShell(nsIDocShellTreeItem
*aStart
);
150 nsRefPtr
<nsCaretAccessible
> mCaretAccessible
;
151 nsCOMPtr
<nsIDOMNode
> mCurrentARIAMenubar
;
154 NS_DEFINE_STATIC_IID_ACCESSOR(nsRootAccessible
, NS_ROOTACCESSIBLE_IMPL_CID
)