OLD | NEW |
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" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 // Whether |primaryWindow_| was opaque before the transition began. | 107 // Whether |primaryWindow_| was opaque before the transition began. |
108 BOOL primaryWindowInitialOpaque_; | 108 BOOL primaryWindowInitialOpaque_; |
109 | 109 |
110 // The initial anchor point of the root layer. | 110 // The initial anchor point of the root layer. |
111 CGPoint initialRootAnchorPoint_; | 111 CGPoint initialRootAnchorPoint_; |
112 | 112 |
113 // The initial origin of the content view. | 113 // The initial origin of the content view. |
114 NSPoint initialContentViewOrigin_; | 114 NSPoint initialContentViewOrigin_; |
115 | 115 |
116 // The initial value of the content view's autoresizeSubviews property. | |
117 BOOL initialContentViewAutoresizesSubviews_; | |
118 | |
119 // 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 |
120 // |primaryWindow_|. | 117 // |primaryWindow_|. |
121 BOOL changingPrimaryWindowSize_; | 118 BOOL changingPrimaryWindowSize_; |
122 | 119 |
123 // The frame of the |primaryWindow_| before it starts the transition. | 120 // The frame of the |primaryWindow_| before it starts the transition. |
124 NSRect initialFrame_; | 121 NSRect initialFrame_; |
125 | 122 |
126 // The frame that |primaryWindow_| is expected to have after the transition | 123 // The frame that |primaryWindow_| is expected to have after the transition |
127 // is finished. | 124 // is finished. |
128 NSRect finalFrame_; | 125 NSRect finalFrame_; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 initialContentViewOrigin_ = [[primaryWindow_ contentView] frame].origin; | 321 initialContentViewOrigin_ = [[primaryWindow_ contentView] frame].origin; |
325 initialRootAnchorPoint_ = root.anchorPoint; | 322 initialRootAnchorPoint_ = root.anchorPoint; |
326 | 323 |
327 NSPoint contentViewOrigin = | 324 NSPoint contentViewOrigin = |
328 [self pointRelativeToCurrentScreen:finalFrame_.origin]; | 325 [self pointRelativeToCurrentScreen:finalFrame_.origin]; |
329 NSRect relativeContentFinalFrame = | 326 NSRect relativeContentFinalFrame = |
330 NSMakeRect(contentViewOrigin.x, contentViewOrigin.y, | 327 NSMakeRect(contentViewOrigin.x, contentViewOrigin.y, |
331 finalFrame_.size.width, finalFrame_.size.height); | 328 finalFrame_.size.width, finalFrame_.size.height); |
332 [primaryWindow_ forceContentViewFrame:relativeContentFinalFrame]; | 329 [primaryWindow_ forceContentViewFrame:relativeContentFinalFrame]; |
333 | 330 |
334 // In OSX 10.11, when the NSFullScreenWindowMask is added or removed, | |
335 // the window's frame and layer changes slightly which causes a janky | |
336 // movement. As a result, we should disable the content view's autoresize | |
337 // at the beginning of the animation and set it back to its original value | |
338 // at the end of the animation. | |
339 initialContentViewAutoresizesSubviews_ = [contentView autoresizesSubviews]; | |
340 [contentView setAutoresizesSubviews:NO]; | |
341 | |
342 fullscreenTabStripBackgroundView_.reset( | 331 fullscreenTabStripBackgroundView_.reset( |
343 [[FullscreenTabStripBackgroundView alloc] | 332 [[FullscreenTabStripBackgroundView alloc] |
344 initWithFrame:finalFrame_ | 333 initWithFrame:finalFrame_ |
345 background:primaryWindowInitialBackgroundColor_]); | 334 background:primaryWindowInitialBackgroundColor_]); |
346 [fullscreenTabStripBackgroundView_ setFrameOrigin:NSZeroPoint]; | 335 [fullscreenTabStripBackgroundView_ setFrameOrigin:NSZeroPoint]; |
347 [contentView addSubview:fullscreenTabStripBackgroundView_.get() | 336 [contentView addSubview:fullscreenTabStripBackgroundView_.get() |
348 positioned:NSWindowBelow | 337 positioned:NSWindowBelow |
349 relativeTo:nil]; | 338 relativeTo:nil]; |
350 | 339 |
351 [tabStripBackgroundView_ setHidden:YES]; | 340 [tabStripBackgroundView_ setHidden:YES]; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 root.anchorPoint = initialRootAnchorPoint_; | 473 root.anchorPoint = initialRootAnchorPoint_; |
485 | 474 |
486 NSUInteger styleMask = | 475 NSUInteger styleMask = |
487 ([primaryWindow_ styleMask] & ~NSFullScreenWindowMask) | | 476 ([primaryWindow_ styleMask] & ~NSFullScreenWindowMask) | |
488 NSTexturedBackgroundWindowMask; | 477 NSTexturedBackgroundWindowMask; |
489 [primaryWindow_ setStyleMask:styleMask]; | 478 [primaryWindow_ setStyleMask:styleMask]; |
490 | 479 |
491 NSView* content = [primaryWindow_ contentView]; | 480 NSView* content = [primaryWindow_ contentView]; |
492 [content setFrameOrigin:initialContentViewOrigin_]; | 481 [content setFrameOrigin:initialContentViewOrigin_]; |
493 [self changePrimaryWindowToFinalFrame]; | 482 [self changePrimaryWindowToFinalFrame]; |
494 [content setAutoresizesSubviews:initialContentViewAutoresizesSubviews_]; | |
495 | 483 |
496 [tabStripBackgroundView_ setHidden:NO]; | 484 [tabStripBackgroundView_ setHidden:NO]; |
497 [fullscreenTabStripBackgroundView_ removeFromSuperview]; | 485 [fullscreenTabStripBackgroundView_ removeFromSuperview]; |
498 } | 486 } |
499 | 487 |
500 // Checks if the contentView size is correct. | 488 // Checks if the contentView size is correct. |
501 NSSize expectedSize = finalFrame_.size; | 489 NSSize expectedSize = finalFrame_.size; |
502 NSView* content = [primaryWindow_ contentView]; | 490 NSView* content = [primaryWindow_ contentView]; |
503 DCHECK_EQ(NSHeight(content.frame), expectedSize.height); | 491 DCHECK_EQ(NSHeight(content.frame), expectedSize.height); |
504 DCHECK_EQ(NSWidth(content.frame), expectedSize.width); | 492 DCHECK_EQ(NSWidth(content.frame), expectedSize.width); |
(...skipping 12 matching lines...) Expand all Loading... |
517 return [[[window contentView] superview] layer]; | 505 return [[[window contentView] superview] layer]; |
518 } | 506 } |
519 | 507 |
520 - (NSPoint)pointRelativeToCurrentScreen:(NSPoint)point { | 508 - (NSPoint)pointRelativeToCurrentScreen:(NSPoint)point { |
521 NSRect screenFrame = [[primaryWindow_ screen] frame]; | 509 NSRect screenFrame = [[primaryWindow_ screen] frame]; |
522 return NSMakePoint(point.x - screenFrame.origin.x, | 510 return NSMakePoint(point.x - screenFrame.origin.x, |
523 point.y - screenFrame.origin.y); | 511 point.y - screenFrame.origin.y); |
524 } | 512 } |
525 | 513 |
526 @end | 514 @end |
OLD | NEW |