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

Unified Diff: chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm

Issue 2283753003: Material page info (Mac, 1/3): Update section padding variables. (Closed)
Patch Set: Also move constant grouping comments into this CL. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
diff --git a/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm b/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
index 1968d1ecb64a3189e851d3fd0c660e8d6e84e1da..1d47e9eada6a1a740e1c812f4c3d0f895db5acbd 100644
--- a/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
+++ b/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
@@ -58,31 +58,29 @@ using ChosenObjectDeleteCallback =
namespace {
+/**************** General ****************/
+
// The default width of the window, in view coordinates. It may be larger to
// fit the content.
-const CGFloat kDefaultWindowWidth = 310;
-
-// Padding between the window frame and content.
-const CGFloat kFramePadding = 20;
-
-// Padding between the window frame and content.
-const CGFloat kVerticalSectionMargin = 16;
+const CGFloat kDefaultWindowWidth = 320;
-// Padding between the window frame and content for the internal page bubble.
-const CGFloat kInternalPageFramePadding = 10;
+// Padding around each section
+const CGFloat kSectionVerticalPadding = 20;
+const CGFloat kSectionHorizontalPadding = 16;
// Spacing between the identity field and the security summary.
const CGFloat kSpacingBeforeSecuritySummary = 2;
+/**************** Security Section ****************/
+
// Spacing between the security summary and the reset decisions button.
const CGFloat kSpacingBeforeResetDecisionsButton = 8;
+/**************** Site Settings Section ****************/
+
// Spacing between parts of the site settings section.
const CGFloat kSiteSettingsSectionSpacing = 2;
-// Spacing between the image and text for internal pages.
-const CGFloat kInternalPageImageSpacing = 10;
-
// Square size of the permission images.
const CGFloat kPermissionImageSize = 19;
@@ -109,6 +107,16 @@ const CGFloat kPermissionPopUpXSpacing = 3;
// |IDS_WEBSITE_SETTINGS_{FIRST,THIRD}_PARTY_SITE_DATA| next to each other.
const CGFloat kTextLabelXPadding = 5;
+/**************** Internal Page Bubble ****************/
+
+// Padding between the window frame and content for the internal page bubble.
+const CGFloat kInternalPageFramePadding = 10;
+
+// Spacing between the image and text for internal pages.
+const CGFloat kInternalPageImageSpacing = 10;
+
+/********************************/
+
// NOTE: This assumes that there will never be more than one website settings
// popup shown, and that the one that is shown is associated with the current
// window. This matches the behaviour in views: see WebsiteSettingsPopupView.
@@ -316,7 +324,7 @@ bool IsInternalURL(const GURL& url) {
// Create a controlOrigin to place the text fields. The y value doesn't
// matter, because the correct value is calculated in -performLayout.
- NSPoint controlOrigin = NSMakePoint(kFramePadding, 0);
+ NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0);
// Create a text field (empty for now) to show the site identity.
identityField_ = [self addText:base::string16()
@@ -459,20 +467,17 @@ bool IsInternalURL(const GURL& url) {
[self setWidthOfView:securitySectionView_ to:contentWidth];
[self setWidthOfView:siteSettingsSectionView_ to:contentWidth];
- CGFloat yPos = info_bubble::kBubbleArrowHeight;
+ CGFloat yPos = 0;
[self layoutSecuritySection];
- yPos = [self setYPositionOfView:securitySectionView_ to:yPos + kFramePadding];
+ yPos = [self setYPositionOfView:securitySectionView_ to:yPos];
- yPos = [self setYPositionOfView:separatorAfterSecuritySection_
- to:yPos + kVerticalSectionMargin];
+ yPos = [self setYPositionOfView:separatorAfterSecuritySection_ to:yPos];
[self layoutSiteSettingsSection];
- yPos = [self setYPositionOfView:siteSettingsSectionView_
- to:yPos + kVerticalSectionMargin];
+ yPos = [self setYPositionOfView:siteSettingsSectionView_ to:yPos];
- [contentView_ setFrame:NSMakeRect(0, 0, NSWidth([contentView_ frame]),
- yPos + kFramePadding)];
+ [contentView_ setFrame:NSMakeRect(0, 0, NSWidth([contentView_ frame]), yPos)];
[self sizeAndPositionWindow];
}
@@ -482,7 +487,8 @@ bool IsInternalURL(const GURL& url) {
CGFloat yPos = 0;
[self sizeTextFieldHeightToFit:identityField_];
- yPos = [self setYPositionOfView:identityField_ to:yPos];
+ yPos = [self setYPositionOfView:identityField_
+ to:yPos + kSectionVerticalPadding];
[self sizeTextFieldHeightToFit:securitySummaryField_];
yPos = [self setYPositionOfView:securitySummaryField_
@@ -503,14 +509,15 @@ bool IsInternalURL(const GURL& url) {
}
// Resize the height based on contents.
- [self setHeightOfView:securitySectionView_ to:yPos];
+ [self setHeightOfView:securitySectionView_ to:yPos + kSectionVerticalPadding];
}
- (void)layoutSiteSettingsSection {
// Start the layout with the first element. Margins are handled by the caller.
CGFloat yPos = 0;
- yPos = [self setYPositionOfView:cookiesView_ to:yPos];
+ yPos =
+ [self setYPositionOfView:cookiesView_ to:yPos + kSectionVerticalPadding];
if (permissionsPresent_) {
// Put the permission info just below the link button.
@@ -522,11 +529,13 @@ bool IsInternalURL(const GURL& url) {
// TODO(lgarron): set the position of this based on RTL/LTR.
// http://code.google.com/p/chromium/issues/detail?id=525304
yPos += kSiteSettingsSectionSpacing;
- [siteSettingsButton_ setFrameOrigin:NSMakePoint(kFramePadding, yPos)];
+ [siteSettingsButton_
+ setFrameOrigin:NSMakePoint(kSectionHorizontalPadding, yPos)];
yPos = NSMaxY([siteSettingsButton_ frame]);
// Resize the height based on contents.
- [self setHeightOfView:siteSettingsSectionView_ to:yPos];
+ [self setHeightOfView:siteSettingsSectionView_
+ to:yPos + kSectionVerticalPadding];
}
// Adjust the size of the window to match the size of the content, and position
@@ -577,7 +586,7 @@ bool IsInternalURL(const GURL& url) {
atPoint:(NSPoint)point {
// Size the text to take up the full available width, with some padding.
// The height is arbitrary as it will be adjusted later.
- CGFloat width = NSWidth([view frame]) - point.x - kFramePadding;
+ CGFloat width = NSWidth([view frame]) - point.x - kSectionHorizontalPadding;
NSRect frame = NSMakeRect(point.x, point.y, width, 100);
base::scoped_nsobject<NSTextField> textField(
[[NSTextField alloc] initWithFrame:frame]);
@@ -617,7 +626,7 @@ bool IsInternalURL(const GURL& url) {
// Add a link button with the given text to |view|.
- (NSButton*)addLinkButtonWithText:(NSString*)text toView:(NSView*)view {
// Frame size is arbitrary; it will be adjusted by the layout tweaker.
- NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10);
+ NSRect frame = NSMakeRect(kSectionHorizontalPadding, 0, 100, 10);
base::scoped_nsobject<NSButton> button(
[[NSButton alloc] initWithFrame:frame]);
base::scoped_nsobject<HyperlinkButtonCell> cell(
@@ -637,7 +646,7 @@ bool IsInternalURL(const GURL& url) {
- (NSButton*)addButtonWithText:(NSString*)text toView:(NSView*)view {
NSRect containerFrame = [view frame];
// Frame size is arbitrary; it will be adjusted by the layout tweaker.
- NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10);
+ NSRect frame = NSMakeRect(kSectionHorizontalPadding, 0, 100, 10);
base::scoped_nsobject<NSButton> button(
[[NSButton alloc] initWithFrame:frame]);
@@ -645,7 +654,8 @@ bool IsInternalURL(const GURL& url) {
// of the connection section minus the padding on both sides minus the
// connection image size and spacing.
// TODO(lgarron): handle this sizing in -performLayout.
- CGFloat maxTitleWidth = containerFrame.size.width - kFramePadding * 2;
+ CGFloat maxTitleWidth =
+ containerFrame.size.width - kSectionHorizontalPadding * 2;
base::scoped_nsobject<NSButtonCell> cell(
[[NSButtonCell alloc] initTextCell:text]);
@@ -710,8 +720,9 @@ bool IsInternalURL(const GURL& url) {
// Ensure the containing view is large enough to contain the button with its
// widest possible title.
NSRect containerFrame = [view frame];
- containerFrame.size.width = std::max(
- NSWidth(containerFrame), point.x + maxTitleWidth + kFramePadding);
+ containerFrame.size.width =
+ std::max(NSWidth(containerFrame),
+ point.x + maxTitleWidth + kSectionHorizontalPadding);
[view setFrame:containerFrame];
[view addSubview:button.get()];
return button.get();
@@ -735,8 +746,8 @@ bool IsInternalURL(const GURL& url) {
// Ensure the containing view is large enough to contain the button.
NSRect containerFrame = [view frame];
containerFrame.size.width =
- std::max(NSWidth(containerFrame),
- point.x + kPermissionDeleteImageSize + kFramePadding);
+ std::max(NSWidth(containerFrame), point.x + kPermissionDeleteImageSize +
+ kSectionHorizontalPadding);
[view setFrame:containerFrame];
[view addSubview:button.get()];
return button.get();
@@ -780,7 +791,7 @@ bool IsInternalURL(const GURL& url) {
if (isRTL) {
point.x = NSWidth([view frame]) - kPermissionImageSize -
- kPermissionImageSpacing - kFramePadding;
+ kPermissionImageSpacing - kSectionHorizontalPadding;
imageView = [self addImageWithSize:[image size] toView:view atPoint:point];
[imageView setImage:image];
point.x -= kPermissionImageSpacing;
@@ -870,7 +881,7 @@ bool IsInternalURL(const GURL& url) {
if (isRTL) {
point.x = NSWidth([view frame]) - kPermissionImageSize -
- kPermissionImageSpacing - kFramePadding;
+ kPermissionImageSpacing - kSectionHorizontalPadding;
imageView = [self addImageWithSize:[image size] toView:view atPoint:point];
[imageView setImage:image];
point.x -= kPermissionImageSpacing;
@@ -972,7 +983,7 @@ bool IsInternalURL(const GURL& url) {
base::i18n::GetStringDirection(firstPartyLabelText);
[cookiesView_ setSubviews:[NSArray array]];
- NSPoint controlOrigin = NSMakePoint(kFramePadding, 0);
+ NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0);
NSTextField* label;
@@ -986,7 +997,8 @@ bool IsInternalURL(const GURL& url) {
[header sizeToFit];
if (isRTL) {
- controlOrigin.x = viewWidth - kFramePadding - NSWidth([header frame]);
+ controlOrigin.x =
+ viewWidth - kSectionHorizontalPadding - NSWidth([header frame]);
[header setFrameOrigin:controlOrigin];
}
controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing;
@@ -995,7 +1007,7 @@ bool IsInternalURL(const GURL& url) {
// Reset X for the cookie image.
if (isRTL) {
controlOrigin.x = viewWidth - kPermissionImageSize -
- kPermissionImageSpacing - kFramePadding;
+ kPermissionImageSpacing - kSectionHorizontalPadding;
}
WebsiteSettingsUI::PermissionInfo info;
@@ -1061,7 +1073,7 @@ bool IsInternalURL(const GURL& url) {
- (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList
andChosenObjects:(const ChosenObjectInfoList&)chosenObjectInfoList {
[permissionsView_ setSubviews:[NSArray array]];
- NSPoint controlOrigin = NSMakePoint(kFramePadding, 0);
+ NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0);
permissionsPresent_ = YES;
@@ -1077,8 +1089,8 @@ bool IsInternalURL(const GURL& url) {
atPoint:controlOrigin];
[header sizeToFit];
if (isRTL) {
- controlOrigin.x = NSWidth([permissionsView_ frame]) - kFramePadding -
- NSWidth([header frame]);
+ controlOrigin.x = NSWidth([permissionsView_ frame]) -
+ kSectionHorizontalPadding - NSWidth([header frame]);
[header setFrameOrigin:controlOrigin];
}
controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing;
@@ -1099,7 +1111,7 @@ bool IsInternalURL(const GURL& url) {
controlOrigin.y = rowBottomRight.y;
}
- controlOrigin.y += kFramePadding;
+ controlOrigin.y += kPermissionsTabSpacing;
}
[permissionsView_ setFrameSize:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698