summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 19:31:32 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 19:31:32 +0000
commit35b6997efcb547a72500ce21fb2f3f302753ecca (patch)
tree6d54b12ffc16a88c1b09b669592d719ad504c455 /chrome/browser
parent643c454ce6553446661a7a1517ffc38cdad25aa8 (diff)
downloadchromium_src-35b6997efcb547a72500ce21fb2f3f302753ecca.zip
chromium_src-35b6997efcb547a72500ce21fb2f3f302753ecca.tar.gz
chromium_src-35b6997efcb547a72500ce21fb2f3f302753ecca.tar.bz2
Fix bubbles (bookmark, status, blocked content, both extension ones) in resolution independence.
BUG=http://crbug.com/19476, http://crbug.com/36366 TEST=click the star in RI and the bubble should position itself correctly; status bubble should have adequate height for text Review URL: http://codereview.chromium.org/851009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/content_blocked_bubble_controller.mm12
-rw-r--r--chrome/browser/cocoa/extension_installed_bubble_controller.mm33
-rw-r--r--chrome/browser/cocoa/extensions/browser_actions_controller.mm10
-rw-r--r--chrome/browser/cocoa/extensions/extension_popup_controller.mm9
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm8
-rw-r--r--chrome/browser/cocoa/status_bubble_mac.mm12
-rw-r--r--chrome/browser/cocoa/toolbar_controller.mm3
7 files changed, 51 insertions, 36 deletions
diff --git a/chrome/browser/cocoa/content_blocked_bubble_controller.mm b/chrome/browser/cocoa/content_blocked_bubble_controller.mm
index 7191d29..46b751d 100644
--- a/chrome/browser/cocoa/content_blocked_bubble_controller.mm
+++ b/chrome/browser/cocoa/content_blocked_bubble_controller.mm
@@ -249,8 +249,10 @@ static NSString* ReplaceNSStringPlaceholders(NSString* formatString,
// so only 1 * kLinkOuterPadding more is needed.
int delta = blockedContents.size() * kLinkLineHeight - kLinkPadding +
kLinkOuterPadding;
+ NSSize deltaSize = NSMakeSize(0, delta);
+ deltaSize = [[[self window] contentView] convertSize:deltaSize toView:nil];
NSRect windowFrame = [[self window] frame];
- windowFrame.size.height += delta;
+ windowFrame.size.height += deltaSize.height;
[[self window] setFrame:windowFrame display:NO];
// Create popup list.
@@ -328,9 +330,11 @@ static NSString* ReplaceNSStringPlaceholders(NSString* formatString,
- (void)showWindow:(id)sender {
NSWindow* window = [self window]; // completes nib load
- NSPoint origin = [parentWindow_ convertBaseToScreen:anchor_];
- origin.x -= NSWidth([window frame]) - kBubbleArrowXOffset -
- kBubbleArrowWidth / 2;
+ NSPoint origin = anchor_;
+ NSSize offsets = NSMakeSize(kBubbleArrowXOffset + kBubbleArrowWidth / 2.0,
+ 0);
+ offsets = [[parentWindow_ contentView] convertSize:offsets toView:nil];
+ origin.x -= NSWidth([window frame]) - offsets.width;
origin.y -= NSHeight([window frame]);
[window setFrameOrigin:origin];
[parentWindow_ addChildWindow:window ordered:NSWindowAbove];
diff --git a/chrome/browser/cocoa/extension_installed_bubble_controller.mm b/chrome/browser/cocoa/extension_installed_bubble_controller.mm
index 968413b..f65b455 100644
--- a/chrome/browser/cocoa/extension_installed_bubble_controller.mm
+++ b/chrome/browser/cocoa/extension_installed_bubble_controller.mm
@@ -25,7 +25,6 @@
#import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
-
// C++ class that receives EXTENSION_LOADED notifications and proxies them back
// to |controller|.
class ExtensionLoadedNotificationObserver : public NotificationObserver {
@@ -171,15 +170,19 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
NSView* button = [[[window->cocoa_controller() toolbarController]
browserActionsController] browserActionViewForExtension:extension_];
DCHECK(button);
- NSRect boundsRect = [[[button window] contentView]
- convertRect:[button frame]
- fromView:[button superview]];
- CGFloat xPos = NSMinX(boundsRect) + NSWidth([button frame]) / 2;
+ NSRect boundsRect = [[button superview] convertRect:[button frame]
+ toView:nil];
+ CGFloat xPos = NSMidX(boundsRect);
// If the button is hidden, display the button at the edge of the Browser
// Actions container.
// TODO(andybons): Make it point to the chevron once it's implemented.
- if ([button alphaValue] == 0.0)
- xPos = NSMaxX([[button superview] frame]);
+ if ([button alphaValue] == 0.0) {
+ NSView* superview = [button superview];
+ NSRect superviewRect =
+ [[superview superview] convertRect:[superview frame]
+ toView:nil];
+ xPos = NSMaxX(superviewRect);
+ }
arrowPoint = NSMakePoint(xPos, NSMinY(boundsRect));
break;
@@ -200,11 +203,10 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
locationBarView->GetAutocompleteTextField();
size_t index =
locationBarView->GetPageActionIndex(extension_->page_action());
- NSView* browserContentWindow = [window->GetNativeHandle() contentView];
NSRect iconRect = [[field autocompleteTextFieldCell]
pageActionFrameForIndex:index inFrame:[field frame]];
- NSRect boundsrect = [browserContentWindow convertRect:iconRect
- fromView:[field superview]];
+ NSRect boundsrect = [[field superview] convertRect:iconRect
+ toView:nil];
arrowPoint = NSMakePoint(NSMidX(boundsrect) + 1, NSMinY(boundsrect));
break;
}
@@ -229,10 +231,11 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
// Load nib and calculate height based on messages to be shown.
NSWindow* window = [self initializeWindow];
int newWindowHeight = [self calculateWindowHeight];
- NSSize windowDelta = NSMakeSize(
- 0, newWindowHeight - NSHeight([[window contentView] bounds]));
[infoBubbleView_ setFrameSize:NSMakeSize(
NSWidth([[window contentView] bounds]), newWindowHeight)];
+ NSSize windowDelta = NSMakeSize(
+ 0, newWindowHeight - NSHeight([[window contentView] bounds]));
+ windowDelta = [[window contentView] convertSize:windowDelta toView:nil];
NSRect newFrame = [window frame];
newFrame.size.height += windowDelta.height;
[window setFrame:newFrame display:NO];
@@ -243,8 +246,10 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
// Find window origin, taking into account bubble size and arrow location.
NSPoint origin =
[parentWindow_ convertBaseToScreen:[self calculateArrowPoint]];
- origin.x -= NSWidth([window frame]) - kBubbleArrowXOffset -
- kBubbleArrowWidth / 2;
+ NSSize offsets = NSMakeSize(kBubbleArrowXOffset + kBubbleArrowWidth / 2.0,
+ 0);
+ offsets = [[window contentView] convertSize:offsets toView:nil];
+ origin.x -= NSWidth([window frame]) - offsets.width;
origin.y -= NSHeight([window frame]);
[window setFrameOrigin:origin];
diff --git a/chrome/browser/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/cocoa/extensions/browser_actions_controller.mm
index 7acd763..2d494e4 100644
--- a/chrome/browser/cocoa/extensions/browser_actions_controller.mm
+++ b/chrome/browser/cocoa/extensions/browser_actions_controller.mm
@@ -375,15 +375,11 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
if (!extensionId)
return;
BrowserActionButton* actionButton = [buttons_ objectForKey:extensionId];
- NSRect relativeButtonBounds = [[[actionButton window] contentView]
- convertRect:[actionButton bounds]
- fromView:actionButton];
- NSPoint arrowPoint = [[actionButton window] convertBaseToScreen:NSMakePoint(
- NSMinX(relativeButtonBounds),
- NSMinY(relativeButtonBounds))];
+ NSPoint arrowPoint = [actionButton frame].origin;
// Adjust the anchor point to be at the center of the browser action button.
arrowPoint.x += kBrowserActionWidth / 2;
-
+ arrowPoint = [[actionButton superview] convertPoint:arrowPoint toView:nil];
+ arrowPoint = [[actionButton window] convertBaseToScreen:arrowPoint];
[ExtensionPopupController showURL:action->GetPopupUrl(tabId)
inBrowser:browser_
anchoredAt:arrowPoint
diff --git a/chrome/browser/cocoa/extensions/extension_popup_controller.mm b/chrome/browser/cocoa/extensions/extension_popup_controller.mm
index 72271b5..c9f61f0 100644
--- a/chrome/browser/cocoa/extensions/extension_popup_controller.mm
+++ b/chrome/browser/cocoa/extensions/extension_popup_controller.mm
@@ -192,12 +192,15 @@ CGFloat Clamp(CGFloat value, CGFloat min, CGFloat max) {
NSRect frame = [extensionView_ frame];
frame.size.height += kBubbleArrowHeight + kBubbleCornerRadius;
frame.size.width += kBubbleCornerRadius;
+ frame = [extensionView_ convertRectToBase:frame];
// Adjust the origin according to the height and width so that the arrow is
// positioned correctly at the middle and slightly down from the button.
NSPoint windowOrigin = anchor_;
- windowOrigin.x -= NSWidth(frame) - kBubbleArrowXOffset -
- (kBubbleArrowWidth / 2.0);
- windowOrigin.y -= NSHeight(frame) - (kBubbleArrowHeight / 2.0);
+ NSSize offsets = NSMakeSize(kBubbleArrowXOffset + kBubbleArrowWidth / 2.0,
+ kBubbleArrowHeight / 2.0);
+ offsets = [extensionView_ convertSize:offsets toView:nil];
+ windowOrigin.x -= NSWidth(frame) - offsets.width;
+ windowOrigin.y -= NSHeight(frame) - offsets.height;
frame.origin = windowOrigin;
// Is the window still animating in? If so, then cancel that and create a new
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index 3229f45..4b6a1cd 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -850,14 +850,14 @@ void LocationBarViewMac::ContentSettingImageView::OnMousePressed(NSRect bounds)
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), &displayHost,
NULL, NULL);
- // Transform mouse coordinates to content-view space.
+ // Transform mouse coordinates to screen space.
AutocompleteTextField* textField = owner_->GetAutocompleteTextField();
NSWindow* window = [textField window];
- bounds = [[window contentView] convertRect:bounds
- fromView:textField];
+ bounds = [textField convertRect:bounds toView:nil];
+ NSPoint anchor = NSMakePoint(NSMidX(bounds) + 1, NSMinY(bounds));
+ anchor = [window convertBaseToScreen:anchor];
// Open bubble.
- NSPoint anchor = NSMakePoint(NSMidX(bounds) + 1, NSMinY(bounds));
[[ContentBlockedBubbleController
showForType:content_setting_image_model_->get_content_settings_type()
parentWindow:window
diff --git a/chrome/browser/cocoa/status_bubble_mac.mm b/chrome/browser/cocoa/status_bubble_mac.mm
index 3949441..7f77029 100644
--- a/chrome/browser/cocoa/status_bubble_mac.mm
+++ b/chrome/browser/cocoa/status_bubble_mac.mm
@@ -297,7 +297,12 @@ void StatusBubbleMac::Create() {
return;
// TODO(avi):fix this for RTL
- window_ = [[NSWindow alloc] initWithContentRect:CalculateWindowFrame()
+ NSRect window_rect = CalculateWindowFrame();
+ // initWithContentRect has origin in screen coords and size in scaled window
+ // coordinates.
+ window_rect.size =
+ [[parent_ contentView] convertSize:window_rect.size fromView:nil];
+ window_ = [[NSWindow alloc] initWithContentRect:window_rect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:YES];
@@ -554,8 +559,11 @@ void StatusBubbleMac::SwitchParentWindow(NSWindow* parent) {
NSRect StatusBubbleMac::CalculateWindowFrame() {
DCHECK(parent_);
+ NSSize size = NSMakeSize(0, kWindowHeight);
+ size = [[parent_ contentView] convertSize:size toView:nil];
+
NSRect rect = [parent_ frame];
- rect.size.height = kWindowHeight;
+ rect.size.height = size.height;
rect.size.width = static_cast<int>(kWindowWidthPercent * rect.size.width);
return rect;
}
diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm
index cb62cef..bf32934 100644
--- a/chrome/browser/cocoa/toolbar_controller.mm
+++ b/chrome/browser/cocoa/toolbar_controller.mm
@@ -732,8 +732,7 @@ class PrefObserverBridge : public NotificationObserver {
}
- (NSRect)starButtonInWindowCoordinates {
- return [[[starButton_ window] contentView] convertRect:[starButton_ bounds]
- fromView:starButton_];
+ return [starButton_ convertRect:[starButton_ bounds] toView:nil];
}
- (CGFloat)desiredHeightForCompression:(CGFloat)compressByHeight {