| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 view_->OnMouseReleased(ui::MouseEvent(ui::ET_MOUSE_RELEASED, | 199 view_->OnMouseReleased(ui::MouseEvent(ui::ET_MOUSE_RELEASED, |
| 200 center, | 200 center, |
| 201 center, | 201 center, |
| 202 ui::EventTimeForNow(), | 202 ui::EventTimeForNow(), |
| 203 ui::EF_LEFT_MOUSE_BUTTON, | 203 ui::EF_LEFT_MOUSE_BUTTON, |
| 204 ui::EF_LEFT_MOUSE_BUTTON)); | 204 ui::EF_LEFT_MOUSE_BUTTON)); |
| 205 } | 205 } |
| 206 | 206 |
| 207 bool NativeViewAccessibility::SetStringValue(const base::string16& new_value) { | 207 bool NativeViewAccessibility::SetStringValue(const base::string16& new_value) { |
| 208 // Return an error if the view can't set the value. | 208 // Return an error if the view can't set the value. |
| 209 if (!CanSetStringValue()) |
| 210 return false; |
| 211 |
| 209 ui::AXViewState state; | 212 ui::AXViewState state; |
| 210 view_->GetAccessibleState(&state); | 213 view_->GetAccessibleState(&state); |
| 211 if (state.set_value_callback.is_null()) | |
| 212 return false; | |
| 213 | |
| 214 state.set_value_callback.Run(new_value); | 214 state.set_value_callback.Run(new_value); |
| 215 return true; | 215 return true; |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool NativeViewAccessibility::CanSetStringValue() { |
| 219 ui::AXViewState state; |
| 220 view_->GetAccessibleState(&state); |
| 221 return !ui::AXViewState::IsFlagSet(GetData().state, ui::AX_STATE_READ_ONLY) && |
| 222 !state.set_value_callback.is_null(); |
| 223 } |
| 224 |
| 218 void NativeViewAccessibility::OnWidgetDestroying(Widget* widget) { | 225 void NativeViewAccessibility::OnWidgetDestroying(Widget* widget) { |
| 219 if (parent_widget_ == widget) { | 226 if (parent_widget_ == widget) { |
| 220 parent_widget_->RemoveObserver(this); | 227 parent_widget_->RemoveObserver(this); |
| 221 parent_widget_ = nullptr; | 228 parent_widget_ = nullptr; |
| 222 } | 229 } |
| 223 } | 230 } |
| 224 | 231 |
| 225 void NativeViewAccessibility::SetParentWidget(Widget* parent_widget) { | 232 void NativeViewAccessibility::SetParentWidget(Widget* parent_widget) { |
| 226 if (parent_widget_) | 233 if (parent_widget_) |
| 227 parent_widget_->RemoveObserver(this); | 234 parent_widget_->RemoveObserver(this); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 258 child_widget_platform_node->GetDelegate()); | 265 child_widget_platform_node->GetDelegate()); |
| 259 if (child_widget_view_accessibility->parent_widget() != widget) | 266 if (child_widget_view_accessibility->parent_widget() != widget) |
| 260 child_widget_view_accessibility->SetParentWidget(widget); | 267 child_widget_view_accessibility->SetParentWidget(widget); |
| 261 } | 268 } |
| 262 | 269 |
| 263 result_child_widgets->push_back(child_widget); | 270 result_child_widgets->push_back(child_widget); |
| 264 } | 271 } |
| 265 } | 272 } |
| 266 | 273 |
| 267 } // namespace views | 274 } // namespace views |
| OLD | NEW |