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

Unified Diff: ui/gfx/canvas.cc

Issue 2527513002: Update ash shelf/tray focus rects. (Closed)
Patch Set: fixes Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/canvas.cc
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index 01c30cd939211e75cd965c26741039d0ba8c5872..e8e15f2f406b9d58b4a79e6d08c2636eabd249f2 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -14,6 +14,7 @@
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "ui/gfx/font_list.h"
+#include "ui/gfx/geometry/insets_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
@@ -343,23 +344,19 @@ void Canvas::DrawFocusRect(const RectF& rect) {
}
void Canvas::DrawSolidFocusRect(const Rect& rect, SkColor color) {
- DrawSolidFocusRect(RectF(rect), color);
+ DrawSolidFocusRect(RectF(rect), color, 1.f);
}
-void Canvas::DrawSolidFocusRect(const RectF& rect, SkColor color) {
+void Canvas::DrawSolidFocusRect(const RectF& rect,
+ SkColor color,
+ float thickness = 1.f) {
SkPaint paint;
paint.setColor(color);
- paint.setStrokeWidth(SK_Scalar1);
- // Note: We cannot use DrawRect since it would create a path and fill it which
- // would cause problems near the edge of the canvas.
- float x1 = std::min(rect.x(), rect.right());
- float x2 = std::max(rect.x(), rect.right());
- float y1 = std::min(rect.y(), rect.bottom());
- float y2 = std::max(rect.y(), rect.bottom());
- DrawLine(PointF(x1, y1), PointF(x2, y1), paint);
- DrawLine(PointF(x1, y2), PointF(x2, y2), paint);
- DrawLine(PointF(x1, y1), PointF(x1, y2), paint);
- DrawLine(PointF(x2, y1), PointF(x2, y2 + 1.f), paint);
+ paint.setStrokeWidth(SkFloatToScalar(thickness));
+ paint.setStyle(SkPaint::kStroke_Style);
+ gfx::RectF draw_rect = rect;
+ draw_rect.Inset(gfx::InsetsF(thickness / 2));
+ DrawRect(draw_rect, paint);
}
void Canvas::DrawImageInt(const ImageSkia& image, int x, int y) {

Powered by Google App Engine
This is Rietveld 408576698