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

Unified Diff: chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm

Issue 2924353002: [Mac] Mirror content settings bubble in RTL. (Closed)
Patch Set: Created 3 years, 6 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
Index: chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm
index c10a6631d2933e3fe5430885b112338c73d786e6..585a82908ffdd074b768830f902581b7cb427429 100644
--- a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm
+++ b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm
@@ -99,6 +99,7 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
[label setStringValue:text];
[label setSelectable:NO];
[label setBezeled:NO];
+ [label setAlignment:NSNaturalTextAlignment];
return [label autorelease];
}
@@ -379,6 +380,7 @@ const ContentTypeToNibPath kNibPaths[] = {
NSRect titleFrame = [titleLabel_ frame];
titleFrame.origin.y -= deltaY;
[titleLabel_ setFrame:titleFrame];
+ [titleLabel_ setAlignment:NSNaturalTextAlignment];
}
- (void)initializeMessage {
@@ -397,6 +399,7 @@ const ContentTypeToNibPath kNibPaths[] = {
NSRect messageFrame = [messageLabel_ frame];
messageFrame.origin.y -= deltaY;
[messageLabel_ setFrame:messageFrame];
+ [messageLabel_ setAlignment:NSNaturalTextAlignment];
}
- (void)initializeRadioGroup {
@@ -439,6 +442,19 @@ const ContentTypeToNibPath kNibPaths[] = {
NSRect windowFrame = [[self window] frame];
windowFrame.size.height += radioDeltaY;
[[self window] setFrame:windowFrame display:NO];
+
+ // NSMatrix-based radio buttons don't get automatically flipped for
+ // RTL. Setting the user interface layout direction explicitly
+ // doesn't affect rendering, so set image position and text alignment
+ // manually.
+ if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout())
+ for (NSButtonCell* cell in [allowBlockRadioGroup_ cells]) {
+ [cell setAlignment:NSNaturalTextAlignment];
+ [cell setImagePosition:cocoa_l10n_util::LeadingCellImagePosition()];
+ // Why not?
+ [cell setUserInterfaceLayoutDirection:
+ NSUserInterfaceLayoutDirectionRightToLeft];
+ }
}
- (NSButton*)hyperlinkButtonWithFrame:(NSRect)frame
@@ -919,6 +935,17 @@ const ContentTypeToNibPath kNibPaths[] = {
if (contentSettingBubbleModel_->AsMediaStreamBubbleModel())
[self initializeMediaMenus];
+ // RTL-ize NIBS:
Avi (use Gerrit) 2017/06/09 17:41:05 blank line above this comment to separate it from
lgrey 2017/06/09 17:59:13 Done.
+ if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) {
+ cocoa_l10n_util::FlipAllSubviewsIfNecessary([self bubble]);
+ // Some NIBs have the manage/done buttons outside of the bubble.
+ cocoa_l10n_util::FlipAllSubviewsIfNecessary([[self bubble] superview]);
+ cocoa_l10n_util::FlipAllSubviewsIfNecessary(contentsContainer_);
+ // These buttons are inside |GTMWidthBasedTweaker|s, so fix margins.
+ cocoa_l10n_util::FlipAllSubviewsIfNecessary([infoButton_ superview]);
+ cocoa_l10n_util::FlipAllSubviewsIfNecessary([doneButton_ superview]);
+ cocoa_l10n_util::FlipAllSubviewsIfNecessary([manageButton_ superview]);
Avi (use Gerrit) 2017/06/09 17:41:05 for both of these line comments (941, 944), since
lgrey 2017/06/09 17:59:13 Done.
+ }
}
///////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698