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) 2003
20 * the Initial Developer. All Rights Reserved.
23 * Original Author: Aaron Leventhal (aaronl@netscape.com)
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.
37 * ***** END LICENSE BLOCK ***** */
39 /* For documentation of the accessibility architecture,
40 * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
43 #ifndef _nsAccessNodeWrap_H_
44 #define _nsAccessNodeWrap_H_
46 // Avoid warning C4509:
47 // nonstandard extension used: 'nsAccessibleWrap::[methodname]'
48 // uses SEH and 'xpAccessible' has destructor
49 // At this point we're catching a crash which is of much greater
50 // importance than the missing dereference for the nsCOMPtr<>
51 #pragma warning( disable : 4509 )
54 #include "nsIAccessible.h"
55 #include "nsIAccessibleEvent.h"
56 #include "nsIWinAccessNode.h"
57 #include "ISimpleDOMNode.h"
58 #include "nsIDOMElement.h"
59 #include "nsIContent.h"
60 #include "nsAccessNode.h"
67 #ifdef MOZ_CRASHREPORTER
68 #include "nsICrashReporter.h"
71 typedef LRESULT (STDAPICALLTYPE
*LPFNNOTIFYWINEVENT
)(DWORD event
,HWND hwnd
,LONG idObjectType
,LONG idObject
);
72 typedef LRESULT (STDAPICALLTYPE
*LPFNGETGUITHREADINFO
)(DWORD idThread
, GUITHREADINFO
* pgui
);
74 class AccTextChangeEvent
;
76 class nsAccessNodeWrap
: public nsAccessNode
,
77 public nsIWinAccessNode
,
78 public ISimpleDOMNode
,
79 public IServiceProvider
82 NS_DECL_ISUPPORTS_INHERITED
83 NS_DECL_NSIWINACCESSNODE
85 public: // IServiceProvider
86 STDMETHODIMP
QueryService(REFGUID guidService
, REFIID riid
, void** ppv
);
88 public: // construction, destruction
89 nsAccessNodeWrap(nsIContent
*aContent
, nsIWeakReference
*aShell
);
90 virtual ~nsAccessNodeWrap();
93 STDMETHODIMP
QueryInterface(REFIID
, void**);
97 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE
get_nodeInfo(
98 /* [out] */ BSTR __RPC_FAR
*tagName
,
99 /* [out] */ short __RPC_FAR
*nameSpaceID
,
100 /* [out] */ BSTR __RPC_FAR
*nodeValue
,
101 /* [out] */ unsigned int __RPC_FAR
*numChildren
,
102 /* [out] */ unsigned int __RPC_FAR
*aUniqueID
,
103 /* [out][retval] */ unsigned short __RPC_FAR
*nodeType
);
105 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE
get_attributes(
106 /* [in] */ unsigned short maxAttribs
,
107 /* [length_is][size_is][out] */ BSTR __RPC_FAR
*attribNames
,
108 /* [length_is][size_is][out] */ short __RPC_FAR
*nameSpaceID
,
109 /* [length_is][size_is][out] */ BSTR __RPC_FAR
*attribValues
,
110 /* [out][retval] */ unsigned short __RPC_FAR
*numAttribs
);
112 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE
get_attributesForNames(
113 /* [in] */ unsigned short maxAttribs
,
114 /* [length_is][size_is][in] */ BSTR __RPC_FAR
*attribNames
,
115 /* [length_is][size_is][in] */ short __RPC_FAR
*nameSpaceID
,
116 /* [length_is][size_is][retval] */ BSTR __RPC_FAR
*attribValues
);
118 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE
get_computedStyle(
119 /* [in] */ unsigned short maxStyleProperties
,
120 /* [in] */ boolean useAlternateView
,
121 /* [length_is][size_is][out] */ BSTR __RPC_FAR
*styleProperties
,
122 /* [length_is][size_is][out] */ BSTR __RPC_FAR
*styleValues
,
123 /* [out][retval] */ unsigned short __RPC_FAR
*numStyleProperties
);
125 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE
get_computedStyleForProperties(
126 /* [in] */ unsigned short numStyleProperties
,
127 /* [in] */ boolean useAlternateView
,
128 /* [length_is][size_is][in] */ BSTR __RPC_FAR
*styleProperties
,
129 /* [length_is][size_is][out][retval] */ BSTR __RPC_FAR
*styleValues
);
131 virtual HRESULT STDMETHODCALLTYPE
scrollTo(/* [in] */ boolean scrollTopLeft
);
133 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE
get_parentNode(ISimpleDOMNode __RPC_FAR
*__RPC_FAR
*node
);
134 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE
get_firstChild(ISimpleDOMNode __RPC_FAR
*__RPC_FAR
*node
);
135 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE
get_lastChild(ISimpleDOMNode __RPC_FAR
*__RPC_FAR
*node
);
136 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE
get_previousSibling(ISimpleDOMNode __RPC_FAR
*__RPC_FAR
*node
);
137 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE
get_nextSibling(ISimpleDOMNode __RPC_FAR
*__RPC_FAR
*node
);
138 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE
get_childAt(unsigned childIndex
,
139 ISimpleDOMNode __RPC_FAR
*__RPC_FAR
*node
);
141 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE
get_innerHTML(
142 /* [out][retval] */ BSTR __RPC_FAR
*innerHTML
);
144 virtual /* [local][propget] */ HRESULT STDMETHODCALLTYPE
get_localInterface(
145 /* [retval][out] */ void __RPC_FAR
*__RPC_FAR
*localInterface
);
147 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE
get_language(
148 /* [out][retval] */ BSTR __RPC_FAR
*language
);
150 static void InitAccessibility();
151 static void ShutdownAccessibility();
153 /// the accessible library and cached methods
154 static HINSTANCE gmAccLib
;
155 static HINSTANCE gmUserLib
;
156 static LPFNACCESSIBLEOBJECTFROMWINDOW gmAccessibleObjectFromWindow
;
157 static LPFNNOTIFYWINEVENT gmNotifyWinEvent
;
158 static LPFNGETGUITHREADINFO gmGetGUIThreadInfo
;
160 static int FilterA11yExceptions(unsigned int aCode
, EXCEPTION_POINTERS
*aExceptionInfo
);
162 static PRBool
IsOnlyMsaaCompatibleJawsPresent();
164 static void TurnOffNewTabSwitchingForJawsAndWE();
166 static void DoATSpecificProcessing();
171 * Return ISimpleDOMNode instance for existing accessible object or
172 * creates new nsAccessNode instance if the accessible doesn't exist.
174 * @note ISimpleDOMNode is returned addrefed
176 ISimpleDOMNode
*MakeAccessNode(nsINode
*aNode
);
178 static PRBool gIsEnumVariantSupportDisabled
;
181 * Used to determine whether an IAccessible2 compatible screen reader is
182 * loaded. Currently used for JAWS versions older than 8.0.2173.
184 static PRBool gIsIA2Disabled
;
187 * It is used in nsHyperTextAccessibleWrap for IA2::newText/oldText
190 static AccTextChangeEvent
* gTextEvent
;
194 * Converts nsresult to HRESULT.
196 HRESULT
GetHRESULT(nsresult aResult
);