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 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" | 5 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // passed to +[NSAnimationContext setDuration:] to stop an in-progress | 57 // passed to +[NSAnimationContext setDuration:] to stop an in-progress |
58 // animation as quickly as possible. | 58 // animation as quickly as possible. |
59 const NSTimeInterval kMinimumTimeInterval = | 59 const NSTimeInterval kMinimumTimeInterval = |
60 std::numeric_limits<NSTimeInterval>::min(); | 60 std::numeric_limits<NSTimeInterval>::min(); |
61 | 61 |
62 // How quickly the status bubble should expand. | 62 // How quickly the status bubble should expand. |
63 const CGFloat kExpansionDurationSeconds = 0.125; | 63 const CGFloat kExpansionDurationSeconds = 0.125; |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
67 @interface StatusBubbleAnimationDelegate : NSObject { | 67 @interface StatusBubbleAnimationDelegate : NSObject <CAAnimationDelegate> { |
68 @private | 68 @private |
69 base::mac::ScopedBlock<void (^)(void)> completionHandler_; | 69 base::mac::ScopedBlock<void (^)(void)> completionHandler_; |
70 } | 70 } |
71 | 71 |
72 - (id)initWithCompletionHandler:(void (^)(void))completionHandler; | 72 - (id)initWithCompletionHandler:(void (^)(void))completionHandler; |
73 | 73 |
74 // CAAnimation delegate method | 74 // CAAnimation delegate methods |
| 75 - (void)animationDidStart:(CAAnimation*)animation; |
75 - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished; | 76 - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished; |
76 @end | 77 @end |
77 | 78 |
78 @implementation StatusBubbleAnimationDelegate | 79 @implementation StatusBubbleAnimationDelegate |
79 | 80 |
80 - (id)initWithCompletionHandler:(void (^)(void))completionHandler { | 81 - (id)initWithCompletionHandler:(void (^)(void))completionHandler { |
81 if ((self = [super init])) { | 82 if ((self = [super init])) { |
82 completionHandler_.reset(completionHandler, base::scoped_policy::RETAIN); | 83 completionHandler_.reset(completionHandler, base::scoped_policy::RETAIN); |
83 } | 84 } |
84 | 85 |
85 return self; | 86 return self; |
86 } | 87 } |
87 | 88 |
| 89 - (void)animationDidStart:(CAAnimation*)theAnimation { |
| 90 // CAAnimationDelegate method added on OSX 10.12. |
| 91 } |
88 - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished { | 92 - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished { |
89 completionHandler_.get()(); | 93 completionHandler_.get()(); |
90 } | 94 } |
91 | 95 |
92 @end | 96 @end |
93 | 97 |
94 @interface StatusBubbleWindow : NSWindow { | 98 @interface StatusBubbleWindow : NSWindow { |
95 @private | 99 @private |
96 void (^completionHandler_)(void); | 100 void (^completionHandler_)(void); |
97 } | 101 } |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 } | 851 } |
848 } | 852 } |
849 | 853 |
850 // Round the top corners when the bubble is below the parent window. | 854 // Round the top corners when the bubble is below the parent window. |
851 if (NSMinY(window_frame) < NSMinY(parent_frame)) { | 855 if (NSMinY(window_frame) < NSMinY(parent_frame)) { |
852 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner; | 856 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner; |
853 } | 857 } |
854 | 858 |
855 return corner_flags; | 859 return corner_flags; |
856 } | 860 } |
OLD | NEW |