OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ios/chrome/browser/ui/rtl_geometry.h" | 5 #include "ios/chrome/browser/ui/rtl_geometry.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
9 | 9 |
10 #include "base/ios/ios_util.h" | 10 #include "base/ios/ios_util.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 #pragma mark - autolayout utilities | 210 #pragma mark - autolayout utilities |
211 | 211 |
212 NSLayoutFormatOptions LayoutOptionForRTLSupport() { | 212 NSLayoutFormatOptions LayoutOptionForRTLSupport() { |
213 if (UseRTLLayout()) { | 213 if (UseRTLLayout()) { |
214 return NSLayoutFormatDirectionLeadingToTrailing; | 214 return NSLayoutFormatDirectionLeadingToTrailing; |
215 } | 215 } |
216 return NSLayoutFormatDirectionLeftToRight; | 216 return NSLayoutFormatDirectionLeftToRight; |
217 } | 217 } |
218 | |
219 #pragma mark - deprecated functions | |
220 | |
221 bool IsRTLUILayout() { | |
222 if (base::ios::IsRunningOnIOS9OrLater()) { | |
223 #if __IPHONE_9_0 | |
224 // Calling this method is better than using the locale on iOS9 since it will | |
225 // work with the right to left pseudolanguage. | |
226 return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute: | |
227 UISemanticContentAttributeUnspecified] == | |
228 UIUserInterfaceLayoutDirectionRightToLeft; | |
229 #endif | |
230 } | |
231 // Using NSLocale instead of base::i18n::IsRTL() in order to take into account | |
232 // right to left pseudolanguage correctly (which base::i18n::IsRTL() doesn't). | |
233 return [NSLocale characterDirectionForLanguage: | |
234 [[NSLocale currentLocale] | |
235 objectForKey:NSLocaleLanguageCode]] == | |
236 NSLocaleLanguageDirectionRightToLeft; | |
237 } | |
OLD | NEW |