diff options
-rw-r--r-- | views/accessibility/accessibility_types.h | 1 | ||||
-rw-r--r-- | views/accessibility/view_accessibility.cc | 2 | ||||
-rw-r--r-- | views/controls/button/checkbox.cc | 14 | ||||
-rw-r--r-- | views/controls/button/checkbox.h | 10 | ||||
-rw-r--r-- | views/controls/image_view.cc | 8 | ||||
-rw-r--r-- | views/controls/label.cc | 7 |
6 files changed, 32 insertions, 10 deletions
diff --git a/views/accessibility/accessibility_types.h b/views/accessibility/accessibility_types.h index fc890bb..e3bdfae 100644 --- a/views/accessibility/accessibility_types.h +++ b/views/accessibility/accessibility_types.h @@ -23,6 +23,7 @@ class AccessibilityTypes { ROLE_APPLICATION, ROLE_BUTTONDROPDOWN, ROLE_BUTTONMENU, + ROLE_CHECKBUTTON, ROLE_CLIENT, ROLE_GRAPHIC, ROLE_GROUPING, diff --git a/views/accessibility/view_accessibility.cc b/views/accessibility/view_accessibility.cc index 952f6d4..f6c83eb 100644 --- a/views/accessibility/view_accessibility.cc +++ b/views/accessibility/view_accessibility.cc @@ -674,6 +674,8 @@ long ViewAccessibility::MSAARole(AccessibilityTypes::Role role) { return ROLE_SYSTEM_BUTTONDROPDOWN; case AccessibilityTypes::ROLE_BUTTONMENU: return ROLE_SYSTEM_BUTTONMENU; + case AccessibilityTypes::ROLE_CHECKBUTTON: + return ROLE_SYSTEM_CHECKBUTTON; case AccessibilityTypes::ROLE_GRAPHIC: return ROLE_SYSTEM_GRAPHIC; case AccessibilityTypes::ROLE_GROUPING: diff --git a/views/controls/button/checkbox.cc b/views/controls/button/checkbox.cc index f4594be..1dcb80a 100644 --- a/views/controls/button/checkbox.cc +++ b/views/controls/button/checkbox.cc @@ -5,6 +5,7 @@ #include "views/controls/button/checkbox.h" #include "app/gfx/canvas.h" +#include "base/logging.h" #include "views/controls/label.h" namespace views { @@ -152,6 +153,19 @@ void Checkbox::WillLoseFocus() { label_->set_paint_as_focused(false); } +bool Checkbox::GetAccessibleRole(AccessibilityTypes::Role* role) { + DCHECK(role); + + *role = AccessibilityTypes::ROLE_CHECKBUTTON; + return true; +} + +bool Checkbox::GetAccessibleName(std::wstring* name) { + DCHECK(name); + *name = label_->GetText(); + return !name->empty(); +} + std::string Checkbox::GetClassName() const { return kViewClassName; } diff --git a/views/controls/button/checkbox.h b/views/controls/button/checkbox.h index 8274070..dc58117 100644 --- a/views/controls/button/checkbox.h +++ b/views/controls/button/checkbox.h @@ -5,6 +5,8 @@ #ifndef VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ #define VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ +#include <string> + #include "views/controls/button/native_button.h" namespace views { @@ -18,7 +20,7 @@ class Checkbox : public NativeButton { static const char kViewClassName[]; Checkbox(); - Checkbox(const std::wstring& label); + explicit Checkbox(const std::wstring& label); virtual ~Checkbox(); // Sets a listener for this checkbox. Checkboxes aren't required to have them @@ -55,6 +57,10 @@ class Checkbox : public NativeButton { virtual void WillGainFocus(); virtual void WillLoseFocus(); + // Accessibility accessors, overridden from View. + virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); + virtual bool GetAccessibleName(std::wstring* name); + // Overridden from NativeButton: virtual void SetLabel(const std::wstring& label); @@ -85,4 +91,4 @@ class Checkbox : public NativeButton { } // namespace views -#endif // #ifndef VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ +#endif // VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ diff --git a/views/controls/image_view.cc b/views/controls/image_view.cc index 2a7e18d..14a6219 100644 --- a/views/controls/image_view.cc +++ b/views/controls/image_view.cc @@ -81,7 +81,7 @@ void ImageView::ComputeImageOrigin(int image_width, int image_height, gfx::Insets insets = GetInsets(); - switch(actual_horiz_alignment) { + switch (actual_horiz_alignment) { case LEADING: *x = insets.left(); break; @@ -137,11 +137,9 @@ void ImageView::Paint(gfx::Canvas* canvas) { } bool ImageView::GetAccessibleName(std::wstring* name) { - if (!name || tooltip_text_.empty()) - return false; - + DCHECK(name); *name = tooltip_text_; - return true; + return !name->empty(); } bool ImageView::GetAccessibleRole(AccessibilityTypes::Role* role) { diff --git a/views/controls/label.cc b/views/controls/label.cc index f6f25d1..4610cdb 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -105,14 +105,14 @@ int Label::GetBaseline() { int Label::ComputeMultiLineFlags() { int flags = gfx::Canvas::MULTI_LINE; - #if !defined(OS_WIN) +#if !defined(OS_WIN) // Don't ellide multiline labels on Linux. // Todo(davemoore): Do we depend on elliding multiline text? // Pango insists on limiting the number of lines to one if text is // ellided. You can get around this if you can pass a maximum height // but we don't currently have that data when we call the pango code. flags |= gfx::Canvas::NO_ELLIPSIS; - #endif +#endif if (allow_character_break_) flags |= gfx::Canvas::CHARACTER_BREAK; switch (horiz_alignment_) { @@ -498,8 +498,9 @@ bool Label::GetAccessibleRole(AccessibilityTypes::Role* role) { } bool Label::GetAccessibleName(std::wstring* name) { + DCHECK(name); *name = GetText(); - return true; + return !name->empty(); } bool Label::GetAccessibleState(AccessibilityTypes::State* state) { |