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