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 "ui/views/accessibility/native_view_accessibility_win.h" | 5 #include "ui/views/accessibility/native_view_accessibility_win.h" |
6 | 6 |
7 #include <oleacc.h> | 7 #include <oleacc.h> |
8 #include <UIAutomationClient.h> | 8 #include <UIAutomationClient.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 if (!states) | 830 if (!states) |
831 return E_INVALIDARG; | 831 return E_INVALIDARG; |
832 | 832 |
833 ui::AXViewState state; | 833 ui::AXViewState state; |
834 view_->GetAccessibleState(&state); | 834 view_->GetAccessibleState(&state); |
835 | 835 |
836 // There are only a couple of states we need to support | 836 // There are only a couple of states we need to support |
837 // in IAccessible2. If any more are added, we may want to | 837 // in IAccessible2. If any more are added, we may want to |
838 // add a helper function like MSAAState. | 838 // add a helper function like MSAAState. |
839 *states = IA2_STATE_OPAQUE; | 839 *states = IA2_STATE_OPAQUE; |
840 if (state.state & ui::AX_STATE_EDITABLE) | 840 if (state.HasStateFlag(ui::AX_STATE_EDITABLE)) |
841 *states |= IA2_STATE_EDITABLE; | 841 *states |= IA2_STATE_EDITABLE; |
842 | 842 |
843 return S_OK; | 843 return S_OK; |
844 } | 844 } |
845 | 845 |
846 STDMETHODIMP NativeViewAccessibilityWin::get_uniqueID(LONG* unique_id) { | 846 STDMETHODIMP NativeViewAccessibilityWin::get_uniqueID(LONG* unique_id) { |
847 if (!view_) | 847 if (!view_) |
848 return E_FAIL; | 848 return E_FAIL; |
849 | 849 |
850 if (!unique_id) | 850 if (!unique_id) |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 return ROLE_SYSTEM_TOOLBAR; | 1238 return ROLE_SYSTEM_TOOLBAR; |
1239 case ui::AX_ROLE_WINDOW: | 1239 case ui::AX_ROLE_WINDOW: |
1240 return ROLE_SYSTEM_WINDOW; | 1240 return ROLE_SYSTEM_WINDOW; |
1241 case ui::AX_ROLE_CLIENT: | 1241 case ui::AX_ROLE_CLIENT: |
1242 default: | 1242 default: |
1243 // This is the default role for MSAA. | 1243 // This is the default role for MSAA. |
1244 return ROLE_SYSTEM_CLIENT; | 1244 return ROLE_SYSTEM_CLIENT; |
1245 } | 1245 } |
1246 } | 1246 } |
1247 | 1247 |
1248 int32 NativeViewAccessibilityWin::MSAAState(uint32 state) { | 1248 int32 NativeViewAccessibilityWin::MSAAState(const ui::AXViewState& state) { |
1249 // This maps MSAA states for get_accState(). See also the IAccessible2 | 1249 // This maps MSAA states for get_accState(). See also the IAccessible2 |
1250 // interface get_states(). | 1250 // interface get_states(). |
1251 | 1251 |
1252 int32 msaa_state = 0; | 1252 int32 msaa_state = 0; |
1253 if (state & ui::AX_STATE_CHECKED) | 1253 if (state.HasStateFlag(ui::AX_STATE_CHECKED)) |
1254 msaa_state |= STATE_SYSTEM_CHECKED; | 1254 msaa_state |= STATE_SYSTEM_CHECKED; |
1255 if (state & ui::AX_STATE_COLLAPSED) | 1255 if (state.HasStateFlag(ui::AX_STATE_COLLAPSED)) |
1256 msaa_state |= STATE_SYSTEM_COLLAPSED; | 1256 msaa_state |= STATE_SYSTEM_COLLAPSED; |
1257 if (state & ui::AX_STATE_DEFAULT) | 1257 if (state.HasStateFlag(ui::AX_STATE_DEFAULT)) |
1258 msaa_state |= STATE_SYSTEM_DEFAULT; | 1258 msaa_state |= STATE_SYSTEM_DEFAULT; |
1259 if (state & ui::AX_STATE_EXPANDED) | 1259 if (state.HasStateFlag(ui::AX_STATE_EXPANDED)) |
1260 msaa_state |= STATE_SYSTEM_EXPANDED; | 1260 msaa_state |= STATE_SYSTEM_EXPANDED; |
1261 if (state & ui::AX_STATE_HASPOPUP) | 1261 if (state.HasStateFlag(ui::AX_STATE_HASPOPUP)) |
1262 msaa_state |= STATE_SYSTEM_HASPOPUP; | 1262 msaa_state |= STATE_SYSTEM_HASPOPUP; |
1263 if (state & ui::AX_STATE_HOVERED) | 1263 if (state.HasStateFlag(ui::AX_STATE_HOVERED)) |
1264 msaa_state |= STATE_SYSTEM_HOTTRACKED; | 1264 msaa_state |= STATE_SYSTEM_HOTTRACKED; |
1265 if (state & ui::AX_STATE_INVISIBLE) | 1265 if (state.HasStateFlag(ui::AX_STATE_INVISIBLE)) |
1266 msaa_state |= STATE_SYSTEM_INVISIBLE; | 1266 msaa_state |= STATE_SYSTEM_INVISIBLE; |
1267 if (state & ui::AX_STATE_LINKED) | 1267 if (state.HasStateFlag(ui::AX_STATE_LINKED)) |
1268 msaa_state |= STATE_SYSTEM_LINKED; | 1268 msaa_state |= STATE_SYSTEM_LINKED; |
1269 if (state & ui::AX_STATE_OFFSCREEN) | 1269 if (state.HasStateFlag(ui::AX_STATE_OFFSCREEN)) |
1270 msaa_state |= STATE_SYSTEM_OFFSCREEN; | 1270 msaa_state |= STATE_SYSTEM_OFFSCREEN; |
1271 if (state & ui::AX_STATE_PRESSED) | 1271 if (state.HasStateFlag(ui::AX_STATE_PRESSED)) |
1272 msaa_state |= STATE_SYSTEM_PRESSED; | 1272 msaa_state |= STATE_SYSTEM_PRESSED; |
1273 if (state & ui::AX_STATE_PROTECTED) | 1273 if (state.HasStateFlag(ui::AX_STATE_PROTECTED)) |
1274 msaa_state |= STATE_SYSTEM_PROTECTED; | 1274 msaa_state |= STATE_SYSTEM_PROTECTED; |
1275 if (state & ui::AX_STATE_READ_ONLY) | 1275 if (state.HasStateFlag(ui::AX_STATE_READ_ONLY)) |
1276 msaa_state |= STATE_SYSTEM_READONLY; | 1276 msaa_state |= STATE_SYSTEM_READONLY; |
1277 if (state & ui::AX_STATE_SELECTED) | 1277 if (state.HasStateFlag(ui::AX_STATE_SELECTED)) |
1278 msaa_state |= STATE_SYSTEM_SELECTED; | 1278 msaa_state |= STATE_SYSTEM_SELECTED; |
1279 if (state & ui::AX_STATE_FOCUSED) | 1279 if (state.HasStateFlag(ui::AX_STATE_FOCUSED)) |
1280 msaa_state |= STATE_SYSTEM_FOCUSED; | 1280 msaa_state |= STATE_SYSTEM_FOCUSED; |
1281 if (state & ui::AX_STATE_DISABLED) | 1281 if (state.HasStateFlag(ui::AX_STATE_DISABLED)) |
1282 msaa_state |= STATE_SYSTEM_UNAVAILABLE; | 1282 msaa_state |= STATE_SYSTEM_UNAVAILABLE; |
1283 return msaa_state; | 1283 return msaa_state; |
1284 } | 1284 } |
1285 | 1285 |
1286 // | 1286 // |
1287 // Private methods. | 1287 // Private methods. |
1288 // | 1288 // |
1289 | 1289 |
1290 bool NativeViewAccessibilityWin::IsNavDirNext(int nav_dir) const { | 1290 bool NativeViewAccessibilityWin::IsNavDirNext(int nav_dir) const { |
1291 return (nav_dir == NAVDIR_RIGHT || | 1291 return (nav_dir == NAVDIR_RIGHT || |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 CustomButton* button = static_cast<CustomButton*>(view); | 1332 CustomButton* button = static_cast<CustomButton*>(view); |
1333 if (button->IsHotTracked()) | 1333 if (button->IsHotTracked()) |
1334 msaa_state->lVal |= STATE_SYSTEM_HOTTRACKED; | 1334 msaa_state->lVal |= STATE_SYSTEM_HOTTRACKED; |
1335 } | 1335 } |
1336 if (view->HasFocus()) | 1336 if (view->HasFocus()) |
1337 msaa_state->lVal |= STATE_SYSTEM_FOCUSED; | 1337 msaa_state->lVal |= STATE_SYSTEM_FOCUSED; |
1338 | 1338 |
1339 // Add on any view-specific states. | 1339 // Add on any view-specific states. |
1340 ui::AXViewState view_state; | 1340 ui::AXViewState view_state; |
1341 view->GetAccessibleState(&view_state); | 1341 view->GetAccessibleState(&view_state); |
1342 msaa_state->lVal |= MSAAState(view_state.state); | 1342 msaa_state->lVal |= MSAAState(view_state); |
1343 } | 1343 } |
1344 | 1344 |
1345 base::string16 NativeViewAccessibilityWin::TextForIAccessibleText() { | 1345 base::string16 NativeViewAccessibilityWin::TextForIAccessibleText() { |
1346 ui::AXViewState state; | 1346 ui::AXViewState state; |
1347 view_->GetAccessibleState(&state); | 1347 view_->GetAccessibleState(&state); |
1348 if (state.role == ui::AX_ROLE_TEXT_FIELD) | 1348 if (state.role == ui::AX_ROLE_TEXT_FIELD) |
1349 return state.value; | 1349 return state.value; |
1350 else | 1350 else |
1351 return state.name; | 1351 return state.name; |
1352 } | 1352 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 continue; | 1406 continue; |
1407 | 1407 |
1408 if (widget->GetNativeWindowProperty(kWidgetNativeViewHostKey)) | 1408 if (widget->GetNativeWindowProperty(kWidgetNativeViewHostKey)) |
1409 continue; | 1409 continue; |
1410 | 1410 |
1411 result_child_widgets->push_back(child_widget); | 1411 result_child_widgets->push_back(child_widget); |
1412 } | 1412 } |
1413 } | 1413 } |
1414 | 1414 |
1415 } // namespace views | 1415 } // namespace views |
OLD | NEW |