diff options
Diffstat (limited to 'views/controls')
50 files changed, 274 insertions, 325 deletions
diff --git a/views/controls/button/button.cc b/views/controls/button/button.cc index 6d18204..7b6cc75 100644 --- a/views/controls/button/button.cc +++ b/views/controls/button/button.cc @@ -3,9 +3,7 @@ // found in the LICENSE file. #include "views/controls/button/button.h" - #include "base/utf_string_conversions.h" -#include "ui/base/accessibility/accessible_view_state.h" namespace views { @@ -20,12 +18,8 @@ void Button::SetTooltipText(const std::wstring& tooltip_text) { TooltipTextChanged(); } -void Button::SetAccessibleName(const string16& name) { - accessible_name_ = name; -} - -void Button::SetAccessibleKeyboardShortcut(const string16& shortcut) { - accessible_shortcut_ = shortcut; +void Button::SetAccessibleKeyboardShortcut(const std::wstring& shortcut) { + accessible_shortcut_ = WideToUTF16Hack(shortcut); } //////////////////////////////////////////////////////////////////////////////// @@ -39,10 +33,12 @@ bool Button::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { return true; } -void Button::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; - state->name = accessible_name_; - state->keyboard_shortcut = accessible_shortcut_; +string16 Button::GetAccessibleKeyboardShortcut() { + return accessible_shortcut_; +} + +AccessibilityTypes::Role Button::GetAccessibleRole() { + return AccessibilityTypes::ROLE_PUSHBUTTON; } //////////////////////////////////////////////////////////////////////////////// diff --git a/views/controls/button/button.h b/views/controls/button/button.h index 0c9c6c7..263e45f 100644 --- a/views/controls/button/button.h +++ b/views/controls/button/button.h @@ -36,13 +36,13 @@ class Button : public View { int mouse_event_flags() const { return mouse_event_flags_; } - void SetAccessibleName(const string16& name); - void SetAccessibleKeyboardShortcut(const string16& shortcut); + void SetAccessibleKeyboardShortcut(const std::wstring& shortcut); // Overridden from View: virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual string16 GetAccessibleKeyboardShortcut() OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; protected: // Construct the Button with a Listener. The listener can be NULL. This can be @@ -61,7 +61,6 @@ class Button : public View { string16 tooltip_text_; // Accessibility data. - string16 accessible_name_; string16 accessible_shortcut_; // The id tag associated with this button. Used to disambiguate buttons in diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc index a5f7ab1..d2f69e2 100644 --- a/views/controls/button/button_dropdown.cc +++ b/views/controls/button/button_dropdown.cc @@ -8,7 +8,6 @@ #include "base/message_loop.h" #include "base/utf_string_conversions.h" #include "grit/app_strings.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/l10n/l10n_util.h" #include "views/controls/menu/view_menu_delegate.h" #include "views/widget/widget.h" @@ -166,11 +165,16 @@ void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) { // //////////////////////////////////////////////////////////////////////////////// -void ButtonDropDown::GetAccessibleState(ui::AccessibleViewState* state) { - CustomButton::GetAccessibleState(state); - state->role = ui::AccessibilityTypes::ROLE_BUTTONDROPDOWN; - state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); - state->state = ui::AccessibilityTypes::STATE_HASPOPUP; +string16 ButtonDropDown::GetAccessibleDefaultAction() { + return l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); +} + +AccessibilityTypes::Role ButtonDropDown::GetAccessibleRole() { + return AccessibilityTypes::ROLE_BUTTONDROPDOWN; +} + +AccessibilityTypes::State ButtonDropDown::GetAccessibleState() { + return AccessibilityTypes::STATE_HASPOPUP; } } // namespace views diff --git a/views/controls/button/button_dropdown.h b/views/controls/button/button_dropdown.h index 32f2c5c..07b8276 100644 --- a/views/controls/button/button_dropdown.h +++ b/views/controls/button/button_dropdown.h @@ -26,7 +26,9 @@ class ButtonDropDown : public ImageButton { virtual ~ButtonDropDown(); // Accessibility accessors, overridden from View. - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual string16 GetAccessibleDefaultAction() OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual AccessibilityTypes::State GetAccessibleState() OVERRIDE; private: // Overridden from CustomButton diff --git a/views/controls/button/checkbox.cc b/views/controls/button/checkbox.cc index 2a34cc5..719dfd8 100644 --- a/views/controls/button/checkbox.cc +++ b/views/controls/button/checkbox.cc @@ -5,7 +5,6 @@ #include "views/controls/button/checkbox.h" #include "base/logging.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/gfx/canvas.h" #include "views/controls/label.h" @@ -159,10 +158,12 @@ void Checkbox::OnBlur() { label_->set_paint_as_focused(false); } -void Checkbox::GetAccessibleState(ui::AccessibleViewState* state) { - Button::GetAccessibleState(state); - state->role = ui::AccessibilityTypes::ROLE_CHECKBUTTON; - state->state = checked() ? ui::AccessibilityTypes::STATE_CHECKED : 0; +AccessibilityTypes::Role Checkbox::GetAccessibleRole() { + return AccessibilityTypes::ROLE_CHECKBUTTON; +} + +AccessibilityTypes::State Checkbox::GetAccessibleState() { + return checked() ? AccessibilityTypes::STATE_CHECKED : 0; } std::string Checkbox::GetClassName() const { diff --git a/views/controls/button/checkbox.h b/views/controls/button/checkbox.h index 801b0fd..71d218d 100644 --- a/views/controls/button/checkbox.h +++ b/views/controls/button/checkbox.h @@ -57,7 +57,8 @@ class Checkbox : public NativeButton { virtual void OnBlur() OVERRIDE; // Accessibility accessors, overridden from View. - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual AccessibilityTypes::State GetAccessibleState() OVERRIDE; // Overridden from NativeButton: virtual void SetLabel(const std::wstring& label) OVERRIDE; diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc index fc349a2..1696d14 100644 --- a/views/controls/button/custom_button.cc +++ b/views/controls/button/custom_button.cc @@ -4,11 +4,9 @@ #include "views/controls/button/custom_button.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/animation/throb_animation.h" #include "ui/base/keycodes/keyboard_codes.h" #include "views/screen.h" -#include "views/widget/widget.h" namespace views { @@ -59,23 +57,24 @@ void CustomButton::SetAnimationDuration(int duration) { //////////////////////////////////////////////////////////////////////////////// // CustomButton, View overrides: -void CustomButton::GetAccessibleState(ui::AccessibleViewState* state) { - Button::GetAccessibleState(state); +AccessibilityTypes::State CustomButton::GetAccessibleState() { + int state = 0; switch (state_) { case BS_HOT: - state->state = ui::AccessibilityTypes::STATE_HOTTRACKED; + state = AccessibilityTypes::STATE_HOTTRACKED; break; case BS_PUSHED: - state->state = ui::AccessibilityTypes::STATE_PRESSED; + state = AccessibilityTypes::STATE_PRESSED; break; case BS_DISABLED: - state->state = ui::AccessibilityTypes::STATE_UNAVAILABLE; + state = AccessibilityTypes::STATE_UNAVAILABLE; break; case BS_NORMAL: case BS_COUNT: // No additional accessibility state set for this button state. break; } + return state; } void CustomButton::SetEnabled(bool enabled) { @@ -249,10 +248,8 @@ void CustomButton::SetHotTracked(bool flag) { if (state_ != BS_DISABLED) SetState(flag ? BS_HOT : BS_NORMAL); - if (flag) { - GetWidget()->NotifyAccessibilityEvent( - this, ui::AccessibilityTypes::EVENT_FOCUS, true); - } + if (flag) + NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS); } bool CustomButton::IsHotTracked() const { diff --git a/views/controls/button/custom_button.h b/views/controls/button/custom_button.h index 1a0f75e..17dafbf 100644 --- a/views/controls/button/custom_button.h +++ b/views/controls/button/custom_button.h @@ -48,7 +48,7 @@ class CustomButton : public Button, void SetAnimationDuration(int duration); // Overridden from View: - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual AccessibilityTypes::State GetAccessibleState() OVERRIDE; virtual void SetEnabled(bool enabled) OVERRIDE; virtual bool IsEnabled() const OVERRIDE; virtual bool IsFocusable() const OVERRIDE; diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc index db138bb..f88b106 100644 --- a/views/controls/button/menu_button.cc +++ b/views/controls/button/menu_button.cc @@ -7,7 +7,6 @@ #include "base/utf_string_conversions.h" #include "grit/app_strings.h" #include "grit/app_resources.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/dragdrop/drag_drop_types.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" @@ -261,11 +260,16 @@ void MenuButton::OnMouseExited(const MouseEvent& event) { // //////////////////////////////////////////////////////////////////////////////// -void MenuButton::GetAccessibleState(ui::AccessibleViewState* state) { - CustomButton::GetAccessibleState(state); - state->role = ui::AccessibilityTypes::ROLE_BUTTONMENU; - state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); - state->state = ui::AccessibilityTypes::STATE_HASPOPUP; +string16 MenuButton::GetAccessibleDefaultAction() { + return l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); +} + +AccessibilityTypes::Role MenuButton::GetAccessibleRole() { + return AccessibilityTypes::ROLE_BUTTONMENU; +} + +AccessibilityTypes::State MenuButton::GetAccessibleState() { + return AccessibilityTypes::STATE_HASPOPUP; } std::string MenuButton::GetClassName() const { diff --git a/views/controls/button/menu_button.h b/views/controls/button/menu_button.h index c6f3092..55f5a89 100644 --- a/views/controls/button/menu_button.h +++ b/views/controls/button/menu_button.h @@ -58,7 +58,9 @@ class MenuButton : public TextButton { virtual bool OnKeyReleased(const KeyEvent& e); // Accessibility accessors, overridden from View. - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual string16 GetAccessibleDefaultAction() OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual AccessibilityTypes::State GetAccessibleState() OVERRIDE; // Returns views/MenuButton. virtual std::string GetClassName() const; diff --git a/views/controls/button/native_button_win.cc b/views/controls/button/native_button_win.cc index 2783c84..fbba56a 100644 --- a/views/controls/button/native_button_win.cc +++ b/views/controls/button/native_button_win.cc @@ -11,7 +11,6 @@ #include "base/win/scoped_comptr.h" #include "base/win/win_util.h" #include "base/win/windows_version.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "views/controls/button/checkbox.h" #include "views/controls/button/native_button.h" #include "views/controls/button/radio_button.h" @@ -72,19 +71,18 @@ void NativeButtonWin::UpdateDefault() { } void NativeButtonWin::UpdateAccessibleName() { - ui::AccessibleViewState state; - native_button_->GetAccessibleState(&state); - string16 name = state.name; - base::win::ScopedComPtr<IAccPropServices> pAccPropServices; - HRESULT hr = CoCreateInstance( - CLSID_AccPropServices, NULL, CLSCTX_SERVER, - IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); - if (SUCCEEDED(hr)) { - VARIANT var; - var.vt = VT_BSTR; - var.bstrVal = SysAllocString(name.c_str()); - hr = pAccPropServices->SetHwndProp(native_view(), OBJID_WINDOW, - CHILDID_SELF, PROPID_ACC_NAME, var); + string16 name; + if (native_button_->GetAccessibleName(&name)) { + base::win::ScopedComPtr<IAccPropServices> pAccPropServices; + HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, + IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); + if (SUCCEEDED(hr)) { + VARIANT var; + var.vt = VT_BSTR; + var.bstrVal = SysAllocString(name.c_str()); + hr = pAccPropServices->SetHwndProp(native_view(), OBJID_WINDOW, + CHILDID_SELF, PROPID_ACC_NAME, var); + } } } diff --git a/views/controls/button/radio_button.cc b/views/controls/button/radio_button.cc index f162f2c..4074da4 100644 --- a/views/controls/button/radio_button.cc +++ b/views/controls/button/radio_button.cc @@ -5,7 +5,6 @@ #include "views/controls/button/radio_button.h" #include "base/logging.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "views/widget/root_view.h" namespace views { @@ -61,9 +60,8 @@ void RadioButton::SetChecked(bool checked) { //////////////////////////////////////////////////////////////////////////////// // RadioButton, View overrides: -void RadioButton::GetAccessibleState(ui::AccessibleViewState* state) { - Checkbox::GetAccessibleState(state); - state->role = ui::AccessibilityTypes::ROLE_RADIOBUTTON; +AccessibilityTypes::Role RadioButton::GetAccessibleRole() { + return AccessibilityTypes::ROLE_RADIOBUTTON; } View* RadioButton::GetSelectedViewForGroup(int group_id) { diff --git a/views/controls/button/radio_button.h b/views/controls/button/radio_button.h index 5ff6f76..7ea35f5 100644 --- a/views/controls/button/radio_button.h +++ b/views/controls/button/radio_button.h @@ -22,18 +22,16 @@ class RadioButton : public Checkbox { virtual ~RadioButton(); // Overridden from Checkbox: - virtual void SetChecked(bool checked) OVERRIDE; + virtual void SetChecked(bool checked); // Overridden from View: - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual View* GetSelectedViewForGroup(int group_id) OVERRIDE; - virtual bool IsGroupFocusTraversable() const OVERRIDE; - virtual void OnMouseReleased(const MouseEvent& event, bool canceled) - OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual View* GetSelectedViewForGroup(int group_id); + virtual bool IsGroupFocusTraversable() const; + virtual void OnMouseReleased(const MouseEvent& event, bool canceled); protected: - // Overridden from View: - virtual std::string GetClassName() const OVERRIDE; + virtual std::string GetClassName() const; // Overridden from NativeButton: virtual NativeButtonWrapper* CreateWrapper(); diff --git a/views/controls/combobox/combobox.cc b/views/controls/combobox/combobox.cc index 2f77942..be7d719 100644 --- a/views/controls/combobox/combobox.cc +++ b/views/controls/combobox/combobox.cc @@ -6,7 +6,6 @@ #include "base/logging.h" #include "base/utf_string_conversions.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/models/combobox_model.h" #include "views/controls/combobox/native_combobox_wrapper.h" @@ -53,10 +52,6 @@ void Combobox::SelectionChanged() { listener_->ItemChanged(this, prev_selected_item, selected_item_); } -void Combobox::SetAccessibleName(const string16& name) { - accessible_name_ = name; -} - //////////////////////////////////////////////////////////////////////////////// // Combobox, View overrides: @@ -94,10 +89,12 @@ void Combobox::OnPaintFocusBorder(gfx::Canvas* canvas) { View::OnPaintFocusBorder(canvas); } -void Combobox::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_COMBOBOX; - state->name = accessible_name_; - state->value = model_->GetItemAt(selected_item_); +AccessibilityTypes::Role Combobox::GetAccessibleRole() { + return AccessibilityTypes::ROLE_COMBOBOX; +} + +string16 Combobox::GetAccessibleValue() { + return model_->GetItemAt(selected_item_); } void Combobox::OnFocus() { diff --git a/views/controls/combobox/combobox.h b/views/controls/combobox/combobox.h index c50fadd..1de06d6 100644 --- a/views/controls/combobox/combobox.h +++ b/views/controls/combobox/combobox.h @@ -58,23 +58,20 @@ class Combobox : public View { // Accessor for |model_|. ComboboxModel* model() const { return model_; } - // Set the accessible name of the combo box. - void SetAccessibleName(const string16& name); - // Overridden from View: - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void Layout() OVERRIDE; - virtual void SetEnabled(bool enabled) OVERRIDE; - virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e) OVERRIDE; - virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual gfx::Size GetPreferredSize(); + virtual void Layout(); + virtual void SetEnabled(bool enabled); + virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e); + virtual void OnPaintFocusBorder(gfx::Canvas* canvas); + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual string16 GetAccessibleValue() OVERRIDE; protected: - // Overridden from View: - virtual void OnFocus() OVERRIDE; + virtual void OnFocus(); virtual void ViewHierarchyChanged(bool is_add, View* parent, - View* child) OVERRIDE; - virtual std::string GetClassName() const OVERRIDE; + View* child); + virtual std::string GetClassName() const; // The object that actually implements the native combobox. NativeComboboxWrapper* native_wrapper_; @@ -89,9 +86,6 @@ class Combobox : public View { // The current selection. int selected_item_; - // The accessible name of the text field. - string16 accessible_name_; - DISALLOW_COPY_AND_ASSIGN(Combobox); }; diff --git a/views/controls/image_view.cc b/views/controls/image_view.cc index bc86e55..7f05e97 100644 --- a/views/controls/image_view.cc +++ b/views/controls/image_view.cc @@ -6,7 +6,6 @@ #include "base/logging.h" #include "base/utf_string_conversions.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/gfx/canvas.h" #include "ui/gfx/insets.h" @@ -127,9 +126,8 @@ void ImageView::OnPaint(gfx::Canvas* canvas) { } } -void ImageView::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_GRAPHIC; - state->name = tooltip_text_; +AccessibilityTypes::Role ImageView::GetAccessibleRole() { + return AccessibilityTypes::ROLE_GRAPHIC; } void ImageView::SetHorizontalAlignment(Alignment ha) { @@ -156,6 +154,7 @@ ImageView::Alignment ImageView::GetVerticalAlignment() { void ImageView::SetTooltipText(const std::wstring& tooltip) { tooltip_text_ = WideToUTF16Hack(tooltip); + SetAccessibleName(WideToUTF16Hack(tooltip)); } std::wstring ImageView::GetTooltipText() { diff --git a/views/controls/image_view.h b/views/controls/image_view.h index cde4bfd..b1791ac 100644 --- a/views/controls/image_view.h +++ b/views/controls/image_view.h @@ -75,11 +75,10 @@ class ImageView : public View { std::wstring GetTooltipText(); // Overriden from View - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) - OVERRIDE; + virtual gfx::Size GetPreferredSize(); + virtual void OnPaint(gfx::Canvas* canvas); + virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); private: // Compute the image origin given the desired size and the receiver alignment diff --git a/views/controls/label.cc b/views/controls/label.cc index 6fedc80..1b105f0 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -12,7 +12,6 @@ #include "base/string_split.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/text/text_elider.h" #include "ui/gfx/canvas_skia.h" @@ -107,6 +106,7 @@ void Label::SetText(const std::wstring& text) { text_ = WideToUTF16Hack(text); url_set_ = false; text_size_valid_ = false; + SetAccessibleName(WideToUTF16Hack(text)); PreferredSizeChanged(); SchedulePaint(); } @@ -250,10 +250,12 @@ void Label::SizeToFit(int max_width) { SizeToPreferredSize(); } -void Label::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_STATICTEXT; - state->state = ui::AccessibilityTypes::STATE_READONLY; - state->name = text_; +AccessibilityTypes::Role Label::GetAccessibleRole() { + return AccessibilityTypes::ROLE_STATICTEXT; +} + +AccessibilityTypes::State Label::GetAccessibleState() { + return AccessibilityTypes::STATE_READONLY; } void Label::SetHasFocusBorder(bool has_focus_border) { diff --git a/views/controls/label.h b/views/controls/label.h index a0ef7d2..d916659 100644 --- a/views/controls/label.h +++ b/views/controls/label.h @@ -79,7 +79,7 @@ class Label : public View { virtual void OnPaintBackground(gfx::Canvas* canvas); // Set the font. - virtual void SetFont(const gfx::Font& font); + void SetFont(const gfx::Font& font); // Set the label text. void SetText(const std::wstring& text); @@ -180,7 +180,8 @@ class Label : public View { void SizeToFit(int max_width); // Accessibility accessors, overridden from View. - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual AccessibilityTypes::State GetAccessibleState(); // Gets/sets the flag to determine whether the label should be collapsed when // it's hidden (not visible). If this flag is true, the label will return a diff --git a/views/controls/label_unittest.cc b/views/controls/label_unittest.cc index a7b2ac2..6d2ba91 100644 --- a/views/controls/label_unittest.cc +++ b/views/controls/label_unittest.cc @@ -5,7 +5,6 @@ #include "base/i18n/rtl.h" #include "base/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/canvas.h" #include "views/border.h" @@ -160,11 +159,13 @@ TEST(LabelTest, Accessibility) { string16 test_text(ASCIIToUTF16("My special text.")); label.SetText(UTF16ToWideHack(test_text)); - ui::AccessibleViewState state; - label.GetAccessibleState(&state); - EXPECT_EQ(ui::AccessibilityTypes::ROLE_STATICTEXT, state.role); - EXPECT_EQ(test_text, state.name); - EXPECT_TRUE(ui::AccessibilityTypes::STATE_READONLY & state.state); + EXPECT_EQ(AccessibilityTypes::ROLE_STATICTEXT, label.GetAccessibleRole()); + + string16 name; + EXPECT_TRUE(label.GetAccessibleName(&name)); + EXPECT_EQ(test_text, name); + + EXPECT_TRUE(AccessibilityTypes::STATE_READONLY & label.GetAccessibleState()); } TEST(LabelTest, SingleLineSizing) { diff --git a/views/controls/link.cc b/views/controls/link.cc index c6e22f1..de7512b 100644 --- a/views/controls/link.cc +++ b/views/controls/link.cc @@ -9,7 +9,6 @@ #endif #include "base/logging.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/font.h" @@ -149,9 +148,8 @@ bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) { (e.key_code() == ui::VKEY_RETURN); } -void Link::GetAccessibleState(ui::AccessibleViewState* state) { - Label::GetAccessibleState(state); - state->role = ui::AccessibilityTypes::ROLE_LINK; +AccessibilityTypes::Role Link::GetAccessibleRole() { + return AccessibilityTypes::ROLE_LINK; } void Link::SetFont(const gfx::Font& font) { diff --git a/views/controls/link.h b/views/controls/link.h index e616317..4c9cb8f 100644 --- a/views/controls/link.h +++ b/views/controls/link.h @@ -46,16 +46,16 @@ class Link : public Label { const LinkController* GetController(); // Overridden from View: - virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; - virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; + virtual bool OnMousePressed(const MouseEvent& event); + virtual bool OnMouseDragged(const MouseEvent& event); virtual void OnMouseReleased(const MouseEvent& event, - bool canceled) OVERRIDE; - virtual bool OnKeyPressed(const KeyEvent& e) OVERRIDE; - virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e) OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + bool canceled); + virtual bool OnKeyPressed(const KeyEvent& e); + virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e); - // Overridden from Label: - virtual void SetFont(const gfx::Font& font) OVERRIDE; + // Accessibility accessors, overridden from View: + virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual void SetFont(const gfx::Font& font); // Set whether the link is enabled. virtual void SetEnabled(bool f); diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index 075b92e..906bd40 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -760,10 +760,8 @@ void MenuController::SetSelection(MenuItemView* menu_item, // Notify an accessibility focus event on all menu items except for the root. if (menu_item && (MenuDepth(menu_item) != 1 || - menu_item->GetType() != MenuItemView::SUBMENU)) { - menu_item->GetWidget()->NotifyAccessibilityEvent( - menu_item, ui::AccessibilityTypes::EVENT_FOCUS, true); - } + menu_item->GetType() != MenuItemView::SUBMENU)) + menu_item->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS); } // static diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index c729c2e..ed44c3a 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -6,7 +6,6 @@ #include "base/utf_string_conversions.h" #include "grit/app_strings.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/menu_model.h" #include "ui/gfx/canvas.h" @@ -117,23 +116,27 @@ bool MenuItemView::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { return false; } -void MenuItemView::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_MENUITEM; - state->name = GetAccessibleNameForMenuItem(title_, GetAcceleratorText()); +AccessibilityTypes::Role MenuItemView::GetAccessibleRole() { + return AccessibilityTypes::ROLE_MENUITEM; +} + +AccessibilityTypes::State MenuItemView::GetAccessibleState() { + int state = 0; switch (GetType()) { case SUBMENU: - state->state |= ui::AccessibilityTypes::STATE_HASPOPUP; + state |= AccessibilityTypes::STATE_HASPOPUP; break; case CHECKBOX: case RADIO: - state->state |= GetDelegate()->IsItemChecked(GetCommand()) ? - ui::AccessibilityTypes::STATE_CHECKED : 0; + state |= GetDelegate()->IsItemChecked(GetCommand()) ? + AccessibilityTypes::STATE_CHECKED : 0; break; case NORMAL: case SEPARATOR: // No additional accessibility states currently for these menu states. break; } + return state; } // static @@ -317,6 +320,7 @@ SubmenuView* MenuItemView::CreateSubmenu() { void MenuItemView::SetTitle(const std::wstring& title) { title_ = WideToUTF16Hack(title); + SetAccessibleName(GetAccessibleNameForMenuItem(title_, GetAcceleratorText())); pref_size_.SetSize(0, 0); // Triggers preferred size recalculation. } diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h index 89eab3c..5b5e09c 100644 --- a/views/controls/menu/menu_item_view.h +++ b/views/controls/menu/menu_item_view.h @@ -93,9 +93,9 @@ class MenuItemView : public View { virtual ~MenuItemView(); // Overridden from View: - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) - OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); + virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual AccessibilityTypes::State GetAccessibleState(); // Returns the preferred height of menu items. This is only valid when the // menu is about to be shown. diff --git a/views/controls/menu/menu_scroll_view_container.cc b/views/controls/menu/menu_scroll_view_container.cc index 7a644b1..6089838 100644 --- a/views/controls/menu/menu_scroll_view_container.cc +++ b/views/controls/menu/menu_scroll_view_container.cc @@ -10,7 +10,6 @@ #include <Vssym32.h> #endif -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/gfx/canvas_skia.h" #include "ui/gfx/color_utils.h" #include "views/border.h" @@ -163,8 +162,7 @@ class MenuScrollViewContainer::MenuScrollView : public View { // MenuScrollViewContainer ---------------------------------------------------- -MenuScrollViewContainer::MenuScrollViewContainer(SubmenuView* content_view) - : content_view_(content_view) { +MenuScrollViewContainer::MenuScrollViewContainer(SubmenuView* content_view) { scroll_up_button_ = new MenuScrollButton(content_view, true); scroll_down_button_ = new MenuScrollButton(content_view, false); AddChildView(scroll_up_button_); @@ -268,16 +266,14 @@ gfx::Size MenuScrollViewContainer::GetPreferredSize() { return prefsize; } -void MenuScrollViewContainer::GetAccessibleState( - ui::AccessibleViewState* state) { - // Get the name from the submenu view. - content_view_->GetAccessibleState(state); +AccessibilityTypes::Role MenuScrollViewContainer::GetAccessibleRole() { + return AccessibilityTypes::ROLE_MENUBAR; +} - // Now change the role. - state->role = ui::AccessibilityTypes::ROLE_MENUBAR; +AccessibilityTypes::State MenuScrollViewContainer::GetAccessibleState() { // Some AT (like NVDA) will not process focus events on menu item children // unless a parent claims to be focused. - state->state = ui::AccessibilityTypes::STATE_FOCUSED; + return AccessibilityTypes::STATE_FOCUSED; } } // namespace views diff --git a/views/controls/menu/menu_scroll_view_container.h b/views/controls/menu/menu_scroll_view_container.h index 48914af..5472091 100644 --- a/views/controls/menu/menu_scroll_view_container.h +++ b/views/controls/menu/menu_scroll_view_container.h @@ -24,11 +24,12 @@ class MenuScrollViewContainer : public View { View* scroll_up_button() const { return scroll_up_button_; } // View overrides. - virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; - virtual void Layout() OVERRIDE; - virtual void OnBoundsChanged() OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual void OnPaintBackground(gfx::Canvas* canvas); + virtual void Layout(); + virtual void OnBoundsChanged(); + virtual gfx::Size GetPreferredSize(); + virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual AccessibilityTypes::State GetAccessibleState(); private: class MenuScrollView; @@ -40,9 +41,6 @@ class MenuScrollViewContainer : public View { // The scroll view. MenuScrollView* scroll_view_; - // The content view. - SubmenuView* content_view_; - DISALLOW_COPY_AND_ASSIGN(MenuScrollViewContainer); }; diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc index fb78762..7c1f69e 100644 --- a/views/controls/menu/submenu_view.cc +++ b/views/controls/menu/submenu_view.cc @@ -4,14 +4,12 @@ #include "views/controls/menu/submenu_view.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/gfx/canvas.h" #include "views/controls/menu/menu_config.h" #include "views/controls/menu/menu_controller.h" #include "views/controls/menu/menu_host.h" #include "views/controls/menu/menu_scroll_view_container.h" #include "views/widget/root_view.h" -#include "views/widget/widget.h" // Height of the drop indicator. This should be an even number. static const int kDropIndicatorHeight = 2; @@ -127,10 +125,8 @@ void SubmenuView::OnBoundsChanged() { SchedulePaint(); } -void SubmenuView::GetAccessibleState(ui::AccessibleViewState* state) { - // Inherit most of the state from the parent menu item, except the role. - GetMenuItem()->GetAccessibleState(state); - state->role = ui::AccessibilityTypes::ROLE_MENUPOPUP; +AccessibilityTypes::Role SubmenuView::GetAccessibleRole() { + return AccessibilityTypes::ROLE_MENUPOPUP; } void SubmenuView::PaintChildren(gfx::Canvas* canvas) { @@ -237,14 +233,10 @@ void SubmenuView::ShowAt(gfx::NativeWindow parent, if (host_) { host_->ShowMenuHost(do_capture); - GetScrollViewContainer()->GetWidget()->NotifyAccessibilityEvent( - GetScrollViewContainer(), - ui::AccessibilityTypes::EVENT_MENUSTART, - true); - GetWidget()->NotifyAccessibilityEvent( - this, - ui::AccessibilityTypes::EVENT_MENUPOPUPSTART, - true); + GetScrollViewContainer()->NotifyAccessibilityEvent( + AccessibilityTypes::EVENT_MENUSTART); + + NotifyAccessibilityEvent(AccessibilityTypes::EVENT_MENUPOPUPSTART); return; } @@ -255,14 +247,10 @@ void SubmenuView::ShowAt(gfx::NativeWindow parent, ScrollRectToVisible(gfx::Rect(gfx::Point(), gfx::Size(1, 1))); host_->Init(parent, bounds, scroll_view_container_, do_capture); - GetScrollViewContainer()->GetWidget()->NotifyAccessibilityEvent( - GetScrollViewContainer(), - ui::AccessibilityTypes::EVENT_MENUSTART, - true); - GetWidget()->NotifyAccessibilityEvent( - this, - ui::AccessibilityTypes::EVENT_MENUPOPUPSTART, - true); + GetScrollViewContainer()->NotifyAccessibilityEvent( + AccessibilityTypes::EVENT_MENUSTART); + + NotifyAccessibilityEvent(AccessibilityTypes::EVENT_MENUPOPUPSTART); } void SubmenuView::Reposition(const gfx::Rect& bounds) { @@ -272,14 +260,10 @@ void SubmenuView::Reposition(const gfx::Rect& bounds) { void SubmenuView::Close() { if (host_) { - GetWidget()->NotifyAccessibilityEvent( - this, - ui::AccessibilityTypes::EVENT_MENUPOPUPEND, - true); - GetScrollViewContainer()->GetWidget()->NotifyAccessibilityEvent( - GetScrollViewContainer(), - ui::AccessibilityTypes::EVENT_MENUEND, - true); + NotifyAccessibilityEvent(AccessibilityTypes::EVENT_MENUPOPUPEND); + + GetScrollViewContainer()->NotifyAccessibilityEvent( + AccessibilityTypes::EVENT_MENUEND); host_->DestroyMenuHost(); host_ = NULL; @@ -324,6 +308,12 @@ MenuScrollViewContainer* SubmenuView::GetScrollViewContainer() { scroll_view_container_ = new MenuScrollViewContainer(this); // Otherwise MenuHost would delete us. scroll_view_container_->set_parent_owned(false); + + // Use the parent menu item accessible name for the menu view. + string16 accessible_name; + GetMenuItem()->GetAccessibleName(&accessible_name); + scroll_view_container_->SetAccessibleName(accessible_name); + SetAccessibleName(accessible_name); } return scroll_view_container_; } diff --git a/views/controls/menu/submenu_view.h b/views/controls/menu/submenu_view.h index c16c081..cbe2674 100644 --- a/views/controls/menu/submenu_view.h +++ b/views/controls/menu/submenu_view.h @@ -50,15 +50,15 @@ class SubmenuView : public View { // Positions and sizes the child views. This tiles the views vertically, // giving each child the available width. - virtual void Layout() OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual void Layout(); + virtual gfx::Size GetPreferredSize(); // View method. Overridden to schedule a paint. We do this so that when // scrolling occurs, everything is repainted correctly. - virtual void OnBoundsChanged() OVERRIDE; + virtual void OnBoundsChanged(); // Override from View. - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole(); // Painting. void PaintChildren(gfx::Canvas* canvas); @@ -66,16 +66,16 @@ class SubmenuView : public View { // Drag and drop methods. These are forwarded to the MenuController. virtual bool GetDropFormats( int* formats, - std::set<OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; - virtual bool AreDropTypesRequired() OVERRIDE; - virtual bool CanDrop(const OSExchangeData& data) OVERRIDE; - virtual void OnDragEntered(const DropTargetEvent& event) OVERRIDE; - virtual int OnDragUpdated(const DropTargetEvent& event) OVERRIDE; - virtual void OnDragExited() OVERRIDE; - virtual int OnPerformDrop(const DropTargetEvent& event) OVERRIDE; + std::set<OSExchangeData::CustomFormat>* custom_formats); + virtual bool AreDropTypesRequired(); + virtual bool CanDrop(const OSExchangeData& data); + virtual void OnDragEntered(const DropTargetEvent& event); + virtual int OnDragUpdated(const DropTargetEvent& event); + virtual void OnDragExited(); + virtual int OnPerformDrop(const DropTargetEvent& event); // Scrolls on menu item boundaries. - virtual bool OnMouseWheel(const MouseWheelEvent& e) OVERRIDE; + virtual bool OnMouseWheel(const MouseWheelEvent& e); // Returns true if the menu is showing. bool IsShowing(); diff --git a/views/controls/native_control.cc b/views/controls/native_control.cc index 08d6843..34e243e 100644 --- a/views/controls/native_control.cc +++ b/views/controls/native_control.cc @@ -12,7 +12,6 @@ #include "base/logging.h" #include "base/scoped_ptr.h" -#include "ui/base/accessibility/accessibility_types.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/keycodes/keyboard_code_conversion_win.h" #include "ui/base/l10n/l10n_util_win.h" @@ -282,8 +281,7 @@ void NativeControl::OnFocus() { if (container_) { DCHECK(container_->GetControl()); ::SetFocus(container_->GetControl()); - GetWidget()->NotifyAccessibilityEvent( - this, ui::AccessibilityTypes::EVENT_FOCUS, false); + NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS, false); } } diff --git a/views/controls/native_control_gtk.cc b/views/controls/native_control_gtk.cc index 88035c1..a17c4cb 100644 --- a/views/controls/native_control_gtk.cc +++ b/views/controls/native_control_gtk.cc @@ -7,9 +7,7 @@ #include <gtk/gtk.h> #include "base/logging.h" -#include "ui/base/accessibility/accessibility_types.h" #include "views/focus/focus_manager.h" -#include "views/widget/widget.h" namespace views { @@ -68,8 +66,8 @@ void NativeControlGtk::VisibilityChanged(View* starting_from, bool is_visible) { void NativeControlGtk::OnFocus() { DCHECK(native_view()); gtk_widget_grab_focus(native_view()); - GetWidget()->NotifyAccessibilityEvent( - parent(), ui::AccessibilityTypes::EVENT_FOCUS, true); + + parent()->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS); } void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) { diff --git a/views/controls/native_control_win.cc b/views/controls/native_control_win.cc index 13a8c2b..7e7312b 100644 --- a/views/controls/native_control_win.cc +++ b/views/controls/native_control_win.cc @@ -7,12 +7,10 @@ #include <windowsx.h> #include "base/logging.h" -#include "ui/base/accessibility/accessibility_types.h" #include "ui/base/l10n/l10n_util_win.h" #include "ui/base/view_prop.h" #include "ui/base/win/hwnd_util.h" #include "views/focus/focus_manager.h" -#include "views/widget/widget.h" using ui::ViewProp; @@ -114,8 +112,8 @@ void NativeControlWin::OnFocus() { parent_view->HasFocus(); // Send the accessibility focus notification. - parent_view->GetWidget()->NotifyAccessibilityEvent( - parent_view, ui::AccessibilityTypes::EVENT_FOCUS, send_native_event); + parent_view->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS, + send_native_event); } //////////////////////////////////////////////////////////////////////////////// diff --git a/views/controls/progress_bar.cc b/views/controls/progress_bar.cc index e460e27..a6aabb1 100644 --- a/views/controls/progress_bar.cc +++ b/views/controls/progress_bar.cc @@ -11,7 +11,6 @@ #include "base/utf_string_conversions.h" #include "third_party/skia/include/effects/SkGradientShader.h" #include "third_party/skia/include/effects/SkBlurMaskFilter.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/gfx/canvas_skia.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/font.h" @@ -311,9 +310,12 @@ void ProgressBar::SetEnabled(bool enabled) { // TODO(denisromanov): Need to switch progress bar color here? } -void ProgressBar::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_PROGRESSBAR; - state->state = ui::AccessibilityTypes::STATE_READONLY; +AccessibilityTypes::Role ProgressBar::GetAccessibleRole() { + return AccessibilityTypes::ROLE_PROGRESSBAR; +} + +AccessibilityTypes::State ProgressBar::GetAccessibleState() { + return AccessibilityTypes::STATE_READONLY; } } // namespace views diff --git a/views/controls/progress_bar.h b/views/controls/progress_bar.h index 4366519..b2f1202 100644 --- a/views/controls/progress_bar.h +++ b/views/controls/progress_bar.h @@ -52,14 +52,14 @@ class ProgressBar : public View { virtual void SetTooltipText(const std::wstring& tooltip_text); // Gets the tooltip text if has been specified with SetTooltipText(). - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) - OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); // Sets the enabled state. - virtual void SetEnabled(bool enabled) OVERRIDE; + virtual void SetEnabled(bool enabled); // Accessibility accessors, overridden from View. - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual AccessibilityTypes::State GetAccessibleState(); // Maximum value of progress. static const int kMaxProgress; diff --git a/views/controls/progress_bar_unittest.cc b/views/controls/progress_bar_unittest.cc index c7fc4df..55acfd4 100644 --- a/views/controls/progress_bar_unittest.cc +++ b/views/controls/progress_bar_unittest.cc @@ -5,7 +5,6 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "views/controls/progress_bar.h" namespace views { @@ -49,11 +48,17 @@ TEST(ProgressBarTest, Accessibility) { ProgressBar bar; bar.SetProgress(62); - ui::AccessibleViewState state; - bar.GetAccessibleState(&state); - EXPECT_EQ(ui::AccessibilityTypes::ROLE_PROGRESSBAR, state.role); - EXPECT_EQ(string16(), state.name); - EXPECT_TRUE(ui::AccessibilityTypes::STATE_READONLY & state.state); + EXPECT_EQ(AccessibilityTypes::ROLE_PROGRESSBAR, bar.GetAccessibleRole()); + + string16 name; + EXPECT_FALSE(bar.GetAccessibleName(&name)); + EXPECT_EQ(string16(), name); + string16 accessible_name = ASCIIToUTF16("My progress bar"); + bar.SetAccessibleName(accessible_name); + EXPECT_TRUE(bar.GetAccessibleName(&name)); + EXPECT_EQ(accessible_name, name); + + EXPECT_TRUE(AccessibilityTypes::STATE_READONLY & bar.GetAccessibleState()); } } // namespace views diff --git a/views/controls/resize_area.cc b/views/controls/resize_area.cc index 0769cf9..b3897bb 100644 --- a/views/controls/resize_area.cc +++ b/views/controls/resize_area.cc @@ -5,7 +5,6 @@ #include "views/controls/resize_area.h" #include "base/logging.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/resource/resource_bundle.h" #if defined(OS_LINUX) @@ -75,8 +74,8 @@ void ResizeArea::OnMouseReleased(const views::MouseEvent& event, ReportResizeAmount(canceled ? initial_position_ : event.x(), true); } -void ResizeArea::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_SEPARATOR; +AccessibilityTypes::Role ResizeArea::GetAccessibleRole() { + return AccessibilityTypes::ROLE_SEPARATOR; } void ResizeArea::ReportResizeAmount(int resize_amount, bool last_update) { diff --git a/views/controls/resize_area.h b/views/controls/resize_area.h index cf9bea7..9adb60c 100644 --- a/views/controls/resize_area.h +++ b/views/controls/resize_area.h @@ -41,14 +41,13 @@ class ResizeArea : public View { virtual ~ResizeArea(); // Overridden from views::View: - virtual std::string GetClassName() const OVERRIDE; + virtual std::string GetClassName() const; virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type, - const gfx::Point& p) OVERRIDE; - virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; - virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; - virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled) - OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + const gfx::Point& p); + virtual bool OnMousePressed(const views::MouseEvent& event); + virtual bool OnMouseDragged(const views::MouseEvent& event); + virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); + virtual AccessibilityTypes::Role GetAccessibleRole(); private: // Report the amount the user resized by to the delegate, accounting for diff --git a/views/controls/scrollbar/scroll_bar.cc b/views/controls/scrollbar/scroll_bar.cc index 880a42a..94360bb 100644 --- a/views/controls/scrollbar/scroll_bar.cc +++ b/views/controls/scrollbar/scroll_bar.cc @@ -5,7 +5,6 @@ #include "views/controls/scrollbar/scroll_bar.h" #include "base/logging.h" -#include "ui/base/accessibility/accessible_view_state.h" namespace views { @@ -23,8 +22,8 @@ ScrollBar::ScrollBar(bool is_horiz) : is_horiz_(is_horiz), ScrollBar::~ScrollBar() { } -void ScrollBar::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_SCROLLBAR; +AccessibilityTypes::Role ScrollBar::GetAccessibleRole() { + return AccessibilityTypes::ROLE_SCROLLBAR; } bool ScrollBar::IsHorizontal() const { diff --git a/views/controls/scrollbar/scroll_bar.h b/views/controls/scrollbar/scroll_bar.h index d7f187b..faed881 100644 --- a/views/controls/scrollbar/scroll_bar.h +++ b/views/controls/scrollbar/scroll_bar.h @@ -60,7 +60,7 @@ class ScrollBar : public View { virtual ~ScrollBar(); // Overridden from View: - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole(); // Return whether this scrollbar is horizontal bool IsHorizontal() const; diff --git a/views/controls/separator.cc b/views/controls/separator.cc index bc1f522..1a3ca70 100644 --- a/views/controls/separator.cc +++ b/views/controls/separator.cc @@ -5,7 +5,6 @@ #include "views/controls/separator.h" #include "base/logging.h" -#include "ui/base/accessibility/accessible_view_state.h" #if defined(OS_LINUX) #include "views/controls/native_control_gtk.h" #elif defined(OS_WIN) @@ -93,8 +92,8 @@ std::string Separator::GetClassName() const { return kViewClassName; } -void Separator::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_SEPARATOR; +AccessibilityTypes::Role Separator::GetAccessibleRole() { + return AccessibilityTypes::ROLE_SEPARATOR; } //////////////////////////////////////////////////////////////////////////////// diff --git a/views/controls/separator.h b/views/controls/separator.h index 6c4d9c4..186d84f 100644 --- a/views/controls/separator.h +++ b/views/controls/separator.h @@ -24,15 +24,14 @@ class Separator : public View { virtual ~Separator(); // Overridden from View: - virtual void Layout() OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual void Layout(); + virtual gfx::Size GetPreferredSize(); + virtual AccessibilityTypes::Role GetAccessibleRole(); protected: - // Overridden from View: virtual void ViewHierarchyChanged(bool is_add, View* parent, - View* child) OVERRIDE; - virtual std::string GetClassName() const OVERRIDE; + View* child); + virtual std::string GetClassName() const; private: void CreateNativeWrapper(); diff --git a/views/controls/single_split_view.cc b/views/controls/single_split_view.cc index 96302f7..2b076d6 100644 --- a/views/controls/single_split_view.cc +++ b/views/controls/single_split_view.cc @@ -9,7 +9,6 @@ #endif #include "skia/ext/skia_utils_win.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/gfx/canvas.h" #include "views/background.h" @@ -66,9 +65,8 @@ void SingleSplitView::Layout() { View::Layout(); } -void SingleSplitView::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_GROUPING; - state->name = accessible_name_; +AccessibilityTypes::Role SingleSplitView::GetAccessibleRole() { + return AccessibilityTypes::ROLE_GROUPING; } gfx::Size SingleSplitView::GetPreferredSize() { @@ -152,10 +150,6 @@ void SingleSplitView::CalculateChildrenBounds( } } -void SingleSplitView::SetAccessibleName(const string16& name) { - accessible_name_ = name; -} - bool SingleSplitView::OnMousePressed(const MouseEvent& event) { if (!IsPointInDivider(event.location())) return false; diff --git a/views/controls/single_split_view.h b/views/controls/single_split_view.h index 38e7bbb..dc69c67 100644 --- a/views/controls/single_split_view.h +++ b/views/controls/single_split_view.h @@ -42,7 +42,7 @@ class SingleSplitView : public views::View { virtual void OnBoundsChanged(); virtual void Layout(); - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole(); // SingleSplitView's preferred size is the sum of the preferred widths // and the max of the heights. @@ -75,8 +75,6 @@ class SingleSplitView : public views::View { gfx::Rect* leading_bounds, gfx::Rect* trailing_bounds) const; - void SetAccessibleName(const string16& name); - protected: virtual bool OnMousePressed(const MouseEvent& event); virtual bool OnMouseDragged(const MouseEvent& event); @@ -134,9 +132,6 @@ class SingleSplitView : public views::View { // Observer to notify about user initiated handle movements. Not own by us. Observer* observer_; - // The accessible name of this view. - string16 accessible_name_; - DISALLOW_COPY_AND_ASSIGN(SingleSplitView); }; diff --git a/views/controls/tabbed_pane/tabbed_pane.cc b/views/controls/tabbed_pane/tabbed_pane.cc index 1091407..eb9f971 100644 --- a/views/controls/tabbed_pane/tabbed_pane.cc +++ b/views/controls/tabbed_pane/tabbed_pane.cc @@ -5,13 +5,11 @@ #include "views/controls/tabbed_pane/tabbed_pane.h" #include "base/logging.h" -#include "ui/base/accessibility/accessible_view_state.h" // TODO(avi): remove when not needed #include "base/utf_string_conversions.h" #include "ui/base/keycodes/keyboard_codes.h" #include "views/controls/native/native_view_host.h" #include "views/controls/tabbed_pane/native_tabbed_pane_wrapper.h" -#include "views/widget/widget.h" namespace views { @@ -40,6 +38,7 @@ void TabbedPane::AddTabAtIndex(int index, bool select_if_first_tab) { native_tabbed_pane_->AddTabAtIndex(index, title, contents, select_if_first_tab); + contents->SetAccessibleName(WideToUTF16Hack(title)); PreferredSizeChanged(); } @@ -61,10 +60,6 @@ void TabbedPane::SelectTabAt(int index) { native_tabbed_pane_->SelectTabAt(index); } -void TabbedPane::SetAccessibleName(const string16& name) { - accessible_name_ = name; -} - int TabbedPane::GetTabCount() { return native_tabbed_pane_->GetTabCount(); } @@ -123,10 +118,8 @@ void TabbedPane::OnFocus() { native_tabbed_pane_->SetFocus(); View* selected_tab = GetSelectedTab(); - if (selected_tab) { - selected_tab->GetWidget()->NotifyAccessibilityEvent( - selected_tab, ui::AccessibilityTypes::EVENT_FOCUS, true); - } + if (selected_tab) + selected_tab->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS); } else View::OnFocus(); // Will focus the RootView window (so we still get @@ -138,9 +131,8 @@ void TabbedPane::OnPaintFocusBorder(gfx::Canvas* canvas) { View::OnPaintFocusBorder(canvas); } -void TabbedPane::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST; - state->name = accessible_name_; +AccessibilityTypes::Role TabbedPane::GetAccessibleRole() { + return AccessibilityTypes::ROLE_PAGETABLIST; } gfx::Size TabbedPane::GetPreferredSize() { diff --git a/views/controls/tabbed_pane/tabbed_pane.h b/views/controls/tabbed_pane/tabbed_pane.h index a968d36..4fdb727 100644 --- a/views/controls/tabbed_pane/tabbed_pane.h +++ b/views/controls/tabbed_pane/tabbed_pane.h @@ -14,6 +14,7 @@ class NativeTabbedPaneWrapper; // The TabbedPane class is a view that shows tabs. When the user clicks on a // tab, the associated view is displayed. + class TabbedPane : public View { public: TabbedPane(); @@ -62,20 +63,16 @@ class TabbedPane : public View { Listener* listener() const { return listener_; } - void SetAccessibleName(const string16& name); - // View overrides: - virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child) - OVERRIDE; + virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); // Handles Ctrl+Tab and Ctrl+Shift+Tab navigation of pages. - virtual bool AcceleratorPressed(const views::Accelerator& accelerator) - OVERRIDE; - virtual std::string GetClassName() const OVERRIDE; - virtual void Layout() OVERRIDE; - virtual void OnFocus() OVERRIDE; - virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual bool AcceleratorPressed(const views::Accelerator& accelerator); + virtual std::string GetClassName() const; + virtual void Layout(); + virtual void OnFocus(); + virtual void OnPaintFocusBorder(gfx::Canvas* canvas); + virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual gfx::Size GetPreferredSize(); NativeTabbedPaneWrapper* native_wrapper() const { return native_tabbed_pane_; @@ -99,9 +96,6 @@ class TabbedPane : public View { // The listener we notify about tab selection changes. Listener* listener_; - // The accessible name of this view. - string16 accessible_name_; - DISALLOW_COPY_AND_ASSIGN(TabbedPane); }; diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index 8a735d0..2047d40 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -12,7 +12,6 @@ #include "base/win/windows_version.h" #include "grit/app_strings.h" #include "skia/ext/skia_utils_win.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/scoped_clipboard_writer.h" #include "ui/base/keycodes/keyboard_codes.h" @@ -442,11 +441,10 @@ void NativeTextfieldWin::InitializeAccessibilityInfo() { // We expect it to be a Label preceeding this view (if it exists). string16 name; View* label_view = parent->GetChildViewAt(label_index); - if (label_view->GetClassName() == Label::kViewClassName) { - ui::AccessibleViewState state; - label_view->GetAccessibleState(&state); + if (label_view->GetClassName() == Label::kViewClassName && + label_view->GetAccessibleName(&name)) { hr = pAccPropServices->SetHwndPropStr(m_hWnd, OBJID_CLIENT, - CHILDID_SELF, PROPID_ACC_NAME, state.name.c_str()); + CHILDID_SELF, PROPID_ACC_NAME, name.c_str()); } } } diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc index 4366a0c..2a72712 100644 --- a/views/controls/textfield/textfield.cc +++ b/views/controls/textfield/textfield.cc @@ -12,7 +12,6 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/gfx/insets.h" #include "views/controls/native/native_view_host.h" @@ -281,10 +280,6 @@ size_t Textfield::GetCursorPosition() const { return native_wrapper_ ? native_wrapper_->GetCursorPosition() : 0; } -void Textfield::SetAccessibleName(const string16& name) { - accessible_name_ = name; -} - //////////////////////////////////////////////////////////////////////////////// // Textfield, View overrides: @@ -365,14 +360,23 @@ void Textfield::OnBlur() { native_wrapper_->HandleBlur(); } -void Textfield::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_TEXT; - state->name = accessible_name_; +AccessibilityTypes::Role Textfield::GetAccessibleRole() { + return AccessibilityTypes::ROLE_TEXT; +} + +AccessibilityTypes::State Textfield::GetAccessibleState() { + int state = 0; if (read_only()) - state->state |= ui::AccessibilityTypes::STATE_READONLY; + state |= AccessibilityTypes::STATE_READONLY; if (IsPassword()) - state->state |= ui::AccessibilityTypes::STATE_PROTECTED; - state->value = text_; + state |= AccessibilityTypes::STATE_PROTECTED; + return state; +} + +string16 Textfield::GetAccessibleValue() { + if (!text_.empty()) + return text_; + return string16(); } void Textfield::SetEnabled(bool enabled) { diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h index 47285f7..c8484d5 100644 --- a/views/controls/textfield/textfield.h +++ b/views/controls/textfield/textfield.h @@ -247,9 +247,6 @@ class Textfield : public View { // only and has to be called after the wrapper is created. size_t GetCursorPosition() const; - // Set the accessible name of the text field. - void SetAccessibleName(const string16& name); - #ifdef UNIT_TEST gfx::NativeView GetTestingHandle() const { return native_wrapper_ ? native_wrapper_->GetTestingHandle() : NULL; @@ -272,7 +269,9 @@ class Textfield : public View { virtual bool OnKeyReleased(const views::KeyEvent& e) OVERRIDE; virtual void OnFocus() OVERRIDE; virtual void OnBlur() OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual AccessibilityTypes::State GetAccessibleState() OVERRIDE; + virtual string16 GetAccessibleValue() OVERRIDE; protected: virtual void ViewHierarchyChanged(bool is_add, View* parent, @@ -340,9 +339,6 @@ class Textfield : public View { // Text to display when empty. string16 text_to_display_when_empty_; - // The accessible name of the text field. - string16 accessible_name_; - DISALLOW_COPY_AND_ASSIGN(Textfield); }; diff --git a/views/controls/tree/tree_view.cc b/views/controls/tree/tree_view.cc index 4e8a53d..3f6b8bf 100644 --- a/views/controls/tree/tree_view.cc +++ b/views/controls/tree/tree_view.cc @@ -11,7 +11,6 @@ #include "base/stl_util-inl.h" #include "base/win/win_util.h" #include "grit/app_resources.h" -#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/keycodes/keyboard_code_conversion_win.h" #include "ui/base/resource/resource_bundle.h" @@ -61,9 +60,12 @@ TreeView::~TreeView() { ImageList_Destroy(image_list_); } -void TreeView::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_OUTLINE; - state->state = ui::AccessibilityTypes::STATE_READONLY; +AccessibilityTypes::Role TreeView::GetAccessibleRole() { + return AccessibilityTypes::ROLE_OUTLINE; +} + +AccessibilityTypes::State TreeView::GetAccessibleState() { + return AccessibilityTypes::STATE_READONLY; } void TreeView::SetModel(TreeModel* model) { diff --git a/views/controls/tree/tree_view.h b/views/controls/tree/tree_view.h index a542e85..d4d0771 100644 --- a/views/controls/tree/tree_view.h +++ b/views/controls/tree/tree_view.h @@ -79,7 +79,8 @@ class TreeView : public NativeControl, ui::TreeModelObserver { } // Overridden from View: - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual AccessibilityTypes::State GetAccessibleState(); // Edits the specified node. This cancels the current edit and expands // all parents of node. |