| 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..fd195e2ae3589b1a3992af670c4b647ff4d944f0 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,8 @@ void TreeView::OnFocus() {
|
| // Notify the InputMethod so that it knows to query the TextInputClient.
|
| if (GetInputMethod())
|
| GetInputMethod()->OnCaretBoundsChanged(GetPrefixSelector());
|
| +
|
| + SetHasFocusRing(true);
|
| }
|
|
|
| void TreeView::OnBlur() {
|
| @@ -639,6 +643,7 @@ void TreeView::OnBlur() {
|
| SchedulePaintForNode(selected_node_);
|
| if (selector_)
|
| selector_->OnViewBlur();
|
| + SetHasFocusRing(false);
|
| }
|
|
|
| bool TreeView::OnClickOrTap(const ui::LocatedEvent& event) {
|
| @@ -1057,6 +1062,22 @@ bool TreeView::IsPointInExpandControl(InternalNode* node,
|
| return arrow_bounds.Contains(point);
|
| }
|
|
|
| +void TreeView::SetHasFocusRing(bool shows) {
|
| + if (!ui::MaterialDesignController::IsSecondaryUiMaterial() ||
|
| + !PlatformStyle::kTreeViewHasFocusRing) {
|
| + return;
|
| + }
|
| + // 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)
|
| + static_cast<ScrollView*>(grandparent)->SetHasFocusRing(shows);
|
| +}
|
| +
|
| // InternalNode ----------------------------------------------------------------
|
|
|
| TreeView::InternalNode::InternalNode()
|
|
|