| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/animation_util.h" | 5 #include "ios/chrome/browser/ui/animation_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "ios/chrome/browser/ui/reversed_animation.h" | 10 #include "ios/chrome/browser/ui/reversed_animation.h" |
| 11 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 13 #error "This file requires ARC support." | |
| 14 #endif | |
| 15 | |
| 16 CAAnimation* FrameAnimationMake(CALayer* layer, | 12 CAAnimation* FrameAnimationMake(CALayer* layer, |
| 17 CGRect beginFrame, | 13 CGRect beginFrame, |
| 18 CGRect endFrame) { | 14 CGRect endFrame) { |
| 19 CGRect beginBounds = {CGPointZero, beginFrame.size}; | 15 CGRect beginBounds = {CGPointZero, beginFrame.size}; |
| 20 CGRect endBounds = {CGPointZero, endFrame.size}; | 16 CGRect endBounds = {CGPointZero, endFrame.size}; |
| 21 CABasicAnimation* boundsAnimation = | 17 CABasicAnimation* boundsAnimation = |
| 22 [CABasicAnimation animationWithKeyPath:@"bounds"]; | 18 [CABasicAnimation animationWithKeyPath:@"bounds"]; |
| 23 boundsAnimation.fromValue = [NSValue valueWithCGRect:beginBounds]; | 19 boundsAnimation.fromValue = [NSValue valueWithCGRect:beginBounds]; |
| 24 boundsAnimation.toValue = [NSValue valueWithCGRect:endBounds]; | 20 boundsAnimation.toValue = [NSValue valueWithCGRect:endBounds]; |
| 25 boundsAnimation.removedOnCompletion = NO; | 21 boundsAnimation.removedOnCompletion = NO; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 56 for (CAAnimation* animation in animations) | 52 for (CAAnimation* animation in animations) |
| 57 duration = std::max(duration, animation.beginTime + animation.duration); | 53 duration = std::max(duration, animation.beginTime + animation.duration); |
| 58 animationGroup.duration = duration; | 54 animationGroup.duration = duration; |
| 59 animationGroup.fillMode = kCAFillModeBoth; | 55 animationGroup.fillMode = kCAFillModeBoth; |
| 60 animationGroup.removedOnCompletion = NO; | 56 animationGroup.removedOnCompletion = NO; |
| 61 return animationGroup; | 57 return animationGroup; |
| 62 } | 58 } |
| 63 | 59 |
| 64 CAAnimation* DelayedAnimationMake(CAAnimation* animation, | 60 CAAnimation* DelayedAnimationMake(CAAnimation* animation, |
| 65 CFTimeInterval delay) { | 61 CFTimeInterval delay) { |
| 66 CAAnimation* delayedAnimation = [animation copy]; | 62 CAAnimation* delayedAnimation = [[animation copy] autorelease]; |
| 67 if (delayedAnimation) { | 63 if (delayedAnimation) { |
| 68 delayedAnimation.beginTime = delay; | 64 delayedAnimation.beginTime = delay; |
| 69 delayedAnimation = AnimationGroupMake(@[ delayedAnimation ]); | 65 delayedAnimation = AnimationGroupMake(@[ delayedAnimation ]); |
| 70 } | 66 } |
| 71 return delayedAnimation; | 67 return delayedAnimation; |
| 72 } | 68 } |
| 73 | 69 |
| 74 CABasicAnimation* FindAnimationForKeyPath(NSString* keyPath, | 70 CABasicAnimation* FindAnimationForKeyPath(NSString* keyPath, |
| 75 CAAnimation* animation) { | 71 CAAnimation* animation) { |
| 76 __block CABasicAnimation* animationForKeyPath = nil; | 72 __block CABasicAnimation* animationForKeyPath = nil; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 89 *stop = animationForKeyPath != nil; | 85 *stop = animationForKeyPath != nil; |
| 90 }]; | 86 }]; |
| 91 } | 87 } |
| 92 return animationForKeyPath; | 88 return animationForKeyPath; |
| 93 } | 89 } |
| 94 | 90 |
| 95 void RemoveAnimationForKeyFromLayers(NSString* key, NSArray* layers) { | 91 void RemoveAnimationForKeyFromLayers(NSString* key, NSArray* layers) { |
| 96 for (CALayer* layer in layers) | 92 for (CALayer* layer in layers) |
| 97 [layer removeAnimationForKey:key]; | 93 [layer removeAnimationForKey:key]; |
| 98 } | 94 } |
| OLD | NEW |