Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/accessibility/native_view_accessibility.h" | 5 #include "ui/views/accessibility/native_view_accessibility.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "ui/accessibility/ax_view_state.h" | 9 #include "ui/accessibility/ax_view_state.h" |
| 10 #include "ui/events/event_utils.h" | 10 #include "ui/events/event_utils.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 return true; | 217 return true; |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool NativeViewAccessibility::CanSetStringValue() { | 220 bool NativeViewAccessibility::CanSetStringValue() { |
| 221 ui::AXViewState state; | 221 ui::AXViewState state; |
| 222 view_->GetAccessibleState(&state); | 222 view_->GetAccessibleState(&state); |
| 223 return !ui::AXViewState::IsFlagSet(GetData().state, ui::AX_STATE_READ_ONLY) && | 223 return !ui::AXViewState::IsFlagSet(GetData().state, ui::AX_STATE_READ_ONLY) && |
| 224 !state.set_value_callback.is_null(); | 224 !state.set_value_callback.is_null(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 bool NativeViewAccessibility::ReplaceSelectedText( | |
| 228 const base::string16& selection_replacement) { | |
| 229 if (!CanSetStringValue()) | |
| 230 return false; | |
| 231 | |
| 232 ui::AXViewState state; | |
| 233 view_->GetAccessibleState(&state); | |
| 234 state.replace_selection_callback.Run(selection_replacement); | |
| 235 return true; | |
| 236 } | |
|
tapted
2016/09/27 07:16:30
the `bool` arg would make it easier to share code
Patti Lor
2016/10/20 04:19:34
Done.
| |
| 237 | |
| 227 void NativeViewAccessibility::OnWidgetDestroying(Widget* widget) { | 238 void NativeViewAccessibility::OnWidgetDestroying(Widget* widget) { |
| 228 if (parent_widget_ == widget) { | 239 if (parent_widget_ == widget) { |
| 229 parent_widget_->RemoveObserver(this); | 240 parent_widget_->RemoveObserver(this); |
| 230 parent_widget_ = nullptr; | 241 parent_widget_ = nullptr; |
| 231 } | 242 } |
| 232 } | 243 } |
| 233 | 244 |
| 234 void NativeViewAccessibility::SetParentWidget(Widget* parent_widget) { | 245 void NativeViewAccessibility::SetParentWidget(Widget* parent_widget) { |
| 235 if (parent_widget_) | 246 if (parent_widget_) |
| 236 parent_widget_->RemoveObserver(this); | 247 parent_widget_->RemoveObserver(this); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 267 child_widget_platform_node->GetDelegate()); | 278 child_widget_platform_node->GetDelegate()); |
| 268 if (child_widget_view_accessibility->parent_widget() != widget) | 279 if (child_widget_view_accessibility->parent_widget() != widget) |
| 269 child_widget_view_accessibility->SetParentWidget(widget); | 280 child_widget_view_accessibility->SetParentWidget(widget); |
| 270 } | 281 } |
| 271 | 282 |
| 272 result_child_widgets->push_back(child_widget); | 283 result_child_widgets->push_back(child_widget); |
| 273 } | 284 } |
| 274 } | 285 } |
| 275 | 286 |
| 276 } // namespace views | 287 } // namespace views |
| OLD | NEW |