Chromium Code Reviews| 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_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "base/mac/sdk_forward_declarations.h" | 8 #import "base/mac/sdk_forward_declarations.h" |
| 9 #import "chrome/browser/ui/cocoa/browser_window_layout.h" | 9 #import "chrome/browser/ui/cocoa/browser_window_layout.h" |
| 10 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 10 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
| 11 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 11 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| 12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h" | 12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h" |
| 13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
| 14 #import "chrome/browser/ui/cocoa/themed_window.h" | 14 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 15 #import "ui/base/cocoa/focus_tracker.h" | 15 #import "ui/base/cocoa/focus_tracker.h" |
| 16 #include "ui/base/material_design/material_design_controller.h" | 16 #include "ui/base/material_design/material_design_controller.h" |
| 17 #include "ui/base/theme_provider.h" | 17 #include "ui/base/theme_provider.h" |
| 18 | 18 |
| 19 @interface TabWindowController () | 19 @interface TabWindowController () |
| 20 - (void)setUseOverlay:(BOOL)useOverlay; | 20 - (void)setUseOverlay:(BOOL)useOverlay; |
| 21 | 21 |
| 22 // The tab strip background view should always be inserted as the back-most | 22 // The tab strip background view should always be inserted as the back-most |
| 23 // subview of the root view. It cannot be a subview of the contentView, as that | 23 // subview of the root view. It cannot be a subview of the contentView, as that |
| 24 // would cause it to become layer backed, which would cause it to draw on top | 24 // would cause it to become layer backed, which would cause it to draw on top |
| 25 // of non-layer backed content like the window controls. | 25 // of non-layer backed content like the window controls. |
| 26 - (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window | 26 - (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window |
| 27 titleBar:(BOOL)hasTitleBar; | 27 titleBar:(BOOL)hasTitleBar; |
| 28 | |
| 29 // Called when NSWindowWillEnterFullScreenNotification notification received. | |
| 30 // Makes visual effects view hidden as it should not be displayed in fullscreen. | |
| 31 - (void)windowWillEnterFullScreenNotification:(NSNotification*)notification; | |
|
tapted
2016/10/10 23:38:06
nit: windowWillEnterFullScreen: (consistent with B
Eugene But (OOO till 7-30)
2016/10/11 00:33:10
|windowWillEnterFullScreen:| does not follow Codin
| |
| 32 // Called when NSWindowWillExitFullScreenNotification notification received. | |
|
tapted
2016/10/10 23:38:06
nit: blank line before [consistency]
Eugene But (OOO till 7-30)
2016/10/11 00:33:10
Done.
| |
| 33 // Makes visual effects view visible since it was hidden in fullscreen. | |
| 34 - (void)windowWillExitFullScreenNotification:(NSNotification*)notification; | |
| 35 | |
| 28 @end | 36 @end |
| 29 | 37 |
| 30 @interface TabWindowOverlayWindow : NSWindow | 38 @interface TabWindowOverlayWindow : NSWindow |
| 31 @end | 39 @end |
| 32 | 40 |
| 33 @implementation TabWindowOverlayWindow | 41 @implementation TabWindowOverlayWindow |
| 34 | 42 |
| 35 - (const ui::ThemeProvider*)themeProvider { | 43 - (const ui::ThemeProvider*)themeProvider { |
| 36 return [[self parentWindow] themeProvider]; | 44 return [[self parentWindow] themeProvider]; |
| 37 } | 45 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 [[FastResizeView alloc] initWithFrame:[chromeContentView_ bounds]]); | 90 [[FastResizeView alloc] initWithFrame:[chromeContentView_ bounds]]); |
| 83 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable | | 91 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable | |
| 84 NSViewHeightSizable]; | 92 NSViewHeightSizable]; |
| 85 [chromeContentView_ addSubview:tabContentArea_]; | 93 [chromeContentView_ addSubview:tabContentArea_]; |
| 86 | 94 |
| 87 // tabStripBackgroundView_ draws the theme image behind the tab strip area. | 95 // tabStripBackgroundView_ draws the theme image behind the tab strip area. |
| 88 // When making a tab dragging window (setUseOverlay:), this view stays in | 96 // When making a tab dragging window (setUseOverlay:), this view stays in |
| 89 // the parent window so that it can be translucent, while the tab strip view | 97 // the parent window so that it can be translucent, while the tab strip view |
| 90 // moves to the child window and stays opaque. | 98 // moves to the child window and stays opaque. |
| 91 NSView* windowView = [window contentView]; | 99 NSView* windowView = [window contentView]; |
| 100 CGFloat paintHeight = [FramedBrowserWindow browserFrameViewPaintHeight]; | |
| 92 tabStripBackgroundView_.reset([[TabStripBackgroundView alloc] | 101 tabStripBackgroundView_.reset([[TabStripBackgroundView alloc] |
| 93 initWithFrame:NSMakeRect(0, | 102 initWithFrame:NSMakeRect(0, NSMaxY([windowView bounds]) - paintHeight, |
| 94 NSMaxY([windowView bounds]) - | 103 NSWidth([windowView bounds]), paintHeight)]); |
| 95 kBrowserFrameViewPaintHeight, | |
| 96 NSWidth([windowView bounds]), | |
| 97 kBrowserFrameViewPaintHeight)]); | |
| 98 [tabStripBackgroundView_ | 104 [tabStripBackgroundView_ |
| 99 setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; | 105 setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; |
| 100 [self insertTabStripBackgroundViewIntoWindow:window titleBar:hasTitleBar]; | 106 [self insertTabStripBackgroundViewIntoWindow:window titleBar:hasTitleBar]; |
| 101 | 107 |
| 102 tabStripView_.reset([[TabStripView alloc] | 108 tabStripView_.reset([[TabStripView alloc] |
| 103 initWithFrame:NSMakeRect( | 109 initWithFrame:NSMakeRect( |
| 104 0, 0, kDefaultWidth, chrome::kTabStripHeight)]); | 110 0, 0, kDefaultWidth, chrome::kTabStripHeight)]); |
| 105 [tabStripView_ setAutoresizingMask:NSViewWidthSizable | | 111 [tabStripView_ setAutoresizingMask:NSViewWidthSizable | |
| 106 NSViewMinYMargin]; | 112 NSViewMinYMargin]; |
| 107 if (hasTabStrip) | 113 if (hasTabStrip) |
| 108 [windowView addSubview:tabStripView_]; | 114 [windowView addSubview:tabStripView_]; |
| 115 | |
| 116 if (chrome::ShouldUseFullSizeContentView()) { | |
| 117 [[NSNotificationCenter defaultCenter] | |
| 118 addObserver:self | |
| 119 selector:@selector(windowWillEnterFullScreenNotification:) | |
| 120 name:NSWindowWillEnterFullScreenNotification | |
| 121 object:window]; | |
| 122 [[NSNotificationCenter defaultCenter] | |
| 123 addObserver:self | |
| 124 selector:@selector(windowWillExitFullScreenNotification:) | |
| 125 name:NSWindowWillExitFullScreenNotification | |
| 126 object:window]; | |
| 127 } | |
| 109 } | 128 } |
| 110 return self; | 129 return self; |
| 111 } | 130 } |
| 112 | 131 |
| 132 - (void)dealloc { | |
| 133 [[NSNotificationCenter defaultCenter] removeObserver:self]; | |
| 134 [super dealloc]; | |
| 135 } | |
| 136 | |
| 113 - (NSView*)tabStripBackgroundView { | 137 - (NSView*)tabStripBackgroundView { |
| 114 return tabStripBackgroundView_; | 138 return tabStripBackgroundView_; |
| 115 } | 139 } |
| 116 | 140 |
| 117 - (TabStripView*)tabStripView { | 141 - (TabStripView*)tabStripView { |
| 118 return tabStripView_; | 142 return tabStripView_; |
| 119 } | 143 } |
| 120 | 144 |
| 121 - (FastResizeView*)tabContentArea { | 145 - (FastResizeView*)tabContentArea { |
| 122 return tabContentArea_; | 146 return tabContentArea_; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 | 377 |
| 354 - (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window | 378 - (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window |
| 355 titleBar:(BOOL)hasTitleBar { | 379 titleBar:(BOOL)hasTitleBar { |
| 356 DCHECK(tabStripBackgroundView_); | 380 DCHECK(tabStripBackgroundView_); |
| 357 NSView* rootView = [[window contentView] superview]; | 381 NSView* rootView = [[window contentView] superview]; |
| 358 | 382 |
| 359 // In Material Design on 10.10 and higher, the top portion of the window is | 383 // In Material Design on 10.10 and higher, the top portion of the window is |
| 360 // blurred using an NSVisualEffectView. | 384 // blurred using an NSVisualEffectView. |
| 361 Class nsVisualEffectViewClass = NSClassFromString(@"NSVisualEffectView"); | 385 Class nsVisualEffectViewClass = NSClassFromString(@"NSVisualEffectView"); |
| 362 if (!nsVisualEffectViewClass) { | 386 if (!nsVisualEffectViewClass) { |
| 363 [rootView addSubview:tabStripBackgroundView_ | 387 [rootView addSubview:tabStripBackgroundView_ |
|
tapted
2016/10/10 23:38:06
before this, perhaps
DCHECK(!chrome::ShouldUseFull
Eugene But (OOO till 7-30)
2016/10/11 00:33:10
Are you sure? Availability of NSVisualEffectView a
tapted
2016/10/11 04:21:43
The problem here is that |rootView| is [contentVie
Eugene But (OOO till 7-30)
2016/10/11 04:35:46
Oh, right. Done.
| |
| 364 positioned:NSWindowBelow | 388 positioned:NSWindowBelow |
| 365 relativeTo:nil]; | 389 relativeTo:nil]; |
| 366 return; | 390 return; |
| 367 } | 391 } |
| 368 | 392 |
| 369 [window setTitlebarAppearsTransparent:YES]; | 393 [window setTitlebarAppearsTransparent:YES]; |
| 370 | 394 |
| 371 // If the window has a normal titlebar, then do not add NSVisualEffectView. | 395 // If the window has a normal titlebar, then do not add NSVisualEffectView. |
| 372 if (hasTitleBar) | 396 if (hasTitleBar) |
| 373 return; | 397 return; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 387 // the start of -[BrowserWindowController initWithBrowser:takeOwnership:], | 411 // the start of -[BrowserWindowController initWithBrowser:takeOwnership:], |
| 388 // before the |browser_| ivar has been set. Without a browser object we | 412 // before the |browser_| ivar has been set. Without a browser object we |
| 389 // can't check the window's theme. The final setup happens in | 413 // can't check the window's theme. The final setup happens in |
| 390 // -[TabStripView setController:], at which point we have access to the theme. | 414 // -[TabStripView setController:], at which point we have access to the theme. |
| 391 [visualEffectView setAppearance: | 415 [visualEffectView setAppearance: |
| 392 [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]]; | 416 [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]]; |
| 393 [visualEffectView setMaterial:NSVisualEffectMaterialLight]; | 417 [visualEffectView setMaterial:NSVisualEffectMaterialLight]; |
| 394 [visualEffectView setBlendingMode:NSVisualEffectBlendingModeBehindWindow]; | 418 [visualEffectView setBlendingMode:NSVisualEffectBlendingModeBehindWindow]; |
| 395 [visualEffectView setState:NSVisualEffectStateFollowsWindowActiveState]; | 419 [visualEffectView setState:NSVisualEffectStateFollowsWindowActiveState]; |
| 396 | 420 |
| 397 [rootView addSubview:visualEffectView | 421 if (chrome::ShouldUseFullSizeContentView()) { |
| 398 positioned:NSWindowBelow | 422 [[window contentView] addSubview:visualEffectView]; |
| 399 relativeTo:nil]; | 423 } else { |
| 424 [rootView addSubview:visualEffectView | |
| 425 positioned:NSWindowBelow | |
| 426 relativeTo:nil]; | |
| 427 } | |
| 400 | 428 |
| 401 // Make the |tabStripBackgroundView_| a child of the NSVisualEffectView. | 429 // Make the |tabStripBackgroundView_| a child of the NSVisualEffectView. |
| 402 [tabStripBackgroundView_ setFrame:[visualEffectView bounds]]; | 430 [tabStripBackgroundView_ setFrame:[visualEffectView bounds]]; |
| 403 [visualEffectView addSubview:tabStripBackgroundView_]; | 431 [visualEffectView addSubview:tabStripBackgroundView_]; |
| 432 visualEffectView_.reset([visualEffectView retain]); | |
|
tapted
2016/10/10 23:38:06
since visualEffectView is also scoped_nsobject, we
Eugene But (OOO till 7-30)
2016/10/11 00:33:10
Done.
| |
| 404 } | 433 } |
| 405 | 434 |
| 406 // Called when the size of the window content area has changed. Override to | 435 // Called when the size of the window content area has changed. Override to |
| 407 // position specific views. Base class implementation does nothing. | 436 // position specific views. Base class implementation does nothing. |
| 408 - (void)layoutSubviews { | 437 - (void)layoutSubviews { |
| 409 NOTIMPLEMENTED(); | 438 NOTIMPLEMENTED(); |
| 410 } | 439 } |
| 411 | 440 |
| 441 - (void)windowWillEnterFullScreenNotification:(NSNotification*)notification { | |
| 442 [[visualEffectView_ animator] setAlphaValue:0.0]; | |
|
tapted
2016/10/10 23:38:06
I wonder if there are implications for text render
Eugene But (OOO till 7-30)
2016/10/11 00:33:10
Visually looks the same before and after the chang
| |
| 443 } | |
| 444 | |
| 445 - (void)windowWillExitFullScreenNotification:(NSNotification*)notification { | |
| 446 [[visualEffectView_ animator] setAlphaValue:1.0]; | |
|
tapted
2016/10/10 23:38:06
Maybe worth a note for these - visualEffectView_ w
Eugene But (OOO till 7-30)
2016/10/11 00:33:10
Done. Added comments to the header.
| |
| 447 } | |
| 448 | |
| 412 @end | 449 @end |
| OLD | NEW |