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 "chrome/browser/ui/views/accessibility_event_router_views.h" | 5 #include "chrome/browser/ui/views/accessibility_event_router_views.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 return false; | 312 return false; |
313 } | 313 } |
314 | 314 |
315 void AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( | 315 void AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( |
316 views::View* menu, | 316 views::View* menu, |
317 views::View* item, | 317 views::View* item, |
318 int* index, | 318 int* index, |
319 int* count) { | 319 int* count) { |
320 for (int i = 0; i < menu->child_count(); ++i) { | 320 for (int i = 0; i < menu->child_count(); ++i) { |
321 views::View* child = menu->GetChildViewAt(i); | 321 views::View* child = menu->child_at(i); |
322 int previous_count = *count; | 322 int previous_count = *count; |
323 RecursiveGetMenuItemIndexAndCount(child, item, index, count); | 323 RecursiveGetMenuItemIndexAndCount(child, item, index, count); |
324 if (child->GetClassName() == views::MenuItemView::kViewClassName && | 324 if (child->GetClassName() == views::MenuItemView::kViewClassName && |
325 *count == previous_count) { | 325 *count == previous_count) { |
326 if (item == child) | 326 if (item == child) |
327 *index = *count; | 327 *index = *count; |
328 (*count)++; | 328 (*count)++; |
329 } else if (child->GetClassName() == views::TextButton::kViewClassName) { | 329 } else if (child->GetClassName() == views::TextButton::kViewClassName) { |
330 if (item == child) | 330 if (item == child) |
331 *index = *count; | 331 *index = *count; |
332 (*count)++; | 332 (*count)++; |
333 } | 333 } |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 std::string AccessibilityEventRouterViews::RecursiveGetStaticText( | 337 std::string AccessibilityEventRouterViews::RecursiveGetStaticText( |
338 views::View* view) { | 338 views::View* view) { |
339 ui::AccessibleViewState state; | 339 ui::AccessibleViewState state; |
340 view->GetAccessibleState(&state); | 340 view->GetAccessibleState(&state); |
341 if (state.role == ui::AccessibilityTypes::ROLE_STATICTEXT) | 341 if (state.role == ui::AccessibilityTypes::ROLE_STATICTEXT) |
342 return UTF16ToUTF8(state.name); | 342 return UTF16ToUTF8(state.name); |
343 | 343 |
344 for (int i = 0; i < view->child_count(); ++i) { | 344 for (int i = 0; i < view->child_count(); ++i) { |
345 views::View* child = view->GetChildViewAt(i); | 345 views::View* child = view->child_at(i); |
346 std::string result = RecursiveGetStaticText(child); | 346 std::string result = RecursiveGetStaticText(child); |
347 if (!result.empty()) | 347 if (!result.empty()) |
348 return result; | 348 return result; |
349 } | 349 } |
350 return std::string(); | 350 return std::string(); |
351 } | 351 } |
OLD | NEW |