Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_mac.mm |
| diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| index 5c2244a3d200140319495e3d1a4d466840d53eea..4f98d03c3067fc7895168769621e42abf4e8051d 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_mac.mm |
| +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| @@ -55,8 +55,10 @@ |
| #include "ui/gfx/rect_conversions.h" |
| #include "ui/gfx/size_conversions.h" |
| #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| +#include "ui/gfx/native_widget_types.h" |
| #include "ui/surface/io_surface_support_mac.h" |
| #include "webkit/plugins/npapi/webplugin.h" |
| +#include "content/public/browser/web_contents_view_delegate.h" |
|
Avi (use Gerrit)
2012/12/10 20:52:06
alphabetical
keishi
2012/12/11 05:09:14
Done.
|
| using content::BackingStoreMac; |
| using content::BrowserAccessibility; |
| @@ -146,6 +148,7 @@ static float ScaleFactor(NSView* view) { |
| actualRange:(NSRangePointer)actualRange; |
| @end |
| + |
|
Avi (use Gerrit)
2012/12/10 20:52:06
stray return
keishi
2012/12/11 05:09:14
Done.
|
| // NSEvent subtype for scroll gestures events. |
| static const short kIOHIDEventTypeScroll = 6; |
| @@ -330,7 +333,8 @@ void RenderWidgetHostViewMac::InitAsChild( |
| void RenderWidgetHostViewMac::InitAsPopup( |
| RenderWidgetHostView* parent_host_view, |
| - const gfx::Rect& pos) { |
| + const gfx::Rect& pos, |
| + WebContentsViewDelegate* delegate) { |
| bool activatable = popup_type_ == WebKit::WebPopupTypeNone; |
| [cocoa_view_ setCloseOnDeactivate:YES]; |
| [cocoa_view_ setCanBeKeyView:activatable ? YES : NO]; |
| @@ -341,15 +345,18 @@ void RenderWidgetHostViewMac::InitAsPopup( |
| origin_global.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height - |
| pos.height() - origin_global.y; |
| } |
| - NSPoint origin_window = |
| - [[cocoa_view_ window] convertScreenToBase:origin_global]; |
| - NSPoint origin_view = |
| - [cocoa_view_ convertPoint:origin_window fromView:nil]; |
| - NSRect initial_frame = NSMakeRect(origin_view.x, |
| - origin_view.y, |
| - pos.width(), |
| - pos.height()); |
| - [cocoa_view_ setFrame:initial_frame]; |
| + |
| + popup_window_.reset(delegate->CreatePopupWindow()); |
| + [popup_window_ setFrame:NSMakeRect(origin_global.x, origin_global.y, |
| + pos.width(), pos.height()) display:YES]; |
|
Avi (use Gerrit)
2012/12/10 20:52:06
Wrap "display:YES" to the next line; it gets lost
keishi
2012/12/11 05:09:14
Done.
|
| + [popup_window_ setLevel:NSPopUpMenuWindowLevel]; |
| + [popup_window_ setReleasedWhenClosed:NO]; |
| + |
| + [cocoa_view_ setCanBeKeyView:YES]; |
|
Avi (use Gerrit)
2012/12/10 20:52:06
It seems silly to me to call -setCanBeKeyView abov
keishi
2012/12/11 05:09:14
Done.
|
| + [cocoa_view_ setFrame:[[popup_window_ contentView] bounds]]; |
| + [popup_window_ makeKeyAndOrderFront:nil]; |
| + [[popup_window_ contentView] addSubview:cocoa_view_]; |
|
Avi (use Gerrit)
2012/12/10 20:52:06
You may want to set the bindings on the cocoa_view
keishi
2012/12/11 05:09:14
Done.
|
| + [popup_window_ setParentWindow:[parent_host_view->GetNativeView() window]]; |
| } |
| // This function creates the fullscreen window and hides the dock and menubar if |
| @@ -466,16 +473,10 @@ void RenderWidgetHostViewMac::SetBounds(const gfx::Rect& rect) { |
| origin_global.y = |
| NSHeight([screen frame]) - size.height - origin_global.y; |
| } |
| - |
| - // Then |origin_global| is converted to client coordinate system. |
| - DCHECK([cocoa_view_ window]); |
| - NSPoint origin_window = |
| - [[cocoa_view_ window] convertScreenToBase:origin_global]; |
| - NSPoint origin_view = |
| - [[cocoa_view_ superview] convertPoint:origin_window fromView:nil]; |
| - NSRect frame = NSMakeRect(origin_view.x, origin_view.y, |
| - rect.width(), rect.height()); |
| - [cocoa_view_ setFrame:frame]; |
| + [cocoa_view_ setFrame:NSMakeRect(0.0, 0.0, rect.width(), rect.height())]; |
| + [popup_window_ setFrame:NSMakeRect(origin_global.x, origin_global.y, |
| + rect.width(), rect.height()) |
| + display:YES]; |
|
Avi (use Gerrit)
2012/12/10 20:52:06
This is wrong because rect.size() is in view coord
keishi
2012/12/11 05:09:14
When will a view size and a screen size be differe
Avi (use Gerrit)
2012/12/11 05:14:20
Yes, the primary time they differ is on hi-dpi scr
|
| } else { |
| DCHECK([[cocoa_view_ superview] isKindOfClass:[BaseView class]]); |
| BaseView* superview = static_cast<BaseView*>([cocoa_view_ superview]); |
| @@ -730,6 +731,9 @@ void RenderWidgetHostViewMac::Destroy() { |
| [cocoa_view_ removeFromSuperview]; |
| [cocoa_view_ autorelease]; |
| + [popup_window_ close]; |
| + popup_window_.autorelease(); |
| + |
| [fullscreen_window_manager_ exitFullscreenMode]; |
| fullscreen_window_manager_.reset(); |
| [pepper_fullscreen_window_ close]; |