Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/accessibility/browser_accessibility_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_win.h" |
| 6 | 6 |
| 7 #include <UIAutomationClient.h> | 7 #include <UIAutomationClient.h> |
| 8 #include <UIAutomationCoreApi.h> | 8 #include <UIAutomationCoreApi.h> |
| 9 | 9 |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2979 } | 2979 } |
| 2980 } | 2980 } |
| 2981 } | 2981 } |
| 2982 | 2982 |
| 2983 // Expose invalid state for form controls and elements with aria-invalid. | 2983 // Expose invalid state for form controls and elements with aria-invalid. |
| 2984 int invalid_state; | 2984 int invalid_state; |
| 2985 if (GetIntAttribute(ui::AX_ATTR_INVALID_STATE, &invalid_state)) { | 2985 if (GetIntAttribute(ui::AX_ATTR_INVALID_STATE, &invalid_state)) { |
| 2986 // TODO(nektar): Handle the possibility of having multiple aria-invalid | 2986 // TODO(nektar): Handle the possibility of having multiple aria-invalid |
| 2987 // attributes defined, e.g., "invalid:spelling,grammar". | 2987 // attributes defined, e.g., "invalid:spelling,grammar". |
| 2988 switch (invalid_state) { | 2988 switch (invalid_state) { |
| 2989 case ui::AX_INVALID_STATE_NONE: | |
|
dmazzoni
2015/01/27 18:59:17
This isn't related to the sort change
| |
| 2990 break; | |
| 2991 case ui::AX_INVALID_STATE_FALSE: | 2989 case ui::AX_INVALID_STATE_FALSE: |
| 2992 ia2_attributes_.push_back(L"invalid:false"); | 2990 ia2_attributes_.push_back(L"invalid:false"); |
| 2993 break; | 2991 break; |
| 2994 case ui::AX_INVALID_STATE_TRUE: | 2992 case ui::AX_INVALID_STATE_TRUE: |
| 2995 ia2_attributes_.push_back(L"invalid:true"); | 2993 ia2_attributes_.push_back(L"invalid:true"); |
| 2996 break; | 2994 break; |
| 2997 case ui::AX_INVALID_STATE_SPELLING: | 2995 case ui::AX_INVALID_STATE_SPELLING: |
| 2998 ia2_attributes_.push_back(L"invalid:spelling"); | 2996 ia2_attributes_.push_back(L"invalid:spelling"); |
| 2999 break; | 2997 break; |
| 3000 case ui::AX_INVALID_STATE_GRAMMAR: | 2998 case ui::AX_INVALID_STATE_GRAMMAR: |
| 3001 ia2_attributes_.push_back(L"invalid:grammar"); | 2999 ia2_attributes_.push_back(L"invalid:grammar"); |
| 3002 break; | 3000 break; |
| 3003 case ui::AX_INVALID_STATE_OTHER: | 3001 case ui::AX_INVALID_STATE_OTHER: |
| 3004 { | 3002 { |
| 3005 base::string16 aria_invalid_value; | 3003 base::string16 aria_invalid_value; |
| 3006 if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, | 3004 if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, |
| 3007 &aria_invalid_value)) { | 3005 &aria_invalid_value)) { |
| 3008 ia2_attributes_.push_back(L"invalid:" + aria_invalid_value); | 3006 ia2_attributes_.push_back(L"invalid:" + aria_invalid_value); |
| 3009 } else { | 3007 } else { |
| 3010 // Set the attribute to L"true", since we cannot be more specific. | 3008 // Set the attribute to L"true", since we cannot be more specific. |
| 3011 ia2_attributes_.push_back(L"invalid:true"); | 3009 ia2_attributes_.push_back(L"invalid:true"); |
| 3012 } | 3010 } |
| 3013 } | 3011 } |
| 3014 break; | 3012 break; |
| 3015 default: | 3013 default: |
| 3016 NOTREACHED(); | 3014 NOTREACHED(); |
| 3017 } | 3015 } |
| 3018 } | 3016 } |
| 3019 | 3017 |
| 3018 // Expose row or column header sort direction. | |
| 3019 int32 sort_direction; | |
| 3020 if ((ia_role_ == ROLE_SYSTEM_COLUMNHEADER || | |
| 3021 ia_role_ == ROLE_SYSTEM_ROWHEADER) && | |
| 3022 GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) { | |
| 3023 switch (sort_direction) { | |
| 3024 case ui::AX_SORT_DIRECTION_UNSORTED: | |
| 3025 ia2_attributes_.push_back(L"sort:none"); | |
| 3026 break; | |
| 3027 case ui::AX_SORT_DIRECTION_ASCENDING: | |
| 3028 ia2_attributes_.push_back(L"sort:ascending"); | |
| 3029 break; | |
| 3030 case ui::AX_SORT_DIRECTION_DESCENDING: | |
| 3031 ia2_attributes_.push_back(L"sort:descending"); | |
| 3032 break; | |
| 3033 case ui::AX_SORT_DIRECTION_OTHER: | |
| 3034 ia2_attributes_.push_back(L"sort:other"); | |
| 3035 break; | |
| 3036 default: | |
| 3037 NOTREACHED(); | |
| 3038 } | |
| 3039 } | |
| 3040 | |
| 3020 // The calculation of the accessible name of an element has been | 3041 // The calculation of the accessible name of an element has been |
| 3021 // standardized in the HTML to Platform Accessibility APIs Implementation | 3042 // standardized in the HTML to Platform Accessibility APIs Implementation |
| 3022 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the | 3043 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the |
| 3023 // appropriate accessible name on Windows, we need to apply some logic | 3044 // appropriate accessible name on Windows, we need to apply some logic |
| 3024 // to the fields we get from WebKit. | 3045 // to the fields we get from WebKit. |
| 3025 // | 3046 // |
| 3026 // TODO(dmazzoni): move most of this logic into WebKit. | 3047 // TODO(dmazzoni): move most of this logic into WebKit. |
| 3027 // | 3048 // |
| 3028 // WebKit gives us: | 3049 // WebKit gives us: |
| 3029 // | 3050 // |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3892 // The role should always be set. | 3913 // The role should always be set. |
| 3893 DCHECK(!role_name_.empty() || ia_role_); | 3914 DCHECK(!role_name_.empty() || ia_role_); |
| 3894 | 3915 |
| 3895 // If we didn't explicitly set the IAccessible2 role, make it the same | 3916 // If we didn't explicitly set the IAccessible2 role, make it the same |
| 3896 // as the MSAA role. | 3917 // as the MSAA role. |
| 3897 if (!ia2_role_) | 3918 if (!ia2_role_) |
| 3898 ia2_role_ = ia_role_; | 3919 ia2_role_ = ia_role_; |
| 3899 } | 3920 } |
| 3900 | 3921 |
| 3901 } // namespace content | 3922 } // namespace content |
| OLD | NEW |