Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Unified Diff: ui/views/controls/tabbed_pane/tabbed_pane.cc

Issue 2578303003: a11y: Add a11y information to views::Tab and manually ignore its a11y children. (Closed)
Patch Set: Rebase back onto origin/master. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/tabbed_pane/tabbed_pane.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/views/controls/tabbed_pane/tabbed_pane.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698