Commit f4860129 authored by jianli@chromium.org's avatar jianli@chromium.org

[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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217139 0039d316-1c4b-4281-b951-d872f2087c98
parent c092858a
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/bundle_locations.h" #include "base/mac/bundle_locations.h"
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
...@@ -31,7 +30,6 @@ ...@@ -31,7 +30,6 @@
#include "chrome/browser/ui/panels/panel_manager.h" #include "chrome/browser/ui/panels/panel_manager.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/toolbar/encoding_menu_controller.h" #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
#include "chrome/common/chrome_version_info.h"
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_contents_view.h"
...@@ -809,23 +807,32 @@ NSCursor* LoadWebKitCursor(WebKit::WebCursorInfo::Type type) { ...@@ -809,23 +807,32 @@ NSCursor* LoadWebKitCursor(WebKit::WebCursorInfo::Type type) {
} }
- (void)windowDidResize:(NSNotification*)notification { - (void)windowDidResize:(NSNotification*)notification {
// This is a temporary check to track down a crash that occurs occasionally // Remove the web contents view from the view hierarchy when the panel is not
// (http://crbug.com/265932). // taller than the titlebar. Put it back when the panel grows taller than
chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); // the titlebar. Note that RenderWidgetHostViewMac works for the case that
if (channel == chrome::VersionInfo::CHANNEL_CANARY && // the web contents view does not exist in the view hierarchy (i.e. the tab
CommandLine::ForCurrentProcess()->HasSwitch("enable-panel-experiment")) // 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; return;
// Hide the web contents view when the panel is not taller than the titlebar. NSView* contentView = webContents->GetView()->GetNativeView();
// This is to ensure that the titlebar view is not overlapped with the web if (NSHeight([self contentRectForFrameRect:[[self window] frame]]) <=
// contents view because the the web contents view assumes that its panel::kTitlebarHeight) {
// view will never be overlapped by another view in order to perform // No need to retain the view before it is removed from its superview
// optimization. If we do not do this, some part of the web contents view // because WebContentsView keeps a reference to this view.
// will become visible and overlapp the bottom area of the titlebar. if ([contentView superview])
if (WebContents* contents = windowShim_->panel()->GetWebContents()) { [contentView removeFromSuperview];
BOOL hideContents = } else {
NSHeight([self contentRectForFrameRect:[[self window] frame]]) <= if (![contentView superview])
panel::kTitlebarHeight; [[[self window] contentView] addSubview:contentView];
[contents->GetView()->GetNativeView() setHidden:hideContents];
} }
} }
......
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