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

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

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

Powered by Google App Engine
This is Rietveld 408576698