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..fa7ac3343d9070480fe0e9fd3be8f88d901d78df 100644 |
| --- a/ui/views/accessibility/native_view_accessibility.cc |
| +++ b/ui/views/accessibility/native_view_accessibility.cc |
| @@ -58,6 +58,17 @@ bool NativeViewAccessibility::SetFocused(bool focused) { |
| return true; |
| } |
| +#if defined(OS_MACOSX) |
| +bool NativeViewAccessibility::HasFocusableAncestor() { |
| + View* parent = view_; |
| + while ((parent = parent->parent())) { |
| + if (parent->IsAccessibilityFocusable()) |
| + return true; |
| + } |
| + return false; |
| +} |
| +#endif |
| + |
| // ui::AXPlatformNodeDelegate |
| const ui::AXNodeData& NativeViewAccessibility::GetData() { |
| @@ -80,13 +91,20 @@ 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. |
| + if (HasFocusableAncestor()) |
|
tapted
2016/11/25 04:36:27
should we do this only if the view itself is not a
Patti Lor
2016/11/28 06:40:23
That sounds reasonable - I don't think it fixes th
|
| + data_.role = ui::AX_ROLE_UNKNOWN; |
| +#endif |
| return data_; |
| } |
| @@ -140,7 +158,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 +181,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()) |