diff options
Diffstat (limited to 'views/controls/button')
-rw-r--r-- | views/controls/button/button.cc | 20 | ||||
-rw-r--r-- | views/controls/button/button.h | 7 | ||||
-rw-r--r-- | views/controls/button/button_dropdown.cc | 16 | ||||
-rw-r--r-- | views/controls/button/button_dropdown.h | 4 | ||||
-rw-r--r-- | views/controls/button/checkbox.cc | 11 | ||||
-rw-r--r-- | views/controls/button/checkbox.h | 3 | ||||
-rw-r--r-- | views/controls/button/custom_button.cc | 19 | ||||
-rw-r--r-- | views/controls/button/custom_button.h | 2 | ||||
-rw-r--r-- | views/controls/button/menu_button.cc | 16 | ||||
-rw-r--r-- | views/controls/button/menu_button.h | 4 | ||||
-rw-r--r-- | views/controls/button/native_button_win.cc | 26 | ||||
-rw-r--r-- | views/controls/button/radio_button.cc | 6 | ||||
-rw-r--r-- | views/controls/button/radio_button.h | 14 |
13 files changed, 74 insertions, 74 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(); |