OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/controls/button/toggle_button.h" | 5 #include "ui/views/controls/button/toggle_button.h" |
6 | 6 |
7 #include "cc/paint/paint_flags.h" | 7 #include "cc/paint/paint_flags.h" |
8 #include "third_party/skia/include/core/SkDrawLooper.h" | 8 #include "third_party/skia/include/core/SkDrawLooper.h" |
9 #include "ui/accessibility/ax_node_data.h" | 9 #include "ui/accessibility/ax_node_data.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 226 } |
227 | 227 |
228 void ToggleButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 228 void ToggleButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
229 SchedulePaint(); | 229 SchedulePaint(); |
230 } | 230 } |
231 | 231 |
232 void ToggleButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 232 void ToggleButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
233 CustomButton::GetAccessibleNodeData(node_data); | 233 CustomButton::GetAccessibleNodeData(node_data); |
234 | 234 |
235 node_data->role = ui::AX_ROLE_SWITCH; | 235 node_data->role = ui::AX_ROLE_SWITCH; |
236 if (is_on_) | 236 const ui::AXCheckedState checked_state = |
237 node_data->AddStateFlag(ui::AX_STATE_CHECKED); | 237 is_on_ ? ui::AX_CHECKED_STATE_TRUE : ui::AX_CHECKED_STATE_FALSE; |
| 238 node_data->AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, checked_state); |
238 } | 239 } |
239 | 240 |
240 void ToggleButton::NotifyClick(const ui::Event& event) { | 241 void ToggleButton::NotifyClick(const ui::Event& event) { |
241 SetIsOn(!is_on(), true); | 242 SetIsOn(!is_on(), true); |
242 CustomButton::NotifyClick(event); | 243 CustomButton::NotifyClick(event); |
243 } | 244 } |
244 | 245 |
245 void ToggleButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 246 void ToggleButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
246 thumb_view_->AddInkDropLayer(ink_drop_layer); | 247 thumb_view_->AddInkDropLayer(ink_drop_layer); |
247 } | 248 } |
(...skipping 24 matching lines...) Expand all Loading... |
272 // TODO(varkha, estade): The thumb is using its own view. Investigate if | 273 // TODO(varkha, estade): The thumb is using its own view. Investigate if |
273 // repainting in every animation step to update colors could be avoided. | 274 // repainting in every animation step to update colors could be avoided. |
274 UpdateThumb(); | 275 UpdateThumb(); |
275 SchedulePaint(); | 276 SchedulePaint(); |
276 return; | 277 return; |
277 } | 278 } |
278 CustomButton::AnimationProgressed(animation); | 279 CustomButton::AnimationProgressed(animation); |
279 } | 280 } |
280 | 281 |
281 } // namespace views | 282 } // namespace views |
OLD | NEW |