| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |