Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(776)

Side by Side Diff: chrome/browser/browser_accessibility.cc

Issue 2830005: Rename browser_accessibility to browser_accessibility_win, and same for... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_accessibility.h ('k') | chrome/browser/browser_accessibility_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/browser_accessibility.h"
6
7 #include "base/logging.h"
8 #include "chrome/browser/browser_accessibility_manager.h"
9
10 using webkit_glue::WebAccessibility;
11
12 BrowserAccessibility::BrowserAccessibility()
13 : manager_(NULL),
14 parent_(NULL),
15 child_id_(-1),
16 index_in_parent_(-1),
17 renderer_id_(-1),
18 instance_active_(false) {
19 }
20
21 BrowserAccessibility::~BrowserAccessibility() {
22 InactivateTree();
23 }
24
25 void BrowserAccessibility::Initialize(
26 BrowserAccessibilityManager* manager,
27 BrowserAccessibility* parent,
28 LONG child_id,
29 LONG index_in_parent,
30 const webkit_glue::WebAccessibility& src) {
31 manager_ = manager;
32 parent_ = parent;
33 child_id_ = child_id;
34 index_in_parent_ = index_in_parent;
35
36 renderer_id_ = src.id;
37 name_ = src.name;
38 value_ = src.value;
39 attributes_ = src.attributes;
40 location_ = src.location;
41 InitRoleAndState(src.role, src.state);
42
43 // If this object doesn't have a name but it does have a description,
44 // use the description as its name - because some screen readers only
45 // announce the name.
46 if (name_.empty() && HasAttribute(WebAccessibility::ATTR_DESCRIPTION)) {
47 GetAttribute(WebAccessibility::ATTR_DESCRIPTION, &name_);
48 }
49
50 instance_active_ = true;
51 }
52
53 void BrowserAccessibility::AddChild(BrowserAccessibility* child) {
54 children_.push_back(child);
55 }
56
57 void BrowserAccessibility::InactivateTree() {
58 // Mark this object as inactive, so calls to all COM methods will return
59 // failure.
60 instance_active_ = false;
61
62 // Now we can safely call InactivateTree on our children and remove
63 // references to them, so that as much of the tree as possible will be
64 // destroyed now - however, nodes that still have references to them
65 // might stick around a while until all clients have released them.
66 for (std::vector<BrowserAccessibility*>::iterator iter =
67 children_.begin();
68 iter != children_.end(); ++iter) {
69 (*iter)->InactivateTree();
70 (*iter)->Release();
71 }
72 children_.clear();
73 }
74
75 bool BrowserAccessibility::IsDescendantOf(BrowserAccessibility* ancestor) {
76 if (this == ancestor) {
77 return true;
78 } else if (parent_) {
79 return parent_->IsDescendantOf(ancestor);
80 }
81
82 return false;
83 }
84
85 BrowserAccessibility* BrowserAccessibility::GetPreviousSibling() {
86 if (parent_ && index_in_parent_ > 0)
87 return parent_->children_[index_in_parent_ - 1];
88
89 return NULL;
90 }
91
92 BrowserAccessibility* BrowserAccessibility::GetNextSibling() {
93 if (parent_ &&
94 index_in_parent_ < static_cast<int>(parent_->children_.size() - 1)) {
95 return parent_->children_[index_in_parent_ + 1];
96 }
97
98 return NULL;
99 }
100
101 BrowserAccessibility* BrowserAccessibility::NewReference() {
102 AddRef();
103 return this;
104 }
105
106 //
107 // IAccessible methods.
108 //
109 // Conventions:
110 // * Always test for instance_active_ first and return E_FAIL if it's false.
111 // * Always check for invalid arguments first, even if they're unused.
112 // * Return S_FALSE if the only output is a string argument and it's empty.
113 //
114
115 HRESULT BrowserAccessibility::accDoDefaultAction(VARIANT var_id) {
116 if (!instance_active_)
117 return E_FAIL;
118
119 BrowserAccessibility* target = GetTargetFromChildID(var_id);
120 if (!target)
121 return E_INVALIDARG;
122
123 manager_->DoDefaultAction(*target);
124 return S_OK;
125 }
126
127 STDMETHODIMP BrowserAccessibility::accHitTest(LONG x_left, LONG y_top,
128 VARIANT* child) {
129 if (!instance_active_)
130 return E_FAIL;
131
132 if (!child)
133 return E_INVALIDARG;
134
135 return E_NOTIMPL;
136 }
137
138 STDMETHODIMP BrowserAccessibility::accLocation(LONG* x_left, LONG* y_top,
139 LONG* width, LONG* height,
140 VARIANT var_id) {
141 if (!instance_active_)
142 return E_FAIL;
143
144 if (!x_left || !y_top || !width || !height)
145 return E_INVALIDARG;
146
147 BrowserAccessibility* target = GetTargetFromChildID(var_id);
148 if (!target)
149 return E_INVALIDARG;
150
151 // Find the top left corner of the containing window in screen coords, and
152 // adjust the output position by this amount.
153 HWND parent_hwnd = manager_->GetParentHWND();
154 POINT top_left = {0, 0};
155 ::ClientToScreen(parent_hwnd, &top_left);
156
157 *x_left = target->location_.x + top_left.x;
158 *y_top = target->location_.y + top_left.y;
159 *width = target->location_.width;
160 *height = target->location_.height;
161
162 return S_OK;
163 }
164
165 STDMETHODIMP BrowserAccessibility::accNavigate(
166 LONG nav_dir, VARIANT start, VARIANT* end) {
167 BrowserAccessibility* target = GetTargetFromChildID(start);
168 if (!target)
169 return E_INVALIDARG;
170
171 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) &&
172 start.lVal != CHILDID_SELF) {
173 // MSAA states that navigating to first/last child can only be from self.
174 return E_INVALIDARG;
175 }
176
177 BrowserAccessibility* result = NULL;
178 switch (nav_dir) {
179 case NAVDIR_DOWN:
180 case NAVDIR_UP:
181 case NAVDIR_LEFT:
182 case NAVDIR_RIGHT:
183 // These directions are not implemented, matching Mozilla and IE.
184 return E_NOTIMPL;
185 case NAVDIR_FIRSTCHILD:
186 if (target->children_.size() > 0)
187 result = target->children_[0];
188 break;
189 case NAVDIR_LASTCHILD:
190 if (target->children_.size() > 0)
191 result = target->children_[target->children_.size() - 1];
192 break;
193 case NAVDIR_NEXT:
194 result = target->GetNextSibling();
195 break;
196 case NAVDIR_PREVIOUS:
197 result = target->GetPreviousSibling();
198 break;
199 }
200
201 if (!result) {
202 end->vt = VT_EMPTY;
203 return S_FALSE;
204 }
205
206 end->vt = VT_DISPATCH;
207 end->pdispVal = result->NewReference();
208 return S_OK;
209 }
210
211 STDMETHODIMP BrowserAccessibility::get_accChild(VARIANT var_child,
212 IDispatch** disp_child) {
213 if (!instance_active_)
214 return E_FAIL;
215
216 if (!disp_child)
217 return E_INVALIDARG;
218
219 *disp_child = NULL;
220
221 BrowserAccessibility* target = GetTargetFromChildID(var_child);
222 if (!target)
223 return E_INVALIDARG;
224
225 (*disp_child) = target->NewReference();
226 return S_OK;
227 }
228
229 STDMETHODIMP BrowserAccessibility::get_accChildCount(LONG* child_count) {
230 if (!instance_active_)
231 return E_FAIL;
232
233 if (!child_count)
234 return E_INVALIDARG;
235
236 *child_count = children_.size();
237 return S_OK;
238 }
239
240 STDMETHODIMP BrowserAccessibility::get_accDefaultAction(VARIANT var_id,
241 BSTR* def_action) {
242 if (!instance_active_)
243 return E_FAIL;
244
245 if (!def_action)
246 return E_INVALIDARG;
247
248 BrowserAccessibility* target = GetTargetFromChildID(var_id);
249 if (!target)
250 return E_INVALIDARG;
251
252 string16 action;
253 if (!target->GetAttribute(WebAccessibility::ATTR_SHORTCUT, &action))
254 return S_FALSE;
255
256 if (action.empty())
257 return S_FALSE;
258
259 *def_action = SysAllocString(action.c_str());
260
261 DCHECK(*def_action);
262 return S_OK;
263 }
264
265 STDMETHODIMP BrowserAccessibility::get_accDescription(VARIANT var_id,
266 BSTR* desc) {
267 if (!instance_active_)
268 return E_FAIL;
269
270 if (!desc)
271 return E_INVALIDARG;
272
273 BrowserAccessibility* target = GetTargetFromChildID(var_id);
274 if (!target)
275 return E_INVALIDARG;
276
277 string16 description;
278 if (!target->GetAttribute(WebAccessibility::ATTR_DESCRIPTION, &description))
279 return S_FALSE;
280
281 if (description.empty())
282 return S_FALSE;
283
284 *desc = SysAllocString(description.c_str());
285
286 DCHECK(*desc);
287 return S_OK;
288 }
289
290 STDMETHODIMP BrowserAccessibility::get_accFocus(VARIANT* focus_child) {
291 if (!instance_active_)
292 return E_FAIL;
293
294 if (!focus_child)
295 return E_INVALIDARG;
296
297 BrowserAccessibility* focus = manager_->GetFocus(this);
298 if (focus == this) {
299 focus_child->vt = VT_I4;
300 focus_child->lVal = CHILDID_SELF;
301 } else if (focus == NULL) {
302 focus_child->vt = VT_EMPTY;
303 } else {
304 focus_child->vt = VT_DISPATCH;
305 focus_child->pdispVal = focus->NewReference();
306 }
307
308 return S_OK;
309 }
310
311 STDMETHODIMP BrowserAccessibility::get_accHelp(VARIANT var_id, BSTR* help) {
312 if (!instance_active_)
313 return E_FAIL;
314
315 if (!help)
316 return E_INVALIDARG;
317
318 BrowserAccessibility* target = GetTargetFromChildID(var_id);
319 if (!target)
320 return E_INVALIDARG;
321
322 string16 help_str;
323 if (!target->GetAttribute(WebAccessibility::ATTR_HELP, &help_str))
324 return S_FALSE;
325
326 if (help_str.empty())
327 return S_FALSE;
328
329 *help = SysAllocString(help_str.c_str());
330
331 DCHECK(*help);
332 return S_OK;
333 }
334
335 STDMETHODIMP BrowserAccessibility::get_accKeyboardShortcut(VARIANT var_id,
336 BSTR* acc_key) {
337 if (!instance_active_)
338 return E_FAIL;
339
340 if (!acc_key)
341 return E_INVALIDARG;
342
343 BrowserAccessibility* target = GetTargetFromChildID(var_id);
344 if (!target)
345 return E_INVALIDARG;
346
347 string16 shortcut;
348 if (!target->GetAttribute(WebAccessibility::ATTR_SHORTCUT, &shortcut))
349 return S_FALSE;
350
351 if (shortcut.empty())
352 return S_FALSE;
353
354 *acc_key = SysAllocString(shortcut.c_str());
355
356 DCHECK(*acc_key);
357 return S_OK;
358 }
359
360 STDMETHODIMP BrowserAccessibility::get_accName(VARIANT var_id, BSTR* name) {
361 if (!instance_active_)
362 return E_FAIL;
363
364 if (!name)
365 return E_INVALIDARG;
366
367 BrowserAccessibility* target = GetTargetFromChildID(var_id);
368 if (!target)
369 return E_INVALIDARG;
370
371 if (target->name_.empty())
372 return S_FALSE;
373
374 *name = SysAllocString(target->name_.c_str());
375
376 DCHECK(*name);
377 return S_OK;
378 }
379
380 STDMETHODIMP BrowserAccessibility::get_accParent(IDispatch** disp_parent) {
381 if (!instance_active_)
382 return E_FAIL;
383
384 if (!disp_parent)
385 return E_INVALIDARG;
386
387 IAccessible* parent = parent_;
388 if (parent == NULL) {
389 // This happens if we're the root of the tree;
390 // return the IAccessible for the window.
391 parent = manager_->GetParentWindowIAccessible();
392 }
393
394 parent->AddRef();
395 *disp_parent = parent;
396 return S_OK;
397 }
398
399 STDMETHODIMP BrowserAccessibility::get_accRole(VARIANT var_id, VARIANT* role) {
400 if (!instance_active_)
401 return E_FAIL;
402
403 if (!role)
404 return E_INVALIDARG;
405
406 BrowserAccessibility* target = GetTargetFromChildID(var_id);
407 if (!target)
408 return E_INVALIDARG;
409
410 if (!target->role_name_.empty()) {
411 role->vt = VT_BSTR;
412 role->bstrVal = SysAllocString(target->role_name_.c_str());
413 } else {
414 role->vt = VT_I4;
415 role->lVal = target->role_;
416 }
417 return S_OK;
418 }
419
420 STDMETHODIMP BrowserAccessibility::get_accState(VARIANT var_id,
421 VARIANT* state) {
422 if (!instance_active_)
423 return E_FAIL;
424
425 if (!state)
426 return E_INVALIDARG;
427
428 BrowserAccessibility* target = GetTargetFromChildID(var_id);
429 if (!target)
430 return E_INVALIDARG;
431
432 state->vt = VT_I4;
433 state->lVal = target->state_;
434 if (manager_->GetFocus(NULL) == this)
435 state->lVal |= STATE_SYSTEM_FOCUSED;
436
437 return S_OK;
438 }
439
440 STDMETHODIMP BrowserAccessibility::get_accValue(VARIANT var_id, BSTR* value) {
441 if (!instance_active_)
442 return E_FAIL;
443
444 if (!value)
445 return E_INVALIDARG;
446
447 BrowserAccessibility* target = GetTargetFromChildID(var_id);
448 if (!target)
449 return E_INVALIDARG;
450
451 *value = SysAllocString(target->value_.c_str());
452
453 DCHECK(*value);
454 return S_OK;
455 }
456
457 STDMETHODIMP BrowserAccessibility::get_accHelpTopic(BSTR* help_file,
458 VARIANT var_id,
459 LONG* topic_id) {
460 return E_NOTIMPL;
461 }
462
463 STDMETHODIMP BrowserAccessibility::get_accSelection(VARIANT* selected) {
464 if (!instance_active_)
465 return E_FAIL;
466
467 return E_NOTIMPL;
468 }
469
470 STDMETHODIMP BrowserAccessibility::accSelect(LONG flags_sel, VARIANT var_id) {
471 if (!instance_active_)
472 return E_FAIL;
473
474 if (flags_sel & SELFLAG_TAKEFOCUS) {
475 manager_->SetFocus(*this);
476 return S_OK;
477 }
478
479 return S_FALSE;
480 }
481
482 //
483 // IAccessible2 methods.
484 //
485
486 STDMETHODIMP BrowserAccessibility::role(LONG* role) {
487 if (!instance_active_)
488 return E_FAIL;
489
490 if (!role)
491 return E_INVALIDARG;
492
493 *role = ia2_role_;
494
495 return S_OK;
496 }
497
498 STDMETHODIMP BrowserAccessibility::get_attributes(BSTR* attributes) {
499 if (!instance_active_)
500 return E_FAIL;
501
502 if (!attributes)
503 return E_INVALIDARG;
504
505 return S_FALSE;
506 }
507
508 STDMETHODIMP BrowserAccessibility::get_states(AccessibleStates* states) {
509 if (!instance_active_)
510 return E_FAIL;
511
512 if (!states)
513 return E_INVALIDARG;
514
515 *states = ia2_state_;
516
517 return S_OK;
518 }
519
520 STDMETHODIMP BrowserAccessibility::get_uniqueID(LONG* unique_id) {
521 if (!instance_active_)
522 return E_FAIL;
523
524 if (!unique_id)
525 return E_INVALIDARG;
526
527 *unique_id = child_id_;
528 return S_OK;
529 }
530
531 STDMETHODIMP BrowserAccessibility::get_windowHandle(HWND* window_handle) {
532 if (!instance_active_)
533 return E_FAIL;
534
535 if (!window_handle)
536 return E_INVALIDARG;
537
538 *window_handle = manager_->GetParentHWND();
539 return S_OK;
540 }
541
542 STDMETHODIMP BrowserAccessibility::get_indexInParent(LONG* index_in_parent) {
543 if (!instance_active_)
544 return E_FAIL;
545
546 if (!index_in_parent)
547 return E_INVALIDARG;
548
549 *index_in_parent = index_in_parent_;
550 return S_OK;
551 }
552
553 //
554 // IAccessibleImage methods.
555 //
556
557 STDMETHODIMP BrowserAccessibility::get_description(BSTR* desc) {
558 if (!instance_active_)
559 return E_FAIL;
560
561 if (!desc)
562 return E_INVALIDARG;
563
564 string16 description;
565 if (!GetAttribute(WebAccessibility::ATTR_DESCRIPTION, &description))
566 return S_FALSE;
567
568 if (description.empty())
569 return S_FALSE;
570
571 *desc = SysAllocString(description.c_str());
572
573 DCHECK(*desc);
574 return S_OK;
575 }
576
577 STDMETHODIMP BrowserAccessibility::get_imagePosition(
578 enum IA2CoordinateType coordinate_type, long* x, long* y) {
579 if (!instance_active_)
580 return E_FAIL;
581
582 if (!x || !y)
583 return E_INVALIDARG;
584
585 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) {
586 HWND parent_hwnd = manager_->GetParentHWND();
587 POINT top_left = {0, 0};
588 ::ClientToScreen(parent_hwnd, &top_left);
589 *x = location_.x + top_left.x;
590 *y = location_.y + top_left.y;
591 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) {
592 *x = location_.x;
593 *y = location_.y;
594 if (parent_) {
595 *x -= parent_->location_.x;
596 *y -= parent_->location_.y;
597 }
598 } else {
599 return E_INVALIDARG;
600 }
601
602 return S_OK;
603 }
604
605 STDMETHODIMP BrowserAccessibility::get_imageSize(long* height, long* width) {
606 if (!instance_active_)
607 return E_FAIL;
608
609 if (!height || !width)
610 return E_INVALIDARG;
611
612 *height = location_.height;
613 *width = location_.width;
614 return S_OK;
615 }
616
617 //
618 // IAccessibleText methods.
619 //
620
621 STDMETHODIMP BrowserAccessibility::get_nCharacters(long* n_characters) {
622 if (!instance_active_)
623 return E_FAIL;
624
625 if (!n_characters)
626 return E_INVALIDARG;
627
628 *n_characters = name_.length();
629 return S_OK;
630 }
631
632 STDMETHODIMP BrowserAccessibility::get_text(
633 long start_offset, long end_offset, BSTR* text) {
634 if (!instance_active_)
635 return E_FAIL;
636
637 if (!text)
638 return E_INVALIDARG;
639
640 long len = name_.length();
641 if (start_offset < 0)
642 start_offset = 0;
643 if (end_offset > len)
644 end_offset = len;
645
646 *text = SysAllocString(
647 name_.substr(start_offset, end_offset - start_offset).c_str());
648 return S_OK;
649 }
650
651 STDMETHODIMP BrowserAccessibility::get_caretOffset(long* offset) {
652 *offset = 0;
653 return S_OK;
654 }
655
656 //
657 // IServiceProvider methods.
658 //
659
660 STDMETHODIMP BrowserAccessibility::QueryService(
661 REFGUID guidService, REFIID riid, void** object) {
662 if (!instance_active_)
663 return E_FAIL;
664
665 if (guidService == IID_IAccessible || guidService == IID_IAccessible2)
666 return QueryInterface(riid, object);
667
668 *object = NULL;
669 return E_FAIL;
670 }
671
672 //
673 // CComObjectRootEx methods.
674 //
675
676 HRESULT WINAPI BrowserAccessibility::InternalQueryInterface(
677 void* this_ptr,
678 const _ATL_INTMAP_ENTRY* entries,
679 REFIID iid,
680 void** object) {
681 if (iid == IID_IAccessibleText) {
682 if (role_ != ROLE_SYSTEM_LINK) {
683 *object = NULL;
684 return E_NOINTERFACE;
685 }
686 } else if (iid == IID_IAccessibleImage) {
687 if (role_ != ROLE_SYSTEM_GRAPHIC) {
688 *object = NULL;
689 return E_NOINTERFACE;
690 }
691 }
692
693 return CComObjectRootBase::InternalQueryInterface(
694 this_ptr, entries, iid, object);
695 }
696
697 //
698 // Private methods.
699 //
700
701 BrowserAccessibility* BrowserAccessibility::GetTargetFromChildID(
702 const VARIANT& var_id) {
703 if (var_id.vt != VT_I4)
704 return NULL;
705
706 LONG child_id = var_id.lVal;
707 if (child_id == CHILDID_SELF)
708 return this;
709
710 if (child_id >= 1 && child_id <= static_cast<LONG>(children_.size()))
711 return children_[child_id - 1];
712
713 return manager_->GetFromChildID(child_id);
714 }
715
716 bool BrowserAccessibility::HasAttribute(WebAccessibility::Attribute attribute) {
717 return (attributes_.find(attribute) != attributes_.end());
718 }
719
720 bool BrowserAccessibility::GetAttribute(
721 WebAccessibility::Attribute attribute, string16* value) {
722 std::map<int32, string16>::iterator iter = attributes_.find(attribute);
723 if (iter != attributes_.end()) {
724 *value = iter->second;
725 return true;
726 }
727
728 return false;
729 }
730
731 void BrowserAccessibility::InitRoleAndState(LONG web_role,
732 LONG web_state) {
733 state_ = 0;
734 ia2_state_ = IA2_STATE_OPAQUE;
735
736 if ((web_state >> WebAccessibility::STATE_CHECKED) & 1)
737 state_ |= STATE_SYSTEM_CHECKED;
738 if ((web_state >> WebAccessibility::STATE_FOCUSABLE) & 1)
739 state_ |= STATE_SYSTEM_FOCUSABLE;
740 if ((web_state >> WebAccessibility::STATE_HOTTRACKED) & 1)
741 state_ |= STATE_SYSTEM_HOTTRACKED;
742 if ((web_state >> WebAccessibility::STATE_INDETERMINATE) & 1)
743 state_ |= STATE_SYSTEM_INDETERMINATE;
744 if ((web_state >> WebAccessibility::STATE_LINKED) & 1)
745 state_ |= STATE_SYSTEM_LINKED;
746 if ((web_state >> WebAccessibility::STATE_MULTISELECTABLE) & 1)
747 state_ |= STATE_SYSTEM_MULTISELECTABLE;
748 if ((web_state >> WebAccessibility::STATE_OFFSCREEN) & 1)
749 state_ |= STATE_SYSTEM_OFFSCREEN;
750 if ((web_state >> WebAccessibility::STATE_PRESSED) & 1)
751 state_ |= STATE_SYSTEM_PRESSED;
752 if ((web_state >> WebAccessibility::STATE_PROTECTED) & 1)
753 state_ |= STATE_SYSTEM_PROTECTED;
754 if ((web_state >> WebAccessibility::STATE_READONLY) & 1)
755 state_ |= STATE_SYSTEM_READONLY;
756 if ((web_state >> WebAccessibility::STATE_TRAVERSED) & 1)
757 state_ |= STATE_SYSTEM_TRAVERSED;
758 if ((web_state >> WebAccessibility::STATE_UNAVAILABLE) & 1)
759 state_ |= STATE_SYSTEM_UNAVAILABLE;
760
761 role_ = 0;
762 ia2_role_ = 0;
763 switch (web_role) {
764 case WebAccessibility::ROLE_ALERT:
765 case WebAccessibility::ROLE_ALERT_DIALOG:
766 role_ = ROLE_SYSTEM_ALERT;
767 break;
768 case WebAccessibility::ROLE_APPLICATION:
769 role_ = ROLE_SYSTEM_APPLICATION;
770 break;
771 case WebAccessibility::ROLE_ARTICLE:
772 role_ = ROLE_SYSTEM_GROUPING;
773 ia2_role_ = IA2_ROLE_SECTION;
774 break;
775 case WebAccessibility::ROLE_BUTTON:
776 role_ = ROLE_SYSTEM_PUSHBUTTON;
777 break;
778 case WebAccessibility::ROLE_CELL:
779 role_ = ROLE_SYSTEM_CELL;
780 break;
781 case WebAccessibility::ROLE_CHECKBOX:
782 role_ = ROLE_SYSTEM_CHECKBUTTON;
783 break;
784 case WebAccessibility::ROLE_COLOR_WELL:
785 role_ = ROLE_SYSTEM_CLIENT;
786 ia2_role_ = IA2_ROLE_COLOR_CHOOSER;
787 break;
788 case WebAccessibility::ROLE_COLUMN:
789 role_ = ROLE_SYSTEM_COLUMN;
790 break;
791 case WebAccessibility::ROLE_COLUMN_HEADER:
792 role_ = ROLE_SYSTEM_COLUMNHEADER;
793 break;
794 case WebAccessibility::ROLE_COMBO_BOX:
795 role_ = ROLE_SYSTEM_COMBOBOX;
796 break;
797 case WebAccessibility::ROLE_DEFINITION_LIST_DEFINITION:
798 role_name_ = L"dd";
799 ia2_role_ = IA2_ROLE_PARAGRAPH;
800 break;
801 case WebAccessibility::ROLE_DEFINITION_LIST_TERM:
802 role_ = ROLE_SYSTEM_LISTITEM;
803 break;
804 case WebAccessibility::ROLE_DIALOG:
805 role_ = ROLE_SYSTEM_DIALOG;
806 break;
807 case WebAccessibility::ROLE_DOCUMENT:
808 case WebAccessibility::ROLE_WEB_AREA:
809 role_ = ROLE_SYSTEM_DOCUMENT;
810 state_ |= STATE_SYSTEM_READONLY;
811 state_ |= STATE_SYSTEM_FOCUSABLE;
812 break;
813 case WebAccessibility::ROLE_EDITABLE_TEXT:
814 role_ = ROLE_SYSTEM_TEXT;
815 ia2_state_ |= IA2_STATE_SINGLE_LINE;
816 ia2_state_ |= IA2_STATE_EDITABLE;
817 break;
818 case WebAccessibility::ROLE_GRID:
819 role_ = ROLE_SYSTEM_TABLE;
820 break;
821 case WebAccessibility::ROLE_GROUP:
822 role_name_ = L"div";
823 ia2_role_ = IA2_ROLE_SECTION;
824 break;
825 case WebAccessibility::ROLE_HEADING:
826 // TODO(dmazzoni): support all heading levels
827 role_name_ = L"h1";
828 ia2_role_ = IA2_ROLE_HEADING;
829 break;
830 case WebAccessibility::ROLE_IMAGE:
831 role_ = ROLE_SYSTEM_GRAPHIC;
832 break;
833 case WebAccessibility::ROLE_IMAGE_MAP:
834 role_name_ = L"map";
835 ia2_role_ = IA2_ROLE_IMAGE_MAP;
836 break;
837 case WebAccessibility::ROLE_IMAGE_MAP_LINK:
838 role_ = ROLE_SYSTEM_LINK;
839 state_ |= STATE_SYSTEM_LINKED;
840 break;
841 case WebAccessibility::ROLE_LANDMARK_APPLICATION:
842 case WebAccessibility::ROLE_LANDMARK_BANNER:
843 case WebAccessibility::ROLE_LANDMARK_COMPLEMENTARY:
844 case WebAccessibility::ROLE_LANDMARK_CONTENTINFO:
845 case WebAccessibility::ROLE_LANDMARK_MAIN:
846 case WebAccessibility::ROLE_LANDMARK_NAVIGATION:
847 case WebAccessibility::ROLE_LANDMARK_SEARCH:
848 role_ = ROLE_SYSTEM_GROUPING;
849 ia2_role_ = IA2_ROLE_SECTION;
850 break;
851 case WebAccessibility::ROLE_LINK:
852 case WebAccessibility::ROLE_WEBCORE_LINK:
853 role_ = ROLE_SYSTEM_LINK;
854 state_ |= STATE_SYSTEM_LINKED;
855 break;
856 case WebAccessibility::ROLE_LIST:
857 role_ = ROLE_SYSTEM_LIST;
858 break;
859 case WebAccessibility::ROLE_LISTBOX:
860 role_ = ROLE_SYSTEM_LIST;
861 break;
862 case WebAccessibility::ROLE_LISTBOX_OPTION:
863 case WebAccessibility::ROLE_LIST_ITEM:
864 case WebAccessibility::ROLE_LIST_MARKER:
865 role_ = ROLE_SYSTEM_LISTITEM;
866 break;
867 case WebAccessibility::ROLE_MENU:
868 case WebAccessibility::ROLE_MENU_BUTTON:
869 role_ = ROLE_SYSTEM_MENUPOPUP;
870 break;
871 case WebAccessibility::ROLE_MENU_BAR:
872 role_ = ROLE_SYSTEM_MENUBAR;
873 break;
874 case WebAccessibility::ROLE_MENU_ITEM:
875 case WebAccessibility::ROLE_MENU_LIST_OPTION:
876 role_ = ROLE_SYSTEM_MENUITEM;
877 break;
878 case WebAccessibility::ROLE_MENU_LIST_POPUP:
879 role_ = ROLE_SYSTEM_MENUPOPUP;
880 break;
881 case WebAccessibility::ROLE_NOTE:
882 role_ = ROLE_SYSTEM_GROUPING;
883 ia2_role_ = IA2_ROLE_NOTE;
884 break;
885 case WebAccessibility::ROLE_OUTLINE:
886 role_ = ROLE_SYSTEM_OUTLINE;
887 break;
888 case WebAccessibility::ROLE_POPUP_BUTTON:
889 role_ = ROLE_SYSTEM_COMBOBOX;
890 break;
891 case WebAccessibility::ROLE_PROGRESS_INDICATOR:
892 role_ = ROLE_SYSTEM_PROGRESSBAR;
893 break;
894 case WebAccessibility::ROLE_RADIO_BUTTON:
895 role_ = ROLE_SYSTEM_RADIOBUTTON;
896 break;
897 case WebAccessibility::ROLE_RADIO_GROUP:
898 role_ = ROLE_SYSTEM_GROUPING;
899 ia2_role_ = IA2_ROLE_SECTION;
900 break;
901 case WebAccessibility::ROLE_REGION:
902 role_ = ROLE_SYSTEM_GROUPING;
903 ia2_role_ = IA2_ROLE_SECTION;
904 break;
905 case WebAccessibility::ROLE_ROW:
906 role_ = ROLE_SYSTEM_ROW;
907 break;
908 case WebAccessibility::ROLE_ROW_HEADER:
909 role_ = ROLE_SYSTEM_ROWHEADER;
910 break;
911 case WebAccessibility::ROLE_RULER:
912 role_ = ROLE_SYSTEM_CLIENT;
913 ia2_role_ = IA2_ROLE_RULER;
914 break;
915 case WebAccessibility::ROLE_SCROLLAREA:
916 role_ = ROLE_SYSTEM_CLIENT;
917 ia2_role_ = IA2_ROLE_SCROLL_PANE;
918 break;
919 case WebAccessibility::ROLE_SCROLLBAR:
920 role_ = ROLE_SYSTEM_SCROLLBAR;
921 break;
922 case WebAccessibility::ROLE_SLIDER:
923 role_ = ROLE_SYSTEM_SLIDER;
924 break;
925 case WebAccessibility::ROLE_SPLIT_GROUP:
926 role_ = ROLE_SYSTEM_CLIENT;
927 ia2_role_ = IA2_ROLE_SPLIT_PANE;
928 break;
929 case WebAccessibility::ROLE_ANNOTATION:
930 case WebAccessibility::ROLE_STATIC_TEXT:
931 role_ = ROLE_SYSTEM_TEXT;
932 break;
933 case WebAccessibility::ROLE_STATUS:
934 role_ = ROLE_SYSTEM_STATUSBAR;
935 break;
936 case WebAccessibility::ROLE_TAB:
937 role_ = ROLE_SYSTEM_PAGETAB;
938 break;
939 case WebAccessibility::ROLE_TABLE:
940 role_ = ROLE_SYSTEM_TABLE;
941 break;
942 case WebAccessibility::ROLE_TABLE_HEADER_CONTAINER:
943 role_ = ROLE_SYSTEM_GROUPING;
944 ia2_role_ = IA2_ROLE_SECTION;
945 break;
946 case WebAccessibility::ROLE_TAB_GROUP:
947 case WebAccessibility::ROLE_TAB_LIST:
948 case WebAccessibility::ROLE_TAB_PANEL:
949 role_ = ROLE_SYSTEM_PAGETABLIST;
950 break;
951 case WebAccessibility::ROLE_TEXTAREA:
952 role_ = ROLE_SYSTEM_TEXT;
953 ia2_state_ |= IA2_STATE_MULTI_LINE;
954 ia2_state_ |= IA2_STATE_EDITABLE;
955 break;
956 case WebAccessibility::ROLE_TEXT_FIELD:
957 role_ = ROLE_SYSTEM_TEXT;
958 ia2_state_ |= IA2_STATE_SINGLE_LINE;
959 ia2_state_ |= IA2_STATE_EDITABLE;
960 break;
961 case WebAccessibility::ROLE_TOOLBAR:
962 role_ = ROLE_SYSTEM_TOOLBAR;
963 break;
964 case WebAccessibility::ROLE_TOOLTIP:
965 role_ = ROLE_SYSTEM_TOOLTIP;
966 break;
967 case WebAccessibility::ROLE_TREE:
968 role_ = ROLE_SYSTEM_OUTLINE;
969 break;
970 case WebAccessibility::ROLE_TREE_GRID:
971 role_ = ROLE_SYSTEM_OUTLINE;
972 break;
973 case WebAccessibility::ROLE_TREE_ITEM:
974 role_ = ROLE_SYSTEM_OUTLINEITEM;
975 break;
976 case WebAccessibility::ROLE_WINDOW:
977 role_ = ROLE_SYSTEM_WINDOW;
978 break;
979
980 // TODO(dmazzoni): figure out the proper MSAA role for all of these.
981 case WebAccessibility::ROLE_BROWSER:
982 case WebAccessibility::ROLE_BUSY_INDICATOR:
983 case WebAccessibility::ROLE_DIRECTORY:
984 case WebAccessibility::ROLE_DISCLOSURE_TRIANGLE:
985 case WebAccessibility::ROLE_DRAWER:
986 case WebAccessibility::ROLE_GROW_AREA:
987 case WebAccessibility::ROLE_HELP_TAG:
988 case WebAccessibility::ROLE_IGNORED:
989 case WebAccessibility::ROLE_INCREMENTOR:
990 case WebAccessibility::ROLE_LOG:
991 case WebAccessibility::ROLE_MARQUEE:
992 case WebAccessibility::ROLE_MATH:
993 case WebAccessibility::ROLE_MATTE:
994 case WebAccessibility::ROLE_RULER_MARKER:
995 case WebAccessibility::ROLE_SHEET:
996 case WebAccessibility::ROLE_SLIDER_THUMB:
997 case WebAccessibility::ROLE_SPLITTER:
998 case WebAccessibility::ROLE_SYSTEM_WIDE:
999 case WebAccessibility::ROLE_TIMER:
1000 case WebAccessibility::ROLE_VALUE_INDICATOR:
1001 default:
1002 role_ = ROLE_SYSTEM_CLIENT;
1003 break;
1004 }
1005
1006 // The role should always be set.
1007 DCHECK(!role_name_.empty() || role_);
1008
1009 // If we didn't explicitly set the IAccessible2 role, make it the same
1010 // as the MSAA role.
1011 if (!ia2_role_)
1012 ia2_role_ = role_;
1013 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_accessibility.h ('k') | chrome/browser/browser_accessibility_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698