Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(792)

Unified Diff: ui/views/controls/slider.cc

Issue 9665026: Make views Slider accessible on Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change value to stringValue Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/slider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/slider.cc
diff --git a/ui/views/controls/slider.cc b/ui/views/controls/slider.cc
index 5e3a38fce6ecff16a91a0a6ba69c28b6d361f835..5388b5a9d8ea7b91fa6cd1d667a36d30828fbf9d 100644
--- a/ui/views/controls/slider.cc
+++ b/ui/views/controls/slider.cc
@@ -6,13 +6,17 @@
#include "base/logging.h"
#include "base/message_loop.h"
+#include "base/stringprintf.h"
+#include "base/utf_string_conversions.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkPaint.h"
+#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/base/animation/slide_animation.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
+#include "ui/views/widget/widget.h"
namespace {
const int kSlideValueChangeDurationMS = 150;
@@ -62,6 +66,14 @@ void Slider::SetValueInternal(float value, SliderChangeReason reason) {
} else {
SchedulePaint();
}
+ if (GetWidget()) {
+ GetWidget()->NotifyAccessibilityEvent(
+ this, ui::AccessibilityTypes::EVENT_VALUE_CHANGED, true);
+ }
+}
+
+void Slider::SetAccessibleName(const string16& name) {
+ accessible_name_ = name;
}
gfx::Size Slider::GetPreferredSize() {
@@ -147,4 +159,11 @@ void Slider::AnimationProgressed(const ui::Animation* animation) {
SchedulePaint();
}
+void Slider::GetAccessibleState(ui::AccessibleViewState* state) {
+ state->role = ui::AccessibilityTypes::ROLE_SLIDER;
+ state->name = accessible_name_;
+ state->value = UTF8ToUTF16(
+ base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5)));
+}
+
} // namespace views
« no previous file with comments | « ui/views/controls/slider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698