Chromium Code Reviews| Index: ui/views/accessibility/native_view_accessibility.cc |
| diff --git a/ui/views/accessibility/native_view_accessibility.cc b/ui/views/accessibility/native_view_accessibility.cc |
| index 7c960348478b020d7b0bfeed5adf0f50f45e5d70..47bb4cb4c5fa32a5bab210577c35e0b80bdc8d19 100644 |
| --- a/ui/views/accessibility/native_view_accessibility.cc |
| +++ b/ui/views/accessibility/native_view_accessibility.cc |
| @@ -13,6 +13,24 @@ |
| namespace views { |
| +#if defined(OS_MACOSX) |
| +namespace { |
| + |
| +bool IsAccessibilityFocusableWhenEnabled(View* view) { |
| + return view->focus_behavior() != View::FocusBehavior::NEVER && |
| + view->IsDrawn(); |
| +} |
| + |
| +bool ViewHasFocusableAncestor(View* parent) { |
|
tapted
2016/11/29 03:12:49
nit: parent -> view (since it's not the parent tha
Patti Lor
2016/11/29 23:26:18
Done.
|
| + while ((parent = parent->parent())) { |
| + if (IsAccessibilityFocusableWhenEnabled(parent)) |
| + return true; |
| + } |
| + return false; |
| +} |
| +} |
|
tapted
2016/11/29 03:12:49
nit: // namespace (and and a blank line before,
Patti Lor
2016/11/29 23:26:18
Thanks - it seems to not let you if you've only go
|
| +#endif |
| + |
| #if !defined(PLATFORM_HAS_NATIVE_VIEW_ACCESSIBILITY_IMPL) |
| // static |
| NativeViewAccessibility* NativeViewAccessibility::Create(View* view) { |
| @@ -80,13 +98,22 @@ const ui::AXNodeData& NativeViewAccessibility::GetData() { |
| base::UTF16ToUTF8(description)); |
| if (view_->IsAccessibilityFocusable()) |
| - data_.state |= (1 << ui::AX_STATE_FOCUSABLE); |
| + data_.AddStateFlag(ui::AX_STATE_FOCUSABLE); |
| if (!view_->enabled()) |
| - data_.state |= (1 << ui::AX_STATE_DISABLED); |
| + data_.AddStateFlag(ui::AX_STATE_DISABLED); |
| if (!view_->visible()) |
| - data_.state |= (1 << ui::AX_STATE_INVISIBLE); |
| + data_.AddStateFlag(ui::AX_STATE_INVISIBLE); |
| + |
| +#if defined(OS_MACOSX) |
| + // Make sure this element is ignored if there's a focusable parent. All |
| + // keyboard focusable elements should be leaf nodes in the accessibility tree. |
| + // Exceptions to this rule will themselves be accessibility focusable. |
| + if (!IsAccessibilityFocusableWhenEnabled(view_) && |
| + ViewHasFocusableAncestor(view_)) |
| + data_.role = ui::AX_ROLE_UNKNOWN; |
| +#endif |
| return data_; |
| } |
| @@ -140,7 +167,7 @@ gfx::NativeViewAccessible NativeViewAccessibility::GetParent() { |
| } |
| gfx::Vector2d NativeViewAccessibility::GetGlobalCoordinateOffset() { |
| - return gfx::Vector2d(0, 0); // location is already in screen coordinates. |
| + return gfx::Vector2d(0, 0); // Location is already in screen coordinates. |
| } |
| gfx::NativeViewAccessible NativeViewAccessibility::HitTestSync(int x, int y) { |
| @@ -163,9 +190,9 @@ gfx::NativeViewAccessible NativeViewAccessibility::HitTestSync(int x, int y) { |
| if (!view_->HitTestPoint(point)) |
| return nullptr; |
| - // Check if the point is within any of the immediate children of this |
| - // view. We don't have to search further because AXPlatformNode will |
| - // do a recursive hit test if we return anything other than |this| or NULL. |
| + // Check if the point is within any of the immediate children of this view. We |
| + // don't have to search further because AXPlatformNodeWin will do a recursive |
| + // hit test if we return anything other than GetNativeObject() or nullptr. |
| for (int i = view_->child_count() - 1; i >= 0; --i) { |
| View* child_view = view_->child_at(i); |
| if (!child_view->visible()) |