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

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

Issue 2294733004: Revert of [Mac][Material Design] Fix toolbar height on Retina. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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.;
26 27
27 } 28 }
28 29
29 // A view that draws a 1px shadow line beneath the autocomplete textfield. 30 // A view that draws a 1px shadow line beneath the autocomplete textfield.
30 @interface AutocompleteTextFieldShadowView : NSView { 31 @interface AutocompleteTextFieldShadowView : NSView {
31 @private 32 @private
32 AutocompleteTextField* textField_; // Weak. Owns this. 33 AutocompleteTextField* textField_; // Weak. Owns this.
33 } 34 }
34 // This is the designated initializer for AutocompleteTextFieldShadowView. 35 // This is the designated initializer for AutocompleteTextFieldShadowView.
35 - (instancetype)initWithTextField:(AutocompleteTextField*)aTextField; 36 - (instancetype)initWithTextField:(AutocompleteTextField*)aTextField;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 [self adjustFrame]; 79 [self adjustFrame];
79 } 80 }
80 81
81 - (void)drawRect:(NSRect)rect { 82 - (void)drawRect:(NSRect)rect {
82 // Don't draw anything on a Retina display because on Retina there's room 83 // Don't draw anything on a Retina display because on Retina there's room
83 // for the shadow just beneath the autocomplete textfield path stroke. Why 84 // for the shadow just beneath the autocomplete textfield path stroke. Why
84 // even add this view? If the user drags the Incognito window between Retina 85 // even add this view? If the user drags the Incognito window between Retina
85 // and non-Retina screens there would have to be logic to add and remove the 86 // and non-Retina screens there would have to be logic to add and remove the
86 // view. It's easier just to always add it for Incognito mode and draw 87 // view. It's easier just to always add it for Incognito mode and draw
87 // nothing into it. 88 // nothing into it.
88 if (![[self window] inIncognitoModeWithSystemTheme] || 89 if (![[self window] inIncognitoMode] || [self cr_lineWidth] < 1) {
89 [self cr_lineWidth] < 1) {
90 return; 90 return;
91 } 91 }
92 [[AutocompleteTextField shadowColor] set]; 92 [[AutocompleteTextField shadowColor] set];
93 NSRectFillUsingOperation(rect, NSCompositeSourceOver); 93 NSRectFill(rect);
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:0 alpha:0.14]; 107 return [NSColor colorWithGenericGamma22White:kShadowColor alpha:1];
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