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

Side by Side Diff: chrome/browser/cocoa/toolbar_controller.mm

Issue 1608001: [Mac] Line up omnibox popup under field. (Closed)
Patch Set: Wordsmith and test fix. Created 10 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/cocoa/toolbar_controller.h" 5 #import "chrome/browser/cocoa/toolbar_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util_mac.h" 9 #include "app/l10n_util_mac.h"
10 #include "base/mac_util.h" 10 #include "base/mac_util.h"
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 template_url_model->GetTemplateURLForKeyword(keyword); 841 template_url_model->GetTemplateURLForKeyword(keyword);
842 if (!provider) 842 if (!provider)
843 return nil; 843 return nil;
844 std::wstring shortName(provider->AdjustedShortNameForLocaleDirection()); 844 std::wstring shortName(provider->AdjustedShortNameForLocaleDirection());
845 return l10n_util::GetNSStringF(IDS_TOOLTIP_GO_SEARCH, 845 return l10n_util::GetNSStringF(IDS_TOOLTIP_GO_SEARCH,
846 WideToUTF16(shortName), currentText16); 846 WideToUTF16(shortName), currentText16);
847 847
848 } 848 }
849 849
850 - (gfx::Rect)locationStackBounds { 850 - (gfx::Rect)locationStackBounds {
851 // The number of pixels from the left or right edges of the location stack to 851 // The field has a single-pixel border on the left and right. This
852 // "just inside the visible borders". When the omnibox bubble contents are 852 // needs to be factored out so that the popup window's border (which
853 // aligned with this, the visible borders tacked on to the outsides will line 853 // is outside the frame) lines up.
854 // up with the visible borders on the location stack. 854 const int kLocationStackEdgeWidth = 1;
855 const int kLocationStackEdgeWidth = 2;
856 855
857 const NSRect locationFrame = [locationBar_ frame]; 856 const NSRect locationFrame = [locationBar_ frame];
858
859 // Expand to include star and go buttons. Including the widths
860 // rather that calculating from their current placement because this
861 // method can be called while the resize is still rearranging the
862 // views involved.
863 const CGFloat minX = NSMinX(locationFrame) - NSWidth([starButton_ frame]);
864 const CGFloat maxX = NSMaxX(locationFrame) + NSWidth([goButton_ frame]);
865
866 NSRect r = NSMakeRect(minX, NSMinY(locationFrame), maxX - minX,
867 NSHeight(locationFrame));
868 gfx::Rect stack_bounds( 857 gfx::Rect stack_bounds(
869 NSRectToCGRect([[self view] convertRect:r toView:nil])); 858 NSRectToCGRect([[self view] convertRect:locationFrame toView:nil]));
870 // Inset the bounds to just inside the visible edges (see comment above).
871 stack_bounds.Inset(kLocationStackEdgeWidth, 0); 859 stack_bounds.Inset(kLocationStackEdgeWidth, 0);
872 return stack_bounds; 860 return stack_bounds;
873 } 861 }
874 862
875 // (URLDropTargetController protocol) 863 // (URLDropTargetController protocol)
876 - (void)dropURLs:(NSArray*)urls inView:(NSView*)view at:(NSPoint)point { 864 - (void)dropURLs:(NSArray*)urls inView:(NSView*)view at:(NSPoint)point {
877 // TODO(viettrungluu): This code is more or less copied from the code in 865 // TODO(viettrungluu): This code is more or less copied from the code in
878 // |TabStripController|. I'll refactor this soon to make it common and expand 866 // |TabStripController|. I'll refactor this soon to make it common and expand
879 // its capabilities (e.g., allow text DnD). 867 // its capabilities (e.g., allow text DnD).
880 if ([urls count] < 1) { 868 if ([urls count] < 1) {
(...skipping 17 matching lines...) Expand all
898 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { 886 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point {
899 // Do nothing. 887 // Do nothing.
900 } 888 }
901 889
902 // (URLDropTargetController protocol) 890 // (URLDropTargetController protocol)
903 - (void)hideDropURLsIndicatorInView:(NSView*)view { 891 - (void)hideDropURLsIndicatorInView:(NSView*)view {
904 // Do nothing. 892 // Do nothing.
905 } 893 }
906 894
907 @end 895 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field_cell.mm ('k') | chrome/browser/cocoa/toolbar_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698