Commit 6f7b4e45 authored by erikchen@chromium.org's avatar erikchen@chromium.org

mac: Fix tab dragging visual bug in Yosemite. (reland 2)

-----------------Reland 2 Description------------------
Turned on layers for the test for fullscreen windows.

-----------------Reland 1 Description------------------
Reland 1 link: https://codereview.chromium.org/393933003/
Core animation was turned on in M35. The fullscreen window was not layer
backed, but should have been. This original CL exposed this bug.

-----------------Original Description------------------
Original CL link: https://codereview.chromium.org/379293003/

In OSX 10.10+, all views must be added to the NSWindow's contentView. Some
views (like the tab strip and the profile icon) are placed on top of the title
bar and require special treatment. All other views are added as subviews of
'chromeContentView' in TabWindowController. This allows tab dragging and
fullscreen logic to easily move the views that don't need special treatment.

This CL also removes the instances where a VersionIndependentWindow's
contentView gets replaced by setContentView:. Instead, the 'chromeContentView'
gets passed around as a subview. This allows VersionIndependentWindow to remove
another of its internal hacks.

BUG=392239

Review URL: https://codereview.chromium.org/399803002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283650 0039d316-1c4b-4281-b951-d872f2087c98
parent 6249d66e
......@@ -1557,7 +1557,7 @@ using content::WebContents;
if (!downloadShelfController_.get()) {
downloadShelfController_.reset([[DownloadShelfController alloc]
initWithBrowser:browser_.get() resizeDelegate:self]);
[[[self window] contentView] addSubview:[downloadShelfController_ view]];
[self.chromeContentView addSubview:[downloadShelfController_ view]];
}
return downloadShelfController_;
}
......
......@@ -566,13 +566,10 @@ willPositionSheet:(NSWindow*)sheet
[tabStripView removeFromSuperview];
}
// Ditto for the content view.
base::scoped_nsobject<NSView> contentView(
[[sourceWindow contentView] retain]);
// Disable autoresizing of subviews while we move views around. This prevents
// spurious renderer resizes.
[contentView setAutoresizesSubviews:NO];
[contentView removeFromSuperview];
[self.chromeContentView setAutoresizesSubviews:NO];
[self.chromeContentView removeFromSuperview];
// Have to do this here, otherwise later calls can crash because the window
// has no delegate.
......@@ -584,8 +581,11 @@ willPositionSheet:(NSWindow*)sheet
// drawOverlayRect:]. I'm pretty convinced this is an Apple bug, but there is
// no visual impact. I have been unable to tickle it away with other window
// or view manipulation Cocoa calls. Stack added to suppressions_mac.txt.
[contentView setAutoresizesSubviews:YES];
[destWindow setContentView:contentView];
[self.chromeContentView setAutoresizesSubviews:YES];
[[destWindow contentView] addSubview:self.chromeContentView
positioned:NSWindowBelow
relativeTo:nil];
self.chromeContentView.frame = [[destWindow contentView] bounds];
// Move the incognito badge if present.
if ([self shouldShowAvatar]) {
......@@ -852,7 +852,7 @@ willPositionSheet:(NSWindow*)sheet
for (NSWindow* window in [[NSApplication sharedApplication] windows]) {
if ([window
isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) {
[window.contentView setHidden:YES];
[[window contentView] setHidden:YES];
}
}
}
......@@ -930,7 +930,7 @@ willPositionSheet:(NSWindow*)sheet
}
- (void)updateSubviewZOrder:(BOOL)inPresentationMode {
NSView* contentView = [[self window] contentView];
NSView* contentView = self.chromeContentView;
NSView* toolbarView = [toolbarController_ view];
if (inPresentationMode) {
......
......@@ -21,6 +21,7 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
#include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
#import "chrome/browser/ui/cocoa/nsview_additions.h"
#include "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
#include "chrome/browser/ui/host_desktop.h"
......@@ -615,7 +616,7 @@ TEST_F(BrowserWindowControllerTest, TestFindBarOnTop) {
[controller_ addFindBar:bridge.find_bar_cocoa_controller()];
// Test that the Z-order of the find bar is on top of everything.
NSArray* subviews = [[[controller_ window] contentView] subviews];
NSArray* subviews = [controller_.chromeContentView subviews];
NSUInteger findBar_index =
[subviews indexOfObject:[controller_ findBarView]];
EXPECT_NE(NSNotFound, findBar_index);
......@@ -881,6 +882,7 @@ TEST_F(BrowserWindowFullScreenControllerTest, TestActivate) {
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO]);
[[testFullscreenWindow_ contentView] cr_setWantsLayer:YES];
return testFullscreenWindow_.get();
}
@end
......
......@@ -4,6 +4,7 @@
#import "chrome/browser/ui/cocoa/fullscreen_window.h"
#import "chrome/browser/ui/cocoa/nsview_additions.h"
#import "chrome/browser/ui/cocoa/themed_window.h"
@implementation FullscreenWindow
......@@ -27,6 +28,7 @@
// Borderless windows don't usually show up in the Windows menu so whine at
// Cocoa until it complies. See -dealloc and -setTitle: as well.
[NSApp addWindowsItem:self title:@"" filename:NO];
[[self contentView] cr_setWantsLayer:YES];
}
return self;
}
......
......@@ -23,9 +23,19 @@
@interface TabWindowController : NSWindowController<NSWindowDelegate> {
@private
// Wrapper view around web content, and the developer tools view.
base::scoped_nsobject<FastResizeView> tabContentArea_;
// The tab strip overlaps the titlebar of the window.
base::scoped_nsobject<TabStripView> tabStripView_;
// In OSX 10.10+, all views must be added to the NSWindow's contentView. Some
// views (like the tab strip and the profile icon) are placed on top of the
// title bar and require special treatment. All other views should be added
// as subviews of chromeContentView_. This allows tab dragging and fullscreen
// logic to easily move the views that don't need special treatment.
base::scoped_nsobject<NSView> chromeContentView_;
// The child window used during dragging to achieve the opacity tricks.
NSWindow* overlayWindow_;
......@@ -38,6 +48,7 @@
}
@property(readonly, nonatomic) TabStripView* tabStripView;
@property(readonly, nonatomic) FastResizeView* tabContentArea;
@property(readonly, nonatomic) NSView* chromeContentView;
// This is the designated initializer for this class.
- (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip;
......
......@@ -47,7 +47,10 @@
@implementation TabWindowController
- (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip {
NSRect contentRect = NSMakeRect(60, 229, 750, 600);
const CGFloat kDefaultWidth = 750;
const CGFloat kDefaultHeight = 600;
NSRect contentRect = NSMakeRect(60, 229, kDefaultWidth, kDefaultHeight);
base::scoped_nsobject<FramedBrowserWindow> window(
[[FramedBrowserWindow alloc] initWithContentRect:contentRect
hasTabStrip:hasTabStrip]);
......@@ -57,14 +60,20 @@
if ((self = [super initWithWindow:window])) {
[[self window] setDelegate:self];
tabContentArea_.reset([[FastResizeView alloc] initWithFrame:
NSMakeRect(0, 0, 750, 600)]);
chromeContentView_.reset([[NSView alloc]
initWithFrame:NSMakeRect(0, 0, kDefaultWidth, kDefaultHeight)]);
[chromeContentView_
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[[[self window] contentView] addSubview:chromeContentView_];
tabContentArea_.reset(
[[FastResizeView alloc] initWithFrame:[chromeContentView_ bounds]]);
[tabContentArea_ setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
[[[self window] contentView] addSubview:tabContentArea_];
[chromeContentView_ addSubview:tabContentArea_];
tabStripView_.reset([[TabStripView alloc] initWithFrame:
NSMakeRect(0, 0, 750, 37)]);
tabStripView_.reset([[TabStripView alloc]
initWithFrame:NSMakeRect(0, 0, kDefaultWidth, 37)]);
[tabStripView_ setAutoresizingMask:NSViewWidthSizable |
NSViewMinYMargin];
if (hasTabStrip)
......@@ -81,6 +90,10 @@
return tabContentArea_;
}
- (NSView*)chromeContentView {
return chromeContentView_;
}
// Add the top tab strop to the window, above the content box and add it to the
// view hierarchy as a sibling of the content view so it can overlap with the
// window frame.
......@@ -127,7 +140,7 @@
[overlayWindow_ setOpaque:NO];
[overlayWindow_ setDelegate:self];
originalContentView_ = [window contentView];
originalContentView_ = self.chromeContentView;
[window addChildWindow:overlayWindow_ ordered:NSWindowAbove];
// Explicitly set the responder to be nil here (for restoring later).
......@@ -153,7 +166,10 @@
// places. The TabStripView always needs to be in front of the window's
// content view and therefore it should always be added after the content
// view is set.
[window setContentView:originalContentView_];
[[window contentView] addSubview:originalContentView_
positioned:NSWindowBelow
relativeTo:nil];
originalContentView_.frame = [[window contentView] bounds];
[[window cr_windowView] addSubview:[self tabStripView]];
[[window cr_windowView] updateTrackingAreas];
......
......@@ -32,12 +32,6 @@
[super setFrameSize:size];
}
// The contentView gets moved around during certain full-screen operations.
// This is less than ideal, and should eventually be removed.
- (void)viewDidMoveToSuperview {
[self setFrame:[[self superview] bounds]];
}
@end
@implementation NSWindow (VersionIndependentWindow)
......@@ -79,8 +73,8 @@
chromeWindowView_.reset([[FullSizeContentView alloc] init]);
[chromeWindowView_
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[chromeWindowView_ setFrame:[[[self contentView] superview] bounds]];
[self setContentView:chromeWindowView_];
[chromeWindowView_ setFrame:[[[self contentView] superview] bounds]];
}
}
return self;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment