Chromium Code Reviews| 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 } |
|
David Tseng
2011/08/29 19:05:34
nit: first_time_alert_?
dmazzoni
2011/08/29 19:38:35
It's more generally useful, I think I'll be using
| |
| 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. |
| 51 // * Always check for invalid arguments first, even if they're unused. | 53 // * Always check for invalid arguments first, even if they're unused. |
| (...skipping 362 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++) { |
|
David Tseng
2011/08/29 19:05:34
nit: ++i
dmazzoni
2011/08/29 19:38:35
Done.
| |
| 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++) { | |
|
David Tseng
2011/08/29 19:05:34
nit: ++i
dmazzoni
2011/08/29 19:38:35
Done.
| |
| 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; | |
|
David Tseng
2011/08/29 19:05:34
TODO? cells is an out param?
dmazzoni
2011/08/29 19:38:35
Done.
| |
| 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; | |
|
David Tseng
2011/08/29 19:05:34
Same here; TODO.
dmazzoni
2011/08/29 19:38:35
Done.
| |
| 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; | |
|
David Tseng
2011/08/29 19:05:34
Same here.
dmazzoni
2011/08/29 19:38:35
Done.
| |
| 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; | |
|
David Tseng
2011/08/29 19:05:34
nit: TODO?
dmazzoni
2011/08/29 19:38:35
Done.
| |
| 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) | |
|
David Tseng
2011/08/29 19:05:34
Should this ever happen? Will there ever be a cell
dmazzoni
2011/08/29 19:38:35
The parent should be a row, and the row's parent s
| |
| 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++) { | |
|
David Tseng
2011/08/29 19:05:34
nit: ++i
David Tseng
2011/08/29 19:05:34
Also, if you change |unique_cell_ids| to a set, yo
dmazzoni
2011/08/29 19:38:35
Done.
dmazzoni
2011/08/29 19:38:35
Yeah, but unfortunately the order matters. I docum
| |
| 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() { | |
|
David Tseng
2011/08/29 19:05:34
nit: new line above?
| |
| 2188 // Fire an event when an alert first appears. | |
| 2189 if (role_ == WebAccessibility::ROLE_ALERT && first_time_) { | |
| 2190 manager_->NotifyAccessibilityEvent( | |
| 2191 ViewHostMsg_AccessibilityNotification_Type:: | |
| 2192 NOTIFICATION_TYPE_ALERT, | |
| 2193 this); | |
|
David Tseng
2011/08/29 19:05:34
nit: re-align -- 4 spaces).
| |
| 2194 } | |
| 2195 | |
| 2196 // Fire events if text has changed. | |
| 2197 string16 text = TextForIAccessibleText(); | |
| 2198 if (previous_text_ != text) { | |
| 2199 if (!previous_text_.empty() && !text.empty()) { | |
|
David Tseng
2011/08/29 19:05:34
Is this necessary? What happens when the |previous
dmazzoni
2011/08/29 19:38:35
This is the only way I can get JAWS to announce li
| |
| 2200 manager_->NotifyAccessibilityEvent( | |
| 2201 ViewHostMsg_AccessibilityNotification_Type:: | |
| 2202 NOTIFICATION_TYPE_OBJECT_SHOW, | |
| 2203 this); | |
| 2204 } | |
| 2205 | |
| 2206 old_text_ = previous_text_; | |
| 2207 previous_text_ = text; | |
| 2208 } | |
| 2209 | |
| 2210 first_time_ = false; | |
| 2211 } | |
| 2212 | |
| 1958 void BrowserAccessibilityWin::NativeAddReference() { | 2213 void BrowserAccessibilityWin::NativeAddReference() { |
| 1959 AddRef(); | 2214 AddRef(); |
| 1960 } | 2215 } |
| 1961 | 2216 |
| 1962 void BrowserAccessibilityWin::NativeReleaseReference() { | 2217 void BrowserAccessibilityWin::NativeReleaseReference() { |
| 1963 Release(); | 2218 Release(); |
| 1964 } | 2219 } |
| 1965 | 2220 |
| 1966 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { | 2221 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { |
| 1967 AddRef(); | 2222 AddRef(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1992 | 2247 |
| 1993 if (str.empty()) | 2248 if (str.empty()) |
| 1994 return S_FALSE; | 2249 return S_FALSE; |
| 1995 | 2250 |
| 1996 *value_bstr = SysAllocString(str.c_str()); | 2251 *value_bstr = SysAllocString(str.c_str()); |
| 1997 DCHECK(*value_bstr); | 2252 DCHECK(*value_bstr); |
| 1998 | 2253 |
| 1999 return S_OK; | 2254 return S_OK; |
| 2000 } | 2255 } |
| 2001 | 2256 |
| 2257 void BrowserAccessibilityWin::StringAttributeToIA2( | |
| 2258 WebAccessibility::StringAttribute attribute, const char* ia2_attr) { | |
| 2259 string16 value; | |
| 2260 if (GetStringAttribute(attribute, &value)) | |
| 2261 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + value); | |
| 2262 } | |
| 2263 | |
| 2264 void BrowserAccessibilityWin::BoolAttributeToIA2( | |
| 2265 WebAccessibility::BoolAttribute attribute, const char* ia2_attr) { | |
| 2266 bool value; | |
| 2267 if (GetBoolAttribute(attribute, &value)) { | |
| 2268 ia2_attributes_.push_back((ASCIIToUTF16(ia2_attr) + L":") + | |
| 2269 (value ? L"true" : L"false")); | |
| 2270 } | |
| 2271 } | |
| 2272 | |
| 2273 void BrowserAccessibilityWin::IntAttributeToIA2( | |
| 2274 WebAccessibility::IntAttribute attribute, const char* ia2_attr) { | |
| 2275 int value; | |
| 2276 if (GetIntAttribute(attribute, &value)) | |
| 2277 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + | |
| 2278 base::IntToString16(value)); | |
| 2279 } | |
| 2280 | |
| 2002 string16 BrowserAccessibilityWin::Escape(const string16& str) { | 2281 string16 BrowserAccessibilityWin::Escape(const string16& str) { |
| 2003 return EscapeQueryParamValueUTF8(str, false); | 2282 return EscapeQueryParamValueUTF8(str, false); |
| 2004 } | 2283 } |
| 2005 | 2284 |
| 2006 const string16& BrowserAccessibilityWin::TextForIAccessibleText() { | 2285 const string16& BrowserAccessibilityWin::TextForIAccessibleText() { |
| 2007 if (role_ == WebAccessibility::ROLE_TEXT_FIELD || | 2286 if (IsEditableText()) { |
| 2008 role_ == WebAccessibility::ROLE_TEXTAREA) { | |
| 2009 return value_; | 2287 return value_; |
| 2010 } else { | 2288 } else { |
| 2011 return name_; | 2289 return name_; |
| 2012 } | 2290 } |
| 2013 } | 2291 } |
| 2014 | 2292 |
| 2015 void BrowserAccessibilityWin::HandleSpecialTextOffset( | 2293 void BrowserAccessibilityWin::HandleSpecialTextOffset( |
| 2016 const string16& text, LONG* offset) { | 2294 const string16& text, LONG* offset) { |
| 2017 if (*offset == IA2_TEXT_OFFSET_LENGTH) { | 2295 if (*offset == IA2_TEXT_OFFSET_LENGTH) { |
| 2018 *offset = static_cast<LONG>(text.size()); | 2296 *offset = static_cast<LONG>(text.size()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2105 } | 2383 } |
| 2106 | 2384 |
| 2107 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( | 2385 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( |
| 2108 int32 renderer_id) { | 2386 int32 renderer_id) { |
| 2109 return manager_->GetFromRendererID(renderer_id)->toBrowserAccessibilityWin(); | 2387 return manager_->GetFromRendererID(renderer_id)->toBrowserAccessibilityWin(); |
| 2110 } | 2388 } |
| 2111 | 2389 |
| 2112 void BrowserAccessibilityWin::InitRoleAndState() { | 2390 void BrowserAccessibilityWin::InitRoleAndState() { |
| 2113 ia_state_ = 0; | 2391 ia_state_ = 0; |
| 2114 ia2_state_ = IA2_STATE_OPAQUE; | 2392 ia2_state_ = IA2_STATE_OPAQUE; |
| 2393 ia2_attributes_.clear(); | |
| 2115 | 2394 |
| 2395 if ((state_ >> WebAccessibility::STATE_BUSY) & 1) | |
| 2396 ia_state_|= STATE_SYSTEM_BUSY; | |
| 2116 if ((state_ >> WebAccessibility::STATE_CHECKED) & 1) | 2397 if ((state_ >> WebAccessibility::STATE_CHECKED) & 1) |
| 2117 ia_state_ |= STATE_SYSTEM_CHECKED; | 2398 ia_state_ |= STATE_SYSTEM_CHECKED; |
| 2118 if ((state_ >> WebAccessibility::STATE_COLLAPSED) & 1) | 2399 if ((state_ >> WebAccessibility::STATE_COLLAPSED) & 1) |
| 2119 ia_state_|= STATE_SYSTEM_COLLAPSED; | 2400 ia_state_|= STATE_SYSTEM_COLLAPSED; |
| 2120 if ((state_ >> WebAccessibility::STATE_EXPANDED) & 1) | 2401 if ((state_ >> WebAccessibility::STATE_EXPANDED) & 1) |
| 2121 ia_state_|= STATE_SYSTEM_EXPANDED; | 2402 ia_state_|= STATE_SYSTEM_EXPANDED; |
| 2122 if ((state_ >> WebAccessibility::STATE_FOCUSABLE) & 1) | 2403 if ((state_ >> WebAccessibility::STATE_FOCUSABLE) & 1) |
| 2123 ia_state_|= STATE_SYSTEM_FOCUSABLE; | 2404 ia_state_|= STATE_SYSTEM_FOCUSABLE; |
| 2124 if ((state_ >> WebAccessibility::STATE_HASPOPUP) & 1) | 2405 if ((state_ >> WebAccessibility::STATE_HASPOPUP) & 1) |
| 2125 ia_state_|= STATE_SYSTEM_HASPOPUP; | 2406 ia_state_|= STATE_SYSTEM_HASPOPUP; |
| 2126 if ((state_ >> WebAccessibility::STATE_HOTTRACKED) & 1) | 2407 if ((state_ >> WebAccessibility::STATE_HOTTRACKED) & 1) |
| 2127 ia_state_|= STATE_SYSTEM_HOTTRACKED; | 2408 ia_state_|= STATE_SYSTEM_HOTTRACKED; |
| 2128 if ((state_ >> WebAccessibility::STATE_INDETERMINATE) & 1) | 2409 if ((state_ >> WebAccessibility::STATE_INDETERMINATE) & 1) |
| 2129 ia_state_|= STATE_SYSTEM_INDETERMINATE; | 2410 ia_state_|= STATE_SYSTEM_INDETERMINATE; |
| 2130 if ((state_ >> WebAccessibility::STATE_INVISIBLE) & 1) | 2411 if ((state_ >> WebAccessibility::STATE_INVISIBLE) & 1) |
| 2131 ia_state_|= STATE_SYSTEM_INVISIBLE; | 2412 ia_state_|= STATE_SYSTEM_INVISIBLE; |
| 2132 if ((state_ >> WebAccessibility::STATE_LINKED) & 1) | 2413 if ((state_ >> WebAccessibility::STATE_LINKED) & 1) |
| 2133 ia_state_|= STATE_SYSTEM_LINKED; | 2414 ia_state_|= STATE_SYSTEM_LINKED; |
| 2134 if ((state_ >> WebAccessibility::STATE_MULTISELECTABLE) & 1) | 2415 if ((state_ >> WebAccessibility::STATE_MULTISELECTABLE) & 1) |
| 2135 ia_state_|= STATE_SYSTEM_MULTISELECTABLE; | 2416 ia_state_|= STATE_SYSTEM_MULTISELECTABLE; |
| 2136 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. | 2417 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. |
| 2137 if ((state_ >> WebAccessibility::STATE_OFFSCREEN) & 1) | 2418 if ((state_ >> WebAccessibility::STATE_OFFSCREEN) & 1) |
| 2138 ia_state_|= STATE_SYSTEM_OFFSCREEN; | 2419 ia_state_|= STATE_SYSTEM_OFFSCREEN; |
| 2139 if ((state_ >> WebAccessibility::STATE_PRESSED) & 1) | 2420 if ((state_ >> WebAccessibility::STATE_PRESSED) & 1) |
| 2140 ia_state_|= STATE_SYSTEM_PRESSED; | 2421 ia_state_|= STATE_SYSTEM_PRESSED; |
| 2141 if ((state_ >> WebAccessibility::STATE_PROTECTED) & 1) | 2422 if ((state_ >> WebAccessibility::STATE_PROTECTED) & 1) |
| 2142 ia_state_|= STATE_SYSTEM_PROTECTED; | 2423 ia_state_|= STATE_SYSTEM_PROTECTED; |
| 2424 if ((state_ >> WebAccessibility::STATE_READONLY) & 1) | |
| 2425 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2426 if ((state_ >> WebAccessibility::STATE_REQUIRED) & 1) | |
| 2427 ia2_state_|= IA2_STATE_REQUIRED; | |
| 2143 if ((state_ >> WebAccessibility::STATE_SELECTABLE) & 1) | 2428 if ((state_ >> WebAccessibility::STATE_SELECTABLE) & 1) |
| 2144 ia_state_|= STATE_SYSTEM_SELECTABLE; | 2429 ia_state_|= STATE_SYSTEM_SELECTABLE; |
| 2145 if ((state_ >> WebAccessibility::STATE_SELECTED) & 1) | 2430 if ((state_ >> WebAccessibility::STATE_SELECTED) & 1) |
| 2146 ia_state_|= STATE_SYSTEM_SELECTED; | 2431 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) | 2432 if ((state_ >> WebAccessibility::STATE_TRAVERSED) & 1) |
| 2150 ia_state_|= STATE_SYSTEM_TRAVERSED; | 2433 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) | 2434 if ((state_ >> WebAccessibility::STATE_UNAVAILABLE) & 1) |
| 2154 ia_state_|= STATE_SYSTEM_UNAVAILABLE; | 2435 ia_state_|= STATE_SYSTEM_UNAVAILABLE; |
| 2436 if ((state_ >> WebAccessibility::STATE_VERTICAL) & 1) { | |
| 2437 ia2_state_|= IA2_STATE_VERTICAL; | |
| 2438 } else { | |
|
David Tseng
2011/08/29 19:05:34
;Shouldn't we check for this state explicitly?
dmazzoni
2011/08/29 19:38:35
Isn't everything either horizontal or vertical? Is
David Tseng
2011/08/29 23:57:10
On 2011/08/29 19:38:35, Dominic Mazzoni wrote:
Lo
| |
| 2439 ia2_state_|= IA2_STATE_HORIZONTAL; | |
| 2440 } | |
| 2441 if ((state_ >> WebAccessibility::STATE_VISITED) & 1) | |
| 2442 ia_state_|= STATE_SYSTEM_TRAVERSED; | |
| 2443 | |
| 2444 string16 invalid; | |
| 2445 if (GetHtmlAttribute("aria-invalid", &invalid)) | |
| 2446 ia2_state_|= IA2_STATE_INVALID_ENTRY; | |
| 2447 | |
| 2448 bool mixed = false; | |
| 2449 GetBoolAttribute(WebAccessibility::ATTR_BUTTON_MIXED, &mixed); | |
| 2450 if (mixed) | |
| 2451 ia_state_|= STATE_SYSTEM_MIXED; | |
| 2155 | 2452 |
| 2156 string16 html_tag; | 2453 string16 html_tag; |
| 2157 GetStringAttribute(WebAccessibility::ATTR_HTML_TAG, &html_tag); | 2454 GetStringAttribute(WebAccessibility::ATTR_HTML_TAG, &html_tag); |
| 2158 ia_role_ = 0; | 2455 ia_role_ = 0; |
| 2159 ia2_role_ = 0; | 2456 ia2_role_ = 0; |
| 2160 switch (role_) { | 2457 switch (role_) { |
| 2161 case WebAccessibility::ROLE_ALERT: | 2458 case WebAccessibility::ROLE_ALERT: |
| 2459 ia_role_ = ROLE_SYSTEM_ALERT; | |
| 2460 break; | |
| 2162 case WebAccessibility::ROLE_ALERT_DIALOG: | 2461 case WebAccessibility::ROLE_ALERT_DIALOG: |
| 2163 ia_role_ = ROLE_SYSTEM_ALERT; | 2462 ia_role_ = ROLE_SYSTEM_DIALOG; |
| 2164 break; | 2463 break; |
| 2165 case WebAccessibility::ROLE_APPLICATION: | 2464 case WebAccessibility::ROLE_APPLICATION: |
| 2166 ia_role_ = ROLE_SYSTEM_APPLICATION; | 2465 ia_role_ = ROLE_SYSTEM_APPLICATION; |
| 2167 break; | 2466 break; |
| 2168 case WebAccessibility::ROLE_ARTICLE: | 2467 case WebAccessibility::ROLE_ARTICLE: |
| 2169 ia_role_ = ROLE_SYSTEM_GROUPING; | 2468 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2170 ia2_role_ = IA2_ROLE_SECTION; | 2469 ia2_role_ = IA2_ROLE_SECTION; |
| 2470 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2171 break; | 2471 break; |
| 2172 case WebAccessibility::ROLE_BUSY_INDICATOR: | 2472 case WebAccessibility::ROLE_BUSY_INDICATOR: |
| 2173 ia_role_ = ROLE_SYSTEM_ANIMATION; | 2473 ia_role_ = ROLE_SYSTEM_ANIMATION; |
| 2474 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2174 break; | 2475 break; |
| 2175 case WebAccessibility::ROLE_BUTTON: | 2476 case WebAccessibility::ROLE_BUTTON: |
| 2176 ia_role_ = ROLE_SYSTEM_PUSHBUTTON; | 2477 ia_role_ = ROLE_SYSTEM_PUSHBUTTON; |
| 2478 ia_state_|= STATE_SYSTEM_READONLY; | |
|
David Tseng
2011/08/29 19:05:34
Should we be setting this state? Some screen reade
dmazzoni
2011/08/29 19:38:35
So actually I was having the opposite problem: I t
David Tseng
2011/08/29 23:57:10
On 2011/08/29 19:38:35, Dominic Mazzoni wrote:
We
| |
| 2177 break; | 2479 break; |
| 2178 case WebAccessibility::ROLE_CELL: | 2480 case WebAccessibility::ROLE_CELL: |
| 2179 ia_role_ = ROLE_SYSTEM_CELL; | 2481 ia_role_ = ROLE_SYSTEM_CELL; |
| 2482 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2180 break; | 2483 break; |
| 2181 case WebAccessibility::ROLE_CHECKBOX: | 2484 case WebAccessibility::ROLE_CHECKBOX: |
| 2182 ia_role_ = ROLE_SYSTEM_CHECKBUTTON; | 2485 ia_role_ = ROLE_SYSTEM_CHECKBUTTON; |
| 2183 break; | 2486 break; |
| 2184 case WebAccessibility::ROLE_COLOR_WELL: | 2487 case WebAccessibility::ROLE_COLOR_WELL: |
| 2185 ia_role_ = ROLE_SYSTEM_CLIENT; | 2488 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2186 ia2_role_ = IA2_ROLE_COLOR_CHOOSER; | 2489 ia2_role_ = IA2_ROLE_COLOR_CHOOSER; |
| 2187 break; | 2490 break; |
| 2188 case WebAccessibility::ROLE_COLUMN: | 2491 case WebAccessibility::ROLE_COLUMN: |
| 2189 ia_role_ = ROLE_SYSTEM_COLUMN; | 2492 ia_role_ = ROLE_SYSTEM_COLUMN; |
| 2493 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2190 break; | 2494 break; |
| 2191 case WebAccessibility::ROLE_COLUMN_HEADER: | 2495 case WebAccessibility::ROLE_COLUMN_HEADER: |
| 2192 ia_role_ = ROLE_SYSTEM_COLUMNHEADER; | 2496 ia_role_ = ROLE_SYSTEM_COLUMNHEADER; |
| 2497 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2193 break; | 2498 break; |
| 2194 case WebAccessibility::ROLE_COMBO_BOX: | 2499 case WebAccessibility::ROLE_COMBO_BOX: |
| 2195 ia_role_ = ROLE_SYSTEM_COMBOBOX; | 2500 ia_role_ = ROLE_SYSTEM_COMBOBOX; |
| 2196 break; | 2501 break; |
| 2197 case WebAccessibility::ROLE_DEFINITION_LIST_DEFINITION: | 2502 case WebAccessibility::ROLE_DEFINITION_LIST_DEFINITION: |
| 2198 role_name_ = html_tag; | 2503 role_name_ = html_tag; |
| 2199 ia2_role_ = IA2_ROLE_PARAGRAPH; | 2504 ia2_role_ = IA2_ROLE_PARAGRAPH; |
| 2505 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2200 break; | 2506 break; |
| 2201 case WebAccessibility::ROLE_DEFINITION_LIST_TERM: | 2507 case WebAccessibility::ROLE_DEFINITION_LIST_TERM: |
| 2202 ia_role_ = ROLE_SYSTEM_LISTITEM; | 2508 ia_role_ = ROLE_SYSTEM_LISTITEM; |
| 2509 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2203 break; | 2510 break; |
| 2204 case WebAccessibility::ROLE_DIALOG: | 2511 case WebAccessibility::ROLE_DIALOG: |
| 2205 ia_role_ = ROLE_SYSTEM_DIALOG; | 2512 ia_role_ = ROLE_SYSTEM_DIALOG; |
| 2513 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2206 break; | 2514 break; |
| 2207 case WebAccessibility::ROLE_DISCLOSURE_TRIANGLE: | 2515 case WebAccessibility::ROLE_DISCLOSURE_TRIANGLE: |
| 2208 ia_role_ = ROLE_SYSTEM_OUTLINEBUTTON; | 2516 ia_role_ = ROLE_SYSTEM_OUTLINEBUTTON; |
| 2517 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2209 break; | 2518 break; |
| 2210 case WebAccessibility::ROLE_DOCUMENT: | 2519 case WebAccessibility::ROLE_DOCUMENT: |
| 2211 case WebAccessibility::ROLE_WEB_AREA: | 2520 case WebAccessibility::ROLE_WEB_AREA: |
| 2212 ia_role_ = ROLE_SYSTEM_DOCUMENT; | 2521 ia_role_ = ROLE_SYSTEM_DOCUMENT; |
| 2213 ia_state_|= STATE_SYSTEM_READONLY; | 2522 ia_state_|= STATE_SYSTEM_READONLY; |
| 2214 ia_state_|= STATE_SYSTEM_FOCUSABLE; | 2523 ia_state_|= STATE_SYSTEM_FOCUSABLE; |
| 2215 break; | 2524 break; |
| 2216 case WebAccessibility::ROLE_EDITABLE_TEXT: | 2525 case WebAccessibility::ROLE_EDITABLE_TEXT: |
| 2217 ia_role_ = ROLE_SYSTEM_TEXT; | 2526 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2218 ia2_state_ |= IA2_STATE_SINGLE_LINE; | 2527 ia2_state_ |= IA2_STATE_SINGLE_LINE; |
| 2219 ia2_state_ |= IA2_STATE_EDITABLE; | 2528 ia2_state_ |= IA2_STATE_EDITABLE; |
| 2220 break; | 2529 break; |
| 2221 case WebAccessibility::ROLE_GRID: | 2530 case WebAccessibility::ROLE_GRID: |
| 2222 ia_role_ = ROLE_SYSTEM_TABLE; | 2531 ia_role_ = ROLE_SYSTEM_TABLE; |
| 2532 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2223 break; | 2533 break; |
| 2224 case WebAccessibility::ROLE_GROUP: | 2534 case WebAccessibility::ROLE_GROUP: |
| 2225 if (html_tag == L"li") { | 2535 if (html_tag == L"li") { |
| 2226 ia_role_ = ROLE_SYSTEM_LISTITEM; | 2536 ia_role_ = ROLE_SYSTEM_LISTITEM; |
| 2537 } else if (html_tag == L"form") { | |
| 2538 role_name_ = html_tag; | |
| 2539 ia2_role_ = IA2_ROLE_FORM; | |
| 2540 } else if (html_tag == L"p") { | |
| 2541 role_name_ = html_tag; | |
| 2542 ia2_role_ = IA2_ROLE_PARAGRAPH; | |
| 2227 } else { | 2543 } else { |
| 2228 if (html_tag.empty()) | 2544 if (html_tag.empty()) |
| 2229 role_name_ = L"div"; | 2545 role_name_ = L"div"; |
| 2230 else | 2546 else |
| 2231 role_name_ = html_tag; | 2547 role_name_ = html_tag; |
| 2232 ia2_role_ = IA2_ROLE_SECTION; | 2548 ia2_role_ = IA2_ROLE_SECTION; |
| 2233 } | 2549 } |
| 2550 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2234 break; | 2551 break; |
| 2235 case WebAccessibility::ROLE_GROW_AREA: | 2552 case WebAccessibility::ROLE_GROW_AREA: |
| 2236 ia_role_ = ROLE_SYSTEM_GRIP; | 2553 ia_role_ = ROLE_SYSTEM_GRIP; |
| 2554 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2237 break; | 2555 break; |
| 2238 case WebAccessibility::ROLE_HEADING: | 2556 case WebAccessibility::ROLE_HEADING: |
| 2239 role_name_ = html_tag; | 2557 role_name_ = html_tag; |
| 2240 ia2_role_ = IA2_ROLE_HEADING; | 2558 ia2_role_ = IA2_ROLE_HEADING; |
| 2559 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2241 break; | 2560 break; |
| 2242 case WebAccessibility::ROLE_IMAGE: | 2561 case WebAccessibility::ROLE_IMAGE: |
| 2243 ia_role_ = ROLE_SYSTEM_GRAPHIC; | 2562 ia_role_ = ROLE_SYSTEM_GRAPHIC; |
| 2563 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2244 break; | 2564 break; |
| 2245 case WebAccessibility::ROLE_IMAGE_MAP: | 2565 case WebAccessibility::ROLE_IMAGE_MAP: |
| 2246 role_name_ = html_tag; | 2566 role_name_ = html_tag; |
| 2247 ia2_role_ = IA2_ROLE_IMAGE_MAP; | 2567 ia2_role_ = IA2_ROLE_IMAGE_MAP; |
| 2568 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2248 break; | 2569 break; |
| 2249 case WebAccessibility::ROLE_IMAGE_MAP_LINK: | 2570 case WebAccessibility::ROLE_IMAGE_MAP_LINK: |
| 2250 ia_role_ = ROLE_SYSTEM_LINK; | 2571 ia_role_ = ROLE_SYSTEM_LINK; |
| 2251 ia_state_|= STATE_SYSTEM_LINKED; | 2572 ia_state_|= STATE_SYSTEM_LINKED; |
| 2573 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2252 break; | 2574 break; |
| 2253 case WebAccessibility::ROLE_LANDMARK_APPLICATION: | 2575 case WebAccessibility::ROLE_LANDMARK_APPLICATION: |
| 2254 case WebAccessibility::ROLE_LANDMARK_BANNER: | 2576 case WebAccessibility::ROLE_LANDMARK_BANNER: |
| 2255 case WebAccessibility::ROLE_LANDMARK_COMPLEMENTARY: | 2577 case WebAccessibility::ROLE_LANDMARK_COMPLEMENTARY: |
| 2256 case WebAccessibility::ROLE_LANDMARK_CONTENTINFO: | 2578 case WebAccessibility::ROLE_LANDMARK_CONTENTINFO: |
| 2257 case WebAccessibility::ROLE_LANDMARK_MAIN: | 2579 case WebAccessibility::ROLE_LANDMARK_MAIN: |
| 2258 case WebAccessibility::ROLE_LANDMARK_NAVIGATION: | 2580 case WebAccessibility::ROLE_LANDMARK_NAVIGATION: |
| 2259 case WebAccessibility::ROLE_LANDMARK_SEARCH: | 2581 case WebAccessibility::ROLE_LANDMARK_SEARCH: |
| 2260 ia_role_ = ROLE_SYSTEM_GROUPING; | 2582 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2261 ia2_role_ = IA2_ROLE_SECTION; | 2583 ia2_role_ = IA2_ROLE_SECTION; |
| 2584 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2262 break; | 2585 break; |
| 2263 case WebAccessibility::ROLE_LINK: | 2586 case WebAccessibility::ROLE_LINK: |
| 2264 case WebAccessibility::ROLE_WEBCORE_LINK: | 2587 case WebAccessibility::ROLE_WEBCORE_LINK: |
| 2265 ia_role_ = ROLE_SYSTEM_LINK; | 2588 ia_role_ = ROLE_SYSTEM_LINK; |
| 2266 ia_state_|= STATE_SYSTEM_LINKED; | 2589 ia_state_|= STATE_SYSTEM_LINKED; |
| 2590 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2267 break; | 2591 break; |
| 2268 case WebAccessibility::ROLE_LIST: | 2592 case WebAccessibility::ROLE_LIST: |
| 2269 ia_role_ = ROLE_SYSTEM_LIST; | 2593 ia_role_ = ROLE_SYSTEM_LIST; |
| 2594 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2270 break; | 2595 break; |
| 2271 case WebAccessibility::ROLE_LISTBOX: | 2596 case WebAccessibility::ROLE_LISTBOX: |
| 2272 ia_role_ = ROLE_SYSTEM_LIST; | 2597 ia_role_ = ROLE_SYSTEM_LIST; |
| 2273 break; | 2598 break; |
| 2274 case WebAccessibility::ROLE_LISTBOX_OPTION: | 2599 case WebAccessibility::ROLE_LISTBOX_OPTION: |
| 2600 ia_role_ = ROLE_SYSTEM_LISTITEM; | |
| 2601 break; | |
| 2275 case WebAccessibility::ROLE_LIST_ITEM: | 2602 case WebAccessibility::ROLE_LIST_ITEM: |
| 2603 ia_role_ = ROLE_SYSTEM_LISTITEM; | |
| 2604 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2605 break; | |
| 2276 case WebAccessibility::ROLE_LIST_MARKER: | 2606 case WebAccessibility::ROLE_LIST_MARKER: |
| 2277 ia_role_ = ROLE_SYSTEM_LISTITEM; | 2607 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2608 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2278 break; | 2609 break; |
| 2279 case WebAccessibility::ROLE_MATH: | 2610 case WebAccessibility::ROLE_MATH: |
| 2280 ia_role_ = ROLE_SYSTEM_EQUATION; | 2611 ia_role_ = ROLE_SYSTEM_EQUATION; |
| 2612 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2281 break; | 2613 break; |
| 2282 case WebAccessibility::ROLE_MENU: | 2614 case WebAccessibility::ROLE_MENU: |
| 2283 case WebAccessibility::ROLE_MENU_BUTTON: | 2615 case WebAccessibility::ROLE_MENU_BUTTON: |
| 2284 ia_role_ = ROLE_SYSTEM_MENUPOPUP; | 2616 ia_role_ = ROLE_SYSTEM_MENUPOPUP; |
| 2285 break; | 2617 break; |
| 2286 case WebAccessibility::ROLE_MENU_BAR: | 2618 case WebAccessibility::ROLE_MENU_BAR: |
| 2287 ia_role_ = ROLE_SYSTEM_MENUBAR; | 2619 ia_role_ = ROLE_SYSTEM_MENUBAR; |
| 2288 break; | 2620 break; |
| 2289 case WebAccessibility::ROLE_MENU_ITEM: | 2621 case WebAccessibility::ROLE_MENU_ITEM: |
| 2290 case WebAccessibility::ROLE_MENU_LIST_OPTION: | 2622 case WebAccessibility::ROLE_MENU_LIST_OPTION: |
| 2291 ia_role_ = ROLE_SYSTEM_MENUITEM; | 2623 ia_role_ = ROLE_SYSTEM_MENUITEM; |
| 2292 break; | 2624 break; |
| 2293 case WebAccessibility::ROLE_MENU_LIST_POPUP: | 2625 case WebAccessibility::ROLE_MENU_LIST_POPUP: |
| 2294 ia_role_ = ROLE_SYSTEM_MENUPOPUP; | 2626 ia_role_ = ROLE_SYSTEM_MENUPOPUP; |
| 2295 break; | 2627 break; |
| 2296 case WebAccessibility::ROLE_NOTE: | 2628 case WebAccessibility::ROLE_NOTE: |
| 2297 ia_role_ = ROLE_SYSTEM_GROUPING; | 2629 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2298 ia2_role_ = IA2_ROLE_NOTE; | 2630 ia2_role_ = IA2_ROLE_NOTE; |
| 2631 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2299 break; | 2632 break; |
| 2300 case WebAccessibility::ROLE_OUTLINE: | 2633 case WebAccessibility::ROLE_OUTLINE: |
| 2301 ia_role_ = ROLE_SYSTEM_OUTLINE; | 2634 ia_role_ = ROLE_SYSTEM_OUTLINE; |
| 2635 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2302 break; | 2636 break; |
| 2303 case WebAccessibility::ROLE_POPUP_BUTTON: | 2637 case WebAccessibility::ROLE_POPUP_BUTTON: |
| 2304 ia_role_ = ROLE_SYSTEM_COMBOBOX; | 2638 if (html_tag == L"select") { |
| 2639 ia_role_ = ROLE_SYSTEM_COMBOBOX; | |
| 2640 } else { | |
| 2641 ia_role_ = ROLE_SYSTEM_BUTTONMENU; | |
| 2642 } | |
| 2643 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2305 break; | 2644 break; |
| 2306 case WebAccessibility::ROLE_PROGRESS_INDICATOR: | 2645 case WebAccessibility::ROLE_PROGRESS_INDICATOR: |
| 2307 ia_role_ = ROLE_SYSTEM_PROGRESSBAR; | 2646 ia_role_ = ROLE_SYSTEM_PROGRESSBAR; |
| 2647 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2308 break; | 2648 break; |
| 2309 case WebAccessibility::ROLE_RADIO_BUTTON: | 2649 case WebAccessibility::ROLE_RADIO_BUTTON: |
| 2310 ia_role_ = ROLE_SYSTEM_RADIOBUTTON; | 2650 ia_role_ = ROLE_SYSTEM_RADIOBUTTON; |
| 2311 break; | 2651 break; |
| 2312 case WebAccessibility::ROLE_RADIO_GROUP: | 2652 case WebAccessibility::ROLE_RADIO_GROUP: |
| 2313 ia_role_ = ROLE_SYSTEM_GROUPING; | 2653 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2314 ia2_role_ = IA2_ROLE_SECTION; | 2654 ia2_role_ = IA2_ROLE_SECTION; |
| 2315 break; | 2655 break; |
| 2316 case WebAccessibility::ROLE_REGION: | 2656 case WebAccessibility::ROLE_REGION: |
| 2317 ia_role_ = ROLE_SYSTEM_GROUPING; | 2657 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2318 ia2_role_ = IA2_ROLE_SECTION; | 2658 ia2_role_ = IA2_ROLE_SECTION; |
| 2659 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2319 break; | 2660 break; |
| 2320 case WebAccessibility::ROLE_ROW: | 2661 case WebAccessibility::ROLE_ROW: |
| 2321 ia_role_ = ROLE_SYSTEM_ROW; | 2662 ia_role_ = ROLE_SYSTEM_ROW; |
| 2663 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2322 break; | 2664 break; |
| 2323 case WebAccessibility::ROLE_ROW_HEADER: | 2665 case WebAccessibility::ROLE_ROW_HEADER: |
| 2324 ia_role_ = ROLE_SYSTEM_ROWHEADER; | 2666 ia_role_ = ROLE_SYSTEM_ROWHEADER; |
| 2667 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2325 break; | 2668 break; |
| 2326 case WebAccessibility::ROLE_RULER: | 2669 case WebAccessibility::ROLE_RULER: |
| 2327 ia_role_ = ROLE_SYSTEM_CLIENT; | 2670 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2328 ia2_role_ = IA2_ROLE_RULER; | 2671 ia2_role_ = IA2_ROLE_RULER; |
| 2672 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2329 break; | 2673 break; |
| 2330 case WebAccessibility::ROLE_SCROLLAREA: | 2674 case WebAccessibility::ROLE_SCROLLAREA: |
| 2331 ia_role_ = ROLE_SYSTEM_CLIENT; | 2675 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2332 ia2_role_ = IA2_ROLE_SCROLL_PANE; | 2676 ia2_role_ = IA2_ROLE_SCROLL_PANE; |
| 2677 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2333 break; | 2678 break; |
| 2334 case WebAccessibility::ROLE_SCROLLBAR: | 2679 case WebAccessibility::ROLE_SCROLLBAR: |
| 2335 ia_role_ = ROLE_SYSTEM_SCROLLBAR; | 2680 ia_role_ = ROLE_SYSTEM_SCROLLBAR; |
| 2336 break; | 2681 break; |
| 2337 case WebAccessibility::ROLE_SLIDER: | 2682 case WebAccessibility::ROLE_SLIDER: |
| 2338 ia_role_ = ROLE_SYSTEM_SLIDER; | 2683 ia_role_ = ROLE_SYSTEM_SLIDER; |
| 2339 break; | 2684 break; |
| 2340 case WebAccessibility::ROLE_SPLIT_GROUP: | 2685 case WebAccessibility::ROLE_SPLIT_GROUP: |
| 2341 ia_role_ = ROLE_SYSTEM_CLIENT; | 2686 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2342 ia2_role_ = IA2_ROLE_SPLIT_PANE; | 2687 ia2_role_ = IA2_ROLE_SPLIT_PANE; |
| 2688 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2343 break; | 2689 break; |
| 2344 case WebAccessibility::ROLE_ANNOTATION: | 2690 case WebAccessibility::ROLE_ANNOTATION: |
| 2345 case WebAccessibility::ROLE_STATIC_TEXT: | 2691 case WebAccessibility::ROLE_STATIC_TEXT: |
| 2346 ia_role_ = ROLE_SYSTEM_TEXT; | 2692 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2693 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2347 break; | 2694 break; |
| 2348 case WebAccessibility::ROLE_STATUS: | 2695 case WebAccessibility::ROLE_STATUS: |
| 2349 ia_role_ = ROLE_SYSTEM_STATUSBAR; | 2696 ia_role_ = ROLE_SYSTEM_STATUSBAR; |
| 2697 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2350 break; | 2698 break; |
| 2351 case WebAccessibility::ROLE_SPLITTER: | 2699 case WebAccessibility::ROLE_SPLITTER: |
| 2352 ia_role_ = ROLE_SYSTEM_SEPARATOR; | 2700 ia_role_ = ROLE_SYSTEM_SEPARATOR; |
| 2353 break; | 2701 break; |
| 2354 case WebAccessibility::ROLE_TAB: | 2702 case WebAccessibility::ROLE_TAB: |
| 2355 ia_role_ = ROLE_SYSTEM_PAGETAB; | 2703 ia_role_ = ROLE_SYSTEM_PAGETAB; |
| 2356 break; | 2704 break; |
| 2357 case WebAccessibility::ROLE_TABLE: | 2705 case WebAccessibility::ROLE_TABLE: |
| 2358 ia_role_ = ROLE_SYSTEM_TABLE; | 2706 ia_role_ = ROLE_SYSTEM_TABLE; |
| 2707 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2359 break; | 2708 break; |
| 2360 case WebAccessibility::ROLE_TABLE_HEADER_CONTAINER: | 2709 case WebAccessibility::ROLE_TABLE_HEADER_CONTAINER: |
| 2361 ia_role_ = ROLE_SYSTEM_GROUPING; | 2710 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2362 ia2_role_ = IA2_ROLE_SECTION; | 2711 ia2_role_ = IA2_ROLE_SECTION; |
| 2712 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2363 break; | 2713 break; |
| 2364 case WebAccessibility::ROLE_TAB_GROUP: | 2714 case WebAccessibility::ROLE_TAB_GROUP: |
| 2365 case WebAccessibility::ROLE_TAB_LIST: | 2715 case WebAccessibility::ROLE_TAB_LIST: |
| 2366 case WebAccessibility::ROLE_TAB_PANEL: | 2716 case WebAccessibility::ROLE_TAB_PANEL: |
| 2367 ia_role_ = ROLE_SYSTEM_PAGETABLIST; | 2717 ia_role_ = ROLE_SYSTEM_PAGETABLIST; |
| 2368 break; | 2718 break; |
| 2369 case WebAccessibility::ROLE_TEXTAREA: | 2719 case WebAccessibility::ROLE_TEXTAREA: |
| 2370 ia_role_ = ROLE_SYSTEM_TEXT; | 2720 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2371 ia2_state_ |= IA2_STATE_MULTI_LINE; | 2721 ia2_state_ |= IA2_STATE_MULTI_LINE; |
| 2372 ia2_state_ |= IA2_STATE_EDITABLE; | 2722 ia2_state_ |= IA2_STATE_EDITABLE; |
| 2373 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; | 2723 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; |
| 2374 break; | 2724 break; |
| 2375 case WebAccessibility::ROLE_TEXT_FIELD: | 2725 case WebAccessibility::ROLE_TEXT_FIELD: |
| 2376 ia_role_ = ROLE_SYSTEM_TEXT; | 2726 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2377 ia2_state_ |= IA2_STATE_SINGLE_LINE; | 2727 ia2_state_ |= IA2_STATE_SINGLE_LINE; |
| 2378 ia2_state_ |= IA2_STATE_EDITABLE; | 2728 ia2_state_ |= IA2_STATE_EDITABLE; |
| 2379 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; | 2729 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; |
| 2380 break; | 2730 break; |
| 2381 case WebAccessibility::ROLE_TIMER: | 2731 case WebAccessibility::ROLE_TIMER: |
| 2382 ia_role_ = ROLE_SYSTEM_CLOCK; | 2732 ia_role_ = ROLE_SYSTEM_CLOCK; |
| 2733 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2383 break; | 2734 break; |
| 2384 case WebAccessibility::ROLE_TOOLBAR: | 2735 case WebAccessibility::ROLE_TOOLBAR: |
| 2385 ia_role_ = ROLE_SYSTEM_TOOLBAR; | 2736 ia_role_ = ROLE_SYSTEM_TOOLBAR; |
| 2737 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2386 break; | 2738 break; |
| 2387 case WebAccessibility::ROLE_TOOLTIP: | 2739 case WebAccessibility::ROLE_TOOLTIP: |
| 2388 ia_role_ = ROLE_SYSTEM_TOOLTIP; | 2740 ia_role_ = ROLE_SYSTEM_TOOLTIP; |
| 2741 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2389 break; | 2742 break; |
| 2390 case WebAccessibility::ROLE_TREE: | 2743 case WebAccessibility::ROLE_TREE: |
| 2391 ia_role_ = ROLE_SYSTEM_OUTLINE; | 2744 ia_role_ = ROLE_SYSTEM_OUTLINE; |
| 2745 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2392 break; | 2746 break; |
| 2393 case WebAccessibility::ROLE_TREE_GRID: | 2747 case WebAccessibility::ROLE_TREE_GRID: |
| 2394 ia_role_ = ROLE_SYSTEM_OUTLINE; | 2748 ia_role_ = ROLE_SYSTEM_OUTLINE; |
| 2749 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2395 break; | 2750 break; |
| 2396 case WebAccessibility::ROLE_TREE_ITEM: | 2751 case WebAccessibility::ROLE_TREE_ITEM: |
| 2397 ia_role_ = ROLE_SYSTEM_OUTLINEITEM; | 2752 ia_role_ = ROLE_SYSTEM_OUTLINEITEM; |
| 2753 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2398 break; | 2754 break; |
| 2399 case WebAccessibility::ROLE_WINDOW: | 2755 case WebAccessibility::ROLE_WINDOW: |
| 2400 ia_role_ = ROLE_SYSTEM_WINDOW; | 2756 ia_role_ = ROLE_SYSTEM_WINDOW; |
| 2401 break; | 2757 break; |
| 2402 | 2758 |
| 2403 // TODO(dmazzoni): figure out the proper MSAA role for all of these. | 2759 // TODO(dmazzoni): figure out the proper MSAA role for all of these. |
| 2404 case WebAccessibility::ROLE_BROWSER: | 2760 case WebAccessibility::ROLE_BROWSER: |
| 2405 case WebAccessibility::ROLE_DIRECTORY: | 2761 case WebAccessibility::ROLE_DIRECTORY: |
| 2406 case WebAccessibility::ROLE_DRAWER: | 2762 case WebAccessibility::ROLE_DRAWER: |
| 2407 case WebAccessibility::ROLE_HELP_TAG: | 2763 case WebAccessibility::ROLE_HELP_TAG: |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 2421 } | 2777 } |
| 2422 | 2778 |
| 2423 // The role should always be set. | 2779 // The role should always be set. |
| 2424 DCHECK(!role_name_.empty() || ia_role_); | 2780 DCHECK(!role_name_.empty() || ia_role_); |
| 2425 | 2781 |
| 2426 // If we didn't explicitly set the IAccessible2 role, make it the same | 2782 // If we didn't explicitly set the IAccessible2 role, make it the same |
| 2427 // as the MSAA role. | 2783 // as the MSAA role. |
| 2428 if (!ia2_role_) | 2784 if (!ia2_role_) |
| 2429 ia2_role_ = ia_role_; | 2785 ia2_role_ = ia_role_; |
| 2430 } | 2786 } |
| OLD | NEW |