| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 286 |
| 287 @end | 287 @end |
| 288 | 288 |
| 289 #pragma mark - | 289 #pragma mark - |
| 290 | 290 |
| 291 // A delegate, owned by the CAAnimation system, that is alerted when the | 291 // A delegate, owned by the CAAnimation system, that is alerted when the |
| 292 // animation to close a tab is completed. Calls back to the given tab strip | 292 // animation to close a tab is completed. Calls back to the given tab strip |
| 293 // to let it know that |controller_| is ready to be removed from the model. | 293 // to let it know that |controller_| is ready to be removed from the model. |
| 294 // Since we only maintain weak references, the tab strip must call -invalidate: | 294 // Since we only maintain weak references, the tab strip must call -invalidate: |
| 295 // to prevent the use of dangling pointers. | 295 // to prevent the use of dangling pointers. |
| 296 @interface TabCloseAnimationDelegate : NSObject { | 296 @interface TabCloseAnimationDelegate : NSObject <CAAnimationDelegate> { |
| 297 @private | 297 @private |
| 298 TabStripController* strip_; // weak; owns us indirectly | 298 TabStripController* strip_; // weak; owns us indirectly |
| 299 TabController* controller_; // weak | 299 TabController* controller_; // weak |
| 300 } | 300 } |
| 301 | 301 |
| 302 // Will tell |strip| when the animation for |controller|'s view has completed. | 302 // Will tell |strip| when the animation for |controller|'s view has completed. |
| 303 // These should not be nil, and will not be retained. | 303 // These should not be nil, and will not be retained. |
| 304 - (id)initWithTabStrip:(TabStripController*)strip | 304 - (id)initWithTabStrip:(TabStripController*)strip |
| 305 tabController:(TabController*)controller; | 305 tabController:(TabController*)controller; |
| 306 | 306 |
| 307 // Invalidates this object so that no further calls will be made to | 307 // Invalidates this object so that no further calls will be made to |
| 308 // |strip_|. This should be called when |strip_| is released, to | 308 // |strip_|. This should be called when |strip_| is released, to |
| 309 // prevent attempts to call into the released object. | 309 // prevent attempts to call into the released object. |
| 310 - (void)invalidate; | 310 - (void)invalidate; |
| 311 | 311 |
| 312 // CAAnimation delegate method | 312 // CAAnimation delegate methods |
| 313 - (void)animationDidStart:(CAAnimation*)animation; |
| 313 - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished; | 314 - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished; |
| 314 | 315 |
| 315 @end | 316 @end |
| 316 | 317 |
| 317 @implementation TabCloseAnimationDelegate | 318 @implementation TabCloseAnimationDelegate |
| 318 | 319 |
| 319 - (id)initWithTabStrip:(TabStripController*)strip | 320 - (id)initWithTabStrip:(TabStripController*)strip |
| 320 tabController:(TabController*)controller { | 321 tabController:(TabController*)controller { |
| 321 if ((self = [super init])) { | 322 if ((self = [super init])) { |
| 322 DCHECK(strip && controller); | 323 DCHECK(strip && controller); |
| 323 strip_ = strip; | 324 strip_ = strip; |
| 324 controller_ = controller; | 325 controller_ = controller; |
| 325 } | 326 } |
| 326 return self; | 327 return self; |
| 327 } | 328 } |
| 328 | 329 |
| 329 - (void)invalidate { | 330 - (void)invalidate { |
| 330 strip_ = nil; | 331 strip_ = nil; |
| 331 controller_ = nil; | 332 controller_ = nil; |
| 332 } | 333 } |
| 333 | 334 |
| 335 - (void)animationDidStart:(CAAnimation*)theAnimation { |
| 336 // CAAnimationDelegate method added on OSX 10.12. |
| 337 } |
| 334 - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished { | 338 - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished { |
| 335 [strip_ animationDidStop:animation | 339 [strip_ animationDidStop:animation |
| 336 forController:controller_ | 340 forController:controller_ |
| 337 finished:finished]; | 341 finished:finished]; |
| 338 } | 342 } |
| 339 | 343 |
| 340 @end | 344 @end |
| 341 | 345 |
| 342 #pragma mark - | 346 #pragma mark - |
| 343 | 347 |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 | 1403 |
| 1400 // Once we're totally done with the tab, delete its controller | 1404 // Once we're totally done with the tab, delete its controller |
| 1401 [tabArray_ removeObjectAtIndex:index]; | 1405 [tabArray_ removeObjectAtIndex:index]; |
| 1402 } | 1406 } |
| 1403 | 1407 |
| 1404 // Called by the CAAnimation delegate when the tab completes the closing | 1408 // Called by the CAAnimation delegate when the tab completes the closing |
| 1405 // animation. | 1409 // animation. |
| 1406 - (void)animationDidStop:(CAAnimation*)animation | 1410 - (void)animationDidStop:(CAAnimation*)animation |
| 1407 forController:(TabController*)controller | 1411 forController:(TabController*)controller |
| 1408 finished:(BOOL)finished{ | 1412 finished:(BOOL)finished{ |
| 1409 [[animation delegate] invalidate]; | 1413 [(TabCloseAnimationDelegate *)[animation delegate] invalidate]; |
| 1410 [closingControllers_ removeObject:controller]; | 1414 [closingControllers_ removeObject:controller]; |
| 1411 [self removeTab:controller]; | 1415 [self removeTab:controller]; |
| 1412 } | 1416 } |
| 1413 | 1417 |
| 1414 // Save off which TabController is closing and tell its view's animator | 1418 // Save off which TabController is closing and tell its view's animator |
| 1415 // where to move the tab to. Registers a delegate to call back when the | 1419 // where to move the tab to. Registers a delegate to call back when the |
| 1416 // animation is complete in order to remove the tab from the model. | 1420 // animation is complete in order to remove the tab from the model. |
| 1417 - (void)startClosingTabWithAnimation:(TabController*)closingTab { | 1421 - (void)startClosingTabWithAnimation:(TabController*)closingTab { |
| 1418 DCHECK([NSThread isMainThread]); | 1422 DCHECK([NSThread isMainThread]); |
| 1419 | 1423 |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 for (int i = 0; i < tabStripModel_->count(); i++) { | 2315 for (int i = 0; i < tabStripModel_->count(); i++) { |
| 2312 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i]; | 2316 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i]; |
| 2313 } | 2317 } |
| 2314 } | 2318 } |
| 2315 | 2319 |
| 2316 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { | 2320 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { |
| 2317 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; | 2321 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; |
| 2318 } | 2322 } |
| 2319 | 2323 |
| 2320 @end | 2324 @end |
| OLD | NEW |