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

Unified Diff: ui/views/controls/button/toggle_button.cc

Issue 2477983003: Improve a11y state for ToggleButton. (Closed)
Patch Set: use switch role, rebase on top of dmazzoni changes Created 4 years, 1 month 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/button/toggle_button.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/button/toggle_button.cc
diff --git a/ui/views/controls/button/toggle_button.cc b/ui/views/controls/button/toggle_button.cc
index b872f40b256bcbf573109a450c3ae6dafd0fc6d4..ca6915d5d2ea8b589522d25a94c0e4f458e1cacd 100644
--- a/ui/views/controls/button/toggle_button.cc
+++ b/ui/views/controls/button/toggle_button.cc
@@ -6,6 +6,7 @@
#include "third_party/skia/include/core/SkDrawLooper.h"
#include "third_party/skia/include/core/SkPaint.h"
+#include "ui/accessibility/ax_node_data.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
@@ -201,6 +202,14 @@ void ToggleButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
SchedulePaint();
}
+void ToggleButton::GetAccessibleNodeData(ui::AXNodeData* node_data) {
+ CustomButton::GetAccessibleNodeData(node_data);
+
+ node_data->role = ui::AX_ROLE_SWITCH;
+ if (is_on_)
+ node_data->AddStateFlag(ui::AX_STATE_CHECKED);
+}
+
void ToggleButton::AddInkDropLayer(ui::Layer* ink_drop_layer) {
thumb_view_->AddInkDropLayer(ink_drop_layer);
}
« no previous file with comments | « ui/views/controls/button/toggle_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698