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

Unified Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm

Issue 1787553003: mac: Remove uses of a CoreGraphics private API that causes WindowServer crashes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add semicolons. Created 4 years, 9 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm
index ab67fc6804b9dea5550e579b8a0dac4039b480d0..3bb3f4bfb78449782f544a1d1a50743ce9b0fba8 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm
@@ -7,6 +7,9 @@
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.h"
#import "ui/base/cocoa/constrained_window/constrained_window_animation.h"
+// Length of the animation in seconds.
+const NSTimeInterval kAnimationDuration = 0.18;
+
@implementation CustomConstrainedWindowSheet
- (id)initWithCustomWindow:(NSWindow*)customWindow {
@@ -16,21 +19,50 @@
return self;
}
+- (void)setUseSimpleAnimations:(BOOL)simpleAnimations {
+ useSimpleAnimations_ = simpleAnimations;
+}
+
- (void)showSheetForWindow:(NSWindow*)window {
- base::scoped_nsobject<NSAnimation> animation(
- [[ConstrainedWindowAnimationShow alloc] initWithWindow:customWindow_]);
+ base::scoped_nsobject<NSAnimation> animation;
+ if (!useSimpleAnimations_) {
+ animation.reset(
+ [[ConstrainedWindowAnimationShow alloc] initWithWindow:customWindow_]);
+ }
[window addChildWindow:customWindow_
ordered:NSWindowAbove];
[self unhideSheet];
[self updateSheetPosition];
[customWindow_ makeKeyAndOrderFront:nil];
- [animation startAnimation];
+
+ if (useSimpleAnimations_) {
+ [customWindow_ setAlphaValue:0.0];
+ [NSAnimationContext beginGrouping];
+ [[NSAnimationContext currentContext] setDuration:kAnimationDuration];
+ [[customWindow_ animator] setAlphaValue:1.0];
+ [NSAnimationContext endGrouping];
+ } else {
+ [animation startAnimation];
+ }
}
- (void)closeSheetWithAnimation:(BOOL)withAnimation {
if (withAnimation) {
- base::scoped_nsobject<NSAnimation> animation(
- [[ConstrainedWindowAnimationHide alloc] initWithWindow:customWindow_]);
+ base::scoped_nsobject<NSAnimation> animation;
+ if (useSimpleAnimations_) {
+ // Use a blocking animation, rather than -[NSWindow animator].
+ NSArray* animationArray = @[ @{
+ NSViewAnimationTargetKey : customWindow_,
+ NSViewAnimationEffectKey : NSViewAnimationFadeOutEffect,
+ } ];
+ animation.reset(
+ [[NSViewAnimation alloc] initWithViewAnimations:animationArray]);
+ [animation setDuration:kAnimationDuration];
+ [animation setAnimationBlockingMode:NSAnimationBlocking];
+ } else {
+ animation.reset([[ConstrainedWindowAnimationHide alloc]
+ initWithWindow:customWindow_]);
+ }
[animation startAnimation];
}

Powered by Google App Engine
This is Rietveld 408576698