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

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: Fix header files 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
Index: ui/views/controls/slider.cc
diff --git a/ui/views/controls/slider.cc b/ui/views/controls/slider.cc
index 5e3a38fce6ecff16a91a0a6ba69c28b6d361f835..139a0e1e9faa6695f7a893f1a149bab6ca060518 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,12 @@ void Slider::SetValueInternal(float value, SliderChangeReason reason) {
} else {
SchedulePaint();
}
+ GetWidget()->NotifyAccessibilityEvent(
sadrul 2012/03/12 08:40:47 A NULL check here for GetWidget(), in case the val
dmazzoni 2012/03/12 08:44:11 Done.
+ this, ui::AccessibilityTypes::EVENT_VALUE_CHANGED, true);
+}
+
+void Slider::SetAccessibleName(const string16& name) {
+ accessible_name_ = name;
}
gfx::Size Slider::GetPreferredSize() {
@@ -147,4 +157,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
« chrome/browser/accessibility/accessibility_extension_api.cc ('K') | « ui/views/controls/slider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698