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

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

Issue 2569713002: [ObjC ARC] Converts ios/chrome/browser/ui:ui to ARC. (Closed)
Patch Set: Created 4 years 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>
11 #include <stdint.h> 11 #include <stdint.h>
12 #import <UIKit/UIKit.h> 12 #import <UIKit/UIKit.h>
13 #include <cmath> 13 #include <cmath>
14 14
15 #include "base/ios/ios_util.h" 15 #include "base/ios/ios_util.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/mac/foundation_util.h" 17 #include "base/mac/foundation_util.h"
18 #include "base/mac/scoped_nsobject.h"
19 #include "ios/chrome/browser/experimental_flags.h" 18 #include "ios/chrome/browser/experimental_flags.h"
20 #include "ios/chrome/browser/ui/ui_util.h" 19 #include "ios/chrome/browser/ui/ui_util.h"
21 #include "ios/web/public/web_thread.h" 20 #include "ios/web/public/web_thread.h"
22 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/l10n/l10n_util_mac.h" 22 #include "ui/base/l10n/l10n_util_mac.h"
24 #include "ui/gfx/ios/uikit_util.h" 23 #include "ui/gfx/ios/uikit_util.h"
25 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h" 24 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h"
26 25
26 #if !defined(__has_feature) || !__has_feature(objc_arc)
27 #error "This file requires ARC support."
28 #endif
29
27 namespace { 30 namespace {
28 31
29 // Linearly interpolate between |a| and |b| by fraction |f|. Satisfies 32 // Linearly interpolate between |a| and |b| by fraction |f|. Satisfies
30 // |Lerp(a,b,0) == a| and |Lerp(a,b,1) == b|. 33 // |Lerp(a,b,0) == a| and |Lerp(a,b,1) == b|.
31 CGFloat Lerp(CGFloat a, CGFloat b, CGFloat fraction) { 34 CGFloat Lerp(CGFloat a, CGFloat b, CGFloat fraction) {
32 return a * (1.0f - fraction) + b * fraction; 35 return a * (1.0f - fraction) + b * fraction;
33 } 36 }
34 37
35 // Gets the RGBA components from a UIColor in RBG or monochrome color space. 38 // Gets the RGBA components from a UIColor in RBG or monochrome color space.
36 void GetRGBA(UIColor* color, CGFloat* r, CGFloat* g, CGFloat* b, CGFloat* a) { 39 void GetRGBA(UIColor* color, CGFloat* r, CGFloat* g, CGFloat* b, CGFloat* a) {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 NSDictionary* metrics, 548 NSDictionary* metrics,
546 UIView* unused_parentView) { 549 UIView* unused_parentView) {
547 ApplyVisualConstraintsWithMetrics(constraints, subviewsDictionary, metrics); 550 ApplyVisualConstraintsWithMetrics(constraints, subviewsDictionary, metrics);
548 } 551 }
549 552
550 void ApplyVisualConstraintsWithMetricsAndOptions( 553 void ApplyVisualConstraintsWithMetricsAndOptions(
551 NSArray* constraints, 554 NSArray* constraints,
552 NSDictionary* subviewsDictionary, 555 NSDictionary* subviewsDictionary,
553 NSDictionary* metrics, 556 NSDictionary* metrics,
554 NSLayoutFormatOptions options) { 557 NSLayoutFormatOptions options) {
555 base::scoped_nsobject<NSMutableArray> layoutConstraints( 558 NSMutableArray* layoutConstraints =
556 [[NSMutableArray arrayWithCapacity:constraints.count * 3] retain]); 559 [NSMutableArray arrayWithCapacity:constraints.count * 3];
557 for (NSString* constraint in constraints) { 560 for (NSString* constraint in constraints) {
558 DCHECK([constraint isKindOfClass:[NSString class]]); 561 DCHECK([constraint isKindOfClass:[NSString class]]);
559 [layoutConstraints addObjectsFromArray: 562 [layoutConstraints addObjectsFromArray:
560 [NSLayoutConstraint 563 [NSLayoutConstraint
561 constraintsWithVisualFormat:constraint 564 constraintsWithVisualFormat:constraint
562 options:options 565 options:options
563 metrics:metrics 566 metrics:metrics
564 views:subviewsDictionary]]; 567 views:subviewsDictionary]];
565 } 568 }
566 [NSLayoutConstraint activateConstraints:layoutConstraints]; 569 [NSLayoutConstraint activateConstraints:layoutConstraints];
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 DCHECK(!gFirstResponder); 639 DCHECK(!gFirstResponder);
637 [[UIApplication sharedApplication] 640 [[UIApplication sharedApplication]
638 sendAction:@selector(cr_markSelfCurrentFirstResponder) 641 sendAction:@selector(cr_markSelfCurrentFirstResponder)
639 to:nil 642 to:nil
640 from:nil 643 from:nil
641 forEvent:nil]; 644 forEvent:nil];
642 UIResponder* firstResponder = gFirstResponder; 645 UIResponder* firstResponder = gFirstResponder;
643 gFirstResponder = nil; 646 gFirstResponder = nil;
644 return firstResponder; 647 return firstResponder;
645 } 648 }
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