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 } |
| 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; |
| 626 | 634 |
| 627 int columns; | 635 int columns; |
| 628 int rows; | 636 int rows; |
| 629 if (!GetIntAttribute(WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || | 637 if (!GetIntAttribute(WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 630 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) || | 638 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) || |
| 631 columns <= 0 || | 639 columns <= 0 || |
| 632 rows <= 0) { | 640 rows <= 0) { |
| 633 return S_FALSE; | 641 return S_FALSE; |
| 634 } | 642 } |
| 635 | 643 |
| 636 if (column < 0 || column >= columns) | 644 if (column < 0 || column >= columns) |
| 637 return E_INVALIDARG; | 645 return E_INVALIDARG; |
| 638 | 646 |
| 639 for (int i = 0; i < rows; i++) { | 647 for (int i = 0; i < rows; ++i) { |
| 640 int cell_id = cell_ids_[i * columns + column]; | 648 int cell_id = cell_ids_[i * columns + column]; |
| 641 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 649 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 642 manager_->GetFromRendererID(cell_id)); | 650 manager_->GetFromRendererID(cell_id)); |
| 643 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) { | 651 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) { |
| 644 if (cell->name_.size() > 0) { | 652 if (cell->name_.size() > 0) { |
| 645 *description = SysAllocString(cell->name_.c_str()); | 653 *description = SysAllocString(cell->name_.c_str()); |
| 646 return S_OK; | 654 return S_OK; |
| 647 } | 655 } |
| 648 | 656 |
| 649 return cell->GetStringAttributeAsBstr( | 657 return cell->GetStringAttributeAsBstr( |
| (...skipping 50 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)); | |
|
Chris Guillory
2011/08/31 02:14:53
toBrowserAccessibilityWin()
dmazzoni
2011/08/31 22:02:54
Done.
| |
| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 809 if (!GetIntAttribute(WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || | 820 if (!GetIntAttribute(WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 810 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) || | 821 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) || |
| 811 columns <= 0 || | 822 columns <= 0 || |
| 812 rows <= 0) { | 823 rows <= 0) { |
| 813 return S_FALSE; | 824 return S_FALSE; |
| 814 } | 825 } |
| 815 | 826 |
| 816 if (row < 0 || row >= rows) | 827 if (row < 0 || row >= rows) |
| 817 return E_INVALIDARG; | 828 return E_INVALIDARG; |
| 818 | 829 |
| 819 for (int i = 0; i < columns; i++) { | 830 for (int i = 0; i < columns; ++i) { |
| 820 int cell_id = cell_ids_[row * columns + i]; | 831 int cell_id = cell_ids_[row * columns + i]; |
| 821 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 832 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 822 manager_->GetFromRendererID(cell_id)); | 833 manager_->GetFromRendererID(cell_id)); |
| 823 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) { | 834 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) { |
| 824 if (cell->name_.size() > 0) { | 835 if (cell->name_.size() > 0) { |
| 825 *description = SysAllocString(cell->name_.c_str()); | 836 *description = SysAllocString(cell->name_.c_str()); |
| 826 return S_OK; | 837 return S_OK; |
| 827 } | 838 } |
| 828 | 839 |
| 829 return cell->GetStringAttributeAsBstr( | 840 return cell->GetStringAttributeAsBstr( |
| (...skipping 50 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*>( | |
|
Chris Guillory
2011/08/31 02:14:53
toBrowserAccessibilityWin()
| |
| 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) |
| 915 return E_INVALIDARG; | 929 return E_INVALIDARG; |
| 916 | 930 |
| 931 // TODO(dmazzoni): Implement this. | |
| 917 *n_children = 0; | 932 *n_children = 0; |
| 918 return S_OK; | 933 return S_OK; |
| 919 } | 934 } |
| 920 | 935 |
| 921 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns( | 936 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns( |
| 922 long max_columns, | 937 long max_columns, |
| 923 long** columns, | 938 long** columns, |
| 924 long* n_columns) { | 939 long* n_columns) { |
| 925 if (!instance_active_) | 940 if (!instance_active_) |
| 926 return E_FAIL; | 941 return E_FAIL; |
| 927 | 942 |
| 928 if (!columns || !n_columns) | 943 if (!columns || !n_columns) |
| 929 return E_INVALIDARG; | 944 return E_INVALIDARG; |
| 930 | 945 |
| 946 // TODO(dmazzoni): Implement this. | |
| 931 *n_columns = 0; | 947 *n_columns = 0; |
| 932 return S_OK; | 948 return S_OK; |
| 933 } | 949 } |
| 934 | 950 |
| 935 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows( | 951 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows( |
| 936 long max_rows, | 952 long max_rows, |
| 937 long** rows, | 953 long** rows, |
| 938 long* n_rows) { | 954 long* n_rows) { |
| 939 if (!instance_active_) | 955 if (!instance_active_) |
| 940 return E_FAIL; | 956 return E_FAIL; |
| 941 | 957 |
| 942 if (!rows || !n_rows) | 958 if (!rows || !n_rows) |
| 943 return E_INVALIDARG; | 959 return E_INVALIDARG; |
| 944 | 960 |
| 961 // TODO(dmazzoni): Implement this. | |
| 945 *n_rows = 0; | 962 *n_rows = 0; |
| 946 return S_OK; | 963 return S_OK; |
| 947 } | 964 } |
| 948 | 965 |
| 949 STDMETHODIMP BrowserAccessibilityWin::get_summary( | 966 STDMETHODIMP BrowserAccessibilityWin::get_summary( |
| 950 IUnknown** accessible) { | 967 IUnknown** accessible) { |
| 951 if (!instance_active_) | 968 if (!instance_active_) |
| 952 return E_FAIL; | 969 return E_FAIL; |
| 953 | 970 |
| 954 if (!accessible) | 971 if (!accessible) |
| 955 return E_INVALIDARG; | 972 return E_INVALIDARG; |
| 956 | 973 |
| 957 // TODO(dmazzoni): implement | 974 // TODO(dmazzoni): implement |
| 958 return S_FALSE; | 975 return S_FALSE; |
| 959 } | 976 } |
| 960 | 977 |
| 961 STDMETHODIMP BrowserAccessibilityWin::get_isColumnSelected( | 978 STDMETHODIMP BrowserAccessibilityWin::get_isColumnSelected( |
| 962 long column, | 979 long column, |
| 963 boolean* is_selected) { | 980 boolean* is_selected) { |
| 964 if (!instance_active_) | 981 if (!instance_active_) |
| 965 return E_FAIL; | 982 return E_FAIL; |
| 966 | 983 |
| 967 if (!is_selected) | 984 if (!is_selected) |
| 968 return E_INVALIDARG; | 985 return E_INVALIDARG; |
| 969 | 986 |
| 987 // TODO(dmazzoni): Implement this. | |
| 970 *is_selected = false; | 988 *is_selected = false; |
| 971 return S_OK; | 989 return S_OK; |
| 972 } | 990 } |
| 973 | 991 |
| 974 STDMETHODIMP BrowserAccessibilityWin::get_isRowSelected( | 992 STDMETHODIMP BrowserAccessibilityWin::get_isRowSelected( |
| 975 long row, | 993 long row, |
| 976 boolean* is_selected) { | 994 boolean* is_selected) { |
| 977 if (!instance_active_) | 995 if (!instance_active_) |
| 978 return E_FAIL; | 996 return E_FAIL; |
| 979 | 997 |
| 980 if (!is_selected) | 998 if (!is_selected) |
| 981 return E_INVALIDARG; | 999 return E_INVALIDARG; |
| 982 | 1000 |
| 1001 // TODO(dmazzoni): Implement this. | |
| 983 *is_selected = false; | 1002 *is_selected = false; |
| 984 return S_OK; | 1003 return S_OK; |
| 985 } | 1004 } |
| 986 | 1005 |
| 987 STDMETHODIMP BrowserAccessibilityWin::get_isSelected( | 1006 STDMETHODIMP BrowserAccessibilityWin::get_isSelected( |
| 988 long row, | 1007 long row, |
| 989 long column, | 1008 long column, |
| 990 boolean* is_selected) { | 1009 boolean* is_selected) { |
| 991 if (!instance_active_) | 1010 if (!instance_active_) |
| 992 return E_FAIL; | 1011 return E_FAIL; |
| 993 | 1012 |
| 994 if (!is_selected) | 1013 if (!is_selected) |
| 995 return E_INVALIDARG; | 1014 return E_INVALIDARG; |
| 996 | 1015 |
| 1016 // TODO(dmazzoni): Implement this. | |
| 997 *is_selected = false; | 1017 *is_selected = false; |
| 998 return S_OK; | 1018 return S_OK; |
| 999 } | 1019 } |
| 1000 | 1020 |
| 1001 STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtentsAtIndex( | 1021 STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtentsAtIndex( |
| 1002 long index, | 1022 long index, |
| 1003 long* row, | 1023 long* row, |
| 1004 long* column, | 1024 long* column, |
| 1005 long* row_extents, | 1025 long* row_extents, |
| 1006 long* column_extents, | 1026 long* column_extents, |
| 1007 boolean* is_selected) { | 1027 boolean* is_selected) { |
| 1008 if (!instance_active_) | 1028 if (!instance_active_) |
| 1009 return E_FAIL; | 1029 return E_FAIL; |
| 1010 | 1030 |
| 1011 if (!row || !column || !row_extents || !column_extents || !is_selected) | 1031 if (!row || !column || !row_extents || !column_extents || !is_selected) |
| 1012 return E_INVALIDARG; | 1032 return E_INVALIDARG; |
| 1013 | 1033 |
| 1014 int columns; | 1034 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); |
| 1015 int rows; | 1035 if (index < 0) |
| 1016 if (!GetIntAttribute(WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1036 return E_INVALIDARG; |
| 1017 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) || | 1037 if (index >= cell_id_count) |
| 1018 columns <= 0 || | |
| 1019 rows <= 0) { | |
| 1020 return S_FALSE; | 1038 return S_FALSE; |
| 1021 } | |
| 1022 | 1039 |
| 1023 if (index < 0 || index >= columns * rows) | 1040 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*>( | 1041 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1030 manager_->GetFromRendererID(cell_id)); | 1042 manager_->GetFromRendererID(cell_id)); |
| 1031 int rowspan; | 1043 int rowspan; |
| 1032 int colspan; | 1044 int colspan; |
| 1033 if (cell && | 1045 if (cell && |
| 1034 cell->GetIntAttribute( | 1046 cell->GetIntAttribute( |
| 1035 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && | 1047 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && |
| 1036 cell->GetIntAttribute( | 1048 cell->GetIntAttribute( |
| 1037 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && | 1049 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && |
| 1038 rowspan >= 1 && | 1050 rowspan >= 1 && |
| 1039 colspan >= 1) { | 1051 colspan >= 1) { |
| 1040 *row_extents = rowspan; | 1052 *row_extents = rowspan; |
| 1041 *column_extents = colspan; | 1053 *column_extents = colspan; |
| 1042 return S_OK; | 1054 return S_OK; |
| 1043 } | 1055 } |
| 1044 | 1056 |
| 1045 return S_FALSE; | 1057 return S_FALSE; |
| 1046 } | 1058 } |
| 1047 | 1059 |
| 1048 // | 1060 // |
| 1061 // IAccessibleTable2 methods. | |
| 1062 // | |
| 1063 | |
| 1064 STDMETHODIMP BrowserAccessibilityWin::get_cellAt( | |
| 1065 long row, | |
| 1066 long column, | |
| 1067 IUnknown** cell) { | |
| 1068 return get_accessibleAt(row, column, cell); | |
| 1069 } | |
| 1070 | |
| 1071 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedCells(long* cell_count) { | |
| 1072 return get_nSelectedChildren(cell_count); | |
| 1073 } | |
| 1074 | |
| 1075 STDMETHODIMP BrowserAccessibilityWin::get_selectedCells( | |
| 1076 IUnknown*** cells, | |
| 1077 long* n_selected_cells) { | |
| 1078 if (!instance_active_) | |
| 1079 return E_FAIL; | |
| 1080 | |
| 1081 if (!cells || !n_selected_cells) | |
| 1082 return E_INVALIDARG; | |
| 1083 | |
| 1084 // TODO(dmazzoni): Implement this. | |
| 1085 *n_selected_cells = 0; | |
| 1086 return S_OK; | |
| 1087 } | |
| 1088 | |
| 1089 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns( | |
| 1090 long** columns, | |
| 1091 long* n_columns) { | |
| 1092 if (!instance_active_) | |
| 1093 return E_FAIL; | |
| 1094 | |
| 1095 if (!columns || !n_columns) | |
| 1096 return E_INVALIDARG; | |
| 1097 | |
| 1098 // TODO(dmazzoni): Implement this. | |
| 1099 *n_columns = 0; | |
| 1100 return S_OK; | |
| 1101 } | |
| 1102 | |
| 1103 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows( | |
| 1104 long** rows, | |
| 1105 long* n_rows) { | |
| 1106 if (!instance_active_) | |
| 1107 return E_FAIL; | |
| 1108 | |
| 1109 if (!rows || !n_rows) | |
| 1110 return E_INVALIDARG; | |
| 1111 | |
| 1112 // TODO(dmazzoni): Implement this. | |
| 1113 *n_rows = 0; | |
| 1114 return S_OK; | |
| 1115 } | |
| 1116 | |
| 1117 | |
| 1118 // | |
| 1049 // IAccessibleTableCell methods. | 1119 // IAccessibleTableCell methods. |
| 1050 // | 1120 // |
| 1051 | 1121 |
| 1052 STDMETHODIMP BrowserAccessibilityWin::get_columnExtent( | 1122 STDMETHODIMP BrowserAccessibilityWin::get_columnExtent( |
| 1053 long* n_columns_spanned) { | 1123 long* n_columns_spanned) { |
| 1054 if (!instance_active_) | 1124 if (!instance_active_) |
| 1055 return E_FAIL; | 1125 return E_FAIL; |
| 1056 | 1126 |
| 1057 if (!n_columns_spanned) | 1127 if (!n_columns_spanned) |
| 1058 return E_INVALIDARG; | 1128 return E_INVALIDARG; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1081 | 1151 |
| 1082 int column; | 1152 int column; |
| 1083 if (!GetIntAttribute( | 1153 if (!GetIntAttribute( |
| 1084 WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX, &column)) { | 1154 WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX, &column)) { |
| 1085 return S_FALSE; | 1155 return S_FALSE; |
| 1086 } | 1156 } |
| 1087 | 1157 |
| 1088 BrowserAccessibility* table = parent(); | 1158 BrowserAccessibility* table = parent(); |
| 1089 while (table && table->role() != WebAccessibility::ROLE_TABLE) | 1159 while (table && table->role() != WebAccessibility::ROLE_TABLE) |
| 1090 table = table->parent(); | 1160 table = table->parent(); |
| 1091 if (!table) | 1161 if (!table) { |
| 1162 DCHECK(false); | |
|
Chris Guillory
2011/08/31 02:14:53
NOTREACHED()
| |
| 1092 return S_FALSE; | 1163 return S_FALSE; |
| 1164 } | |
| 1093 | 1165 |
| 1094 int columns; | 1166 int columns; |
| 1095 int rows; | 1167 int rows; |
| 1096 if (!table->GetIntAttribute( | 1168 if (!table->GetIntAttribute( |
| 1097 WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1169 WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1098 !table->GetIntAttribute( | 1170 !table->GetIntAttribute( |
| 1099 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) { | 1171 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) { |
| 1100 return S_FALSE; | 1172 return S_FALSE; |
| 1101 } | 1173 } |
| 1102 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) | 1174 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) |
| 1103 return S_FALSE; | 1175 return S_FALSE; |
| 1104 | 1176 |
| 1105 for (int i = 0; i < rows; i++) { | 1177 for (int i = 0; i < rows; ++i) { |
| 1106 int cell_id = table->cell_ids()[i * columns + column]; | 1178 int cell_id = table->cell_ids()[i * columns + column]; |
| 1107 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1179 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1108 manager_->GetFromRendererID(cell_id)); | 1180 manager_->GetFromRendererID(cell_id)); |
| 1109 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) | 1181 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) |
| 1110 (*n_column_header_cells)++; | 1182 (*n_column_header_cells)++; |
| 1111 } | 1183 } |
| 1112 | 1184 |
| 1113 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( | 1185 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( |
| 1114 (*n_column_header_cells) * sizeof(cell_accessibles[0]))); | 1186 (*n_column_header_cells) * sizeof(cell_accessibles[0]))); |
| 1115 int index = 0; | 1187 int index = 0; |
| 1116 for (int i = 0; i < rows; i++) { | 1188 for (int i = 0; i < rows; ++i) { |
| 1117 int cell_id = table->cell_ids()[i * columns + column]; | 1189 int cell_id = table->cell_ids()[i * columns + column]; |
| 1118 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1190 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1119 manager_->GetFromRendererID(cell_id)); | 1191 manager_->GetFromRendererID(cell_id)); |
| 1120 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) { | 1192 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) { |
| 1121 (*cell_accessibles)[index] = | 1193 (*cell_accessibles)[index] = |
| 1122 static_cast<IAccessible*>(cell->NewReference()); | 1194 static_cast<IAccessible*>(cell->NewReference()); |
| 1123 index++; | 1195 ++index; |
| 1124 } | 1196 } |
| 1125 } | 1197 } |
| 1126 | 1198 |
| 1127 return S_OK; | 1199 return S_OK; |
| 1128 } | 1200 } |
| 1129 | 1201 |
| 1130 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex( | 1202 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex( |
| 1131 long* column_index) { | 1203 long* column_index) { |
| 1132 if (!instance_active_) | 1204 if (!instance_active_) |
| 1133 return E_FAIL; | 1205 return E_FAIL; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1177 | 1249 |
| 1178 int row; | 1250 int row; |
| 1179 if (!GetIntAttribute( | 1251 if (!GetIntAttribute( |
| 1180 WebAccessibility::ATTR_TABLE_CELL_ROW_INDEX, &row)) { | 1252 WebAccessibility::ATTR_TABLE_CELL_ROW_INDEX, &row)) { |
| 1181 return S_FALSE; | 1253 return S_FALSE; |
| 1182 } | 1254 } |
| 1183 | 1255 |
| 1184 BrowserAccessibility* table = parent(); | 1256 BrowserAccessibility* table = parent(); |
| 1185 while (table && table->role() != WebAccessibility::ROLE_TABLE) | 1257 while (table && table->role() != WebAccessibility::ROLE_TABLE) |
| 1186 table = table->parent(); | 1258 table = table->parent(); |
| 1187 if (!table) | 1259 if (!table) { |
| 1260 DCHECK(false); | |
|
Chris Guillory
2011/08/31 02:14:53
NOTREACHED()
dmazzoni
2011/08/31 22:02:54
Done.
| |
| 1188 return S_FALSE; | 1261 return S_FALSE; |
| 1262 } | |
| 1189 | 1263 |
| 1190 int columns; | 1264 int columns; |
| 1191 int rows; | 1265 int rows; |
| 1192 if (!table->GetIntAttribute( | 1266 if (!table->GetIntAttribute( |
| 1193 WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1267 WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1194 !table->GetIntAttribute( | 1268 !table->GetIntAttribute( |
| 1195 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) { | 1269 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) { |
| 1196 return S_FALSE; | 1270 return S_FALSE; |
| 1197 } | 1271 } |
| 1198 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) | 1272 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) |
| 1199 return S_FALSE; | 1273 return S_FALSE; |
| 1200 | 1274 |
| 1201 for (int i = 0; i < columns; i++) { | 1275 for (int i = 0; i < columns; ++i) { |
| 1202 int cell_id = table->cell_ids()[row * columns + i]; | 1276 int cell_id = table->cell_ids()[row * columns + i]; |
| 1203 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1277 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1204 manager_->GetFromRendererID(cell_id)); | 1278 manager_->GetFromRendererID(cell_id)); |
| 1205 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) | 1279 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) |
| 1206 (*n_row_header_cells)++; | 1280 (*n_row_header_cells)++; |
| 1207 } | 1281 } |
| 1208 | 1282 |
| 1209 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( | 1283 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( |
| 1210 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); | 1284 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); |
| 1211 int index = 0; | 1285 int index = 0; |
| 1212 for (int i = 0; i < columns; i++) { | 1286 for (int i = 0; i < columns; ++i) { |
| 1213 int cell_id = table->cell_ids()[row * columns + i]; | 1287 int cell_id = table->cell_ids()[row * columns + i]; |
| 1214 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1288 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1215 manager_->GetFromRendererID(cell_id)); | 1289 manager_->GetFromRendererID(cell_id)); |
| 1216 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) { | 1290 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) { |
| 1217 (*cell_accessibles)[index] = | 1291 (*cell_accessibles)[index] = |
| 1218 static_cast<IAccessible*>(cell->NewReference()); | 1292 static_cast<IAccessible*>(cell->NewReference()); |
| 1219 index++; | 1293 ++index; |
| 1220 } | 1294 } |
| 1221 } | 1295 } |
| 1222 | 1296 |
| 1223 return S_OK; | 1297 return S_OK; |
| 1224 } | 1298 } |
| 1225 | 1299 |
| 1226 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex( | 1300 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex( |
| 1227 long* row_index) { | 1301 long* row_index) { |
| 1228 if (!instance_active_) | 1302 if (!instance_active_) |
| 1229 return E_FAIL; | 1303 return E_FAIL; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1291 } | 1365 } |
| 1292 | 1366 |
| 1293 STDMETHODIMP BrowserAccessibilityWin::get_table( | 1367 STDMETHODIMP BrowserAccessibilityWin::get_table( |
| 1294 IUnknown** table) { | 1368 IUnknown** table) { |
| 1295 if (!instance_active_) | 1369 if (!instance_active_) |
| 1296 return E_FAIL; | 1370 return E_FAIL; |
| 1297 | 1371 |
| 1298 if (!table) | 1372 if (!table) |
| 1299 return E_INVALIDARG; | 1373 return E_INVALIDARG; |
| 1300 | 1374 |
| 1375 | |
| 1376 int row; | |
| 1377 int column; | |
| 1378 GetIntAttribute(WebAccessibility::ATTR_TABLE_CELL_ROW_INDEX, &row); | |
| 1379 GetIntAttribute(WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX, &column); | |
| 1380 | |
| 1301 BrowserAccessibility* find_table = parent(); | 1381 BrowserAccessibility* find_table = parent(); |
| 1302 while (find_table && find_table->role() != WebAccessibility::ROLE_TABLE) | 1382 while (find_table && find_table->role() != WebAccessibility::ROLE_TABLE) |
| 1303 find_table = find_table->parent(); | 1383 find_table = find_table->parent(); |
| 1304 if (!find_table) | 1384 if (!find_table) { |
| 1385 DCHECK(false); | |
|
Chris Guillory
2011/08/31 02:14:53
NOTREACHED()
| |
| 1305 return S_FALSE; | 1386 return S_FALSE; |
| 1387 } | |
| 1306 | 1388 |
| 1307 *table = static_cast<IAccessible*>( | 1389 *table = static_cast<IAccessibleTable*>( |
|
Chris Guillory
2011/08/31 02:14:53
toBrowserAccessibilityWin(). IAccessibleTable* cas
dmazzoni
2011/08/31 22:02:54
Switched to use toBrowserAccessibilityWin(), but t
| |
| 1308 static_cast<BrowserAccessibilityWin*>(find_table)->NewReference()); | 1390 static_cast<BrowserAccessibilityWin*>(find_table)->NewReference()); |
| 1309 | 1391 |
| 1310 return S_OK; | 1392 return S_OK; |
| 1311 } | 1393 } |
| 1312 | 1394 |
| 1313 // | 1395 // |
| 1314 // IAccessibleText methods. | 1396 // IAccessibleText methods. |
| 1315 // | 1397 // |
| 1316 | 1398 |
| 1317 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { | 1399 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1519 return S_FALSE; | 1601 return S_FALSE; |
| 1520 } | 1602 } |
| 1521 | 1603 |
| 1522 const string16& text_str = TextForIAccessibleText(); | 1604 const string16& text_str = TextForIAccessibleText(); |
| 1523 | 1605 |
| 1524 *start_offset = offset; | 1606 *start_offset = offset; |
| 1525 *end_offset = FindBoundary(text_str, boundary_type, offset, 1); | 1607 *end_offset = FindBoundary(text_str, boundary_type, offset, 1); |
| 1526 return get_text(*start_offset, *end_offset, text); | 1608 return get_text(*start_offset, *end_offset, text); |
| 1527 } | 1609 } |
| 1528 | 1610 |
| 1611 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { | |
| 1612 if (!instance_active_) | |
| 1613 return E_FAIL; | |
| 1614 | |
| 1615 if (!new_text) | |
| 1616 return E_INVALIDARG; | |
| 1617 | |
| 1618 string16 text = TextForIAccessibleText(); | |
| 1619 | |
| 1620 new_text->text = SysAllocString(text.c_str()); | |
| 1621 new_text->start = 0; | |
| 1622 new_text->end = static_cast<long>(text.size()); | |
|
Chris Guillory
2011/08/31 02:14:53
Verification: string16 keeps a local for the text
dmazzoni
2011/08/31 22:02:54
Correct, this is O(1)
| |
| 1623 return S_OK; | |
| 1624 } | |
| 1625 | |
| 1626 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { | |
| 1627 if (!instance_active_) | |
| 1628 return E_FAIL; | |
| 1629 | |
| 1630 if (!old_text) | |
| 1631 return E_INVALIDARG; | |
| 1632 | |
| 1633 old_text->text = SysAllocString(old_text_.c_str()); | |
| 1634 old_text->start = 0; | |
| 1635 old_text->end = static_cast<long>(old_text_.size()); | |
| 1636 return S_OK; | |
| 1637 } | |
| 1638 | |
| 1639 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( | |
| 1640 LONG x, LONG y, enum IA2CoordinateType coord_type, LONG* offset) { | |
| 1641 if (!instance_active_) | |
| 1642 return E_FAIL; | |
| 1643 | |
| 1644 if (!offset) | |
| 1645 return E_INVALIDARG; | |
| 1646 | |
| 1647 // TODO(dmazzoni): implement this. We're returning S_OK for now so that | |
| 1648 // screen readers still return partially accurate results rather than | |
| 1649 // completely failing. | |
| 1650 *offset = 0; | |
| 1651 return S_OK; | |
| 1652 } | |
| 1653 | |
| 1654 // | |
| 1655 // IAccessibleValue methods. | |
| 1656 // | |
| 1657 | |
| 1658 STDMETHODIMP BrowserAccessibilityWin::get_currentValue(VARIANT* value) { | |
| 1659 if (!instance_active_) | |
| 1660 return E_FAIL; | |
| 1661 | |
| 1662 if (!value) | |
| 1663 return E_INVALIDARG; | |
| 1664 | |
| 1665 float float_val; | |
| 1666 if (GetFloatAttribute(WebAccessibility::ATTR_VALUE_FOR_RANGE, &float_val)) { | |
| 1667 value->vt = VT_R8; | |
| 1668 value->dblVal = float_val; | |
| 1669 return S_OK; | |
| 1670 } | |
| 1671 | |
| 1672 value->vt = VT_EMPTY; | |
| 1673 return S_FALSE; | |
| 1674 } | |
| 1675 | |
| 1676 STDMETHODIMP BrowserAccessibilityWin::get_minimumValue(VARIANT* value) { | |
| 1677 if (!instance_active_) | |
| 1678 return E_FAIL; | |
| 1679 | |
| 1680 if (!value) | |
| 1681 return E_INVALIDARG; | |
| 1682 | |
| 1683 float float_val; | |
| 1684 if (GetFloatAttribute(WebAccessibility::ATTR_MIN_VALUE_FOR_RANGE, | |
| 1685 &float_val)) { | |
| 1686 value->vt = VT_R8; | |
| 1687 value->dblVal = float_val; | |
| 1688 return S_OK; | |
| 1689 } | |
| 1690 | |
| 1691 value->vt = VT_EMPTY; | |
| 1692 return S_FALSE; | |
| 1693 } | |
| 1694 | |
| 1695 STDMETHODIMP BrowserAccessibilityWin::get_maximumValue(VARIANT* value) { | |
| 1696 if (!instance_active_) | |
| 1697 return E_FAIL; | |
| 1698 | |
| 1699 if (!value) | |
| 1700 return E_INVALIDARG; | |
| 1701 | |
| 1702 float float_val; | |
| 1703 if (GetFloatAttribute(WebAccessibility::ATTR_MAX_VALUE_FOR_RANGE, | |
| 1704 &float_val)) { | |
| 1705 value->vt = VT_R8; | |
| 1706 value->dblVal = float_val; | |
| 1707 return S_OK; | |
| 1708 } | |
| 1709 | |
| 1710 value->vt = VT_EMPTY; | |
| 1711 return S_FALSE; | |
| 1712 } | |
| 1713 | |
| 1714 STDMETHODIMP BrowserAccessibilityWin::setCurrentValue(VARIANT new_value) { | |
| 1715 // TODO(dmazzoni): Implement this. | |
| 1716 return E_NOTIMPL; | |
| 1717 } | |
| 1718 | |
| 1529 // | 1719 // |
| 1530 // ISimpleDOMDocument methods. | 1720 // ISimpleDOMDocument methods. |
| 1531 // | 1721 // |
| 1532 | 1722 |
| 1533 STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) { | 1723 STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) { |
| 1534 if (!instance_active_) | 1724 if (!instance_active_) |
| 1535 return E_FAIL; | 1725 return E_FAIL; |
| 1536 | 1726 |
| 1537 if (!url) | 1727 if (!url) |
| 1538 return E_INVALIDARG; | 1728 return E_INVALIDARG; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1700 BSTR* style_properties, | 1890 BSTR* style_properties, |
| 1701 BSTR* style_values) { | 1891 BSTR* style_values) { |
| 1702 if (!instance_active_) | 1892 if (!instance_active_) |
| 1703 return E_FAIL; | 1893 return E_FAIL; |
| 1704 | 1894 |
| 1705 if (!style_properties || !style_values) | 1895 if (!style_properties || !style_values) |
| 1706 return E_INVALIDARG; | 1896 return E_INVALIDARG; |
| 1707 | 1897 |
| 1708 // We only cache a single style property for now: DISPLAY | 1898 // We only cache a single style property for now: DISPLAY |
| 1709 | 1899 |
| 1710 for (unsigned short i = 0; i < num_style_properties; i++) { | 1900 for (unsigned short i = 0; i < num_style_properties; ++i) { |
| 1711 string16 name = (LPCWSTR)style_properties[i]; | 1901 string16 name = (LPCWSTR)style_properties[i]; |
| 1712 StringToLowerASCII(&name); | 1902 StringToLowerASCII(&name); |
| 1713 if (name == L"display") { | 1903 if (name == L"display") { |
| 1714 string16 display; | 1904 string16 display; |
| 1715 GetStringAttribute(WebAccessibility::ATTR_DISPLAY, &display); | 1905 GetStringAttribute(WebAccessibility::ATTR_DISPLAY, &display); |
| 1716 style_values[i] = SysAllocString(display.c_str()); | 1906 style_values[i] = SysAllocString(display.c_str()); |
| 1717 } else { | 1907 } else { |
| 1718 style_values[i] = NULL; | 1908 style_values[i] = NULL; |
| 1719 } | 1909 } |
| 1720 } | 1910 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1846 | 2036 |
| 1847 // | 2037 // |
| 1848 // IServiceProvider methods. | 2038 // IServiceProvider methods. |
| 1849 // | 2039 // |
| 1850 | 2040 |
| 1851 STDMETHODIMP BrowserAccessibilityWin::QueryService( | 2041 STDMETHODIMP BrowserAccessibilityWin::QueryService( |
| 1852 REFGUID guidService, REFIID riid, void** object) { | 2042 REFGUID guidService, REFIID riid, void** object) { |
| 1853 if (!instance_active_) | 2043 if (!instance_active_) |
| 1854 return E_FAIL; | 2044 return E_FAIL; |
| 1855 | 2045 |
| 1856 if (guidService == IID_IAccessibleTable) { | |
| 1857 printf("iatable"); | |
| 1858 } | |
| 1859 if (guidService == IID_IAccessibleTableCell) { | |
| 1860 printf("iatable"); | |
| 1861 } | |
| 1862 | |
| 1863 if (guidService == IID_IAccessible || | 2046 if (guidService == IID_IAccessible || |
| 1864 guidService == IID_IAccessible2 || | 2047 guidService == IID_IAccessible2 || |
| 1865 guidService == IID_IAccessibleImage || | 2048 guidService == IID_IAccessibleImage || |
| 1866 guidService == IID_IAccessibleTable || | 2049 guidService == IID_IAccessibleTable || |
| 2050 guidService == IID_IAccessibleTable2 || | |
| 1867 guidService == IID_IAccessibleTableCell || | 2051 guidService == IID_IAccessibleTableCell || |
| 1868 guidService == IID_IAccessibleText || | 2052 guidService == IID_IAccessibleText || |
| 2053 guidService == IID_IAccessibleValue || | |
| 1869 guidService == IID_ISimpleDOMDocument || | 2054 guidService == IID_ISimpleDOMDocument || |
| 1870 guidService == IID_ISimpleDOMNode || | 2055 guidService == IID_ISimpleDOMNode || |
| 1871 guidService == IID_ISimpleDOMText || | 2056 guidService == IID_ISimpleDOMText || |
| 1872 guidService == GUID_ISimpleDOM) { | 2057 guidService == GUID_ISimpleDOM) { |
| 1873 return QueryInterface(riid, object); | 2058 return QueryInterface(riid, object); |
| 1874 } | 2059 } |
| 1875 | 2060 |
| 1876 *object = NULL; | 2061 *object = NULL; |
| 1877 return E_FAIL; | 2062 return E_FAIL; |
| 1878 } | 2063 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1889 if (iid == IID_IAccessibleText) { | 2074 if (iid == IID_IAccessibleText) { |
| 1890 if (ia_role_ != ROLE_SYSTEM_LINK && ia_role_ != ROLE_SYSTEM_TEXT) { | 2075 if (ia_role_ != ROLE_SYSTEM_LINK && ia_role_ != ROLE_SYSTEM_TEXT) { |
| 1891 *object = NULL; | 2076 *object = NULL; |
| 1892 return E_NOINTERFACE; | 2077 return E_NOINTERFACE; |
| 1893 } | 2078 } |
| 1894 } else if (iid == IID_IAccessibleImage) { | 2079 } else if (iid == IID_IAccessibleImage) { |
| 1895 if (ia_role_ != ROLE_SYSTEM_GRAPHIC) { | 2080 if (ia_role_ != ROLE_SYSTEM_GRAPHIC) { |
| 1896 *object = NULL; | 2081 *object = NULL; |
| 1897 return E_NOINTERFACE; | 2082 return E_NOINTERFACE; |
| 1898 } | 2083 } |
| 1899 } else if (iid == IID_IAccessibleTable) { | 2084 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { |
| 1900 if (ia_role_ != ROLE_SYSTEM_TABLE) { | 2085 if (ia_role_ != ROLE_SYSTEM_TABLE) { |
| 1901 *object = NULL; | 2086 *object = NULL; |
| 1902 return E_NOINTERFACE; | 2087 return E_NOINTERFACE; |
| 1903 } | 2088 } |
| 1904 } else if (iid == IID_IAccessibleTableCell) { | 2089 } else if (iid == IID_IAccessibleTableCell) { |
| 1905 if (ia_role_ != ROLE_SYSTEM_CELL) { | 2090 if (ia_role_ != ROLE_SYSTEM_CELL) { |
| 1906 *object = NULL; | 2091 *object = NULL; |
| 1907 return E_NOINTERFACE; | 2092 return E_NOINTERFACE; |
| 1908 } | 2093 } |
| 2094 } else if (iid == IID_IAccessibleValue) { | |
| 2095 if (ia_role_ != ROLE_SYSTEM_PROGRESSBAR && | |
| 2096 ia_role_ != ROLE_SYSTEM_SCROLLBAR && | |
| 2097 ia_role_ != ROLE_SYSTEM_SLIDER) { | |
| 2098 *object = NULL; | |
| 2099 return E_NOINTERFACE; | |
| 2100 } | |
| 1909 } else if (iid == IID_ISimpleDOMDocument) { | 2101 } else if (iid == IID_ISimpleDOMDocument) { |
| 1910 if (ia_role_ != ROLE_SYSTEM_DOCUMENT) { | 2102 if (ia_role_ != ROLE_SYSTEM_DOCUMENT) { |
| 1911 *object = NULL; | 2103 *object = NULL; |
| 1912 return E_NOINTERFACE; | 2104 return E_NOINTERFACE; |
| 1913 } | 2105 } |
| 1914 } | 2106 } |
| 1915 | 2107 |
| 1916 return CComObjectRootBase::InternalQueryInterface( | 2108 return CComObjectRootBase::InternalQueryInterface( |
| 1917 this_ptr, entries, iid, object); | 2109 this_ptr, entries, iid, object); |
| 1918 } | 2110 } |
| 1919 | 2111 |
| 1920 // | 2112 // |
| 1921 // Private methods. | 2113 // Private methods. |
| 1922 // | 2114 // |
| 1923 | 2115 |
| 1924 // Initialize this object and mark it as active. | 2116 // Initialize this object and mark it as active. |
| 1925 void BrowserAccessibilityWin::Initialize() { | 2117 void BrowserAccessibilityWin::Initialize() { |
| 1926 BrowserAccessibility::Initialize(); | 2118 BrowserAccessibility::Initialize(); |
| 1927 | 2119 |
| 1928 InitRoleAndState(); | 2120 InitRoleAndState(); |
| 1929 | 2121 |
| 1930 // Expose headings levels to NVDA with the "level" object attribute. | 2122 // Expose headings levels with the "level" attribute. |
| 1931 if (role_ == WebAccessibility::ROLE_HEADING && role_name_.size() == 2 && | 2123 if (role_ == WebAccessibility::ROLE_HEADING && role_name_.size() == 2 && |
| 1932 IsAsciiDigit(role_name_[1])) { | 2124 IsAsciiDigit(role_name_[1])) { |
| 1933 html_attributes_.push_back(std::make_pair(L"level", role_name_.substr(1))); | 2125 ia2_attributes_.push_back(string16(L"level:") + role_name_.substr(1)); |
| 1934 } | 2126 } |
| 1935 | 2127 |
| 1936 // Expose the "display" object attribute. | 2128 // Expose the "display" and "tag" attributes. |
| 1937 string16 display; | 2129 StringAttributeToIA2(WebAccessibility::ATTR_DISPLAY, "display"); |
| 1938 if (GetStringAttribute(WebAccessibility::ATTR_DISPLAY, &display)) | 2130 StringAttributeToIA2(WebAccessibility::ATTR_HTML_TAG, "tag"); |
| 1939 html_attributes_.push_back(std::make_pair(L"display", display)); | 2131 StringAttributeToIA2(WebAccessibility::ATTR_ROLE, "xml-roles"); |
| 2132 | |
| 2133 // Expose "level" attribute for tree nodes. | |
| 2134 IntAttributeToIA2(WebAccessibility::ATTR_HIERARCHICAL_LEVEL, "level"); | |
| 2135 | |
| 2136 // Expose live region attributes. | |
| 2137 StringAttributeToIA2(WebAccessibility::ATTR_LIVE_STATUS, "live"); | |
| 2138 StringAttributeToIA2(WebAccessibility::ATTR_LIVE_RELEVANT, "relevant"); | |
| 2139 BoolAttributeToIA2(WebAccessibility::ATTR_LIVE_ATOMIC, "atomic"); | |
| 2140 BoolAttributeToIA2(WebAccessibility::ATTR_LIVE_BUSY, "busy"); | |
| 2141 | |
| 2142 // Expose container live region attributes. | |
| 2143 StringAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_STATUS, | |
| 2144 "container-live"); | |
| 2145 StringAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_RELEVANT, | |
| 2146 "container-relevant"); | |
| 2147 BoolAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_ATOMIC, | |
| 2148 "container-atomic"); | |
| 2149 BoolAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_BUSY, | |
| 2150 "container-busy"); | |
| 2151 | |
| 2152 // Expose slider value. | |
| 2153 if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR || | |
| 2154 ia_role_ == ROLE_SYSTEM_SCROLLBAR || | |
| 2155 ia_role_ == ROLE_SYSTEM_SLIDER) { | |
| 2156 float fval; | |
| 2157 if (value_.empty() && | |
| 2158 GetFloatAttribute(WebAccessibility::ATTR_VALUE_FOR_RANGE, &fval)) { | |
| 2159 // TODO(dmazzoni): Use ICU to localize this? | |
| 2160 value_ = UTF8ToUTF16(base::DoubleToString(fval)); | |
| 2161 } | |
| 2162 ia2_attributes_.push_back(L"valuetext:" + value_); | |
| 2163 } | |
| 2164 | |
| 2165 // Expose table cell index. | |
| 2166 if (ia_role_ == ROLE_SYSTEM_CELL) { | |
| 2167 BrowserAccessibility* table = parent(); | |
| 2168 while (table && table->role() != WebAccessibility::ROLE_TABLE) | |
| 2169 table = table->parent(); | |
| 2170 if (table) { | |
| 2171 const std::vector<int32>& unique_cell_ids = table->unique_cell_ids(); | |
| 2172 int index = -1; | |
| 2173 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | |
| 2174 if (unique_cell_ids[i] == renderer_id_) { | |
| 2175 index = static_cast<int>(i); | |
| 2176 break; | |
| 2177 } | |
| 2178 } | |
| 2179 if (index >= 0) { | |
| 2180 ia2_attributes_.push_back(string16(L"table-cell-index:") + | |
| 2181 base::IntToString16(index)); | |
| 2182 } | |
| 2183 } else { | |
| 2184 DCHECK(false); | |
|
Chris Guillory
2011/08/31 02:14:53
NOTREACHED()
| |
| 2185 } | |
| 2186 } | |
| 1940 | 2187 |
| 1941 // If this is static text, put the text in the name rather than the value. | 2188 // If this is static text, put the text in the name rather than the value. |
| 1942 if (role_ == WebAccessibility::ROLE_STATIC_TEXT && name_.empty()) | 2189 if (role_ == WebAccessibility::ROLE_STATIC_TEXT && name_.empty()) |
| 1943 name_.swap(value_); | 2190 name_.swap(value_); |
| 1944 | 2191 |
| 1945 // If this object doesn't have a name but it does have a description, | 2192 // 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 | 2193 // use the description as its name - because some screen readers only |
| 1947 // announce the name. | 2194 // announce the name. |
| 1948 if (name_.empty()) | 2195 if (name_.empty()) |
| 1949 GetStringAttribute(WebAccessibility::ATTR_DESCRIPTION, &name_); | 2196 GetStringAttribute(WebAccessibility::ATTR_DESCRIPTION, &name_); |
| 1950 | 2197 |
| 1951 // If this doesn't have a value and is linked then set its value to the url | 2198 // 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. | 2199 // attribute. This allows screen readers to read an empty link's destination. |
| 1953 string16 url; | 2200 string16 url; |
| 1954 if (value_.empty() && (ia_state_ & STATE_SYSTEM_LINKED)) | 2201 if (value_.empty() && (ia_state_ & STATE_SYSTEM_LINKED)) |
| 1955 GetStringAttribute(WebAccessibility::ATTR_URL, &value_); | 2202 GetStringAttribute(WebAccessibility::ATTR_URL, &value_); |
| 1956 } | 2203 } |
| 1957 | 2204 |
| 2205 void BrowserAccessibilityWin::SendNodeUpdateEvents() { | |
| 2206 // Fire an event when an alert first appears. | |
| 2207 if (role_ == WebAccessibility::ROLE_ALERT && first_time_) | |
| 2208 manager_->NotifyAccessibilityEvent(ViewHostMsg_AccEvent::ALERT, this); | |
| 2209 | |
| 2210 // Fire events if text has changed. | |
| 2211 string16 text = TextForIAccessibleText(); | |
| 2212 if (previous_text_ != text) { | |
| 2213 if (!previous_text_.empty() && !text.empty()) { | |
| 2214 manager_->NotifyAccessibilityEvent( | |
| 2215 ViewHostMsg_AccEvent::OBJECT_SHOW, this); | |
| 2216 } | |
| 2217 | |
| 2218 // TODO(dmazzoni): look into HIDE events, too. | |
|
Chris Guillory
2011/08/31 02:14:53
Nit: look -> Look
dmazzoni
2011/08/31 22:02:54
Done.
| |
| 2219 | |
| 2220 old_text_ = previous_text_; | |
| 2221 previous_text_ = text; | |
| 2222 } | |
| 2223 | |
| 2224 first_time_ = false; | |
| 2225 } | |
| 2226 | |
| 1958 void BrowserAccessibilityWin::NativeAddReference() { | 2227 void BrowserAccessibilityWin::NativeAddReference() { |
| 1959 AddRef(); | 2228 AddRef(); |
| 1960 } | 2229 } |
| 1961 | 2230 |
| 1962 void BrowserAccessibilityWin::NativeReleaseReference() { | 2231 void BrowserAccessibilityWin::NativeReleaseReference() { |
| 1963 Release(); | 2232 Release(); |
| 1964 } | 2233 } |
| 1965 | 2234 |
| 1966 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { | 2235 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { |
| 1967 AddRef(); | 2236 AddRef(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1992 | 2261 |
| 1993 if (str.empty()) | 2262 if (str.empty()) |
| 1994 return S_FALSE; | 2263 return S_FALSE; |
| 1995 | 2264 |
| 1996 *value_bstr = SysAllocString(str.c_str()); | 2265 *value_bstr = SysAllocString(str.c_str()); |
| 1997 DCHECK(*value_bstr); | 2266 DCHECK(*value_bstr); |
| 1998 | 2267 |
| 1999 return S_OK; | 2268 return S_OK; |
| 2000 } | 2269 } |
| 2001 | 2270 |
| 2271 void BrowserAccessibilityWin::StringAttributeToIA2( | |
| 2272 WebAccessibility::StringAttribute attribute, const char* ia2_attr) { | |
| 2273 string16 value; | |
| 2274 if (GetStringAttribute(attribute, &value)) | |
| 2275 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + value); | |
| 2276 } | |
| 2277 | |
| 2278 void BrowserAccessibilityWin::BoolAttributeToIA2( | |
| 2279 WebAccessibility::BoolAttribute attribute, const char* ia2_attr) { | |
| 2280 bool value; | |
| 2281 if (GetBoolAttribute(attribute, &value)) { | |
| 2282 ia2_attributes_.push_back((ASCIIToUTF16(ia2_attr) + L":") + | |
| 2283 (value ? L"true" : L"false")); | |
| 2284 } | |
| 2285 } | |
| 2286 | |
| 2287 void BrowserAccessibilityWin::IntAttributeToIA2( | |
| 2288 WebAccessibility::IntAttribute attribute, const char* ia2_attr) { | |
| 2289 int value; | |
| 2290 if (GetIntAttribute(attribute, &value)) | |
| 2291 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + | |
| 2292 base::IntToString16(value)); | |
| 2293 } | |
| 2294 | |
| 2002 string16 BrowserAccessibilityWin::Escape(const string16& str) { | 2295 string16 BrowserAccessibilityWin::Escape(const string16& str) { |
| 2003 return EscapeQueryParamValueUTF8(str, false); | 2296 return EscapeQueryParamValueUTF8(str, false); |
| 2004 } | 2297 } |
| 2005 | 2298 |
| 2006 const string16& BrowserAccessibilityWin::TextForIAccessibleText() { | 2299 const string16& BrowserAccessibilityWin::TextForIAccessibleText() { |
| 2007 if (role_ == WebAccessibility::ROLE_TEXT_FIELD || | 2300 if (IsEditableText()) { |
| 2008 role_ == WebAccessibility::ROLE_TEXTAREA) { | |
| 2009 return value_; | 2301 return value_; |
| 2010 } else { | 2302 } else { |
| 2011 return name_; | 2303 return name_; |
| 2012 } | 2304 } |
| 2013 } | 2305 } |
| 2014 | 2306 |
| 2015 void BrowserAccessibilityWin::HandleSpecialTextOffset( | 2307 void BrowserAccessibilityWin::HandleSpecialTextOffset( |
| 2016 const string16& text, LONG* offset) { | 2308 const string16& text, LONG* offset) { |
| 2017 if (*offset == IA2_TEXT_OFFSET_LENGTH) { | 2309 if (*offset == IA2_TEXT_OFFSET_LENGTH) { |
| 2018 *offset = static_cast<LONG>(text.size()); | 2310 *offset = static_cast<LONG>(text.size()); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2034 | 2326 |
| 2035 HandleSpecialTextOffset(text, &start_offset); | 2327 HandleSpecialTextOffset(text, &start_offset); |
| 2036 | 2328 |
| 2037 if (boundary == IA2_TEXT_BOUNDARY_CHAR) { | 2329 if (boundary == IA2_TEXT_BOUNDARY_CHAR) { |
| 2038 if (direction == 1 && start_offset < text_size) | 2330 if (direction == 1 && start_offset < text_size) |
| 2039 return start_offset + 1; | 2331 return start_offset + 1; |
| 2040 else | 2332 else |
| 2041 return start_offset; | 2333 return start_offset; |
| 2042 } else if (boundary == IA2_TEXT_BOUNDARY_LINE) { | 2334 } else if (boundary == IA2_TEXT_BOUNDARY_LINE) { |
| 2043 if (direction == 1) { | 2335 if (direction == 1) { |
| 2044 for (int j = 0; j < static_cast<int>(line_breaks_.size()); j++) { | 2336 for (int j = 0; j < static_cast<int>(line_breaks_.size()); ++j) { |
|
Chris Guillory
2011/08/31 02:14:53
Verification: This is a no effect change on releas
dmazzoni
2011/08/31 22:02:54
Our style guide slightly prefers ++j, but yes, it
| |
| 2045 if (line_breaks_[j] > start_offset) | 2337 if (line_breaks_[j] > start_offset) |
| 2046 return line_breaks_[j]; | 2338 return line_breaks_[j]; |
| 2047 } | 2339 } |
| 2048 return text_size; | 2340 return text_size; |
| 2049 } else { | 2341 } else { |
| 2050 for (int j = static_cast<int>(line_breaks_.size()) - 1; j >= 0; j--) { | 2342 for (int j = static_cast<int>(line_breaks_.size()) - 1; j >= 0; j--) { |
| 2051 if (line_breaks_[j] <= start_offset) | 2343 if (line_breaks_[j] <= start_offset) |
| 2052 return line_breaks_[j]; | 2344 return line_breaks_[j]; |
| 2053 } | 2345 } |
| 2054 return 0; | 2346 return 0; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2105 } | 2397 } |
| 2106 | 2398 |
| 2107 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( | 2399 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( |
| 2108 int32 renderer_id) { | 2400 int32 renderer_id) { |
| 2109 return manager_->GetFromRendererID(renderer_id)->toBrowserAccessibilityWin(); | 2401 return manager_->GetFromRendererID(renderer_id)->toBrowserAccessibilityWin(); |
| 2110 } | 2402 } |
| 2111 | 2403 |
| 2112 void BrowserAccessibilityWin::InitRoleAndState() { | 2404 void BrowserAccessibilityWin::InitRoleAndState() { |
| 2113 ia_state_ = 0; | 2405 ia_state_ = 0; |
| 2114 ia2_state_ = IA2_STATE_OPAQUE; | 2406 ia2_state_ = IA2_STATE_OPAQUE; |
| 2407 ia2_attributes_.clear(); | |
| 2115 | 2408 |
| 2409 if ((state_ >> WebAccessibility::STATE_BUSY) & 1) | |
| 2410 ia_state_|= STATE_SYSTEM_BUSY; | |
| 2116 if ((state_ >> WebAccessibility::STATE_CHECKED) & 1) | 2411 if ((state_ >> WebAccessibility::STATE_CHECKED) & 1) |
| 2117 ia_state_ |= STATE_SYSTEM_CHECKED; | 2412 ia_state_ |= STATE_SYSTEM_CHECKED; |
| 2118 if ((state_ >> WebAccessibility::STATE_COLLAPSED) & 1) | 2413 if ((state_ >> WebAccessibility::STATE_COLLAPSED) & 1) |
| 2119 ia_state_|= STATE_SYSTEM_COLLAPSED; | 2414 ia_state_|= STATE_SYSTEM_COLLAPSED; |
| 2120 if ((state_ >> WebAccessibility::STATE_EXPANDED) & 1) | 2415 if ((state_ >> WebAccessibility::STATE_EXPANDED) & 1) |
| 2121 ia_state_|= STATE_SYSTEM_EXPANDED; | 2416 ia_state_|= STATE_SYSTEM_EXPANDED; |
| 2122 if ((state_ >> WebAccessibility::STATE_FOCUSABLE) & 1) | 2417 if ((state_ >> WebAccessibility::STATE_FOCUSABLE) & 1) |
| 2123 ia_state_|= STATE_SYSTEM_FOCUSABLE; | 2418 ia_state_|= STATE_SYSTEM_FOCUSABLE; |
| 2124 if ((state_ >> WebAccessibility::STATE_HASPOPUP) & 1) | 2419 if ((state_ >> WebAccessibility::STATE_HASPOPUP) & 1) |
| 2125 ia_state_|= STATE_SYSTEM_HASPOPUP; | 2420 ia_state_|= STATE_SYSTEM_HASPOPUP; |
| 2126 if ((state_ >> WebAccessibility::STATE_HOTTRACKED) & 1) | 2421 if ((state_ >> WebAccessibility::STATE_HOTTRACKED) & 1) |
| 2127 ia_state_|= STATE_SYSTEM_HOTTRACKED; | 2422 ia_state_|= STATE_SYSTEM_HOTTRACKED; |
| 2128 if ((state_ >> WebAccessibility::STATE_INDETERMINATE) & 1) | 2423 if ((state_ >> WebAccessibility::STATE_INDETERMINATE) & 1) |
| 2129 ia_state_|= STATE_SYSTEM_INDETERMINATE; | 2424 ia_state_|= STATE_SYSTEM_INDETERMINATE; |
| 2130 if ((state_ >> WebAccessibility::STATE_INVISIBLE) & 1) | 2425 if ((state_ >> WebAccessibility::STATE_INVISIBLE) & 1) |
| 2131 ia_state_|= STATE_SYSTEM_INVISIBLE; | 2426 ia_state_|= STATE_SYSTEM_INVISIBLE; |
| 2132 if ((state_ >> WebAccessibility::STATE_LINKED) & 1) | 2427 if ((state_ >> WebAccessibility::STATE_LINKED) & 1) |
| 2133 ia_state_|= STATE_SYSTEM_LINKED; | 2428 ia_state_|= STATE_SYSTEM_LINKED; |
| 2134 if ((state_ >> WebAccessibility::STATE_MULTISELECTABLE) & 1) | 2429 if ((state_ >> WebAccessibility::STATE_MULTISELECTABLE) & 1) |
| 2135 ia_state_|= STATE_SYSTEM_MULTISELECTABLE; | 2430 ia_state_|= STATE_SYSTEM_MULTISELECTABLE; |
| 2136 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. | 2431 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. |
| 2137 if ((state_ >> WebAccessibility::STATE_OFFSCREEN) & 1) | 2432 if ((state_ >> WebAccessibility::STATE_OFFSCREEN) & 1) |
| 2138 ia_state_|= STATE_SYSTEM_OFFSCREEN; | 2433 ia_state_|= STATE_SYSTEM_OFFSCREEN; |
| 2139 if ((state_ >> WebAccessibility::STATE_PRESSED) & 1) | 2434 if ((state_ >> WebAccessibility::STATE_PRESSED) & 1) |
| 2140 ia_state_|= STATE_SYSTEM_PRESSED; | 2435 ia_state_|= STATE_SYSTEM_PRESSED; |
| 2141 if ((state_ >> WebAccessibility::STATE_PROTECTED) & 1) | 2436 if ((state_ >> WebAccessibility::STATE_PROTECTED) & 1) |
| 2142 ia_state_|= STATE_SYSTEM_PROTECTED; | 2437 ia_state_|= STATE_SYSTEM_PROTECTED; |
| 2438 if ((state_ >> WebAccessibility::STATE_READONLY) & 1) | |
| 2439 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2440 if ((state_ >> WebAccessibility::STATE_REQUIRED) & 1) | |
| 2441 ia2_state_|= IA2_STATE_REQUIRED; | |
| 2143 if ((state_ >> WebAccessibility::STATE_SELECTABLE) & 1) | 2442 if ((state_ >> WebAccessibility::STATE_SELECTABLE) & 1) |
| 2144 ia_state_|= STATE_SYSTEM_SELECTABLE; | 2443 ia_state_|= STATE_SYSTEM_SELECTABLE; |
| 2145 if ((state_ >> WebAccessibility::STATE_SELECTED) & 1) | 2444 if ((state_ >> WebAccessibility::STATE_SELECTED) & 1) |
| 2146 ia_state_|= STATE_SYSTEM_SELECTED; | 2445 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) | 2446 if ((state_ >> WebAccessibility::STATE_TRAVERSED) & 1) |
| 2150 ia_state_|= STATE_SYSTEM_TRAVERSED; | 2447 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) | 2448 if ((state_ >> WebAccessibility::STATE_UNAVAILABLE) & 1) |
| 2154 ia_state_|= STATE_SYSTEM_UNAVAILABLE; | 2449 ia_state_|= STATE_SYSTEM_UNAVAILABLE; |
| 2450 if ((state_ >> WebAccessibility::STATE_VERTICAL) & 1) { | |
| 2451 ia2_state_|= IA2_STATE_VERTICAL; | |
| 2452 } else { | |
| 2453 ia2_state_|= IA2_STATE_HORIZONTAL; | |
| 2454 } | |
| 2455 if ((state_ >> WebAccessibility::STATE_VISITED) & 1) | |
| 2456 ia_state_|= STATE_SYSTEM_TRAVERSED; | |
| 2457 | |
| 2458 string16 invalid; | |
| 2459 if (GetHtmlAttribute("aria-invalid", &invalid)) | |
| 2460 ia2_state_|= IA2_STATE_INVALID_ENTRY; | |
| 2461 | |
| 2462 bool mixed = false; | |
| 2463 GetBoolAttribute(WebAccessibility::ATTR_BUTTON_MIXED, &mixed); | |
| 2464 if (mixed) | |
| 2465 ia_state_|= STATE_SYSTEM_MIXED; | |
| 2155 | 2466 |
| 2156 string16 html_tag; | 2467 string16 html_tag; |
| 2157 GetStringAttribute(WebAccessibility::ATTR_HTML_TAG, &html_tag); | 2468 GetStringAttribute(WebAccessibility::ATTR_HTML_TAG, &html_tag); |
| 2158 ia_role_ = 0; | 2469 ia_role_ = 0; |
| 2159 ia2_role_ = 0; | 2470 ia2_role_ = 0; |
| 2160 switch (role_) { | 2471 switch (role_) { |
| 2161 case WebAccessibility::ROLE_ALERT: | 2472 case WebAccessibility::ROLE_ALERT: |
| 2473 ia_role_ = ROLE_SYSTEM_ALERT; | |
| 2474 break; | |
| 2162 case WebAccessibility::ROLE_ALERT_DIALOG: | 2475 case WebAccessibility::ROLE_ALERT_DIALOG: |
| 2163 ia_role_ = ROLE_SYSTEM_ALERT; | 2476 ia_role_ = ROLE_SYSTEM_DIALOG; |
| 2164 break; | 2477 break; |
| 2165 case WebAccessibility::ROLE_APPLICATION: | 2478 case WebAccessibility::ROLE_APPLICATION: |
| 2166 ia_role_ = ROLE_SYSTEM_APPLICATION; | 2479 ia_role_ = ROLE_SYSTEM_APPLICATION; |
| 2167 break; | 2480 break; |
| 2168 case WebAccessibility::ROLE_ARTICLE: | 2481 case WebAccessibility::ROLE_ARTICLE: |
| 2169 ia_role_ = ROLE_SYSTEM_GROUPING; | 2482 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2170 ia2_role_ = IA2_ROLE_SECTION; | 2483 ia2_role_ = IA2_ROLE_SECTION; |
| 2484 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2171 break; | 2485 break; |
| 2172 case WebAccessibility::ROLE_BUSY_INDICATOR: | 2486 case WebAccessibility::ROLE_BUSY_INDICATOR: |
| 2173 ia_role_ = ROLE_SYSTEM_ANIMATION; | 2487 ia_role_ = ROLE_SYSTEM_ANIMATION; |
| 2488 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2174 break; | 2489 break; |
| 2175 case WebAccessibility::ROLE_BUTTON: | 2490 case WebAccessibility::ROLE_BUTTON: |
| 2176 ia_role_ = ROLE_SYSTEM_PUSHBUTTON; | 2491 ia_role_ = ROLE_SYSTEM_PUSHBUTTON; |
| 2492 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2177 break; | 2493 break; |
| 2178 case WebAccessibility::ROLE_CELL: | 2494 case WebAccessibility::ROLE_CELL: |
| 2179 ia_role_ = ROLE_SYSTEM_CELL; | 2495 ia_role_ = ROLE_SYSTEM_CELL; |
| 2496 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2180 break; | 2497 break; |
| 2181 case WebAccessibility::ROLE_CHECKBOX: | 2498 case WebAccessibility::ROLE_CHECKBOX: |
| 2182 ia_role_ = ROLE_SYSTEM_CHECKBUTTON; | 2499 ia_role_ = ROLE_SYSTEM_CHECKBUTTON; |
| 2183 break; | 2500 break; |
| 2184 case WebAccessibility::ROLE_COLOR_WELL: | 2501 case WebAccessibility::ROLE_COLOR_WELL: |
| 2185 ia_role_ = ROLE_SYSTEM_CLIENT; | 2502 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2186 ia2_role_ = IA2_ROLE_COLOR_CHOOSER; | 2503 ia2_role_ = IA2_ROLE_COLOR_CHOOSER; |
| 2187 break; | 2504 break; |
| 2188 case WebAccessibility::ROLE_COLUMN: | 2505 case WebAccessibility::ROLE_COLUMN: |
| 2189 ia_role_ = ROLE_SYSTEM_COLUMN; | 2506 ia_role_ = ROLE_SYSTEM_COLUMN; |
| 2507 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2190 break; | 2508 break; |
| 2191 case WebAccessibility::ROLE_COLUMN_HEADER: | 2509 case WebAccessibility::ROLE_COLUMN_HEADER: |
| 2192 ia_role_ = ROLE_SYSTEM_COLUMNHEADER; | 2510 ia_role_ = ROLE_SYSTEM_COLUMNHEADER; |
| 2511 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2193 break; | 2512 break; |
| 2194 case WebAccessibility::ROLE_COMBO_BOX: | 2513 case WebAccessibility::ROLE_COMBO_BOX: |
| 2195 ia_role_ = ROLE_SYSTEM_COMBOBOX; | 2514 ia_role_ = ROLE_SYSTEM_COMBOBOX; |
| 2196 break; | 2515 break; |
| 2197 case WebAccessibility::ROLE_DEFINITION_LIST_DEFINITION: | 2516 case WebAccessibility::ROLE_DEFINITION_LIST_DEFINITION: |
| 2198 role_name_ = html_tag; | 2517 role_name_ = html_tag; |
| 2199 ia2_role_ = IA2_ROLE_PARAGRAPH; | 2518 ia2_role_ = IA2_ROLE_PARAGRAPH; |
| 2519 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2200 break; | 2520 break; |
| 2201 case WebAccessibility::ROLE_DEFINITION_LIST_TERM: | 2521 case WebAccessibility::ROLE_DEFINITION_LIST_TERM: |
| 2202 ia_role_ = ROLE_SYSTEM_LISTITEM; | 2522 ia_role_ = ROLE_SYSTEM_LISTITEM; |
| 2523 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2203 break; | 2524 break; |
| 2204 case WebAccessibility::ROLE_DIALOG: | 2525 case WebAccessibility::ROLE_DIALOG: |
| 2205 ia_role_ = ROLE_SYSTEM_DIALOG; | 2526 ia_role_ = ROLE_SYSTEM_DIALOG; |
| 2527 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2206 break; | 2528 break; |
| 2207 case WebAccessibility::ROLE_DISCLOSURE_TRIANGLE: | 2529 case WebAccessibility::ROLE_DISCLOSURE_TRIANGLE: |
| 2208 ia_role_ = ROLE_SYSTEM_OUTLINEBUTTON; | 2530 ia_role_ = ROLE_SYSTEM_OUTLINEBUTTON; |
| 2531 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2209 break; | 2532 break; |
| 2210 case WebAccessibility::ROLE_DOCUMENT: | 2533 case WebAccessibility::ROLE_DOCUMENT: |
| 2211 case WebAccessibility::ROLE_WEB_AREA: | 2534 case WebAccessibility::ROLE_WEB_AREA: |
| 2212 ia_role_ = ROLE_SYSTEM_DOCUMENT; | 2535 ia_role_ = ROLE_SYSTEM_DOCUMENT; |
| 2213 ia_state_|= STATE_SYSTEM_READONLY; | 2536 ia_state_|= STATE_SYSTEM_READONLY; |
| 2214 ia_state_|= STATE_SYSTEM_FOCUSABLE; | 2537 ia_state_|= STATE_SYSTEM_FOCUSABLE; |
| 2215 break; | 2538 break; |
| 2216 case WebAccessibility::ROLE_EDITABLE_TEXT: | 2539 case WebAccessibility::ROLE_EDITABLE_TEXT: |
| 2217 ia_role_ = ROLE_SYSTEM_TEXT; | 2540 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2218 ia2_state_ |= IA2_STATE_SINGLE_LINE; | 2541 ia2_state_ |= IA2_STATE_SINGLE_LINE; |
| 2219 ia2_state_ |= IA2_STATE_EDITABLE; | 2542 ia2_state_ |= IA2_STATE_EDITABLE; |
| 2220 break; | 2543 break; |
| 2221 case WebAccessibility::ROLE_GRID: | 2544 case WebAccessibility::ROLE_GRID: |
| 2222 ia_role_ = ROLE_SYSTEM_TABLE; | 2545 ia_role_ = ROLE_SYSTEM_TABLE; |
| 2546 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2223 break; | 2547 break; |
| 2224 case WebAccessibility::ROLE_GROUP: | 2548 case WebAccessibility::ROLE_GROUP: |
| 2225 if (html_tag == L"li") { | 2549 if (html_tag == L"li") { |
| 2226 ia_role_ = ROLE_SYSTEM_LISTITEM; | 2550 ia_role_ = ROLE_SYSTEM_LISTITEM; |
| 2551 } else if (html_tag == L"form") { | |
| 2552 role_name_ = html_tag; | |
| 2553 ia2_role_ = IA2_ROLE_FORM; | |
| 2554 } else if (html_tag == L"p") { | |
| 2555 role_name_ = html_tag; | |
| 2556 ia2_role_ = IA2_ROLE_PARAGRAPH; | |
| 2227 } else { | 2557 } else { |
| 2228 if (html_tag.empty()) | 2558 if (html_tag.empty()) |
| 2229 role_name_ = L"div"; | 2559 role_name_ = L"div"; |
| 2230 else | 2560 else |
| 2231 role_name_ = html_tag; | 2561 role_name_ = html_tag; |
| 2232 ia2_role_ = IA2_ROLE_SECTION; | 2562 ia2_role_ = IA2_ROLE_SECTION; |
| 2233 } | 2563 } |
| 2564 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2234 break; | 2565 break; |
| 2235 case WebAccessibility::ROLE_GROW_AREA: | 2566 case WebAccessibility::ROLE_GROW_AREA: |
| 2236 ia_role_ = ROLE_SYSTEM_GRIP; | 2567 ia_role_ = ROLE_SYSTEM_GRIP; |
| 2568 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2237 break; | 2569 break; |
| 2238 case WebAccessibility::ROLE_HEADING: | 2570 case WebAccessibility::ROLE_HEADING: |
| 2239 role_name_ = html_tag; | 2571 role_name_ = html_tag; |
| 2240 ia2_role_ = IA2_ROLE_HEADING; | 2572 ia2_role_ = IA2_ROLE_HEADING; |
| 2573 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2241 break; | 2574 break; |
| 2242 case WebAccessibility::ROLE_IMAGE: | 2575 case WebAccessibility::ROLE_IMAGE: |
| 2243 ia_role_ = ROLE_SYSTEM_GRAPHIC; | 2576 ia_role_ = ROLE_SYSTEM_GRAPHIC; |
| 2577 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2244 break; | 2578 break; |
| 2245 case WebAccessibility::ROLE_IMAGE_MAP: | 2579 case WebAccessibility::ROLE_IMAGE_MAP: |
| 2246 role_name_ = html_tag; | 2580 role_name_ = html_tag; |
| 2247 ia2_role_ = IA2_ROLE_IMAGE_MAP; | 2581 ia2_role_ = IA2_ROLE_IMAGE_MAP; |
| 2582 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2248 break; | 2583 break; |
| 2249 case WebAccessibility::ROLE_IMAGE_MAP_LINK: | 2584 case WebAccessibility::ROLE_IMAGE_MAP_LINK: |
| 2250 ia_role_ = ROLE_SYSTEM_LINK; | 2585 ia_role_ = ROLE_SYSTEM_LINK; |
| 2251 ia_state_|= STATE_SYSTEM_LINKED; | 2586 ia_state_|= STATE_SYSTEM_LINKED; |
| 2587 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2252 break; | 2588 break; |
| 2253 case WebAccessibility::ROLE_LANDMARK_APPLICATION: | 2589 case WebAccessibility::ROLE_LANDMARK_APPLICATION: |
| 2254 case WebAccessibility::ROLE_LANDMARK_BANNER: | 2590 case WebAccessibility::ROLE_LANDMARK_BANNER: |
| 2255 case WebAccessibility::ROLE_LANDMARK_COMPLEMENTARY: | 2591 case WebAccessibility::ROLE_LANDMARK_COMPLEMENTARY: |
| 2256 case WebAccessibility::ROLE_LANDMARK_CONTENTINFO: | 2592 case WebAccessibility::ROLE_LANDMARK_CONTENTINFO: |
| 2257 case WebAccessibility::ROLE_LANDMARK_MAIN: | 2593 case WebAccessibility::ROLE_LANDMARK_MAIN: |
| 2258 case WebAccessibility::ROLE_LANDMARK_NAVIGATION: | 2594 case WebAccessibility::ROLE_LANDMARK_NAVIGATION: |
| 2259 case WebAccessibility::ROLE_LANDMARK_SEARCH: | 2595 case WebAccessibility::ROLE_LANDMARK_SEARCH: |
| 2260 ia_role_ = ROLE_SYSTEM_GROUPING; | 2596 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2261 ia2_role_ = IA2_ROLE_SECTION; | 2597 ia2_role_ = IA2_ROLE_SECTION; |
| 2598 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2262 break; | 2599 break; |
| 2263 case WebAccessibility::ROLE_LINK: | 2600 case WebAccessibility::ROLE_LINK: |
| 2264 case WebAccessibility::ROLE_WEBCORE_LINK: | 2601 case WebAccessibility::ROLE_WEBCORE_LINK: |
| 2265 ia_role_ = ROLE_SYSTEM_LINK; | 2602 ia_role_ = ROLE_SYSTEM_LINK; |
| 2266 ia_state_|= STATE_SYSTEM_LINKED; | 2603 ia_state_|= STATE_SYSTEM_LINKED; |
| 2604 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2267 break; | 2605 break; |
| 2268 case WebAccessibility::ROLE_LIST: | 2606 case WebAccessibility::ROLE_LIST: |
| 2269 ia_role_ = ROLE_SYSTEM_LIST; | 2607 ia_role_ = ROLE_SYSTEM_LIST; |
| 2608 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2270 break; | 2609 break; |
| 2271 case WebAccessibility::ROLE_LISTBOX: | 2610 case WebAccessibility::ROLE_LISTBOX: |
| 2272 ia_role_ = ROLE_SYSTEM_LIST; | 2611 ia_role_ = ROLE_SYSTEM_LIST; |
| 2273 break; | 2612 break; |
| 2274 case WebAccessibility::ROLE_LISTBOX_OPTION: | 2613 case WebAccessibility::ROLE_LISTBOX_OPTION: |
| 2614 ia_role_ = ROLE_SYSTEM_LISTITEM; | |
| 2615 break; | |
| 2275 case WebAccessibility::ROLE_LIST_ITEM: | 2616 case WebAccessibility::ROLE_LIST_ITEM: |
| 2617 ia_role_ = ROLE_SYSTEM_LISTITEM; | |
| 2618 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2619 break; | |
| 2276 case WebAccessibility::ROLE_LIST_MARKER: | 2620 case WebAccessibility::ROLE_LIST_MARKER: |
| 2277 ia_role_ = ROLE_SYSTEM_LISTITEM; | 2621 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2622 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2278 break; | 2623 break; |
| 2279 case WebAccessibility::ROLE_MATH: | 2624 case WebAccessibility::ROLE_MATH: |
| 2280 ia_role_ = ROLE_SYSTEM_EQUATION; | 2625 ia_role_ = ROLE_SYSTEM_EQUATION; |
| 2626 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2281 break; | 2627 break; |
| 2282 case WebAccessibility::ROLE_MENU: | 2628 case WebAccessibility::ROLE_MENU: |
| 2283 case WebAccessibility::ROLE_MENU_BUTTON: | 2629 case WebAccessibility::ROLE_MENU_BUTTON: |
| 2284 ia_role_ = ROLE_SYSTEM_MENUPOPUP; | 2630 ia_role_ = ROLE_SYSTEM_MENUPOPUP; |
| 2285 break; | 2631 break; |
| 2286 case WebAccessibility::ROLE_MENU_BAR: | 2632 case WebAccessibility::ROLE_MENU_BAR: |
| 2287 ia_role_ = ROLE_SYSTEM_MENUBAR; | 2633 ia_role_ = ROLE_SYSTEM_MENUBAR; |
| 2288 break; | 2634 break; |
| 2289 case WebAccessibility::ROLE_MENU_ITEM: | 2635 case WebAccessibility::ROLE_MENU_ITEM: |
| 2290 case WebAccessibility::ROLE_MENU_LIST_OPTION: | 2636 case WebAccessibility::ROLE_MENU_LIST_OPTION: |
| 2291 ia_role_ = ROLE_SYSTEM_MENUITEM; | 2637 ia_role_ = ROLE_SYSTEM_MENUITEM; |
| 2292 break; | 2638 break; |
| 2293 case WebAccessibility::ROLE_MENU_LIST_POPUP: | 2639 case WebAccessibility::ROLE_MENU_LIST_POPUP: |
| 2294 ia_role_ = ROLE_SYSTEM_MENUPOPUP; | 2640 ia_role_ = ROLE_SYSTEM_MENUPOPUP; |
| 2295 break; | 2641 break; |
| 2296 case WebAccessibility::ROLE_NOTE: | 2642 case WebAccessibility::ROLE_NOTE: |
| 2297 ia_role_ = ROLE_SYSTEM_GROUPING; | 2643 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2298 ia2_role_ = IA2_ROLE_NOTE; | 2644 ia2_role_ = IA2_ROLE_NOTE; |
| 2645 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2299 break; | 2646 break; |
| 2300 case WebAccessibility::ROLE_OUTLINE: | 2647 case WebAccessibility::ROLE_OUTLINE: |
| 2301 ia_role_ = ROLE_SYSTEM_OUTLINE; | 2648 ia_role_ = ROLE_SYSTEM_OUTLINE; |
| 2649 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2302 break; | 2650 break; |
| 2303 case WebAccessibility::ROLE_POPUP_BUTTON: | 2651 case WebAccessibility::ROLE_POPUP_BUTTON: |
| 2304 ia_role_ = ROLE_SYSTEM_COMBOBOX; | 2652 if (html_tag == L"select") { |
| 2653 ia_role_ = ROLE_SYSTEM_COMBOBOX; | |
| 2654 } else { | |
| 2655 ia_role_ = ROLE_SYSTEM_BUTTONMENU; | |
| 2656 } | |
| 2657 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2305 break; | 2658 break; |
| 2306 case WebAccessibility::ROLE_PROGRESS_INDICATOR: | 2659 case WebAccessibility::ROLE_PROGRESS_INDICATOR: |
| 2307 ia_role_ = ROLE_SYSTEM_PROGRESSBAR; | 2660 ia_role_ = ROLE_SYSTEM_PROGRESSBAR; |
| 2661 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2308 break; | 2662 break; |
| 2309 case WebAccessibility::ROLE_RADIO_BUTTON: | 2663 case WebAccessibility::ROLE_RADIO_BUTTON: |
| 2310 ia_role_ = ROLE_SYSTEM_RADIOBUTTON; | 2664 ia_role_ = ROLE_SYSTEM_RADIOBUTTON; |
| 2311 break; | 2665 break; |
| 2312 case WebAccessibility::ROLE_RADIO_GROUP: | 2666 case WebAccessibility::ROLE_RADIO_GROUP: |
| 2313 ia_role_ = ROLE_SYSTEM_GROUPING; | 2667 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2314 ia2_role_ = IA2_ROLE_SECTION; | 2668 ia2_role_ = IA2_ROLE_SECTION; |
| 2315 break; | 2669 break; |
| 2316 case WebAccessibility::ROLE_REGION: | 2670 case WebAccessibility::ROLE_REGION: |
| 2317 ia_role_ = ROLE_SYSTEM_GROUPING; | 2671 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2318 ia2_role_ = IA2_ROLE_SECTION; | 2672 ia2_role_ = IA2_ROLE_SECTION; |
| 2673 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2319 break; | 2674 break; |
| 2320 case WebAccessibility::ROLE_ROW: | 2675 case WebAccessibility::ROLE_ROW: |
| 2321 ia_role_ = ROLE_SYSTEM_ROW; | 2676 ia_role_ = ROLE_SYSTEM_ROW; |
| 2677 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2322 break; | 2678 break; |
| 2323 case WebAccessibility::ROLE_ROW_HEADER: | 2679 case WebAccessibility::ROLE_ROW_HEADER: |
| 2324 ia_role_ = ROLE_SYSTEM_ROWHEADER; | 2680 ia_role_ = ROLE_SYSTEM_ROWHEADER; |
| 2681 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2325 break; | 2682 break; |
| 2326 case WebAccessibility::ROLE_RULER: | 2683 case WebAccessibility::ROLE_RULER: |
| 2327 ia_role_ = ROLE_SYSTEM_CLIENT; | 2684 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2328 ia2_role_ = IA2_ROLE_RULER; | 2685 ia2_role_ = IA2_ROLE_RULER; |
| 2686 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2329 break; | 2687 break; |
| 2330 case WebAccessibility::ROLE_SCROLLAREA: | 2688 case WebAccessibility::ROLE_SCROLLAREA: |
| 2331 ia_role_ = ROLE_SYSTEM_CLIENT; | 2689 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2332 ia2_role_ = IA2_ROLE_SCROLL_PANE; | 2690 ia2_role_ = IA2_ROLE_SCROLL_PANE; |
| 2691 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2333 break; | 2692 break; |
| 2334 case WebAccessibility::ROLE_SCROLLBAR: | 2693 case WebAccessibility::ROLE_SCROLLBAR: |
| 2335 ia_role_ = ROLE_SYSTEM_SCROLLBAR; | 2694 ia_role_ = ROLE_SYSTEM_SCROLLBAR; |
| 2336 break; | 2695 break; |
| 2337 case WebAccessibility::ROLE_SLIDER: | 2696 case WebAccessibility::ROLE_SLIDER: |
| 2338 ia_role_ = ROLE_SYSTEM_SLIDER; | 2697 ia_role_ = ROLE_SYSTEM_SLIDER; |
| 2339 break; | 2698 break; |
| 2340 case WebAccessibility::ROLE_SPLIT_GROUP: | 2699 case WebAccessibility::ROLE_SPLIT_GROUP: |
| 2341 ia_role_ = ROLE_SYSTEM_CLIENT; | 2700 ia_role_ = ROLE_SYSTEM_CLIENT; |
| 2342 ia2_role_ = IA2_ROLE_SPLIT_PANE; | 2701 ia2_role_ = IA2_ROLE_SPLIT_PANE; |
| 2702 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2343 break; | 2703 break; |
| 2344 case WebAccessibility::ROLE_ANNOTATION: | 2704 case WebAccessibility::ROLE_ANNOTATION: |
| 2345 case WebAccessibility::ROLE_STATIC_TEXT: | 2705 case WebAccessibility::ROLE_STATIC_TEXT: |
| 2346 ia_role_ = ROLE_SYSTEM_TEXT; | 2706 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2707 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2347 break; | 2708 break; |
| 2348 case WebAccessibility::ROLE_STATUS: | 2709 case WebAccessibility::ROLE_STATUS: |
| 2349 ia_role_ = ROLE_SYSTEM_STATUSBAR; | 2710 ia_role_ = ROLE_SYSTEM_STATUSBAR; |
| 2711 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2350 break; | 2712 break; |
| 2351 case WebAccessibility::ROLE_SPLITTER: | 2713 case WebAccessibility::ROLE_SPLITTER: |
| 2352 ia_role_ = ROLE_SYSTEM_SEPARATOR; | 2714 ia_role_ = ROLE_SYSTEM_SEPARATOR; |
| 2353 break; | 2715 break; |
| 2354 case WebAccessibility::ROLE_TAB: | 2716 case WebAccessibility::ROLE_TAB: |
| 2355 ia_role_ = ROLE_SYSTEM_PAGETAB; | 2717 ia_role_ = ROLE_SYSTEM_PAGETAB; |
| 2356 break; | 2718 break; |
| 2357 case WebAccessibility::ROLE_TABLE: | 2719 case WebAccessibility::ROLE_TABLE: |
| 2358 ia_role_ = ROLE_SYSTEM_TABLE; | 2720 ia_role_ = ROLE_SYSTEM_TABLE; |
| 2721 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2359 break; | 2722 break; |
| 2360 case WebAccessibility::ROLE_TABLE_HEADER_CONTAINER: | 2723 case WebAccessibility::ROLE_TABLE_HEADER_CONTAINER: |
| 2361 ia_role_ = ROLE_SYSTEM_GROUPING; | 2724 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 2362 ia2_role_ = IA2_ROLE_SECTION; | 2725 ia2_role_ = IA2_ROLE_SECTION; |
| 2726 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2363 break; | 2727 break; |
| 2364 case WebAccessibility::ROLE_TAB_GROUP: | 2728 case WebAccessibility::ROLE_TAB_GROUP: |
| 2365 case WebAccessibility::ROLE_TAB_LIST: | 2729 case WebAccessibility::ROLE_TAB_LIST: |
| 2366 case WebAccessibility::ROLE_TAB_PANEL: | 2730 case WebAccessibility::ROLE_TAB_PANEL: |
| 2367 ia_role_ = ROLE_SYSTEM_PAGETABLIST; | 2731 ia_role_ = ROLE_SYSTEM_PAGETABLIST; |
| 2368 break; | 2732 break; |
| 2369 case WebAccessibility::ROLE_TEXTAREA: | 2733 case WebAccessibility::ROLE_TEXTAREA: |
| 2370 ia_role_ = ROLE_SYSTEM_TEXT; | 2734 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2371 ia2_state_ |= IA2_STATE_MULTI_LINE; | 2735 ia2_state_ |= IA2_STATE_MULTI_LINE; |
| 2372 ia2_state_ |= IA2_STATE_EDITABLE; | 2736 ia2_state_ |= IA2_STATE_EDITABLE; |
| 2373 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; | 2737 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; |
| 2374 break; | 2738 break; |
| 2375 case WebAccessibility::ROLE_TEXT_FIELD: | 2739 case WebAccessibility::ROLE_TEXT_FIELD: |
| 2376 ia_role_ = ROLE_SYSTEM_TEXT; | 2740 ia_role_ = ROLE_SYSTEM_TEXT; |
| 2377 ia2_state_ |= IA2_STATE_SINGLE_LINE; | 2741 ia2_state_ |= IA2_STATE_SINGLE_LINE; |
| 2378 ia2_state_ |= IA2_STATE_EDITABLE; | 2742 ia2_state_ |= IA2_STATE_EDITABLE; |
| 2379 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; | 2743 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; |
| 2380 break; | 2744 break; |
| 2381 case WebAccessibility::ROLE_TIMER: | 2745 case WebAccessibility::ROLE_TIMER: |
| 2382 ia_role_ = ROLE_SYSTEM_CLOCK; | 2746 ia_role_ = ROLE_SYSTEM_CLOCK; |
| 2747 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2383 break; | 2748 break; |
| 2384 case WebAccessibility::ROLE_TOOLBAR: | 2749 case WebAccessibility::ROLE_TOOLBAR: |
| 2385 ia_role_ = ROLE_SYSTEM_TOOLBAR; | 2750 ia_role_ = ROLE_SYSTEM_TOOLBAR; |
| 2751 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2386 break; | 2752 break; |
| 2387 case WebAccessibility::ROLE_TOOLTIP: | 2753 case WebAccessibility::ROLE_TOOLTIP: |
| 2388 ia_role_ = ROLE_SYSTEM_TOOLTIP; | 2754 ia_role_ = ROLE_SYSTEM_TOOLTIP; |
| 2755 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2389 break; | 2756 break; |
| 2390 case WebAccessibility::ROLE_TREE: | 2757 case WebAccessibility::ROLE_TREE: |
| 2391 ia_role_ = ROLE_SYSTEM_OUTLINE; | 2758 ia_role_ = ROLE_SYSTEM_OUTLINE; |
| 2759 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2392 break; | 2760 break; |
| 2393 case WebAccessibility::ROLE_TREE_GRID: | 2761 case WebAccessibility::ROLE_TREE_GRID: |
| 2394 ia_role_ = ROLE_SYSTEM_OUTLINE; | 2762 ia_role_ = ROLE_SYSTEM_OUTLINE; |
| 2763 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2395 break; | 2764 break; |
| 2396 case WebAccessibility::ROLE_TREE_ITEM: | 2765 case WebAccessibility::ROLE_TREE_ITEM: |
| 2397 ia_role_ = ROLE_SYSTEM_OUTLINEITEM; | 2766 ia_role_ = ROLE_SYSTEM_OUTLINEITEM; |
| 2767 ia_state_|= STATE_SYSTEM_READONLY; | |
| 2398 break; | 2768 break; |
| 2399 case WebAccessibility::ROLE_WINDOW: | 2769 case WebAccessibility::ROLE_WINDOW: |
| 2400 ia_role_ = ROLE_SYSTEM_WINDOW; | 2770 ia_role_ = ROLE_SYSTEM_WINDOW; |
| 2401 break; | 2771 break; |
| 2402 | 2772 |
| 2403 // TODO(dmazzoni): figure out the proper MSAA role for all of these. | 2773 // TODO(dmazzoni): figure out the proper MSAA role for all of these. |
| 2404 case WebAccessibility::ROLE_BROWSER: | 2774 case WebAccessibility::ROLE_BROWSER: |
| 2405 case WebAccessibility::ROLE_DIRECTORY: | 2775 case WebAccessibility::ROLE_DIRECTORY: |
| 2406 case WebAccessibility::ROLE_DRAWER: | 2776 case WebAccessibility::ROLE_DRAWER: |
| 2407 case WebAccessibility::ROLE_HELP_TAG: | 2777 case WebAccessibility::ROLE_HELP_TAG: |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 2421 } | 2791 } |
| 2422 | 2792 |
| 2423 // The role should always be set. | 2793 // The role should always be set. |
| 2424 DCHECK(!role_name_.empty() || ia_role_); | 2794 DCHECK(!role_name_.empty() || ia_role_); |
| 2425 | 2795 |
| 2426 // If we didn't explicitly set the IAccessible2 role, make it the same | 2796 // If we didn't explicitly set the IAccessible2 role, make it the same |
| 2427 // as the MSAA role. | 2797 // as the MSAA role. |
| 2428 if (!ia2_role_) | 2798 if (!ia2_role_) |
| 2429 ia2_role_ = ia_role_; | 2799 ia2_role_ = ia_role_; |
| 2430 } | 2800 } |
| OLD | NEW |