summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 23:06:02 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 23:06:02 +0000
commit8657a412879c6a030083b552608e043b6b413db3 (patch)
tree4d149abc1b0b58057244f50b792a9f1060fec779
parent800d3fe6b871d72851751ef1b60afc307925a108 (diff)
downloadchromium_src-8657a412879c6a030083b552608e043b6b413db3.zip
chromium_src-8657a412879c6a030083b552608e043b6b413db3.tar.gz
chromium_src-8657a412879c6a030083b552608e043b6b413db3.tar.bz2
Merge 217139 "[Mac] Change to detach the web contents view when ..."
> [Mac] Change to detach the web contents view when the panel is not taller than the titlebar. > > We used to hide the web contents view in such case but it seems to trigger some bad effect occasionally. > > BUG=265932 > TEST=existing tests > R=ccameron@chromium.org, dimich@chromium.org > > Review URL: https://codereview.chromium.org/22629009 TBR=jianli@chromium.org Review URL: https://codereview.chromium.org/23139002 git-svn-id: svn://svn.chromium.org/chrome/branches/1547/src@217371 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.mm37
1 files changed, 26 insertions, 11 deletions
diff --git a/chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.mm b/chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.mm
index fbd7e32..4fb08ee 100644
--- a/chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.mm
+++ b/chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.mm
@@ -803,17 +803,32 @@ NSCursor* LoadWebKitCursor(WebKit::WebCursorInfo::Type type) {
}
- (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];
}
}