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

Side by Side Diff: ios/chrome/browser/ui/uikit_ui_util.mm

Issue 2430463003: Removed use of IsRunningOnIOS8OrLater from ui_util and uikit_ui_util (Closed)
Patch Set: one line!!!1! Created 4 years, 2 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/ui_util.mm ('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 #include <stddef.h> 10 #include <stddef.h>
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 UIImage* result = [UIImage imageWithCGImage:cgImage]; 447 UIImage* result = [UIImage imageWithCGImage:cgImage];
448 CGImageRelease(cgImage); 448 CGImageRelease(cgImage);
449 return result; 449 return result;
450 } 450 }
451 451
452 UIInterfaceOrientation GetInterfaceOrientation() { 452 UIInterfaceOrientation GetInterfaceOrientation() {
453 return [[UIApplication sharedApplication] statusBarOrientation]; 453 return [[UIApplication sharedApplication] statusBarOrientation];
454 } 454 }
455 455
456 CGFloat CurrentKeyboardHeight(NSValue* keyboardFrameValue) { 456 CGFloat CurrentKeyboardHeight(NSValue* keyboardFrameValue) {
457 CGSize keyboardSize = [keyboardFrameValue CGRectValue].size; 457 return [keyboardFrameValue CGRectValue].size.height;
458 if (base::ios::IsRunningOnIOS8OrLater()) {
459 return keyboardSize.height;
460 } else {
461 return IsPortrait() ? keyboardSize.height : keyboardSize.width;
462 }
463 } 458 }
464 459
465 UIImage* ImageWithColor(UIColor* color) { 460 UIImage* ImageWithColor(UIColor* color) {
466 CGRect rect = CGRectMake(0, 0, 1, 1); 461 CGRect rect = CGRectMake(0, 0, 1, 1);
467 UIGraphicsBeginImageContext(rect.size); 462 UIGraphicsBeginImageContext(rect.size);
468 CGContextRef context = UIGraphicsGetCurrentContext(); 463 CGContextRef context = UIGraphicsGetCurrentContext();
469 CGContextSetFillColorWithColor(context, [color CGColor]); 464 CGContextSetFillColorWithColor(context, [color CGColor]);
470 CGContextFillRect(context, rect); 465 CGContextFillRect(context, rect);
471 UIImage* image = UIGraphicsGetImageFromCurrentImageContext(); 466 UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
472 UIGraphicsEndImageContext(); 467 UIGraphicsEndImageContext();
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 void AddSameSizeConstraint(UIView* view1, UIView* view2) { 606 void AddSameSizeConstraint(UIView* view1, UIView* view2) {
612 [NSLayoutConstraint activateConstraints:@[ 607 [NSLayoutConstraint activateConstraints:@[
613 [view1.leadingAnchor constraintEqualToAnchor:view2.leadingAnchor], 608 [view1.leadingAnchor constraintEqualToAnchor:view2.leadingAnchor],
614 [view1.trailingAnchor constraintEqualToAnchor:view2.trailingAnchor], 609 [view1.trailingAnchor constraintEqualToAnchor:view2.trailingAnchor],
615 [view1.topAnchor constraintEqualToAnchor:view2.topAnchor], 610 [view1.topAnchor constraintEqualToAnchor:view2.topAnchor],
616 [view1.bottomAnchor constraintEqualToAnchor:view2.bottomAnchor] 611 [view1.bottomAnchor constraintEqualToAnchor:view2.bottomAnchor]
617 ]]; 612 ]];
618 } 613 }
619 614
620 bool IsCompact(id<UITraitEnvironment> environment) { 615 bool IsCompact(id<UITraitEnvironment> environment) {
621 if (base::ios::IsRunningOnIOS8OrLater()) { 616 return environment.traitCollection.horizontalSizeClass ==
622 return environment.traitCollection.horizontalSizeClass == 617 UIUserInterfaceSizeClassCompact;
623 UIUserInterfaceSizeClassCompact;
624 } else {
625 // Prior to iOS 8, iPad is always regular, iPhone is always compact.
626 return !IsIPadIdiom();
627 }
628 } 618 }
629 619
630 bool IsCompact() { 620 bool IsCompact() {
631 UIWindow* keyWindow = [UIApplication sharedApplication].keyWindow; 621 UIWindow* keyWindow = [UIApplication sharedApplication].keyWindow;
632 return IsCompact(keyWindow); 622 return IsCompact(keyWindow);
633 } 623 }
634 624
635 bool IsCompactTablet(id<UITraitEnvironment> environment) { 625 bool IsCompactTablet(id<UITraitEnvironment> environment) {
636 return IsIPadIdiom() && IsCompact(environment); 626 return IsIPadIdiom() && IsCompact(environment);
637 } 627 }
638 628
639 bool IsCompactTablet() { 629 bool IsCompactTablet() {
640 return IsIPadIdiom() && IsCompact(); 630 return IsIPadIdiom() && IsCompact();
641 } 631 }
642 632
643 // Returns the current first responder. 633 // Returns the current first responder.
644 UIResponder* GetFirstResponder() { 634 UIResponder* GetFirstResponder() {
645 DCHECK_CURRENTLY_ON(web::WebThread::UI); 635 DCHECK_CURRENTLY_ON(web::WebThread::UI);
646 DCHECK(!gFirstResponder); 636 DCHECK(!gFirstResponder);
647 [[UIApplication sharedApplication] 637 [[UIApplication sharedApplication]
648 sendAction:@selector(cr_markSelfCurrentFirstResponder) 638 sendAction:@selector(cr_markSelfCurrentFirstResponder)
649 to:nil 639 to:nil
650 from:nil 640 from:nil
651 forEvent:nil]; 641 forEvent:nil];
652 UIResponder* firstResponder = gFirstResponder; 642 UIResponder* firstResponder = gFirstResponder;
653 gFirstResponder = nil; 643 gFirstResponder = nil;
654 return firstResponder; 644 return firstResponder;
655 } 645 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/ui_util.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698