Commit 3e034359 authored by groby@chromium.org's avatar groby@chromium.org

[rAC, OSX] Namespaced constants.

Keep autofill dialog related constants in named namespace.

BUG=none

Review URL: https://chromiumcodereview.appspot.com/23546007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221755 0039d316-1c4b-4281-b951-d872f2087c98
parent 32e29a29
...@@ -144,7 +144,7 @@ void AddMenuItem(NSMenu *menu, id target, SEL selector, NSString* title, ...@@ -144,7 +144,7 @@ void AddMenuItem(NSMenu *menu, id target, SEL selector, NSString* title,
[activeControl setFrame:frame]; [activeControl setFrame:frame];
[icon_ setFrameSize:[[icon_ image] size]]; [icon_ setFrameSize:[[icon_ image] size]];
frame.origin.x -= NSWidth([icon_ frame]) + kAroundTextPadding; frame.origin.x -= NSWidth([icon_ frame]) + autofill::kAroundTextPadding;
[icon_ setFrameOrigin:frame.origin]; [icon_ setFrameOrigin:frame.origin];
} }
......
...@@ -341,7 +341,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( ...@@ -341,7 +341,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed(
NSSize headerSize = NSMakeSize(contentSize.width, kAccountChooserHeight); NSSize headerSize = NSMakeSize(contentSize.width, kAccountChooserHeight);
NSSize size = NSMakeSize( NSSize size = NSMakeSize(
std::max(contentSize.width, headerSize.width), std::max(contentSize.width, headerSize.width),
contentSize.height + headerSize.height + kDetailTopPadding); contentSize.height + headerSize.height + autofill::kDetailTopPadding);
size.width += 2 * chrome_style::kHorizontalPadding; size.width += 2 * chrome_style::kHorizontalPadding;
size.height += chrome_style::kClientBottomPadding + size.height += chrome_style::kClientBottomPadding +
chrome_style::kTitleTopPadding; chrome_style::kTitleTopPadding;
...@@ -362,7 +362,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( ...@@ -362,7 +362,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed(
// equivalent to the height of the header. Clarify with UX what the final // equivalent to the height of the header. Clarify with UX what the final
// padding will be. // padding will be.
if (height != 0.0) { if (height != 0.0) {
size.height = height + headerSize.height + kDetailTopPadding; size.height = height + headerSize.height + autofill::kDetailTopPadding;
} }
} }
...@@ -382,7 +382,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( ...@@ -382,7 +382,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed(
NSDivideRect(clientRect, &headerRect, &mainRect, NSDivideRect(clientRect, &headerRect, &mainRect,
kAccountChooserHeight, NSMinYEdge); kAccountChooserHeight, NSMinYEdge);
NSDivideRect(mainRect, &dummyRect, &mainRect, NSDivideRect(mainRect, &dummyRect, &mainRect,
kDetailTopPadding, NSMinYEdge); autofill::kDetailTopPadding, NSMinYEdge);
[accountChooser_ setFrame:headerRect]; [accountChooser_ setFrame:headerRect];
if ([[signInContainer_ view] isHidden]) { if ([[signInContainer_ view] isHidden]) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_CONSTANTS__H_ #define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_CONSTANTS__H_
// Constants governing layout of autofill dialog. // Constants governing layout of autofill dialog.
namespace { namespace autofill {
// Horizontal padding between text and other elements (in pixels). // Horizontal padding between text and other elements (in pixels).
const CGFloat kAroundTextPadding = 4; const CGFloat kAroundTextPadding = 4;
...@@ -31,6 +31,6 @@ const int kDetailTopPadding = 20; ...@@ -31,6 +31,6 @@ const int kDetailTopPadding = 20;
// Padding between the bottom of the details section and the button strip. // Padding between the bottom of the details section and the button strip.
const int kDetailBottomPadding = 30; const int kDetailBottomPadding = 30;
} // namespace } // autofill
#endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_CONSTANTS__H_ #endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_CONSTANTS__H_
...@@ -104,12 +104,12 @@ ...@@ -104,12 +104,12 @@
NSSize size = NSMakeSize(std::max(buttonSize.width, detailsSize.width), NSSize size = NSMakeSize(std::max(buttonSize.width, detailsSize.width),
buttonSize.height + detailsSize.height); buttonSize.height + detailsSize.height);
size.height += kDetailBottomPadding; size.height += autofill::kDetailBottomPadding;
if (![legalDocumentsView_ isHidden]) { if (![legalDocumentsView_ isHidden]) {
NSSize legalDocumentSize = NSSize legalDocumentSize =
[self preferredLegalDocumentSizeForWidth:detailsSize.width]; [self preferredLegalDocumentSizeForWidth:detailsSize.width];
size.height += legalDocumentSize.height + kVerticalSpacing; size.height += legalDocumentSize.height + autofill::kVerticalSpacing;
} }
NSSize notificationSize = NSSize notificationSize =
...@@ -125,7 +125,8 @@ ...@@ -125,7 +125,8 @@
if (![legalDocumentsView_ isHidden]) { if (![legalDocumentsView_ isHidden]) {
[legalDocumentsView_ setFrameSize: [legalDocumentsView_ setFrameSize:
[self preferredLegalDocumentSizeForWidth:NSWidth(bounds)]]; [self preferredLegalDocumentSizeForWidth:NSWidth(bounds)]];
currentY = NSMaxY([legalDocumentsView_ frame]) + kVerticalSpacing; currentY = NSMaxY([legalDocumentsView_ frame]) +
autofill::kVerticalSpacing;
} }
NSRect buttonFrame = [buttonContainer_ frame]; NSRect buttonFrame = [buttonContainer_ frame];
...@@ -136,7 +137,7 @@ ...@@ -136,7 +137,7 @@
checkboxFrame.origin.y = NSMidY(buttonFrame) - NSHeight(checkboxFrame) / 2.0; checkboxFrame.origin.y = NSMidY(buttonFrame) - NSHeight(checkboxFrame) / 2.0;
[saveInChromeCheckbox_ setFrameOrigin:checkboxFrame.origin]; [saveInChromeCheckbox_ setFrameOrigin:checkboxFrame.origin];
currentY = NSMaxY(buttonFrame) + kDetailBottomPadding; currentY = NSMaxY(buttonFrame) + autofill::kDetailBottomPadding;
NSRect notificationFrame = NSZeroRect; NSRect notificationFrame = NSZeroRect;
notificationFrame.size = [notificationContainer_ preferredSizeForWidth: notificationFrame.size = [notificationContainer_ preferredSizeForWidth:
...@@ -152,7 +153,7 @@ ...@@ -152,7 +153,7 @@
[detailsContainer_ performLayout]; [detailsContainer_ performLayout];
notificationFrame.origin = notificationFrame.origin =
NSMakePoint(0, NSMaxY(containerFrame) + kDetailTopPadding); NSMakePoint(0, NSMaxY(containerFrame) + autofill::kDetailTopPadding);
[[notificationContainer_ view] setFrame:notificationFrame]; [[notificationContainer_ view] setFrame:notificationFrame];
[notificationContainer_ performLayout]; [notificationContainer_ performLayout];
} }
...@@ -175,7 +176,7 @@ ...@@ -175,7 +176,7 @@
[button sizeToFit]; [button sizeToFit];
[buttonContainer_ addSubview:button]; [buttonContainer_ addSubview:button];
CGFloat nextX = NSMaxX([button frame]) + kButtonGap; CGFloat nextX = NSMaxX([button frame]) + autofill::kButtonGap;
button.reset([[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); button.reset([[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
[button setFrameOrigin:NSMakePoint(nextX, 0)]; [button setFrameOrigin:NSMakePoint(nextX, 0)];
[button setTitle:l10n_util::GetNSStringWithFixup( [button setTitle:l10n_util::GetNSStringWithFixup(
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
// If the first notification doesn't have an arrow, reserve empty space. // If the first notification doesn't have an arrow, reserve empty space.
if (![[notificationControllers_ objectAtIndex:0] hasArrow]) if (![[notificationControllers_ objectAtIndex:0] hasArrow])
preferredSize.height += kArrowHeight; preferredSize.height += autofill::kArrowHeight;
for (AutofillNotificationController* delegate in for (AutofillNotificationController* delegate in
notificationControllers_.get()) notificationControllers_.get())
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
NSRect remaining = [[self view] bounds]; NSRect remaining = [[self view] bounds];
if (![[notificationControllers_ objectAtIndex:0] hasArrow]) if (![[notificationControllers_ objectAtIndex:0] hasArrow])
remaining.size.height -= kArrowHeight; remaining.size.height -= autofill::kArrowHeight;
for (AutofillNotificationController* delegate in for (AutofillNotificationController* delegate in
notificationControllers_.get()) { notificationControllers_.get()) {
......
...@@ -41,12 +41,13 @@ ...@@ -41,12 +41,13 @@
NSBezierPath* arrow = [NSBezierPath bezierPath]; NSBezierPath* arrow = [NSBezierPath bezierPath];
[arrow moveToPoint:anchorPoint]; [arrow moveToPoint:anchorPoint];
[arrow relativeLineToPoint:NSMakePoint(-kArrowWidth / 2.0, -kArrowHeight)]; [arrow relativeLineToPoint:
[arrow relativeLineToPoint:NSMakePoint(kArrowWidth, 0)]; NSMakePoint(-autofill::kArrowWidth / 2.0, -autofill::kArrowHeight)];
[arrow relativeLineToPoint:NSMakePoint(autofill::kArrowWidth, 0)];
[arrow closePath]; [arrow closePath];
[backgroundColor_ setFill]; [backgroundColor_ setFill];
[arrow fill]; [arrow fill];
backgroundRect.size.height -= kArrowHeight; backgroundRect.size.height -= autofill::kArrowHeight;
} }
dirtyRect = NSIntersectionRect(backgroundRect, dirtyRect); dirtyRect = NSIntersectionRect(backgroundRect, dirtyRect);
...@@ -149,9 +150,9 @@ ...@@ -149,9 +150,9 @@
} }
if ([[self notificationView] hasArrow]) if ([[self notificationView] hasArrow])
preferredSize.height += kArrowHeight; preferredSize.height += autofill::kArrowHeight;
preferredSize.height += 2 * kNotificationPadding; preferredSize.height += 2 * autofill::kNotificationPadding;
return preferredSize; return preferredSize;
} }
...@@ -163,9 +164,9 @@ ...@@ -163,9 +164,9 @@
- (void)performLayout { - (void)performLayout {
NSRect bounds = [[self view] bounds]; NSRect bounds = [[self view] bounds];
if ([[self notificationView] hasArrow]) if ([[self notificationView] hasArrow])
bounds.size.height -= kArrowHeight; bounds.size.height -= autofill::kArrowHeight;
NSRect textFrame = NSInsetRect(bounds, 0, kNotificationPadding); NSRect textFrame = NSInsetRect(bounds, 0, autofill::kNotificationPadding);
if (![checkbox_ isHidden]) { if (![checkbox_ isHidden]) {
// Temporarily resize checkbox to just the box, no extra clickable area. // Temporarily resize checkbox to just the box, no extra clickable area.
textFrame.origin.x += checkboxSizeWithoutTitle_.width; textFrame.origin.x += checkboxSizeWithoutTitle_.width;
......
...@@ -114,9 +114,9 @@ void OverlayTimerBridge::UpdateOverlayState() { ...@@ -114,9 +114,9 @@ void OverlayTimerBridge::UpdateOverlayState() {
NSColor* shadingColor = gfx::SkColorToCalibratedNSColor(kShadingColor); NSColor* shadingColor = gfx::SkColorToCalibratedNSColor(kShadingColor);
NSColor* borderColor = gfx::SkColorToCalibratedNSColor(kSubtleBorderColor); NSColor* borderColor = gfx::SkColorToCalibratedNSColor(kSubtleBorderColor);
CGFloat arrowHalfWidth = kArrowWidth / 2.0; CGFloat arrowHalfWidth = autofill::kArrowWidth / 2.0;
NSRect bounds = [self bounds]; NSRect bounds = [self bounds];
CGFloat y = NSMaxY(bounds) - kArrowHeight; CGFloat y = NSMaxY(bounds) - autofill::kArrowHeight;
NSBezierPath* arrow = [NSBezierPath bezierPath]; NSBezierPath* arrow = [NSBezierPath bezierPath];
// Note that we purposely draw slightly outside of |bounds| so that the // Note that we purposely draw slightly outside of |bounds| so that the
...@@ -126,8 +126,10 @@ void OverlayTimerBridge::UpdateOverlayState() { ...@@ -126,8 +126,10 @@ void OverlayTimerBridge::UpdateOverlayState() {
[arrow moveToPoint:NSMakePoint(NSMinX(arrowBounds), y)]; [arrow moveToPoint:NSMakePoint(NSMinX(arrowBounds), y)];
[arrow lineToPoint: [arrow lineToPoint:
NSMakePoint(NSMidX(arrowBounds) - arrowHalfWidth, y)]; NSMakePoint(NSMidX(arrowBounds) - arrowHalfWidth, y)];
[arrow relativeLineToPoint:NSMakePoint(arrowHalfWidth, kArrowHeight)]; [arrow relativeLineToPoint:
[arrow relativeLineToPoint:NSMakePoint(arrowHalfWidth, -kArrowHeight)]; NSMakePoint(arrowHalfWidth,autofill::kArrowHeight)];
[arrow relativeLineToPoint:
NSMakePoint(arrowHalfWidth, -autofill::kArrowHeight)];
[arrow lineToPoint:NSMakePoint(NSMaxX(arrowBounds), y)]; [arrow lineToPoint:NSMakePoint(NSMaxX(arrowBounds), y)];
[arrow lineToPoint:NSMakePoint(NSMaxX(arrowBounds), NSMinY(arrowBounds))]; [arrow lineToPoint:NSMakePoint(NSMaxX(arrowBounds), NSMinY(arrowBounds))];
[arrow lineToPoint:NSMakePoint(NSMinX(arrowBounds), NSMinY(arrowBounds))]; [arrow lineToPoint:NSMakePoint(NSMinX(arrowBounds), NSMinY(arrowBounds))];
...@@ -145,7 +147,7 @@ void OverlayTimerBridge::UpdateOverlayState() { ...@@ -145,7 +147,7 @@ void OverlayTimerBridge::UpdateOverlayState() {
height += NSHeight([label frame]); height += NSHeight([label frame]);
height += kOverlayTextInterlineSpacing; height += kOverlayTextInterlineSpacing;
} }
return height + kArrowHeight; return height + autofill::kArrowHeight;
} }
- (void)setMessages: - (void)setMessages:
...@@ -175,8 +177,8 @@ void OverlayTimerBridge::UpdateOverlayState() { ...@@ -175,8 +177,8 @@ void OverlayTimerBridge::UpdateOverlayState() {
} }
- (void)performLayout { - (void)performLayout {
CGFloat y = CGFloat y = NSMaxY([self bounds]) - autofill::kArrowHeight -
NSMaxY([self bounds]) - kArrowHeight - kOverlayTextInterlineSpacing; kOverlayTextInterlineSpacing;
for (NSTextView* label in [self subviews]) { for (NSTextView* label in [self subviews]) {
DCHECK([label isKindOfClass:[NSTextView class]]); DCHECK([label isKindOfClass:[NSTextView class]]);
CGFloat labelHeight = NSHeight([label frame]); CGFloat labelHeight = NSHeight([label frame]);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
NSAttributedString* title = [self attributedTitle]; NSAttributedString* title = [self attributedTitle];
NSSize size = [title size]; NSSize size = [title size];
size.height = std::max(size.height, imageSize.height); size.height = std::max(size.height, imageSize.height);
size.width += kButtonGap + imageSize.width; size.width += autofill::kButtonGap + imageSize.width;
return size; return size;
} }
......
...@@ -60,7 +60,7 @@ TEST_F(DownArrowPopupMenuCellTest, Defaults) { ...@@ -60,7 +60,7 @@ TEST_F(DownArrowPopupMenuCellTest, Defaults) {
NSAttributedString* title = [cell attributedTitle]; NSAttributedString* title = [cell attributedTitle];
NSSize titleSize = [title size]; NSSize titleSize = [title size];
EXPECT_EQ(titleSize.width + [image size].width + kButtonGap, EXPECT_EQ(titleSize.width + [image size].width + autofill::kButtonGap,
[cell cellSize].width); [cell cellSize].width);
EXPECT_EQ(std::max(titleSize.height, [image size].height), EXPECT_EQ(std::max(titleSize.height, [image size].height),
[cell cellSize].height); [cell cellSize].height);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment