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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm

Issue 1948963002: [Mac][Material Design] Fix toolbar height on Retina. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/mac_util.h" 8 #import "base/mac/mac_util.h"
9 #import "base/mac/sdk_forward_declarations.h" 9 #import "base/mac/sdk_forward_declarations.h"
10 #include "chrome/browser/themes/theme_service.h" 10 #include "chrome/browser/themes/theme_service.h"
11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" 12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
13 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" 13 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
14 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h" 14 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h"
15 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 15 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
16 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 16 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
17 #import "chrome/browser/ui/cocoa/url_drop_target.h" 17 #import "chrome/browser/ui/cocoa/url_drop_target.h"
18 #import "chrome/browser/ui/cocoa/view_id_util.h" 18 #import "chrome/browser/ui/cocoa/view_id_util.h"
19 #import "ui/base/cocoa/nsview_additions.h" 19 #import "ui/base/cocoa/nsview_additions.h"
20 #include "ui/base/material_design/material_design_controller.h" 20 #include "ui/base/material_design/material_design_controller.h"
21 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 21 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
22 22
23 namespace { 23 namespace {
24 const CGFloat kAnimationDuration = 0.2; 24 const CGFloat kAnimationDuration = 0.2;
25 const CGFloat kShadowInset = 3; 25 const CGFloat kShadowInset = 3;
26 const CGFloat kShadowColor = 69 / 255.;
27 26
28 } 27 }
29 28
30 // A view that draws a 1px shadow line beneath the autocomplete textfield. 29 // A view that draws a 1px shadow line beneath the autocomplete textfield.
31 @interface AutocompleteTextFieldShadowView : NSView { 30 @interface AutocompleteTextFieldShadowView : NSView {
32 @private 31 @private
33 AutocompleteTextField* textField_; // Weak. Owns this. 32 AutocompleteTextField* textField_; // Weak. Owns this.
34 } 33 }
35 // This is the designated initializer for AutocompleteTextFieldShadowView. 34 // This is the designated initializer for AutocompleteTextFieldShadowView.
36 - (instancetype)initWithTextField:(AutocompleteTextField*)aTextField; 35 - (instancetype)initWithTextField:(AutocompleteTextField*)aTextField;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 [self adjustFrame]; 78 [self adjustFrame];
80 } 79 }
81 80
82 - (void)drawRect:(NSRect)rect { 81 - (void)drawRect:(NSRect)rect {
83 // Don't draw anything on a Retina display because on Retina there's room 82 // Don't draw anything on a Retina display because on Retina there's room
84 // for the shadow just beneath the autocomplete textfield path stroke. Why 83 // for the shadow just beneath the autocomplete textfield path stroke. Why
85 // even add this view? If the user drags the Incognito window between Retina 84 // even add this view? If the user drags the Incognito window between Retina
86 // and non-Retina screens there would have to be logic to add and remove the 85 // and non-Retina screens there would have to be logic to add and remove the
87 // view. It's easier just to always add it for Incognito mode and draw 86 // view. It's easier just to always add it for Incognito mode and draw
88 // nothing into it. 87 // nothing into it.
89 if (![[self window] inIncognitoMode] || [self cr_lineWidth] < 1) { 88 if (![[self window] inIncognitoModeWithSystemTheme] ||
89 [self cr_lineWidth] < 1) {
90 return; 90 return;
91 } 91 }
92 [[AutocompleteTextField shadowColor] set]; 92 [[AutocompleteTextField shadowColor] set];
93 NSRectFill(rect); 93 NSRectFillUsingOperation(rect, NSCompositeSourceOver);
94 } 94 }
95 95
96 @end 96 @end
97 97
98 @implementation AutocompleteTextField 98 @implementation AutocompleteTextField
99 99
100 @synthesize observer = observer_; 100 @synthesize observer = observer_;
101 101
102 + (Class)cellClass { 102 + (Class)cellClass {
103 return [AutocompleteTextFieldCell class]; 103 return [AutocompleteTextFieldCell class];
104 } 104 }
105 105
106 + (NSColor*)shadowColor { 106 + (NSColor*)shadowColor {
107 return [NSColor colorWithGenericGamma22White:kShadowColor alpha:1]; 107 return [NSColor colorWithGenericGamma22White:0 alpha:0.14];
108 } 108 }
109 109
110 - (void)dealloc { 110 - (void)dealloc {
111 [[NSNotificationCenter defaultCenter] removeObserver:self]; 111 [[NSNotificationCenter defaultCenter] removeObserver:self];
112 [shadowView_ removeFromSuperview]; 112 [shadowView_ removeFromSuperview];
113 [super dealloc]; 113 [super dealloc];
114 } 114 }
115 115
116 - (void)awakeFromNib { 116 - (void)awakeFromNib {
117 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]); 117 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]);
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 NSMinY(frame), 665 NSMinY(frame),
666 suggestWidth, 666 suggestWidth,
667 NSHeight(frame)); 667 NSHeight(frame));
668 668
669 gfx::ScopedNSGraphicsContextSaveGState saveGState; 669 gfx::ScopedNSGraphicsContextSaveGState saveGState;
670 NSRectClip(suggestRect); 670 NSRectClip(suggestRect);
671 [cell drawInteriorWithFrame:frame inView:controlView]; 671 [cell drawInteriorWithFrame:frame inView:controlView];
672 } 672 }
673 673
674 } // namespace autocomplete_text_field 674 } // namespace autocomplete_text_field
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm ('k') | chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698