/src/mozilla-central/accessible/generic/ApplicationAccessible.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim:expandtab:shiftwidth=2:tabstop=2: |
3 | | */ |
4 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
5 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 | | |
8 | | #include "ApplicationAccessible.h" |
9 | | |
10 | | #include "nsAccessibilityService.h" |
11 | | #include "nsAccUtils.h" |
12 | | #include "Relation.h" |
13 | | #include "Role.h" |
14 | | #include "States.h" |
15 | | |
16 | | #include "nsIComponentManager.h" |
17 | | #include "nsIWindowMediator.h" |
18 | | #include "nsServiceManagerUtils.h" |
19 | | #include "mozilla/Services.h" |
20 | | #include "nsGlobalWindow.h" |
21 | | #include "nsIStringBundle.h" |
22 | | |
23 | | using namespace mozilla::a11y; |
24 | | |
25 | | ApplicationAccessible::ApplicationAccessible() : |
26 | | AccessibleWrap(nullptr, nullptr) |
27 | 0 | { |
28 | 0 | mType = eApplicationType; |
29 | 0 | mAppInfo = do_GetService("@mozilla.org/xre/app-info;1"); |
30 | 0 | MOZ_ASSERT(mAppInfo, "no application info"); |
31 | 0 | } |
32 | | |
33 | | //////////////////////////////////////////////////////////////////////////////// |
34 | | // nsIAccessible |
35 | | |
36 | | ENameValueFlag |
37 | | ApplicationAccessible::Name(nsString& aName) const |
38 | 0 | { |
39 | 0 | aName.Truncate(); |
40 | 0 |
|
41 | 0 | nsCOMPtr<nsIStringBundleService> bundleService = |
42 | 0 | mozilla::services::GetStringBundleService(); |
43 | 0 |
|
44 | 0 | NS_ASSERTION(bundleService, "String bundle service must be present!"); |
45 | 0 | if (!bundleService) |
46 | 0 | return eNameOK; |
47 | 0 | |
48 | 0 | nsCOMPtr<nsIStringBundle> bundle; |
49 | 0 | nsresult rv = bundleService->CreateBundle("chrome://branding/locale/brand.properties", |
50 | 0 | getter_AddRefs(bundle)); |
51 | 0 | if (NS_FAILED(rv)) |
52 | 0 | return eNameOK; |
53 | 0 | |
54 | 0 | nsAutoString appName; |
55 | 0 | rv = bundle->GetStringFromName("brandShortName", appName); |
56 | 0 | if (NS_FAILED(rv) || appName.IsEmpty()) { |
57 | 0 | NS_WARNING("brandShortName not found, using default app name"); |
58 | 0 | appName.AssignLiteral("Gecko based application"); |
59 | 0 | } |
60 | 0 |
|
61 | 0 | aName.Assign(appName); |
62 | 0 | return eNameOK; |
63 | 0 | } |
64 | | |
65 | | void |
66 | | ApplicationAccessible::Description(nsString& aDescription) |
67 | 0 | { |
68 | 0 | aDescription.Truncate(); |
69 | 0 | } |
70 | | |
71 | | void |
72 | | ApplicationAccessible::Value(nsString& aValue) const |
73 | 0 | { |
74 | 0 | aValue.Truncate(); |
75 | 0 | } |
76 | | |
77 | | uint64_t |
78 | | ApplicationAccessible::State() |
79 | 0 | { |
80 | 0 | return IsDefunct() ? states::DEFUNCT : 0; |
81 | 0 | } |
82 | | |
83 | | already_AddRefed<nsIPersistentProperties> |
84 | | ApplicationAccessible::NativeAttributes() |
85 | 0 | { |
86 | 0 | return nullptr; |
87 | 0 | } |
88 | | |
89 | | GroupPos |
90 | | ApplicationAccessible::GroupPosition() |
91 | 0 | { |
92 | 0 | return GroupPos(); |
93 | 0 | } |
94 | | |
95 | | Accessible* |
96 | | ApplicationAccessible::ChildAtPoint(int32_t aX, int32_t aY, |
97 | | EWhichChildAtPoint aWhichChild) |
98 | 0 | { |
99 | 0 | return nullptr; |
100 | 0 | } |
101 | | |
102 | | Accessible* |
103 | | ApplicationAccessible::FocusedChild() |
104 | 0 | { |
105 | 0 | Accessible* focus = FocusMgr()->FocusedAccessible(); |
106 | 0 | if (focus && focus->Parent() == this) |
107 | 0 | return focus; |
108 | 0 | |
109 | 0 | return nullptr; |
110 | 0 | } |
111 | | |
112 | | Relation |
113 | | ApplicationAccessible::RelationByType(RelationType aRelationType) const |
114 | 0 | { |
115 | 0 | return Relation(); |
116 | 0 | } |
117 | | |
118 | | nsIntRect |
119 | | ApplicationAccessible::Bounds() const |
120 | 0 | { |
121 | 0 | return nsIntRect(); |
122 | 0 | } |
123 | | |
124 | | nsRect |
125 | | ApplicationAccessible::BoundsInAppUnits() const |
126 | 0 | { |
127 | 0 | return nsRect(); |
128 | 0 | } |
129 | | |
130 | | //////////////////////////////////////////////////////////////////////////////// |
131 | | // Accessible public methods |
132 | | |
133 | | void |
134 | | ApplicationAccessible::Shutdown() |
135 | 0 | { |
136 | 0 | mAppInfo = nullptr; |
137 | 0 | } |
138 | | |
139 | | void |
140 | | ApplicationAccessible::ApplyARIAState(uint64_t* aState) const |
141 | 0 | { |
142 | 0 | } |
143 | | |
144 | | role |
145 | | ApplicationAccessible::NativeRole() const |
146 | 0 | { |
147 | 0 | return roles::APP_ROOT; |
148 | 0 | } |
149 | | |
150 | | uint64_t |
151 | | ApplicationAccessible::NativeState() const |
152 | 0 | { |
153 | 0 | return 0; |
154 | 0 | } |
155 | | |
156 | | KeyBinding |
157 | | ApplicationAccessible::AccessKey() const |
158 | 0 | { |
159 | 0 | return KeyBinding(); |
160 | 0 | } |
161 | | |
162 | | void |
163 | | ApplicationAccessible::Init() |
164 | 0 | { |
165 | 0 | // Basically children are kept updated by Append/RemoveChild method calls. |
166 | 0 | // However if there are open windows before accessibility was started |
167 | 0 | // then we need to make sure root accessibles for open windows are created so |
168 | 0 | // that all root accessibles are stored in application accessible children |
169 | 0 | // array. |
170 | 0 |
|
171 | 0 | nsGlobalWindowOuter::OuterWindowByIdTable* windowsById = |
172 | 0 | nsGlobalWindowOuter::GetWindowsTable(); |
173 | 0 |
|
174 | 0 | if (!windowsById) { |
175 | 0 | return; |
176 | 0 | } |
177 | 0 | |
178 | 0 | for (auto iter = windowsById->Iter(); !iter.Done(); iter.Next()) { |
179 | 0 | nsGlobalWindowOuter* window = iter.Data(); |
180 | 0 | if (window->GetDocShell() && window->IsRootOuterWindow()) { |
181 | 0 | nsCOMPtr<nsIDocument> docNode = window->GetExtantDoc(); |
182 | 0 |
|
183 | 0 | if (docNode) { |
184 | 0 | GetAccService()->GetDocAccessible(docNode); // ensure creation |
185 | 0 | } |
186 | 0 | } |
187 | 0 | } |
188 | 0 | } |
189 | | |
190 | | Accessible* |
191 | | ApplicationAccessible::GetSiblingAtOffset(int32_t aOffset, |
192 | | nsresult* aError) const |
193 | 0 | { |
194 | 0 | if (aError) |
195 | 0 | *aError = NS_OK; // fail peacefully |
196 | 0 |
|
197 | 0 | return nullptr; |
198 | 0 | } |