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

Unified Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 1394763003: Update LocationBarView Background (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/location_bar/location_bar_view.cc
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index c39d2fca8b57c5ccc74d5a93ffc65eb87a2dfdf6..f280af21e09b6c71162bb46e748a162166b516f3 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -103,6 +103,32 @@ using views::View;
namespace {
+void DrawScaledRoundRect(gfx::Canvas* canvas,
Peter Kasting 2015/10/08 21:33:06 Nit: I'd add a comment about what this does, in pa
jonross 2015/10/09 15:59:24 Done.
+ SkPaint::Style style,
+ SkColor color,
+ gfx::Rect bounds) {
+ const float display_scale = canvas->image_scale();
+ canvas->Save();
+ SkScalar scale_factor = 1.0f / display_scale;
+ canvas->sk_canvas()->scale(scale_factor, scale_factor);
+
+ SkPaint paint;
+ paint.setStyle(style);
+ paint.setColor(color);
+ paint.setAntiAlias(true);
+
+ const float kOffset = 0.5f;
+ gfx::RectF border_rect_f(bounds);
+ border_rect_f.Scale(display_scale);
+ gfx::InsetsF insets(kOffset, kOffset, kOffset, kOffset);
+ border_rect_f.Inset(insets);
+
+ const SkScalar kCornerRadius = SkDoubleToScalar(2.5f * display_scale);
+ canvas->sk_canvas()->drawRoundRect(gfx::RectFToSkRect(border_rect_f),
+ kCornerRadius, kCornerRadius, paint);
+ canvas->Restore();
+}
+
int GetEditLeadingInternalSpace() {
// The textfield has 1 px of whitespace before the text in the RTL case only.
return base::i18n::IsRTL() ? 1 : 0;
@@ -1259,6 +1285,8 @@ void LocationBarView::OnPaint(gfx::Canvas* canvas) {
SkColor color(GetColor(SecurityStateModel::NONE, BACKGROUND));
if (is_popup_mode_) {
canvas->FillRect(bounds, color);
+ } else if (ui::MaterialDesignController::IsModeMaterial()) {
+ DrawScaledRoundRect(canvas, SkPaint::kFill_Style, color, bounds);
} else {
SkPaint paint;
paint.setStyle(SkPaint::kFill_Style);
@@ -1290,28 +1318,8 @@ void LocationBarView::PaintChildren(const ui::PaintContext& context) {
border_rect.Inset(-kPopupEdgeThickness, 0);
if (ui::MaterialDesignController::IsModeMaterial()) {
- gfx::Canvas* canvas = recorder.canvas();
- const float display_scale = canvas->image_scale();
- canvas->Save();
- SkScalar scale_factor = 1.0f / display_scale;
- canvas->sk_canvas()->scale(scale_factor, scale_factor);
-
- SkPaint paint;
- paint.setStyle(SkPaint::Style::kStroke_Style);
- paint.setColor(SkColorSetARGB(0x40, 0x00, 0x00, 0x00));
- paint.setStrokeWidth(1);
- paint.setAntiAlias(true);
-
- const float kOffset = 0.5f;
- gfx::RectF border_rect_f(border_rect);
- border_rect_f.Scale(display_scale);
- gfx::InsetsF insets(kOffset, kOffset, kOffset, kOffset);
- border_rect_f.Inset(insets);
-
- const SkScalar kCornerRadius = SkDoubleToScalar(2.5f * display_scale);
- canvas->sk_canvas()->drawRoundRect(gfx::RectFToSkRect(border_rect_f),
- kCornerRadius, kCornerRadius, paint);
- recorder.canvas()->Restore();
+ DrawScaledRoundRect(recorder.canvas(), SkPaint::Style::kStroke_Style,
+ SkColorSetARGB(0x40, 0x00, 0x00, 0x00), border_rect);
Peter Kasting 2015/10/08 21:33:06 I don't think this is right for popup windows, whe
jonross 2015/10/09 15:14:17 I looked at the spec, to get the desired alpha ble
Peter Kasting 2015/10/09 16:03:32 That's what I thought. There are several ways to
} else {
views::Painter::PaintPainterAt(recorder.canvas(), border_painter_.get(),
border_rect);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698