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

Side by Side Diff: content/browser/accessibility/browser_accessibility_win.cc

Issue 880523002: Revert of Send Windows accessibility events based on tree updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@implicit_1_tests
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility_win.h" 5 #include "content/browser/accessibility/browser_accessibility_win.h"
6 6
7 #include <UIAutomationClient.h> 7 #include <UIAutomationClient.h>
8 #include <UIAutomationCoreApi.h> 8 #include <UIAutomationCoreApi.h>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 for (long i = 0; i < count; ++i) { 168 for (long i = 0; i < count; ++i) {
169 HRESULT result = get_target(i, &targets[i]); 169 HRESULT result = get_target(i, &targets[i]);
170 if (result != S_OK) 170 if (result != S_OK)
171 return result; 171 return result;
172 } 172 }
173 173
174 return S_OK; 174 return S_OK;
175 } 175 }
176 176
177 // 177 //
178 // BrowserAccessibilityWin::WinAttributes
179 //
180
181 BrowserAccessibilityWin::WinAttributes::WinAttributes()
182 : ia_role(0),
183 ia_state(0),
184 ia2_role(0),
185 ia2_state(0) {
186 }
187
188 //
189 // BrowserAccessibilityWin 178 // BrowserAccessibilityWin
190 // 179 //
191 180
192 // static 181 // static
193 BrowserAccessibility* BrowserAccessibility::Create() { 182 BrowserAccessibility* BrowserAccessibility::Create() {
194 ui::win::CreateATLModuleIfNeeded(); 183 ui::win::CreateATLModuleIfNeeded();
195 CComObject<BrowserAccessibilityWin>* instance; 184 CComObject<BrowserAccessibilityWin>* instance;
196 HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance); 185 HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance);
197 DCHECK(SUCCEEDED(hr)); 186 DCHECK(SUCCEEDED(hr));
198 return instance->NewReference(); 187 return instance->NewReference();
199 } 188 }
200 189
201 BrowserAccessibilityWin* BrowserAccessibility::ToBrowserAccessibilityWin() { 190 BrowserAccessibilityWin* BrowserAccessibility::ToBrowserAccessibilityWin() {
202 return static_cast<BrowserAccessibilityWin*>(this); 191 return static_cast<BrowserAccessibilityWin*>(this);
203 } 192 }
204 193
205 BrowserAccessibilityWin::BrowserAccessibilityWin() 194 BrowserAccessibilityWin::BrowserAccessibilityWin()
206 : win_attributes_(new WinAttributes()), 195 : ia_role_(0),
196 ia_state_(0),
197 ia2_role_(0),
198 ia2_state_(0),
199 first_time_(true),
200 old_ia_state_(0),
207 previous_scroll_x_(0), 201 previous_scroll_x_(0),
208 previous_scroll_y_(0) { 202 previous_scroll_y_(0) {
209 // Start unique IDs at -1 and decrement each time, because get_accChild 203 // Start unique IDs at -1 and decrement each time, because get_accChild
210 // uses positive IDs to enumerate children, so we use negative IDs to 204 // uses positive IDs to enumerate children, so we use negative IDs to
211 // clearly distinguish between indices and unique IDs. 205 // clearly distinguish between indices and unique IDs.
212 unique_id_win_ = next_unique_id_win_; 206 unique_id_win_ = next_unique_id_win_;
213 if (next_unique_id_win_ == 207 if (next_unique_id_win_ ==
214 base::win::kLastBrowserAccessibilityManagerAccessibilityId) { 208 base::win::kLastBrowserAccessibilityManagerAccessibilityId) {
215 next_unique_id_win_ = 209 next_unique_id_win_ =
216 base::win::kFirstBrowserAccessibilityManagerAccessibilityId; 210 base::win::kFirstBrowserAccessibilityManagerAccessibilityId;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 if (!instance_active()) 390 if (!instance_active())
397 return E_FAIL; 391 return E_FAIL;
398 392
399 if (!desc) 393 if (!desc)
400 return E_INVALIDARG; 394 return E_INVALIDARG;
401 395
402 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 396 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
403 if (!target) 397 if (!target)
404 return E_INVALIDARG; 398 return E_INVALIDARG;
405 399
406 base::string16 description_str = target->description(); 400 return target->GetStringAttributeAsBstr(
407 if (description_str.empty()) 401 ui::AX_ATTR_DESCRIPTION, desc);
408 return S_FALSE;
409
410 *desc = SysAllocString(description_str.c_str());
411
412 DCHECK(*desc);
413 return S_OK;
414 } 402 }
415 403
416 STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) { 404 STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) {
417 if (!instance_active()) 405 if (!instance_active())
418 return E_FAIL; 406 return E_FAIL;
419 407
420 if (!focus_child) 408 if (!focus_child)
421 return E_INVALIDARG; 409 return E_INVALIDARG;
422 410
423 BrowserAccessibilityWin* focus = static_cast<BrowserAccessibilityWin*>( 411 BrowserAccessibilityWin* focus = static_cast<BrowserAccessibilityWin*>(
(...skipping 15 matching lines...) Expand all
439 if (!instance_active()) 427 if (!instance_active())
440 return E_FAIL; 428 return E_FAIL;
441 429
442 if (!help) 430 if (!help)
443 return E_INVALIDARG; 431 return E_INVALIDARG;
444 432
445 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 433 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
446 if (!target) 434 if (!target)
447 return E_INVALIDARG; 435 return E_INVALIDARG;
448 436
449 base::string16 help_str = target->help(); 437 return target->GetStringAttributeAsBstr(
450 if (help_str.empty()) 438 ui::AX_ATTR_HELP, help);
451 return S_FALSE;
452
453 *help = SysAllocString(help_str.c_str());
454
455 DCHECK(*help);
456 return S_OK;
457 } 439 }
458 440
459 STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, 441 STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id,
460 BSTR* acc_key) { 442 BSTR* acc_key) {
461 if (!instance_active()) 443 if (!instance_active())
462 return E_FAIL; 444 return E_FAIL;
463 445
464 if (!acc_key) 446 if (!acc_key)
465 return E_INVALIDARG; 447 return E_INVALIDARG;
466 448
467 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 449 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
468 if (!target) 450 if (!target)
469 return E_INVALIDARG; 451 return E_INVALIDARG;
470 452
471 return target->GetStringAttributeAsBstr( 453 return target->GetStringAttributeAsBstr(
472 ui::AX_ATTR_SHORTCUT, acc_key); 454 ui::AX_ATTR_SHORTCUT, acc_key);
473 } 455 }
474 456
475 STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { 457 STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) {
476 if (!instance_active()) 458 if (!instance_active())
477 return E_FAIL; 459 return E_FAIL;
478 460
479 if (!name) 461 if (!name)
480 return E_INVALIDARG; 462 return E_INVALIDARG;
481 463
482 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 464 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
483 if (!target) 465 if (!target)
484 return E_INVALIDARG; 466 return E_INVALIDARG;
485 467
486 base::string16 name_str = target->name(); 468 std::string name_str = target->name();
487 469
488 // If the name is empty, see if it's labeled by another element. 470 // If the name is empty, see if it's labeled by another element.
489 if (name_str.empty()) { 471 if (name_str.empty()) {
490 int title_elem_id; 472 int title_elem_id;
491 if (target->GetIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT, 473 if (target->GetIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT,
492 &title_elem_id)) { 474 &title_elem_id)) {
493 BrowserAccessibilityWin* title_elem = 475 BrowserAccessibility* title_elem =
494 manager()->GetFromID(title_elem_id)->ToBrowserAccessibilityWin(); 476 manager()->GetFromID(title_elem_id);
495 if (title_elem) 477 if (title_elem)
496 name_str = title_elem->GetNameRecursive(); 478 name_str = title_elem->GetTextRecursive();
497 } 479 }
498 } 480 }
499 481
500 if (name_str.empty()) 482 if (name_str.empty())
501 return S_FALSE; 483 return S_FALSE;
502 484
503 *name = SysAllocString(name_str.c_str()); 485 *name = SysAllocString(base::UTF8ToUTF16(name_str).c_str());
504 486
505 DCHECK(*name); 487 DCHECK(*name);
506 return S_OK; 488 return S_OK;
507 } 489 }
508 490
509 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { 491 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) {
510 if (!instance_active()) 492 if (!instance_active())
511 return E_FAIL; 493 return E_FAIL;
512 494
513 if (!disp_parent) 495 if (!disp_parent)
(...skipping 27 matching lines...) Expand all
541 if (!instance_active()) 523 if (!instance_active())
542 return E_FAIL; 524 return E_FAIL;
543 525
544 if (!role) 526 if (!role)
545 return E_INVALIDARG; 527 return E_INVALIDARG;
546 528
547 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 529 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
548 if (!target) 530 if (!target)
549 return E_INVALIDARG; 531 return E_INVALIDARG;
550 532
551 if (!target->role_name().empty()) { 533 if (!target->role_name_.empty()) {
552 role->vt = VT_BSTR; 534 role->vt = VT_BSTR;
553 role->bstrVal = SysAllocString(target->role_name().c_str()); 535 role->bstrVal = SysAllocString(target->role_name_.c_str());
554 } else { 536 } else {
555 role->vt = VT_I4; 537 role->vt = VT_I4;
556 role->lVal = target->ia_role(); 538 role->lVal = target->ia_role_;
557 } 539 }
558 return S_OK; 540 return S_OK;
559 } 541 }
560 542
561 STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, 543 STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id,
562 VARIANT* state) { 544 VARIANT* state) {
563 if (!instance_active()) 545 if (!instance_active())
564 return E_FAIL; 546 return E_FAIL;
565 547
566 if (!state) 548 if (!state)
567 return E_INVALIDARG; 549 return E_INVALIDARG;
568 550
569 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 551 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
570 if (!target) 552 if (!target)
571 return E_INVALIDARG; 553 return E_INVALIDARG;
572 554
573 state->vt = VT_I4; 555 state->vt = VT_I4;
574 state->lVal = target->ia_state(); 556 state->lVal = target->ia_state_;
575 if (manager()->GetFocus(NULL) == this) 557 if (manager()->GetFocus(NULL) == this)
576 state->lVal |= STATE_SYSTEM_FOCUSED; 558 state->lVal |= STATE_SYSTEM_FOCUSED;
577 559
578 return S_OK; 560 return S_OK;
579 } 561 }
580 562
581 STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, 563 STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id,
582 BSTR* value) { 564 BSTR* value) {
583 if (!instance_active()) 565 if (!instance_active())
584 return E_FAIL; 566 return E_FAIL;
(...skipping 24 matching lines...) Expand all
609 ui::AX_ATTR_COLOR_VALUE_BLUE); 591 ui::AX_ATTR_COLOR_VALUE_BLUE);
610 base::string16 value_text; 592 base::string16 value_text;
611 value_text = base::IntToString16((r * 100) / 255) + L"% red " + 593 value_text = base::IntToString16((r * 100) / 255) + L"% red " +
612 base::IntToString16((g * 100) / 255) + L"% green " + 594 base::IntToString16((g * 100) / 255) + L"% green " +
613 base::IntToString16((b * 100) / 255) + L"% blue"; 595 base::IntToString16((b * 100) / 255) + L"% blue";
614 *value = SysAllocString(value_text.c_str()); 596 *value = SysAllocString(value_text.c_str());
615 DCHECK(*value); 597 DCHECK(*value);
616 return S_OK; 598 return S_OK;
617 } 599 }
618 600
619 *value = SysAllocString(target->value().c_str()); 601 *value = SysAllocString(base::UTF8ToUTF16(target->value()).c_str());
620 DCHECK(*value); 602 DCHECK(*value);
621 return S_OK; 603 return S_OK;
622 } 604 }
623 605
624 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, 606 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file,
625 VARIANT var_id, 607 VARIANT var_id,
626 LONG* topic_id) { 608 LONG* topic_id) {
627 return E_NOTIMPL; 609 return E_NOTIMPL;
628 } 610 }
629 611
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 // IAccessible2 methods. 674 // IAccessible2 methods.
693 // 675 //
694 676
695 STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) { 677 STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) {
696 if (!instance_active()) 678 if (!instance_active())
697 return E_FAIL; 679 return E_FAIL;
698 680
699 if (!role) 681 if (!role)
700 return E_INVALIDARG; 682 return E_INVALIDARG;
701 683
702 *role = ia2_role(); 684 *role = ia2_role_;
703 685
704 return S_OK; 686 return S_OK;
705 } 687 }
706 688
707 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { 689 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) {
708 if (!instance_active()) 690 if (!instance_active())
709 return E_FAIL; 691 return E_FAIL;
710 692
711 if (!attributes) 693 if (!attributes)
712 return E_INVALIDARG; 694 return E_INVALIDARG;
(...skipping 14 matching lines...) Expand all
727 return S_OK; 709 return S_OK;
728 } 710 }
729 711
730 STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) { 712 STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) {
731 if (!instance_active()) 713 if (!instance_active())
732 return E_FAIL; 714 return E_FAIL;
733 715
734 if (!states) 716 if (!states)
735 return E_INVALIDARG; 717 return E_INVALIDARG;
736 718
737 *states = ia2_state(); 719 *states = ia2_state_;
738 720
739 return S_OK; 721 return S_OK;
740 } 722 }
741 723
742 STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) { 724 STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) {
743 if (!instance_active()) 725 if (!instance_active())
744 return E_FAIL; 726 return E_FAIL;
745 727
746 if (!unique_id) 728 if (!unique_id)
747 return E_INVALIDARG; 729 return E_INVALIDARG;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 // IAccessibleImage methods. 973 // IAccessibleImage methods.
992 // 974 //
993 975
994 STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { 976 STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) {
995 if (!instance_active()) 977 if (!instance_active())
996 return E_FAIL; 978 return E_FAIL;
997 979
998 if (!desc) 980 if (!desc)
999 return E_INVALIDARG; 981 return E_INVALIDARG;
1000 982
1001 if (description().empty()) 983 return GetStringAttributeAsBstr(
1002 return S_FALSE; 984 ui::AX_ATTR_DESCRIPTION, desc);
1003
1004 *desc = SysAllocString(description().c_str());
1005
1006 DCHECK(*desc);
1007 return S_OK;
1008 } 985 }
1009 986
1010 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( 987 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition(
1011 enum IA2CoordinateType coordinate_type, 988 enum IA2CoordinateType coordinate_type,
1012 LONG* x, 989 LONG* x,
1013 LONG* y) { 990 LONG* y) {
1014 if (!instance_active()) 991 if (!instance_active())
1015 return E_FAIL; 992 return E_FAIL;
1016 993
1017 if (!x || !y) 994 if (!x || !y)
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( 1150 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>(
1174 manager()->GetFromID(cell_id)); 1151 manager()->GetFromID(cell_id));
1175 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { 1152 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) {
1176 base::string16 cell_name = cell->GetString16Attribute( 1153 base::string16 cell_name = cell->GetString16Attribute(
1177 ui::AX_ATTR_NAME); 1154 ui::AX_ATTR_NAME);
1178 if (cell_name.size() > 0) { 1155 if (cell_name.size() > 0) {
1179 *description = SysAllocString(cell_name.c_str()); 1156 *description = SysAllocString(cell_name.c_str());
1180 return S_OK; 1157 return S_OK;
1181 } 1158 }
1182 1159
1183 if (cell->description().size() > 0) { 1160 return cell->GetStringAttributeAsBstr(
1184 *description = SysAllocString(cell->description().c_str()); 1161 ui::AX_ATTR_DESCRIPTION, description);
1185 return S_OK;
1186 }
1187 } 1162 }
1188 } 1163 }
1189 1164
1190 return S_FALSE; 1165 return S_FALSE;
1191 } 1166 }
1192 1167
1193 STDMETHODIMP BrowserAccessibilityWin::get_columnExtentAt( 1168 STDMETHODIMP BrowserAccessibilityWin::get_columnExtentAt(
1194 long row, 1169 long row,
1195 long column, 1170 long column,
1196 long* n_columns_spanned) { 1171 long* n_columns_spanned) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 BrowserAccessibilityWin* cell = 1337 BrowserAccessibilityWin* cell =
1363 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); 1338 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin();
1364 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { 1339 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) {
1365 base::string16 cell_name = cell->GetString16Attribute( 1340 base::string16 cell_name = cell->GetString16Attribute(
1366 ui::AX_ATTR_NAME); 1341 ui::AX_ATTR_NAME);
1367 if (cell_name.size() > 0) { 1342 if (cell_name.size() > 0) {
1368 *description = SysAllocString(cell_name.c_str()); 1343 *description = SysAllocString(cell_name.c_str());
1369 return S_OK; 1344 return S_OK;
1370 } 1345 }
1371 1346
1372 if (cell->description().size() > 0) { 1347 return cell->GetStringAttributeAsBstr(
1373 *description = SysAllocString(cell->description().c_str()); 1348 ui::AX_ATTR_DESCRIPTION, description);
1374 return S_OK;
1375 }
1376 } 1349 }
1377 } 1350 }
1378 1351
1379 return S_FALSE; 1352 return S_FALSE;
1380 } 1353 }
1381 1354
1382 STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(long row, 1355 STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(long row,
1383 long column, 1356 long column,
1384 long* n_rows_spanned) { 1357 long* n_rows_spanned) {
1385 if (!instance_active()) 1358 if (!instance_active())
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 return get_text(*start_offset, *end_offset, text); 2140 return get_text(*start_offset, *end_offset, text);
2168 } 2141 }
2169 2142
2170 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { 2143 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) {
2171 if (!instance_active()) 2144 if (!instance_active())
2172 return E_FAIL; 2145 return E_FAIL;
2173 2146
2174 if (!new_text) 2147 if (!new_text)
2175 return E_INVALIDARG; 2148 return E_INVALIDARG;
2176 2149
2177 int start, old_len, new_len; 2150 base::string16 text = TextForIAccessibleText();
2178 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len);
2179 if (new_len == 0)
2180 return E_FAIL;
2181 2151
2182 base::string16 substr = hypertext_.substr(start, new_len); 2152 new_text->text = SysAllocString(text.c_str());
2183 new_text->text = SysAllocString(substr.c_str()); 2153 new_text->start = 0;
2184 new_text->start = static_cast<long>(start); 2154 new_text->end = static_cast<long>(text.size());
2185 new_text->end = static_cast<long>(start + new_len);
2186 return S_OK; 2155 return S_OK;
2187 } 2156 }
2188 2157
2189 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { 2158 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) {
2190 if (!instance_active()) 2159 if (!instance_active())
2191 return E_FAIL; 2160 return E_FAIL;
2192 2161
2193 if (!old_text) 2162 if (!old_text)
2194 return E_INVALIDARG; 2163 return E_INVALIDARG;
2195 2164
2196 int start, old_len, new_len; 2165 old_text->text = SysAllocString(old_text_.c_str());
2197 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); 2166 old_text->start = 0;
2198 if (old_len == 0) 2167 old_text->end = static_cast<long>(old_text_.size());
2199 return E_FAIL;
2200
2201 base::string16 substr = old_hypertext_.substr(start, old_len);
2202 old_text->text = SysAllocString(substr.c_str());
2203 old_text->start = static_cast<long>(start);
2204 old_text->end = static_cast<long>(start + old_len);
2205 return S_OK; 2168 return S_OK;
2206 } 2169 }
2207 2170
2208 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( 2171 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint(
2209 LONG x, 2172 LONG x,
2210 LONG y, 2173 LONG y,
2211 enum IA2CoordinateType coord_type, 2174 enum IA2CoordinateType coord_type,
2212 LONG* offset) { 2175 LONG* offset) {
2213 if (!instance_active()) 2176 if (!instance_active())
2214 return E_FAIL; 2177 return E_FAIL;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 long char_index, 2291 long char_index,
2329 long* hyperlink_index) { 2292 long* hyperlink_index) {
2330 if (!instance_active()) 2293 if (!instance_active())
2331 return E_FAIL; 2294 return E_FAIL;
2332 2295
2333 if (!hyperlink_index) 2296 if (!hyperlink_index)
2334 return E_INVALIDARG; 2297 return E_INVALIDARG;
2335 2298
2336 *hyperlink_index = -1; 2299 *hyperlink_index = -1;
2337 2300
2338 if (char_index < 0 || 2301 if (char_index < 0 || char_index >= static_cast<long>(hypertext_.size()))
2339 char_index >= static_cast<long>(hypertext_.size())) {
2340 return E_INVALIDARG; 2302 return E_INVALIDARG;
2341 }
2342 2303
2343 std::map<int32, int32>::iterator it = 2304 std::map<int32, int32>::iterator it =
2344 hyperlink_offset_to_index_.find(char_index); 2305 hyperlink_offset_to_index_.find(char_index);
2345 if (it == hyperlink_offset_to_index_.end()) 2306 if (it == hyperlink_offset_to_index_.end())
2346 return E_FAIL; 2307 return E_FAIL;
2347 2308
2348 *hyperlink_index = it->second; 2309 *hyperlink_index = it->second;
2349 return S_OK; 2310 return S_OK;
2350 } 2311 }
2351 2312
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2480 return E_INVALIDARG; 2441 return E_INVALIDARG;
2481 } 2442 }
2482 2443
2483 base::string16 tag; 2444 base::string16 tag;
2484 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) 2445 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag))
2485 *node_name = SysAllocString(tag.c_str()); 2446 *node_name = SysAllocString(tag.c_str());
2486 else 2447 else
2487 *node_name = NULL; 2448 *node_name = NULL;
2488 2449
2489 *name_space_id = 0; 2450 *name_space_id = 0;
2490 *node_value = SysAllocString(value().c_str()); 2451 *node_value = SysAllocString(base::UTF8ToUTF16(value()).c_str());
2491 *num_children = PlatformChildCount(); 2452 *num_children = PlatformChildCount();
2492 *unique_id = unique_id_win_; 2453 *unique_id = unique_id_win_;
2493 2454
2494 if (ia_role() == ROLE_SYSTEM_DOCUMENT) { 2455 if (ia_role_ == ROLE_SYSTEM_DOCUMENT) {
2495 *node_type = NODETYPE_DOCUMENT; 2456 *node_type = NODETYPE_DOCUMENT;
2496 } else if (ia_role() == ROLE_SYSTEM_TEXT && 2457 } else if (ia_role_ == ROLE_SYSTEM_TEXT &&
2497 ((ia2_state() & IA2_STATE_EDITABLE) == 0)) { 2458 ((ia2_state_ & IA2_STATE_EDITABLE) == 0)) {
2498 *node_type = NODETYPE_TEXT; 2459 *node_type = NODETYPE_TEXT;
2499 } else { 2460 } else {
2500 *node_type = NODETYPE_ELEMENT; 2461 *node_type = NODETYPE_ELEMENT;
2501 } 2462 }
2502 2463
2503 return S_OK; 2464 return S_OK;
2504 } 2465 }
2505 2466
2506 STDMETHODIMP BrowserAccessibilityWin::get_attributes( 2467 STDMETHODIMP BrowserAccessibilityWin::get_attributes(
2507 unsigned short max_attribs, 2468 unsigned short max_attribs,
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 // 2859 //
2899 2860
2900 // static 2861 // static
2901 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( 2862 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface(
2902 void* this_ptr, 2863 void* this_ptr,
2903 const _ATL_INTMAP_ENTRY* entries, 2864 const _ATL_INTMAP_ENTRY* entries,
2904 REFIID iid, 2865 REFIID iid,
2905 void** object) { 2866 void** object) {
2906 BrowserAccessibilityWin* accessibility = 2867 BrowserAccessibilityWin* accessibility =
2907 reinterpret_cast<BrowserAccessibilityWin*>(this_ptr); 2868 reinterpret_cast<BrowserAccessibilityWin*>(this_ptr);
2908 int32 ia_role = accessibility->ia_role(); 2869 int32 ia_role = accessibility->ia_role_;
2909 if (iid == IID_IAccessibleImage) { 2870 if (iid == IID_IAccessibleImage) {
2910 if (ia_role != ROLE_SYSTEM_GRAPHIC) { 2871 if (ia_role != ROLE_SYSTEM_GRAPHIC) {
2911 *object = NULL; 2872 *object = NULL;
2912 return E_NOINTERFACE; 2873 return E_NOINTERFACE;
2913 } 2874 }
2914 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { 2875 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) {
2915 if (ia_role != ROLE_SYSTEM_TABLE) { 2876 if (ia_role != ROLE_SYSTEM_TABLE) {
2916 *object = NULL; 2877 *object = NULL;
2917 return E_NOINTERFACE; 2878 return E_NOINTERFACE;
2918 } 2879 }
(...skipping 17 matching lines...) Expand all
2936 } 2897 }
2937 2898
2938 return CComObjectRootBase::InternalQueryInterface( 2899 return CComObjectRootBase::InternalQueryInterface(
2939 this_ptr, entries, iid, object); 2900 this_ptr, entries, iid, object);
2940 } 2901 }
2941 2902
2942 // 2903 //
2943 // Private methods. 2904 // Private methods.
2944 // 2905 //
2945 2906
2946 // Called every time this node's data changes, while the tree update is 2907 // Called every time this node's data changes.
2947 // still in progress.
2948 void BrowserAccessibilityWin::OnDataChanged() { 2908 void BrowserAccessibilityWin::OnDataChanged() {
2949 BrowserAccessibility::OnDataChanged(); 2909 BrowserAccessibility::OnDataChanged();
2950 }
2951
2952 // Called every time this node's data changes, after an atomic tree update.
2953 void BrowserAccessibilityWin::OnUpdateFinished() {
2954 BrowserAccessibility::OnUpdateFinished();
2955
2956 if (PlatformIsChildOfLeaf())
2957 return;
2958
2959 bool is_new_object = ia_role() == 0 && role_name().empty();
2960
2961 old_win_attributes_.swap(win_attributes_);
2962 win_attributes_.reset(new WinAttributes());
2963 2910
2964 InitRoleAndState(); 2911 InitRoleAndState();
2965 2912
2966 win_attributes_->ia2_attributes.clear();
2967
2968 // Expose autocomplete attribute for combobox and textbox. 2913 // Expose autocomplete attribute for combobox and textbox.
2969 StringAttributeToIA2(ui::AX_ATTR_AUTO_COMPLETE, "autocomplete"); 2914 StringAttributeToIA2(ui::AX_ATTR_AUTO_COMPLETE, "autocomplete");
2970 2915
2971 // Expose the "display" and "tag" attributes. 2916 // Expose the "display" and "tag" attributes.
2972 StringAttributeToIA2(ui::AX_ATTR_DISPLAY, "display"); 2917 StringAttributeToIA2(ui::AX_ATTR_DISPLAY, "display");
2973 StringAttributeToIA2(ui::AX_ATTR_TEXT_INPUT_TYPE, "text-input-type"); 2918 StringAttributeToIA2(ui::AX_ATTR_TEXT_INPUT_TYPE, "text-input-type");
2974 StringAttributeToIA2(ui::AX_ATTR_HTML_TAG, "tag"); 2919 StringAttributeToIA2(ui::AX_ATTR_HTML_TAG, "tag");
2975 StringAttributeToIA2(ui::AX_ATTR_ROLE, "xml-roles"); 2920 StringAttributeToIA2(ui::AX_ATTR_ROLE, "xml-roles");
2976 2921
2977 // Expose "level" attribute for headings, trees, etc. 2922 // Expose "level" attribute for headings, trees, etc.
2978 IntAttributeToIA2(ui::AX_ATTR_HIERARCHICAL_LEVEL, "level"); 2923 IntAttributeToIA2(ui::AX_ATTR_HIERARCHICAL_LEVEL, "level");
2979 2924
2980 // Expose the set size and position in set for listbox options. 2925 // Expose the set size and position in set for listbox options.
2981 if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && 2926 if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION &&
2982 GetParent() && 2927 GetParent() &&
2983 GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { 2928 GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) {
2984 win_attributes_->ia2_attributes.push_back( 2929 ia2_attributes_.push_back(
2985 L"setsize:" + base::IntToString16(GetParent()->PlatformChildCount())); 2930 L"setsize:" + base::IntToString16(GetParent()->PlatformChildCount()));
2986 win_attributes_->ia2_attributes.push_back( 2931 ia2_attributes_.push_back(
2987 L"setsize:" + base::IntToString16(GetIndexInParent() + 1)); 2932 L"setsize:" + base::IntToString16(GetIndexInParent() + 1));
2988 } 2933 }
2989 2934
2990 if (ia_role() == ROLE_SYSTEM_CHECKBUTTON || 2935 if (ia_role_ == ROLE_SYSTEM_CHECKBUTTON ||
2991 ia_role() == ROLE_SYSTEM_RADIOBUTTON || 2936 ia_role_ == ROLE_SYSTEM_RADIOBUTTON ||
2992 ia2_role() == IA2_ROLE_CHECK_MENU_ITEM || 2937 ia2_role_ == IA2_ROLE_CHECK_MENU_ITEM ||
2993 ia2_role() == IA2_ROLE_RADIO_MENU_ITEM || 2938 ia2_role_ == IA2_ROLE_RADIO_MENU_ITEM ||
2994 ia2_role() == IA2_ROLE_TOGGLE_BUTTON) { 2939 ia2_role_ == IA2_ROLE_TOGGLE_BUTTON) {
2995 win_attributes_->ia2_attributes.push_back(L"checkable:true"); 2940 ia2_attributes_.push_back(L"checkable:true");
2996 } 2941 }
2997 2942
2998 // Expose live region attributes. 2943 // Expose live region attributes.
2999 StringAttributeToIA2(ui::AX_ATTR_LIVE_STATUS, "live"); 2944 StringAttributeToIA2(ui::AX_ATTR_LIVE_STATUS, "live");
3000 StringAttributeToIA2(ui::AX_ATTR_LIVE_RELEVANT, "relevant"); 2945 StringAttributeToIA2(ui::AX_ATTR_LIVE_RELEVANT, "relevant");
3001 BoolAttributeToIA2(ui::AX_ATTR_LIVE_ATOMIC, "atomic"); 2946 BoolAttributeToIA2(ui::AX_ATTR_LIVE_ATOMIC, "atomic");
3002 BoolAttributeToIA2(ui::AX_ATTR_LIVE_BUSY, "busy"); 2947 BoolAttributeToIA2(ui::AX_ATTR_LIVE_BUSY, "busy");
3003 2948
3004 // Expose container live region attributes. 2949 // Expose container live region attributes.
3005 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_STATUS, 2950 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_STATUS,
3006 "container-live"); 2951 "container-live");
3007 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_RELEVANT, 2952 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_RELEVANT,
3008 "container-relevant"); 2953 "container-relevant");
3009 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, 2954 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC,
3010 "container-atomic"); 2955 "container-atomic");
3011 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, 2956 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY,
3012 "container-busy"); 2957 "container-busy");
3013 2958
2959 // Expose slider value.
2960 if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR ||
2961 ia_role_ == ROLE_SYSTEM_SCROLLBAR ||
2962 ia_role_ == ROLE_SYSTEM_SLIDER) {
2963 ia2_attributes_.push_back(L"valuetext:" + GetValueText());
2964 }
2965
3014 // Expose table cell index. 2966 // Expose table cell index.
3015 if (IsCellOrTableHeaderRole()) { 2967 if (IsCellOrTableHeaderRole()) {
3016 BrowserAccessibility* table = GetParent(); 2968 BrowserAccessibility* table = GetParent();
3017 while (table && table->GetRole() != ui::AX_ROLE_TABLE) 2969 while (table && table->GetRole() != ui::AX_ROLE_TABLE)
3018 table = table->GetParent(); 2970 table = table->GetParent();
3019 if (table) { 2971 if (table) {
3020 const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute( 2972 const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute(
3021 ui::AX_ATTR_UNIQUE_CELL_IDS); 2973 ui::AX_ATTR_UNIQUE_CELL_IDS);
3022 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { 2974 for (size_t i = 0; i < unique_cell_ids.size(); ++i) {
3023 if (unique_cell_ids[i] == GetId()) { 2975 if (unique_cell_ids[i] == GetId()) {
3024 win_attributes_->ia2_attributes.push_back( 2976 ia2_attributes_.push_back(
3025 base::string16(L"table-cell-index:") + base::IntToString16(i)); 2977 base::string16(L"table-cell-index:") + base::IntToString16(i));
3026 } 2978 }
3027 } 2979 }
3028 } 2980 }
3029 } 2981 }
3030 2982
3031 // Expose invalid state for form controls and elements with aria-invalid. 2983 // Expose invalid state for form controls and elements with aria-invalid.
3032 int invalid_state; 2984 int invalid_state;
3033 if (GetIntAttribute(ui::AX_ATTR_INVALID_STATE, &invalid_state)) { 2985 if (GetIntAttribute(ui::AX_ATTR_INVALID_STATE, &invalid_state)) {
3034 // TODO(nektar): Handle the possibility of having multiple aria-invalid 2986 // TODO(nektar): Handle the possibility of having multiple aria-invalid
3035 // attributes defined, e.g., "invalid:spelling,grammar". 2987 // attributes defined, e.g., "invalid:spelling,grammar".
3036 switch (invalid_state) { 2988 switch (invalid_state) {
3037 case ui::AX_INVALID_STATE_NONE: 2989 case ui::AX_INVALID_STATE_NONE:
3038 break; 2990 break;
3039 case ui::AX_INVALID_STATE_FALSE: 2991 case ui::AX_INVALID_STATE_FALSE:
3040 win_attributes_->ia2_attributes.push_back(L"invalid:false"); 2992 ia2_attributes_.push_back(L"invalid:false");
3041 break; 2993 break;
3042 case ui::AX_INVALID_STATE_TRUE: 2994 case ui::AX_INVALID_STATE_TRUE:
3043 win_attributes_->ia2_attributes.push_back(L"invalid:true"); 2995 ia2_attributes_.push_back(L"invalid:true");
3044 break; 2996 break;
3045 case ui::AX_INVALID_STATE_SPELLING: 2997 case ui::AX_INVALID_STATE_SPELLING:
3046 win_attributes_->ia2_attributes.push_back(L"invalid:spelling"); 2998 ia2_attributes_.push_back(L"invalid:spelling");
3047 break; 2999 break;
3048 case ui::AX_INVALID_STATE_GRAMMAR: 3000 case ui::AX_INVALID_STATE_GRAMMAR:
3049 win_attributes_->ia2_attributes.push_back(L"invalid:grammar"); 3001 ia2_attributes_.push_back(L"invalid:grammar");
3050 break; 3002 break;
3051 case ui::AX_INVALID_STATE_OTHER: 3003 case ui::AX_INVALID_STATE_OTHER:
3052 { 3004 {
3053 base::string16 aria_invalid_value; 3005 base::string16 aria_invalid_value;
3054 if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, 3006 if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE,
3055 &aria_invalid_value)) { 3007 &aria_invalid_value)) {
3056 win_attributes_->ia2_attributes.push_back( 3008 ia2_attributes_.push_back(L"invalid:" + aria_invalid_value);
3057 L"invalid:" + aria_invalid_value);
3058 } else { 3009 } else {
3059 // Set the attribute to L"true", since we cannot be more specific. 3010 // Set the attribute to L"true", since we cannot be more specific.
3060 win_attributes_->ia2_attributes.push_back(L"invalid:true"); 3011 ia2_attributes_.push_back(L"invalid:true");
3061 } 3012 }
3062 } 3013 }
3063 break; 3014 break;
3064 default: 3015 default:
3065 NOTREACHED(); 3016 NOTREACHED();
3066 } 3017 }
3067 } 3018 }
3068 3019
3069 // The calculation of the accessible name of an element has been 3020 // The calculation of the accessible name of an element has been
3070 // standardized in the HTML to Platform Accessibility APIs Implementation 3021 // standardized in the HTML to Platform Accessibility APIs Implementation
3071 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the 3022 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the
3072 // appropriate accessible name on Windows, we need to apply some logic 3023 // appropriate accessible name on Windows, we need to apply some logic
3073 // to the fields we get from WebKit. 3024 // to the fields we get from WebKit.
3074 // 3025 //
3075 // TODO(dmazzoni): move most of this logic into WebKit. 3026 // TODO(dmazzoni): move most of this logic into WebKit.
3076 // 3027 //
3077 // WebKit gives us: 3028 // WebKit gives us:
3078 // 3029 //
3079 // name: the default name, e.g. inner text 3030 // name: the default name, e.g. inner text
3080 // title ui element: a reference to a <label> element on the same 3031 // title ui element: a reference to a <label> element on the same
3081 // page that labels this node. 3032 // page that labels this node.
3082 // description: accessible labels that override the default name: 3033 // description: accessible labels that override the default name:
3083 // aria-label or aria-labelledby or aria-describedby 3034 // aria-label or aria-labelledby or aria-describedby
3084 // help: the value of the "title" attribute 3035 // help: the value of the "title" attribute
3085 // 3036 //
3086 // On Windows, the logic we apply lets some fields take precedence and 3037 // On Windows, the logic we apply lets some fields take precedence and
3087 // always returns the primary name in "name" and the secondary name, 3038 // always returns the primary name in "name" and the secondary name,
3088 // if any, in "description". 3039 // if any, in "description".
3089 3040
3090 int title_elem_id = GetIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT); 3041 int title_elem_id = GetIntAttribute(
3091 base::string16 name = GetString16Attribute(ui::AX_ATTR_NAME); 3042 ui::AX_ATTR_TITLE_UI_ELEMENT);
3092 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); 3043 std::string help = GetStringAttribute(ui::AX_ATTR_HELP);
3093 base::string16 help = GetString16Attribute(ui::AX_ATTR_HELP); 3044 std::string description = GetStringAttribute(
3094 base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE); 3045 ui::AX_ATTR_DESCRIPTION);
3095 3046
3096 // WebKit annoyingly puts the title in the description if there's no other 3047 // WebKit annoyingly puts the title in the description if there's no other
3097 // description, which just confuses the rest of the logic. Put it back. 3048 // description, which just confuses the rest of the logic. Put it back.
3098 // Now "help" is always the value of the "title" attribute, if present. 3049 // Now "help" is always the value of the "title" attribute, if present.
3099 base::string16 title_attr; 3050 std::string title_attr;
3100 if (GetHtmlAttribute("title", &title_attr) && 3051 if (GetHtmlAttribute("title", &title_attr) &&
3101 description == title_attr && 3052 description == title_attr &&
3102 help.empty()) { 3053 help.empty()) {
3103 help = description; 3054 help = description;
3104 description.clear(); 3055 description.clear();
3105 } 3056 }
3106 3057
3107 // Now implement the main logic: the descripion should become the name if 3058 // Now implement the main logic: the descripion should become the name if
3108 // it's nonempty, and the help should become the description if 3059 // it's nonempty, and the help should become the description if
3109 // there's no description - or the name if there's no name or description. 3060 // there's no description - or the name if there's no name or description.
3110 if (!description.empty()) { 3061 if (!description.empty()) {
3111 name = description; 3062 set_name(description);
3112 description.clear(); 3063 description.clear();
3113 } 3064 }
3114 if (!help.empty() && description.empty()) { 3065 if (!help.empty() && description.empty()) {
3115 description = help; 3066 description = help;
3116 help.clear(); 3067 help.clear();
3117 } 3068 }
3118 if (!description.empty() && name.empty() && !title_elem_id) { 3069 if (!description.empty() && name().empty() && !title_elem_id) {
3119 name = description; 3070 set_name(description);
3120 description.clear(); 3071 description.clear();
3121 } 3072 }
3122 3073
3123 // If it's a text field, also consider the placeholder. 3074 // If it's a text field, also consider the placeholder.
3124 base::string16 placeholder; 3075 std::string placeholder;
3125 if (GetRole() == ui::AX_ROLE_TEXT_FIELD && 3076 if (GetRole() == ui::AX_ROLE_TEXT_FIELD &&
3126 HasState(ui::AX_STATE_FOCUSABLE) && 3077 HasState(ui::AX_STATE_FOCUSABLE) &&
3127 GetHtmlAttribute("placeholder", &placeholder)) { 3078 GetHtmlAttribute("placeholder", &placeholder)) {
3128 if (name.empty() && !title_elem_id) { 3079 if (name().empty() && !title_elem_id) {
3129 name = placeholder; 3080 set_name(placeholder);
3130 } else if (description.empty()) { 3081 } else if (description.empty()) {
3131 description = placeholder; 3082 description = placeholder;
3132 } 3083 }
3133 } 3084 }
3134 3085
3086 SetStringAttribute(ui::AX_ATTR_DESCRIPTION, description);
3087 SetStringAttribute(ui::AX_ATTR_HELP, help);
3088
3135 // On Windows, the value of a document should be its url. 3089 // On Windows, the value of a document should be its url.
3136 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || 3090 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA ||
3137 GetRole() == ui::AX_ROLE_WEB_AREA) { 3091 GetRole() == ui::AX_ROLE_WEB_AREA) {
3138 value = GetString16Attribute(ui::AX_ATTR_DOC_URL); 3092 set_value(GetStringAttribute(ui::AX_ATTR_DOC_URL));
3139 } 3093 }
3140 3094
3141 // For certain roles (listbox option, static text, and list marker) 3095 // For certain roles (listbox option, static text, and list marker)
3142 // WebKit stores the main accessible text in the "value" - swap it so 3096 // WebKit stores the main accessible text in the "value" - swap it so
3143 // that it's the "name". 3097 // that it's the "name".
3144 if (name.empty() && 3098 if (name().empty() &&
3145 (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || 3099 (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION ||
3146 GetRole() == ui::AX_ROLE_STATIC_TEXT || 3100 GetRole() == ui::AX_ROLE_STATIC_TEXT ||
3147 GetRole() == ui::AX_ROLE_LIST_MARKER)) { 3101 GetRole() == ui::AX_ROLE_LIST_MARKER)) {
3148 base::string16 tmp = value; 3102 std::string tmp = value();
3149 value = name; 3103 set_value(name());
3150 name = tmp; 3104 set_name(tmp);
3151 } 3105 }
3152 3106
3153 // If this doesn't have a value and is linked then set its value to the url 3107 // If this doesn't have a value and is linked then set its value to the url
3154 // attribute. This allows screen readers to read an empty link's destination. 3108 // attribute. This allows screen readers to read an empty link's destination.
3155 if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED)) 3109 if (value().empty() && (ia_state_ & STATE_SYSTEM_LINKED))
3156 value = GetString16Attribute(ui::AX_ATTR_URL); 3110 set_value(GetStringAttribute(ui::AX_ATTR_URL));
3157
3158 win_attributes_->name = name;
3159 win_attributes_->description = description;
3160 win_attributes_->help = help;
3161 win_attributes_->value = value;
3162 3111
3163 // Clear any old relationships between this node and other nodes. 3112 // Clear any old relationships between this node and other nodes.
3164 for (size_t i = 0; i < relations_.size(); ++i) 3113 for (size_t i = 0; i < relations_.size(); ++i)
3165 relations_[i]->Release(); 3114 relations_[i]->Release();
3166 relations_.clear(); 3115 relations_.clear();
3167 3116
3168 // Handle title UI element. 3117 // Handle title UI element.
3169 if (title_elem_id) { 3118 if (title_elem_id) {
3170 // Add a labelled by relationship. 3119 // Add a labelled by relationship.
3171 CComObject<BrowserAccessibilityRelation>* relation; 3120 CComObject<BrowserAccessibilityRelation>* relation;
3172 HRESULT hr = CComObject<BrowserAccessibilityRelation>::CreateInstance( 3121 HRESULT hr = CComObject<BrowserAccessibilityRelation>::CreateInstance(
3173 &relation); 3122 &relation);
3174 DCHECK(SUCCEEDED(hr)); 3123 DCHECK(SUCCEEDED(hr));
3175 relation->AddRef(); 3124 relation->AddRef();
3176 relation->Initialize(this, IA2_RELATION_LABELLED_BY); 3125 relation->Initialize(this, IA2_RELATION_LABELLED_BY);
3177 relation->AddTarget(title_elem_id); 3126 relation->AddTarget(title_elem_id);
3178 relations_.push_back(relation); 3127 relations_.push_back(relation);
3179 } 3128 }
3180 3129
3181 // Expose slider value.
3182 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR ||
3183 ia_role() == ROLE_SYSTEM_SCROLLBAR ||
3184 ia_role() == ROLE_SYSTEM_SLIDER) {
3185 win_attributes_->ia2_attributes.push_back(L"valuetext:" + GetValueText());
3186 }
3187
3188 // If this is a web area for a presentational iframe, give it a role of 3130 // If this is a web area for a presentational iframe, give it a role of
3189 // something other than DOCUMENT so that the fact that it's a separate doc 3131 // something other than DOCUMENT so that the fact that it's a separate doc
3190 // is not exposed to AT. 3132 // is not exposed to AT.
3191 if (IsWebAreaForPresentationalIframe()) { 3133 if (IsWebAreaForPresentationalIframe()) {
3192 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; 3134 ia_role_ = ROLE_SYSTEM_GROUPING;
3193 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; 3135 ia2_role_ = ROLE_SYSTEM_GROUPING;
3194 } 3136 }
3195
3196 BrowserAccessibilityManagerWin* manager =
3197 this->manager()->ToBrowserAccessibilityManagerWin();
3198
3199 // Fire an event when an alert first appears.
3200 if (ia_role() == ROLE_SYSTEM_ALERT &&
3201 old_win_attributes_->ia_role != ROLE_SYSTEM_ALERT) {
3202 manager->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this);
3203 }
3204
3205 // Fire an event if the name, description, help, or value changes.
3206 if (!is_new_object) {
3207 if (name != old_win_attributes_->name)
3208 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, this);
3209 if (description != old_win_attributes_->description)
3210 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_DESCRIPTIONCHANGE, this);
3211 if (help != old_win_attributes_->help)
3212 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_HELPCHANGE, this);
3213 if (value != old_win_attributes_->value)
3214 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_VALUECHANGE, this);
3215 if (ia_state() != old_win_attributes_->ia_state)
3216 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_STATECHANGE, this);
3217
3218 // Normally focus events are handled elsewhere, however
3219 // focus for managed descendants is platform-specific.
3220 // Fire a focus event if the focused descendant in a multi-select
3221 // list box changes.
3222 if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION &&
3223 (ia_state() & STATE_SYSTEM_FOCUSABLE) &&
3224 (ia_state() & STATE_SYSTEM_SELECTABLE) &&
3225 (ia_state() & STATE_SYSTEM_FOCUSED) &&
3226 !(old_win_attributes_->ia_state & STATE_SYSTEM_FOCUSED)) {
3227 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_FOCUS, this);
3228 }
3229
3230 // Handle selection being added or removed.
3231 bool is_selected_now = (ia_state() & STATE_SYSTEM_SELECTED) != 0;
3232 bool was_selected_before =
3233 (old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED) != 0;
3234 if (is_selected_now && !was_selected_before) {
3235 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONADD, this);
3236 } else if (!is_selected_now && was_selected_before) {
3237 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, this);
3238 }
3239
3240 // Fire an event if this container object has scrolled.
3241 int sx = 0;
3242 int sy = 0;
3243 if (GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) &&
3244 GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) {
3245 if (sx != previous_scroll_x_ || sy != previous_scroll_y_)
3246 manager->MaybeCallNotifyWinEvent(EVENT_SYSTEM_SCROLLINGEND, this);
3247 previous_scroll_x_ = sx;
3248 previous_scroll_y_ = sy;
3249 }
3250
3251 // Changing a static text node can affect the IAccessibleText hypertext
3252 // of the parent node, so force it to be recomputed here.
3253 if (GetParent() &&
3254 GetRole() == ui::AX_ROLE_STATIC_TEXT &&
3255 name != old_win_attributes_->name) {
3256 GetParent()->ToBrowserAccessibilityWin()->UpdateIAccessibleText();
3257 }
3258 }
3259
3260 old_win_attributes_.reset(nullptr);
3261 } 3137 }
3262 3138
3263 void BrowserAccessibilityWin::UpdateIAccessibleText() { 3139 void BrowserAccessibilityWin::OnUpdateFinished() {
3264 old_hypertext_ = hypertext_;
3265 hypertext_.clear();
3266
3267 // Construct the hypertext for this node. 3140 // Construct the hypertext for this node.
3268 hyperlink_offset_to_index_.clear(); 3141 hyperlink_offset_to_index_.clear();
3269 hyperlinks_.clear(); 3142 hyperlinks_.clear();
3143 hypertext_.clear();
3270 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { 3144 for (unsigned int i = 0; i < PlatformChildCount(); ++i) {
3271 BrowserAccessibilityWin* child = 3145 BrowserAccessibility* child = PlatformGetChild(i);
3272 PlatformGetChild(i)->ToBrowserAccessibilityWin();
3273 if (child->GetRole() == ui::AX_ROLE_STATIC_TEXT) { 3146 if (child->GetRole() == ui::AX_ROLE_STATIC_TEXT) {
3274 hypertext_ += child->name(); 3147 hypertext_ += base::UTF8ToUTF16(child->name());
3275 } else { 3148 } else {
3276 hyperlink_offset_to_index_[hypertext_.size()] = 3149 hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size();
3277 hyperlinks_.size();
3278 hypertext_ += kEmbeddedCharacter; 3150 hypertext_ += kEmbeddedCharacter;
3279 hyperlinks_.push_back(i); 3151 hyperlinks_.push_back(i);
3280 } 3152 }
3281 } 3153 }
3282 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); 3154 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size());
3283 3155
3284 if (hypertext_ != old_hypertext_) { 3156 // Fire an event when an alert first appears.
3285 BrowserAccessibilityManagerWin* manager = 3157 if (GetRole() == ui::AX_ROLE_ALERT && first_time_)
3286 this->manager()->ToBrowserAccessibilityManagerWin(); 3158 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this);
3287 3159
3288 int start, old_len, new_len; 3160 // Fire events if text has changed.
3289 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); 3161 base::string16 text = TextForIAccessibleText();
3290 if (old_len) { 3162 if (previous_text_ != text) {
3291 // In-process screen readers may call IAccessibleText::get_oldText 3163 if (!previous_text_.empty() && !text.empty()) {
3292 // to retrieve the text that was removed. 3164 manager()->NotifyAccessibilityEvent(
3293 manager->MaybeCallNotifyWinEvent(IA2_EVENT_TEXT_REMOVED, this); 3165 ui::AX_EVENT_SHOW, this);
3294 } 3166 }
3295 if (new_len) { 3167
3296 // In-process screen readers may call IAccessibleText::get_newText 3168 // TODO(dmazzoni): Look into HIDE events, too.
3297 // to retrieve the text that was inserted. 3169
3298 manager->MaybeCallNotifyWinEvent(IA2_EVENT_TEXT_INSERTED, this); 3170 old_text_ = previous_text_;
3299 } 3171 previous_text_ = text;
3300 } 3172 }
3301 3173
3302 old_hypertext_.clear(); 3174 BrowserAccessibilityManagerWin* manager =
3303 } 3175 this->manager()->ToBrowserAccessibilityManagerWin();
3304 3176
3305 void BrowserAccessibilityWin::OnSubtreeWillBeDeleted() { 3177 // Fire events if the state has changed.
3306 manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( 3178 if (!first_time_ && ia_state_ != old_ia_state_) {
3307 EVENT_OBJECT_HIDE, this); 3179 // Normally focus events are handled elsewhere, however
3308 } 3180 // focus for managed descendants is platform-specific.
3181 // Fire a focus event if the focused descendant in a multi-select
3182 // list box changes.
3183 if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION &&
3184 (ia_state_ & STATE_SYSTEM_FOCUSABLE) &&
3185 (ia_state_ & STATE_SYSTEM_SELECTABLE) &&
3186 (ia_state_ & STATE_SYSTEM_FOCUSED) &&
3187 !(old_ia_state_ & STATE_SYSTEM_FOCUSED)) {
3188 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_FOCUS, unique_id_win());
3189 }
3309 3190
3310 void BrowserAccessibilityWin::OnSubtreeCreationFinished() { 3191 if ((ia_state_ & STATE_SYSTEM_SELECTED) &&
3311 manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( 3192 !(old_ia_state_ & STATE_SYSTEM_SELECTED)) {
3312 EVENT_OBJECT_SHOW, this); 3193 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONADD,
3194 unique_id_win());
3195 } else if (!(ia_state_ & STATE_SYSTEM_SELECTED) &&
3196 (old_ia_state_ & STATE_SYSTEM_SELECTED)) {
3197 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE,
3198 unique_id_win());
3199 }
3200
3201 old_ia_state_ = ia_state_;
3202 }
3203
3204 // Fire an event if this container object has scrolled.
3205 int sx = 0;
3206 int sy = 0;
3207 if (GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) &&
3208 GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) {
3209 if (!first_time_ &&
3210 (sx != previous_scroll_x_ || sy != previous_scroll_y_)) {
3211 manager->MaybeCallNotifyWinEvent(EVENT_SYSTEM_SCROLLINGEND,
3212 unique_id_win());
3213 }
3214 previous_scroll_x_ = sx;
3215 previous_scroll_y_ = sy;
3216 }
3217
3218 first_time_ = false;
3313 } 3219 }
3314 3220
3315 void BrowserAccessibilityWin::NativeAddReference() { 3221 void BrowserAccessibilityWin::NativeAddReference() {
3316 AddRef(); 3222 AddRef();
3317 } 3223 }
3318 3224
3319 void BrowserAccessibilityWin::NativeReleaseReference() { 3225 void BrowserAccessibilityWin::NativeReleaseReference() {
3320 Release(); 3226 Release();
3321 } 3227 }
3322 3228
3323 bool BrowserAccessibilityWin::IsNative() const { 3229 bool BrowserAccessibilityWin::IsNative() const {
3324 return true; 3230 return true;
3325 } 3231 }
3326 3232
3327 void BrowserAccessibilityWin::OnLocationChanged() { 3233 void BrowserAccessibilityWin::OnLocationChanged() {
3328 manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( 3234 manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent(
3329 EVENT_OBJECT_LOCATIONCHANGE, this); 3235 EVENT_OBJECT_LOCATIONCHANGE, unique_id_win());
3330 } 3236 }
3331 3237
3332 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { 3238 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() {
3333 AddRef(); 3239 AddRef();
3334 return this; 3240 return this;
3335 } 3241 }
3336 3242
3337 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( 3243 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID(
3338 const VARIANT& var_id) { 3244 const VARIANT& var_id) {
3339 if (var_id.vt != VT_I4) 3245 if (var_id.vt != VT_I4)
(...skipping 24 matching lines...) Expand all
3364 *value_bstr = SysAllocString(str.c_str()); 3270 *value_bstr = SysAllocString(str.c_str());
3365 DCHECK(*value_bstr); 3271 DCHECK(*value_bstr);
3366 3272
3367 return S_OK; 3273 return S_OK;
3368 } 3274 }
3369 3275
3370 void BrowserAccessibilityWin::StringAttributeToIA2( 3276 void BrowserAccessibilityWin::StringAttributeToIA2(
3371 ui::AXStringAttribute attribute, 3277 ui::AXStringAttribute attribute,
3372 const char* ia2_attr) { 3278 const char* ia2_attr) {
3373 base::string16 value; 3279 base::string16 value;
3374 if (GetString16Attribute(attribute, &value)) { 3280 if (GetString16Attribute(attribute, &value))
3375 win_attributes_->ia2_attributes.push_back( 3281 ia2_attributes_.push_back(base::ASCIIToUTF16(ia2_attr) + L":" + value);
3376 base::ASCIIToUTF16(ia2_attr) + L":" + value);
3377 }
3378 } 3282 }
3379 3283
3380 void BrowserAccessibilityWin::BoolAttributeToIA2( 3284 void BrowserAccessibilityWin::BoolAttributeToIA2(
3381 ui::AXBoolAttribute attribute, 3285 ui::AXBoolAttribute attribute,
3382 const char* ia2_attr) { 3286 const char* ia2_attr) {
3383 bool value; 3287 bool value;
3384 if (GetBoolAttribute(attribute, &value)) { 3288 if (GetBoolAttribute(attribute, &value)) {
3385 win_attributes_->ia2_attributes.push_back( 3289 ia2_attributes_.push_back((base::ASCIIToUTF16(ia2_attr) + L":") +
3386 (base::ASCIIToUTF16(ia2_attr) + L":") + 3290 (value ? L"true" : L"false"));
3387 (value ? L"true" : L"false"));
3388 } 3291 }
3389 } 3292 }
3390 3293
3391 void BrowserAccessibilityWin::IntAttributeToIA2( 3294 void BrowserAccessibilityWin::IntAttributeToIA2(
3392 ui::AXIntAttribute attribute, 3295 ui::AXIntAttribute attribute,
3393 const char* ia2_attr) { 3296 const char* ia2_attr) {
3394 int value; 3297 int value;
3395 if (GetIntAttribute(attribute, &value)) { 3298 if (GetIntAttribute(attribute, &value)) {
3396 win_attributes_->ia2_attributes.push_back( 3299 ia2_attributes_.push_back(base::ASCIIToUTF16(ia2_attr) + L":" +
3397 base::ASCIIToUTF16(ia2_attr) + L":" + 3300 base::IntToString16(value));
3398 base::IntToString16(value));
3399 } 3301 }
3400 } 3302 }
3401 3303
3402 base::string16 BrowserAccessibilityWin::GetNameRecursive() const {
3403 if (!name().empty()) {
3404 return name();
3405 }
3406
3407 base::string16 result;
3408 for (uint32 i = 0; i < PlatformChildCount(); ++i) {
3409 result += PlatformGetChild(i)->ToBrowserAccessibilityWin()->
3410 GetNameRecursive();
3411 }
3412 return result;
3413 }
3414
3415 base::string16 BrowserAccessibilityWin::GetValueText() { 3304 base::string16 BrowserAccessibilityWin::GetValueText() {
3416 float fval; 3305 float fval;
3417 base::string16 value = this->value(); 3306 base::string16 value = base::UTF8ToUTF16(this->value());
3418 3307
3419 if (value.empty() && 3308 if (value.empty() &&
3420 GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) { 3309 GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) {
3421 value = base::UTF8ToUTF16(base::DoubleToString(fval)); 3310 value = base::UTF8ToUTF16(base::DoubleToString(fval));
3422 } 3311 }
3423 return value; 3312 return value;
3424 } 3313 }
3425 3314
3426 base::string16 BrowserAccessibilityWin::TextForIAccessibleText() { 3315 base::string16 BrowserAccessibilityWin::TextForIAccessibleText() {
3427 if (IsEditableText()) 3316 if (IsEditableText())
3428 return value(); 3317 return base::UTF8ToUTF16(value());
3429 return (GetRole() == ui::AX_ROLE_STATIC_TEXT) ? name() : hypertext_; 3318 return (GetRole() == ui::AX_ROLE_STATIC_TEXT) ?
3430 } 3319 base::UTF8ToUTF16(name()) : hypertext_;
3431
3432 void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted(
3433 int* start, int* old_len, int* new_len) {
3434 *start = 0;
3435 *old_len = 0;
3436 *new_len = 0;
3437
3438 const base::string16& old_text = old_hypertext_;
3439 const base::string16& new_text = hypertext_;
3440
3441 size_t common_prefix = 0;
3442 while (common_prefix < old_text.size() &&
3443 common_prefix < new_text.size() &&
3444 old_text[common_prefix] == new_text[common_prefix]) {
3445 ++common_prefix;
3446 }
3447
3448 size_t common_suffix = 0;
3449 while (common_prefix + common_suffix < old_text.size() &&
3450 common_prefix + common_suffix < new_text.size() &&
3451 old_text[old_text.size() - common_suffix - 1] ==
3452 new_text[new_text.size() - common_suffix - 1]) {
3453 ++common_suffix;
3454 }
3455
3456 *start = common_prefix;
3457 *old_len = old_text.size() - common_prefix - common_suffix;
3458 *new_len = new_text.size() - common_prefix - common_suffix;
3459 } 3320 }
3460 3321
3461 void BrowserAccessibilityWin::HandleSpecialTextOffset( 3322 void BrowserAccessibilityWin::HandleSpecialTextOffset(
3462 const base::string16& text, 3323 const base::string16& text,
3463 LONG* offset) { 3324 LONG* offset) {
3464 if (*offset == IA2_TEXT_OFFSET_LENGTH) 3325 if (*offset == IA2_TEXT_OFFSET_LENGTH)
3465 *offset = static_cast<LONG>(text.size()); 3326 *offset = static_cast<LONG>(text.size());
3466 else if (*offset == IA2_TEXT_OFFSET_CARET) 3327 else if (*offset == IA2_TEXT_OFFSET_CARET)
3467 get_caretOffset(offset); 3328 get_caretOffset(offset);
3468 } 3329 }
(...skipping 30 matching lines...) Expand all
3499 ui::AX_ATTR_LINE_BREAKS); 3360 ui::AX_ATTR_LINE_BREAKS);
3500 return ui::FindAccessibleTextBoundary( 3361 return ui::FindAccessibleTextBoundary(
3501 text, line_breaks, boundary, start_offset, direction); 3362 text, line_breaks, boundary, start_offset, direction);
3502 } 3363 }
3503 3364
3504 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32 id) { 3365 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32 id) {
3505 return manager()->GetFromID(id)->ToBrowserAccessibilityWin(); 3366 return manager()->GetFromID(id)->ToBrowserAccessibilityWin();
3506 } 3367 }
3507 3368
3508 void BrowserAccessibilityWin::InitRoleAndState() { 3369 void BrowserAccessibilityWin::InitRoleAndState() {
3509 int32 ia_role = 0; 3370 ia_state_ = 0;
3510 int32 ia_state = 0; 3371 ia2_state_ = IA2_STATE_OPAQUE;
3511 base::string16 role_name; 3372 ia2_attributes_.clear();
3512 int32 ia2_role = 0;
3513 int32 ia2_state = IA2_STATE_OPAQUE;
3514 3373
3515 if (HasState(ui::AX_STATE_BUSY)) 3374 if (HasState(ui::AX_STATE_BUSY))
3516 ia_state |= STATE_SYSTEM_BUSY; 3375 ia_state_ |= STATE_SYSTEM_BUSY;
3517 if (HasState(ui::AX_STATE_CHECKED)) 3376 if (HasState(ui::AX_STATE_CHECKED))
3518 ia_state |= STATE_SYSTEM_CHECKED; 3377 ia_state_ |= STATE_SYSTEM_CHECKED;
3519 if (HasState(ui::AX_STATE_COLLAPSED)) 3378 if (HasState(ui::AX_STATE_COLLAPSED))
3520 ia_state |= STATE_SYSTEM_COLLAPSED; 3379 ia_state_ |= STATE_SYSTEM_COLLAPSED;
3521 if (HasState(ui::AX_STATE_EXPANDED)) 3380 if (HasState(ui::AX_STATE_EXPANDED))
3522 ia_state |= STATE_SYSTEM_EXPANDED; 3381 ia_state_ |= STATE_SYSTEM_EXPANDED;
3523 if (HasState(ui::AX_STATE_FOCUSABLE)) 3382 if (HasState(ui::AX_STATE_FOCUSABLE))
3524 ia_state |= STATE_SYSTEM_FOCUSABLE; 3383 ia_state_ |= STATE_SYSTEM_FOCUSABLE;
3525 if (HasState(ui::AX_STATE_HASPOPUP)) 3384 if (HasState(ui::AX_STATE_HASPOPUP))
3526 ia_state |= STATE_SYSTEM_HASPOPUP; 3385 ia_state_ |= STATE_SYSTEM_HASPOPUP;
3527 if (HasState(ui::AX_STATE_HOVERED)) 3386 if (HasState(ui::AX_STATE_HOVERED))
3528 ia_state |= STATE_SYSTEM_HOTTRACKED; 3387 ia_state_ |= STATE_SYSTEM_HOTTRACKED;
3529 if (HasState(ui::AX_STATE_INDETERMINATE)) 3388 if (HasState(ui::AX_STATE_INDETERMINATE))
3530 ia_state |= STATE_SYSTEM_INDETERMINATE; 3389 ia_state_ |= STATE_SYSTEM_INDETERMINATE;
3531 if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && 3390 if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) &&
3532 GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != ui::AX_INVALID_STATE_FALSE) 3391 GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != ui::AX_INVALID_STATE_FALSE)
3533 ia2_state |= IA2_STATE_INVALID_ENTRY; 3392 ia2_state_ |= IA2_STATE_INVALID_ENTRY;
3534 if (HasState(ui::AX_STATE_INVISIBLE)) 3393 if (HasState(ui::AX_STATE_INVISIBLE))
3535 ia_state |= STATE_SYSTEM_INVISIBLE; 3394 ia_state_ |= STATE_SYSTEM_INVISIBLE;
3536 if (HasState(ui::AX_STATE_LINKED)) 3395 if (HasState(ui::AX_STATE_LINKED))
3537 ia_state |= STATE_SYSTEM_LINKED; 3396 ia_state_ |= STATE_SYSTEM_LINKED;
3538 if (HasState(ui::AX_STATE_MULTISELECTABLE)) { 3397 if (HasState(ui::AX_STATE_MULTISELECTABLE)) {
3539 ia_state |= STATE_SYSTEM_EXTSELECTABLE; 3398 ia_state_ |= STATE_SYSTEM_EXTSELECTABLE;
3540 ia_state |= STATE_SYSTEM_MULTISELECTABLE; 3399 ia_state_ |= STATE_SYSTEM_MULTISELECTABLE;
3541 } 3400 }
3542 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. 3401 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect.
3543 if (HasState(ui::AX_STATE_OFFSCREEN)) 3402 if (HasState(ui::AX_STATE_OFFSCREEN))
3544 ia_state |= STATE_SYSTEM_OFFSCREEN; 3403 ia_state_ |= STATE_SYSTEM_OFFSCREEN;
3545 if (HasState(ui::AX_STATE_PRESSED)) 3404 if (HasState(ui::AX_STATE_PRESSED))
3546 ia_state |= STATE_SYSTEM_PRESSED; 3405 ia_state_ |= STATE_SYSTEM_PRESSED;
3547 if (HasState(ui::AX_STATE_PROTECTED)) 3406 if (HasState(ui::AX_STATE_PROTECTED))
3548 ia_state |= STATE_SYSTEM_PROTECTED; 3407 ia_state_ |= STATE_SYSTEM_PROTECTED;
3549 if (HasState(ui::AX_STATE_REQUIRED)) 3408 if (HasState(ui::AX_STATE_REQUIRED))
3550 ia2_state |= IA2_STATE_REQUIRED; 3409 ia2_state_ |= IA2_STATE_REQUIRED;
3551 if (HasState(ui::AX_STATE_SELECTABLE)) 3410 if (HasState(ui::AX_STATE_SELECTABLE))
3552 ia_state |= STATE_SYSTEM_SELECTABLE; 3411 ia_state_ |= STATE_SYSTEM_SELECTABLE;
3553 if (HasState(ui::AX_STATE_SELECTED)) 3412 if (HasState(ui::AX_STATE_SELECTED))
3554 ia_state |= STATE_SYSTEM_SELECTED; 3413 ia_state_ |= STATE_SYSTEM_SELECTED;
3555 if (HasState(ui::AX_STATE_VISITED)) 3414 if (HasState(ui::AX_STATE_VISITED))
3556 ia_state |= STATE_SYSTEM_TRAVERSED; 3415 ia_state_ |= STATE_SYSTEM_TRAVERSED;
3557 if (!HasState(ui::AX_STATE_ENABLED)) 3416 if (!HasState(ui::AX_STATE_ENABLED))
3558 ia_state |= STATE_SYSTEM_UNAVAILABLE; 3417 ia_state_ |= STATE_SYSTEM_UNAVAILABLE;
3559 if (HasState(ui::AX_STATE_VERTICAL)) 3418 if (HasState(ui::AX_STATE_VERTICAL))
3560 ia2_state |= IA2_STATE_VERTICAL; 3419 ia2_state_ |= IA2_STATE_VERTICAL;
3561 if (HasState(ui::AX_STATE_HORIZONTAL)) 3420 if (HasState(ui::AX_STATE_HORIZONTAL))
3562 ia2_state |= IA2_STATE_HORIZONTAL; 3421 ia2_state_ |= IA2_STATE_HORIZONTAL;
3563 if (HasState(ui::AX_STATE_VISITED)) 3422 if (HasState(ui::AX_STATE_VISITED))
3564 ia_state |= STATE_SYSTEM_TRAVERSED; 3423 ia_state_ |= STATE_SYSTEM_TRAVERSED;
3565 3424
3566 // WebKit marks everything as readonly unless it's editable text, so if it's 3425 // WebKit marks everything as readonly unless it's editable text, so if it's
3567 // not readonly, mark it as editable now. The final computation of the 3426 // not readonly, mark it as editable now. The final computation of the
3568 // READONLY state for MSAA is below, after the switch. 3427 // READONLY state for MSAA is below, after the switch.
3569 if (!HasState(ui::AX_STATE_READ_ONLY)) 3428 if (!HasState(ui::AX_STATE_READ_ONLY))
3570 ia2_state |= IA2_STATE_EDITABLE; 3429 ia2_state_ |= IA2_STATE_EDITABLE;
3571 3430
3572 if (GetBoolAttribute(ui::AX_ATTR_BUTTON_MIXED)) 3431 if (GetBoolAttribute(ui::AX_ATTR_BUTTON_MIXED))
3573 ia_state |= STATE_SYSTEM_MIXED; 3432 ia_state_ |= STATE_SYSTEM_MIXED;
3574 3433
3575 if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) 3434 if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE))
3576 ia2_state |= IA2_STATE_EDITABLE; 3435 ia2_state_ |= IA2_STATE_EDITABLE;
3577 3436
3578 if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) 3437 if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty())
3579 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; 3438 ia2_state_ |= IA2_STATE_SUPPORTS_AUTOCOMPLETION;
3580 3439
3581 base::string16 html_tag = GetString16Attribute( 3440 base::string16 html_tag = GetString16Attribute(
3582 ui::AX_ATTR_HTML_TAG); 3441 ui::AX_ATTR_HTML_TAG);
3442 ia_role_ = 0;
3443 ia2_role_ = 0;
3583 switch (GetRole()) { 3444 switch (GetRole()) {
3584 case ui::AX_ROLE_ALERT: 3445 case ui::AX_ROLE_ALERT:
3585 ia_role = ROLE_SYSTEM_ALERT; 3446 ia_role_ = ROLE_SYSTEM_ALERT;
3586 break; 3447 break;
3587 case ui::AX_ROLE_ALERT_DIALOG: 3448 case ui::AX_ROLE_ALERT_DIALOG:
3588 ia_role = ROLE_SYSTEM_DIALOG; 3449 ia_role_ = ROLE_SYSTEM_DIALOG;
3589 break; 3450 break;
3590 case ui::AX_ROLE_APPLICATION: 3451 case ui::AX_ROLE_APPLICATION:
3591 ia_role = ROLE_SYSTEM_APPLICATION; 3452 ia_role_ = ROLE_SYSTEM_APPLICATION;
3592 break; 3453 break;
3593 case ui::AX_ROLE_ARTICLE: 3454 case ui::AX_ROLE_ARTICLE:
3594 ia_role = ROLE_SYSTEM_DOCUMENT; 3455 ia_role_ = ROLE_SYSTEM_DOCUMENT;
3595 ia_state |= STATE_SYSTEM_READONLY; 3456 ia_state_ |= STATE_SYSTEM_READONLY;
3596 break; 3457 break;
3597 case ui::AX_ROLE_BANNER: 3458 case ui::AX_ROLE_BANNER:
3598 ia_role = ROLE_SYSTEM_GROUPING; 3459 ia_role_ = ROLE_SYSTEM_GROUPING;
3599 ia2_role = IA2_ROLE_HEADER; 3460 ia2_role_ = IA2_ROLE_HEADER;
3600 break; 3461 break;
3601 case ui::AX_ROLE_BLOCKQUOTE: 3462 case ui::AX_ROLE_BLOCKQUOTE:
3602 role_name = html_tag; 3463 role_name_ = html_tag;
3603 ia2_role = IA2_ROLE_SECTION; 3464 ia2_role_ = IA2_ROLE_SECTION;
3604 break; 3465 break;
3605 case ui::AX_ROLE_BUSY_INDICATOR: 3466 case ui::AX_ROLE_BUSY_INDICATOR:
3606 ia_role = ROLE_SYSTEM_ANIMATION; 3467 ia_role_ = ROLE_SYSTEM_ANIMATION;
3607 ia_state |= STATE_SYSTEM_READONLY; 3468 ia_state_ |= STATE_SYSTEM_READONLY;
3608 break; 3469 break;
3609 case ui::AX_ROLE_BUTTON: 3470 case ui::AX_ROLE_BUTTON:
3610 ia_role = ROLE_SYSTEM_PUSHBUTTON; 3471 ia_role_ = ROLE_SYSTEM_PUSHBUTTON;
3611 break; 3472 break;
3612 case ui::AX_ROLE_CANVAS: 3473 case ui::AX_ROLE_CANVAS:
3613 if (GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { 3474 if (GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) {
3614 role_name = L"canvas"; 3475 role_name_ = L"canvas";
3615 ia2_role = IA2_ROLE_CANVAS; 3476 ia2_role_ = IA2_ROLE_CANVAS;
3616 } else { 3477 } else {
3617 ia_role = ROLE_SYSTEM_GRAPHIC; 3478 ia_role_ = ROLE_SYSTEM_GRAPHIC;
3618 } 3479 }
3619 break; 3480 break;
3620 case ui::AX_ROLE_CAPTION: 3481 case ui::AX_ROLE_CAPTION:
3621 ia_role = ROLE_SYSTEM_TEXT; 3482 ia_role_ = ROLE_SYSTEM_TEXT;
3622 ia2_role = IA2_ROLE_CAPTION; 3483 ia2_role_ = IA2_ROLE_CAPTION;
3623 break; 3484 break;
3624 case ui::AX_ROLE_CELL: 3485 case ui::AX_ROLE_CELL:
3625 ia_role = ROLE_SYSTEM_CELL; 3486 ia_role_ = ROLE_SYSTEM_CELL;
3626 break; 3487 break;
3627 case ui::AX_ROLE_CHECK_BOX: 3488 case ui::AX_ROLE_CHECK_BOX:
3628 ia_role = ROLE_SYSTEM_CHECKBUTTON; 3489 ia_role_ = ROLE_SYSTEM_CHECKBUTTON;
3629 ia2_state |= IA2_STATE_CHECKABLE; 3490 ia2_state_ |= IA2_STATE_CHECKABLE;
3630 break; 3491 break;
3631 case ui::AX_ROLE_COLOR_WELL: 3492 case ui::AX_ROLE_COLOR_WELL:
3632 ia_role = ROLE_SYSTEM_TEXT; 3493 ia_role_ = ROLE_SYSTEM_TEXT;
3633 ia2_role = IA2_ROLE_COLOR_CHOOSER; 3494 ia2_role_ = IA2_ROLE_COLOR_CHOOSER;
3634 break; 3495 break;
3635 case ui::AX_ROLE_COLUMN: 3496 case ui::AX_ROLE_COLUMN:
3636 ia_role = ROLE_SYSTEM_COLUMN; 3497 ia_role_ = ROLE_SYSTEM_COLUMN;
3637 break; 3498 break;
3638 case ui::AX_ROLE_COLUMN_HEADER: 3499 case ui::AX_ROLE_COLUMN_HEADER:
3639 ia_role = ROLE_SYSTEM_COLUMNHEADER; 3500 ia_role_ = ROLE_SYSTEM_COLUMNHEADER;
3640 break; 3501 break;
3641 case ui::AX_ROLE_COMBO_BOX: 3502 case ui::AX_ROLE_COMBO_BOX:
3642 ia_role = ROLE_SYSTEM_COMBOBOX; 3503 ia_role_ = ROLE_SYSTEM_COMBOBOX;
3643 break; 3504 break;
3644 case ui::AX_ROLE_COMPLEMENTARY: 3505 case ui::AX_ROLE_COMPLEMENTARY:
3645 ia_role = ROLE_SYSTEM_GROUPING; 3506 ia_role_ = ROLE_SYSTEM_GROUPING;
3646 ia2_role = IA2_ROLE_NOTE; 3507 ia2_role_ = IA2_ROLE_NOTE;
3647 break; 3508 break;
3648 case ui::AX_ROLE_CONTENT_INFO: 3509 case ui::AX_ROLE_CONTENT_INFO:
3649 ia_role = ROLE_SYSTEM_TEXT; 3510 ia_role_ = ROLE_SYSTEM_TEXT;
3650 ia2_role = IA2_ROLE_PARAGRAPH; 3511 ia2_role_ = IA2_ROLE_PARAGRAPH;
3651 break; 3512 break;
3652 case ui::AX_ROLE_DATE: 3513 case ui::AX_ROLE_DATE:
3653 case ui::AX_ROLE_DATE_TIME: 3514 case ui::AX_ROLE_DATE_TIME:
3654 ia_role = ROLE_SYSTEM_DROPLIST; 3515 ia_role_ = ROLE_SYSTEM_DROPLIST;
3655 ia2_role = IA2_ROLE_DATE_EDITOR; 3516 ia2_role_ = IA2_ROLE_DATE_EDITOR;
3656 break; 3517 break;
3657 case ui::AX_ROLE_DIV: 3518 case ui::AX_ROLE_DIV:
3658 role_name = L"div"; 3519 role_name_ = L"div";
3659 ia_role = ROLE_SYSTEM_GROUPING; 3520 ia_role_ = ROLE_SYSTEM_GROUPING;
3660 ia2_role = IA2_ROLE_SECTION; 3521 ia2_role_ = IA2_ROLE_SECTION;
3661 break; 3522 break;
3662 case ui::AX_ROLE_DEFINITION: 3523 case ui::AX_ROLE_DEFINITION:
3663 role_name = html_tag; 3524 role_name_ = html_tag;
3664 ia2_role = IA2_ROLE_PARAGRAPH; 3525 ia2_role_ = IA2_ROLE_PARAGRAPH;
3665 ia_state |= STATE_SYSTEM_READONLY; 3526 ia_state_ |= STATE_SYSTEM_READONLY;
3666 break; 3527 break;
3667 case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL: 3528 case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL:
3668 role_name = html_tag; 3529 role_name_ = html_tag;
3669 ia_role = ROLE_SYSTEM_TEXT; 3530 ia_role_ = ROLE_SYSTEM_TEXT;
3670 ia2_role = IA2_ROLE_PARAGRAPH; 3531 ia2_role_ = IA2_ROLE_PARAGRAPH;
3671 break; 3532 break;
3672 case ui::AX_ROLE_DESCRIPTION_LIST: 3533 case ui::AX_ROLE_DESCRIPTION_LIST:
3673 role_name = html_tag; 3534 role_name_ = html_tag;
3674 ia_role = ROLE_SYSTEM_LIST; 3535 ia_role_ = ROLE_SYSTEM_LIST;
3675 ia_state |= STATE_SYSTEM_READONLY; 3536 ia_state_ |= STATE_SYSTEM_READONLY;
3676 break; 3537 break;
3677 case ui::AX_ROLE_DESCRIPTION_LIST_TERM: 3538 case ui::AX_ROLE_DESCRIPTION_LIST_TERM:
3678 ia_role = ROLE_SYSTEM_LISTITEM; 3539 ia_role_ = ROLE_SYSTEM_LISTITEM;
3679 ia_state |= STATE_SYSTEM_READONLY; 3540 ia_state_ |= STATE_SYSTEM_READONLY;
3680 break; 3541 break;
3681 case ui::AX_ROLE_DETAILS: 3542 case ui::AX_ROLE_DETAILS:
3682 role_name = html_tag; 3543 role_name_ = html_tag;
3683 ia_role = ROLE_SYSTEM_GROUPING; 3544 ia_role_ = ROLE_SYSTEM_GROUPING;
3684 break; 3545 break;
3685 case ui::AX_ROLE_DIALOG: 3546 case ui::AX_ROLE_DIALOG:
3686 ia_role = ROLE_SYSTEM_DIALOG; 3547 ia_role_ = ROLE_SYSTEM_DIALOG;
3687 break; 3548 break;
3688 case ui::AX_ROLE_DISCLOSURE_TRIANGLE: 3549 case ui::AX_ROLE_DISCLOSURE_TRIANGLE:
3689 ia_role = ROLE_SYSTEM_PUSHBUTTON; 3550 ia_role_ = ROLE_SYSTEM_PUSHBUTTON;
3690 break; 3551 break;
3691 case ui::AX_ROLE_DOCUMENT: 3552 case ui::AX_ROLE_DOCUMENT:
3692 case ui::AX_ROLE_ROOT_WEB_AREA: 3553 case ui::AX_ROLE_ROOT_WEB_AREA:
3693 case ui::AX_ROLE_WEB_AREA: 3554 case ui::AX_ROLE_WEB_AREA:
3694 ia_role = ROLE_SYSTEM_DOCUMENT; 3555 ia_role_ = ROLE_SYSTEM_DOCUMENT;
3695 ia_state |= STATE_SYSTEM_READONLY; 3556 ia_state_ |= STATE_SYSTEM_READONLY;
3696 ia_state |= STATE_SYSTEM_FOCUSABLE; 3557 ia_state_ |= STATE_SYSTEM_FOCUSABLE;
3697 break; 3558 break;
3698 case ui::AX_ROLE_EMBEDDED_OBJECT: 3559 case ui::AX_ROLE_EMBEDDED_OBJECT:
3699 ia_role = ROLE_SYSTEM_CLIENT; 3560 ia_role_ = ROLE_SYSTEM_CLIENT;
3700 ia2_role = IA2_ROLE_EMBEDDED_OBJECT; 3561 ia2_role_ = IA2_ROLE_EMBEDDED_OBJECT;
3701 break; 3562 break;
3702 case ui::AX_ROLE_FIGCAPTION: 3563 case ui::AX_ROLE_FIGCAPTION:
3703 role_name = html_tag; 3564 role_name_ = html_tag;
3704 ia2_role = IA2_ROLE_CAPTION; 3565 ia2_role_ = IA2_ROLE_CAPTION;
3705 break; 3566 break;
3706 case ui::AX_ROLE_FIGURE: 3567 case ui::AX_ROLE_FIGURE:
3707 ia_role = ROLE_SYSTEM_GROUPING; 3568 ia_role_ = ROLE_SYSTEM_GROUPING;
3708 break; 3569 break;
3709 case ui::AX_ROLE_FORM: 3570 case ui::AX_ROLE_FORM:
3710 role_name = L"form"; 3571 role_name_ = L"form";
3711 ia2_role = IA2_ROLE_FORM; 3572 ia2_role_ = IA2_ROLE_FORM;
3712 break; 3573 break;
3713 case ui::AX_ROLE_FOOTER: 3574 case ui::AX_ROLE_FOOTER:
3714 ia_role = ROLE_SYSTEM_GROUPING; 3575 ia_role_ = ROLE_SYSTEM_GROUPING;
3715 ia2_role = IA2_ROLE_FOOTER; 3576 ia2_role_ = IA2_ROLE_FOOTER;
3716 break; 3577 break;
3717 case ui::AX_ROLE_GRID: 3578 case ui::AX_ROLE_GRID:
3718 ia_role = ROLE_SYSTEM_TABLE; 3579 ia_role_ = ROLE_SYSTEM_TABLE;
3719 ia_state |= STATE_SYSTEM_READONLY; 3580 ia_state_ |= STATE_SYSTEM_READONLY;
3720 break; 3581 break;
3721 case ui::AX_ROLE_GROUP: { 3582 case ui::AX_ROLE_GROUP: {
3722 base::string16 aria_role = GetString16Attribute( 3583 base::string16 aria_role = GetString16Attribute(
3723 ui::AX_ATTR_ROLE); 3584 ui::AX_ATTR_ROLE);
3724 if (aria_role == L"group" || html_tag == L"fieldset") { 3585 if (aria_role == L"group" || html_tag == L"fieldset") {
3725 ia_role = ROLE_SYSTEM_GROUPING; 3586 ia_role_ = ROLE_SYSTEM_GROUPING;
3726 } else if (html_tag == L"li") { 3587 } else if (html_tag == L"li") {
3727 ia_role = ROLE_SYSTEM_LISTITEM; 3588 ia_role_ = ROLE_SYSTEM_LISTITEM;
3728 ia_state |= STATE_SYSTEM_READONLY; 3589 ia_state_ |= STATE_SYSTEM_READONLY;
3729 } else { 3590 } else {
3730 if (html_tag.empty()) 3591 if (html_tag.empty())
3731 role_name = L"div"; 3592 role_name_ = L"div";
3732 else 3593 else
3733 role_name = html_tag; 3594 role_name_ = html_tag;
3734 ia2_role = IA2_ROLE_SECTION; 3595 ia2_role_ = IA2_ROLE_SECTION;
3735 } 3596 }
3736 break; 3597 break;
3737 } 3598 }
3738 case ui::AX_ROLE_HEADING: 3599 case ui::AX_ROLE_HEADING:
3739 role_name = html_tag; 3600 role_name_ = html_tag;
3740 ia2_role = IA2_ROLE_HEADING; 3601 ia2_role_ = IA2_ROLE_HEADING;
3741 break; 3602 break;
3742 case ui::AX_ROLE_IFRAME: 3603 case ui::AX_ROLE_IFRAME:
3743 ia_role = ROLE_SYSTEM_DOCUMENT; 3604 ia_role_ = ROLE_SYSTEM_DOCUMENT;
3744 ia2_role = IA2_ROLE_INTERNAL_FRAME; 3605 ia2_role_ = IA2_ROLE_INTERNAL_FRAME;
3745 ia_state = STATE_SYSTEM_READONLY; 3606 ia_state_ = STATE_SYSTEM_READONLY;
3746 break; 3607 break;
3747 case ui::AX_ROLE_IFRAME_PRESENTATIONAL: 3608 case ui::AX_ROLE_IFRAME_PRESENTATIONAL:
3748 ia_role = ROLE_SYSTEM_GROUPING; 3609 ia_role_ = ROLE_SYSTEM_GROUPING;
3749 break; 3610 break;
3750 case ui::AX_ROLE_IMAGE: 3611 case ui::AX_ROLE_IMAGE:
3751 ia_role = ROLE_SYSTEM_GRAPHIC; 3612 ia_role_ = ROLE_SYSTEM_GRAPHIC;
3752 ia_state |= STATE_SYSTEM_READONLY; 3613 ia_state_ |= STATE_SYSTEM_READONLY;
3753 break; 3614 break;
3754 case ui::AX_ROLE_IMAGE_MAP: 3615 case ui::AX_ROLE_IMAGE_MAP:
3755 role_name = html_tag; 3616 role_name_ = html_tag;
3756 ia2_role = IA2_ROLE_IMAGE_MAP; 3617 ia2_role_ = IA2_ROLE_IMAGE_MAP;
3757 ia_state |= STATE_SYSTEM_READONLY; 3618 ia_state_ |= STATE_SYSTEM_READONLY;
3758 break; 3619 break;
3759 case ui::AX_ROLE_IMAGE_MAP_LINK: 3620 case ui::AX_ROLE_IMAGE_MAP_LINK:
3760 ia_role = ROLE_SYSTEM_LINK; 3621 ia_role_ = ROLE_SYSTEM_LINK;
3761 ia_state |= STATE_SYSTEM_LINKED; 3622 ia_state_ |= STATE_SYSTEM_LINKED;
3762 ia_state |= STATE_SYSTEM_READONLY; 3623 ia_state_ |= STATE_SYSTEM_READONLY;
3763 break; 3624 break;
3764 case ui::AX_ROLE_LABEL_TEXT: 3625 case ui::AX_ROLE_LABEL_TEXT:
3765 case ui::AX_ROLE_LEGEND: 3626 case ui::AX_ROLE_LEGEND:
3766 ia_role = ROLE_SYSTEM_TEXT; 3627 ia_role_ = ROLE_SYSTEM_TEXT;
3767 ia2_role = IA2_ROLE_LABEL; 3628 ia2_role_ = IA2_ROLE_LABEL;
3768 break; 3629 break;
3769 case ui::AX_ROLE_SEARCH: 3630 case ui::AX_ROLE_SEARCH:
3770 ia_role = ROLE_SYSTEM_GROUPING; 3631 ia_role_ = ROLE_SYSTEM_GROUPING;
3771 ia2_role = IA2_ROLE_SECTION; 3632 ia2_role_ = IA2_ROLE_SECTION;
3772 break; 3633 break;
3773 case ui::AX_ROLE_LINK: 3634 case ui::AX_ROLE_LINK:
3774 ia_role = ROLE_SYSTEM_LINK; 3635 ia_role_ = ROLE_SYSTEM_LINK;
3775 ia_state |= STATE_SYSTEM_LINKED; 3636 ia_state_ |= STATE_SYSTEM_LINKED;
3776 break; 3637 break;
3777 case ui::AX_ROLE_LIST: 3638 case ui::AX_ROLE_LIST:
3778 ia_role = ROLE_SYSTEM_LIST; 3639 ia_role_ = ROLE_SYSTEM_LIST;
3779 ia_state |= STATE_SYSTEM_READONLY; 3640 ia_state_ |= STATE_SYSTEM_READONLY;
3780 break; 3641 break;
3781 case ui::AX_ROLE_LIST_BOX: 3642 case ui::AX_ROLE_LIST_BOX:
3782 ia_role = ROLE_SYSTEM_LIST; 3643 ia_role_ = ROLE_SYSTEM_LIST;
3783 break; 3644 break;
3784 case ui::AX_ROLE_LIST_BOX_OPTION: 3645 case ui::AX_ROLE_LIST_BOX_OPTION:
3785 ia_role = ROLE_SYSTEM_LISTITEM; 3646 ia_role_ = ROLE_SYSTEM_LISTITEM;
3786 if (ia_state & STATE_SYSTEM_SELECTABLE) { 3647 if (ia_state_ & STATE_SYSTEM_SELECTABLE) {
3787 ia_state |= STATE_SYSTEM_FOCUSABLE; 3648 ia_state_ |= STATE_SYSTEM_FOCUSABLE;
3788 if (HasState(ui::AX_STATE_FOCUSED)) 3649 if (HasState(ui::AX_STATE_FOCUSED))
3789 ia_state |= STATE_SYSTEM_FOCUSED; 3650 ia_state_ |= STATE_SYSTEM_FOCUSED;
3790 } 3651 }
3791 break; 3652 break;
3792 case ui::AX_ROLE_LIST_ITEM: 3653 case ui::AX_ROLE_LIST_ITEM:
3793 ia_role = ROLE_SYSTEM_LISTITEM; 3654 ia_role_ = ROLE_SYSTEM_LISTITEM;
3794 ia_state |= STATE_SYSTEM_READONLY; 3655 ia_state_ |= STATE_SYSTEM_READONLY;
3795 break; 3656 break;
3796 case ui::AX_ROLE_MAIN: 3657 case ui::AX_ROLE_MAIN:
3797 ia_role = ROLE_SYSTEM_GROUPING; 3658 ia_role_ = ROLE_SYSTEM_GROUPING;
3798 ia2_role = IA2_ROLE_PARAGRAPH; 3659 ia2_role_ = IA2_ROLE_PARAGRAPH;
3799 break; 3660 break;
3800 case ui::AX_ROLE_MARQUEE: 3661 case ui::AX_ROLE_MARQUEE:
3801 ia_role = ROLE_SYSTEM_ANIMATION; 3662 ia_role_ = ROLE_SYSTEM_ANIMATION;
3802 break; 3663 break;
3803 case ui::AX_ROLE_MATH: 3664 case ui::AX_ROLE_MATH:
3804 ia_role = ROLE_SYSTEM_EQUATION; 3665 ia_role_ = ROLE_SYSTEM_EQUATION;
3805 break; 3666 break;
3806 case ui::AX_ROLE_MENU: 3667 case ui::AX_ROLE_MENU:
3807 case ui::AX_ROLE_MENU_BUTTON: 3668 case ui::AX_ROLE_MENU_BUTTON:
3808 ia_role = ROLE_SYSTEM_MENUPOPUP; 3669 ia_role_ = ROLE_SYSTEM_MENUPOPUP;
3809 break; 3670 break;
3810 case ui::AX_ROLE_MENU_BAR: 3671 case ui::AX_ROLE_MENU_BAR:
3811 ia_role = ROLE_SYSTEM_MENUBAR; 3672 ia_role_ = ROLE_SYSTEM_MENUBAR;
3812 break; 3673 break;
3813 case ui::AX_ROLE_MENU_ITEM: 3674 case ui::AX_ROLE_MENU_ITEM:
3814 ia_role = ROLE_SYSTEM_MENUITEM; 3675 ia_role_ = ROLE_SYSTEM_MENUITEM;
3815 break; 3676 break;
3816 case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: 3677 case ui::AX_ROLE_MENU_ITEM_CHECK_BOX:
3817 ia_role = ROLE_SYSTEM_MENUITEM; 3678 ia_role_ = ROLE_SYSTEM_MENUITEM;
3818 ia2_role = IA2_ROLE_CHECK_MENU_ITEM; 3679 ia2_role_ = IA2_ROLE_CHECK_MENU_ITEM;
3819 ia2_state |= IA2_STATE_CHECKABLE; 3680 ia2_state_ |= IA2_STATE_CHECKABLE;
3820 break; 3681 break;
3821 case ui::AX_ROLE_MENU_ITEM_RADIO: 3682 case ui::AX_ROLE_MENU_ITEM_RADIO:
3822 ia_role = ROLE_SYSTEM_MENUITEM; 3683 ia_role_ = ROLE_SYSTEM_MENUITEM;
3823 ia2_role = IA2_ROLE_RADIO_MENU_ITEM; 3684 ia2_role_ = IA2_ROLE_RADIO_MENU_ITEM;
3824 break; 3685 break;
3825 case ui::AX_ROLE_MENU_LIST_POPUP: 3686 case ui::AX_ROLE_MENU_LIST_POPUP:
3826 ia_role = ROLE_SYSTEM_CLIENT; 3687 ia_role_ = ROLE_SYSTEM_CLIENT;
3827 break; 3688 break;
3828 case ui::AX_ROLE_MENU_LIST_OPTION: 3689 case ui::AX_ROLE_MENU_LIST_OPTION:
3829 ia_role = ROLE_SYSTEM_LISTITEM; 3690 ia_role_ = ROLE_SYSTEM_LISTITEM;
3830 if (ia_state & STATE_SYSTEM_SELECTABLE) { 3691 if (ia_state_ & STATE_SYSTEM_SELECTABLE) {
3831 ia_state |= STATE_SYSTEM_FOCUSABLE; 3692 ia_state_ |= STATE_SYSTEM_FOCUSABLE;
3832 if (HasState(ui::AX_STATE_FOCUSED)) 3693 if (HasState(ui::AX_STATE_FOCUSED))
3833 ia_state |= STATE_SYSTEM_FOCUSED; 3694 ia_state_ |= STATE_SYSTEM_FOCUSED;
3834 } 3695 }
3835 break; 3696 break;
3836 case ui::AX_ROLE_METER: 3697 case ui::AX_ROLE_METER:
3837 role_name = html_tag; 3698 role_name_ = html_tag;
3838 ia_role = ROLE_SYSTEM_PROGRESSBAR; 3699 ia_role_ = ROLE_SYSTEM_PROGRESSBAR;
3839 break; 3700 break;
3840 case ui::AX_ROLE_NAVIGATION: 3701 case ui::AX_ROLE_NAVIGATION:
3841 ia_role = ROLE_SYSTEM_GROUPING; 3702 ia_role_ = ROLE_SYSTEM_GROUPING;
3842 ia2_role = IA2_ROLE_SECTION; 3703 ia2_role_ = IA2_ROLE_SECTION;
3843 break; 3704 break;
3844 case ui::AX_ROLE_NOTE: 3705 case ui::AX_ROLE_NOTE:
3845 ia_role = ROLE_SYSTEM_GROUPING; 3706 ia_role_ = ROLE_SYSTEM_GROUPING;
3846 ia2_role = IA2_ROLE_NOTE; 3707 ia2_role_ = IA2_ROLE_NOTE;
3847 break; 3708 break;
3848 case ui::AX_ROLE_OUTLINE: 3709 case ui::AX_ROLE_OUTLINE:
3849 ia_role = ROLE_SYSTEM_OUTLINE; 3710 ia_role_ = ROLE_SYSTEM_OUTLINE;
3850 break; 3711 break;
3851 case ui::AX_ROLE_PARAGRAPH: 3712 case ui::AX_ROLE_PARAGRAPH:
3852 role_name = L"P"; 3713 role_name_ = L"P";
3853 ia2_role = IA2_ROLE_PARAGRAPH; 3714 ia2_role_ = IA2_ROLE_PARAGRAPH;
3854 break; 3715 break;
3855 case ui::AX_ROLE_POP_UP_BUTTON: 3716 case ui::AX_ROLE_POP_UP_BUTTON:
3856 if (html_tag == L"select") { 3717 if (html_tag == L"select") {
3857 ia_role = ROLE_SYSTEM_COMBOBOX; 3718 ia_role_ = ROLE_SYSTEM_COMBOBOX;
3858 } else { 3719 } else {
3859 ia_role = ROLE_SYSTEM_BUTTONMENU; 3720 ia_role_ = ROLE_SYSTEM_BUTTONMENU;
3860 } 3721 }
3861 break; 3722 break;
3862 case ui::AX_ROLE_PRE: 3723 case ui::AX_ROLE_PRE:
3863 role_name = html_tag; 3724 role_name_ = html_tag;
3864 ia_role = ROLE_SYSTEM_TEXT; 3725 ia_role_ = ROLE_SYSTEM_TEXT;
3865 ia2_role = IA2_ROLE_PARAGRAPH; 3726 ia2_role_ = IA2_ROLE_PARAGRAPH;
3866 break; 3727 break;
3867 case ui::AX_ROLE_PROGRESS_INDICATOR: 3728 case ui::AX_ROLE_PROGRESS_INDICATOR:
3868 ia_role = ROLE_SYSTEM_PROGRESSBAR; 3729 ia_role_ = ROLE_SYSTEM_PROGRESSBAR;
3869 ia_state |= STATE_SYSTEM_READONLY; 3730 ia_state_ |= STATE_SYSTEM_READONLY;
3870 break; 3731 break;
3871 case ui::AX_ROLE_RADIO_BUTTON: 3732 case ui::AX_ROLE_RADIO_BUTTON:
3872 ia_role = ROLE_SYSTEM_RADIOBUTTON; 3733 ia_role_ = ROLE_SYSTEM_RADIOBUTTON;
3873 ia2_state = IA2_STATE_CHECKABLE; 3734 ia2_state_ = IA2_STATE_CHECKABLE;
3874 break; 3735 break;
3875 case ui::AX_ROLE_RADIO_GROUP: 3736 case ui::AX_ROLE_RADIO_GROUP:
3876 ia_role = ROLE_SYSTEM_GROUPING; 3737 ia_role_ = ROLE_SYSTEM_GROUPING;
3877 break; 3738 break;
3878 case ui::AX_ROLE_REGION: 3739 case ui::AX_ROLE_REGION:
3879 if (html_tag == L"section") { 3740 if (html_tag == L"section") {
3880 ia_role = ROLE_SYSTEM_GROUPING; 3741 ia_role_ = ROLE_SYSTEM_GROUPING;
3881 ia2_role = IA2_ROLE_SECTION; 3742 ia2_role_ = IA2_ROLE_SECTION;
3882 } else { 3743 } else {
3883 ia_role = ROLE_SYSTEM_PANE; 3744 ia_role_ = ROLE_SYSTEM_PANE;
3884 } 3745 }
3885 break; 3746 break;
3886 case ui::AX_ROLE_ROW: 3747 case ui::AX_ROLE_ROW:
3887 ia_role = ROLE_SYSTEM_ROW; 3748 ia_role_ = ROLE_SYSTEM_ROW;
3888 break; 3749 break;
3889 case ui::AX_ROLE_ROW_HEADER: 3750 case ui::AX_ROLE_ROW_HEADER:
3890 ia_role = ROLE_SYSTEM_ROWHEADER; 3751 ia_role_ = ROLE_SYSTEM_ROWHEADER;
3891 break; 3752 break;
3892 case ui::AX_ROLE_RUBY: 3753 case ui::AX_ROLE_RUBY:
3893 ia_role = ROLE_SYSTEM_TEXT; 3754 ia_role_ = ROLE_SYSTEM_TEXT;
3894 ia2_role = IA2_ROLE_TEXT_FRAME; 3755 ia2_role_ = IA2_ROLE_TEXT_FRAME;
3895 break; 3756 break;
3896 case ui::AX_ROLE_RULER: 3757 case ui::AX_ROLE_RULER:
3897 ia_role = ROLE_SYSTEM_CLIENT; 3758 ia_role_ = ROLE_SYSTEM_CLIENT;
3898 ia2_role = IA2_ROLE_RULER; 3759 ia2_role_ = IA2_ROLE_RULER;
3899 ia_state |= STATE_SYSTEM_READONLY; 3760 ia_state_ |= STATE_SYSTEM_READONLY;
3900 break; 3761 break;
3901 case ui::AX_ROLE_SCROLL_AREA: 3762 case ui::AX_ROLE_SCROLL_AREA:
3902 ia_role = ROLE_SYSTEM_CLIENT; 3763 ia_role_ = ROLE_SYSTEM_CLIENT;
3903 ia2_role = IA2_ROLE_SCROLL_PANE; 3764 ia2_role_ = IA2_ROLE_SCROLL_PANE;
3904 ia_state |= STATE_SYSTEM_READONLY; 3765 ia_state_ |= STATE_SYSTEM_READONLY;
3905 ia2_state &= ~(IA2_STATE_EDITABLE); 3766 ia2_state_ &= ~(IA2_STATE_EDITABLE);
3906 break; 3767 break;
3907 case ui::AX_ROLE_SCROLL_BAR: 3768 case ui::AX_ROLE_SCROLL_BAR:
3908 ia_role = ROLE_SYSTEM_SCROLLBAR; 3769 ia_role_ = ROLE_SYSTEM_SCROLLBAR;
3909 break; 3770 break;
3910 case ui::AX_ROLE_SLIDER: 3771 case ui::AX_ROLE_SLIDER:
3911 ia_role = ROLE_SYSTEM_SLIDER; 3772 ia_role_ = ROLE_SYSTEM_SLIDER;
3912 break; 3773 break;
3913 case ui::AX_ROLE_SPIN_BUTTON: 3774 case ui::AX_ROLE_SPIN_BUTTON:
3914 ia_role = ROLE_SYSTEM_SPINBUTTON; 3775 ia_role_ = ROLE_SYSTEM_SPINBUTTON;
3915 break; 3776 break;
3916 case ui::AX_ROLE_SPIN_BUTTON_PART: 3777 case ui::AX_ROLE_SPIN_BUTTON_PART:
3917 ia_role = ROLE_SYSTEM_PUSHBUTTON; 3778 ia_role_ = ROLE_SYSTEM_PUSHBUTTON;
3918 break; 3779 break;
3919 case ui::AX_ROLE_ANNOTATION: 3780 case ui::AX_ROLE_ANNOTATION:
3920 case ui::AX_ROLE_LIST_MARKER: 3781 case ui::AX_ROLE_LIST_MARKER:
3921 case ui::AX_ROLE_STATIC_TEXT: 3782 case ui::AX_ROLE_STATIC_TEXT:
3922 ia_role = ROLE_SYSTEM_STATICTEXT; 3783 ia_role_ = ROLE_SYSTEM_STATICTEXT;
3923 break; 3784 break;
3924 case ui::AX_ROLE_STATUS: 3785 case ui::AX_ROLE_STATUS:
3925 ia_role = ROLE_SYSTEM_STATUSBAR; 3786 ia_role_ = ROLE_SYSTEM_STATUSBAR;
3926 break; 3787 break;
3927 case ui::AX_ROLE_SPLITTER: 3788 case ui::AX_ROLE_SPLITTER:
3928 ia_role = ROLE_SYSTEM_SEPARATOR; 3789 ia_role_ = ROLE_SYSTEM_SEPARATOR;
3929 break; 3790 break;
3930 case ui::AX_ROLE_SVG_ROOT: 3791 case ui::AX_ROLE_SVG_ROOT:
3931 ia_role = ROLE_SYSTEM_GRAPHIC; 3792 ia_role_ = ROLE_SYSTEM_GRAPHIC;
3932 break; 3793 break;
3933 case ui::AX_ROLE_TAB: 3794 case ui::AX_ROLE_TAB:
3934 ia_role = ROLE_SYSTEM_PAGETAB; 3795 ia_role_ = ROLE_SYSTEM_PAGETAB;
3935 break; 3796 break;
3936 case ui::AX_ROLE_TABLE: { 3797 case ui::AX_ROLE_TABLE: {
3937 base::string16 aria_role = GetString16Attribute( 3798 base::string16 aria_role = GetString16Attribute(
3938 ui::AX_ATTR_ROLE); 3799 ui::AX_ATTR_ROLE);
3939 if (aria_role == L"treegrid") { 3800 if (aria_role == L"treegrid") {
3940 ia_role = ROLE_SYSTEM_OUTLINE; 3801 ia_role_ = ROLE_SYSTEM_OUTLINE;
3941 } else { 3802 } else {
3942 ia_role = ROLE_SYSTEM_TABLE; 3803 ia_role_ = ROLE_SYSTEM_TABLE;
3943 } 3804 }
3944 break; 3805 break;
3945 } 3806 }
3946 case ui::AX_ROLE_TABLE_HEADER_CONTAINER: 3807 case ui::AX_ROLE_TABLE_HEADER_CONTAINER:
3947 ia_role = ROLE_SYSTEM_GROUPING; 3808 ia_role_ = ROLE_SYSTEM_GROUPING;
3948 ia2_role = IA2_ROLE_SECTION; 3809 ia2_role_ = IA2_ROLE_SECTION;
3949 ia_state |= STATE_SYSTEM_READONLY; 3810 ia_state_ |= STATE_SYSTEM_READONLY;
3950 break; 3811 break;
3951 case ui::AX_ROLE_TAB_LIST: 3812 case ui::AX_ROLE_TAB_LIST:
3952 ia_role = ROLE_SYSTEM_PAGETABLIST; 3813 ia_role_ = ROLE_SYSTEM_PAGETABLIST;
3953 break; 3814 break;
3954 case ui::AX_ROLE_TAB_PANEL: 3815 case ui::AX_ROLE_TAB_PANEL:
3955 ia_role = ROLE_SYSTEM_PROPERTYPAGE; 3816 ia_role_ = ROLE_SYSTEM_PROPERTYPAGE;
3956 break; 3817 break;
3957 case ui::AX_ROLE_TOGGLE_BUTTON: 3818 case ui::AX_ROLE_TOGGLE_BUTTON:
3958 ia_role = ROLE_SYSTEM_PUSHBUTTON; 3819 ia_role_ = ROLE_SYSTEM_PUSHBUTTON;
3959 ia2_role = IA2_ROLE_TOGGLE_BUTTON; 3820 ia2_role_ = IA2_ROLE_TOGGLE_BUTTON;
3960 break; 3821 break;
3961 case ui::AX_ROLE_TEXT_AREA: 3822 case ui::AX_ROLE_TEXT_AREA:
3962 ia_role = ROLE_SYSTEM_TEXT; 3823 ia_role_ = ROLE_SYSTEM_TEXT;
3963 ia2_state |= IA2_STATE_MULTI_LINE; 3824 ia2_state_ |= IA2_STATE_MULTI_LINE;
3964 ia2_state |= IA2_STATE_EDITABLE; 3825 ia2_state_ |= IA2_STATE_EDITABLE;
3965 ia2_state |= IA2_STATE_SELECTABLE_TEXT; 3826 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT;
3966 break; 3827 break;
3967 case ui::AX_ROLE_TEXT_FIELD: 3828 case ui::AX_ROLE_TEXT_FIELD:
3968 ia_role = ROLE_SYSTEM_TEXT; 3829 ia_role_ = ROLE_SYSTEM_TEXT;
3969 ia2_state |= IA2_STATE_SINGLE_LINE; 3830 ia2_state_ |= IA2_STATE_SINGLE_LINE;
3970 ia2_state |= IA2_STATE_EDITABLE; 3831 ia2_state_ |= IA2_STATE_EDITABLE;
3971 ia2_state |= IA2_STATE_SELECTABLE_TEXT; 3832 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT;
3972 break; 3833 break;
3973 case ui::AX_ROLE_TIME: 3834 case ui::AX_ROLE_TIME:
3974 ia_role = ROLE_SYSTEM_SPINBUTTON; 3835 ia_role_ = ROLE_SYSTEM_SPINBUTTON;
3975 break; 3836 break;
3976 case ui::AX_ROLE_TIMER: 3837 case ui::AX_ROLE_TIMER:
3977 ia_role = ROLE_SYSTEM_CLOCK; 3838 ia_role_ = ROLE_SYSTEM_CLOCK;
3978 ia_state |= STATE_SYSTEM_READONLY; 3839 ia_state_ |= STATE_SYSTEM_READONLY;
3979 break; 3840 break;
3980 case ui::AX_ROLE_TOOLBAR: 3841 case ui::AX_ROLE_TOOLBAR:
3981 ia_role = ROLE_SYSTEM_TOOLBAR; 3842 ia_role_ = ROLE_SYSTEM_TOOLBAR;
3982 ia_state |= STATE_SYSTEM_READONLY; 3843 ia_state_ |= STATE_SYSTEM_READONLY;
3983 break; 3844 break;
3984 case ui::AX_ROLE_TOOLTIP: 3845 case ui::AX_ROLE_TOOLTIP:
3985 ia_role = ROLE_SYSTEM_TOOLTIP; 3846 ia_role_ = ROLE_SYSTEM_TOOLTIP;
3986 ia_state |= STATE_SYSTEM_READONLY; 3847 ia_state_ |= STATE_SYSTEM_READONLY;
3987 break; 3848 break;
3988 case ui::AX_ROLE_TREE: 3849 case ui::AX_ROLE_TREE:
3989 ia_role = ROLE_SYSTEM_OUTLINE; 3850 ia_role_ = ROLE_SYSTEM_OUTLINE;
3990 break; 3851 break;
3991 case ui::AX_ROLE_TREE_GRID: 3852 case ui::AX_ROLE_TREE_GRID:
3992 ia_role = ROLE_SYSTEM_OUTLINE; 3853 ia_role_ = ROLE_SYSTEM_OUTLINE;
3993 break; 3854 break;
3994 case ui::AX_ROLE_TREE_ITEM: 3855 case ui::AX_ROLE_TREE_ITEM:
3995 ia_role = ROLE_SYSTEM_OUTLINEITEM; 3856 ia_role_ = ROLE_SYSTEM_OUTLINEITEM;
3996 break; 3857 break;
3997 case ui::AX_ROLE_LINE_BREAK: 3858 case ui::AX_ROLE_LINE_BREAK:
3998 ia_role = ROLE_SYSTEM_WHITESPACE; 3859 ia_role_ = ROLE_SYSTEM_WHITESPACE;
3999 break; 3860 break;
4000 case ui::AX_ROLE_WINDOW: 3861 case ui::AX_ROLE_WINDOW:
4001 ia_role = ROLE_SYSTEM_WINDOW; 3862 ia_role_ = ROLE_SYSTEM_WINDOW;
4002 break; 3863 break;
4003 3864
4004 // TODO(dmazzoni): figure out the proper MSAA role for all of these. 3865 // TODO(dmazzoni): figure out the proper MSAA role for all of these.
4005 case ui::AX_ROLE_DIRECTORY: 3866 case ui::AX_ROLE_DIRECTORY:
4006 case ui::AX_ROLE_IGNORED: 3867 case ui::AX_ROLE_IGNORED:
4007 case ui::AX_ROLE_LOG: 3868 case ui::AX_ROLE_LOG:
4008 case ui::AX_ROLE_NONE: 3869 case ui::AX_ROLE_NONE:
4009 case ui::AX_ROLE_PRESENTATIONAL: 3870 case ui::AX_ROLE_PRESENTATIONAL:
4010 case ui::AX_ROLE_SLIDER_THUMB: 3871 case ui::AX_ROLE_SLIDER_THUMB:
4011 default: 3872 default:
4012 ia_role = ROLE_SYSTEM_CLIENT; 3873 ia_role_ = ROLE_SYSTEM_CLIENT;
4013 break; 3874 break;
4014 } 3875 }
4015 3876
4016 // Compute the final value of READONLY for MSAA. 3877 // Compute the final value of READONLY for MSAA.
4017 // 3878 //
4018 // We always set the READONLY state for elements that have the 3879 // We always set the READONLY state for elements that have the
4019 // aria-readonly attribute and for a few roles (in the switch above). 3880 // aria-readonly attribute and for a few roles (in the switch above).
4020 // We clear the READONLY state on focusable controls and on a document. 3881 // We clear the READONLY state on focusable controls and on a document.
4021 // Everything else, the majority of objects, do not have this state set. 3882 // Everything else, the majority of objects, do not have this state set.
4022 if (HasState(ui::AX_STATE_FOCUSABLE) && 3883 if (HasState(ui::AX_STATE_FOCUSABLE) &&
4023 ia_role != ROLE_SYSTEM_DOCUMENT) { 3884 ia_role_ != ROLE_SYSTEM_DOCUMENT) {
4024 ia_state &= ~(STATE_SYSTEM_READONLY); 3885 ia_state_ &= ~(STATE_SYSTEM_READONLY);
4025 } 3886 }
4026 if (!HasState(ui::AX_STATE_READ_ONLY)) 3887 if (!HasState(ui::AX_STATE_READ_ONLY))
4027 ia_state &= ~(STATE_SYSTEM_READONLY); 3888 ia_state_ &= ~(STATE_SYSTEM_READONLY);
4028 if (GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) 3889 if (GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY))
4029 ia_state |= STATE_SYSTEM_READONLY; 3890 ia_state_ |= STATE_SYSTEM_READONLY;
4030 3891
4031 // The role should always be set. 3892 // The role should always be set.
4032 DCHECK(!role_name.empty() || ia_role); 3893 DCHECK(!role_name_.empty() || ia_role_);
4033 3894
4034 // If we didn't explicitly set the IAccessible2 role, make it the same 3895 // If we didn't explicitly set the IAccessible2 role, make it the same
4035 // as the MSAA role. 3896 // as the MSAA role.
4036 if (!ia2_role) 3897 if (!ia2_role_)
4037 ia2_role = ia_role; 3898 ia2_role_ = ia_role_;
4038
4039 win_attributes_->ia_role = ia_role;
4040 win_attributes_->ia_state = ia_state;
4041 win_attributes_->role_name = role_name;
4042 win_attributes_->ia2_role = ia2_role;
4043 win_attributes_->ia2_state = ia2_state;
4044 } 3899 }
4045 3900
4046 } // namespace content 3901 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698