| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 10 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
| 11 #include "content/common/view_messages.h" |
| 11 #include "net/base/escape.h" | 12 #include "net/base/escape.h" |
| 12 | 13 |
| 13 using webkit_glue::WebAccessibility; | 14 using webkit_glue::WebAccessibility; |
| 14 | 15 |
| 15 // The GUID for the ISimpleDOM service is not defined in the IDL files. | 16 // The GUID for the ISimpleDOM service is not defined in the IDL files. |
| 16 // This is taken directly from the Mozilla sources | 17 // This is taken directly from the Mozilla sources |
| 17 // (accessible/src/msaa/nsAccessNodeWrap.cpp) and it's also documented at: | 18 // (accessible/src/msaa/nsAccessNodeWrap.cpp) and it's also documented at: |
| 18 // http://developer.mozilla.org/en/Accessibility/AT-APIs/ImplementationFeatures/
MSAA | 19 // http://developer.mozilla.org/en/Accessibility/AT-APIs/ImplementationFeatures/
MSAA |
| 19 | 20 |
| 20 const GUID GUID_ISimpleDOM = { | 21 const GUID GUID_ISimpleDOM = { |
| 21 0x0c539790, 0x12e4, 0x11cf, | 22 0x0c539790, 0x12e4, 0x11cf, |
| 22 0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8}; | 23 0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8}; |
| 23 | 24 |
| 24 // static | 25 // static |
| 25 BrowserAccessibility* BrowserAccessibility::Create() { | 26 BrowserAccessibility* BrowserAccessibility::Create() { |
| 26 CComObject<BrowserAccessibilityWin>* instance; | 27 CComObject<BrowserAccessibilityWin>* instance; |
| 27 HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance); | 28 HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance); |
| 28 DCHECK(SUCCEEDED(hr)); | 29 DCHECK(SUCCEEDED(hr)); |
| 29 return instance->NewReference(); | 30 return instance->NewReference(); |
| 30 } | 31 } |
| 31 | 32 |
| 32 BrowserAccessibilityWin* BrowserAccessibility::toBrowserAccessibilityWin() { | 33 BrowserAccessibilityWin* BrowserAccessibility::toBrowserAccessibilityWin() { |
| 33 return static_cast<BrowserAccessibilityWin*>(this); | 34 return static_cast<BrowserAccessibilityWin*>(this); |
| 34 } | 35 } |
| 35 | 36 |
| 36 BrowserAccessibilityWin::BrowserAccessibilityWin() | 37 BrowserAccessibilityWin::BrowserAccessibilityWin() |
| 37 : ia_role_(0), | 38 : ia_role_(0), |
| 38 ia_state_(0), | 39 ia_state_(0), |
| 39 ia2_role_(0), | 40 ia2_role_(0), |
| 40 ia2_state_(0) { | 41 ia2_state_(0), |
| 42 first_time_(true) { |
| 41 } | 43 } |
| 42 | 44 |
| 43 BrowserAccessibilityWin::~BrowserAccessibilityWin() { | 45 BrowserAccessibilityWin::~BrowserAccessibilityWin() { |
| 44 } | 46 } |
| 45 | 47 |
| 46 // | 48 // |
| 47 // IAccessible methods. | 49 // IAccessible methods. |
| 48 // | 50 // |
| 49 // Conventions: | 51 // Conventions: |
| 50 // * Always test for instance_active_ first and return E_FAIL if it's false. | 52 // * Always test for instance_active_ first and return E_FAIL if it's false. |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 return S_OK; | 416 return S_OK; |
| 415 } | 417 } |
| 416 | 418 |
| 417 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { | 419 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { |
| 418 if (!instance_active_) | 420 if (!instance_active_) |
| 419 return E_FAIL; | 421 return E_FAIL; |
| 420 | 422 |
| 421 if (!attributes) | 423 if (!attributes) |
| 422 return E_INVALIDARG; | 424 return E_INVALIDARG; |
| 423 | 425 |
| 424 // Follow Firefox's convention, which is to return a set of key-value pairs | 426 // The iaccessible2 attributes are a set of key-value pairs |
| 425 // separated by semicolons, with a colon between the key and the value. | 427 // separated by semicolons, with a colon between the key and the value. |
| 426 string16 str; | 428 string16 str; |
| 427 for (unsigned int i = 0; i < html_attributes_.size(); i++) { | 429 for (unsigned int i = 0; i < ia2_attributes_.size(); i++) { |
| 428 if (i != 0) | 430 if (i != 0) |
| 429 str += L';'; | 431 str += L';'; |
| 430 str += Escape(html_attributes_[i].first); | 432 str += ia2_attributes_[i]; |
| 431 str += L':'; | |
| 432 str += Escape(html_attributes_[i].second); | |
| 433 } | 433 } |
| 434 | 434 |
| 435 if (str.empty()) | 435 if (str.empty()) |
| 436 return S_FALSE; | 436 return S_FALSE; |
| 437 | 437 |
| 438 *attributes = SysAllocString(str.c_str()); | 438 *attributes = SysAllocString(str.c_str()); |
| 439 DCHECK(*attributes); | 439 DCHECK(*attributes); |
| 440 return S_OK; | 440 return S_OK; |
| 441 } | 441 } |
| 442 | 442 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 | 567 |
| 568 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids_.size())); | 568 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids_.size())); |
| 569 | 569 |
| 570 int cell_id = cell_ids_[row * columns + column]; | 570 int cell_id = cell_ids_[row * columns + column]; |
| 571 BrowserAccessibilityWin* cell = GetFromRendererID(cell_id); | 571 BrowserAccessibilityWin* cell = GetFromRendererID(cell_id); |
| 572 if (cell) { | 572 if (cell) { |
| 573 *accessible = static_cast<IAccessible*>(cell->NewReference()); | 573 *accessible = static_cast<IAccessible*>(cell->NewReference()); |
| 574 return S_OK; | 574 return S_OK; |
| 575 } | 575 } |
| 576 | 576 |
| 577 return S_FALSE; | 577 *accessible = NULL; |
| 578 return E_INVALIDARG; |
| 578 } | 579 } |
| 579 | 580 |
| 580 STDMETHODIMP BrowserAccessibilityWin::get_caption(IUnknown** accessible) { | 581 STDMETHODIMP BrowserAccessibilityWin::get_caption(IUnknown** accessible) { |
| 581 if (!instance_active_) | 582 if (!instance_active_) |
| 582 return E_FAIL; | 583 return E_FAIL; |
| 583 | 584 |
| 584 if (!accessible) | 585 if (!accessible) |
| 585 return E_INVALIDARG; | 586 return E_INVALIDARG; |
| 586 | 587 |
| 587 // TODO(dmazzoni): implement | 588 // TODO(dmazzoni): implement |
| (...skipping 15 matching lines...) Expand all Loading... |
| 603 if (!GetIntAttribute(WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || | 604 if (!GetIntAttribute(WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 604 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) || | 605 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) || |
| 605 columns <= 0 || | 606 columns <= 0 || |
| 606 rows <= 0) { | 607 rows <= 0) { |
| 607 return S_FALSE; | 608 return S_FALSE; |
| 608 } | 609 } |
| 609 | 610 |
| 610 if (row < 0 || row >= rows || column < 0 || column >= columns) | 611 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 611 return E_INVALIDARG; | 612 return E_INVALIDARG; |
| 612 | 613 |
| 613 *cell_index = row * columns + column; | 614 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids_.size())); |
| 615 int cell_id = cell_ids_[row * columns + column]; |
| 616 for (size_t i = 0; i < unique_cell_ids_.size(); i++) { |
| 617 if (unique_cell_ids_[i] == cell_id) { |
| 618 *cell_index = (long)i; |
| 619 return S_OK; |
| 620 } |
| 621 } |
| 614 | 622 |
| 615 return S_OK; | 623 return S_FALSE; |
| 616 } | 624 } |
| 617 | 625 |
| 618 STDMETHODIMP BrowserAccessibilityWin::get_columnDescription( | 626 STDMETHODIMP BrowserAccessibilityWin::get_columnDescription( |
| 619 long column, | 627 long column, |
| 620 BSTR* description) { | 628 BSTR* description) { |
| 621 if (!instance_active_) | 629 if (!instance_active_) |
| 622 return E_FAIL; | 630 return E_FAIL; |
| 623 | 631 |
| 624 if (!description) | 632 if (!description) |
| 625 return E_INVALIDARG; | 633 return E_INVALIDARG; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 | 708 |
| 701 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex( | 709 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex( |
| 702 long cell_index, | 710 long cell_index, |
| 703 long* column_index) { | 711 long* column_index) { |
| 704 if (!instance_active_) | 712 if (!instance_active_) |
| 705 return E_FAIL; | 713 return E_FAIL; |
| 706 | 714 |
| 707 if (!column_index) | 715 if (!column_index) |
| 708 return E_INVALIDARG; | 716 return E_INVALIDARG; |
| 709 | 717 |
| 710 int columns; | 718 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); |
| 711 int rows; | 719 if (cell_index < 0) |
| 712 if (!GetIntAttribute(WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || | 720 return E_INVALIDARG; |
| 713 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) || | 721 if (cell_index >= cell_id_count) |
| 714 columns <= 0 || | |
| 715 rows <= 0) { | |
| 716 return S_FALSE; | 722 return S_FALSE; |
| 723 |
| 724 int cell_id = unique_cell_ids_[cell_index]; |
| 725 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 726 manager_->GetFromRendererID(cell_id)); |
| 727 int col_index; |
| 728 if (cell && |
| 729 cell->GetIntAttribute( |
| 730 WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) { |
| 731 *column_index = col_index; |
| 732 return S_OK; |
| 717 } | 733 } |
| 718 | 734 |
| 719 if (cell_index < 0 || cell_index >= columns * rows) | 735 return S_FALSE; |
| 720 return E_INVALIDARG; | |
| 721 | |
| 722 *column_index = cell_index % columns; | |
| 723 | |
| 724 return S_OK; | |
| 725 } | 736 } |
| 726 | 737 |
| 727 STDMETHODIMP BrowserAccessibilityWin::get_nColumns( | 738 STDMETHODIMP BrowserAccessibilityWin::get_nColumns( |
| 728 long* column_count) { | 739 long* column_count) { |
| 729 if (!instance_active_) | 740 if (!instance_active_) |
| 730 return E_FAIL; | 741 return E_FAIL; |
| 731 | 742 |
| 732 if (!column_count) | 743 if (!column_count) |
| 733 return E_INVALIDARG; | 744 return E_INVALIDARG; |
| 734 | 745 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 | 891 |
| 881 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex( | 892 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex( |
| 882 long cell_index, | 893 long cell_index, |
| 883 long* row_index) { | 894 long* row_index) { |
| 884 if (!instance_active_) | 895 if (!instance_active_) |
| 885 return E_FAIL; | 896 return E_FAIL; |
| 886 | 897 |
| 887 if (!row_index) | 898 if (!row_index) |
| 888 return E_INVALIDARG; | 899 return E_INVALIDARG; |
| 889 | 900 |
| 890 int columns; | 901 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); |
| 891 int rows; | 902 if (cell_index < 0) |
| 892 if (!GetIntAttribute(WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || | 903 return E_INVALIDARG; |
| 893 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) || | 904 if (cell_index >= cell_id_count) |
| 894 columns <= 0 || | |
| 895 rows <= 0) { | |
| 896 return S_FALSE; | 905 return S_FALSE; |
| 906 |
| 907 int cell_id = unique_cell_ids_[cell_index]; |
| 908 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 909 manager_->GetFromRendererID(cell_id)); |
| 910 int cell_row_index; |
| 911 if (cell && |
| 912 cell->GetIntAttribute( |
| 913 WebAccessibility::ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) { |
| 914 *row_index = cell_row_index; |
| 915 return S_OK; |
| 897 } | 916 } |
| 898 | 917 |
| 899 if (cell_index < 0 || cell_index >= columns * rows) | 918 return S_FALSE; |
| 900 return E_INVALIDARG; | |
| 901 | |
| 902 *row_index = cell_index / columns; | |
| 903 | |
| 904 return S_OK; | |
| 905 } | 919 } |
| 906 | 920 |
| 907 STDMETHODIMP BrowserAccessibilityWin::get_selectedChildren( | 921 STDMETHODIMP BrowserAccessibilityWin::get_selectedChildren( |
| 908 long max_children, | 922 long max_children, |
| 909 long** children, | 923 long** children, |
| 910 long* n_children) { | 924 long* n_children) { |
| 911 if (!instance_active_) | 925 if (!instance_active_) |
| 912 return E_FAIL; | 926 return E_FAIL; |
| 913 | 927 |
| 914 if (!children || !n_children) | 928 if (!children || !n_children) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 long* column, | 1018 long* column, |
| 1005 long* row_extents, | 1019 long* row_extents, |
| 1006 long* column_extents, | 1020 long* column_extents, |
| 1007 boolean* is_selected) { | 1021 boolean* is_selected) { |
| 1008 if (!instance_active_) | 1022 if (!instance_active_) |
| 1009 return E_FAIL; | 1023 return E_FAIL; |
| 1010 | 1024 |
| 1011 if (!row || !column || !row_extents || !column_extents || !is_selected) | 1025 if (!row || !column || !row_extents || !column_extents || !is_selected) |
| 1012 return E_INVALIDARG; | 1026 return E_INVALIDARG; |
| 1013 | 1027 |
| 1014 int columns; | 1028 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); |
| 1015 int rows; | 1029 if (index < 0) |
| 1016 if (!GetIntAttribute(WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1030 return E_INVALIDARG; |
| 1017 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) || | 1031 if (index >= cell_id_count) |
| 1018 columns <= 0 || | |
| 1019 rows <= 0) { | |
| 1020 return S_FALSE; | 1032 return S_FALSE; |
| 1021 } | |
| 1022 | 1033 |
| 1023 if (index < 0 || index >= columns * rows) | 1034 int cell_id = unique_cell_ids_[index]; |
| 1024 return E_INVALIDARG; | |
| 1025 | |
| 1026 *column = index % columns; | |
| 1027 *row = index / columns; | |
| 1028 int cell_id = cell_ids_[index]; | |
| 1029 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1035 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1030 manager_->GetFromRendererID(cell_id)); | 1036 manager_->GetFromRendererID(cell_id)); |
| 1031 int rowspan; | 1037 int rowspan; |
| 1032 int colspan; | 1038 int colspan; |
| 1033 if (cell && | 1039 if (cell && |
| 1034 cell->GetIntAttribute( | 1040 cell->GetIntAttribute( |
| 1035 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && | 1041 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && |
| 1036 cell->GetIntAttribute( | 1042 cell->GetIntAttribute( |
| 1037 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && | 1043 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && |
| 1038 rowspan >= 1 && | 1044 rowspan >= 1 && |
| 1039 colspan >= 1) { | 1045 colspan >= 1) { |
| 1040 *row_extents = rowspan; | 1046 *row_extents = rowspan; |
| 1041 *column_extents = colspan; | 1047 *column_extents = colspan; |
| 1042 return S_OK; | 1048 return S_OK; |
| 1043 } | 1049 } |
| 1044 | 1050 |
| 1045 return S_FALSE; | 1051 return S_FALSE; |
| 1046 } | 1052 } |
| 1047 | 1053 |
| 1048 // | 1054 // |
| 1055 // IAccessibleTable2 methods. |
| 1056 // |
| 1057 |
| 1058 STDMETHODIMP BrowserAccessibilityWin::get_cellAt( |
| 1059 long row, |
| 1060 long column, |
| 1061 IUnknown** cell) { |
| 1062 return get_accessibleAt(row, column, cell); |
| 1063 } |
| 1064 |
| 1065 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedCells(long* cell_count) { |
| 1066 return get_nSelectedChildren(cell_count); |
| 1067 } |
| 1068 |
| 1069 STDMETHODIMP BrowserAccessibilityWin::get_selectedCells( |
| 1070 IUnknown*** cells, |
| 1071 long* n_selected_cells) { |
| 1072 if (!instance_active_) |
| 1073 return E_FAIL; |
| 1074 |
| 1075 if (!cells || !n_selected_cells) |
| 1076 return E_INVALIDARG; |
| 1077 |
| 1078 *n_selected_cells = 0; |
| 1079 return S_OK; |
| 1080 } |
| 1081 |
| 1082 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns( |
| 1083 long** columns, |
| 1084 long* n_columns) { |
| 1085 if (!instance_active_) |
| 1086 return E_FAIL; |
| 1087 |
| 1088 if (!columns || !n_columns) |
| 1089 return E_INVALIDARG; |
| 1090 |
| 1091 *n_columns = 0; |
| 1092 return S_OK; |
| 1093 } |
| 1094 |
| 1095 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows( |
| 1096 long** rows, |
| 1097 long* n_rows) { |
| 1098 if (!instance_active_) |
| 1099 return E_FAIL; |
| 1100 |
| 1101 if (!rows || !n_rows) |
| 1102 return E_INVALIDARG; |
| 1103 |
| 1104 *n_rows = 0; |
| 1105 return S_OK; |
| 1106 } |
| 1107 |
| 1108 |
| 1109 // |
| 1049 // IAccessibleTableCell methods. | 1110 // IAccessibleTableCell methods. |
| 1050 // | 1111 // |
| 1051 | 1112 |
| 1052 STDMETHODIMP BrowserAccessibilityWin::get_columnExtent( | 1113 STDMETHODIMP BrowserAccessibilityWin::get_columnExtent( |
| 1053 long* n_columns_spanned) { | 1114 long* n_columns_spanned) { |
| 1054 if (!instance_active_) | 1115 if (!instance_active_) |
| 1055 return E_FAIL; | 1116 return E_FAIL; |
| 1056 | 1117 |
| 1057 if (!n_columns_spanned) | 1118 if (!n_columns_spanned) |
| 1058 return E_INVALIDARG; | 1119 return E_INVALIDARG; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 } | 1352 } |
| 1292 | 1353 |
| 1293 STDMETHODIMP BrowserAccessibilityWin::get_table( | 1354 STDMETHODIMP BrowserAccessibilityWin::get_table( |
| 1294 IUnknown** table) { | 1355 IUnknown** table) { |
| 1295 if (!instance_active_) | 1356 if (!instance_active_) |
| 1296 return E_FAIL; | 1357 return E_FAIL; |
| 1297 | 1358 |
| 1298 if (!table) | 1359 if (!table) |
| 1299 return E_INVALIDARG; | 1360 return E_INVALIDARG; |
| 1300 | 1361 |
| 1362 |
| 1363 int row; |
| 1364 int column; |
| 1365 GetIntAttribute(WebAccessibility::ATTR_TABLE_CELL_ROW_INDEX, &row); |
| 1366 GetIntAttribute(WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX, &column); |
| 1367 |
| 1301 BrowserAccessibility* find_table = parent(); | 1368 BrowserAccessibility* find_table = parent(); |
| 1302 while (find_table && find_table->role() != WebAccessibility::ROLE_TABLE) | 1369 while (find_table && find_table->role() != WebAccessibility::ROLE_TABLE) |
| 1303 find_table = find_table->parent(); | 1370 find_table = find_table->parent(); |
| 1304 if (!find_table) | 1371 if (!find_table) |
| 1305 return S_FALSE; | 1372 return S_FALSE; |
| 1306 | 1373 |
| 1307 *table = static_cast<IAccessible*>( | 1374 *table = static_cast<IAccessibleTable*>( |
| 1308 static_cast<BrowserAccessibilityWin*>(find_table)->NewReference()); | 1375 static_cast<BrowserAccessibilityWin*>(find_table)->NewReference()); |
| 1309 | 1376 |
| 1310 return S_OK; | 1377 return S_OK; |
| 1311 } | 1378 } |
| 1312 | 1379 |
| 1313 // | 1380 // |
| 1314 // IAccessibleText methods. | 1381 // IAccessibleText methods. |
| 1315 // | 1382 // |
| 1316 | 1383 |
| 1317 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { | 1384 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 return S_FALSE; | 1586 return S_FALSE; |
| 1520 } | 1587 } |
| 1521 | 1588 |
| 1522 const string16& text_str = TextForIAccessibleText(); | 1589 const string16& text_str = TextForIAccessibleText(); |
| 1523 | 1590 |
| 1524 *start_offset = offset; | 1591 *start_offset = offset; |
| 1525 *end_offset = FindBoundary(text_str, boundary_type, offset, 1); | 1592 *end_offset = FindBoundary(text_str, boundary_type, offset, 1); |
| 1526 return get_text(*start_offset, *end_offset, text); | 1593 return get_text(*start_offset, *end_offset, text); |
| 1527 } | 1594 } |
| 1528 | 1595 |
| 1596 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { |
| 1597 if (!instance_active_) |
| 1598 return E_FAIL; |
| 1599 |
| 1600 if (!new_text) |
| 1601 return E_INVALIDARG; |
| 1602 |
| 1603 string16 text = TextForIAccessibleText(); |
| 1604 |
| 1605 new_text->text = SysAllocString(text.c_str()); |
| 1606 new_text->start = 0; |
| 1607 new_text->end = static_cast<long>(text.size()); |
| 1608 return S_OK; |
| 1609 } |
| 1610 |
| 1611 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { |
| 1612 if (!instance_active_) |
| 1613 return E_FAIL; |
| 1614 |
| 1615 if (!old_text) |
| 1616 return E_INVALIDARG; |
| 1617 |
| 1618 old_text->text = SysAllocString(old_text_.c_str()); |
| 1619 old_text->start = 0; |
| 1620 old_text->end = static_cast<long>(old_text_.size()); |
| 1621 return S_OK; |
| 1622 } |
| 1623 |
| 1624 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( |
| 1625 LONG x, LONG y, enum IA2CoordinateType coord_type, LONG* offset) { |
| 1626 if (!instance_active_) |
| 1627 return E_FAIL; |
| 1628 |
| 1629 if (!offset) |
| 1630 return E_INVALIDARG; |
| 1631 |
| 1632 // TODO(dmazzoni): implement this. We're returning S_OK for now so that |
| 1633 // screen readers still return partially accurate results rather than |
| 1634 // completely failing. |
| 1635 *offset = 0; |
| 1636 return S_OK; |
| 1637 } |
| 1638 |
| 1639 // |
| 1640 // IAccessibleValue methods. |
| 1641 // |
| 1642 |
| 1643 STDMETHODIMP BrowserAccessibilityWin::get_currentValue(VARIANT* value) { |
| 1644 if (!instance_active_) |
| 1645 return E_FAIL; |
| 1646 |
| 1647 if (!value) |
| 1648 return E_INVALIDARG; |
| 1649 |
| 1650 float float_val; |
| 1651 if (GetFloatAttribute(WebAccessibility::ATTR_VALUE_FOR_RANGE, &float_val)) { |
| 1652 value->vt = VT_R8; |
| 1653 value->dblVal = float_val; |
| 1654 return S_OK; |
| 1655 } |
| 1656 |
| 1657 value->vt = VT_EMPTY; |
| 1658 return S_FALSE; |
| 1659 } |
| 1660 |
| 1661 STDMETHODIMP BrowserAccessibilityWin::get_minimumValue(VARIANT* value) { |
| 1662 if (!instance_active_) |
| 1663 return E_FAIL; |
| 1664 |
| 1665 if (!value) |
| 1666 return E_INVALIDARG; |
| 1667 |
| 1668 float float_val; |
| 1669 if (GetFloatAttribute(WebAccessibility::ATTR_MIN_VALUE_FOR_RANGE, |
| 1670 &float_val)) { |
| 1671 value->vt = VT_R8; |
| 1672 value->dblVal = float_val; |
| 1673 return S_OK; |
| 1674 } |
| 1675 |
| 1676 value->vt = VT_EMPTY; |
| 1677 return S_FALSE; |
| 1678 } |
| 1679 |
| 1680 STDMETHODIMP BrowserAccessibilityWin::get_maximumValue(VARIANT* value) { |
| 1681 if (!instance_active_) |
| 1682 return E_FAIL; |
| 1683 |
| 1684 if (!value) |
| 1685 return E_INVALIDARG; |
| 1686 |
| 1687 float float_val; |
| 1688 if (GetFloatAttribute(WebAccessibility::ATTR_MAX_VALUE_FOR_RANGE, |
| 1689 &float_val)) { |
| 1690 value->vt = VT_R8; |
| 1691 value->dblVal = float_val; |
| 1692 return S_OK; |
| 1693 } |
| 1694 |
| 1695 value->vt = VT_EMPTY; |
| 1696 return S_FALSE; |
| 1697 } |
| 1698 |
| 1699 STDMETHODIMP BrowserAccessibilityWin::setCurrentValue(VARIANT new_value) { |
| 1700 return E_NOTIMPL; |
| 1701 } |
| 1702 |
| 1529 // | 1703 // |
| 1530 // ISimpleDOMDocument methods. | 1704 // ISimpleDOMDocument methods. |
| 1531 // | 1705 // |
| 1532 | 1706 |
| 1533 STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) { | 1707 STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) { |
| 1534 if (!instance_active_) | 1708 if (!instance_active_) |
| 1535 return E_FAIL; | 1709 return E_FAIL; |
| 1536 | 1710 |
| 1537 if (!url) | 1711 if (!url) |
| 1538 return E_INVALIDARG; | 1712 return E_INVALIDARG; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 | 2020 |
| 1847 // | 2021 // |
| 1848 // IServiceProvider methods. | 2022 // IServiceProvider methods. |
| 1849 // | 2023 // |
| 1850 | 2024 |
| 1851 STDMETHODIMP BrowserAccessibilityWin::QueryService( | 2025 STDMETHODIMP BrowserAccessibilityWin::QueryService( |
| 1852 REFGUID guidService, REFIID riid, void** object) { | 2026 REFGUID guidService, REFIID riid, void** object) { |
| 1853 if (!instance_active_) | 2027 if (!instance_active_) |
| 1854 return E_FAIL; | 2028 return E_FAIL; |
| 1855 | 2029 |
| 1856 if (guidService == IID_IAccessibleTable) { | |
| 1857 printf("iatable"); | |
| 1858 } | |
| 1859 if (guidService == IID_IAccessibleTableCell) { | |
| 1860 printf("iatable"); | |
| 1861 } | |
| 1862 | |
| 1863 if (guidService == IID_IAccessible || | 2030 if (guidService == IID_IAccessible || |
| 1864 guidService == IID_IAccessible2 || | 2031 guidService == IID_IAccessible2 || |
| 1865 guidService == IID_IAccessibleImage || | 2032 guidService == IID_IAccessibleImage || |
| 1866 guidService == IID_IAccessibleTable || | 2033 guidService == IID_IAccessibleTable || |
| 2034 guidService == IID_IAccessibleTable2 || |
| 1867 guidService == IID_IAccessibleTableCell || | 2035 guidService == IID_IAccessibleTableCell || |
| 1868 guidService == IID_IAccessibleText || | 2036 guidService == IID_IAccessibleText || |
| 2037 guidService == IID_IAccessibleValue || |
| 1869 guidService == IID_ISimpleDOMDocument || | 2038 guidService == IID_ISimpleDOMDocument || |
| 1870 guidService == IID_ISimpleDOMNode || | 2039 guidService == IID_ISimpleDOMNode || |
| 1871 guidService == IID_ISimpleDOMText || | 2040 guidService == IID_ISimpleDOMText || |
| 1872 guidService == GUID_ISimpleDOM) { | 2041 guidService == GUID_ISimpleDOM) { |
| 1873 return QueryInterface(riid, object); | 2042 return QueryInterface(riid, object); |
| 1874 } | 2043 } |
| 1875 | 2044 |
| 1876 *object = NULL; | 2045 *object = NULL; |
| 1877 return E_FAIL; | 2046 return E_FAIL; |
| 1878 } | 2047 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1889 if (iid == IID_IAccessibleText) { | 2058 if (iid == IID_IAccessibleText) { |
| 1890 if (ia_role_ != ROLE_SYSTEM_LINK && ia_role_ != ROLE_SYSTEM_TEXT) { | 2059 if (ia_role_ != ROLE_SYSTEM_LINK && ia_role_ != ROLE_SYSTEM_TEXT) { |
| 1891 *object = NULL; | 2060 *object = NULL; |
| 1892 return E_NOINTERFACE; | 2061 return E_NOINTERFACE; |
| 1893 } | 2062 } |
| 1894 } else if (iid == IID_IAccessibleImage) { | 2063 } else if (iid == IID_IAccessibleImage) { |
| 1895 if (ia_role_ != ROLE_SYSTEM_GRAPHIC) { | 2064 if (ia_role_ != ROLE_SYSTEM_GRAPHIC) { |
| 1896 *object = NULL; | 2065 *object = NULL; |
| 1897 return E_NOINTERFACE; | 2066 return E_NOINTERFACE; |
| 1898 } | 2067 } |
| 1899 } else if (iid == IID_IAccessibleTable) { | 2068 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { |
| 1900 if (ia_role_ != ROLE_SYSTEM_TABLE) { | 2069 if (ia_role_ != ROLE_SYSTEM_TABLE) { |
| 1901 *object = NULL; | 2070 *object = NULL; |
| 1902 return E_NOINTERFACE; | 2071 return E_NOINTERFACE; |
| 1903 } | 2072 } |
| 1904 } else if (iid == IID_IAccessibleTableCell) { | 2073 } else if (iid == IID_IAccessibleTableCell) { |
| 1905 if (ia_role_ != ROLE_SYSTEM_CELL) { | 2074 if (ia_role_ != ROLE_SYSTEM_CELL) { |
| 1906 *object = NULL; | 2075 *object = NULL; |
| 1907 return E_NOINTERFACE; | 2076 return E_NOINTERFACE; |
| 1908 } | 2077 } |
| 2078 } else if (iid == IID_IAccessibleValue) { |
| 2079 if (ia_role_ != ROLE_SYSTEM_PROGRESSBAR && |
| 2080 ia_role_ != ROLE_SYSTEM_SCROLLBAR && |
| 2081 ia_role_ != ROLE_SYSTEM_SLIDER) { |
| 2082 *object = NULL; |
| 2083 return E_NOINTERFACE; |
| 2084 } |
| 1909 } else if (iid == IID_ISimpleDOMDocument) { | 2085 } else if (iid == IID_ISimpleDOMDocument) { |
| 1910 if (ia_role_ != ROLE_SYSTEM_DOCUMENT) { | 2086 if (ia_role_ != ROLE_SYSTEM_DOCUMENT) { |
| 1911 *object = NULL; | 2087 *object = NULL; |
| 1912 return E_NOINTERFACE; | 2088 return E_NOINTERFACE; |
| 1913 } | 2089 } |
| 1914 } | 2090 } |
| 1915 | 2091 |
| 1916 return CComObjectRootBase::InternalQueryInterface( | 2092 return CComObjectRootBase::InternalQueryInterface( |
| 1917 this_ptr, entries, iid, object); | 2093 this_ptr, entries, iid, object); |
| 1918 } | 2094 } |
| 1919 | 2095 |
| 1920 // | 2096 // |
| 1921 // Private methods. | 2097 // Private methods. |
| 1922 // | 2098 // |
| 1923 | 2099 |
| 1924 // Initialize this object and mark it as active. | 2100 // Initialize this object and mark it as active. |
| 1925 void BrowserAccessibilityWin::Initialize() { | 2101 void BrowserAccessibilityWin::Initialize() { |
| 1926 BrowserAccessibility::Initialize(); | 2102 BrowserAccessibility::Initialize(); |
| 1927 | 2103 |
| 1928 InitRoleAndState(); | 2104 InitRoleAndState(); |
| 1929 | 2105 |
| 1930 // Expose headings levels to NVDA with the "level" object attribute. | 2106 // Expose headings levels with the "level" attribute. |
| 1931 if (role_ == WebAccessibility::ROLE_HEADING && role_name_.size() == 2 && | 2107 if (role_ == WebAccessibility::ROLE_HEADING && role_name_.size() == 2 && |
| 1932 IsAsciiDigit(role_name_[1])) { | 2108 IsAsciiDigit(role_name_[1])) { |
| 1933 html_attributes_.push_back(std::make_pair(L"level", role_name_.substr(1))); | 2109 ia2_attributes_.push_back(string16(L"level:") + role_name_.substr(1)); |
| 1934 } | 2110 } |
| 1935 | 2111 |
| 1936 // Expose the "display" object attribute. | 2112 // Expose the "display" and "tag" attributes. |
| 1937 string16 display; | 2113 StringAttributeToIA2(WebAccessibility::ATTR_DISPLAY, "display"); |
| 1938 if (GetStringAttribute(WebAccessibility::ATTR_DISPLAY, &display)) | 2114 StringAttributeToIA2(WebAccessibility::ATTR_HTML_TAG, "tag"); |
| 1939 html_attributes_.push_back(std::make_pair(L"display", display)); | 2115 StringAttributeToIA2(WebAccessibility::ATTR_ROLE, "xml-roles"); |
| 2116 |
| 2117 // Expose "level" attribute for tree nodes. |
| 2118 IntAttributeToIA2(WebAccessibility::ATTR_HIERARCHICAL_LEVEL, "level"); |
| 2119 |
| 2120 // Expose live region attributes. |
| 2121 StringAttributeToIA2(WebAccessibility::ATTR_LIVE_STATUS, "live"); |
| 2122 StringAttributeToIA2(WebAccessibility::ATTR_LIVE_RELEVANT, "relevant"); |
| 2123 BoolAttributeToIA2(WebAccessibility::ATTR_LIVE_ATOMIC, "atomic"); |
| 2124 BoolAttributeToIA2(WebAccessibility::ATTR_LIVE_BUSY, "busy"); |
| 2125 |
| 2126 // Expose container live region attributes. |
| 2127 StringAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_STATUS, |
| 2128 "container-live"); |
| 2129 StringAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_RELEVANT, |
| 2130 "container-relevant"); |
| 2131 BoolAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_ATOMIC, |
| 2132 "container-atomic"); |
| 2133 BoolAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_BUSY, |
| 2134 "container-busy"); |
| 2135 |
| 2136 // Expose slider value. |
| 2137 if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR || |
| 2138 ia_role_ == ROLE_SYSTEM_SCROLLBAR || |
| 2139 ia_role_ == ROLE_SYSTEM_SLIDER) { |
| 2140 float fval; |
| 2141 if (value_.empty() && |
| 2142 GetFloatAttribute(WebAccessibility::ATTR_VALUE_FOR_RANGE, &fval)) { |
| 2143 // TODO(dmazzoni): Use ICU to localize this? |
| 2144 value_ = UTF8ToUTF16(base::DoubleToString(fval)); |
| 2145 } |
| 2146 ia2_attributes_.push_back(L"valuetext:" + value_); |
| 2147 } |
| 2148 |
| 2149 // Expose table cell index. |
| 2150 if (ia_role_ == ROLE_SYSTEM_CELL) { |
| 2151 BrowserAccessibility* table = parent(); |
| 2152 while (table && table->role() != WebAccessibility::ROLE_TABLE) |
| 2153 table = table->parent(); |
| 2154 if (table) { |
| 2155 const std::vector<int32>& unique_cell_ids = table->unique_cell_ids(); |
| 2156 int index = -1; |
| 2157 for (size_t i = 0; i < unique_cell_ids.size(); i++) { |
| 2158 if (unique_cell_ids[i] == renderer_id_) { |
| 2159 index = static_cast<int>(i); |
| 2160 break; |
| 2161 } |
| 2162 } |
| 2163 if (index >= 0) { |
| 2164 ia2_attributes_.push_back(string16(L"table-cell-index:") + |
| 2165 base::IntToString16(index)); |
| 2166 } |
| 2167 } |
| 2168 } |
| 1940 | 2169 |
| 1941 // If this is static text, put the text in the name rather than the value. | 2170 // If this is static text, put the text in the name rather than the value. |
| 1942 if (role_ == WebAccessibility::ROLE_STATIC_TEXT && name_.empty()) | 2171 if (role_ == WebAccessibility::ROLE_STATIC_TEXT && name_.empty()) |
| 1943 name_.swap(value_); | 2172 name_.swap(value_); |
| 1944 | 2173 |
| 1945 // If this object doesn't have a name but it does have a description, | 2174 // If this object doesn't have a name but it does have a description, |
| 1946 // use the description as its name - because some screen readers only | 2175 // use the description as its name - because some screen readers only |
| 1947 // announce the name. | 2176 // announce the name. |
| 1948 if (name_.empty()) | 2177 if (name_.empty()) |
| 1949 GetStringAttribute(WebAccessibility::ATTR_DESCRIPTION, &name_); | 2178 GetStringAttribute(WebAccessibility::ATTR_DESCRIPTION, &name_); |
| 1950 | 2179 |
| 1951 // If this doesn't have a value and is linked then set its value to the url | 2180 // If this doesn't have a value and is linked then set its value to the url |
| 1952 // attribute. This allows screen readers to read an empty link's destination. | 2181 // attribute. This allows screen readers to read an empty link's destination. |
| 1953 string16 url; | 2182 string16 url; |
| 1954 if (value_.empty() && (ia_state_ & STATE_SYSTEM_LINKED)) | 2183 if (value_.empty() && (ia_state_ & STATE_SYSTEM_LINKED)) |
| 1955 GetStringAttribute(WebAccessibility::ATTR_URL, &value_); | 2184 GetStringAttribute(WebAccessibility::ATTR_URL, &value_); |
| 1956 } | 2185 } |
| 1957 | 2186 |
| 2187 void BrowserAccessibilityWin::SendNodeUpdateEvents() { |
| 2188 // Fire an event when an alert first appears. |
| 2189 if (role_ == WebAccessibility::ROLE_ALERT && first_time_) |
| 2190 manager_->NotifyAccessibilityEvent(ViewHostMsg_AccEvent::ALERT, this); |
| 2191 |
| 2192 // Fire events if text has changed. |
| 2193 string16 text = TextForIAccessibleText(); |
| 2194 if (previous_text_ != text) { |
| 2195 if (!previous_text_.empty() && !text.empty()) { |
| 2196 manager_->NotifyAccessibilityEvent( |
| 2197 ViewHostMsg_AccEvent::OBJECT_SHOW, this); |
| 2198 } |
| 2199 |
| 2200 old_text_ = previous_text_; |
| 2201 previous_text_ = text; |
| 2202 } |
| 2203 |
| 2204 first_time_ = false; |
| 2205 } |
| 2206 |
| 1958 void BrowserAccessibilityWin::NativeAddReference() { | 2207 void BrowserAccessibilityWin::NativeAddReference() { |
| 1959 AddRef(); | 2208 AddRef(); |
| 1960 } | 2209 } |
| 1961 | 2210 |
| 1962 void BrowserAccessibilityWin::NativeReleaseReference() { | 2211 void BrowserAccessibilityWin::NativeReleaseReference() { |
| 1963 Release(); | 2212 Release(); |
| 1964 } | 2213 } |
| 1965 | 2214 |
| 1966 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { | 2215 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { |
| 1967 AddRef(); | 2216 AddRef(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1992 | 2241 |
| 1993 if (str.empty()) | 2242 if (str.empty()) |
| 1994 return S_FALSE; | 2243 return S_FALSE; |
| 1995 | 2244 |
| 1996 *value_bstr = SysAllocString(str.c_str()); | 2245 *value_bstr = SysAllocString(str.c_str()); |
| 1997 DCHECK(*value_bstr); | 2246 DCHECK(*value_bstr); |
| 1998 | 2247 |
| 1999 return S_OK; | 2248 return S_OK; |
| 2000 } | 2249 } |
| 2001 | 2250 |
| 2251 void BrowserAccessibilityWin::StringAttributeToIA2( |
| 2252 WebAccessibility::StringAttribute attribute, const char* ia2_attr) { |
| 2253 string16 value; |
| 2254 if (GetStringAttribute(attribute, &value)) |
| 2255 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + value); |
| 2256 } |
| 2257 |
| 2258 void BrowserAccessibilityWin::BoolAttributeToIA2( |
| 2259 WebAccessibility::BoolAttribute attribute, const char* ia2_attr) { |
| 2260 bool value; |
| 2261 if (GetBoolAttribute(attribute, &value)) { |
| 2262 ia2_attributes_.push_back((ASCIIToUTF16(ia2_attr) + L":") + |
| 2263 (value ? L"true" : L"false")); |
| 2264 } |
| 2265 } |
| 2266 |
| 2267 void BrowserAccessibilityWin::IntAttributeToIA2( |
| 2268 WebAccessibility::IntAttribute attribute, const char* ia2_attr) { |
| 2269 int value; |
| 2270 if (GetIntAttribute(attribute, &value)) |
| 2271 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + |
| 2272 base::IntToString16(value)); |
| 2273 } |
| 2274 |
| 2002 string16 BrowserAccessibilityWin::Escape(const string16& str) { | 2275 string16 BrowserAccessibilityWin::Escape(const string16& str) { |
| 2003 return EscapeQueryParamValueUTF8(str, false); | 2276 return EscapeQueryParamValueUTF8(str, false); |
| 2004 } | 2277 } |
| 2005 | 2278 |
| 2006 const string16& BrowserAccessibilityWin::TextForIAccessibleText() { | 2279 const string16& BrowserAccessibilityWin::TextForIAccessibleText() { |
| 2007 if (role_ == WebAccessibility::ROLE_TEXT_FIELD || | 2280 if (IsEditableText()) { |
| 2008 role_ == WebAccessibility::ROLE_TEXTAREA) { | |
| 2009 return value_; | 2281 return value_; |
| 2010 } else { | 2282 } else { |
| 2011 return name_; | 2283 return name_; |
| 2012 } | 2284 } |
| 2013 } | 2285 } |
| 2014 | 2286 |
| 2015 void BrowserAccessibilityWin::HandleSpecialTextOffset( | 2287 void BrowserAccessibilityWin::HandleSpecialTextOffset( |
| 2016 const string16& text, LONG* offset) { | 2288 const string16& text, LONG* offset) { |
| 2017 if (*offset == IA2_TEXT_OFFSET_LENGTH) { | 2289 if (*offset == IA2_TEXT_OFFSET_LENGTH) { |
| 2018 *offset = static_cast<LONG>(text.size()); | 2290 *offset = static_cast<LONG>(text.size()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2105 } | 2377 } |
| 2106 | 2378 |
| 2107 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( | 2379 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( |
| 2108 int32 renderer_id) { | 2380 int32 renderer_id) { |
| 2109 return manager_->GetFromRendererID(renderer_id)->toBrowserAccessibilityWin(); | 2381 return manager_->GetFromRendererID(renderer_id)->toBrowserAccessibilityWin(); |
| 2110 } | 2382 } |
| 2111 | 2383 |
| 2112 void BrowserAccessibilityWin::InitRoleAndState() { | 2384 void BrowserAccessibilityWin::InitRoleAndState() { |
| 2113 ia_state_ = 0; | 2385 ia_state_ = 0; |
| 2114 ia2_state_ = IA2_STATE_OPAQUE; | 2386 ia2_state_ = IA2_STATE_OPAQUE; |
| 2387 ia2_attributes_.clear(); |
| 2115 | 2388 |
| 2389 if ((state_ >> WebAccessibility::STATE_BUSY) & 1) |
| 2390 ia_state_|= STATE_SYSTEM_BUSY; |
| 2116 if ((state_ >> WebAccessibility::STATE_CHECKED) & 1) | 2391 if ((state_ >> WebAccessibility::STATE_CHECKED) & 1) |
| 2117 ia_state_ |= STATE_SYSTEM_CHECKED; | 2392 ia_state_ |= STATE_SYSTEM_CHECKED; |
| 2118 if ((state_ >> WebAccessibility::STATE_COLLAPSED) & 1) | 2393 if ((state_ >> WebAccessibility::STATE_COLLAPSED) & 1) |
| 2119 ia_state_|= STATE_SYSTEM_COLLAPSED; | 2394 ia_state_|= STATE_SYSTEM_COLLAPSED; |
| 2120 if ((state_ >> WebAccessibility::STATE_EXPANDED) & 1) | 2395 if ((state_ >> WebAccessibility::STATE_EXPANDED) & 1) |
| 2121 ia_state_|= STATE_SYSTEM_EXPANDED; | 2396 ia_state_|= STATE_SYSTEM_EXPANDED; |
| 2122 if ((state_ >> WebAccessibility::STATE_FOCUSABLE) & 1) | 2397 if ((state_ >> WebAccessibility::STATE_FOCUSABLE) & 1) |
| 2123 ia_state_|= STATE_SYSTEM_FOCUSABLE; | 2398 ia_state_|= STATE_SYSTEM_FOCUSABLE; |
| 2124 if ((state_ >> WebAccessibility::STATE_HASPOPUP) & 1) | 2399 if ((state_ >> WebAccessibility::STATE_HASPOPUP) & 1) |
| 2125 ia_state_|= STATE_SYSTEM_HASPOPUP; | 2400 ia_state_|= STATE_SYSTEM_HASPOPUP; |
| 2126 if ((state_ >> WebAccessibility::STATE_HOTTRACKED) & 1) | 2401 if ((state_ >> WebAccessibility::STATE_HOTTRACKED) & 1) |
| 2127 ia_state_|= STATE_SYSTEM_HOTTRACKED; | 2402 ia_state_|= STATE_SYSTEM_HOTTRACKED; |
| 2128 if ((state_ >> WebAccessibility::STATE_INDETERMINATE) & 1) | 2403 if ((state_ >> WebAccessibility::STATE_INDETERMINATE) & 1) |
| 2129 ia_state_|= STATE_SYSTEM_INDETERMINATE; | 2404 ia_state_|= STATE_SYSTEM_INDETERMINATE; |
| 2130 if ((state_ >> WebAccessibility::STATE_INVISIBLE) & 1) | 2405 if ((state_ >> WebAccessibility::STATE_INVISIBLE) & 1) |
| 2131 ia_state_|= STATE_SYSTEM_INVISIBLE; | 2406 ia_state_|= STATE_SYSTEM_INVISIBLE; |
| 2132 if ((state_ >> WebAccessibility::STATE_LINKED) & 1) | 2407 if ((state_ >> WebAccessibility::STATE_LINKED) & 1) |
| 2133 ia_state_|= STATE_SYSTEM_LINKED; | 2408 ia_state_|= STATE_SYSTEM_LINKED; |
| 2134 if ((state_ >> WebAccessibility::STATE_MULTISELECTABLE) & 1) | 2409 if ((state_ >> WebAccessibility::STATE_MULTISELECTABLE) & 1) |
| 2135 ia_state_|= STATE_SYSTEM_MULTISELECTABLE; | 2410 ia_state_|= STATE_SYSTEM_MULTISELECTABLE; |
| 2136 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. | 2411 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. |
| 2137 if ((state_ >> WebAccessibility::STATE_OFFSCREEN) & 1) | 2412 if ((state_ >> WebAccessibility::STATE_OFFSCREEN) & 1) |
| 2138 ia_state_|= STATE_SYSTEM_OFFSCREEN; | 2413 ia_state_|= STATE_SYSTEM_OFFSCREEN; |
| 2139 if ((state_ >> WebAccessibility::STATE_PRESSED) & 1) | 2414 if ((state_ >> WebAccessibility::STATE_PRESSED) & 1) |
| 2140 ia_state_|= STATE_SYSTEM_PRESSED; | 2415 ia_state_|= STATE_SYSTEM_PRESSED; |
| 2141 if ((state_ >> WebAccessibility::STATE_PROTECTED) & 1) | 2416 if ((state_ >> WebAccessibility::STATE_PROTECTED) & 1) |
| 2142 ia_state_|= STATE_SYSTEM_PROTECTED; | 2417 ia_state_|= STATE_SYSTEM_PROTECTED; |
| 2418 if ((state_ >> WebAccessibility::STATE_READONLY) & 1) |
| 2419 ia_state_|= STATE_SYSTEM_READONLY; |
| 2420 if ((state_ >> WebAccessibility::STATE_REQUIRED) & 1) |
| 2421 ia2_state_|= IA2_STATE_REQUIRED; |
| 2143 if ((state_ >> WebAccessibility::STATE_SELECTABLE) & 1) | 2422 if ((state_ >> WebAccessibility::STATE_SELECTABLE) & 1) |
| 2144 ia_state_|= STATE_SYSTEM_SELECTABLE; | 2423 ia_state_|= STATE_SYSTEM_SELECTABLE; |
| 2145 if ((state_ >> WebAccessibility::STATE_SELECTED) & 1) | 2424 if ((state_ >> WebAccessibility::STATE_SELECTED) & 1) |
| 2146 ia_state_|= STATE_SYSTEM_SELECTED; | 2425 ia_state_|= STATE_SYSTEM_SELECTED; |
| 2147 if ((state_ >> WebAccessibility::STATE_READONLY) & 1) | |
| 2148 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2149 if ((state_ >> WebAccessibility::STATE_TRAVERSED) & 1) | 2426 if ((state_ >> WebAccessibility::STATE_TRAVERSED) & 1) |
| 2150 ia_state_|= STATE_SYSTEM_TRAVERSED; | 2427 ia_state_|= STATE_SYSTEM_TRAVERSED; |
| 2151 if ((state_ >> WebAccessibility::STATE_BUSY) & 1) | |
| 2152 ia_state_|= STATE_SYSTEM_BUSY; | |
| 2153 if ((state_ >> WebAccessibility::STATE_UNAVAILABLE) & 1) | 2428 if ((state_ >> WebAccessibility::STATE_UNAVAILABLE) & 1) |
| 2154 ia_state_|= STATE_SYSTEM_UNAVAILABLE; | 2429 ia_state_|= STATE_SYSTEM_UNAVAILABLE; |
| 2430 if ((state_ >> WebAccessibility::STATE_VERTICAL) & 1) { |
| 2431 ia2_state_|= IA2_STATE_VERTICAL; |
| 2432 } else { |
| 2433 ia2_state_|= IA2_STATE_HORIZONTAL; |
| 2434 } |
| 2435 if ((state_ >> WebAccessibility::STATE_VISITED) & 1) |
| 2436 ia_state_|= STATE_SYSTEM_TRAVERSED; |
| 2437 |
| 2438 string16 invalid; |
| 2439 if (GetHtmlAttribute("aria-invalid", &invalid)) |
| 2440 ia2_state_|= IA2_STATE_INVALID_ENTRY; |
| 2441 |
| 2442 bool mixed = false; |
| 2443 GetBoolAttribute(WebAccessibility::ATTR_BUTTON_MIXED, &mixed); |
| 2444 if (mixed) |
| 2445 ia_state_|= STATE_SYSTEM_MIXED; |
| 2155 | 2446 |
| 2156 string16 html_tag; | 2447 string16 html_tag; |
| 2157 GetStringAttribute(WebAccessibility::ATTR_HTML_TAG, &html_tag); | 2448 GetStringAttribute(WebAccessibility::ATTR_HTML_TAG, &html_tag); |
| 2158 ia_role_ = 0; | 2449 ia_role_ = 0; |
| 2159 ia2_role_ = 0; | 2450 ia2_role_ = 0; |
| 2160 switch (role_) { | 2451 switch (role_) { |
| 2161 case WebAccessibility::ROLE_ALERT: | 2452 case WebAccessibility::ROLE_ALERT: |
| 2453 ia_role_ = ROLE_SYSTEM_ALERT; |
| 2454 break; |
| 2162 case WebAccessibility::ROLE_ALERT_DIALOG: | 2455 case WebAccessibility::ROLE_ALERT_DIALOG: |
| 2163 ia_role_ = ROLE_SYSTEM_ALERT; | 2456 ia_role_ = ROLE_SYSTEM_DIALOG; |
| 2164 break; | 2457 break; |
| 2165 case WebAccessibility::ROLE_APPLICATION: | 2458 case WebAccessibility::ROLE_APPLICATION: |
| 2166 ia_role_ = ROLE_SYSTEM_APPLICATION; | 2459 ia_role_ = ROLE_SYSTEM_APPLICATION; |
| 2167 break; | 2460 break; |
| 2168 case WebAccessibility::ROLE_ARTICLE: | 2461 case WebAccessibility::ROLE_ARTICLE: |
| 2169 ia_role_ = ROLE_SYSTEM_GROUPING; | 2462 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2170 ia2_role_ = IA2_ROLE_SECTION; | 2463 ia2_role_ = IA2_ROLE_SECTION; |
| 2464 ia_state_|= STATE_SYSTEM_READONLY; |
| 2171 break; | 2465 break; |
| 2172 case WebAccessibility::ROLE_BUSY_INDICATOR: | 2466 case WebAccessibility::ROLE_BUSY_INDICATOR: |
| 2173 ia_role_ = ROLE_SYSTEM_ANIMATION; | 2467 ia_role_ = ROLE_SYSTEM_ANIMATION; |
| 2468 ia_state_|= STATE_SYSTEM_READONLY; |
| 2174 break; | 2469 break; |
| 2175 case WebAccessibility::ROLE_BUTTON: | 2470 case WebAccessibility::ROLE_BUTTON: |
| 2176 ia_role_ = ROLE_SYSTEM_PUSHBUTTON; | 2471 ia_role_ = ROLE_SYSTEM_PUSHBUTTON; |
| 2472 ia_state_|= STATE_SYSTEM_READONLY; |
| 2177 break; | 2473 break; |
| 2178 case WebAccessibility::ROLE_CELL: | 2474 case WebAccessibility::ROLE_CELL: |
| 2179 ia_role_ = ROLE_SYSTEM_CELL; | 2475 ia_role_ = ROLE_SYSTEM_CELL; |
| 2476 ia_state_|= STATE_SYSTEM_READONLY; |
| 2180 break; | 2477 break; |
| 2181 case WebAccessibility::ROLE_CHECKBOX: | 2478 case WebAccessibility::ROLE_CHECKBOX: |
| 2182 ia_role_ = ROLE_SYSTEM_CHECKBUTTON; | 2479 ia_role_ = ROLE_SYSTEM_CHECKBUTTON; |
| 2183 break; | 2480 break; |
| 2184 case WebAccessibility::ROLE_COLOR_WELL: | 2481 case WebAccessibility::ROLE_COLOR_WELL: |
| 2185 ia_role_ = ROLE_SYSTEM_CLIENT; | 2482 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2186 ia2_role_ = IA2_ROLE_COLOR_CHOOSER; | 2483 ia2_role_ = IA2_ROLE_COLOR_CHOOSER; |
| 2187 break; | 2484 break; |
| 2188 case WebAccessibility::ROLE_COLUMN: | 2485 case WebAccessibility::ROLE_COLUMN: |
| 2189 ia_role_ = ROLE_SYSTEM_COLUMN; | 2486 ia_role_ = ROLE_SYSTEM_COLUMN; |
| 2487 ia_state_|= STATE_SYSTEM_READONLY; |
| 2190 break; | 2488 break; |
| 2191 case WebAccessibility::ROLE_COLUMN_HEADER: | 2489 case WebAccessibility::ROLE_COLUMN_HEADER: |
| 2192 ia_role_ = ROLE_SYSTEM_COLUMNHEADER; | 2490 ia_role_ = ROLE_SYSTEM_COLUMNHEADER; |
| 2491 ia_state_|= STATE_SYSTEM_READONLY; |
| 2193 break; | 2492 break; |
| 2194 case WebAccessibility::ROLE_COMBO_BOX: | 2493 case WebAccessibility::ROLE_COMBO_BOX: |
| 2195 ia_role_ = ROLE_SYSTEM_COMBOBOX; | 2494 ia_role_ = ROLE_SYSTEM_COMBOBOX; |
| 2196 break; | 2495 break; |
| 2197 case WebAccessibility::ROLE_DEFINITION_LIST_DEFINITION: | 2496 case WebAccessibility::ROLE_DEFINITION_LIST_DEFINITION: |
| 2198 role_name_ = html_tag; | 2497 role_name_ = html_tag; |
| 2199 ia2_role_ = IA2_ROLE_PARAGRAPH; | 2498 ia2_role_ = IA2_ROLE_PARAGRAPH; |
| 2499 ia_state_|= STATE_SYSTEM_READONLY; |
| 2200 break; | 2500 break; |
| 2201 case WebAccessibility::ROLE_DEFINITION_LIST_TERM: | 2501 case WebAccessibility::ROLE_DEFINITION_LIST_TERM: |
| 2202 ia_role_ = ROLE_SYSTEM_LISTITEM; | 2502 ia_role_ = ROLE_SYSTEM_LISTITEM; |
| 2503 ia_state_|= STATE_SYSTEM_READONLY; |
| 2203 break; | 2504 break; |
| 2204 case WebAccessibility::ROLE_DIALOG: | 2505 case WebAccessibility::ROLE_DIALOG: |
| 2205 ia_role_ = ROLE_SYSTEM_DIALOG; | 2506 ia_role_ = ROLE_SYSTEM_DIALOG; |
| 2507 ia_state_|= STATE_SYSTEM_READONLY; |
| 2206 break; | 2508 break; |
| 2207 case WebAccessibility::ROLE_DISCLOSURE_TRIANGLE: | 2509 case WebAccessibility::ROLE_DISCLOSURE_TRIANGLE: |
| 2208 ia_role_ = ROLE_SYSTEM_OUTLINEBUTTON; | 2510 ia_role_ = ROLE_SYSTEM_OUTLINEBUTTON; |
| 2511 ia_state_|= STATE_SYSTEM_READONLY; |
| 2209 break; | 2512 break; |
| 2210 case WebAccessibility::ROLE_DOCUMENT: | 2513 case WebAccessibility::ROLE_DOCUMENT: |
| 2211 case WebAccessibility::ROLE_WEB_AREA: | 2514 case WebAccessibility::ROLE_WEB_AREA: |
| 2212 ia_role_ = ROLE_SYSTEM_DOCUMENT; | 2515 ia_role_ = ROLE_SYSTEM_DOCUMENT; |
| 2213 ia_state_|= STATE_SYSTEM_READONLY; | 2516 ia_state_|= STATE_SYSTEM_READONLY; |
| 2214 ia_state_|= STATE_SYSTEM_FOCUSABLE; | 2517 ia_state_|= STATE_SYSTEM_FOCUSABLE; |
| 2215 break; | 2518 break; |
| 2216 case WebAccessibility::ROLE_EDITABLE_TEXT: | 2519 case WebAccessibility::ROLE_EDITABLE_TEXT: |
| 2217 ia_role_ = ROLE_SYSTEM_TEXT; | 2520 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2218 ia2_state_ |= IA2_STATE_SINGLE_LINE; | 2521 ia2_state_ |= IA2_STATE_SINGLE_LINE; |
| 2219 ia2_state_ |= IA2_STATE_EDITABLE; | 2522 ia2_state_ |= IA2_STATE_EDITABLE; |
| 2220 break; | 2523 break; |
| 2221 case WebAccessibility::ROLE_GRID: | 2524 case WebAccessibility::ROLE_GRID: |
| 2222 ia_role_ = ROLE_SYSTEM_TABLE; | 2525 ia_role_ = ROLE_SYSTEM_TABLE; |
| 2526 ia_state_|= STATE_SYSTEM_READONLY; |
| 2223 break; | 2527 break; |
| 2224 case WebAccessibility::ROLE_GROUP: | 2528 case WebAccessibility::ROLE_GROUP: |
| 2225 if (html_tag == L"li") { | 2529 if (html_tag == L"li") { |
| 2226 ia_role_ = ROLE_SYSTEM_LISTITEM; | 2530 ia_role_ = ROLE_SYSTEM_LISTITEM; |
| 2531 } else if (html_tag == L"form") { |
| 2532 role_name_ = html_tag; |
| 2533 ia2_role_ = IA2_ROLE_FORM; |
| 2534 } else if (html_tag == L"p") { |
| 2535 role_name_ = html_tag; |
| 2536 ia2_role_ = IA2_ROLE_PARAGRAPH; |
| 2227 } else { | 2537 } else { |
| 2228 if (html_tag.empty()) | 2538 if (html_tag.empty()) |
| 2229 role_name_ = L"div"; | 2539 role_name_ = L"div"; |
| 2230 else | 2540 else |
| 2231 role_name_ = html_tag; | 2541 role_name_ = html_tag; |
| 2232 ia2_role_ = IA2_ROLE_SECTION; | 2542 ia2_role_ = IA2_ROLE_SECTION; |
| 2233 } | 2543 } |
| 2544 ia_state_|= STATE_SYSTEM_READONLY; |
| 2234 break; | 2545 break; |
| 2235 case WebAccessibility::ROLE_GROW_AREA: | 2546 case WebAccessibility::ROLE_GROW_AREA: |
| 2236 ia_role_ = ROLE_SYSTEM_GRIP; | 2547 ia_role_ = ROLE_SYSTEM_GRIP; |
| 2548 ia_state_|= STATE_SYSTEM_READONLY; |
| 2237 break; | 2549 break; |
| 2238 case WebAccessibility::ROLE_HEADING: | 2550 case WebAccessibility::ROLE_HEADING: |
| 2239 role_name_ = html_tag; | 2551 role_name_ = html_tag; |
| 2240 ia2_role_ = IA2_ROLE_HEADING; | 2552 ia2_role_ = IA2_ROLE_HEADING; |
| 2553 ia_state_|= STATE_SYSTEM_READONLY; |
| 2241 break; | 2554 break; |
| 2242 case WebAccessibility::ROLE_IMAGE: | 2555 case WebAccessibility::ROLE_IMAGE: |
| 2243 ia_role_ = ROLE_SYSTEM_GRAPHIC; | 2556 ia_role_ = ROLE_SYSTEM_GRAPHIC; |
| 2557 ia_state_|= STATE_SYSTEM_READONLY; |
| 2244 break; | 2558 break; |
| 2245 case WebAccessibility::ROLE_IMAGE_MAP: | 2559 case WebAccessibility::ROLE_IMAGE_MAP: |
| 2246 role_name_ = html_tag; | 2560 role_name_ = html_tag; |
| 2247 ia2_role_ = IA2_ROLE_IMAGE_MAP; | 2561 ia2_role_ = IA2_ROLE_IMAGE_MAP; |
| 2562 ia_state_|= STATE_SYSTEM_READONLY; |
| 2248 break; | 2563 break; |
| 2249 case WebAccessibility::ROLE_IMAGE_MAP_LINK: | 2564 case WebAccessibility::ROLE_IMAGE_MAP_LINK: |
| 2250 ia_role_ = ROLE_SYSTEM_LINK; | 2565 ia_role_ = ROLE_SYSTEM_LINK; |
| 2251 ia_state_|= STATE_SYSTEM_LINKED; | 2566 ia_state_|= STATE_SYSTEM_LINKED; |
| 2567 ia_state_|= STATE_SYSTEM_READONLY; |
| 2252 break; | 2568 break; |
| 2253 case WebAccessibility::ROLE_LANDMARK_APPLICATION: | 2569 case WebAccessibility::ROLE_LANDMARK_APPLICATION: |
| 2254 case WebAccessibility::ROLE_LANDMARK_BANNER: | 2570 case WebAccessibility::ROLE_LANDMARK_BANNER: |
| 2255 case WebAccessibility::ROLE_LANDMARK_COMPLEMENTARY: | 2571 case WebAccessibility::ROLE_LANDMARK_COMPLEMENTARY: |
| 2256 case WebAccessibility::ROLE_LANDMARK_CONTENTINFO: | 2572 case WebAccessibility::ROLE_LANDMARK_CONTENTINFO: |
| 2257 case WebAccessibility::ROLE_LANDMARK_MAIN: | 2573 case WebAccessibility::ROLE_LANDMARK_MAIN: |
| 2258 case WebAccessibility::ROLE_LANDMARK_NAVIGATION: | 2574 case WebAccessibility::ROLE_LANDMARK_NAVIGATION: |
| 2259 case WebAccessibility::ROLE_LANDMARK_SEARCH: | 2575 case WebAccessibility::ROLE_LANDMARK_SEARCH: |
| 2260 ia_role_ = ROLE_SYSTEM_GROUPING; | 2576 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2261 ia2_role_ = IA2_ROLE_SECTION; | 2577 ia2_role_ = IA2_ROLE_SECTION; |
| 2578 ia_state_|= STATE_SYSTEM_READONLY; |
| 2262 break; | 2579 break; |
| 2263 case WebAccessibility::ROLE_LINK: | 2580 case WebAccessibility::ROLE_LINK: |
| 2264 case WebAccessibility::ROLE_WEBCORE_LINK: | 2581 case WebAccessibility::ROLE_WEBCORE_LINK: |
| 2265 ia_role_ = ROLE_SYSTEM_LINK; | 2582 ia_role_ = ROLE_SYSTEM_LINK; |
| 2266 ia_state_|= STATE_SYSTEM_LINKED; | 2583 ia_state_|= STATE_SYSTEM_LINKED; |
| 2584 ia_state_|= STATE_SYSTEM_READONLY; |
| 2267 break; | 2585 break; |
| 2268 case WebAccessibility::ROLE_LIST: | 2586 case WebAccessibility::ROLE_LIST: |
| 2269 ia_role_ = ROLE_SYSTEM_LIST; | 2587 ia_role_ = ROLE_SYSTEM_LIST; |
| 2588 ia_state_|= STATE_SYSTEM_READONLY; |
| 2270 break; | 2589 break; |
| 2271 case WebAccessibility::ROLE_LISTBOX: | 2590 case WebAccessibility::ROLE_LISTBOX: |
| 2272 ia_role_ = ROLE_SYSTEM_LIST; | 2591 ia_role_ = ROLE_SYSTEM_LIST; |
| 2273 break; | 2592 break; |
| 2274 case WebAccessibility::ROLE_LISTBOX_OPTION: | 2593 case WebAccessibility::ROLE_LISTBOX_OPTION: |
| 2594 ia_role_ = ROLE_SYSTEM_LISTITEM; |
| 2595 break; |
| 2275 case WebAccessibility::ROLE_LIST_ITEM: | 2596 case WebAccessibility::ROLE_LIST_ITEM: |
| 2597 ia_role_ = ROLE_SYSTEM_LISTITEM; |
| 2598 ia_state_|= STATE_SYSTEM_READONLY; |
| 2599 break; |
| 2276 case WebAccessibility::ROLE_LIST_MARKER: | 2600 case WebAccessibility::ROLE_LIST_MARKER: |
| 2277 ia_role_ = ROLE_SYSTEM_LISTITEM; | 2601 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2602 ia_state_|= STATE_SYSTEM_READONLY; |
| 2278 break; | 2603 break; |
| 2279 case WebAccessibility::ROLE_MATH: | 2604 case WebAccessibility::ROLE_MATH: |
| 2280 ia_role_ = ROLE_SYSTEM_EQUATION; | 2605 ia_role_ = ROLE_SYSTEM_EQUATION; |
| 2606 ia_state_|= STATE_SYSTEM_READONLY; |
| 2281 break; | 2607 break; |
| 2282 case WebAccessibility::ROLE_MENU: | 2608 case WebAccessibility::ROLE_MENU: |
| 2283 case WebAccessibility::ROLE_MENU_BUTTON: | 2609 case WebAccessibility::ROLE_MENU_BUTTON: |
| 2284 ia_role_ = ROLE_SYSTEM_MENUPOPUP; | 2610 ia_role_ = ROLE_SYSTEM_MENUPOPUP; |
| 2285 break; | 2611 break; |
| 2286 case WebAccessibility::ROLE_MENU_BAR: | 2612 case WebAccessibility::ROLE_MENU_BAR: |
| 2287 ia_role_ = ROLE_SYSTEM_MENUBAR; | 2613 ia_role_ = ROLE_SYSTEM_MENUBAR; |
| 2288 break; | 2614 break; |
| 2289 case WebAccessibility::ROLE_MENU_ITEM: | 2615 case WebAccessibility::ROLE_MENU_ITEM: |
| 2290 case WebAccessibility::ROLE_MENU_LIST_OPTION: | 2616 case WebAccessibility::ROLE_MENU_LIST_OPTION: |
| 2291 ia_role_ = ROLE_SYSTEM_MENUITEM; | 2617 ia_role_ = ROLE_SYSTEM_MENUITEM; |
| 2292 break; | 2618 break; |
| 2293 case WebAccessibility::ROLE_MENU_LIST_POPUP: | 2619 case WebAccessibility::ROLE_MENU_LIST_POPUP: |
| 2294 ia_role_ = ROLE_SYSTEM_MENUPOPUP; | 2620 ia_role_ = ROLE_SYSTEM_MENUPOPUP; |
| 2295 break; | 2621 break; |
| 2296 case WebAccessibility::ROLE_NOTE: | 2622 case WebAccessibility::ROLE_NOTE: |
| 2297 ia_role_ = ROLE_SYSTEM_GROUPING; | 2623 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2298 ia2_role_ = IA2_ROLE_NOTE; | 2624 ia2_role_ = IA2_ROLE_NOTE; |
| 2625 ia_state_|= STATE_SYSTEM_READONLY; |
| 2299 break; | 2626 break; |
| 2300 case WebAccessibility::ROLE_OUTLINE: | 2627 case WebAccessibility::ROLE_OUTLINE: |
| 2301 ia_role_ = ROLE_SYSTEM_OUTLINE; | 2628 ia_role_ = ROLE_SYSTEM_OUTLINE; |
| 2629 ia_state_|= STATE_SYSTEM_READONLY; |
| 2302 break; | 2630 break; |
| 2303 case WebAccessibility::ROLE_POPUP_BUTTON: | 2631 case WebAccessibility::ROLE_POPUP_BUTTON: |
| 2304 ia_role_ = ROLE_SYSTEM_COMBOBOX; | 2632 if (html_tag == L"select") { |
| 2633 ia_role_ = ROLE_SYSTEM_COMBOBOX; |
| 2634 } else { |
| 2635 ia_role_ = ROLE_SYSTEM_BUTTONMENU; |
| 2636 } |
| 2637 ia_state_|= STATE_SYSTEM_READONLY; |
| 2305 break; | 2638 break; |
| 2306 case WebAccessibility::ROLE_PROGRESS_INDICATOR: | 2639 case WebAccessibility::ROLE_PROGRESS_INDICATOR: |
| 2307 ia_role_ = ROLE_SYSTEM_PROGRESSBAR; | 2640 ia_role_ = ROLE_SYSTEM_PROGRESSBAR; |
| 2641 ia_state_|= STATE_SYSTEM_READONLY; |
| 2308 break; | 2642 break; |
| 2309 case WebAccessibility::ROLE_RADIO_BUTTON: | 2643 case WebAccessibility::ROLE_RADIO_BUTTON: |
| 2310 ia_role_ = ROLE_SYSTEM_RADIOBUTTON; | 2644 ia_role_ = ROLE_SYSTEM_RADIOBUTTON; |
| 2311 break; | 2645 break; |
| 2312 case WebAccessibility::ROLE_RADIO_GROUP: | 2646 case WebAccessibility::ROLE_RADIO_GROUP: |
| 2313 ia_role_ = ROLE_SYSTEM_GROUPING; | 2647 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2314 ia2_role_ = IA2_ROLE_SECTION; | 2648 ia2_role_ = IA2_ROLE_SECTION; |
| 2315 break; | 2649 break; |
| 2316 case WebAccessibility::ROLE_REGION: | 2650 case WebAccessibility::ROLE_REGION: |
| 2317 ia_role_ = ROLE_SYSTEM_GROUPING; | 2651 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2318 ia2_role_ = IA2_ROLE_SECTION; | 2652 ia2_role_ = IA2_ROLE_SECTION; |
| 2653 ia_state_|= STATE_SYSTEM_READONLY; |
| 2319 break; | 2654 break; |
| 2320 case WebAccessibility::ROLE_ROW: | 2655 case WebAccessibility::ROLE_ROW: |
| 2321 ia_role_ = ROLE_SYSTEM_ROW; | 2656 ia_role_ = ROLE_SYSTEM_ROW; |
| 2657 ia_state_|= STATE_SYSTEM_READONLY; |
| 2322 break; | 2658 break; |
| 2323 case WebAccessibility::ROLE_ROW_HEADER: | 2659 case WebAccessibility::ROLE_ROW_HEADER: |
| 2324 ia_role_ = ROLE_SYSTEM_ROWHEADER; | 2660 ia_role_ = ROLE_SYSTEM_ROWHEADER; |
| 2661 ia_state_|= STATE_SYSTEM_READONLY; |
| 2325 break; | 2662 break; |
| 2326 case WebAccessibility::ROLE_RULER: | 2663 case WebAccessibility::ROLE_RULER: |
| 2327 ia_role_ = ROLE_SYSTEM_CLIENT; | 2664 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2328 ia2_role_ = IA2_ROLE_RULER; | 2665 ia2_role_ = IA2_ROLE_RULER; |
| 2666 ia_state_|= STATE_SYSTEM_READONLY; |
| 2329 break; | 2667 break; |
| 2330 case WebAccessibility::ROLE_SCROLLAREA: | 2668 case WebAccessibility::ROLE_SCROLLAREA: |
| 2331 ia_role_ = ROLE_SYSTEM_CLIENT; | 2669 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2332 ia2_role_ = IA2_ROLE_SCROLL_PANE; | 2670 ia2_role_ = IA2_ROLE_SCROLL_PANE; |
| 2671 ia_state_|= STATE_SYSTEM_READONLY; |
| 2333 break; | 2672 break; |
| 2334 case WebAccessibility::ROLE_SCROLLBAR: | 2673 case WebAccessibility::ROLE_SCROLLBAR: |
| 2335 ia_role_ = ROLE_SYSTEM_SCROLLBAR; | 2674 ia_role_ = ROLE_SYSTEM_SCROLLBAR; |
| 2336 break; | 2675 break; |
| 2337 case WebAccessibility::ROLE_SLIDER: | 2676 case WebAccessibility::ROLE_SLIDER: |
| 2338 ia_role_ = ROLE_SYSTEM_SLIDER; | 2677 ia_role_ = ROLE_SYSTEM_SLIDER; |
| 2339 break; | 2678 break; |
| 2340 case WebAccessibility::ROLE_SPLIT_GROUP: | 2679 case WebAccessibility::ROLE_SPLIT_GROUP: |
| 2341 ia_role_ = ROLE_SYSTEM_CLIENT; | 2680 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2342 ia2_role_ = IA2_ROLE_SPLIT_PANE; | 2681 ia2_role_ = IA2_ROLE_SPLIT_PANE; |
| 2682 ia_state_|= STATE_SYSTEM_READONLY; |
| 2343 break; | 2683 break; |
| 2344 case WebAccessibility::ROLE_ANNOTATION: | 2684 case WebAccessibility::ROLE_ANNOTATION: |
| 2345 case WebAccessibility::ROLE_STATIC_TEXT: | 2685 case WebAccessibility::ROLE_STATIC_TEXT: |
| 2346 ia_role_ = ROLE_SYSTEM_TEXT; | 2686 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2687 ia_state_|= STATE_SYSTEM_READONLY; |
| 2347 break; | 2688 break; |
| 2348 case WebAccessibility::ROLE_STATUS: | 2689 case WebAccessibility::ROLE_STATUS: |
| 2349 ia_role_ = ROLE_SYSTEM_STATUSBAR; | 2690 ia_role_ = ROLE_SYSTEM_STATUSBAR; |
| 2691 ia_state_|= STATE_SYSTEM_READONLY; |
| 2350 break; | 2692 break; |
| 2351 case WebAccessibility::ROLE_SPLITTER: | 2693 case WebAccessibility::ROLE_SPLITTER: |
| 2352 ia_role_ = ROLE_SYSTEM_SEPARATOR; | 2694 ia_role_ = ROLE_SYSTEM_SEPARATOR; |
| 2353 break; | 2695 break; |
| 2354 case WebAccessibility::ROLE_TAB: | 2696 case WebAccessibility::ROLE_TAB: |
| 2355 ia_role_ = ROLE_SYSTEM_PAGETAB; | 2697 ia_role_ = ROLE_SYSTEM_PAGETAB; |
| 2356 break; | 2698 break; |
| 2357 case WebAccessibility::ROLE_TABLE: | 2699 case WebAccessibility::ROLE_TABLE: |
| 2358 ia_role_ = ROLE_SYSTEM_TABLE; | 2700 ia_role_ = ROLE_SYSTEM_TABLE; |
| 2701 ia_state_|= STATE_SYSTEM_READONLY; |
| 2359 break; | 2702 break; |
| 2360 case WebAccessibility::ROLE_TABLE_HEADER_CONTAINER: | 2703 case WebAccessibility::ROLE_TABLE_HEADER_CONTAINER: |
| 2361 ia_role_ = ROLE_SYSTEM_GROUPING; | 2704 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2362 ia2_role_ = IA2_ROLE_SECTION; | 2705 ia2_role_ = IA2_ROLE_SECTION; |
| 2706 ia_state_|= STATE_SYSTEM_READONLY; |
| 2363 break; | 2707 break; |
| 2364 case WebAccessibility::ROLE_TAB_GROUP: | 2708 case WebAccessibility::ROLE_TAB_GROUP: |
| 2365 case WebAccessibility::ROLE_TAB_LIST: | 2709 case WebAccessibility::ROLE_TAB_LIST: |
| 2366 case WebAccessibility::ROLE_TAB_PANEL: | 2710 case WebAccessibility::ROLE_TAB_PANEL: |
| 2367 ia_role_ = ROLE_SYSTEM_PAGETABLIST; | 2711 ia_role_ = ROLE_SYSTEM_PAGETABLIST; |
| 2368 break; | 2712 break; |
| 2369 case WebAccessibility::ROLE_TEXTAREA: | 2713 case WebAccessibility::ROLE_TEXTAREA: |
| 2370 ia_role_ = ROLE_SYSTEM_TEXT; | 2714 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2371 ia2_state_ |= IA2_STATE_MULTI_LINE; | 2715 ia2_state_ |= IA2_STATE_MULTI_LINE; |
| 2372 ia2_state_ |= IA2_STATE_EDITABLE; | 2716 ia2_state_ |= IA2_STATE_EDITABLE; |
| 2373 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; | 2717 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; |
| 2374 break; | 2718 break; |
| 2375 case WebAccessibility::ROLE_TEXT_FIELD: | 2719 case WebAccessibility::ROLE_TEXT_FIELD: |
| 2376 ia_role_ = ROLE_SYSTEM_TEXT; | 2720 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2377 ia2_state_ |= IA2_STATE_SINGLE_LINE; | 2721 ia2_state_ |= IA2_STATE_SINGLE_LINE; |
| 2378 ia2_state_ |= IA2_STATE_EDITABLE; | 2722 ia2_state_ |= IA2_STATE_EDITABLE; |
| 2379 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; | 2723 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; |
| 2380 break; | 2724 break; |
| 2381 case WebAccessibility::ROLE_TIMER: | 2725 case WebAccessibility::ROLE_TIMER: |
| 2382 ia_role_ = ROLE_SYSTEM_CLOCK; | 2726 ia_role_ = ROLE_SYSTEM_CLOCK; |
| 2727 ia_state_|= STATE_SYSTEM_READONLY; |
| 2383 break; | 2728 break; |
| 2384 case WebAccessibility::ROLE_TOOLBAR: | 2729 case WebAccessibility::ROLE_TOOLBAR: |
| 2385 ia_role_ = ROLE_SYSTEM_TOOLBAR; | 2730 ia_role_ = ROLE_SYSTEM_TOOLBAR; |
| 2731 ia_state_|= STATE_SYSTEM_READONLY; |
| 2386 break; | 2732 break; |
| 2387 case WebAccessibility::ROLE_TOOLTIP: | 2733 case WebAccessibility::ROLE_TOOLTIP: |
| 2388 ia_role_ = ROLE_SYSTEM_TOOLTIP; | 2734 ia_role_ = ROLE_SYSTEM_TOOLTIP; |
| 2735 ia_state_|= STATE_SYSTEM_READONLY; |
| 2389 break; | 2736 break; |
| 2390 case WebAccessibility::ROLE_TREE: | 2737 case WebAccessibility::ROLE_TREE: |
| 2391 ia_role_ = ROLE_SYSTEM_OUTLINE; | 2738 ia_role_ = ROLE_SYSTEM_OUTLINE; |
| 2739 ia_state_|= STATE_SYSTEM_READONLY; |
| 2392 break; | 2740 break; |
| 2393 case WebAccessibility::ROLE_TREE_GRID: | 2741 case WebAccessibility::ROLE_TREE_GRID: |
| 2394 ia_role_ = ROLE_SYSTEM_OUTLINE; | 2742 ia_role_ = ROLE_SYSTEM_OUTLINE; |
| 2743 ia_state_|= STATE_SYSTEM_READONLY; |
| 2395 break; | 2744 break; |
| 2396 case WebAccessibility::ROLE_TREE_ITEM: | 2745 case WebAccessibility::ROLE_TREE_ITEM: |
| 2397 ia_role_ = ROLE_SYSTEM_OUTLINEITEM; | 2746 ia_role_ = ROLE_SYSTEM_OUTLINEITEM; |
| 2747 ia_state_|= STATE_SYSTEM_READONLY; |
| 2398 break; | 2748 break; |
| 2399 case WebAccessibility::ROLE_WINDOW: | 2749 case WebAccessibility::ROLE_WINDOW: |
| 2400 ia_role_ = ROLE_SYSTEM_WINDOW; | 2750 ia_role_ = ROLE_SYSTEM_WINDOW; |
| 2401 break; | 2751 break; |
| 2402 | 2752 |
| 2403 // TODO(dmazzoni): figure out the proper MSAA role for all of these. | 2753 // TODO(dmazzoni): figure out the proper MSAA role for all of these. |
| 2404 case WebAccessibility::ROLE_BROWSER: | 2754 case WebAccessibility::ROLE_BROWSER: |
| 2405 case WebAccessibility::ROLE_DIRECTORY: | 2755 case WebAccessibility::ROLE_DIRECTORY: |
| 2406 case WebAccessibility::ROLE_DRAWER: | 2756 case WebAccessibility::ROLE_DRAWER: |
| 2407 case WebAccessibility::ROLE_HELP_TAG: | 2757 case WebAccessibility::ROLE_HELP_TAG: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2421 } | 2771 } |
| 2422 | 2772 |
| 2423 // The role should always be set. | 2773 // The role should always be set. |
| 2424 DCHECK(!role_name_.empty() || ia_role_); | 2774 DCHECK(!role_name_.empty() || ia_role_); |
| 2425 | 2775 |
| 2426 // If we didn't explicitly set the IAccessible2 role, make it the same | 2776 // If we didn't explicitly set the IAccessible2 role, make it the same |
| 2427 // as the MSAA role. | 2777 // as the MSAA role. |
| 2428 if (!ia2_role_) | 2778 if (!ia2_role_) |
| 2429 ia2_role_ = ia_role_; | 2779 ia2_role_ = ia_role_; |
| 2430 } | 2780 } |
| OLD | NEW |