Chromium Code Reviews| 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 c06bf9b4c499543104acc8d3ad5f88d0d6cdc38e..0298717b2110830c51514e995576c8419bac4526 100644 |
| --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm |
| +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm |
| @@ -666,6 +666,12 @@ 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) { |
| if (is_hidden_) |
| return; |
| @@ -676,20 +682,25 @@ 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) { |
| + NSRect bounds = NSMakeRect(0, 0, rect.width(), rect.height()); |
| + bounds = [cocoa_view_ convertRect:bounds toView:nil]; |
|
Nico
2011/02/16 18:18:45
is convertSize:toView: enough?
|
| + global_origin.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height - |
| + bounds.size.height - global_origin.y; |
|
Nico
2011/02/16 18:20:03
global_origin and the screen's frame are in screen
honten.org
2011/02/16 18:45:37
Here, my intention is |rect| is actually in view c
Nico
2011/02/16 21:16:01
Chances are I misunderstand something.
…ah! So Ge
honten.org
2011/02/16 21:18:57
Sure, I'll file it and fix the nits.
On 2011/02/1
honten.org
2011/02/18 09:11:26
Done.
|
| + } |
| + |
| + // 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() { |