Chromium Code Reviews| Index: ui/views/controls/tabbed_pane/tabbed_pane.cc |
| diff --git a/ui/views/controls/tabbed_pane/tabbed_pane.cc b/ui/views/controls/tabbed_pane/tabbed_pane.cc |
| index f36f68083227ffe0517ac13fcd8a703def3e8bff..49fd043e74ee2088e29022118efa6765244d75a0 100644 |
| --- a/ui/views/controls/tabbed_pane/tabbed_pane.cc |
| +++ b/ui/views/controls/tabbed_pane/tabbed_pane.cc |
| @@ -27,6 +27,8 @@ |
| #include "ui/views/layout/layout_manager.h" |
| #include "ui/views/widget/widget.h" |
| +namespace views { |
| + |
| namespace { |
| // TODO(markusheintz|msw): Use NativeTheme colors. |
| @@ -42,9 +44,22 @@ const gfx::Font::Weight kInactiveWeight = gfx::Font::Weight::NORMAL; |
| const int kHarmonyTabStripTabHeight = 40; |
| -} // namespace |
| +// views::Tab shouldn't expose any of its children in the a11y tree. Instead, it |
| +// should provide the a11y information itself. Normally, non-keyboard-focusable |
| +// children of keyboard-focusable parents are ignored, but Tabs only mark the |
| +// currently selected tab as keyboard-focusable. This means all unselected Tabs |
| +// expose their children to the a11y tree. To fix, manually ignore the children. |
| +class IgnoredLabel : public Label { |
|
Patti Lor
2016/12/22 00:20:30
Alternatively, we could add a method onto NativeVi
tapted
2016/12/22 00:50:09
This looks good.
Patti Lor
2016/12/30 00:35:02
Ok, thanks! :)
|
| + public: |
| + IgnoredLabel(const base::string16& text, const gfx::FontList& font_list) |
|
tapted
2016/12/22 00:50:08
Can we call this TabLabel? And move the font_list
Patti Lor
2016/12/30 00:35:02
Done.
|
| + : Label(text, font_list) {} |
| -namespace views { |
| + void GetAccessibleNodeData(ui::AXNodeData* data) override { |
| + data->role = ui::AX_ROLE_IGNORED; |
| + } |
| +}; |
| + |
| +} // namespace |
| // static |
| const char TabbedPane::kViewClassName[] = "TabbedPane"; |
| @@ -132,7 +147,7 @@ const char Tab::kViewClassName[] = "Tab"; |
| Tab::Tab(TabbedPane* tabbed_pane, const base::string16& title, View* contents) |
| : tabbed_pane_(tabbed_pane), |
| - title_(new Label( |
| + title_(new IgnoredLabel( |
| title, |
| ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( |
| ui::kLabelFontSizeDelta, |
| @@ -238,6 +253,12 @@ void Tab::SetState(TabState tab_state) { |
| SchedulePaint(); |
| } |
| +void Tab::GetAccessibleNodeData(ui::AXNodeData* data) { |
| + data->role = ui::AX_ROLE_TAB; |
| + data->SetName(title()->text()); |
| + data->AddStateFlag(ui::AX_STATE_SELECTABLE); |
| +} |
|
tapted
2016/12/22 00:50:08
Are there more things we should add that NSSegment
Patti Lor
2016/12/30 00:35:02
Good point - I've added ui::AX_STATE_SELECTED => A
|
| + |
| void Tab::OnFocus() { |
| OnStateChanged(); |
| // When the tab gains focus, send an accessibility event indicating that the |