1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_a11y_sdnAccessible_h_ 8 #define mozilla_a11y_sdnAccessible_h_ 9 10 #include "ISimpleDOM.h" 11 #include "AccessibleWrap.h" 12 #include "IUnknownImpl.h" 13 14 #include "mozilla/Attributes.h" 15 #include "mozilla/Maybe.h" 16 #include "mozilla/NotNull.h" 17 18 namespace mozilla { 19 namespace a11y { 20 21 class sdnAccessible final : public ISimpleDOMNode { 22 public: sdnAccessible(nsINode * aNode)23 explicit sdnAccessible(nsINode* aNode) : mNode(aNode) { 24 if (!mNode) MOZ_CRASH(); 25 } 26 sdnAccessible(NotNull<AccessibleWrap * > aAccWrap)27 explicit sdnAccessible(NotNull<AccessibleWrap*> aAccWrap) 28 : mNode(aAccWrap->GetNode()), mWrap(aAccWrap) {} 29 30 ~sdnAccessible(); 31 32 /** 33 * Return if the object is defunct. 34 */ IsDefunct()35 bool IsDefunct() const { return !GetDocument(); } 36 37 /** 38 * Return a document accessible it belongs to if any. 39 */ 40 DocAccessible* GetDocument() const; 41 42 /* 43 * Return associated accessible if any. 44 */ 45 AccessibleWrap* GetAccessible(); 46 SetUniqueID(uint32_t aNewUniqueId)47 void SetUniqueID(uint32_t aNewUniqueId) { mUniqueId = Some(aNewUniqueId); } 48 ReleaseUniqueID()49 Maybe<uint32_t> ReleaseUniqueID() { 50 Maybe<uint32_t> result = mUniqueId; 51 mUniqueId = Nothing(); 52 return result; 53 } 54 55 // IUnknown 56 DECL_IUNKNOWN 57 58 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_nodeInfo( 59 /* [out] */ BSTR __RPC_FAR* aNodeName, 60 /* [out] */ short __RPC_FAR* aNameSpaceID, 61 /* [out] */ BSTR __RPC_FAR* aNodeValue, 62 /* [out] */ unsigned int __RPC_FAR* aNumChildren, 63 /* [out] */ unsigned int __RPC_FAR* aUniqueID, 64 /* [out][retval] */ unsigned short __RPC_FAR* aNodeType); 65 66 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_attributes( 67 /* [in] */ unsigned short aMaxAttribs, 68 /* [length_is][size_is][out] */ BSTR __RPC_FAR* aAttribNames, 69 /* [length_is][size_is][out] */ short __RPC_FAR* aNameSpaceIDs, 70 /* [length_is][size_is][out] */ BSTR __RPC_FAR* aAttribValues, 71 /* [out][retval] */ unsigned short __RPC_FAR* aNumAttribs); 72 73 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_attributesForNames( 74 /* [in] */ unsigned short aMaxAttribs, 75 /* [length_is][size_is][in] */ BSTR __RPC_FAR* aAttribNames, 76 /* [length_is][size_is][in] */ short __RPC_FAR* aNameSpaceID, 77 /* [length_is][size_is][retval] */ BSTR __RPC_FAR* aAttribValues); 78 79 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_computedStyle( 80 /* [in] */ unsigned short aMaxStyleProperties, 81 /* [in] */ boolean aUseAlternateView, 82 /* [length_is][size_is][out] */ BSTR __RPC_FAR* aStyleProperties, 83 /* [length_is][size_is][out] */ BSTR __RPC_FAR* aStyleValues, 84 /* [out][retval] */ unsigned short __RPC_FAR* aNumStyleProperties); 85 86 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE 87 get_computedStyleForProperties( 88 /* [in] */ unsigned short aNumStyleProperties, 89 /* [in] */ boolean aUseAlternateView, 90 /* [length_is][size_is][in] */ BSTR __RPC_FAR* aStyleProperties, 91 /* [length_is][size_is][out][retval] */ BSTR __RPC_FAR* aStyleValues); 92 93 virtual HRESULT STDMETHODCALLTYPE scrollTo(/* [in] */ boolean aScrollTopLeft); 94 95 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_parentNode( 96 /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode); 97 98 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_firstChild( 99 /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode); 100 101 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_lastChild( 102 /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode); 103 104 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_previousSibling( 105 /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode); 106 107 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nextSibling( 108 /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode); 109 110 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_childAt( 111 /* [in] */ unsigned aChildIndex, 112 /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode); 113 114 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_innerHTML( 115 /* [out][retval] */ BSTR __RPC_FAR* aInnerHTML); 116 117 virtual /* [local][propget] */ HRESULT STDMETHODCALLTYPE get_localInterface( 118 /* [retval][out] */ void __RPC_FAR* __RPC_FAR* aLocalInterface); 119 120 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_language( 121 /* [out][retval] */ BSTR __RPC_FAR* aLanguage); 122 123 private: 124 nsCOMPtr<nsINode> mNode; 125 RefPtr<AccessibleWrap> mWrap; 126 Maybe<uint32_t> mUniqueId; 127 }; 128 129 } // namespace a11y 130 } // namespace mozilla 131 132 #endif // mozilla_a11y_sdnAccessible_h_ 133