| 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/stack_view/stack_view_controller.h" | 5 #import "ios/chrome/browser/ui/stack_view/stack_view_controller.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 | 2018 |
| 2019 if (parentView) { | 2019 if (parentView) { |
| 2020 CGPoint viewCoordinate = [parentView convertPoint:center toView:self.view]; | 2020 CGPoint viewCoordinate = [parentView convertPoint:center toView:self.view]; |
| 2021 _lastTapPoint = viewCoordinate; | 2021 _lastTapPoint = viewCoordinate; |
| 2022 } | 2022 } |
| 2023 } | 2023 } |
| 2024 | 2024 |
| 2025 - (Tab*)dismissWithNewTabAnimation:(const GURL&)URL | 2025 - (Tab*)dismissWithNewTabAnimation:(const GURL&)URL |
| 2026 atIndex:(NSUInteger)position | 2026 atIndex:(NSUInteger)position |
| 2027 transition:(ui::PageTransition)transition { | 2027 transition:(ui::PageTransition)transition { |
| 2028 // Record the start time for this operation so it may be reported as a metric |
| 2029 // in the animation completion block. |
| 2030 NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate]; |
| 2031 |
| 2028 // This helps smooth out the animation. | 2032 // This helps smooth out the animation. |
| 2029 [[_scrollView layer] setShouldRasterize:YES]; | 2033 [[_scrollView layer] setShouldRasterize:YES]; |
| 2030 if (_isBeingDismissed) | 2034 if (_isBeingDismissed) |
| 2031 return NULL; | 2035 return NULL; |
| 2032 DCHECK(_isActive); | 2036 DCHECK(_isActive); |
| 2033 [self prepareForDismissal]; | 2037 [self prepareForDismissal]; |
| 2034 _isBeingDismissed = YES; | 2038 _isBeingDismissed = YES; |
| 2035 [self setNeedsStatusBarAppearanceUpdate]; | 2039 [self setNeedsStatusBarAppearanceUpdate]; |
| 2036 DCHECK(URL.is_valid()); | 2040 DCHECK(URL.is_valid()); |
| 2037 // Stop pre-loading cards. | 2041 // Stop pre-loading cards. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2070 newCard.image = [tab updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; | 2074 newCard.image = [tab updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; |
| 2071 [tab view].frame = originalTabFrame; | 2075 [tab view].frame = originalTabFrame; |
| 2072 newCard.center = | 2076 newCard.center = |
| 2073 CGPointMake(CGRectGetMidX(viewBounds), CGRectGetMidY(viewBounds)); | 2077 CGPointMake(CGRectGetMidX(viewBounds), CGRectGetMidY(viewBounds)); |
| 2074 [self.view addSubview:newCard]; | 2078 [self.view addSubview:newCard]; |
| 2075 | 2079 |
| 2076 void (^completionBlock)(void) = ^{ | 2080 void (^completionBlock)(void) = ^{ |
| 2077 [newCard removeFromSuperview]; | 2081 [newCard removeFromSuperview]; |
| 2078 [[_scrollView layer] setShouldRasterize:NO]; | 2082 [[_scrollView layer] setShouldRasterize:NO]; |
| 2079 [_delegate tabSwitcherDismissTransitionDidEnd:self]; | 2083 [_delegate tabSwitcherDismissTransitionDidEnd:self]; |
| 2084 double duration = [NSDate timeIntervalSinceReferenceDate] - startTime; |
| 2085 if (_activeCardSet.tabModel.isOffTheRecord) { |
| 2086 UMA_HISTOGRAM_TIMES( |
| 2087 "Toolbar.TabSwitcher.NewIncognitoTabPresentationDurationn", |
| 2088 base::TimeDelta::FromSecondsD(duration)); |
| 2089 } else { |
| 2090 UMA_HISTOGRAM_TIMES("Toolbar.TabSwitcher.NewTabPresentationDuration", |
| 2091 base::TimeDelta::FromSecondsD(duration)); |
| 2092 } |
| 2080 }; | 2093 }; |
| 2081 | 2094 |
| 2082 CGPoint origin = _lastTapPoint; | 2095 CGPoint origin = _lastTapPoint; |
| 2083 _lastTapPoint = CGPointZero; | 2096 _lastTapPoint = CGPointZero; |
| 2084 ios_internal::page_animation_util::AnimateInPaperWithAnimationAndCompletion( | 2097 ios_internal::page_animation_util::AnimateInPaperWithAnimationAndCompletion( |
| 2085 newCard, -statusBarHeight, | 2098 newCard, -statusBarHeight, |
| 2086 newCard.frame.size.height - newCard.image.size.height, origin, | 2099 newCard.frame.size.height - newCard.image.size.height, origin, |
| 2087 [self isCurrentSetIncognito], nil, completionBlock); | 2100 [self isCurrentSetIncognito], nil, completionBlock); |
| 2088 // TODO(stuartmorgan): Animate the other set off to the side. | 2101 // TODO(stuartmorgan): Animate the other set off to the side. |
| 2089 | 2102 |
| (...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3503 | 3516 |
| 3504 @end | 3517 @end |
| 3505 | 3518 |
| 3506 @implementation StackViewController (Testing) | 3519 @implementation StackViewController (Testing) |
| 3507 | 3520 |
| 3508 - (UIScrollView*)scrollView { | 3521 - (UIScrollView*)scrollView { |
| 3509 return _scrollView.get(); | 3522 return _scrollView.get(); |
| 3510 } | 3523 } |
| 3511 | 3524 |
| 3512 @end | 3525 @end |
| OLD | NEW |