Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: ui/views/controls/focus_ring.cc

Issue 2813353002: Ensure that the focus ring in the bookmarks bar does not paint outside the parent view. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/controls/scroll_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/focus_ring.h" 5 #include "ui/views/controls/focus_ring.h"
6 6
7 #include "ui/gfx/canvas.h" 7 #include "ui/gfx/canvas.h"
8 #include "ui/native_theme/native_theme.h" 8 #include "ui/native_theme/native_theme.h"
9 #include "ui/views/controls/focusable_border.h" 9 #include "ui/views/controls/focusable_border.h"
10 10
(...skipping 22 matching lines...) Expand all
33 33
34 const char FocusRing::kViewClassName[] = "FocusRing"; 34 const char FocusRing::kViewClassName[] = "FocusRing";
35 35
36 // static 36 // static
37 views::View* FocusRing::Install(views::View* parent, 37 views::View* FocusRing::Install(views::View* parent,
38 ui::NativeTheme::ColorId override_color_id) { 38 ui::NativeTheme::ColorId override_color_id) {
39 FocusRing* ring = GetFocusRing(parent); 39 FocusRing* ring = GetFocusRing(parent);
40 if (!ring) { 40 if (!ring) {
41 ring = new FocusRing(); 41 ring = new FocusRing();
42 parent->AddChildView(ring); 42 parent->AddChildView(ring);
43 // A layer is necessary to paint beyond the parent's bounds.
44 ring->SetPaintToLayer();
45 ring->layer()->SetFillsBoundsOpaquely(false);
43 } 46 }
44 ring->override_color_id_ = override_color_id; 47 ring->override_color_id_ = override_color_id;
45 ring->Layout(); 48 ring->Layout();
46 ring->SchedulePaint(); 49 ring->SchedulePaint();
47 return ring; 50 return ring;
48 } 51 }
49 52
50 // static 53 // static
51 void FocusRing::Uninstall(views::View* parent) { 54 void FocusRing::Uninstall(views::View* parent) {
52 delete GetFocusRing(parent); 55 delete GetFocusRing(parent);
(...skipping 26 matching lines...) Expand all
79 0x66)); 82 0x66));
80 flags.setStyle(cc::PaintFlags::kStroke_Style); 83 flags.setStyle(cc::PaintFlags::kStroke_Style);
81 flags.setStrokeWidth(kFocusHaloThicknessDp); 84 flags.setStrokeWidth(kFocusHaloThicknessDp);
82 gfx::RectF rect(GetLocalBounds()); 85 gfx::RectF rect(GetLocalBounds());
83 rect.Inset(gfx::InsetsF(kFocusHaloThicknessDp / 2.f)); 86 rect.Inset(gfx::InsetsF(kFocusHaloThicknessDp / 2.f));
84 canvas->DrawRoundRect(rect, kFocusHaloCornerRadiusDp, flags); 87 canvas->DrawRoundRect(rect, kFocusHaloCornerRadiusDp, flags);
85 } 88 }
86 89
87 FocusRing::FocusRing() 90 FocusRing::FocusRing()
88 : override_color_id_(ui::NativeTheme::kColorId_NumColors) { 91 : override_color_id_(ui::NativeTheme::kColorId_NumColors) {
89 // A layer is necessary to paint beyond the parent's bounds.
90 SetPaintToLayer();
ananta 2017/04/12 23:54:04 Moved this code to FocusRing::Install() as we need
91 layer()->SetFillsBoundsOpaquely(false);
92 } 92 }
93 93
94 FocusRing::~FocusRing() {} 94 FocusRing::~FocusRing() {}
95 95
96 } // namespace views 96 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/scroll_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698