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

Unified Diff: chrome/browser/renderer_host/render_widget_host_view_mac.mm

Issue 6024008: Consider the popup window position when the window shows upward. This patch depends on WebKit patch. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix CPoint to POINT. Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index d1a241427da4455f09a6a9af1d08453b84283f06..5db8ee44ded5c3b1a6ce9557ffac13e68c5507f9 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -672,6 +672,14 @@ void RenderWidgetHostViewMac::WasHidden() {
}
void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) {
+ gfx::Rect rect = GetViewBounds();
+ rect.set_size(size);
+ SetBounds(rect);
+}
+
+void RenderWidgetHostViewMac::SetBounds(const gfx::Rect& rect) {
+ // |rect.size()| is view coordinates, |rect.origin| is screen coordinates,
+ // TODO(thakis): fix, http://crbug.com/73362
if (is_hidden_)
return;
@@ -682,20 +690,26 @@ void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) {
// again. On Cocoa, we rely on the Cocoa view struture and resizer flags to
// keep things sized properly. On the other hand, if the size is not empty
// then this is a valid request for a pop-up.
- if (size.IsEmpty())
+ if (rect.size().IsEmpty())
return;
- // Do conversions to upper-left origin, as "set size" means keep the
- // upper-left corner pinned. If the new size is valid, this is a popup whose
- // superview is another RenderWidgetHostViewCocoa, but even if it's directly
- // in a TabContentsViewCocoa, they're both BaseViews.
- DCHECK([[cocoa_view_ superview] isKindOfClass:[BaseView class]]);
- gfx::Rect rect =
- [(BaseView*)[cocoa_view_ superview] flipNSRectToRect:[cocoa_view_ frame]];
- rect.set_width(size.width());
- rect.set_height(size.height());
- [cocoa_view_ setFrame:
- [(BaseView*)[cocoa_view_ superview] flipRectToNSRect:rect]];
+ // The position of |rect| is screen coordnate system and we have to consider
+ // Cocoa coordinate system is upside-down and also muti screen.
+ NSPoint global_origin = NSPointFromCGPoint(rect.origin().ToCGPoint());
+ if ([[NSScreen screens] count] > 0) {
+ NSSize size = NSMakeSize(rect.width(), rect.height());
+ size = [cocoa_view_ convertSize:size toView:nil];
+ NSScreen* screen =
+ static_cast<NSScreen*>([[NSScreen screens] objectAtIndex:0]);
+ global_origin.y = NSHeight([screen frame]) - size.height - global_origin.y;
+ }
+
+ // Then |global_origin| is converted to client coordinate system.
+ NSPoint window_origin =
+ [[cocoa_view_ window] convertScreenToBase:global_origin];
+ NSRect frame = NSMakeRect(window_origin.x, window_origin.y,
+ rect.width(), rect.height());
+ [cocoa_view_ setFrame:frame];
}
gfx::NativeView RenderWidgetHostViewMac::GetNativeView() {
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_mac.h ('k') | chrome/browser/renderer_host/render_widget_host_view_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698