summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 17:22:25 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 17:22:25 +0000
commitff920f7685e372765f875189019fd6099200186f (patch)
tree2ee8de4e49fdd36b49030b3e15c7b884e0e09e3f /chrome
parent0614bad929b227c0ca6bccfe7a7644068fb8dd7a (diff)
downloadchromium_src-ff920f7685e372765f875189019fd6099200186f.zip
chromium_src-ff920f7685e372765f875189019fd6099200186f.tar.gz
chromium_src-ff920f7685e372765f875189019fd6099200186f.tar.bz2
[Mac] Line up omnibox popup under field.
Also line up the icons. Spacing can be adjusted later. BUG=37865 TEST=Popup edges line up under field edges. TEST=Popup icons and text should line up under field icon and text. Review URL: http://codereview.chromium.org/1608001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43357 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_mac.mm14
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell.mm10
-rw-r--r--chrome/browser/cocoa/toolbar_controller.mm22
-rw-r--r--chrome/browser/cocoa/toolbar_controller_unittest.mm8
4 files changed, 26 insertions, 28 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
index 6407475..973ed67 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
@@ -15,6 +15,7 @@
#include "gfx/rect.h"
#include "grit/theme_resources.h"
#import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
+#import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
namespace {
@@ -31,7 +32,7 @@ const int kCellHeightAdjust = 7.0;
const CGFloat kPopupRoundingRadius = 3.5;
// Gap between the field and the popup.
-const CGFloat kPopupFieldGap = 2.0;
+const CGFloat kPopupFieldGap = 0.0;
// How opaque the popup window should be. This matches Windows (see
// autocomplete_popup_contents_view.cc, kGlassPopupTransparency).
@@ -665,10 +666,15 @@ void AutocompletePopupViewMac::OpenURLForRow(int row, bool force_background) {
// This handles drawing the decorations of the rounded popup window,
// calling on NSMatrix to draw the actual contents.
- (void)drawRect:(NSRect)rect {
+ // Apparently this expects flipped coordinates, because in order to
+ // round the bottom corners visually, I need to specify the top
+ // corners here.
NSBezierPath* path =
- [NSBezierPath bezierPathWithRoundedRect:[self bounds]
- xRadius:kPopupRoundingRadius
- yRadius:kPopupRoundingRadius];
+ [NSBezierPath gtm_bezierPathWithRoundRect:[self bounds]
+ topLeftCornerRadius:kPopupRoundingRadius
+ topRightCornerRadius:kPopupRoundingRadius
+ bottomLeftCornerRadius:0.0
+ bottomRightCornerRadius:0.0];
// Draw the matrix clipped to our border.
[NSGraphicsContext saveGraphicsState];
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.mm b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
index 0543bf6..3c29f8b 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
@@ -45,7 +45,9 @@ const NSInteger kIconLabelYOffset = 7;
// decorations need to be trimmed.
const CGFloat kEditorHorizontalInset = 3.0;
-const CGFloat kLocationIconXOffset = 3.0;
+// Cause the location icon to line up above the icons in the popup.
+const CGFloat kLocationIconXOffset = 9.0;
+const CGFloat kLocationIconXPad = 5.0;
// Conveniences to centralize width+offset calculations.
CGFloat WidthForHint(NSAttributedString* hintString) {
@@ -288,8 +290,10 @@ void DrawImageInRect(NSImage* image, NSView* view, const NSRect& rect) {
// code could be made simpler.
if (!keywordString_ && locationIconView_ && locationIconView_->IsVisible()) {
const NSSize imageSize = locationIconView_->GetImageSize();
- textFrame.origin.x += imageSize.width;
- textFrame.size.width -= imageSize.width;
+ const CGFloat locationIconWidth =
+ kLocationIconXOffset + kLocationIconXPad + imageSize.width;
+ textFrame.origin.x += locationIconWidth;
+ textFrame.size.width -= locationIconWidth;
}
if (hintString_) {
diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm
index 0d12ee5..fc0cdb0 100644
--- a/chrome/browser/cocoa/toolbar_controller.mm
+++ b/chrome/browser/cocoa/toolbar_controller.mm
@@ -847,26 +847,14 @@ class PrefObserverBridge : public NotificationObserver {
}
- (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;
+ // The field has a single-pixel border on the left and right. This
+ // needs to be factored out so that the popup window's border (which
+ // is outside the frame) lines up.
+ const int kLocationStackEdgeWidth = 1;
const NSRect locationFrame = [locationBar_ frame];
-
- // Expand to include star and go buttons. Including the widths
- // rather that calculating from their current placement because this
- // method can be called while the resize is still rearranging the
- // views involved.
- const CGFloat minX = NSMinX(locationFrame) - NSWidth([starButton_ frame]);
- const CGFloat maxX = NSMaxX(locationFrame) + NSWidth([goButton_ frame]);
-
- 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).
+ NSRectToCGRect([[self view] convertRect:locationFrame toView:nil]));
stack_bounds.Inset(kLocationStackEdgeWidth, 0);
return stack_bounds;
}
diff --git a/chrome/browser/cocoa/toolbar_controller_unittest.mm b/chrome/browser/cocoa/toolbar_controller_unittest.mm
index dab5cba..8dcb135 100644
--- a/chrome/browser/cocoa/toolbar_controller_unittest.mm
+++ b/chrome/browser/cocoa/toolbar_controller_unittest.mm
@@ -240,10 +240,10 @@ TEST_F(ToolbarControllerTest, BubblePosition) {
// 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));
+ // The location stack should be just within the border of the
+ // location bar.
+ EXPECT_EQ(locationStackFrame.x(), NSMinX(locationFrame) + 1);
+ EXPECT_EQ(locationStackFrame.right(), NSMaxX(locationFrame) - 1);
}
TEST_F(ToolbarControllerTest, HoverButtonForEvent) {