Chromium Code Reviews| Index: ui/views/controls/focusable_border.cc |
| diff --git a/ui/views/controls/focusable_border.cc b/ui/views/controls/focusable_border.cc |
| index a63629c0ef3444a5e10b78cfc928d3f66b5d37e1..6f388e9ec4c415e44a3e4f28ed730864ae486bbe 100644 |
| --- a/ui/views/controls/focusable_border.cc |
| +++ b/ui/views/controls/focusable_border.cc |
| @@ -43,27 +43,28 @@ void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) { |
| flags.setStyle(cc::PaintFlags::kStroke_Style); |
| flags.setColor(GetCurrentColor(view)); |
| + gfx::ScopedCanvas scoped(canvas); |
| + float dsf = canvas->UndoDeviceScaleFactor(); |
| + |
| + const int stroke_width_px = |
| + ui::MaterialDesignController::IsSecondaryUiMaterial() ? 1 : dsf; |
|
Peter Kasting
2017/02/14 00:30:32
It seems like the old pre-Harmony code was trying
Evan Stade
2017/02/14 00:37:47
That was just a hacky way to get a 1dip border. 1d
Peter Kasting
2017/02/14 00:45:59
I see.
Why was the old code producing poorer-look
|
| + flags.setStrokeWidth(SkIntToScalar(stroke_width_px)); |
| + |
| + // Scale the rect and snap to pixel boundaries. |
| + gfx::RectF rect(gfx::ScaleToEnclosingRect(view.GetLocalBounds(), dsf)); |
| + rect.Inset(gfx::InsetsF(stroke_width_px / 2.0f)); |
| + |
| + SkPath path; |
| if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| - gfx::ScopedCanvas scoped(canvas); |
| - float dsf = canvas->UndoDeviceScaleFactor(); |
| - // Scale the rect and snap to pixel boundaries. |
| - gfx::RectF rect(gfx::ScaleToEnclosingRect(view.GetLocalBounds(), dsf)); |
| - rect.Inset(gfx::InsetsF(0.5f)); |
| - SkPath path; |
| + flags.setAntiAlias(true); |
| float corner_radius_px = kCornerRadiusDp * dsf; |
| path.addRoundRect(gfx::RectFToSkRect(rect), corner_radius_px, |
| corner_radius_px); |
| - const int kStrokeWidthPx = 1; |
| - flags.setStrokeWidth(SkIntToScalar(kStrokeWidthPx)); |
| - flags.setAntiAlias(true); |
| - canvas->DrawPath(path, flags); |
| } else { |
| - SkPath path; |
| - path.addRect(gfx::RectToSkRect(view.GetLocalBounds()), |
| - SkPath::kCW_Direction); |
| - flags.setStrokeWidth(SkIntToScalar(2)); |
| - canvas->DrawPath(path, flags); |
| + path.addRect(gfx::RectFToSkRect(rect), SkPath::kCW_Direction); |
| } |
| + |
| + canvas->DrawPath(path, flags); |
| } |
| gfx::Insets FocusableBorder::GetInsets() const { |