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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm

Issue 1408033010: Fix for Exit Fullscreen Animation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/browser_window_fullscreen_transition.h" 5 #import "chrome/browser/ui/cocoa/browser_window_fullscreen_transition.h"
6 6
7 #include <QuartzCore/QuartzCore.h> 7 #include <QuartzCore/QuartzCore.h>
8 8
9 #include "base/mac/bind_objc_block.h" 9 #include "base/mac/bind_objc_block.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
11 #include "base/mac/mac_util.h" 11 #include "base/mac/mac_util.h"
12 #import "base/mac/sdk_forward_declarations.h" 12 #import "base/mac/sdk_forward_declarations.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 14 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
15 #import "chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h"
15 16
16 namespace { 17 namespace {
17 18
18 NSString* const kPrimaryWindowAnimationID = @"PrimaryWindowAnimationID"; 19 NSString* const kPrimaryWindowAnimationID = @"PrimaryWindowAnimationID";
19 NSString* const kSnapshotWindowAnimationID = @"SnapshotWindowAnimationID"; 20 NSString* const kSnapshotWindowAnimationID = @"SnapshotWindowAnimationID";
20 NSString* const kAnimationIDKey = @"AnimationIDKey"; 21 NSString* const kAnimationIDKey = @"AnimationIDKey";
21 22
23 // The fraction of the duration from AppKit's startCustomAnimation methods
24 // that we want our animation to run in.
25 CGFloat const kAnimationDurationFrame = 0.5;
erikchen 2015/11/09 18:29:21 maybe kAnimationDurationFraction?
spqchan 2015/11/09 22:27:19 Done.
26
22 // This class has two simultaneous animations to resize and reposition layers. 27 // This class has two simultaneous animations to resize and reposition layers.
23 // These animations must use the same timing function, otherwise there will be 28 // These animations must use the same timing function, otherwise there will be
24 // visual discordance. 29 // visual discordance.
25 NSString* TransformAnimationTimingFunction() { 30 NSString* TransformAnimationTimingFunction() {
26 return kCAMediaTimingFunctionEaseInEaseOut; 31 return kCAMediaTimingFunctionEaseInEaseOut;
27 } 32 }
28 33
29 // This class locks and unlocks the FrameBrowserWindow. Its destructor ensures 34 // This class locks and unlocks the FrameBrowserWindow. Its destructor ensures
30 // that the lock gets released. 35 // that the lock gets released.
31 class FrameAndStyleLock { 36 class FrameAndStyleLock {
32 public: 37 public:
33 explicit FrameAndStyleLock(FramedBrowserWindow* window) : window_(window) {} 38 explicit FrameAndStyleLock(FramedBrowserWindow* window) : window_(window) {}
34 39
35 ~FrameAndStyleLock() { set_lock(NO); } 40 ~FrameAndStyleLock() { set_lock(NO); }
36 41
37 void set_lock(bool lock) { [window_ setFrameAndStyleMaskLock:lock]; } 42 void set_lock(bool lock) { [window_ setStyleMaskLock:lock]; }
38 43
39 private: 44 private:
40 FramedBrowserWindow* window_; // weak 45 FramedBrowserWindow* window_; // weak
41 46
42 DISALLOW_COPY_AND_ASSIGN(FrameAndStyleLock); 47 DISALLOW_COPY_AND_ASSIGN(FrameAndStyleLock);
43 }; 48 };
44 49
45 } // namespace 50 } // namespace
46 51
52 // This view draws a dummy toolbar over the resized content view during
53 // the exit fullscreen animation. It is removed at the end of the animation.
54 @interface FullscreenTabStripBackgroundView : NSView {
55 base::scoped_nsobject<NSColor> windowBackgroundColor_;
56 }
57
58 - (instancetype)initWithFrame:(NSRect)frame background:(NSColor*)color;
59
60 @end
61
62 @implementation FullscreenTabStripBackgroundView
63
64 - (instancetype)initWithFrame:(NSRect)frame background:(NSColor*)color {
65 if ((self = [super initWithFrame:frame])) {
66 windowBackgroundColor_.reset([color copy]);
67 }
68 return self;
69 }
70
71 // Override this method so that we can paint the toolbar in this view.
72 // This method first fill itself with the toolbar's background. After that,
73 // it will paint the window's theme if applicable.
74 - (void)drawRect:(NSRect)frame {
75 [windowBackgroundColor_ set];
76 NSRectFillUsingOperation(frame, NSCompositeDestinationOver);
77
78 [FramedBrowserWindow drawWindowThemeInDirtyRect:frame
79 forView:self
80 bounds:[self bounds]
81 forceBlackBackground:NO];
82 }
83
84 @end
85
47 @interface BrowserWindowFullscreenTransition () { 86 @interface BrowserWindowFullscreenTransition () {
48 // Flag to keep track of whether we are entering or exiting fullscreen. 87 // Flag to keep track of whether we are entering or exiting fullscreen.
49 BOOL isEnteringFullscreen_; 88 BOOL isEnteringFullscreen_;
50 89
51 // The window which is undergoing the fullscreen transition. 90 // The window which is undergoing the fullscreen transition.
52 base::scoped_nsobject<FramedBrowserWindow> primaryWindow_; 91 base::scoped_nsobject<FramedBrowserWindow> primaryWindow_;
53 92
54 // A layer that holds a snapshot of the original state of |primaryWindow_|. 93 // A layer that holds a snapshot of the original state of |primaryWindow_|.
55 base::scoped_nsobject<CALayer> snapshotLayer_; 94 base::scoped_nsobject<CALayer> snapshotLayer_;
56 95
57 // A temporary window that holds |snapshotLayer_|. 96 // A temporary window that holds |snapshotLayer_|.
58 base::scoped_nsobject<NSWindow> snapshotWindow_; 97 base::scoped_nsobject<NSWindow> snapshotWindow_;
59 98
99 // The tabstrip background view in the window. During the exit fullscreen
100 // animation, this view be hidden while a dummy tabstrip background will be
101 // drawn over the content view.
102 base::scoped_nsobject<NSView> tabStripBackgroundView_;
103
60 // The background color of |primaryWindow_| before the transition began. 104 // The background color of |primaryWindow_| before the transition began.
61 base::scoped_nsobject<NSColor> primaryWindowInitialBackgroundColor_; 105 base::scoped_nsobject<NSColor> primaryWindowInitialBackgroundColor_;
62 106
63 // Whether |primaryWindow_| was opaque before the transition began. 107 // Whether |primaryWindow_| was opaque before the transition began.
64 BOOL primaryWindowInitialOpaque_; 108 BOOL primaryWindowInitialOpaque_;
65 109
110 // The initial anchor point of the root layer.
111 CGPoint initialRootAnchorPoint_;
112
113 // The initial origin of the content view.
114 NSPoint initialContentViewOrigin_;
115
66 // Whether the instance is in the process of changing the size of 116 // Whether the instance is in the process of changing the size of
67 // |primaryWindow_|. 117 // |primaryWindow_|.
68 BOOL changingPrimaryWindowSize_; 118 BOOL changingPrimaryWindowSize_;
69 119
70 // The frame of the |primaryWindow_| before it starts the transition. 120 // The frame of the |primaryWindow_| before it starts the transition.
71 NSRect initialFrame_; 121 NSRect initialFrame_;
72 122
73 // The frame that |primaryWindow_| is expected to have after the transition 123 // The frame that |primaryWindow_| is expected to have after the transition
74 // is finished. 124 // is finished.
75 NSRect finalFrame_; 125 NSRect finalFrame_;
76 126
127 // This view draws the tabstrip background during the exit animation.
128 base::scoped_nsobject<FullscreenTabStripBackgroundView>
129 fullscreenTabStripBackgroundView_;
130
77 // Locks and unlocks the FullSizeContentWindow. 131 // Locks and unlocks the FullSizeContentWindow.
78 scoped_ptr<FrameAndStyleLock> lock_; 132 scoped_ptr<FrameAndStyleLock> lock_;
79 } 133 }
80 134
81 // Takes a snapshot of |primaryWindow_| and puts it in |snapshotLayer_|. 135 // Takes a snapshot of |primaryWindow_| and puts it in |snapshotLayer_|.
82 - (void)takeSnapshot; 136 - (void)takeSnapshot;
83 137
84 // Creates |snapshotWindow_| and adds |snapshotLayer_| to it. 138 // Creates |snapshotWindow_| and adds |snapshotLayer_| to it.
85 - (void)makeAndPrepareSnapshotWindow; 139 - (void)makeAndPrepareSnapshotWindow;
86 140
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 primaryWindow_.reset([window retain]); 186 primaryWindow_.reset([window retain]);
133 187
134 isEnteringFullscreen_ = YES; 188 isEnteringFullscreen_ = YES;
135 initialFrame_ = [primaryWindow_ frame]; 189 initialFrame_ = [primaryWindow_ frame];
136 finalFrame_ = [[primaryWindow_ screen] frame]; 190 finalFrame_ = [[primaryWindow_ screen] frame];
137 } 191 }
138 return self; 192 return self;
139 } 193 }
140 194
141 - (instancetype)initExitWithWindow:(FramedBrowserWindow*)window 195 - (instancetype)initExitWithWindow:(FramedBrowserWindow*)window
142 frame:(NSRect)frame { 196 frame:(NSRect)frame
197 tabStripBackgroundView:(NSView*)view {
143 DCHECK(window); 198 DCHECK(window);
144 DCHECK([self rootLayerOfWindow:window]); 199 DCHECK([self rootLayerOfWindow:window]);
145 if ((self = [super init])) { 200 if ((self = [super init])) {
146 primaryWindow_.reset([window retain]); 201 primaryWindow_.reset([window retain]);
147 202 tabStripBackgroundView_.reset([view retain]);
148 isEnteringFullscreen_ = NO; 203 isEnteringFullscreen_ = NO;
149 finalFrame_ = frame; 204 finalFrame_ = frame;
150 initialFrame_ = [[primaryWindow_ screen] frame]; 205 initialFrame_ = [[primaryWindow_ screen] frame];
151 206
152 lock_.reset(new FrameAndStyleLock(window)); 207 lock_.reset(new FrameAndStyleLock(window));
153 } 208 }
154 return self; 209 return self;
155 } 210 }
156 211
157 - (NSArray*)customWindowsForFullScreenTransition { 212 - (NSArray*)customWindowsForFullScreenTransition {
158 [self takeSnapshot]; 213 [self takeSnapshot];
159 [self makeAndPrepareSnapshotWindow]; 214 [self makeAndPrepareSnapshotWindow];
160 return @[ primaryWindow_.get(), snapshotWindow_.get() ]; 215 return @[ primaryWindow_.get(), snapshotWindow_.get() ];
161 } 216 }
162 217
163 - (void)startCustomFullScreenAnimationWithDuration:(NSTimeInterval)duration { 218 - (void)startCustomFullScreenAnimationWithDuration:(NSTimeInterval)duration {
219 CGFloat animationDuration = duration * kAnimationDurationFrame;
164 [self preparePrimaryWindowForAnimation]; 220 [self preparePrimaryWindowForAnimation];
165 [self animatePrimaryWindowWithDuration:duration]; 221 [self animatePrimaryWindowWithDuration:animationDuration];
166 [self animateSnapshotWindowWithDuration:duration]; 222 [self animateSnapshotWindowWithDuration:animationDuration];
167 } 223 }
168 224
169 - (BOOL)shouldWindowBeUnconstrained { 225 - (BOOL)shouldWindowBeUnconstrained {
170 return changingPrimaryWindowSize_; 226 return changingPrimaryWindowSize_;
171 } 227 }
172 228
173 - (NSSize)desiredWindowLayoutSize { 229 - (NSSize)desiredWindowLayoutSize {
174 return isEnteringFullscreen_ ? [primaryWindow_ frame].size 230 return isEnteringFullscreen_ ? [primaryWindow_ frame].size
175 : [[primaryWindow_ contentView] bounds].size; 231 : [[primaryWindow_ contentView] bounds].size;
176 } 232 }
(...skipping 26 matching lines...) Expand all
203 [snapshotWindow_ setBackgroundColor:[NSColor clearColor]]; 259 [snapshotWindow_ setBackgroundColor:[NSColor clearColor]];
204 [snapshotWindow_ setAnimationBehavior:NSWindowAnimationBehaviorNone]; 260 [snapshotWindow_ setAnimationBehavior:NSWindowAnimationBehaviorNone];
205 261
206 [[[snapshotWindow_ contentView] layer] addSublayer:snapshotLayer_]; 262 [[[snapshotWindow_ contentView] layer] addSublayer:snapshotLayer_];
207 263
208 // Compute the frame of the snapshot layer such that the snapshot is 264 // Compute the frame of the snapshot layer such that the snapshot is
209 // positioned exactly on top of the original position of |primaryWindow_|. 265 // positioned exactly on top of the original position of |primaryWindow_|.
210 NSRect snapshotLayerFrame = 266 NSRect snapshotLayerFrame =
211 [snapshotWindow_ convertRectFromScreen:[primaryWindow_ frame]]; 267 [snapshotWindow_ convertRectFromScreen:[primaryWindow_ frame]];
212 [snapshotLayer_ setFrame:snapshotLayerFrame]; 268 [snapshotLayer_ setFrame:snapshotLayerFrame];
269
270 if (isEnteringFullscreen_)
271 [snapshotWindow_ orderFront:nil];
213 } 272 }
214 273
215 - (void)preparePrimaryWindowForAnimation { 274 - (void)preparePrimaryWindowForAnimation {
216 // Save the initial state of the primary window. 275 // Save the initial state of the primary window.
217 primaryWindowInitialBackgroundColor_.reset( 276 primaryWindowInitialBackgroundColor_.reset(
218 [[primaryWindow_ backgroundColor] copy]); 277 [[primaryWindow_ backgroundColor] copy]);
219 primaryWindowInitialOpaque_ = [primaryWindow_ isOpaque]; 278 primaryWindowInitialOpaque_ = [primaryWindow_ isOpaque];
220 279
221 // Make |primaryWindow_| invisible. This must happen before the window is 280 // Make |primaryWindow_| invisible. This must happen before the window is
222 // resized, since resizing the window will call drawRect: and cause content 281 // resized, since resizing the window will call drawRect: and cause content
223 // to flash over the entire screen. 282 // to flash over the entire screen.
224 [primaryWindow_ setOpaque:NO]; 283 [primaryWindow_ setOpaque:NO];
225 CALayer* root = [self rootLayerOfWindow:primaryWindow_];
226 root.opacity = 0;
227 284
228 if (isEnteringFullscreen_) { 285 if (isEnteringFullscreen_) {
229 // As soon as the style mask includes the flag NSFullScreenWindowMask, the 286 // As soon as the style mask includes the flag NSFullScreenWindowMask, the
230 // window is expected to receive fullscreen layout. This must be set before 287 // window is expected to receive fullscreen layout. This must be set before
231 // the window is resized, as that causes a relayout. 288 // the window is resized, as that causes a relayout.
289
290 CALayer* root = [self rootLayerOfWindow:primaryWindow_];
291 root.opacity = 0;
292
232 [primaryWindow_ 293 [primaryWindow_
233 setStyleMask:[primaryWindow_ styleMask] | NSFullScreenWindowMask]; 294 setStyleMask:[primaryWindow_ styleMask] | NSFullScreenWindowMask];
234 [self changePrimaryWindowToFinalFrame]; 295 [self changePrimaryWindowToFinalFrame];
235 } else { 296 } else {
236 // Set the size of the root layer to the size of the final frame. The root 297 [snapshotWindow_ orderFront:nil];
erikchen 2015/11/09 18:29:21 what's with the different in timing? Can you add c
spqchan 2015/11/09 22:27:19 Done.
237 // layer is placed at position (0, 0) because the animation will take care 298
238 // of the layer's start and end position. 299 NSView* contentView = [primaryWindow_ contentView];
239 root.frame = 300 NSView* rootView = [contentView superview];
240 NSMakeRect(0, 0, finalFrame_.size.width, finalFrame_.size.height); 301
302 // Since only the content view is resized, the window's background
303 // must transparent. This is a hack that forces the layer to remove
erikchen 2015/11/09 18:29:21 s/must/must be/
spqchan 2015/11/09 22:27:19 Done.
304 // the textured background and replace it with clearColor.
305 [rootView setWantsLayer:NO];
erikchen 2015/11/09 18:29:21 Why does this hack work? Shouldn't we be able to m
spqchan 2015/11/09 22:27:19 Having NSTexturedBackgroundWindowMask prevents the
erikchen 2015/11/10 02:15:43 Why can't you use -setNeedsDisplay or something si
spqchan 2015/11/10 18:45:31 I tried to use setNeedsDisplay, updateLayer and va
306 [primaryWindow_ setBackgroundColor:[NSColor clearColor]];
307 [primaryWindow_ setStyleMask:[primaryWindow_ styleMask] &
308 ~NSTexturedBackgroundWindowMask];
309 [rootView setWantsLayer:YES];
310
311 CALayer* root = [self rootLayerOfWindow:primaryWindow_];
312 root.opacity = 0;
241 313
242 // Right before the animation begins, change the contentView size to the 314 // Right before the animation begins, change the contentView size to the
243 // expected size at the end of the animation. Afterwards, lock the 315 // expected size at the end of the animation. Afterwards, lock the
244 // |primaryWindow_| so that AppKit will not be able to make unwanted 316 // |primaryWindow_| so that AppKit will not be able to make unwanted
245 // changes to it during the animation. 317 // changes to it during the animation.
246 [primaryWindow_ forceContentViewSize:finalFrame_.size]; 318 initialContentViewOrigin_ = [[primaryWindow_ contentView] frame].origin;
319 initialRootAnchorPoint_ = root.anchorPoint;
320
321 NSPoint contentViewOrigin =
322 [self pointRelativeToCurrentScreen:finalFrame_.origin];
323 NSRect relativeContentFinalFrame =
324 NSMakeRect(contentViewOrigin.x, contentViewOrigin.y,
325 finalFrame_.size.width, finalFrame_.size.height);
326 [primaryWindow_ forceContentViewFrame:relativeContentFinalFrame];
327 [contentView setAutoresizesSubviews:NO];
erikchen 2015/11/09 18:29:21 Why? If we're preventing the frame from changing,
spqchan 2015/11/09 22:27:19 We don't actually prevent the frame from changing.
328
329 fullscreenTabStripBackgroundView_.reset(
330 [[FullscreenTabStripBackgroundView alloc]
331 initWithFrame:finalFrame_
332 background:primaryWindowInitialBackgroundColor_]);
333 [fullscreenTabStripBackgroundView_ setFrameOrigin:NSZeroPoint];
334 [contentView addSubview:fullscreenTabStripBackgroundView_.get()
335 positioned:NSWindowBelow
336 relativeTo:nil];
337
338 [tabStripBackgroundView_ setHidden:YES];
339
340 // Set anchor point to be the center of the content view
341 CGFloat anchorPointX =
342 NSMidX(relativeContentFinalFrame) / NSWidth(initialFrame_);
343 CGFloat anchorPointY =
344 NSMidY(relativeContentFinalFrame) / NSHeight(initialFrame_);
345 root.anchorPoint = CGPointMake(anchorPointX, anchorPointY);
346
247 lock_->set_lock(YES); 347 lock_->set_lock(YES);
248 } 348 }
249 } 349 }
250 350
251 - (void)animateSnapshotWindowWithDuration:(CGFloat)duration { 351 - (void)animateSnapshotWindowWithDuration:(CGFloat)duration {
252 [snapshotWindow_ orderFront:nil];
253
254 // Calculate the frame so that it's relative to the screen. 352 // Calculate the frame so that it's relative to the screen.
255 NSRect finalFrameRelativeToScreen = 353 NSRect finalFrameRelativeToScreen =
256 [snapshotWindow_ convertRectFromScreen:finalFrame_]; 354 [snapshotWindow_ convertRectFromScreen:finalFrame_];
257 355
258 // Move the snapshot layer until it's bottom-left corner is at the the 356 // Move the snapshot layer until it's bottom-left corner is at the the
259 // bottom-left corner of the expected frame. 357 // bottom-left corner of the expected frame.
260 CABasicAnimation* positionAnimation = 358 CABasicAnimation* positionAnimation =
261 [CABasicAnimation animationWithKeyPath:@"position"]; 359 [CABasicAnimation animationWithKeyPath:@"position"];
262 positionAnimation.toValue = 360 positionAnimation.toValue =
263 [NSValue valueWithPoint:finalFrameRelativeToScreen.origin]; 361 [NSValue valueWithPoint:finalFrameRelativeToScreen.origin];
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // Animate the primary window from its initial position, the center of the 416 // Animate the primary window from its initial position, the center of the
319 // initial window. 417 // initial window.
320 CABasicAnimation* positionAnimation = 418 CABasicAnimation* positionAnimation =
321 [CABasicAnimation animationWithKeyPath:@"position"]; 419 [CABasicAnimation animationWithKeyPath:@"position"];
322 NSPoint centerOfInitialFrame = 420 NSPoint centerOfInitialFrame =
323 NSMakePoint(NSMidX(initialFrame), NSMidY(initialFrame)); 421 NSMakePoint(NSMidX(initialFrame), NSMidY(initialFrame));
324 NSPoint startingLayerPoint = 422 NSPoint startingLayerPoint =
325 [self pointRelativeToCurrentScreen:centerOfInitialFrame]; 423 [self pointRelativeToCurrentScreen:centerOfInitialFrame];
326 positionAnimation.fromValue = [NSValue valueWithPoint:startingLayerPoint]; 424 positionAnimation.fromValue = [NSValue valueWithPoint:startingLayerPoint];
327 425
328 // Since the root layer's frame is different from the window, AppKit might 426 NSPoint endingLayerPoint =
329 // animate it to a different position if we have multiple windows in 427 [self pointRelativeToCurrentScreen:NSMakePoint(NSMidX(endFrame),
330 // fullscreen. This ensures that the animation moves to the correct position. 428 NSMidY(endFrame))];
331 CGFloat anchorPointX = NSWidth(endFrame) / 2; 429 positionAnimation.toValue = [NSValue valueWithPoint:endingLayerPoint];
332 CGFloat anchorPointY = NSHeight(endFrame) / 2;
333 NSPoint endLayerPoint = [self pointRelativeToCurrentScreen:endFrame.origin];
334 positionAnimation.toValue =
335 [NSValue valueWithPoint:NSMakePoint(endLayerPoint.x + anchorPointX,
336 endLayerPoint.y + anchorPointY)];
337 430
338 CAAnimationGroup* group = [CAAnimationGroup animation]; 431 CAAnimationGroup* group = [CAAnimationGroup animation];
339 group.removedOnCompletion = NO; 432 group.removedOnCompletion = NO;
340 group.fillMode = kCAFillModeForwards; 433 group.fillMode = kCAFillModeForwards;
341 group.animations = 434 group.animations =
342 @[ opacityAnimation, positionAnimation, transformAnimation ]; 435 @[ opacityAnimation, positionAnimation, transformAnimation ];
343 group.timingFunction = [CAMediaTimingFunction 436 group.timingFunction = [CAMediaTimingFunction
344 functionWithName:TransformAnimationTimingFunction()]; 437 functionWithName:TransformAnimationTimingFunction()];
345 group.duration = duration; 438 group.duration = duration;
346 [group setValue:kPrimaryWindowAnimationID forKey:kAnimationIDKey]; 439 [group setValue:kPrimaryWindowAnimationID forKey:kAnimationIDKey];
(...skipping 19 matching lines...) Expand all
366 snapshotLayer_.reset(); 459 snapshotLayer_.reset();
367 return; 460 return;
368 } 461 }
369 462
370 if ([animationID isEqual:kPrimaryWindowAnimationID]) { 463 if ([animationID isEqual:kPrimaryWindowAnimationID]) {
371 // If we're exiting full screen, we want to set the |primaryWindow_|'s 464 // If we're exiting full screen, we want to set the |primaryWindow_|'s
372 // frame to the expected frame at the end of the animation. The window's 465 // frame to the expected frame at the end of the animation. The window's
373 // lock must also be released. 466 // lock must also be released.
374 if (!isEnteringFullscreen_) { 467 if (!isEnteringFullscreen_) {
375 lock_->set_lock(NO); 468 lock_->set_lock(NO);
469
470 CALayer* root = [self rootLayerOfWindow:primaryWindow_];
471 root.anchorPoint = initialRootAnchorPoint_;
472
376 [primaryWindow_ 473 [primaryWindow_
377 setStyleMask:[primaryWindow_ styleMask] & ~NSFullScreenWindowMask]; 474 setStyleMask:[primaryWindow_ styleMask] & ~NSFullScreenWindowMask];
erikchen 2015/11/09 18:29:21 does this need to be 2 separate calls to setStyleM
spqchan 2015/11/09 22:27:19 I separated them so that it looks cleaner. I'll go
475 [primaryWindow_ setStyleMask:[primaryWindow_ styleMask] |
476 NSTexturedBackgroundWindowMask];
477
478 NSView* content = [primaryWindow_ contentView];
479 [content setFrameOrigin:initialContentViewOrigin_];
378 [self changePrimaryWindowToFinalFrame]; 480 [self changePrimaryWindowToFinalFrame];
481 [[primaryWindow_ contentView] setAutoresizesSubviews:YES];
482
483 [tabStripBackgroundView_ setHidden:NO];
484 [fullscreenTabStripBackgroundView_ removeFromSuperview];
379 } 485 }
380 486
381 // Checks if the contentView size is correct. 487 // Checks if the contentView size is correct.
382 NSSize expectedSize = finalFrame_.size; 488 NSSize expectedSize = finalFrame_.size;
383 NSView* content = [primaryWindow_ contentView]; 489 NSView* content = [primaryWindow_ contentView];
384 DCHECK_EQ(NSHeight(content.frame), expectedSize.height); 490 DCHECK_EQ(NSHeight(content.frame), expectedSize.height);
385 DCHECK_EQ(NSWidth(content.frame), expectedSize.width); 491 DCHECK_EQ(NSWidth(content.frame), expectedSize.width);
386 492
387 // Restore the state of the primary window and make it visible again. 493 // Restore the state of the primary window and make it visible again.
388 [primaryWindow_ setOpaque:primaryWindowInitialOpaque_]; 494 [primaryWindow_ setOpaque:primaryWindowInitialOpaque_];
389 [primaryWindow_ setBackgroundColor:primaryWindowInitialBackgroundColor_]; 495 [primaryWindow_ setBackgroundColor:primaryWindowInitialBackgroundColor_];
390 496
391 CALayer* root = [self rootLayerOfWindow:primaryWindow_]; 497 CALayer* root = [self rootLayerOfWindow:primaryWindow_];
392 [root removeAnimationForKey:kPrimaryWindowAnimationID]; 498 [root removeAnimationForKey:kPrimaryWindowAnimationID];
393 root.opacity = 1; 499 root.opacity = 1;
394 } 500 }
395 } 501 }
396 502
397 - (CALayer*)rootLayerOfWindow:(NSWindow*)window { 503 - (CALayer*)rootLayerOfWindow:(NSWindow*)window {
398 return [[[window contentView] superview] layer]; 504 return [[[window contentView] superview] layer];
399 } 505 }
400 506
401 - (NSPoint)pointRelativeToCurrentScreen:(NSPoint)point { 507 - (NSPoint)pointRelativeToCurrentScreen:(NSPoint)point {
402 NSRect screenFrame = [[primaryWindow_ screen] frame]; 508 NSRect screenFrame = [[primaryWindow_ screen] frame];
403 return NSMakePoint(point.x - screenFrame.origin.x, 509 return NSMakePoint(point.x - screenFrame.origin.x,
404 point.y - screenFrame.origin.y); 510 point.y - screenFrame.origin.y);
405 } 511 }
406 512
407 @end 513 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698