| 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 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3031 } | 3031 } |
| 3032 } | 3032 } |
| 3033 } | 3033 } |
| 3034 | 3034 |
| 3035 // Expose invalid state for form controls and elements with aria-invalid. | 3035 // Expose invalid state for form controls and elements with aria-invalid. |
| 3036 int invalid_state; | 3036 int invalid_state; |
| 3037 if (GetIntAttribute(ui::AX_ATTR_INVALID_STATE, &invalid_state)) { | 3037 if (GetIntAttribute(ui::AX_ATTR_INVALID_STATE, &invalid_state)) { |
| 3038 // TODO(nektar): Handle the possibility of having multiple aria-invalid | 3038 // TODO(nektar): Handle the possibility of having multiple aria-invalid |
| 3039 // attributes defined, e.g., "invalid:spelling,grammar". | 3039 // attributes defined, e.g., "invalid:spelling,grammar". |
| 3040 switch (invalid_state) { | 3040 switch (invalid_state) { |
| 3041 case ui::AX_INVALID_STATE_NONE: | |
| 3042 break; | |
| 3043 case ui::AX_INVALID_STATE_FALSE: | 3041 case ui::AX_INVALID_STATE_FALSE: |
| 3044 win_attributes_->ia2_attributes.push_back(L"invalid:false"); | 3042 win_attributes_->ia2_attributes.push_back(L"invalid:false"); |
| 3045 break; | 3043 break; |
| 3046 case ui::AX_INVALID_STATE_TRUE: | 3044 case ui::AX_INVALID_STATE_TRUE: |
| 3047 win_attributes_->ia2_attributes.push_back(L"invalid:true"); | 3045 win_attributes_->ia2_attributes.push_back(L"invalid:true"); |
| 3048 break; | 3046 break; |
| 3049 case ui::AX_INVALID_STATE_SPELLING: | 3047 case ui::AX_INVALID_STATE_SPELLING: |
| 3050 win_attributes_->ia2_attributes.push_back(L"invalid:spelling"); | 3048 win_attributes_->ia2_attributes.push_back(L"invalid:spelling"); |
| 3051 break; | 3049 break; |
| 3052 case ui::AX_INVALID_STATE_GRAMMAR: | 3050 case ui::AX_INVALID_STATE_GRAMMAR: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3063 // Set the attribute to L"true", since we cannot be more specific. | 3061 // Set the attribute to L"true", since we cannot be more specific. |
| 3064 win_attributes_->ia2_attributes.push_back(L"invalid:true"); | 3062 win_attributes_->ia2_attributes.push_back(L"invalid:true"); |
| 3065 } | 3063 } |
| 3066 } | 3064 } |
| 3067 break; | 3065 break; |
| 3068 default: | 3066 default: |
| 3069 NOTREACHED(); | 3067 NOTREACHED(); |
| 3070 } | 3068 } |
| 3071 } | 3069 } |
| 3072 | 3070 |
| 3071 // Expose row or column header sort direction. |
| 3072 int32 sort_direction; |
| 3073 if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || |
| 3074 ia_role() == ROLE_SYSTEM_ROWHEADER) && |
| 3075 GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) { |
| 3076 switch (sort_direction) { |
| 3077 case ui::AX_SORT_DIRECTION_UNSORTED: |
| 3078 win_attributes_->ia2_attributes.push_back(L"sort:none"); |
| 3079 break; |
| 3080 case ui::AX_SORT_DIRECTION_ASCENDING: |
| 3081 win_attributes_->ia2_attributes.push_back(L"sort:ascending"); |
| 3082 break; |
| 3083 case ui::AX_SORT_DIRECTION_DESCENDING: |
| 3084 win_attributes_->ia2_attributes.push_back(L"sort:descending"); |
| 3085 break; |
| 3086 case ui::AX_SORT_DIRECTION_OTHER: |
| 3087 win_attributes_->ia2_attributes.push_back(L"sort:other"); |
| 3088 break; |
| 3089 default: |
| 3090 NOTREACHED(); |
| 3091 } |
| 3092 } |
| 3093 |
| 3073 // The calculation of the accessible name of an element has been | 3094 // The calculation of the accessible name of an element has been |
| 3074 // standardized in the HTML to Platform Accessibility APIs Implementation | 3095 // standardized in the HTML to Platform Accessibility APIs Implementation |
| 3075 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the | 3096 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the |
| 3076 // appropriate accessible name on Windows, we need to apply some logic | 3097 // appropriate accessible name on Windows, we need to apply some logic |
| 3077 // to the fields we get from WebKit. | 3098 // to the fields we get from WebKit. |
| 3078 // | 3099 // |
| 3079 // TODO(dmazzoni): move most of this logic into WebKit. | 3100 // TODO(dmazzoni): move most of this logic into WebKit. |
| 3080 // | 3101 // |
| 3081 // WebKit gives us: | 3102 // WebKit gives us: |
| 3082 // | 3103 // |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4089 ia2_role = ia_role; | 4110 ia2_role = ia_role; |
| 4090 | 4111 |
| 4091 win_attributes_->ia_role = ia_role; | 4112 win_attributes_->ia_role = ia_role; |
| 4092 win_attributes_->ia_state = ia_state; | 4113 win_attributes_->ia_state = ia_state; |
| 4093 win_attributes_->role_name = role_name; | 4114 win_attributes_->role_name = role_name; |
| 4094 win_attributes_->ia2_role = ia2_role; | 4115 win_attributes_->ia2_role = ia2_role; |
| 4095 win_attributes_->ia2_state = ia2_state; | 4116 win_attributes_->ia2_state = ia2_state; |
| 4096 } | 4117 } |
| 4097 | 4118 |
| 4098 } // namespace content | 4119 } // namespace content |
| OLD | NEW |