Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#ifndef mozilla_a11y_AccessibleWrap_h_
7
#define mozilla_a11y_AccessibleWrap_h_
8
9
#include "Accessible.h"
10
#include "GeneratedJNIWrappers.h"
11
#include "mozilla/a11y/ProxyAccessible.h"
12
#include "nsCOMPtr.h"
13
14
namespace mozilla {
15
namespace a11y {
16
17
class AccessibleWrap : public Accessible {
18
public:
19
AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
20
virtual ~AccessibleWrap();
21
22
MOZ_CAN_RUN_SCRIPT_BOUNDARY // TODO: Mark this as MOZ_CAN_RUN_SCRIPT
23
virtual nsresult
24
HandleAccEvent(AccEvent* aEvent) override;
25
26
virtual void Shutdown() override;
27
28
virtual bool DoAction(uint8_t aIndex) const override;
29
30
int32_t VirtualViewID() const { return mID; }
31
32
virtual void SetTextContents(const nsAString& aText);
33
34
virtual void GetTextContents(nsAString& aText);
35
36
virtual bool GetSelectionBounds(int32_t* aStartOffset, int32_t* aEndOffset);
37
38
virtual void Pivot(int32_t aGranularity, bool aForward, bool aInclusive);
39
40
virtual void ExploreByTouch(float aX, float aY);
41
42
virtual void NavigateText(int32_t aGranularity, int32_t aStartOffset,
43
int32_t aEndOffset, bool aForward, bool aSelect);
44
45
virtual void SetSelection(int32_t aStart, int32_t aEnd);
46
47
virtual void Cut();
48
49
virtual void Copy();
50
51
MOZ_CAN_RUN_SCRIPT_BOUNDARY
52
virtual void Paste();
53
54
mozilla::java::GeckoBundle::LocalRef ToBundle(bool aSmall = false);
55
56
mozilla::java::GeckoBundle::LocalRef ToBundle(
57
const uint64_t aState, const nsIntRect& aBounds,
58
const uint8_t aActionCount, const nsString& aName,
59
const nsString& aTextValue, const nsString& aDOMNodeID,
60
const nsString& aDescription,
61
const double& aCurVal = UnspecifiedNaN<double>(),
62
const double& aMinVal = UnspecifiedNaN<double>(),
63
const double& aMaxVal = UnspecifiedNaN<double>(),
64
const double& aStep = UnspecifiedNaN<double>(),
65
nsIPersistentProperties* aAttributes = nullptr);
66
67
virtual void WrapperDOMNodeID(nsString& aDOMNodeID);
68
69
int32_t AndroidClass() {
70
return mID == kNoID ? java::SessionAccessibility::CLASSNAME_WEBVIEW
71
: GetAndroidClass(WrapperRole());
72
}
73
74
static already_AddRefed<nsIPersistentProperties> AttributeArrayToProperties(
75
const nsTArray<Attribute>& aAttributes);
76
77
static const int32_t kNoID = -1;
78
79
protected:
80
// IDs should be a positive 32bit integer.
81
static int32_t AcquireID();
82
static void ReleaseID(int32_t aID);
83
84
static int32_t GetAndroidClass(role aRole);
85
86
static int32_t GetInputType(const nsString& aInputTypeAttr);
87
88
int32_t mID;
89
90
private:
91
virtual AccessibleWrap* WrapperParent() {
92
return static_cast<AccessibleWrap*>(Parent());
93
}
94
95
virtual bool WrapperRangeInfo(double* aCurVal, double* aMinVal,
96
double* aMaxVal, double* aStep);
97
98
virtual role WrapperRole() { return Role(); }
99
100
void GetTextEquiv(nsString& aText);
101
102
bool HandleLiveRegionEvent(AccEvent* aEvent);
103
104
void GetSelectionOrCaret(int32_t* aStartOffset, int32_t* aEndOffset);
105
106
static void GetRoleDescription(role aRole,
107
nsIPersistentProperties* aAttributes,
108
nsAString& aGeckoRole,
109
nsAString& aRoleDescription);
110
111
static uint32_t GetFlags(role aRole, uint64_t aState, uint8_t aActionCount);
112
};
113
114
static inline AccessibleWrap* WrapperFor(const ProxyAccessible* aProxy) {
115
return reinterpret_cast<AccessibleWrap*>(aProxy->GetWrapper());
116
}
117
118
} // namespace a11y
119
} // namespace mozilla
120
121
#endif