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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/ui/uikit_ui_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #import "ios/chrome/browser/ui/uikit_ui_util.h" 5 #import "ios/chrome/browser/ui/uikit_ui_util.h"
6 6
7 #import <Accelerate/Accelerate.h> 7 #import <Accelerate/Accelerate.h>
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 #import <QuartzCore/QuartzCore.h> 9 #import <QuartzCore/QuartzCore.h>
10 #import <UIKit/UIKit.h> 10 #import <UIKit/UIKit.h>
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 [parentView addConstraint:[NSLayoutConstraint 450 [parentView addConstraint:[NSLayoutConstraint
451 constraintWithItem:subview 451 constraintWithItem:subview
452 attribute:NSLayoutAttributeCenterX 452 attribute:NSLayoutAttributeCenterX
453 relatedBy:NSLayoutRelationEqual 453 relatedBy:NSLayoutRelationEqual
454 toItem:parentView 454 toItem:parentView
455 attribute:NSLayoutAttributeCenterX 455 attribute:NSLayoutAttributeCenterX
456 multiplier:1 456 multiplier:1
457 constant:0]]; 457 constant:0]];
458 } 458 }
459 459
460 void AddSameCenterXConstraint(UIView *parentView, UIView *subview1,
461 UIView *subview2) {
462 DCHECK_EQ(parentView, [subview1 superview]);
463 DCHECK_EQ(parentView, [subview2 superview]);
464 DCHECK_NE(subview1, subview2);
465 [parentView addConstraint:[NSLayoutConstraint
466 constraintWithItem:subview1
467 attribute:NSLayoutAttributeCenterX
468 relatedBy:NSLayoutRelationEqual
469 toItem:subview2
470 attribute:NSLayoutAttributeCenterX
471 multiplier:1
472 constant:0]];
473 }
474
460 void AddSameCenterYConstraint(UIView* parentView, UIView* subview) { 475 void AddSameCenterYConstraint(UIView* parentView, UIView* subview) {
461 DCHECK_EQ(parentView, [subview superview]); 476 DCHECK_EQ(parentView, [subview superview]);
462 [parentView addConstraint:[NSLayoutConstraint 477 [parentView addConstraint:[NSLayoutConstraint
463 constraintWithItem:subview 478 constraintWithItem:subview
464 attribute:NSLayoutAttributeCenterY 479 attribute:NSLayoutAttributeCenterY
465 relatedBy:NSLayoutRelationEqual 480 relatedBy:NSLayoutRelationEqual
466 toItem:parentView 481 toItem:parentView
467 attribute:NSLayoutAttributeCenterY 482 attribute:NSLayoutAttributeCenterY
468 multiplier:1 483 multiplier:1
469 constant:0]]; 484 constant:0]];
(...skipping 22 matching lines...) Expand all
492 return IsCompactTabletSizeClass( 507 return IsCompactTabletSizeClass(
493 [rootController.traitCollection horizontalSizeClass]); 508 [rootController.traitCollection horizontalSizeClass]);
494 } else { 509 } else {
495 return IsCompactTabletSizeClass(UIUserInterfaceSizeClassRegular); 510 return IsCompactTabletSizeClass(UIUserInterfaceSizeClassRegular);
496 } 511 }
497 } 512 }
498 513
499 bool IsCompactTabletSizeClass(UIUserInterfaceSizeClass sizeClass) { 514 bool IsCompactTabletSizeClass(UIUserInterfaceSizeClass sizeClass) {
500 return IsIPadIdiom() && sizeClass == UIUserInterfaceSizeClassCompact; 515 return IsIPadIdiom() && sizeClass == UIUserInterfaceSizeClassCompact;
501 } 516 }
517
518 BOOL IsRTLUILayout() {
519 if (base::ios::IsRunningOnIOS9OrLater()) {
520 #if __IPHONE_9_0
521 // Calling this method is better than using the locale on iOS9 since it will
522 // work with the right to left pseudolanguage.
523 return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:
524 UISemanticContentAttributeUnspecified] ==
525 UIUserInterfaceLayoutDirectionRightToLeft;
526 #endif
527 }
528 // Using NSLocale instead of base::i18n::IsRTL() in order to take into account
529 // right to left pseudolanguage correctly (which base::i18n::IsRTL() doesn't).
530 return
531 [NSLocale
532 characterDirectionForLanguage:
533 [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]] ==
534 NSLocaleLanguageDirectionRightToLeft;
535 }
OLDNEW
« 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