Chromium Code Reviews| Index: ui/views/controls/tree/tree_view.cc |
| diff --git a/ui/views/controls/tree/tree_view.cc b/ui/views/controls/tree/tree_view.cc |
| index a87875e7870ddb7af5c099fcd3f9a917d7d549a1..f4d1007afbba0f41134d3cf8a44b85eb5de87f06 100644 |
| --- a/ui/views/controls/tree/tree_view.cc |
| +++ b/ui/views/controls/tree/tree_view.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/message_loop/message_loop.h" |
| #include "ui/accessibility/ax_view_state.h" |
| #include "ui/base/ime/input_method.h" |
| +#include "ui/base/material_design/material_design_controller.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/events/event.h" |
| #include "ui/events/keycodes/keyboard_codes.h" |
| @@ -21,6 +22,7 @@ |
| #include "ui/gfx/skia_util.h" |
| #include "ui/native_theme/native_theme.h" |
| #include "ui/resources/grit/ui_resources.h" |
| +#include "ui/views/controls/focus_ring.h" |
| #include "ui/views/controls/prefix_selector.h" |
| #include "ui/views/controls/scroll_view.h" |
| #include "ui/views/controls/textfield/textfield.h" |
| @@ -631,6 +633,13 @@ void TreeView::OnFocus() { |
| // Notify the InputMethod so that it knows to query the TextInputClient. |
| if (GetInputMethod()) |
| GetInputMethod()->OnCaretBoundsChanged(GetPrefixSelector()); |
| + |
| + if (ui::MaterialDesignController::IsSecondaryUiMaterial() && |
| + PlatformStyle::kTreeViewHasFocusRing) { |
| + ScrollView* focus_ring_view = FindFocusRingView(); |
| + focus_ring_view->SetHasFocusRing(true); |
| + focus_ring_view->SchedulePaint(); |
|
sky
2016/10/12 23:58:01
Are you sure you need a SchedulePaint here? If so,
Elly Fong-Jones
2016/10/13 11:14:56
I believe so - FocusRing::Install() and FocusRing:
|
| + } |
| } |
| void TreeView::OnBlur() { |
| @@ -639,6 +648,12 @@ void TreeView::OnBlur() { |
| SchedulePaintForNode(selected_node_); |
| if (selector_) |
| selector_->OnViewBlur(); |
| + if (ui::MaterialDesignController::IsSecondaryUiMaterial() && |
|
sky
2016/10/12 23:58:01
As this is nearly the same as the above and only d
Elly Fong-Jones
2016/10/13 11:14:56
Done.
|
| + PlatformStyle::kTreeViewHasFocusRing) { |
| + ScrollView* focus_ring_view = FindFocusRingView(); |
| + focus_ring_view->SetHasFocusRing(false); |
| + focus_ring_view->SchedulePaint(); |
| + } |
| } |
| bool TreeView::OnClickOrTap(const ui::LocatedEvent& event) { |
| @@ -1057,6 +1072,19 @@ bool TreeView::IsPointInExpandControl(InternalNode* node, |
| return arrow_bounds.Contains(point); |
| } |
| +ScrollView* TreeView::FindFocusRingView() { |
| + // If this View is the grandchild of a ScrollView, use the grandparent |
| + // ScrollView for the focus ring instead of this View so that the focus ring |
| + // won't be scrolled. Since ScrollViews have a single content view, which they |
| + // wrap in a ScrollView::Viewport, being the grandchild of a ScrollView |
| + // implies being the sole grandchild, which means it's fine to wrap the focus |
| + // ring around the grandparent here. |
| + View* grandparent = parent() ? parent()->parent() : nullptr; |
| + if (grandparent && grandparent->GetClassName() == ScrollView::kViewClassName) |
| + return static_cast<ScrollView*>(grandparent); |
| + return nullptr; |
| +} |
| + |
| // InternalNode ---------------------------------------------------------------- |
| TreeView::InternalNode::InternalNode() |