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

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

Issue 2102853002: [Mac][Material Design] Adjust (i) and lock Omnibox icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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
Index: chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm b/chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm
index ed67727500412742814b1f05f58e1b8fc9fcb07c..12969eec6bb848e9b3d546331c3e549a8763a0b8 100644
--- a/chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm
@@ -12,6 +12,7 @@
#include "skia/ext/skia_utils_mac.h"
#import "ui/base/cocoa/nsview_additions.h"
#include "ui/base/material_design/material_design_controller.h"
+#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
namespace {
@@ -38,7 +39,7 @@ const CGFloat kBackgroundYInset = 4.0;
} // namespace
-BubbleDecoration::BubbleDecoration() : baseline_offset_(0) {
+BubbleDecoration::BubbleDecoration() : retina_baseline_offset_(0) {
attributes_.reset([[NSMutableDictionary alloc] init]);
[attributes_ setObject:LocationBarDecoration::GetFont()
forKey:NSFontAttributeName];
@@ -132,8 +133,16 @@ void BubbleDecoration::DrawInFrame(NSRect frame, NSView* control_view) {
if (label_) {
NSRect textRect = frame;
textRect.origin.x = textOffset;
- textRect.origin.y += baseline_offset_;
textRect.size.width = NSMaxX(decoration_frame) - NSMinX(textRect);
+ // Transform the coordinate system to adjust the baseline on Retina. This is
+ // the only way to get fractional adjustments.
+ gfx::ScopedNSGraphicsContextSaveGState saveGraphicsState;
+ CGFloat lineWidth = [control_view cr_lineWidth];
+ if (lineWidth < 1) {
+ NSAffineTransform* transform = [NSAffineTransform transform];
+ [transform translateXBy:0 yBy:retina_baseline_offset_];
+ [transform concat];
+ }
DrawLabel(label_, attributes_, textRect);
}
}
@@ -179,6 +188,6 @@ void BubbleDecoration::SetFont(NSFont* font) {
[attributes_ setObject:font forKey:NSFontAttributeName];
}
-void BubbleDecoration::SetBaselineOffset(CGFloat offset) {
- baseline_offset_ = offset;
+void BubbleDecoration::SetRetinaBaselineOffset(CGFloat offset) {
+ retina_baseline_offset_ = offset;
}
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/bubble_decoration.h ('k') | chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698