| 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..552c6ee05930fae26d6774ad23b1bff47700f34a 100644
|
| --- a/ui/views/controls/tabbed_pane/tabbed_pane.cc
|
| +++ b/ui/views/controls/tabbed_pane/tabbed_pane.cc
|
| @@ -8,6 +8,7 @@
|
| #include "base/macros.h"
|
| #include "third_party/skia/include/core/SkPaint.h"
|
| #include "third_party/skia/include/core/SkPath.h"
|
| +#include "ui/accessibility/ax_action_data.h"
|
| #include "ui/accessibility/ax_node_data.h"
|
| #include "ui/base/default_style.h"
|
| #include "ui/base/material_design/material_design_controller.h"
|
| @@ -27,6 +28,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 +45,29 @@ const gfx::Font::Weight kInactiveWeight = gfx::Font::Weight::NORMAL;
|
|
|
| const int kHarmonyTabStripTabHeight = 40;
|
|
|
| -} // namespace
|
| +// The View containing the text for each tab in the tab strip.
|
| +class TabLabel : public Label {
|
| + public:
|
| + explicit TabLabel(const base::string16& tab_title)
|
| + : Label(tab_title,
|
| + ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
|
| + ui::kLabelFontSizeDelta,
|
| + gfx::Font::NORMAL,
|
| + kActiveWeight)) {}
|
| +
|
| + // Label:
|
| + void GetAccessibleNodeData(ui::AXNodeData* data) override {
|
| + // 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.
|
| + data->role = ui::AX_ROLE_IGNORED;
|
| + }
|
| +};
|
|
|
| -namespace views {
|
| +} // namespace
|
|
|
| // static
|
| const char TabbedPane::kViewClassName[] = "TabbedPane";
|
| @@ -67,33 +90,6 @@ class MdTab : public Tab {
|
| DISALLOW_COPY_AND_ASSIGN(MdTab);
|
| };
|
|
|
| -// The tab strip shown above the tab contents.
|
| -class TabStrip : public View {
|
| - public:
|
| - // Internal class name.
|
| - static const char kViewClassName[];
|
| -
|
| - TabStrip();
|
| - ~TabStrip() override;
|
| -
|
| - // Called by TabStrip when the selected tab changes. This function is only
|
| - // called if |from_tab| is not null, i.e., there was a previously selected
|
| - // tab.
|
| - virtual void OnSelectedTabChanged(Tab* from_tab, Tab* to_tab);
|
| -
|
| - // Overridden from View:
|
| - const char* GetClassName() const override;
|
| - void OnPaintBorder(gfx::Canvas* canvas) override;
|
| -
|
| - Tab* GetSelectedTab() const;
|
| - Tab* GetTabAtDeltaFromSelected(int delta) const;
|
| - Tab* GetTabAtIndex(int index) const;
|
| - int GetSelectedTabIndex() const;
|
| -
|
| - private:
|
| - DISALLOW_COPY_AND_ASSIGN(TabStrip);
|
| -};
|
| -
|
| // A subclass of TabStrip that implements the Harmony visual styling. This
|
| // class uses a BoxLayout to position tabs.
|
| class MdTabStrip : public TabStrip, public gfx::AnimationDelegate {
|
| @@ -132,12 +128,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,
|
| - ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
|
| - ui::kLabelFontSizeDelta,
|
| - gfx::Font::NORMAL,
|
| - kActiveWeight))),
|
| + title_(new TabLabel(title)),
|
| tab_state_(TAB_ACTIVE),
|
| contents_(contents) {
|
| // Calculate this now while the font list is guaranteed to be bold.
|
| @@ -238,6 +229,24 @@ 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);
|
| + if (selected())
|
| + data->AddStateFlag(ui::AX_STATE_SELECTED);
|
| +}
|
| +
|
| +bool Tab::HandleAccessibleAction(const ui::AXActionData& action_data) {
|
| + if (action_data.action != ui::AX_ACTION_SET_SELECTION || !enabled())
|
| + return false;
|
| +
|
| + // It's not clear what should happen if a tab is 'deselected', so the
|
| + // AX_ACTION_SET_SELECTION action will always select the tab.
|
| + tabbed_pane_->SelectTab(this);
|
| + return true;
|
| +}
|
| +
|
| void Tab::OnFocus() {
|
| OnStateChanged();
|
| // When the tab gains focus, send an accessibility event indicating that the
|
|
|