diff options
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/location_bar_view_mac.h | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/location_bar_view_mac.mm | 15 | ||||
-rw-r--r-- | chrome/browser/cocoa/toolbar_controller.h | 14 | ||||
-rw-r--r-- | chrome/browser/cocoa/toolbar_controller.mm | 46 | ||||
-rw-r--r-- | chrome/browser/cocoa/toolbar_controller_unittest.mm | 21 |
5 files changed, 52 insertions, 48 deletions
diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h index f04b11e..d765a83 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.h +++ b/chrome/browser/cocoa/location_bar_view_mac.h @@ -13,8 +13,8 @@ #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" #include "chrome/browser/location_bar.h" -class AutocompletePopupPositioner; @class AutocompleteTextField; +class BubblePositioner; class CommandUpdater; class Profile; class ToolbarModel; @@ -28,7 +28,7 @@ class LocationBarViewMac : public AutocompleteEditController, public LocationBarTesting { public: LocationBarViewMac(AutocompleteTextField* field, - AutocompletePopupPositioner* positioner, + const BubblePositioner* bubble_positioner, CommandUpdater* command_updater, ToolbarModel* toolbar_model, Profile* profile); diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm index bbf8a66..42262ee 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar_view_mac.mm @@ -45,13 +45,14 @@ std::wstring GetKeywordName(Profile* profile, const std::wstring& keyword) { } // namespace -LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field, - AutocompletePopupPositioner* positioner, - CommandUpdater* command_updater, - ToolbarModel* toolbar_model, - Profile* profile) - : edit_view_(new AutocompleteEditViewMac(this, positioner, toolbar_model, - profile, command_updater, field)), +LocationBarViewMac::LocationBarViewMac( + AutocompleteTextField* field, + const BubblePositioner* bubble_positioner, + CommandUpdater* command_updater, + ToolbarModel* toolbar_model, + Profile* profile) + : edit_view_(new AutocompleteEditViewMac(this, bubble_positioner, + toolbar_model, profile, command_updater, field)), command_updater_(command_updater), field_(field), disposition_(CURRENT_TAB), diff --git a/chrome/browser/cocoa/toolbar_controller.h b/chrome/browser/cocoa/toolbar_controller.h index d86b1fc..f61822f 100644 --- a/chrome/browser/cocoa/toolbar_controller.h +++ b/chrome/browser/cocoa/toolbar_controller.h @@ -15,16 +15,16 @@ #import "chrome/browser/cocoa/view_resizer.h" #include "chrome/common/pref_member.h" -class AutocompletePopupPositioner; @class AutocompleteTextField; @class AutocompleteTextFieldEditor; @class BackForwardMenuController; -@class DelayedMenuButton; -@class MenuButton; class Browser; +class BubblePositioner; class CommandUpdater; +@class DelayedMenuButton; class LocationBar; class LocationBarViewMac; +@class MenuButton; namespace ToolbarControllerInternal { class PrefObserverBridge; } @@ -35,7 +35,7 @@ class ToolbarView; // A controller for the toolbar in the browser window. Manages // updating the state for location bar and back/fwd/reload/go buttons. -// Manages the bookmark bar and it's position in the window relative to +// Manages the bookmark bar and its position in the window relative to // the web content view. @interface ToolbarController : @@ -56,8 +56,8 @@ class ToolbarView; // Used for monitoring the optional toolbar button prefs. scoped_ptr<ToolbarControllerInternal::PrefObserverBridge> prefObserver_; - // Used to positioner the omnibox popup view. - scoped_ptr<AutocompletePopupPositioner> popupPositioner_; + // Used to position the omnibox bubble. + scoped_ptr<BubblePositioner> bubblePositioner_; BooleanPrefMember showHomeButton_; BooleanPrefMember showPageOptionButtons_; BOOL hasToolbar_; // if NO, we only have the location bar. @@ -146,7 +146,7 @@ class ToolbarView; - (NSArray*)toolbarViews; - (void)showOptionalHomeButton; - (void)showOptionalPageWrenchButtons; -- (gfx::Rect)autocompletePopupPosition; +- (gfx::Rect)locationStackBounds; // Return a hover button for the current event. - (NSButton*)hoverButtonForEvent:(NSEvent*)theEvent; @end diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm index c7c0ad3..65350f7 100644 --- a/chrome/browser/cocoa/toolbar_controller.mm +++ b/chrome/browser/cocoa/toolbar_controller.mm @@ -10,7 +10,7 @@ #include "base/gfx/rect.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/autocomplete/autocomplete_edit_view.h" -#include "chrome/browser/autocomplete/autocomplete_popup_view.h" +#include "chrome/browser/bubble_positioner.h" #import "chrome/browser/cocoa/autocomplete_text_field.h" #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" #import "chrome/browser/cocoa/back_forward_menu_controller.h" @@ -44,16 +44,16 @@ static const float kBookmarkBarOverlap = 7.0; namespace { -// A C++ class used to correctly position the autocomplete popup. -class AutocompletePopupPositionerMac : public AutocompletePopupPositioner { +// A C++ class used to correctly position the omnibox. +class BubblePositionerMac : public BubblePositioner { public: - AutocompletePopupPositionerMac(ToolbarController* controller) + BubblePositionerMac(ToolbarController* controller) : controller_(controller) { } - virtual ~AutocompletePopupPositionerMac() { } + virtual ~BubblePositionerMac() { } - // Overridden from AutocompletePopupPositioner. - virtual gfx::Rect GetPopupBounds() const { - return [controller_ autocompletePopupPosition]; + // BubblePositioner: + virtual gfx::Rect GetLocationStackBounds() const { + return [controller_ locationStackBounds]; } private: @@ -128,9 +128,9 @@ class PrefObserverBridge : public NotificationObserver { // bar and button state. - (void)awakeFromNib { [self initCommandStatus:commands_]; - popupPositioner_.reset(new AutocompletePopupPositionerMac(self)); + bubblePositioner_.reset(new BubblePositionerMac(self)); locationBarView_.reset(new LocationBarViewMac(locationBar_, - popupPositioner_.get(), + bubblePositioner_.get(), commands_, toolbarModel_, profile_)); [locationBar_ setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]]; @@ -514,19 +514,25 @@ class PrefObserverBridge : public NotificationObserver { } -- (gfx::Rect)autocompletePopupPosition { - // The popup should span from the left edge of the star button to the right - // edge of the go button. The returned height is ignored. +- (gfx::Rect)locationStackBounds { + // The number of pixels from the left or right edges of the location stack to + // "just inside the visible borders". When the omnibox bubble contents are + // aligned with this, the visible borders tacked on to the outsides will line + // up with the visible borders on the location stack. + const int kLocationStackEdgeWidth = 2; + NSRect locationFrame = [locationBar_ frame]; - // TODO(shess): The buttons have an extra 2 pixels between the edge - // of the visual button and the edge of the logical button. This - // seems wrong. - int minX = NSMinX([starButton_ frame]) + 2.0; - int maxX = NSMaxX([goButton_ frame]) - 2.0; + int minX = NSMinX([starButton_ frame]); + int maxX = NSMaxX([goButton_ frame]); DCHECK(minX < NSMinX(locationFrame)); DCHECK(maxX > NSMaxX(locationFrame)); - NSRect r = NSMakeRect(minX, NSMinY(locationFrame), maxX - minX, 0); - return gfx::Rect(NSRectToCGRect([[self view] convertRect:r toView:nil])); + NSRect r = NSMakeRect(minX, NSMinY(locationFrame), maxX - minX, + NSHeight(locationFrame)); + gfx::Rect stack_bounds( + NSRectToCGRect([[self view] convertRect:r toView:nil])); + // Inset the bounds to just inside the visible edges (see comment above). + stack_bounds.Inset(kLocationStackEdgeWidth, 0); + return stack_bounds; } @end diff --git a/chrome/browser/cocoa/toolbar_controller_unittest.mm b/chrome/browser/cocoa/toolbar_controller_unittest.mm index 21f9e61..9ba3236 100644 --- a/chrome/browser/cocoa/toolbar_controller_unittest.mm +++ b/chrome/browser/cocoa/toolbar_controller_unittest.mm @@ -273,7 +273,7 @@ TEST_F(ToolbarControllerTest, StarButtonInWindowCoordinates) { EXPECT_TRUE(NSContainsRect(all, star)); } -TEST_F(ToolbarControllerTest, AutocompletePopupPosition) { +TEST_F(ToolbarControllerTest, BubblePosition) { NSView* locationBar = [[bar_ toolbarViews] objectAtIndex:kLocationIndex]; // The window frame (in window base coordinates). @@ -281,17 +281,14 @@ TEST_F(ToolbarControllerTest, AutocompletePopupPosition) { // The frame of the location bar in window base coordinates. NSRect locationFrame = [locationBar convertRect:[locationBar bounds] toView:nil]; - // The frame of the popup in window base coordinates. - gfx::Rect popupFrame = [bar_ autocompletePopupPosition]; - - // Make sure the popup starts to the left of and ends to the right of the - // location bar. - EXPECT_LT(popupFrame.x(), NSMinX(locationFrame)); - EXPECT_GT(popupFrame.right(), NSMaxX(locationFrame)); - - // Make sure the popup frame is positioned above the bottom of the - // location bar. - EXPECT_GE(popupFrame.bottom(), NSMinY(locationFrame)); + // The frame of the location stack in window base coordinates. The horizontal + // coordinates here are used for the omnibox dropdown. + gfx::Rect locationStackFrame = [bar_ locationStackBounds]; + + // Make sure the location stack starts to the left of and ends to the right of + // the location bar. + EXPECT_LT(locationStackFrame.x(), NSMinX(locationFrame)); + EXPECT_GT(locationStackFrame.right(), NSMaxX(locationFrame)); } TEST_F(ToolbarControllerTest, HoverButtonForEvent) { |