| Index: ui/views/controls/focus_ring.cc
|
| diff --git a/ui/views/controls/focus_ring.cc b/ui/views/controls/focus_ring.cc
|
| index 8e1702b37884dbb2114351b7c52591ba9da9fde7..59e97f7838a31ae786f179693cd74af000afa1ac 100644
|
| --- a/ui/views/controls/focus_ring.cc
|
| +++ b/ui/views/controls/focus_ring.cc
|
| @@ -21,6 +21,15 @@ constexpr float kFocusHaloThicknessDp = 2.f;
|
| constexpr float kFocusHaloCornerRadiusDp =
|
| FocusableBorder::kCornerRadiusDp + kFocusHaloThicknessDp / 2.f;
|
|
|
| +FocusRing* GetFocusRing(views::View* parent) {
|
| + for (int i = 0; i < parent->child_count(); ++i) {
|
| + if (parent->child_at(i)->GetClassName() == FocusRing::kViewClassName)
|
| + return static_cast<FocusRing*>(parent->child_at(i));
|
| + }
|
| + NOTREACHED();
|
| + return nullptr;
|
| +}
|
| +
|
| } // namespace
|
|
|
| const char FocusRing::kViewClassName[] = "FocusRing";
|
| @@ -35,13 +44,16 @@ void FocusRing::Install(views::View* parent) {
|
|
|
| // static
|
| void FocusRing::Uninstall(views::View* parent) {
|
| - for (int i = 0; i < parent->child_count(); ++i) {
|
| - if (parent->child_at(i)->GetClassName() == kViewClassName) {
|
| - delete parent->child_at(i);
|
| - return;
|
| - }
|
| - }
|
| - NOTREACHED();
|
| + delete GetFocusRing(parent);
|
| +}
|
| +
|
| +// static
|
| +void FocusRing::SetColorId(
|
| + views::View* parent,
|
| + const base::Optional<ui::NativeTheme::ColorId>& override_color_id) {
|
| + FocusRing* ring = GetFocusRing(parent);
|
| + ring->override_color_id_ = override_color_id;
|
| + ring->SchedulePaint();
|
| }
|
|
|
| const char* FocusRing::GetClassName() const {
|
| @@ -63,9 +75,11 @@ void FocusRing::Layout() {
|
| void FocusRing::OnPaint(gfx::Canvas* canvas) {
|
| SkPaint paint;
|
| paint.setAntiAlias(true);
|
| - paint.setColor(SkColorSetA(GetNativeTheme()->GetSystemColor(
|
| - ui::NativeTheme::kColorId_FocusedBorderColor),
|
| - 0x66));
|
| + paint.setColor(SkColorSetA(
|
| + GetNativeTheme()->GetSystemColor(
|
| + override_color_id_ ? *override_color_id_
|
| + : ui::NativeTheme::kColorId_FocusedBorderColor),
|
| + 0x66));
|
| paint.setStyle(SkPaint::kStroke_Style);
|
| paint.setStrokeWidth(kFocusHaloThicknessDp);
|
| gfx::RectF rect(GetLocalBounds());
|
|
|