summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-04 19:16:28 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-04 19:16:28 +0000
commita3046083f16194a4e5d783e5933b26f7bddb4a8c (patch)
tree04cb7afa214eea31a62cfd82cb9d1f8c9af80f7b
parent61e27acc8de9d271950c4adbae678fa4bdd28a09 (diff)
downloadchromium_src-a3046083f16194a4e5d783e5933b26f7bddb4a8c.zip
chromium_src-a3046083f16194a4e5d783e5933b26f7bddb4a8c.tar.gz
chromium_src-a3046083f16194a4e5d783e5933b26f7bddb4a8c.tar.bz2
Mac: fullscreen mode find bar positioning fix.
Always position the find bar (if visible) below the visually contiguous toolbar (i.e., toolbar + maybe bookmark bar). In fullscreen mode, this may mean that it hangs off the top of the screen, which is intended. BUG=31638 TEST=Find bar still works normally (and is positioned correctly) in non-fullscreen mode. For developers who know how to enable fullscreen mode, it should be positioned as described above and work correctly. Review URL: http://codereview.chromium.org/572006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38119 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm30
-rw-r--r--chrome/browser/cocoa/find_bar_cocoa_controller.h8
-rw-r--r--chrome/browser/cocoa/find_bar_cocoa_controller.mm31
3 files changed, 35 insertions, 34 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index 6dda638..39d28dc 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -1287,11 +1287,18 @@ willPositionSheet:(NSWindow*)sheet
// Create a controller for the findbar.
findBarCocoaController_.reset([findBarCocoaController retain]);
- [[[self window] contentView] addSubview:[findBarCocoaController_ view]
- positioned:NSWindowAbove
- relativeTo:[toolbarController_ view]];
- [findBarCocoaController_
- positionFindBarView:[infoBarContainerController_ view]];
+ NSView *contentView = [[self window] contentView];
+ [contentView addSubview:[findBarCocoaController_ view]
+ positioned:NSWindowAbove
+ relativeTo:[toolbarController_ view]];
+
+ // Place the find bar immediately below the toolbar/attached bookmark bar. In
+ // fullscreen mode, it hangs off the top of the screen when the bar is hidden.
+ CGFloat maxY = [self placeBookmarkBarBelowInfoBar] ?
+ NSMinY([[toolbarController_ view] frame]) :
+ NSMinY([[bookmarkBarController_ view] frame]);
+ CGFloat maxWidth = NSWidth([contentView frame]);
+ [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth];
}
- (NSWindow*)createFullscreenWindow {
@@ -1913,15 +1920,20 @@ willPositionSheet:(NSWindow*)sheet
[fullscreenController_ overlayFrameChanged:[floatingBarBackingView_ frame]];
+ // Place the find bar immediately below the toolbar/attached bookmark bar. In
+ // fullscreen mode, it hangs off the top of the screen when the bar is hidden.
+ [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:width];
+
// If in fullscreen mode, reset |maxY| to top of screen, so that the floating
// bar slides over the things which appear to be in the content area.
if (isFullscreen)
maxY = NSMaxY(contentBounds);
- // Place the infobar container in place below the toolbar.
+ // Also place the infobar container immediate below the toolbar, except in
+ // fullscreen mode in which case it's at the top of the visual content area.
maxY = [self layoutInfoBarAtMaxY:maxY width:width];
- // If the bookmark bar is detached, place it at the bottom of the stack.
+ // If the bookmark bar is detached, place it next in the visual content area.
if (placeBookmarkBarBelowInfoBar)
maxY = [self layoutBookmarkBarAtMaxY:maxY width:width];
@@ -1931,10 +1943,6 @@ willPositionSheet:(NSWindow*)sheet
// Finally, the content area takes up all of the remaining space.
[self layoutTabContentAreaAtMinY:minY maxY:maxY width:width];
- // Position the find bar relative to the infobar container.
- [findBarCocoaController_
- positionFindBarView:[infoBarContainerController_ view]];
-
// Place the status bubble at the bottom of the content area.
verticalOffsetForStatusBubble_ = minY;
diff --git a/chrome/browser/cocoa/find_bar_cocoa_controller.h b/chrome/browser/cocoa/find_bar_cocoa_controller.h
index 21ce106..6b3cf55 100644
--- a/chrome/browser/cocoa/find_bar_cocoa_controller.h
+++ b/chrome/browser/cocoa/find_bar_cocoa_controller.h
@@ -55,9 +55,11 @@ class FindNotificationDetails;
- (IBAction)previousResult:(id)sender;
-// Positions the find bar based on the location of the infobar container.
-// TODO(rohitrao): Move this logic into BrowserWindowController.
-- (void)positionFindBarView:(NSView*)infoBarContainerView;
+// Position the find bar at the given maximum y-coordinate (the min-y of the
+// bar -- toolbar + possibly bookmark bar, but not including the infobars) with
+// the given maximum width (i.e., the find bar should fit between 0 and
+// |maxWidth|).
+- (void)positionFindBarViewAtMaxY:(CGFloat)maxY maxWidth:(CGFloat)maxWidth;
// Methods called from FindBarBridge.
- (void)showFindBar:(BOOL)animate;
diff --git a/chrome/browser/cocoa/find_bar_cocoa_controller.mm b/chrome/browser/cocoa/find_bar_cocoa_controller.mm
index 05ae37a..c78a1bc 100644
--- a/chrome/browser/cocoa/find_bar_cocoa_controller.mm
+++ b/chrome/browser/cocoa/find_bar_cocoa_controller.mm
@@ -99,27 +99,18 @@ const float kFindBarCloseDuration = 0.15;
stopSearch:YES];
}
-// Positions the find bar container view in the correct location based on the
-// current state of the window. The find bar container is always positioned one
-// pixel above the infobar container. Note that we are using the infobar
-// container location as a proxy for the toolbar location, but we cannot
-// position based on the toolbar because the toolbar is not always present (for
-// example in fullscreen windows).
-- (void)positionFindBarView:(NSView*)infoBarContainerView {
- static const int kRightEdgeOffset = 25;
+- (void)positionFindBarViewAtMaxY:(CGFloat)maxY maxWidth:(CGFloat)maxWidth {
+ static const CGFloat kRightEdgeOffset = 25;
NSView* containerView = [self view];
- int containerHeight = NSHeight([containerView frame]);
- int containerWidth = NSWidth([containerView frame]);
-
- // Start by computing the upper right corner of the infobar container, then
- // move left by a constant offset and up one pixel. This gives us the upper
- // right corner of our bounding box. We move up one pixel to overlap with the
- // toolbar area, which allows us to cover up the toolbar's border, if present.
- NSRect windowRect = [infoBarContainerView frame];
- int max_x = NSMaxX(windowRect) - kRightEdgeOffset;
- int max_y = NSMaxY(windowRect) + 1;
-
- NSRect newFrame = NSMakeRect(max_x - containerWidth, max_y - containerHeight,
+ CGFloat containerHeight = NSHeight([containerView frame]);
+ CGFloat containerWidth = NSWidth([containerView frame]);
+
+ // Adjust where we'll actually place the find bar.
+ CGFloat maxX = maxWidth - kRightEdgeOffset;
+ DLOG_IF(WARNING, maxX < 0) << "Window too narrow for find bar";
+ maxY += 1;
+
+ NSRect newFrame = NSMakeRect(maxX - containerWidth, maxY - containerHeight,
containerWidth, containerHeight);
[containerView setFrame:newFrame];
}