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

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

Issue 2172713002: Adjust BackgroundWith1PxBorder to better handle fractional scale factors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 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/background_with_1_px_border.cc
diff --git a/chrome/browser/ui/views/location_bar/background_with_1_px_border.cc b/chrome/browser/ui/views/location_bar/background_with_1_px_border.cc
index c0cb9fb6780953c44a4086255ccb40e1094df71d..d489a3b20066b066e63f66ce8334654067216182 100644
--- a/chrome/browser/ui/views/location_bar/background_with_1_px_border.cc
+++ b/chrome/browser/ui/views/location_bar/background_with_1_px_border.cc
@@ -26,9 +26,15 @@ void BackgroundWith1PxBorder::Paint(gfx::Canvas* canvas,
gfx::ScopedCanvas scoped_canvas(canvas);
const float scale = canvas->UndoDeviceScaleFactor();
border_rect_f.Scale(scale);
- const float inset =
- GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS) * scale - 0.5f;
- border_rect_f.Inset(inset, inset);
+ // Draw the border as a 1px thick line aligned with the inside edge of the
+ // LOCATION_BAR_BORDER_THICKNESS region. This line needs to be snapped to the
+ // pixel grid, so the result of the scale-up needs to be snapped to an integer
+ // value. Using floor() instead of round() ensures that, for non-integral
+ // scale factors, the border will still be drawn inside the BORDER_THICKNESS
+ // region instead of being partially inside it.
+ border_rect_f.Inset(gfx::InsetsF(
+ std::floor(GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS) * scale) -
+ 0.5f));
SkPath path;
const SkScalar scaled_corner_radius =
« 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