OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/accessibility/browser_accessibility_win.h" | 5 #include "chrome/browser/accessibility/browser_accessibility_win.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/accessibility/browser_accessibility_manager_win.h" | 10 #include "chrome/browser/accessibility/browser_accessibility_manager_win.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 return E_FAIL; | 59 return E_FAIL; |
60 | 60 |
61 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 61 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
62 if (!target) | 62 if (!target) |
63 return E_INVALIDARG; | 63 return E_INVALIDARG; |
64 | 64 |
65 manager_->DoDefaultAction(*target); | 65 manager_->DoDefaultAction(*target); |
66 return S_OK; | 66 return S_OK; |
67 } | 67 } |
68 | 68 |
69 STDMETHODIMP BrowserAccessibilityWin::accHitTest( | 69 STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, |
70 LONG x_left, LONG y_top, VARIANT* child) { | 70 LONG y_top, |
| 71 VARIANT* child) { |
71 if (!instance_active_) | 72 if (!instance_active_) |
72 return E_FAIL; | 73 return E_FAIL; |
73 | 74 |
74 if (!child) | 75 if (!child) |
75 return E_INVALIDARG; | 76 return E_INVALIDARG; |
76 | 77 |
77 gfx::Point point(x_left, y_top); | 78 gfx::Point point(x_left, y_top); |
78 if (!GetBoundsRect().Contains(point)) { | 79 if (!GetBoundsRect().Contains(point)) { |
79 // Return S_FALSE and VT_EMPTY when the outside the object's boundaries. | 80 // Return S_FALSE and VT_EMPTY when the outside the object's boundaries. |
80 child->vt = VT_EMPTY; | 81 child->vt = VT_EMPTY; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 130 |
130 BrowserAccessibility* result = NULL; | 131 BrowserAccessibility* result = NULL; |
131 switch (nav_dir) { | 132 switch (nav_dir) { |
132 case NAVDIR_DOWN: | 133 case NAVDIR_DOWN: |
133 case NAVDIR_UP: | 134 case NAVDIR_UP: |
134 case NAVDIR_LEFT: | 135 case NAVDIR_LEFT: |
135 case NAVDIR_RIGHT: | 136 case NAVDIR_RIGHT: |
136 // These directions are not implemented, matching Mozilla and IE. | 137 // These directions are not implemented, matching Mozilla and IE. |
137 return E_NOTIMPL; | 138 return E_NOTIMPL; |
138 case NAVDIR_FIRSTCHILD: | 139 case NAVDIR_FIRSTCHILD: |
139 if (target->children_.size() > 0) | 140 if (!target->children_.empty()) |
140 result = target->children_[0]; | 141 result = target->children_.front(); |
141 break; | 142 break; |
142 case NAVDIR_LASTCHILD: | 143 case NAVDIR_LASTCHILD: |
143 if (target->children_.size() > 0) | 144 if (!target->children_.empty()) |
144 result = target->children_[target->children_.size() - 1]; | 145 result = target->children_.back(); |
145 break; | 146 break; |
146 case NAVDIR_NEXT: | 147 case NAVDIR_NEXT: |
147 result = target->GetNextSibling(); | 148 result = target->GetNextSibling(); |
148 break; | 149 break; |
149 case NAVDIR_PREVIOUS: | 150 case NAVDIR_PREVIOUS: |
150 result = target->GetPreviousSibling(); | 151 result = target->GetPreviousSibling(); |
151 break; | 152 break; |
152 } | 153 } |
153 | 154 |
154 if (!result) { | 155 if (!result) { |
155 end->vt = VT_EMPTY; | 156 end->vt = VT_EMPTY; |
156 return S_FALSE; | 157 return S_FALSE; |
157 } | 158 } |
158 | 159 |
159 end->vt = VT_DISPATCH; | 160 end->vt = VT_DISPATCH; |
160 end->pdispVal = result->toBrowserAccessibilityWin()->NewReference(); | 161 end->pdispVal = result->toBrowserAccessibilityWin()->NewReference(); |
161 return S_OK; | 162 return S_OK; |
162 } | 163 } |
163 | 164 |
164 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, | 165 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, |
165 IDispatch** disp_child) { | 166 IDispatch** disp_child) { |
166 if (!instance_active_) | 167 if (!instance_active_) |
167 return E_FAIL; | 168 return E_FAIL; |
168 | 169 |
169 if (!disp_child) | 170 if (!disp_child) |
170 return E_INVALIDARG; | 171 return E_INVALIDARG; |
171 | 172 |
172 *disp_child = NULL; | 173 *disp_child = NULL; |
173 | 174 |
174 BrowserAccessibilityWin* target = GetTargetFromChildID(var_child); | 175 BrowserAccessibilityWin* target = GetTargetFromChildID(var_child); |
175 if (!target) | 176 if (!target) |
176 return E_INVALIDARG; | 177 return E_INVALIDARG; |
177 | 178 |
178 (*disp_child) = target->NewReference(); | 179 (*disp_child) = target->NewReference(); |
179 return S_OK; | 180 return S_OK; |
180 } | 181 } |
181 | 182 |
182 STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { | 183 STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { |
183 if (!instance_active_) | 184 if (!instance_active_) |
184 return E_FAIL; | 185 return E_FAIL; |
185 | 186 |
186 if (!child_count) | 187 if (!child_count) |
187 return E_INVALIDARG; | 188 return E_INVALIDARG; |
188 | 189 |
189 *child_count = children_.size(); | 190 *child_count = children_.size(); |
190 return S_OK; | 191 return S_OK; |
191 } | 192 } |
192 | 193 |
193 STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, | 194 STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, |
194 BSTR* def_action) { | 195 BSTR* def_action) { |
195 if (!instance_active_) | 196 if (!instance_active_) |
196 return E_FAIL; | 197 return E_FAIL; |
197 | 198 |
198 if (!def_action) | 199 if (!def_action) |
199 return E_INVALIDARG; | 200 return E_INVALIDARG; |
200 | 201 |
201 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 202 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
202 if (!target) | 203 if (!target) |
203 return E_INVALIDARG; | 204 return E_INVALIDARG; |
204 | 205 |
205 return target->GetAttributeAsBstr( | 206 return target->GetAttributeAsBstr( |
206 WebAccessibility::ATTR_SHORTCUT, def_action); | 207 WebAccessibility::ATTR_SHORTCUT, def_action); |
207 } | 208 } |
208 | 209 |
209 STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, | 210 STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, |
210 BSTR* desc) { | 211 BSTR* desc) { |
211 if (!instance_active_) | 212 if (!instance_active_) |
212 return E_FAIL; | 213 return E_FAIL; |
213 | 214 |
214 if (!desc) | 215 if (!desc) |
215 return E_INVALIDARG; | 216 return E_INVALIDARG; |
216 | 217 |
217 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 218 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
218 if (!target) | 219 if (!target) |
219 return E_INVALIDARG; | 220 return E_INVALIDARG; |
220 | 221 |
(...skipping 30 matching lines...) Expand all Loading... |
251 return E_INVALIDARG; | 252 return E_INVALIDARG; |
252 | 253 |
253 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 254 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
254 if (!target) | 255 if (!target) |
255 return E_INVALIDARG; | 256 return E_INVALIDARG; |
256 | 257 |
257 return target->GetAttributeAsBstr(WebAccessibility::ATTR_HELP, help); | 258 return target->GetAttributeAsBstr(WebAccessibility::ATTR_HELP, help); |
258 } | 259 } |
259 | 260 |
260 STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, | 261 STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, |
261 BSTR* acc_key) { | 262 BSTR* acc_key) { |
262 if (!instance_active_) | 263 if (!instance_active_) |
263 return E_FAIL; | 264 return E_FAIL; |
264 | 265 |
265 if (!acc_key) | 266 if (!acc_key) |
266 return E_INVALIDARG; | 267 return E_INVALIDARG; |
267 | 268 |
268 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 269 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
269 if (!target) | 270 if (!target) |
270 return E_INVALIDARG; | 271 return E_INVALIDARG; |
271 | 272 |
(...skipping 25 matching lines...) Expand all Loading... |
297 return E_FAIL; | 298 return E_FAIL; |
298 | 299 |
299 if (!disp_parent) | 300 if (!disp_parent) |
300 return E_INVALIDARG; | 301 return E_INVALIDARG; |
301 | 302 |
302 IAccessible* parent = parent_->toBrowserAccessibilityWin(); | 303 IAccessible* parent = parent_->toBrowserAccessibilityWin(); |
303 if (parent == NULL) { | 304 if (parent == NULL) { |
304 // This happens if we're the root of the tree; | 305 // This happens if we're the root of the tree; |
305 // return the IAccessible for the window. | 306 // return the IAccessible for the window. |
306 parent = manager_->toBrowserAccessibilityManagerWin()-> | 307 parent = manager_->toBrowserAccessibilityManagerWin()-> |
307 GetParentWindowIAccessible(); | 308 GetParentWindowIAccessible(); |
308 } | 309 } |
309 | 310 |
310 parent->AddRef(); | 311 parent->AddRef(); |
311 *disp_parent = parent; | 312 *disp_parent = parent; |
312 return S_OK; | 313 return S_OK; |
313 } | 314 } |
314 | 315 |
315 STDMETHODIMP BrowserAccessibilityWin::get_accRole( | 316 STDMETHODIMP BrowserAccessibilityWin::get_accRole( |
316 VARIANT var_id, VARIANT* role) { | 317 VARIANT var_id, VARIANT* role) { |
317 if (!instance_active_) | 318 if (!instance_active_) |
(...skipping 10 matching lines...) Expand all Loading... |
328 role->vt = VT_BSTR; | 329 role->vt = VT_BSTR; |
329 role->bstrVal = SysAllocString(target->role_name_.c_str()); | 330 role->bstrVal = SysAllocString(target->role_name_.c_str()); |
330 } else { | 331 } else { |
331 role->vt = VT_I4; | 332 role->vt = VT_I4; |
332 role->lVal = target->ia_role_; | 333 role->lVal = target->ia_role_; |
333 } | 334 } |
334 return S_OK; | 335 return S_OK; |
335 } | 336 } |
336 | 337 |
337 STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, | 338 STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, |
338 VARIANT* state) { | 339 VARIANT* state) { |
339 if (!instance_active_) | 340 if (!instance_active_) |
340 return E_FAIL; | 341 return E_FAIL; |
341 | 342 |
342 if (!state) | 343 if (!state) |
343 return E_INVALIDARG; | 344 return E_INVALIDARG; |
344 | 345 |
345 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 346 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
346 if (!target) | 347 if (!target) |
347 return E_INVALIDARG; | 348 return E_INVALIDARG; |
348 | 349 |
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 } | 1598 } |
1598 | 1599 |
1599 // The role should always be set. | 1600 // The role should always be set. |
1600 DCHECK(!role_name_.empty() || ia_role_); | 1601 DCHECK(!role_name_.empty() || ia_role_); |
1601 | 1602 |
1602 // If we didn't explicitly set the IAccessible2 role, make it the same | 1603 // If we didn't explicitly set the IAccessible2 role, make it the same |
1603 // as the MSAA role. | 1604 // as the MSAA role. |
1604 if (!ia2_role_) | 1605 if (!ia2_role_) |
1605 ia2_role_ = ia_role_; | 1606 ia2_role_ = ia_role_; |
1606 } | 1607 } |
OLD | NEW |