Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #include <QuartzCore/QuartzCore.h> | 7 #include <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 gfx::NativeView parent_view) { | 323 gfx::NativeView parent_view) { |
| 324 } | 324 } |
| 325 | 325 |
| 326 void RenderWidgetHostViewMac::InitAsPopup( | 326 void RenderWidgetHostViewMac::InitAsPopup( |
| 327 RenderWidgetHostView* parent_host_view, | 327 RenderWidgetHostView* parent_host_view, |
| 328 const gfx::Rect& pos) { | 328 const gfx::Rect& pos) { |
| 329 bool activatable = popup_type_ == WebKit::WebPopupTypeNone; | 329 bool activatable = popup_type_ == WebKit::WebPopupTypeNone; |
| 330 [cocoa_view_ setCloseOnDeactivate:YES]; | 330 [cocoa_view_ setCloseOnDeactivate:YES]; |
| 331 [cocoa_view_ setCanBeKeyView:activatable ? YES : NO]; | 331 [cocoa_view_ setCanBeKeyView:activatable ? YES : NO]; |
| 332 [parent_host_view->GetNativeView() addSubview:cocoa_view_]; | 332 [parent_host_view->GetNativeView() addSubview:cocoa_view_]; |
| 333 NSWindow* popupWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(10,10 0,400,300) | |
|
jam
2012/11/30 02:12:06
testing code?
| |
| 334 styleMask:NSTitledWindowMask | |
| 335 backing:NSBackingStoreBuffered | |
| 336 defer:NO]; | |
| 337 [[popupWindow contentView] addSubview:cocoa_view_]; | |
| 338 [popupWindow makeKeyAndOrderFront:popupWindow]; | |
| 333 | 339 |
| 334 NSPoint origin_global = NSPointFromCGPoint(pos.origin().ToCGPoint()); | 340 NSPoint origin_global = NSPointFromCGPoint(pos.origin().ToCGPoint()); |
| 335 if ([[NSScreen screens] count] > 0) { | 341 if ([[NSScreen screens] count] > 0) { |
| 336 origin_global.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height - | 342 origin_global.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height - |
| 337 pos.height() - origin_global.y; | 343 pos.height() - origin_global.y; |
| 338 } | 344 } |
| 339 NSPoint origin_window = | 345 NSPoint origin_window = |
| 340 [[cocoa_view_ window] convertScreenToBase:origin_global]; | 346 [[cocoa_view_ window] convertScreenToBase:origin_global]; |
| 341 NSPoint origin_view = | 347 NSPoint origin_view = |
| 342 [cocoa_view_ convertPoint:origin_window fromView:nil]; | 348 [cocoa_view_ convertPoint:origin_window fromView:nil]; |
| (...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2214 if (renderWidgetHostView_->compositing_iosurface_.get()) | 2220 if (renderWidgetHostView_->compositing_iosurface_.get()) |
| 2215 renderWidgetHostView_->compositing_iosurface_->GlobalFrameDidChange(); | 2221 renderWidgetHostView_->compositing_iosurface_->GlobalFrameDidChange(); |
| 2216 handlingGlobalFrameDidChange_ = NO; | 2222 handlingGlobalFrameDidChange_ = NO; |
| 2217 } | 2223 } |
| 2218 | 2224 |
| 2219 - (void)windowChangedGlobalFrame:(NSNotification*)notification { | 2225 - (void)windowChangedGlobalFrame:(NSNotification*)notification { |
| 2220 renderWidgetHostView_->UpdateScreenInfo( | 2226 renderWidgetHostView_->UpdateScreenInfo( |
| 2221 renderWidgetHostView_->GetNativeView()); | 2227 renderWidgetHostView_->GetNativeView()); |
| 2222 } | 2228 } |
| 2223 | 2229 |
| 2224 - (void)setFrameSize:(NSSize)newSize { | 2230 - (void)setFrame:(NSRect)frameRect { |
| 2225 // NB: -[NSView setFrame:] calls through -setFrameSize:, so overriding | 2231 [super setFrame:frameRect]; |
| 2226 // -setFrame: isn't neccessary. | 2232 if (!renderWidgetHostView_->render_widget_host_) |
| 2227 [super setFrameSize:newSize]; | 2233 return; |
| 2228 if (renderWidgetHostView_->render_widget_host_) | 2234 renderWidgetHostView_->render_widget_host_->SendScreenRects(); |
| 2229 renderWidgetHostView_->render_widget_host_->WasResized(); | 2235 renderWidgetHostView_->render_widget_host_->WasResized(); |
| 2230 } | 2236 } |
| 2231 | 2237 |
| 2232 - (void)callSetNeedsDisplayInRect { | 2238 - (void)callSetNeedsDisplayInRect { |
| 2233 DCHECK([NSThread isMainThread]); | 2239 DCHECK([NSThread isMainThread]); |
| 2234 DCHECK(renderWidgetHostView_->call_set_needs_display_in_rect_pending_); | 2240 DCHECK(renderWidgetHostView_->call_set_needs_display_in_rect_pending_); |
| 2235 [self setNeedsDisplayInRect:renderWidgetHostView_->invalid_rect_]; | 2241 [self setNeedsDisplayInRect:renderWidgetHostView_->invalid_rect_]; |
| 2236 renderWidgetHostView_->call_set_needs_display_in_rect_pending_ = false; | 2242 renderWidgetHostView_->call_set_needs_display_in_rect_pending_ = false; |
| 2237 renderWidgetHostView_->invalid_rect_ = NSZeroRect; | 2243 renderWidgetHostView_->invalid_rect_ = NSZeroRect; |
| 2238 } | 2244 } |
| 2239 | 2245 |
| (...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3365 if (!string) return NO; | 3371 if (!string) return NO; |
| 3366 | 3372 |
| 3367 // If the user is currently using an IME, confirm the IME input, | 3373 // If the user is currently using an IME, confirm the IME input, |
| 3368 // and then insert the text from the service, the same as TextEdit and Safari. | 3374 // and then insert the text from the service, the same as TextEdit and Safari. |
| 3369 [self confirmComposition]; | 3375 [self confirmComposition]; |
| 3370 [self insertText:string]; | 3376 [self insertText:string]; |
| 3371 return YES; | 3377 return YES; |
| 3372 } | 3378 } |
| 3373 | 3379 |
| 3374 @end | 3380 @end |
| OLD | NEW |