| OLD | NEW |
| 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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 [parentView addConstraint:[NSLayoutConstraint | 510 [parentView addConstraint:[NSLayoutConstraint |
| 511 constraintWithItem:subview1 | 511 constraintWithItem:subview1 |
| 512 attribute:NSLayoutAttributeCenterY | 512 attribute:NSLayoutAttributeCenterY |
| 513 relatedBy:NSLayoutRelationEqual | 513 relatedBy:NSLayoutRelationEqual |
| 514 toItem:subview2 | 514 toItem:subview2 |
| 515 attribute:NSLayoutAttributeCenterY | 515 attribute:NSLayoutAttributeCenterY |
| 516 multiplier:1 | 516 multiplier:1 |
| 517 constant:0]]; | 517 constant:0]]; |
| 518 } | 518 } |
| 519 | 519 |
| 520 bool IsCompact() { | 520 bool IsCompact(id<UITraitEnvironment> environment) { |
| 521 if (base::ios::IsRunningOnIOS8OrLater()) { | 521 if (base::ios::IsRunningOnIOS8OrLater()) { |
| 522 UIWindow* keyWindow = [UIApplication sharedApplication].keyWindow; | 522 return environment.traitCollection.horizontalSizeClass == |
| 523 return [keyWindow.traitCollection horizontalSizeClass] == | |
| 524 UIUserInterfaceSizeClassCompact; | 523 UIUserInterfaceSizeClassCompact; |
| 525 } else { | 524 } else { |
| 526 // Prior to iOS 8, iPad is always regular, iPhone is always compact. | 525 // Prior to iOS 8, iPad is always regular, iPhone is always compact. |
| 527 return !IsIPadIdiom(); | 526 return !IsIPadIdiom(); |
| 528 } | 527 } |
| 529 } | 528 } |
| 530 | 529 |
| 530 bool IsCompact() { |
| 531 UIWindow* keyWindow = [UIApplication sharedApplication].keyWindow; |
| 532 return IsCompact(keyWindow); |
| 533 } |
| 534 |
| 535 bool IsCompactTablet(id<UITraitEnvironment> environment) { |
| 536 return IsIPadIdiom() && IsCompact(environment); |
| 537 } |
| 538 |
| 531 bool IsCompactTablet() { | 539 bool IsCompactTablet() { |
| 532 return IsIPadIdiom() && IsCompact(); | 540 return IsIPadIdiom() && IsCompact(); |
| 533 } | 541 } |
| OLD | NEW |