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

Unified Diff: chrome/browser/ui/cocoa/nsview_additions.mm

Issue 11876036: Alternate NTP: Don't hide bookmark bar on instant (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 7 years, 11 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/nsview_additions.mm
diff --git a/chrome/browser/ui/cocoa/nsview_additions.mm b/chrome/browser/ui/cocoa/nsview_additions.mm
index 92103309e7ba0c412e23e77cc2828638fcdbc3cf..6352f08f955e10a995b5e1c92ff7d09808a69ba1 100644
--- a/chrome/browser/ui/cocoa/nsview_additions.mm
+++ b/chrome/browser/ui/cocoa/nsview_additions.mm
@@ -4,6 +4,8 @@
#import "chrome/browser/ui/cocoa/nsview_additions.h"
+#include "base/logging.h"
+
#if !defined(MAC_OS_X_VERSION_10_7) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
@@ -28,4 +30,36 @@
return [self hitTest:mouseLoc] == self;
}
+- (BOOL)cr_isBelowView:(NSView*)otherView {
+ NSArray* subviews = [[self superview] subviews];
+
+ NSUInteger selfIndex = [subviews indexOfObject:self];
+ DCHECK_NE(NSNotFound, selfIndex);
+
+ NSUInteger otherIndex = [subviews indexOfObject:otherView];
+ DCHECK_NE(NSNotFound, otherIndex);
+
+ return selfIndex < otherIndex;
+}
+
+- (BOOL)cr_isAboveView:(NSView*)otherView {
+ return ![self cr_isBelowView:otherView];
+}
+
+- (void)cr_ensureSubview:(NSView*)subview
+ isPositioned:(NSWindowOrderingMode)place
+ relativeTo:(NSView *)otherView {
+ DCHECK(place == NSWindowAbove || place == NSWindowBelow);
+ BOOL isAbove = place == NSWindowAbove;
+ if ([[subview superview] isEqual:self] &&
+ [subview cr_isAboveView:otherView] == isAbove) {
+ return;
+ }
+
+ [subview removeFromSuperview];
+ [self addSubview:subview
+ positioned:place
+ relativeTo:otherView];
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698