diff options
author | erikchen <erikchen@chromium.org> | 2014-10-10 12:56:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-10 19:56:54 +0000 |
commit | 9fa914507cbcce4fb7f05501106d0a5183d3dff9 (patch) | |
tree | 733a7c20de8c5138ac0d103c92456ed2c3176137 /chrome/browser/ui/cocoa/browser_window_controller_unittest.mm | |
parent | 22c781e61a21d95a102e0e72c76f05c2bbe58093 (diff) | |
download | chromium_src-9fa914507cbcce4fb7f05501106d0a5183d3dff9.zip chromium_src-9fa914507cbcce4fb7f05501106d0a5183d3dff9.tar.gz chromium_src-9fa914507cbcce4fb7f05501106d0a5183d3dff9.tar.bz2 |
mac: Use a full-size content view (reland 1).
The original attempt to land the CL incorrectly interacted with another
recently landed CL that added the tabStripBackgroundView
(https://codereview.chromium.org/611453004). This CL was causing that view to
become layer backed, which caused it to draw on top of non-layer backed window
content, including the window controls.
This reland reworks the logic so that the tabStripBackgroundView is added to
the root view and does not become layer backed. This reland also updates
browser_tests to catch similar such errors in the future.
--------------Original CL Description---------------
Make the window's contentView have the same size as the window itself. Adjust
the view hierarchy so that Chrome does not add subviews directly to the root
view.
By default, the contentView does not occupy the full size of a framed window.
Chrome still wants to draw in the title bar. Historically, Chrome has done this
by adding subviews directly to the root view. This causes several problems. The
most egregious is related to layer ordering when the root view does not have a
layer. By making the window's contentView full-sized, there is no longer any
need to add subviews to the root view.
I deleted the tests in presentation_mode_controller_unittest.mm since they were
layout tests for the browser_window_controller, but the tests in
browser_window_layout_unittest.mm are both more robust and more comprehensive.
I fixed a bug in moveViewsForImmersiveFullscreen:... where the tabStripView was
being added to the source window rather than the destination window.
This CL is mostly a reland of https://codereview.chromium.org/399803002/.
Original CL Committed: https://crrev.com/746dbb9cfefaac243704956db431ff9bb9b0485b
Original CL Cr-Commit-Position: refs/heads/master@{#298584}
BUG=417923
Review URL: https://codereview.chromium.org/646703002
Cr-Commit-Position: refs/heads/master@{#299168}
Diffstat (limited to 'chrome/browser/ui/cocoa/browser_window_controller_unittest.mm')
-rw-r--r-- | chrome/browser/ui/cocoa/browser_window_controller_unittest.mm | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm index bdc6a3f..06af3cf 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm @@ -20,6 +20,7 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" +#import "chrome/browser/ui/cocoa/fast_resize_view.h" #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" #include "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" @@ -241,21 +242,63 @@ TEST_F(BrowserWindowControllerTest, TestIncognitoWidthSpace) { namespace { +// Returns the frame of the view in window coordinates. +NSRect FrameInWindowForView(NSView* view) { + return [[view superview] convertRect:[view frame] toView:nil]; +} + +// Whether the view's frame is within the bounds of the superview. +BOOL ViewContainmentValid(NSView* view) { + if (NSIsEmptyRect([view frame])) + return YES; + + return NSContainsRect([[view superview] bounds], [view frame]); +} + +// Checks the view hierarchy rooted at |view| to ensure that each view is +// properly contained. +BOOL ViewHierarchyContainmentValid(NSView* view) { + // TODO(erikchen): Fix these views to have correct containment. + // http://crbug.com/397665. + if ([view isKindOfClass:NSClassFromString(@"DownloadShelfView")]) + return YES; + if ([view isKindOfClass:NSClassFromString(@"BookmarkBarToolbarView")]) + return YES; + if ([view isKindOfClass:NSClassFromString(@"BrowserActionsContainerView")]) + return YES; + + if (!ViewContainmentValid(view)) { + LOG(ERROR) << "View violates containment: " << + [[view description] UTF8String]; + return NO; + } + + for (NSView* subview in [view subviews]) { + BOOL result = ViewHierarchyContainmentValid(subview); + if (!result) + return NO; + } + + return YES; +} + // Verifies that the toolbar, infobar, tab content area, and download shelf // completely fill the area under the tabstrip. void CheckViewPositions(BrowserWindowController* controller) { - NSRect contentView = [[[controller window] contentView] bounds]; - NSRect tabstrip = [[controller tabStripView] frame]; - NSRect toolbar = [[controller toolbarView] frame]; - NSRect infobar = [[controller infoBarContainerView] frame]; - NSRect contentArea = [[controller tabContentArea] frame]; + EXPECT_TRUE(ViewHierarchyContainmentValid([[controller window] contentView])); + + NSRect contentView = FrameInWindowForView([[controller window] contentView]); + NSRect tabstrip = FrameInWindowForView([controller tabStripView]); + NSRect toolbar = FrameInWindowForView([controller toolbarView]); + NSRect infobar = FrameInWindowForView([controller infoBarContainerView]); + NSRect tabContent = FrameInWindowForView([controller tabContentArea]); NSRect download = NSZeroRect; if ([[[controller downloadShelf] view] superview]) download = [[[controller downloadShelf] view] frame]; EXPECT_EQ(NSMinY(contentView), NSMinY(download)); - EXPECT_EQ(NSMaxY(download), NSMinY(contentArea)); - EXPECT_EQ(NSMaxY(contentArea), NSMinY(infobar)); + EXPECT_EQ(NSMaxY(download), NSMinY(tabContent)); + EXPECT_EQ(NSMaxY(tabContent), NSMinY(infobar)); // Bookmark bar frame is random memory when hidden. if ([controller bookmarkBarVisible]) { @@ -620,7 +663,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); @@ -888,6 +931,7 @@ TEST_F(BrowserWindowFullScreenControllerTest, DISABLED_TestActivate) { styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]); + [[testFullscreenWindow_ contentView] setWantsLayer:YES]; return testFullscreenWindow_.get(); } @end |