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

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

Issue 2162083004: Make ToggleImageButton into an accessible toggle button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rework toggle logic. Created 4 years, 5 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/button/image_button.cc
diff --git a/ui/views/controls/button/image_button.cc b/ui/views/controls/button/image_button.cc
index a9fda37f5b49ed642fbf086df347f75870b83ff8..483d971bbea836c6fceacbee82433f7dcf3704a6 100644
--- a/ui/views/controls/button/image_button.cc
+++ b/ui/views/controls/button/image_button.cc
@@ -215,7 +215,7 @@ void ToggleImageButton::SetToggled(bool toggled) {
toggled_ = toggled;
SchedulePaint();
- NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true);
+ NotifyAccessibilityEvent(ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED, true);
}
void ToggleImageButton::SetToggledImage(ButtonState image_state,
@@ -270,6 +270,15 @@ bool ToggleImageButton::GetTooltipText(const gfx::Point& p,
void ToggleImageButton::GetAccessibleState(ui::AXViewState* state) {
ImageButton::GetAccessibleState(state);
GetTooltipText(gfx::Point(), &state->name);
+
+ // Use the visual pressed image as a cue for making this control into an
dmazzoni 2016/07/22 18:06:29 wrap? looks like more than 80 chars in Rietveld
David Tseng 2016/07/22 22:49:26 Hmm...strange, it's 73 characters.
+ // accessible toggle button.
+ if ((toggled_ && !images_[ButtonState::STATE_NORMAL].isNull()) ||
+ (!toggled_ && !alternate_images_[ButtonState::STATE_NORMAL].isNull())) {
+ state->role = ui::AX_ROLE_TOGGLE_BUTTON;
+ if (toggled_)
+ state->AddStateFlag(ui::AX_STATE_PRESSED);
+ }
}
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698