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

Unified Diff: chrome/browser/cocoa/toolbar_controller.mm

Issue 173439: [Mac] The autocomplete popup now gets its position from the toolbar controlle... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 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 | « chrome/browser/cocoa/toolbar_controller.h ('k') | chrome/browser/cocoa/toolbar_controller_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/toolbar_controller.mm
===================================================================
--- chrome/browser/cocoa/toolbar_controller.mm (revision 24441)
+++ chrome/browser/cocoa/toolbar_controller.mm (working copy)
@@ -6,7 +6,9 @@
#include "base/mac_util.h"
#include "base/sys_string_conversions.h"
+#include "base/gfx/rect.h"
#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/autocomplete/autocomplete_popup_view.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"
@@ -35,6 +37,26 @@
- (void)prefChanged:(std::wstring*)prefName;
@end
+namespace {
+
+// A C++ class used to correctly position the autocomplete popup.
+class AutocompletePopupPositionerMac : public AutocompletePopupPositioner {
+ public:
+ AutocompletePopupPositionerMac(ToolbarController* controller)
+ : controller_(controller) { }
+ virtual ~AutocompletePopupPositionerMac() { }
+
+ // Overridden from AutocompletePopupPositioner.
+ virtual gfx::Rect GetPopupBounds() const {
+ return [controller_ autocompletePopupPosition];
+ }
+
+ private:
+ ToolbarController* controller_; // weak, owns us
+};
+
+} // namespace
+
namespace ToolbarControllerInternal {
// A C++ class registered for changes in preferences. Bridges the
@@ -54,7 +76,7 @@
ToolbarController* controller_; // weak, owns us
};
-} // namespace
+} // namespace ToolbarControllerInternal
@implementation ToolbarController
@@ -99,8 +121,11 @@
// bar and button state.
- (void)awakeFromNib {
[self initCommandStatus:commands_];
- locationBarView_.reset(new LocationBarViewMac(locationBar_, commands_,
- toolbarModel_, profile_));
+ popupPositioner_.reset(new AutocompletePopupPositionerMac(self));
+ locationBarView_.reset(new LocationBarViewMac(locationBar_,
+ popupPositioner_.get(),
+ commands_, toolbarModel_,
+ profile_));
[locationBar_ setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
// Register pref observers for the optional home and page/options buttons
@@ -378,5 +403,16 @@
fromView:starButton_];
}
+- (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.
+ NSRect locationFrame = [locationBar_ frame];
+ 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]));
+}
@end
« no previous file with comments | « chrome/browser/cocoa/toolbar_controller.h ('k') | chrome/browser/cocoa/toolbar_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698