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

Unified Diff: chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm

Issue 12224052: Alternate NTP: Fix bug where shadow is not removed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 7 years, 10 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
Index: chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm
diff --git a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm
index fc9fb756a9148bb78c463fdc7903943d30dc21ba..662eaf6cfd141b707a0dabf1d03fd62d31859292 100644
--- a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm
+++ b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm
@@ -51,12 +51,10 @@
[super dealloc];
}
-- (void)showPreview:(content::WebContents*)preview
- height:(CGFloat)height
- heightUnits:(InstantSizeUnits)heightUnits
- drawDropShadow:(BOOL)drawDropShadow {
- DCHECK(preview);
-
+- (void)setPreview:(content::WebContents*)preview
+ height:(CGFloat)height
+ heightUnits:(InstantSizeUnits)heightUnits
+ drawDropShadow:(BOOL)drawDropShadow {
// If drawing drop shadow, clip the bottom 1-px-thick separator out of
// preview.
// TODO(sail): remove this when GWS gives chrome the height without the
@@ -72,8 +70,10 @@
}
// Remove any old preview contents before showing the new one.
- if (previewContents_)
+ if (previewContents_) {
[previewContents_->GetNativeView() removeFromSuperview];
+ previewContents_->WasHidden();
+ }
previewContents_ = preview;
previewHeight_ = height;
@@ -81,9 +81,11 @@
drawDropShadow_ = drawDropShadow;
// Add the preview contents.
- [[[self view] window] disableScreenUpdatesUntilFlush];
- previewContents_->GetView()->SetAllowOverlappingViews(true);
- [[self view] addSubview:previewContents_->GetNativeView()];
+ if (previewContents_) {
+ [[[self view] window] disableScreenUpdatesUntilFlush];
+ previewContents_->GetView()->SetAllowOverlappingViews(true);
+ [[self view] addSubview:previewContents_->GetNativeView()];
+ }
if (drawDropShadow_) {
if (!dropShadowView_) {
@@ -98,28 +100,20 @@
[self layoutViews];
- previewContents_->WasShown();
-}
-
-- (void)hidePreview {
- // There may be no previewContents_ in the prerender case.
- if (!previewContents_)
- return;
-
- // Remove the preview contents.
- [previewContents_->GetNativeView() removeFromSuperview];
- previewContents_->WasHidden();
- previewContents_ = nil;
-
- drawDropShadow_ = false;
- [dropShadowView_ removeFromSuperview];
- dropShadowView_.reset();
+ if (previewContents_)
+ previewContents_->WasShown();
}
- (void)onActivateTabWithContents:(content::WebContents*)contents {
if (previewContents_ == contents) {
- [previewContents_->GetNativeView() removeFromSuperview];
- previewContents_ = nil;
+ if (previewContents_) {
+ [previewContents_->GetNativeView() removeFromSuperview];
+ previewContents_ = NULL;
+ }
+ [self setPreview:NULL
+ height:0
+ heightUnits:INSTANT_SIZE_PIXELS
+ drawDropShadow:NO];
}
}

Powered by Google App Engine
This is Rietveld 408576698