summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
authorctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-10 18:34:03 +0000
committerctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-10 18:34:03 +0000
commit4abaee203b9d0dfe8c2fb84682a564fe995b3c79 (patch)
tree7cc0237dfa00cbc87e6d769449c0e073cdc64a62 /views/controls
parent6e64343accab0d5b5436645e40a36f5ff20d17ec (diff)
downloadchromium_src-4abaee203b9d0dfe8c2fb84682a564fe995b3c79.zip
chromium_src-4abaee203b9d0dfe8c2fb84682a564fe995b3c79.tar.gz
chromium_src-4abaee203b9d0dfe8c2fb84682a564fe995b3c79.tar.bz2
Landing tfarina CL.
Original patch by thiago.farina@gmail.com See original review at: http://codereview.chromium.org/668225/show BUG=9616 TEST=opens AccExplorer2, opens clear browsing data, select the a checkbox+label with the AccExplorer2 tool, see if the role for this control is checkbox. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41178 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/button/checkbox.cc14
-rw-r--r--views/controls/button/checkbox.h10
-rw-r--r--views/controls/image_view.cc8
-rw-r--r--views/controls/label.cc7
4 files changed, 29 insertions, 10 deletions
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) {