summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-06 03:36:36 +0000
committermrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-06 03:36:36 +0000
commitd1c90bf7270eb0dd62e1e4924d55bd97636762f0 (patch)
tree5bcafcd0b5d28e3a9000ce0a64a8d487359e5e35 /chrome
parent5e81ea70d1c32614b5cb438b05bd2bc8c057fb72 (diff)
downloadchromium_src-d1c90bf7270eb0dd62e1e4924d55bd97636762f0.zip
chromium_src-d1c90bf7270eb0dd62e1e4924d55bd97636762f0.tar.gz
chromium_src-d1c90bf7270eb0dd62e1e4924d55bd97636762f0.tar.bz2
Change how the calculation is performed for determining the location of the arrow tip in a bubble window.
BUG=40406 TEST=1) Not in full-screen and with language set to English, press Cmd-D and verify bubble is properly positioned with arrow tip pointing to star. Change language to Espanol and repeat test. 2) Now in full-screen, repeat the tests. Review URL: http://codereview.chromium.org/1623002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43694 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/bookmark_bubble_controller.mm12
-rw-r--r--chrome/browser/cocoa/browser_window_controller.h6
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm12
-rw-r--r--chrome/browser/cocoa/browser_window_controller_unittest.mm2
-rw-r--r--chrome/browser/cocoa/info_bubble_view.h3
-rw-r--r--chrome/browser/cocoa/info_bubble_view.mm9
6 files changed, 28 insertions, 16 deletions
diff --git a/chrome/browser/cocoa/bookmark_bubble_controller.mm b/chrome/browser/cocoa/bookmark_bubble_controller.mm
index c3b7cd0..465691e 100644
--- a/chrome/browser/cocoa/bookmark_bubble_controller.mm
+++ b/chrome/browser/cocoa/bookmark_bubble_controller.mm
@@ -98,15 +98,17 @@
[BrowserWindowController browserWindowControllerForWindow:parentWindow_];
[bwc lockBarVisibilityForOwner:self withAnimation:NO delay:NO];
NSWindow* window = [self window]; // completes nib load
+ [bubble_ setArrowLocation:kTopRight];
// Insure decent positioning even in the absence of a browser controller,
// which will occur for some unit tests.
- NSPoint topRight = bwc ? [bwc topRightForBubble] :
+ NSPoint arrowtip = bwc ? [bwc pointForBubbleArrowTip] :
NSMakePoint([window frame].size.width, [window frame].size.height);
- NSPoint origin = [parentWindow_ convertBaseToScreen:topRight];
- origin.y -= NSHeight([window frame]);
- origin.x -= NSWidth([window frame]);
+ NSPoint origin = [parentWindow_ convertBaseToScreen:arrowtip];
+ NSPoint bubbleArrowtip = [bubble_ arrowTip];
+ bubbleArrowtip = [bubble_ convertPoint:bubbleArrowtip toView:nil];
+ origin.y -= bubbleArrowtip.y;
+ origin.x -= bubbleArrowtip.x;
[window setFrameOrigin:origin];
- [bubble_ setArrowLocation:kTopRight];
[parentWindow_ addChildWindow:window ordered:NSWindowAbove];
// Default is IDS_BOOMARK_BUBBLE_PAGE_BOOKMARK; "Bookmark".
// If adding for the 1st time the string becomes "Bookmark Added!"
diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h
index 4568e6a..975594c 100644
--- a/chrome/browser/cocoa/browser_window_controller.h
+++ b/chrome/browser/cocoa/browser_window_controller.h
@@ -244,8 +244,8 @@ class TabStripModelObserverBridge;
// Gets the pattern phase for the window.
- (NSPoint)themePatternPhase;
-// Return a point suitable for the topRight for a bookmark bubble.
-- (NSPoint)topRightForBubble;
+// Return the point to which a bubble window's arrow should point.
+- (NSPoint)pointForBubbleArrowTip;
@end // @interface BrowserWindowController
@@ -353,7 +353,7 @@ class TabStripModelObserverBridge;
- (NSWindow*)createFullscreenWindow;
// Return a point suitable for the topRight for a bookmark bubble.
-- (NSPoint)topRightForBubble;
+- (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.
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index 05edc1a..65f7b61 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -1372,14 +1372,12 @@
return phase;
}
-- (NSPoint)topRightForBubble {
+- (NSPoint)pointForBubbleArrowTip {
NSRect rect = [toolbarController_ starIconInWindowCoordinates];
- NSPoint p = NSMakePoint(NSMaxX(rect), NSMinY(rect)); // bottom right
-
- // Adjust top-right based on our knowledge of how the view looks.
- p.x += 31;
- p.y += 5;
-
+ // 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;
}
diff --git a/chrome/browser/cocoa/browser_window_controller_unittest.mm b/chrome/browser/cocoa/browser_window_controller_unittest.mm
index fbdef54..d6a3dca 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_ topRightForBubble];
+ NSPoint p = [controller_ pointForBubbleArrowTip];
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/info_bubble_view.h b/chrome/browser/cocoa/info_bubble_view.h
index d5cfa4e..91ffc907 100644
--- a/chrome/browser/cocoa/info_bubble_view.h
+++ b/chrome/browser/cocoa/info_bubble_view.h
@@ -36,6 +36,9 @@ enum InfoBubbleType {
@property (assign, nonatomic) BubbleArrowLocation arrowLocation;
@property (assign, nonatomic) InfoBubbleType bubbleType;
+// Returns the point location in view coordinates of the tip of the arrow.
+- (NSPoint)arrowTip;
+
@end
#endif // CHROME_BROWSER_COCOA_INFO_BUBBLE_VIEW_H_
diff --git a/chrome/browser/cocoa/info_bubble_view.mm b/chrome/browser/cocoa/info_bubble_view.mm
index 58cd923..1ced0dd 100644
--- a/chrome/browser/cocoa/info_bubble_view.mm
+++ b/chrome/browser/cocoa/info_bubble_view.mm
@@ -92,4 +92,13 @@ extern const CGFloat kBubbleCornerRadius = 8.0;
}
}
+- (NSPoint)arrowTip {
+ NSRect bounds = [self bounds];
+ CGFloat tipXOffset = kBubbleArrowXOffset + kBubbleArrowWidth / 2.0;
+ CGFloat xOffset = arrowLocation_ == kTopRight ? NSMaxX(bounds) - tipXOffset :
+ NSMinX(bounds) + tipXOffset;
+ NSPoint arrowTip = NSMakePoint(xOffset, NSMaxY(bounds));
+ return arrowTip;
+}
+
@end