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 "ui/events/event_utils.h" | 8 #include "ui/events/event_utils.h" |
| 9 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
| 10 #include "ui/views/controls/native/native_view_host.h" | 10 #include "ui/views/controls/native/native_view_host.h" |
| 11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
| 12 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 | 15 |
| 16 namespace { | |
| 17 | |
| 18 // Determine a View's visibility accounting for potentially invisible ancestors, | |
| 19 // since View::visible() won't return true for descendants of invisible Views. | |
| 20 bool IsViewVisible(View* view) { | |
| 21 while (view) { | |
|
karandeepb
2016/12/28 10:59:59
Also a visible view with no parent would return tr
Patti Lor
2016/12/29 00:57:56
This was fixed when replacing this method with IsD
| |
| 22 if (!view->visible()) | |
| 23 return false; | |
| 24 view = view->parent(); | |
| 25 } | |
| 26 return true; | |
| 27 } | |
| 28 | |
| 29 } // namespace | |
| 30 | |
| 16 #if !defined(PLATFORM_HAS_NATIVE_VIEW_ACCESSIBILITY_IMPL) | 31 #if !defined(PLATFORM_HAS_NATIVE_VIEW_ACCESSIBILITY_IMPL) |
| 17 // static | 32 // static |
| 18 NativeViewAccessibility* NativeViewAccessibility::Create(View* view) { | 33 NativeViewAccessibility* NativeViewAccessibility::Create(View* view) { |
| 19 return new NativeViewAccessibility(view); | 34 return new NativeViewAccessibility(view); |
| 20 } | 35 } |
| 21 #endif // !defined(PLATFORM_HAS_NATIVE_VIEW_ACCESSIBILITY_IMPL) | 36 #endif // !defined(PLATFORM_HAS_NATIVE_VIEW_ACCESSIBILITY_IMPL) |
| 22 | 37 |
| 23 NativeViewAccessibility::NativeViewAccessibility(View* view) | 38 NativeViewAccessibility::NativeViewAccessibility(View* view) |
| 24 : view_(view), | 39 : view_(view), |
| 25 parent_widget_(nullptr), | 40 parent_widget_(nullptr), |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 view_->GetTooltipText(gfx::Point(), &description); | 93 view_->GetTooltipText(gfx::Point(), &description); |
| 79 data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION, | 94 data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION, |
| 80 base::UTF16ToUTF8(description)); | 95 base::UTF16ToUTF8(description)); |
| 81 | 96 |
| 82 if (view_->IsAccessibilityFocusable()) | 97 if (view_->IsAccessibilityFocusable()) |
| 83 data_.state |= (1 << ui::AX_STATE_FOCUSABLE); | 98 data_.state |= (1 << ui::AX_STATE_FOCUSABLE); |
| 84 | 99 |
| 85 if (!view_->enabled()) | 100 if (!view_->enabled()) |
| 86 data_.state |= (1 << ui::AX_STATE_DISABLED); | 101 data_.state |= (1 << ui::AX_STATE_DISABLED); |
| 87 | 102 |
| 88 if (!view_->visible()) | 103 if (!IsViewVisible(view_)) |
|
karandeepb
2016/12/28 10:57:10
It seems to me that View::IsDrawn accomplishes the
Patti Lor
2016/12/29 00:57:56
Oops, you're totally right. Thanks for pointing it
| |
| 89 data_.state |= (1 << ui::AX_STATE_INVISIBLE); | 104 data_.state |= (1 << ui::AX_STATE_INVISIBLE); |
| 90 | 105 |
| 91 return data_; | 106 return data_; |
| 92 } | 107 } |
| 93 | 108 |
| 94 int NativeViewAccessibility::GetChildCount() { | 109 int NativeViewAccessibility::GetChildCount() { |
| 95 int child_count = view_->child_count(); | 110 int child_count = view_->child_count(); |
| 96 | 111 |
| 97 std::vector<Widget*> child_widgets; | 112 std::vector<Widget*> child_widgets; |
| 98 PopulateChildWidgetVector(&child_widgets); | 113 PopulateChildWidgetVector(&child_widgets); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 child_widget_platform_node->GetDelegate()); | 291 child_widget_platform_node->GetDelegate()); |
| 277 if (child_widget_view_accessibility->parent_widget() != widget) | 292 if (child_widget_view_accessibility->parent_widget() != widget) |
| 278 child_widget_view_accessibility->SetParentWidget(widget); | 293 child_widget_view_accessibility->SetParentWidget(widget); |
| 279 } | 294 } |
| 280 | 295 |
| 281 result_child_widgets->push_back(child_widget); | 296 result_child_widgets->push_back(child_widget); |
| 282 } | 297 } |
| 283 } | 298 } |
| 284 | 299 |
| 285 } // namespace views | 300 } // namespace views |
| OLD | NEW |