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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/autofill_suggestion_container.mm

Issue 58823002: [rAC, OSX] Fixed field width for suggest input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/autofill/autofill_suggestion_container.h" 5 #import "chrome/browser/ui/cocoa/autofill/autofill_suggestion_container.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac/scoped_nsobject.h" 11 #include "base/mac/scoped_nsobject.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" 13 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h"
14 #include "chrome/browser/ui/chrome_style.h" 14 #include "chrome/browser/ui/chrome_style.h"
15 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h"
15 #import "chrome/browser/ui/cocoa/autofill/autofill_textfield.h" 16 #import "chrome/browser/ui/cocoa/autofill/autofill_textfield.h"
16 #include "skia/ext/skia_utils_mac.h" 17 #include "skia/ext/skia_utils_mac.h"
17 18
18 namespace { 19 namespace {
19 20
20 // Horizontal padding between text and other elements (in pixels). 21 // Horizontal padding between text and other elements (in pixels).
21 const int kAroundTextPadding = 4; 22 const int kAroundTextPadding = 4;
22 23
23 // Vertical padding between individual elements. 24 // Vertical padding between individual elements.
24 const int kVerticalPadding = 8; 25 const int kVerticalPadding = 8;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 102
102 [label_ sizeToFit]; 103 [label_ sizeToFit];
103 [label2_ sizeToFit]; 104 [label2_ sizeToFit];
104 } 105 }
105 106
106 - (void)showInputField:(NSString*)text withIcon:(NSImage*)icon { 107 - (void)showInputField:(NSString*)text withIcon:(NSImage*)icon {
107 [[inputField_ cell] setPlaceholderString:text]; 108 [[inputField_ cell] setPlaceholderString:text];
108 [[inputField_ cell] setIcon:icon]; 109 [[inputField_ cell] setIcon:icon];
109 [inputField_ setHidden:NO]; 110 [inputField_ setHidden:NO];
110 [inputField_ sizeToFit]; 111 [inputField_ sizeToFit];
112
113 // Enforce fixed width.
114 NSSize frameSize = NSMakeSize(autofill::kFieldWidth,
115 NSHeight([inputField_ frame]));
116 [inputField_ setFrameSize:frameSize];
111 } 117 }
112 118
113 - (NSSize)preferredSizeForFirstLine { 119 - (NSSize)preferredSizeForFirstLine {
114 NSSize size = [label_ bounds].size; 120 NSSize size = [label_ bounds].size;
115 if (![iconImageView_ isHidden]) { 121 if (![iconImageView_ isHidden]) {
116 size.height = std::max(size.height, NSHeight([iconImageView_ frame])); 122 size.height = std::max(size.height, NSHeight([iconImageView_ frame]));
117 size.width += NSWidth([iconImageView_ frame]) + kAroundTextPadding; 123 size.width += NSWidth([iconImageView_ frame]) + kAroundTextPadding;
118 } 124 }
119 // Final inputField_ sizing/spacing depends on a TODO(estade) in Views code. 125 // Final inputField_ sizing/spacing depends on a TODO(estade) in Views code.
120 if (![inputField_ isHidden]) { 126 if (![inputField_ isHidden]) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 192
187 [spacer_ setFrame:spacerFrame]; 193 [spacer_ setFrame:spacerFrame];
188 [label_ setFrame:labelFrame]; 194 [label_ setFrame:labelFrame];
189 [label2_ setFrameOrigin:NSMakePoint( 195 [label2_ setFrameOrigin:NSMakePoint(
190 0, 196 0,
191 NSMinY(lineFrame) - kAroundTextPadding - NSHeight([label2_ frame]))]; 197 NSMinY(lineFrame) - kAroundTextPadding - NSHeight([label2_ frame]))];
192 [[self view] setFrameSize:preferredContainerSize]; 198 [[self view] setFrameSize:preferredContainerSize];
193 } 199 }
194 200
195 @end 201 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698