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

Unified Diff: ios/chrome/browser/ui/uikit_ui_util.mm

Issue 1280913003: Upstreaming browser/ui/uikit_ui_util from iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « ios/chrome/browser/ui/uikit_ui_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/uikit_ui_util.mm
diff --git a/ios/chrome/browser/ui/uikit_ui_util.mm b/ios/chrome/browser/ui/uikit_ui_util.mm
index 3f8d5b70fc8c7d76173e92fb42df7490f2a61dd0..9b9d8f5f22915bd84b57475aa0900df95c13d4ab 100644
--- a/ios/chrome/browser/ui/uikit_ui_util.mm
+++ b/ios/chrome/browser/ui/uikit_ui_util.mm
@@ -457,6 +457,21 @@ void AddSameCenterXConstraint(UIView* parentView, UIView* subview) {
constant:0]];
}
+void AddSameCenterXConstraint(UIView *parentView, UIView *subview1,
+ UIView *subview2) {
+ DCHECK_EQ(parentView, [subview1 superview]);
+ DCHECK_EQ(parentView, [subview2 superview]);
+ DCHECK_NE(subview1, subview2);
+ [parentView addConstraint:[NSLayoutConstraint
+ constraintWithItem:subview1
+ attribute:NSLayoutAttributeCenterX
+ relatedBy:NSLayoutRelationEqual
+ toItem:subview2
+ attribute:NSLayoutAttributeCenterX
+ multiplier:1
+ constant:0]];
+}
+
void AddSameCenterYConstraint(UIView* parentView, UIView* subview) {
DCHECK_EQ(parentView, [subview superview]);
[parentView addConstraint:[NSLayoutConstraint
@@ -499,3 +514,22 @@ bool IsCompactTablet() {
bool IsCompactTabletSizeClass(UIUserInterfaceSizeClass sizeClass) {
return IsIPadIdiom() && sizeClass == UIUserInterfaceSizeClassCompact;
}
+
+BOOL IsRTLUILayout() {
+ if (base::ios::IsRunningOnIOS9OrLater()) {
+#if __IPHONE_9_0
+ // Calling this method is better than using the locale on iOS9 since it will
+ // work with the right to left pseudolanguage.
+ return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:
+ UISemanticContentAttributeUnspecified] ==
+ UIUserInterfaceLayoutDirectionRightToLeft;
+#endif
+ }
+ // Using NSLocale instead of base::i18n::IsRTL() in order to take into account
+ // right to left pseudolanguage correctly (which base::i18n::IsRTL() doesn't).
+ return
+ [NSLocale
+ characterDirectionForLanguage:
+ [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]] ==
+ NSLocaleLanguageDirectionRightToLeft;
+}
« no previous file with comments | « ios/chrome/browser/ui/uikit_ui_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698