| 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 "ash/common/system/tray/tray_utils.h" | 5 #include "ash/common/system/tray/tray_utils.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/wm_shelf_util.h" | 7 #include "ash/common/shelf/wm_shelf_util.h" |
| 8 #include "ash/common/system/tray/tray_constants.h" | 8 #include "ash/common/system/tray/tray_constants.h" |
| 9 #include "ash/common/system/tray/tray_item_view.h" | 9 #include "ash/common/system/tray/tray_item_view.h" |
| 10 #include "ui/accessibility/ax_view_state.h" | 10 #include "ui/accessibility/ax_view_state.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 void SetTrayLabelItemBorder(TrayItemView* tray_view, ShelfAlignment alignment) { | 43 void SetTrayLabelItemBorder(TrayItemView* tray_view, ShelfAlignment alignment) { |
| 44 if (IsHorizontalAlignment(alignment)) { | 44 if (IsHorizontalAlignment(alignment)) { |
| 45 tray_view->SetBorder(views::Border::CreateEmptyBorder( | 45 tray_view->SetBorder(views::Border::CreateEmptyBorder( |
| 46 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, | 46 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, |
| 47 kTrayLabelItemHorizontalPaddingBottomAlignment)); | 47 kTrayLabelItemHorizontalPaddingBottomAlignment)); |
| 48 } else { | 48 } else { |
| 49 // Center the label for vertical launcher alignment. | 49 // Center the label for vertical launcher alignment. |
| 50 int horizontal_padding = std::max(0, | 50 int horizontal_padding = |
| 51 (tray_view->GetPreferredSize().width() - | 51 std::max(0, (tray_view->GetPreferredSize().width() - |
| 52 tray_view->label()->GetPreferredSize().width()) / 2); | 52 tray_view->label()->GetPreferredSize().width()) / |
| 53 2); |
| 53 tray_view->SetBorder(views::Border::CreateEmptyBorder( | 54 tray_view->SetBorder(views::Border::CreateEmptyBorder( |
| 54 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding, | 55 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding, |
| 55 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding)); | 56 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding)); |
| 56 } | 57 } |
| 57 } | 58 } |
| 58 | 59 |
| 59 void GetAccessibleLabelFromDescendantViews( | 60 void GetAccessibleLabelFromDescendantViews( |
| 60 views::View* view, | 61 views::View* view, |
| 61 std::vector<base::string16>& out_labels) { | 62 std::vector<base::string16>& out_labels) { |
| 62 ui::AXViewState temp_state; | 63 ui::AXViewState temp_state; |
| 63 view->GetAccessibleState(&temp_state); | 64 view->GetAccessibleState(&temp_state); |
| 64 if (!temp_state.name.empty()) | 65 if (!temp_state.name.empty()) |
| 65 out_labels.push_back(temp_state.name); | 66 out_labels.push_back(temp_state.name); |
| 66 | 67 |
| 67 // Do not descend into static text labels which may compute their own labels | 68 // Do not descend into static text labels which may compute their own labels |
| 68 // recursively. | 69 // recursively. |
| 69 if (temp_state.role == ui::AX_ROLE_STATIC_TEXT) | 70 if (temp_state.role == ui::AX_ROLE_STATIC_TEXT) |
| 70 return; | 71 return; |
| 71 | 72 |
| 72 for (int i = 0; i < view->child_count(); ++i) | 73 for (int i = 0; i < view->child_count(); ++i) |
| 73 GetAccessibleLabelFromDescendantViews(view->child_at(i), out_labels); | 74 GetAccessibleLabelFromDescendantViews(view->child_at(i), out_labels); |
| 74 } | 75 } |
| 75 | 76 |
| 76 } // namespace ash | 77 } // namespace ash |
| OLD | NEW |