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
mozilla::java::GeckoBundle::LocalRef ToBundle(bool aSmall = false);
39
40
mozilla::java::GeckoBundle::LocalRef ToBundle(
41
const uint64_t aState, const nsIntRect& aBounds,
42
const uint8_t aActionCount, const nsString& aName,
43
const nsString& aTextValue, const nsString& aDOMNodeID,
44
const nsString& aDescription,
45
const double& aCurVal = UnspecifiedNaN<double>(),
46
const double& aMinVal = UnspecifiedNaN<double>(),
47
const double& aMaxVal = UnspecifiedNaN<double>(),
48
const double& aStep = UnspecifiedNaN<double>(),
49
nsIPersistentProperties* aAttributes = nullptr);
50
51
virtual void WrapperDOMNodeID(nsString& aDOMNodeID);
52
53
int32_t AndroidClass() {
54
return mID == kNoID ? java::SessionAccessibility::CLASSNAME_WEBVIEW
55
: GetAndroidClass(WrapperRole());
56
}
57
58
static already_AddRefed<nsIPersistentProperties> AttributeArrayToProperties(
59
const nsTArray<Attribute>& aAttributes);
60
61
static const int32_t kNoID = -1;
62
63
protected:
64
// IDs should be a positive 32bit integer.
65
static int32_t AcquireID();
66
static void ReleaseID(int32_t aID);
67
68
static int32_t GetAndroidClass(role aRole);
69
70
static int32_t GetInputType(const nsString& aInputTypeAttr);
71
72
int32_t mID;
73
74
private:
75
virtual AccessibleWrap* WrapperParent() {
76
return static_cast<AccessibleWrap*>(Parent());
77
}
78
79
virtual bool WrapperRangeInfo(double* aCurVal, double* aMinVal,
80
double* aMaxVal, double* aStep);
81
82
virtual role WrapperRole() { return Role(); }
83
84
void GetTextEquiv(nsString& aText);
85
86
bool HandleLiveRegionEvent(AccEvent* aEvent);
87
88
static void GetRoleDescription(role aRole,
89
nsIPersistentProperties* aAttributes,
90
nsAString& aGeckoRole,
91
nsAString& aRoleDescription);
92
93
static uint32_t GetFlags(role aRole, uint64_t aState, uint8_t aActionCount);
94
};
95
96
static inline AccessibleWrap* WrapperFor(const ProxyAccessible* aProxy) {
97
return reinterpret_cast<AccessibleWrap*>(aProxy->GetWrapper());
98
}
99
100
} // namespace a11y
101
} // namespace mozilla
102
103
#endif