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

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

Issue 22629009: [Mac] Change to detach the web contents view when the panel is not taller than the titlebar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedbacks 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
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 7fcf282ac7fee575d9e12ad6e763a7f015eb3c6b..75c1cd95b3beb810094a458e4108c0e1f9c0a1ba 100644
--- a/chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.mm
+++ b/chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.mm
@@ -7,7 +7,6 @@
#import <Cocoa/Cocoa.h>
#include "base/auto_reset.h"
-#include "base/command_line.h"
#include "base/logging.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/mac_util.h"
@@ -31,7 +30,6 @@
#include "chrome/browser/ui/panels/panel_manager.h"
#include "chrome/browser/ui/tabs/tab_strip_model.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/web_contents.h"
#include "content/public/browser/web_contents_view.h"
@@ -809,23 +807,32 @@ NSCursor* LoadWebKitCursor(WebKit::WebCursorInfo::Type type) {
}
- (void)windowDidResize:(NSNotification*)notification {
- // This is a temporary check to track down a crash that occurs occasionally
- // (http://crbug.com/265932).
- chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
- if (channel == chrome::VersionInfo::CHANNEL_CANARY &&
- CommandLine::ForCurrentProcess()->HasSwitch("enable-panel-experiment"))
+ // 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 overlapp the bottom area of the titlebar.
ccameron 2013/08/13 00:43:22 nit: s/overlapp/overlap/
+ content::WebContents* webContents = windowShim_->panel()->GetWebContents();
+ if (!webContents)
return;
- // 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];
+ 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