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/. *
8 #ifndef MOZILLA_A11Y_RemoteAccessibleWrap_h
9 #define MOZILLA_A11Y_RemoteAccessibleWrap_h
11 #include "AccessibleWrap.h"
12 #include "DocAccessibleParent.h"
18 * A wrapper for Accessible proxies. The public methods here should be
19 * overriden from AccessibleWrap or its super classes. This gives us an
20 * abstraction layer so SessionAccessibility doesn't have to distinguish between
21 * a local or remote accessibles. NOTE: This shouldn't be regarded as a full
22 * Accessible implementation.
24 class RemoteAccessibleWrap
: public AccessibleWrap
{
26 explicit RemoteAccessibleWrap(RemoteAccessible
* aProxy
);
28 virtual void Shutdown() override
;
32 virtual already_AddRefed
<AccAttributes
> Attributes() override
;
34 virtual uint32_t ChildCount() const override
;
36 virtual LocalAccessible
* LocalChildAt(uint32_t aIndex
) const override
;
38 virtual ENameValueFlag
Name(nsString
& aName
) const override
;
40 virtual void Value(nsString
& aValue
) const override
;
42 virtual uint64_t State() override
;
44 virtual nsIntRect
Bounds() const override
;
47 virtual void ScrollTo(uint32_t aHow
) const override
;
49 virtual uint8_t ActionCount() const override
;
51 virtual bool DoAction(uint8_t aIndex
) const override
;
55 virtual void SetTextContents(const nsAString
& aText
) override
;
57 virtual void GetTextContents(nsAString
& aText
) override
;
59 virtual bool GetSelectionBounds(int32_t* aStartOffset
,
60 int32_t* aEndOffset
) override
;
62 virtual void PivotTo(int32_t aGranularity
, bool aForward
,
63 bool aInclusive
) override
;
65 virtual void NavigateText(int32_t aGranularity
, int32_t aStartOffset
,
66 int32_t aEndOffset
, bool aForward
,
67 bool aSelect
) override
;
69 virtual void SetSelection(int32_t aStart
, int32_t aEnd
) override
;
71 virtual void Cut() override
;
73 virtual void Copy() override
;
75 virtual void Paste() override
;
77 virtual void ExploreByTouch(float aX
, float aY
) override
;
79 virtual void WrapperDOMNodeID(nsString
& aDOMNodeID
) override
;
82 virtual role
WrapperRole() override
;
84 virtual AccessibleWrap
* WrapperParent() override
;
86 virtual bool WrapperRangeInfo(double* aCurVal
, double* aMinVal
,
87 double* aMaxVal
, double* aStep
) override
;
90 class DocRemoteAccessibleWrap
: public RemoteAccessibleWrap
{
92 explicit DocRemoteAccessibleWrap(DocAccessibleParent
* aProxy
)
93 : RemoteAccessibleWrap(aProxy
) {
94 mGenericTypes
|= eDocument
;
96 if (aProxy
->IsTopLevel()) {
103 virtual void Shutdown() override
{
105 auto doc
= static_cast<DocAccessibleParent
*>(Proxy());
106 if (!doc
->IsTopLevel()) {
107 MOZ_ASSERT(mID
!= kNoID
, "A non root accessible must have an id");
112 mBits
.proxy
= nullptr;
113 mStateFlags
|= eIsDefunct
;
116 DocRemoteAccessibleWrap
* ParentDocument() {
117 DocAccessibleParent
* proxy
= static_cast<DocAccessibleParent
*>(Proxy());
119 if (DocAccessibleParent
* parent
= proxy
->ParentDoc()) {
120 return reinterpret_cast<DocRemoteAccessibleWrap
*>(parent
->GetWrapper());
126 DocRemoteAccessibleWrap
* GetChildDocumentAt(uint32_t aIndex
) {
127 auto doc
= Proxy()->AsDoc();
128 if (doc
&& doc
->ChildDocCount() > aIndex
) {
129 return reinterpret_cast<DocRemoteAccessibleWrap
*>(
130 doc
->ChildDocAt(aIndex
)->GetWrapper());
136 void AddID(uint32_t aID
, AccessibleWrap
* aAcc
) {
137 mIDToAccessibleMap
.InsertOrUpdate(aID
, aAcc
);
139 void RemoveID(uint32_t aID
) { mIDToAccessibleMap
.Remove(aID
); }
140 AccessibleWrap
* GetAccessibleByID(uint32_t aID
) const {
141 return mIDToAccessibleMap
.Get(aID
);
146 * This provides a mapping from 32 bit id to accessible objects.
148 nsTHashMap
<nsUint32HashKey
, AccessibleWrap
*> mIDToAccessibleMap
;
151 } // namespace mozilla