| 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_base.h" | 5 #include "ui/views/accessibility/native_view_accessibility_base.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 // Views may misbehave if their widget is closed; return an unknown role | 56 // Views may misbehave if their widget is closed; return an unknown role |
| 57 // rather than possibly crashing. | 57 // rather than possibly crashing. |
| 58 if (!view_->GetWidget() || view_->GetWidget()->IsClosed()) { | 58 if (!view_->GetWidget() || view_->GetWidget()->IsClosed()) { |
| 59 data_.role = ui::AX_ROLE_UNKNOWN; | 59 data_.role = ui::AX_ROLE_UNKNOWN; |
| 60 data_.state = 1 << ui::AX_STATE_DISABLED; | 60 data_.state = 1 << ui::AX_STATE_DISABLED; |
| 61 return data_; | 61 return data_; |
| 62 } | 62 } |
| 63 | 63 |
| 64 view_->GetAccessibleNodeData(&data_); | 64 view_->GetAccessibleNodeData(&data_); |
| 65 data_.location = gfx::RectF(view_->GetBoundsInScreen()); | 65 data_.location = GetBoundsInScreen(); |
| 66 base::string16 description; | 66 base::string16 description; |
| 67 view_->GetTooltipText(gfx::Point(), &description); | 67 view_->GetTooltipText(gfx::Point(), &description); |
| 68 data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION, | 68 data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION, |
| 69 base::UTF16ToUTF8(description)); | 69 base::UTF16ToUTF8(description)); |
| 70 | 70 |
| 71 if (view_->IsAccessibilityFocusable()) | 71 if (view_->IsAccessibilityFocusable()) |
| 72 data_.state |= (1 << ui::AX_STATE_FOCUSABLE); | 72 data_.state |= (1 << ui::AX_STATE_FOCUSABLE); |
| 73 | 73 |
| 74 if (!view_->enabled()) | 74 if (!view_->enabled()) |
| 75 data_.state |= (1 << ui::AX_STATE_DISABLED); | 75 data_.state |= (1 << ui::AX_STATE_DISABLED); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 void NativeViewAccessibilityBase::SetParentWidget(Widget* parent_widget) { | 221 void NativeViewAccessibilityBase::SetParentWidget(Widget* parent_widget) { |
| 222 if (parent_widget_) | 222 if (parent_widget_) |
| 223 parent_widget_->RemoveObserver(this); | 223 parent_widget_->RemoveObserver(this); |
| 224 parent_widget_ = parent_widget; | 224 parent_widget_ = parent_widget; |
| 225 parent_widget_->AddObserver(this); | 225 parent_widget_->AddObserver(this); |
| 226 } | 226 } |
| 227 | 227 |
| 228 gfx::RectF NativeViewAccessibilityBase::GetBoundsInScreen() const { |
| 229 return gfx::RectF(view_->GetBoundsInScreen()); |
| 230 } |
| 231 |
| 228 void NativeViewAccessibilityBase::PopulateChildWidgetVector( | 232 void NativeViewAccessibilityBase::PopulateChildWidgetVector( |
| 229 std::vector<Widget*>* result_child_widgets) { | 233 std::vector<Widget*>* result_child_widgets) { |
| 230 // Only attach child widgets to the root view. | 234 // Only attach child widgets to the root view. |
| 231 Widget* widget = view_->GetWidget(); | 235 Widget* widget = view_->GetWidget(); |
| 232 // Note that during window close, a Widget may exist in a state where it has | 236 // Note that during window close, a Widget may exist in a state where it has |
| 233 // no NativeView, but hasn't yet torn down its view hierarchy. | 237 // no NativeView, but hasn't yet torn down its view hierarchy. |
| 234 if (!widget || !widget->GetNativeView() || widget->GetRootView() != view_) | 238 if (!widget || !widget->GetNativeView() || widget->GetRootView() != view_) |
| 235 return; | 239 return; |
| 236 | 240 |
| 237 std::set<Widget*> child_widgets; | 241 std::set<Widget*> child_widgets; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 256 child_widget_platform_node->GetDelegate()); | 260 child_widget_platform_node->GetDelegate()); |
| 257 if (child_widget_view_accessibility->parent_widget() != widget) | 261 if (child_widget_view_accessibility->parent_widget() != widget) |
| 258 child_widget_view_accessibility->SetParentWidget(widget); | 262 child_widget_view_accessibility->SetParentWidget(widget); |
| 259 } | 263 } |
| 260 | 264 |
| 261 result_child_widgets->push_back(child_widget); | 265 result_child_widgets->push_back(child_widget); |
| 262 } | 266 } |
| 263 } | 267 } |
| 264 | 268 |
| 265 } // namespace views | 269 } // namespace views |
| OLD | NEW |