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

Unified Diff: chrome/browser/ui/cocoa/location_bar/security_state_bubble_decoration.mm

Issue 2861653004: [Mac] Adjust the size, position and color of security indicator divider. (Closed)
Patch Set: Adjustments for non-Retina. Created 3 years, 7 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 | « chrome/browser/ui/cocoa/location_bar/location_bar_decoration.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/location_bar/security_state_bubble_decoration.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/security_state_bubble_decoration.mm b/chrome/browser/ui/cocoa/location_bar/security_state_bubble_decoration.mm
index 2a8efd6d0a80757f4b46226debf7ec729781568f..f3878f1f5b8465edc537281c7fc76aa2f7fb754d 100644
--- a/chrome/browser/ui/cocoa/location_bar/security_state_bubble_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/security_state_bubble_decoration.mm
@@ -32,6 +32,9 @@ namespace {
// Padding between the label and icon/divider.
CGFloat kLabelPadding = 4.0;
+// Divider height.
+CGFloat kDividerHeight = 16.0;
+
// Inset for the background.
const CGFloat kBackgroundYInset = 4.0;
@@ -232,15 +235,29 @@ void SecurityStateBubbleDecoration::DrawInFrame(NSRect frame,
// Draw the divider.
if (state() == DecorationMouseState::NONE && !active()) {
- const CGFloat divider_x_position =
- is_rtl ? NSMinX(decoration_frame) + DividerPadding()
- : NSMaxX(decoration_frame) - DividerPadding();
NSBezierPath* line = [NSBezierPath bezierPath];
[line setLineWidth:line_width];
- [line moveToPoint:NSMakePoint(divider_x_position,
- NSMinY(decoration_frame))];
- [line lineToPoint:NSMakePoint(divider_x_position,
- NSMaxY(decoration_frame))];
+ NSPoint divider_origin = NSZeroPoint;
+ divider_origin.x = is_rtl ? NSMinX(decoration_frame) + DividerPadding()
+ : NSMaxX(decoration_frame) - DividerPadding();
+ // Screen pixels lay between integral coordinates in user space. If you
+ // draw a line from (16, 16) to (16, 32), Core Graphics maps that line to
+ // the pixels that lay along x=16.5. In order to achieve a line that
+ // appears to lay along x=16, CG will perform dithering. To get a crisp
+ // line, you have to specify x=16.5, so translating by 1/2 the 1-pixel
+ // line width creates the crisp line we want. We subtract to better center
+ // the line between the label and URL.
+ divider_origin.x -= line_width / 2.;
+ CGFloat divider_y_frame_offset =
+ (NSHeight(decoration_frame) - kDividerHeight) / 2.0;
+ divider_origin.y = NSMinY(decoration_frame) + divider_y_frame_offset;
+ // Adjust the divider origin by 1/2 a point to visually center the
+ // divider vertically on Retina.
+ if (line_width < 1) {
+ divider_origin.y -= 0.5;
+ }
+ [line moveToPoint:divider_origin];
+ [line relativeLineToPoint:NSMakePoint(0, kDividerHeight)];
NSColor* divider_color = GetDividerColor(in_dark_mode);
CGFloat divider_alpha =
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/location_bar_decoration.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698