Back to index

lightning-sunbird  0.9+nobinonly
nsRootAccessible.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef _nsRootAccessible_H_
00039 #define _nsRootAccessible_H_
00040 
00041 #include "nsDocAccessibleWrap.h"
00042 #include "nsHashtable.h"
00043 #include "nsIAccessibilityService.h"
00044 #include "nsIAccessibleDocument.h"
00045 #include "nsIDocument.h"
00046 #include "nsIDOMFocusListener.h"
00047 #include "nsIDOMFormListener.h"
00048 #include "nsIDOMXULListener.h"
00049 #include "nsIAccessibleCaret.h"
00050 #include "nsITimer.h"
00051 
00052 class nsIAccessibleEventListener;
00053 
00054 const PRInt32 SCROLL_HASH_START_SIZE = 6;
00055 
00056 class nsRootAccessible : public nsDocAccessibleWrap,
00057                          public nsIDOMFocusListener,
00058                          public nsIDOMFormListener,
00059                          public nsIDOMXULListener
00060 {
00061   NS_DECL_ISUPPORTS_INHERITED
00062 
00063   public:
00064     nsRootAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell);
00065     virtual ~nsRootAccessible();
00066 
00067     NS_IMETHOD GetName(nsAString& aName);
00068     NS_IMETHOD GetParent(nsIAccessible * *aParent);
00069     NS_IMETHOD GetRole(PRUint32 *aRole);
00070     NS_IMETHOD GetState(PRUint32 *aState);
00071     NS_IMETHOD GetAccessibleRelated(PRUint32 aRelationType,
00072                                     nsIAccessible **aRelated);
00073 
00074     // ----- nsIDOMEventListener --------------------------
00075     NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
00076 
00077     // ----- nsIDOMFocusListener --------------------------
00078     NS_IMETHOD Focus(nsIDOMEvent* aEvent);
00079     NS_IMETHOD Blur(nsIDOMEvent* aEvent);
00080 
00081     // ----- nsIDOMFormListener ---------------------------
00082     NS_IMETHOD Submit(nsIDOMEvent* aEvent);
00083     NS_IMETHOD Reset(nsIDOMEvent* aEvent);
00084     NS_IMETHOD Change(nsIDOMEvent* aEvent);
00085     NS_IMETHOD Select(nsIDOMEvent* aEvent);
00086     NS_IMETHOD Input(nsIDOMEvent* aEvent);
00087 
00088     // ----- nsIDOMXULListener ---------------------------
00089     NS_IMETHOD PopupShowing(nsIDOMEvent* aEvent);
00090     NS_IMETHOD PopupShown(nsIDOMEvent* aEvent);
00091     NS_IMETHOD PopupHiding(nsIDOMEvent* aEvent);
00092     NS_IMETHOD PopupHidden(nsIDOMEvent* aEvent);
00093     NS_IMETHOD Close(nsIDOMEvent* aEvent);
00094     NS_IMETHOD Command(nsIDOMEvent* aEvent);
00095     NS_IMETHOD Broadcast(nsIDOMEvent* aEvent);
00096     NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent);
00097 
00098     // nsIAccessibleDocument
00099     NS_IMETHOD GetCaretAccessible(nsIAccessible **aAccessibleCaret);
00100 
00101     // nsIAccessNode
00102     NS_IMETHOD Shutdown();
00103 
00104     void ShutdownAll();
00105 
00106   private:
00107     nsCOMPtr<nsITimer> mFireFocusTimer;
00108     static void FireFocusCallback(nsITimer *aTimer, void *aClosure);
00109     
00110   protected:
00111     nsresult AddEventListeners();
00112     nsresult RemoveEventListeners();
00113     static void GetTargetNode(nsIDOMEvent *aEvent, nsIDOMNode **aTargetNode);
00114     void TryFireEarlyLoadEvent(nsIAccessible *focusAccessible,
00115                                   nsIDOMNode *focusNode);
00116     void FireAccessibleFocusEvent(nsIAccessible *focusAccessible,
00117                                   nsIDOMNode *focusNode,
00118                                   nsIDOMEvent *aFocusEvent,
00119                                   PRBool aForceEvent = PR_FALSE);
00120     void FireCurrentFocusEvent();
00121     void GetChromeEventHandler(nsIDOMEventTarget **aChromeTarget);
00122     already_AddRefed<nsIDocShellTreeItem>
00123            GetContentDocShell(nsIDocShellTreeItem *aStart);
00124     nsCOMPtr<nsIAccessibilityService> mAccService;
00125     nsCOMPtr<nsIAccessibleCaret> mCaretAccessible;
00126     PRPackedBool mIsInDHTMLMenu;
00127 };
00128 
00129 #endif