summaryrefslogtreecommitdiffstats
path: root/accessible/windows/sdn/sdnAccessible.h
blob: 610a4ca5de0a1ecb0021ce645b1aa8c36ed4f9e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_a11y_sdnAccessible_h_
#define mozilla_a11y_sdnAccessible_h_

#include "ISimpleDOM.h"
#include "AccessibleWrap.h"
#include "IUnknownImpl.h"
#include "MsaaAccessible.h"

#include "mozilla/Attributes.h"
#include "mozilla/Maybe.h"
#include "mozilla/NotNull.h"

namespace mozilla {
namespace a11y {

class sdnAccessible final : public ISimpleDOMNode {
 public:
  explicit sdnAccessible(nsINode* aNode) : mNode(aNode) {
    if (!mNode) MOZ_CRASH();
  }

  explicit sdnAccessible(NotNull<MsaaAccessible*> aMsaa) : mMsaa(aMsaa) {
    Accessible* acc = aMsaa->Acc();
    MOZ_ASSERT(acc);
    if (LocalAccessible* localAcc = acc->AsLocal()) {
      mNode = localAcc->GetNode();
    }
  }

  ~sdnAccessible();

  /**
   * Return if the object is defunct.
   */
  bool IsDefunct() const {
    if (mMsaa && !mMsaa->Acc()) {
      return true;
    }
    if (!mNode) {
      MOZ_ASSERT(mMsaa && mMsaa->Acc()->IsRemote());
      return false;
    }
    return !GetDocument();
  }

  /**
   * Return a local document accessible it belongs to if any.
   */
  DocAccessible* GetDocument() const;

  /*
   * Return associated MsaaAccessible if any.
   */
  MsaaAccessible* GetMsaa();

  void SetUniqueID(uint32_t aNewUniqueId) { mUniqueId = Some(aNewUniqueId); }

  Maybe<uint32_t> ReleaseUniqueID() {
    Maybe<uint32_t> result = mUniqueId;
    mUniqueId = Nothing();
    return result;
  }

  // IUnknown
  DECL_IUNKNOWN

  virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_nodeInfo(
      /* [out] */ BSTR __RPC_FAR* aNodeName,
      /* [out] */ short __RPC_FAR* aNameSpaceID,
      /* [out] */ BSTR __RPC_FAR* aNodeValue,
      /* [out] */ unsigned int __RPC_FAR* aNumChildren,
      /* [out] */ unsigned int __RPC_FAR* aUniqueID,
      /* [out][retval] */ unsigned short __RPC_FAR* aNodeType);

  virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_attributes(
      /* [in] */ unsigned short aMaxAttribs,
      /* [length_is][size_is][out] */ BSTR __RPC_FAR* aAttribNames,
      /* [length_is][size_is][out] */ short __RPC_FAR* aNameSpaceIDs,
      /* [length_is][size_is][out] */ BSTR __RPC_FAR* aAttribValues,
      /* [out][retval] */ unsigned short __RPC_FAR* aNumAttribs);

  virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_attributesForNames(
      /* [in] */ unsigned short aMaxAttribs,
      /* [length_is][size_is][in] */ BSTR __RPC_FAR* aAttribNames,
      /* [length_is][size_is][in] */ short __RPC_FAR* aNameSpaceID,
      /* [length_is][size_is][retval] */ BSTR __RPC_FAR* aAttribValues);

  virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_computedStyle(
      /* [in] */ unsigned short aMaxStyleProperties,
      /* [in] */ boolean aUseAlternateView,
      /* [length_is][size_is][out] */ BSTR __RPC_FAR* aStyleProperties,
      /* [length_is][size_is][out] */ BSTR __RPC_FAR* aStyleValues,
      /* [out][retval] */ unsigned short __RPC_FAR* aNumStyleProperties);

  virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE
  get_computedStyleForProperties(
      /* [in] */ unsigned short aNumStyleProperties,
      /* [in] */ boolean aUseAlternateView,
      /* [length_is][size_is][in] */ BSTR __RPC_FAR* aStyleProperties,
      /* [length_is][size_is][out][retval] */ BSTR __RPC_FAR* aStyleValues);

  virtual HRESULT STDMETHODCALLTYPE scrollTo(/* [in] */ boolean aScrollTopLeft);

  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_parentNode(
      /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode);

  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_firstChild(
      /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode);

  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_lastChild(
      /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode);

  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_previousSibling(
      /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode);

  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nextSibling(
      /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode);

  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_childAt(
      /* [in] */ unsigned aChildIndex,
      /* [out][retval] */ ISimpleDOMNode __RPC_FAR* __RPC_FAR* aNode);

  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_innerHTML(
      /* [out][retval] */ BSTR __RPC_FAR* aInnerHTML);

  virtual /* [local][propget] */ HRESULT STDMETHODCALLTYPE get_localInterface(
      /* [retval][out] */ void __RPC_FAR* __RPC_FAR* aLocalInterface);

  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_language(
      /* [out][retval] */ BSTR __RPC_FAR* aLanguage);

 private:
  // mNode will be null for a RemoteAccessible. In that case, we only partially
  // implement this interface using data from the RemoteAccessible cache.
  nsCOMPtr<nsINode> mNode;
  RefPtr<MsaaAccessible> mMsaa;
  Maybe<uint32_t> mUniqueId;
};

}  // namespace a11y
}  // namespace mozilla

#endif  // mozilla_a11y_sdnAccessible_h_