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

Unified Diff: chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.mm

Issue 23139002: Merge 217139 "[Mac] Change to detach the web contents view when ..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1547/src/
Patch Set: Created 7 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.mm
===================================================================
--- chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.mm (revision 217358)
+++ chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.mm (working copy)
@@ -803,17 +803,32 @@
}
- (void)windowDidResize:(NSNotification*)notification {
- // Hide the web contents view when the panel is not taller than the titlebar.
- // This is to ensure that the titlebar view is not overlapped with the web
- // contents view because the the web contents view assumes that its
- // view will never be overlapped by another view in order to perform
- // optimization. If we do not do this, some part of the web contents view
- // will become visible and overlapp the bottom area of the titlebar.
- if (WebContents* contents = windowShim_->panel()->GetWebContents()) {
- BOOL hideContents =
- NSHeight([self contentRectForFrameRect:[[self window] frame]]) <=
- panel::kTitlebarHeight;
- [contents->GetView()->GetNativeView() setHidden:hideContents];
+ // Remove the web contents view from the view hierarchy when the panel is not
+ // taller than the titlebar. Put it back when the panel grows taller than
+ // the titlebar. Note that RenderWidgetHostViewMac works for the case that
+ // the web contents view does not exist in the view hierarchy (i.e. the tab
+ // is not the main one), but it does not work well, like causing occasional
+ // crashes (http://crbug.com/265932), if the web contents view is made hidden.
+ //
+ // The reason for doing this is to ensure that our titlebar view, that is
+ // somewhat taller than the standard titlebar, does not overlap with the web
+ // contents view because the the web contents view assumes that its view will
+ // never overlap with another view in order to paint the web contents view
+ // directly. If we do not do this, some part of the web contents view will
+ // become visible and overlap the bottom area of the titlebar.
+ content::WebContents* webContents = windowShim_->panel()->GetWebContents();
+ if (!webContents)
+ return;
+ NSView* contentView = webContents->GetView()->GetNativeView();
+ if (NSHeight([self contentRectForFrameRect:[[self window] frame]]) <=
+ panel::kTitlebarHeight) {
+ // No need to retain the view before it is removed from its superview
+ // because WebContentsView keeps a reference to this view.
+ if ([contentView superview])
+ [contentView removeFromSuperview];
+ } else {
+ if (![contentView superview])
+ [[[self window] contentView] addSubview:contentView];
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698