summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field.h6
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field.mm5
-rw-r--r--chrome/browser/cocoa/bookmark_bubble_controller.mm4
-rw-r--r--chrome/browser/cocoa/browser_window_controller.h5
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm9
-rw-r--r--chrome/browser/cocoa/browser_window_controller_unittest.mm2
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.h3
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm10
-rw-r--r--chrome/browser/cocoa/toolbar_controller.h7
-rw-r--r--chrome/browser/cocoa/toolbar_controller.mm5
-rw-r--r--chrome/browser/cocoa/toolbar_controller_unittest.mm11
11 files changed, 31 insertions, 36 deletions
diff --git a/chrome/browser/cocoa/autocomplete_text_field.h b/chrome/browser/cocoa/autocomplete_text_field.h
index 351685a..b4d70aa 100644
--- a/chrome/browser/cocoa/autocomplete_text_field.h
+++ b/chrome/browser/cocoa/autocomplete_text_field.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -129,10 +129,6 @@ class AutocompleteTextFieldObserver {
// is not over an action.
- (NSMenu*)actionMenuForEvent:(NSEvent*)event;
-// Return the rectangle the star is being shown in, for purposes of
-// positioning the bookmark bubble.
-- (NSRect)starIconFrame;
-
// If the location icon is draggable, return its drag pasteboard.
- (NSPasteboard*)locationDragPasteboard;
diff --git a/chrome/browser/cocoa/autocomplete_text_field.mm b/chrome/browser/cocoa/autocomplete_text_field.mm
index f24cfa5..18d30d1 100644
--- a/chrome/browser/cocoa/autocomplete_text_field.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field.mm
@@ -382,11 +382,6 @@
actionMenuForEvent:event inRect:[self bounds] ofView:self];
}
-- (NSRect)starIconFrame {
- AutocompleteTextFieldCell* cell = [self autocompleteTextFieldCell];
- return [cell starIconFrameForFrame:[self bounds]];
-}
-
- (NSPasteboard*)locationDragPasteboard {
return [[self autocompleteTextFieldCell] locationDragPasteboard];
}
diff --git a/chrome/browser/cocoa/bookmark_bubble_controller.mm b/chrome/browser/cocoa/bookmark_bubble_controller.mm
index 7695bec..3d9726d 100644
--- a/chrome/browser/cocoa/bookmark_bubble_controller.mm
+++ b/chrome/browser/cocoa/bookmark_bubble_controller.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -143,7 +143,7 @@ void BookmarkBubbleNotificationBridge::Observe(
[bubble_ setArrowLocation:info_bubble::kTopRight];
// Insure decent positioning even in the absence of a browser controller,
// which will occur for some unit tests.
- NSPoint arrowtip = bwc ? [bwc pointForBubbleArrowTip] :
+ NSPoint arrowtip = bwc ? [bwc bookmarkBubblePoint] :
NSMakePoint([window frame].size.width, [window frame].size.height);
NSPoint origin = [parentWindow_ convertBaseToScreen:arrowtip];
NSPoint bubbleArrowtip = [bubble_ arrowTip];
diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h
index 7eff55b..2c808c8 100644
--- a/chrome/browser/cocoa/browser_window_controller.h
+++ b/chrome/browser/cocoa/browser_window_controller.h
@@ -245,7 +245,7 @@ class TabStripModelObserverBridge;
- (NSPoint)themePatternPhase;
// Return the point to which a bubble window's arrow should point.
-- (NSPoint)pointForBubbleArrowTip;
+- (NSPoint)bookmarkBubblePoint;
// Call when the user changes the tab strip display mode, enabling or
// disabling vertical tabs for this browser. Re-flows the contents of the
@@ -357,9 +357,6 @@ class TabStripModelObserverBridge;
// Return an autoreleased NSWindow suitable for fullscreen use.
- (NSWindow*)createFullscreenWindow;
-// Return a point suitable for the topRight for a bookmark bubble.
-- (NSPoint)pointForBubbleArrowTip;
-
// Resets any saved state about window growth (due to showing the bookmark bar
// or the download shelf), so that future shrinking will occur from the bottom.
- (void)resetWindowGrowthState;
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index ccd632e..5730c3e 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -1377,13 +1377,8 @@
return phase;
}
-- (NSPoint)pointForBubbleArrowTip {
- NSRect rect = [toolbarController_ starIconInWindowCoordinates];
- // Determine the point of the arrow of the bubble window.
- NSPoint p = rect.origin;
- p.x += (NSWidth(rect) / 2.0) + 1.0; // Star is not exactly in center.
- p.y += 4;
- return p;
+- (NSPoint)bookmarkBubblePoint {
+ return [toolbarController_ bookmarkBubblePoint];
}
// Show the bookmark bubble (e.g. user just clicked on the STAR).
diff --git a/chrome/browser/cocoa/browser_window_controller_unittest.mm b/chrome/browser/cocoa/browser_window_controller_unittest.mm
index d6a3dca..8431aa1 100644
--- a/chrome/browser/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/browser_window_controller_unittest.mm
@@ -434,7 +434,7 @@ TEST_F(BrowserWindowControllerTest, BookmarkBarIsSameWidth) {
}
TEST_F(BrowserWindowControllerTest, TestTopRightForBubble) {
- NSPoint p = [controller_ pointForBubbleArrowTip];
+ NSPoint p = [controller_ bookmarkBubblePoint];
NSRect all = [[controller_ window] frame];
// As a sanity check make sure the point is vaguely in the top right
diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h
index ef8f0c3..aa32c0a 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.h
+++ b/chrome/browser/cocoa/location_bar_view_mac.h
@@ -85,6 +85,9 @@ class LocationBarViewMac : public AutocompleteEditController,
// Set the starred state of the bookmark star.
void SetStarred(bool starred);
+ // Get the point on the star for the bookmark bubble to aim at.
+ NSPoint GetBookmarkBubblePoint() const;
+
// Updates the location bar. Resets the bar's permanent text and
// security style, and if |should_restore_state| is true, restores
// saved state from the tab (for tab switching).
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index fd4d87a..bd8fc2f 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -429,6 +429,16 @@ void LocationBarViewMac::SetStarred(bool starred) {
[field_ resetFieldEditorFrameIfNeeded];
}
+NSPoint LocationBarViewMac::GetBookmarkBubblePoint() const {
+ AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
+ NSRect frame = [cell starIconFrameForFrame:[field_ bounds]];
+ frame = [field_ convertRect:frame toView:nil];
+
+ // Star is not exactly centered horizontally, and the tip should
+ // point to the visual bottom of the star, not the middle.
+ return NSMakePoint(NSMidX(frame), NSMinY(frame) + 4.0);
+}
+
NSImage* LocationBarViewMac::GetTabButtonImage() {
if (!tab_button_image_) {
SkBitmap* skiaBitmap = ResourceBundle::GetSharedInstance().
diff --git a/chrome/browser/cocoa/toolbar_controller.h b/chrome/browser/cocoa/toolbar_controller.h
index bc14f1b..313ef4e 100644
--- a/chrome/browser/cocoa/toolbar_controller.h
+++ b/chrome/browser/cocoa/toolbar_controller.h
@@ -138,10 +138,9 @@ class WrenchMenuModel;
// ignored. This changes the behavior of other methods, like |-view|.
- (void)setHasToolbar:(BOOL)toolbar hasLocationBar:(BOOL)locBar;
-// The bookmark bubble (when you click the star or hit Command-d)
-// needs to know where to go. Somewhere near the star icon seems like
-// a good start.
-- (NSRect)starIconInWindowCoordinates;
+// Point on the star icon for the bookmark bubble to be - in the
+// associated window's coordinate system.
+- (NSPoint)bookmarkBubblePoint;
// Returns the desired toolbar height for the given compression factor.
- (CGFloat)desiredHeightForCompression:(CGFloat)compressByHeight;
diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm
index c015f19..c211313 100644
--- a/chrome/browser/cocoa/toolbar_controller.mm
+++ b/chrome/browser/cocoa/toolbar_controller.mm
@@ -18,7 +18,6 @@
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
#import "chrome/browser/cocoa/accelerators_cocoa.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"
#import "chrome/browser/cocoa/background_gradient_view.h"
@@ -682,8 +681,8 @@ class PrefObserverBridge : public NotificationObserver {
[NSAnimationContext endGrouping];
}
-- (NSRect)starIconInWindowCoordinates {
- return [locationBar_ convertRect:[locationBar_ starIconFrame] toView:nil];
+- (NSPoint)bookmarkBubblePoint {
+ return locationBarView_->GetBookmarkBubblePoint();
}
- (CGFloat)desiredHeightForCompression:(CGFloat)compressByHeight {
diff --git a/chrome/browser/cocoa/toolbar_controller_unittest.mm b/chrome/browser/cocoa/toolbar_controller_unittest.mm
index 863a65a..b601e69 100644
--- a/chrome/browser/cocoa/toolbar_controller_unittest.mm
+++ b/chrome/browser/cocoa/toolbar_controller_unittest.mm
@@ -199,12 +199,13 @@ TEST_F(ToolbarControllerTest, DontToggleWhenNoToolbar) {
EXPECT_TRUE(NSEqualRects(locationBarFrame, newLocationBarFrame));
}
-TEST_F(ToolbarControllerTest, StarIconInWindowCoordinates) {
- NSRect star = [bar_ starIconInWindowCoordinates];
- NSRect all = [[[bar_ view] window] frame];
+TEST_F(ToolbarControllerTest, BookmarkBubblePoint) {
+ const NSPoint starPoint = [bar_ bookmarkBubblePoint];
+ const NSRect barFrame =
+ [[bar_ view] convertRect:[[bar_ view] bounds] toView:nil];
- // Make sure the star is completely inside the window rect
- EXPECT_TRUE(NSContainsRect(all, star));
+ // Make sure the star is completely inside the location bar.
+ EXPECT_TRUE(NSPointInRect(starPoint, barFrame));
}
TEST_F(ToolbarControllerTest, HoverButtonForEvent) {