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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 11498008: RenderWidget popup should be a NSWindow so it can go outside the main window. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removed include Created 8 years 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 unified diff | Download patch
OLDNEW
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 29 matching lines...) Expand all
40 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
41 #include "content/public/browser/native_web_keyboard_event.h" 41 #include "content/public/browser/native_web_keyboard_event.h"
42 #import "content/public/browser/render_widget_host_view_mac_delegate.h" 42 #import "content/public/browser/render_widget_host_view_mac_delegate.h"
43 #include "skia/ext/platform_canvas.h" 43 #include "skia/ext/platform_canvas.h"
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
46 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFact ory.h" 46 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFact ory.h"
47 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFact ory.h" 47 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFact ory.h"
48 #import "third_party/mozilla/ComplexTextInputPanel.h" 48 #import "third_party/mozilla/ComplexTextInputPanel.h"
49 #include "third_party/skia/include/core/SkColor.h" 49 #include "third_party/skia/include/core/SkColor.h"
50 #import "ui/base/cocoa/event_hook_application.h"
50 #import "ui/base/cocoa/fullscreen_window_manager.h" 51 #import "ui/base/cocoa/fullscreen_window_manager.h"
51 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" 52 #import "ui/base/cocoa/underlay_opengl_hosting_window.h"
52 #include "ui/base/keycodes/keyboard_codes.h" 53 #include "ui/base/keycodes/keyboard_codes.h"
53 #include "ui/base/layout.h" 54 #include "ui/base/layout.h"
54 #include "ui/gfx/point.h" 55 #include "ui/gfx/point.h"
55 #include "ui/gfx/rect_conversions.h" 56 #include "ui/gfx/rect_conversions.h"
56 #include "ui/gfx/size_conversions.h" 57 #include "ui/gfx/size_conversions.h"
57 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 58 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
58 #include "ui/surface/io_surface_support_mac.h" 59 #include "ui/surface/io_surface_support_mac.h"
59 #include "webkit/plugins/npapi/webplugin.h" 60 #include "webkit/plugins/npapi/webplugin.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 @property(nonatomic, assign) NSRange selectedRange; 131 @property(nonatomic, assign) NSRange selectedRange;
131 @property(nonatomic, assign) NSRange markedRange; 132 @property(nonatomic, assign) NSRange markedRange;
132 133
133 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event; 134 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event;
134 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; 135 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r;
135 - (void)setRWHVDelegate:(NSObject<RenderWidgetHostViewMacDelegate>*)delegate; 136 - (void)setRWHVDelegate:(NSObject<RenderWidgetHostViewMacDelegate>*)delegate;
136 - (void)gotUnhandledWheelEvent; 137 - (void)gotUnhandledWheelEvent;
137 - (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right; 138 - (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right;
138 - (void)setHasHorizontalScrollbar:(BOOL)has_horizontal_scrollbar; 139 - (void)setHasHorizontalScrollbar:(BOOL)has_horizontal_scrollbar;
139 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv; 140 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv;
140 - (void)cancelChildPopups;
141 - (void)windowDidChangeBackingProperties:(NSNotification*)notification; 141 - (void)windowDidChangeBackingProperties:(NSNotification*)notification;
142 - (void)windowChangedGlobalFrame:(NSNotification*)notification; 142 - (void)windowChangedGlobalFrame:(NSNotification*)notification;
143 - (void)checkForPluginImeCancellation; 143 - (void)checkForPluginImeCancellation;
144 - (void)updateTabBackingStoreScaleFactor; 144 - (void)updateTabBackingStoreScaleFactor;
145 - (NSRect)firstViewRectForCharacterRange:(NSRange)theRange 145 - (NSRect)firstViewRectForCharacterRange:(NSRange)theRange
146 actualRange:(NSRangePointer)actualRange; 146 actualRange:(NSRangePointer)actualRange;
147 @end 147 @end
148 148
149 // NSEvent subtype for scroll gestures events. 149 // NSEvent subtype for scroll gestures events.
150 static const short kIOHIDEventTypeScroll = 6; 150 static const short kIOHIDEventTypeScroll = 6;
151 151
152 // A window subclass that allows the fullscreen window to become main and gain 152 // A window subclass that allows the fullscreen window to become main and gain
153 // keyboard focus. This is only used for pepper flash. Normal fullscreen is 153 // keyboard focus. This is only used for pepper flash. Normal fullscreen is
154 // handled by the browser. 154 // handled by the browser.
155 @interface PepperFlashFullscreenWindow : UnderlayOpenGLHostingWindow 155 @interface PepperFlashFullscreenWindow : UnderlayOpenGLHostingWindow
156 @end 156 @end
157 157
158 @implementation PepperFlashFullscreenWindow 158 @implementation PepperFlashFullscreenWindow
159 159
160 - (BOOL)canBecomeKeyWindow { 160 - (BOOL)canBecomeKeyWindow {
161 return YES; 161 return YES;
162 } 162 }
163 163
164 - (BOOL)canBecomeMainWindow { 164 - (BOOL)canBecomeMainWindow {
165 return YES; 165 return YES;
166 } 166 }
167 167
168 @end 168 @end
169 169
170 @interface RenderWidgetPopupWindow : NSWindow<CrEventHookProtocol>
171 @end
172
173 @implementation RenderWidgetPopupWindow
174
175 - (id)initWithContentRect:(NSRect)contentRect
176 styleMask:(NSUInteger)windowStyle
177 backing:(NSBackingStoreType)bufferingType
178 defer:(BOOL)deferCreation {
179 if (self = [super initWithContentRect:contentRect
180 styleMask:windowStyle
181 backing:bufferingType
182 defer:deferCreation]) {
183 [self setOpaque:NO];
184 [self setBackgroundColor:[NSColor clearColor]];
185 [self startObservingClicks];
186 }
187 return self;
188 }
189
190 - (void)close {
191 [self stopObservingClicks];
192 [super close];
193 }
194
195 // Gets called for all events in application. Watching for a click outside the
196 // window so we can close.
197 - (void)hookForEvent:(NSEvent*)theEvent {
198 if ([theEvent window] == self)
199 return;
200 NSEventType eventType = [theEvent type];
201 if (eventType == NSLeftMouseDown || eventType == NSRightMouseDown)
202 [self close];
203 }
204
205 // Gets called when the menubar is clicked.
206 // Needed because the hookForEvent method doesn't see the click on the menubar.
207 - (void)begunTracking:(NSNotification*)notification {
208 [self close];
209 }
210
211 // Install the callback.
212 - (void)startObservingClicks {
213 CrEventHookApplication* app = static_cast<CrEventHookApplication*>(
214 [CrEventHookApplication sharedApplication]);
215 [app addEventHook:self];
216
217 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
218 [nc addObserver:self
219 selector:@selector(begunTracking:)
220 name:NSMenuDidBeginTrackingNotification
221 object:[NSApp mainMenu]];
222 }
223
224 // Remove the callback.
225 - (void)stopObservingClicks {
226 CrEventHookApplication* app = static_cast<CrEventHookApplication*>(
227 [CrEventHookApplication sharedApplication]);
228 [app removeEventHook:self];
229
230 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
231 [nc removeObserver:self
232 name:NSMenuDidBeginTrackingNotification
233 object:[NSApp mainMenu]];
234 }
235
236 @end
237
170 namespace { 238 namespace {
171 239
172 // Maximum number of characters we allow in a tooltip. 240 // Maximum number of characters we allow in a tooltip.
173 const size_t kMaxTooltipLength = 1024; 241 const size_t kMaxTooltipLength = 1024;
174 242
175 // TODO(suzhe): Upstream this function. 243 // TODO(suzhe): Upstream this function.
176 WebKit::WebColor WebColorFromNSColor(NSColor *color) { 244 WebKit::WebColor WebColorFromNSColor(NSColor *color) {
177 CGFloat r, g, b, a; 245 CGFloat r, g, b, a;
178 [color getRed:&r green:&g blue:&b alpha:&a]; 246 [color getRed:&r green:&g blue:&b alpha:&a];
179 247
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 void RenderWidgetHostViewMac::InitAsChild( 395 void RenderWidgetHostViewMac::InitAsChild(
328 gfx::NativeView parent_view) { 396 gfx::NativeView parent_view) {
329 } 397 }
330 398
331 void RenderWidgetHostViewMac::InitAsPopup( 399 void RenderWidgetHostViewMac::InitAsPopup(
332 RenderWidgetHostView* parent_host_view, 400 RenderWidgetHostView* parent_host_view,
333 const gfx::Rect& pos) { 401 const gfx::Rect& pos) {
334 bool activatable = popup_type_ == WebKit::WebPopupTypeNone; 402 bool activatable = popup_type_ == WebKit::WebPopupTypeNone;
335 [cocoa_view_ setCloseOnDeactivate:YES]; 403 [cocoa_view_ setCloseOnDeactivate:YES];
336 [cocoa_view_ setCanBeKeyView:activatable ? YES : NO]; 404 [cocoa_view_ setCanBeKeyView:activatable ? YES : NO];
337 [parent_host_view->GetNativeView() addSubview:cocoa_view_];
338 405
339 NSPoint origin_global = NSPointFromCGPoint(pos.origin().ToCGPoint()); 406 NSPoint origin_global = NSPointFromCGPoint(pos.origin().ToCGPoint());
340 if ([[NSScreen screens] count] > 0) { 407 if ([[NSScreen screens] count] > 0) {
341 origin_global.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height - 408 origin_global.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height -
342 pos.height() - origin_global.y; 409 pos.height() - origin_global.y;
343 } 410 }
344 NSPoint origin_window = 411
345 [[cocoa_view_ window] convertScreenToBase:origin_global]; 412 popup_window_.reset([[RenderWidgetPopupWindow alloc]
346 NSPoint origin_view = 413 initWithContentRect:NSMakeRect(origin_global.x, origin_global.y,
347 [cocoa_view_ convertPoint:origin_window fromView:nil]; 414 pos.width(), pos.height())
348 NSRect initial_frame = NSMakeRect(origin_view.x, 415 styleMask:NSBorderlessWindowMask
349 origin_view.y, 416 backing:NSBackingStoreBuffered
350 pos.width(), 417 defer:NO]);
351 pos.height()); 418 [popup_window_ setLevel:NSPopUpMenuWindowLevel];
352 [cocoa_view_ setFrame:initial_frame]; 419 [popup_window_ setReleasedWhenClosed:NO];
420 [popup_window_ makeKeyAndOrderFront:nil];
421 [[popup_window_ contentView] addSubview:cocoa_view_];
422 [cocoa_view_ setFrame:[[popup_window_ contentView] bounds]];
423 [cocoa_view_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
424 [[NSNotificationCenter defaultCenter]
425 addObserver:cocoa_view_
426 selector:@selector(popupWindowWillClose:)
427 name:NSWindowWillCloseNotification
428 object:popup_window_];
353 } 429 }
354 430
355 // This function creates the fullscreen window and hides the dock and menubar if 431 // This function creates the fullscreen window and hides the dock and menubar if
356 // necessary. Note, this codepath is only used for pepper flash when 432 // necessary. Note, this codepath is only used for pepper flash when
357 // pp::FlashFullScreen::SetFullscreen() is called. If 433 // pp::FlashFullScreen::SetFullscreen() is called. If
358 // pp::FullScreen::SetFullscreen() is called then the entire browser window 434 // pp::FullScreen::SetFullscreen() is called then the entire browser window
359 // will enter fullscreen instead. 435 // will enter fullscreen instead.
360 void RenderWidgetHostViewMac::InitAsFullscreen( 436 void RenderWidgetHostViewMac::InitAsFullscreen(
361 RenderWidgetHostView* reference_host_view) { 437 RenderWidgetHostView* reference_host_view) {
362 fullscreen_parent_host_view_ = 438 fullscreen_parent_host_view_ =
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 if (rect.size().IsEmpty()) 527 if (rect.size().IsEmpty())
452 return; 528 return;
453 529
454 // Ignore the position of |rect| for non-popup rwhvs. This is because 530 // Ignore the position of |rect| for non-popup rwhvs. This is because
455 // background tabs do not have a window, but the window is required for the 531 // background tabs do not have a window, but the window is required for the
456 // coordinate conversions. Popups are always for a visible tab. 532 // coordinate conversions. Popups are always for a visible tab.
457 if (IsPopup()) { 533 if (IsPopup()) {
458 // The position of |rect| is screen coordinate system and we have to 534 // The position of |rect| is screen coordinate system and we have to
459 // consider Cocoa coordinate system is upside-down and also multi-screen. 535 // consider Cocoa coordinate system is upside-down and also multi-screen.
460 NSPoint origin_global = NSPointFromCGPoint(rect.origin().ToCGPoint()); 536 NSPoint origin_global = NSPointFromCGPoint(rect.origin().ToCGPoint());
537 NSSize size = NSMakeSize(rect.width(), rect.height());
538 size = [cocoa_view_ convertSize:size toView:nil];
461 if ([[NSScreen screens] count] > 0) { 539 if ([[NSScreen screens] count] > 0) {
462 NSSize size = NSMakeSize(rect.width(), rect.height());
463 size = [cocoa_view_ convertSize:size toView:nil];
464 NSScreen* screen = 540 NSScreen* screen =
465 static_cast<NSScreen*>([[NSScreen screens] objectAtIndex:0]); 541 static_cast<NSScreen*>([[NSScreen screens] objectAtIndex:0]);
466 origin_global.y = 542 origin_global.y =
467 NSHeight([screen frame]) - size.height - origin_global.y; 543 NSHeight([screen frame]) - size.height - origin_global.y;
468 } 544 }
469 545 [popup_window_ setFrame:NSMakeRect(origin_global.x, origin_global.y,
470 // Then |origin_global| is converted to client coordinate system. 546 size.width, size.height)
471 DCHECK([cocoa_view_ window]); 547 display:YES];
472 NSPoint origin_window =
473 [[cocoa_view_ window] convertScreenToBase:origin_global];
474 NSPoint origin_view =
475 [[cocoa_view_ superview] convertPoint:origin_window fromView:nil];
476 NSRect frame = NSMakeRect(origin_view.x, origin_view.y,
477 rect.width(), rect.height());
478 [cocoa_view_ setFrame:frame];
479 } else { 548 } else {
480 DCHECK([[cocoa_view_ superview] isKindOfClass:[BaseView class]]); 549 DCHECK([[cocoa_view_ superview] isKindOfClass:[BaseView class]]);
481 BaseView* superview = static_cast<BaseView*>([cocoa_view_ superview]); 550 BaseView* superview = static_cast<BaseView*>([cocoa_view_ superview]);
482 gfx::Rect rect2 = [superview flipNSRectToRect:[cocoa_view_ frame]]; 551 gfx::Rect rect2 = [superview flipNSRectToRect:[cocoa_view_ frame]];
483 rect2.set_width(rect.width()); 552 rect2.set_width(rect.width());
484 rect2.set_height(rect.height()); 553 rect2.set_height(rect.height());
485 [cocoa_view_ setFrame:[superview flipRectToNSRect:rect2]]; 554 [cocoa_view_ setFrame:[superview flipRectToNSRect:rect2]];
486 } 555 }
487 } 556 }
488 557
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 } 767 }
699 768
700 void RenderWidgetHostViewMac::RenderViewGone(base::TerminationStatus status, 769 void RenderWidgetHostViewMac::RenderViewGone(base::TerminationStatus status,
701 int error_code) { 770 int error_code) {
702 Destroy(); 771 Destroy();
703 } 772 }
704 773
705 void RenderWidgetHostViewMac::Destroy() { 774 void RenderWidgetHostViewMac::Destroy() {
706 AckPendingSwapBuffers(); 775 AckPendingSwapBuffers();
707 776
708 // On Windows, popups are implemented with a popup window style, so that when
709 // an event comes in that would "cancel" it, it receives the OnCancelMode
710 // message and can kill itself. Alas, on the Mac, views cannot capture events
711 // outside of themselves. On Windows, if Destroy is being called on a view,
712 // then the event causing the destroy had also cancelled any popups by the
713 // time Destroy() was called. On the Mac we have to destroy all the popups
714 // ourselves.
715
716 // Depth-first destroy all popups. Use ShutdownHost() to enforce
717 // deepest-first ordering.
718 for (NSView* subview in [cocoa_view_ subviews]) { 777 for (NSView* subview in [cocoa_view_ subviews]) {
719 if ([subview isKindOfClass:[RenderWidgetHostViewCocoa class]]) { 778 if ([subview isKindOfClass:[AcceleratedPluginView class]]) {
720 [static_cast<RenderWidgetHostViewCocoa*>(subview)
721 renderWidgetHostViewMac]->ShutdownHost();
722 } else if ([subview isKindOfClass:[AcceleratedPluginView class]]) {
723 [static_cast<AcceleratedPluginView*>(subview) 779 [static_cast<AcceleratedPluginView*>(subview)
724 onRenderWidgetHostViewGone]; 780 onRenderWidgetHostViewGone];
725 } 781 }
726 } 782 }
727 783
784 [[NSNotificationCenter defaultCenter]
785 removeObserver:cocoa_view_
786 name:NSWindowWillCloseNotification
787 object:popup_window_];
788
728 // We've been told to destroy. 789 // We've been told to destroy.
729 [cocoa_view_ retain]; 790 [cocoa_view_ retain];
730 [cocoa_view_ removeFromSuperview]; 791 [cocoa_view_ removeFromSuperview];
731 [cocoa_view_ autorelease]; 792 [cocoa_view_ autorelease];
732 793
794 [popup_window_ close];
795 popup_window_.autorelease();
796
733 [fullscreen_window_manager_ exitFullscreenMode]; 797 [fullscreen_window_manager_ exitFullscreenMode];
734 fullscreen_window_manager_.reset(); 798 fullscreen_window_manager_.reset();
735 [pepper_fullscreen_window_ close]; 799 [pepper_fullscreen_window_ close];
736 800
737 // This can be called as part of processing the window's responder 801 // This can be called as part of processing the window's responder
738 // chain, for instance |-performKeyEquivalent:|. In that case the 802 // chain, for instance |-performKeyEquivalent:|. In that case the
739 // object needs to survive until the stack unwinds. 803 // object needs to survive until the stack unwinds.
740 pepper_fullscreen_window_.autorelease(); 804 pepper_fullscreen_window_.autorelease();
741 805
742 // We get this call just before |render_widget_host_| deletes 806 // We get this call just before |render_widget_host_| deletes
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 widgetHost->ForwardKeyboardEvent(event); 2143 widgetHost->ForwardKeyboardEvent(event);
2080 } 2144 }
2081 } 2145 }
2082 2146
2083 // Possibly autohide the cursor. 2147 // Possibly autohide the cursor.
2084 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent]) 2148 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent])
2085 [NSCursor setHiddenUntilMouseMoves:YES]; 2149 [NSCursor setHiddenUntilMouseMoves:YES];
2086 } 2150 }
2087 2151
2088 - (void)scrollWheel:(NSEvent*)theEvent { 2152 - (void)scrollWheel:(NSEvent*)theEvent {
2089 // Cancel popups before calling the delegate because even if the delegate eats
2090 // the event, it's still an explicit user action outside the popup.
2091 [self cancelChildPopups];
2092
2093 if (delegate_ && [delegate_ respondsToSelector:@selector(handleEvent:)]) { 2153 if (delegate_ && [delegate_ respondsToSelector:@selector(handleEvent:)]) {
2094 BOOL handled = [delegate_ handleEvent:theEvent]; 2154 BOOL handled = [delegate_ handleEvent:theEvent];
2095 if (handled) 2155 if (handled)
2096 return; 2156 return;
2097 } 2157 }
2098 2158
2099 const WebMouseWheelEvent& event = 2159 const WebMouseWheelEvent& event =
2100 WebInputEventFactory::mouseWheelEvent(theEvent, self); 2160 WebInputEventFactory::mouseWheelEvent(theEvent, self);
2101 if (renderWidgetHostView_->render_widget_host_) 2161 if (renderWidgetHostView_->render_widget_host_)
2102 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(event); 2162 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(event);
2103 } 2163 }
2104 2164
2105 // See the comment in RenderWidgetHostViewMac::Destroy() about cancellation
2106 // events. On the Mac we must kill popups on outside events, thus this lovely
2107 // case of filicide caused by events on parent views.
2108 - (void)cancelChildPopups {
2109 // If this view can be the key view, it is not a popup. Therefore, if it has
2110 // any children, they are popups that need to be canceled.
2111 if (canBeKeyView_) {
2112 for (NSView* subview in [self subviews]) {
2113 if (![subview isKindOfClass:[RenderWidgetHostViewCocoa class]])
2114 continue; // Skip plugin views.
2115
2116 [static_cast<RenderWidgetHostViewCocoa*>(subview)
2117 renderWidgetHostViewMac]->KillSelf();
2118 }
2119 }
2120 }
2121
2122 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { 2165 - (void)viewWillMoveToWindow:(NSWindow*)newWindow {
2123 // We're messing with the window, so do this to ensure no flashes. This one 2166 // We're messing with the window, so do this to ensure no flashes. This one
2124 // prevents a flash when the current tab is closed. 2167 // prevents a flash when the current tab is closed.
2125 NSWindow* oldWindow = [self window]; 2168 NSWindow* oldWindow = [self window];
2126 [oldWindow disableScreenUpdatesUntilFlush]; 2169 [oldWindow disableScreenUpdatesUntilFlush];
2127 2170
2128 NSNotificationCenter* notificationCenter = 2171 NSNotificationCenter* notificationCenter =
2129 [NSNotificationCenter defaultCenter]; 2172 [NSNotificationCenter defaultCenter];
2130 if (oldWindow) { 2173 if (oldWindow) {
2131 [notificationCenter 2174 [notificationCenter
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3330 } 3373 }
3331 3374
3332 - (void)updateCursor:(NSCursor*)cursor { 3375 - (void)updateCursor:(NSCursor*)cursor {
3333 if (currentCursor_ == cursor) 3376 if (currentCursor_ == cursor)
3334 return; 3377 return;
3335 3378
3336 currentCursor_.reset(cursor, base::scoped_policy::RETAIN); 3379 currentCursor_.reset(cursor, base::scoped_policy::RETAIN);
3337 [[self window] invalidateCursorRectsForView:self]; 3380 [[self window] invalidateCursorRectsForView:self];
3338 } 3381 }
3339 3382
3383 - (void)popupWindowWillClose:(NSNotification *)notification {
3384 renderWidgetHostView_->KillSelf();
3385 }
3386
3340 @end 3387 @end
3341 3388
3342 // 3389 //
3343 // Supporting application services 3390 // Supporting application services
3344 // 3391 //
3345 @implementation RenderWidgetHostViewCocoa(NSServicesRequests) 3392 @implementation RenderWidgetHostViewCocoa(NSServicesRequests)
3346 3393
3347 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard 3394 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard
3348 types:(NSArray*)types { 3395 types:(NSArray*)types {
3349 const std::string& str = renderWidgetHostView_->selected_text(); 3396 const std::string& str = renderWidgetHostView_->selected_text();
(...skipping 11 matching lines...) Expand all
3361 if (!string) return NO; 3408 if (!string) return NO;
3362 3409
3363 // If the user is currently using an IME, confirm the IME input, 3410 // If the user is currently using an IME, confirm the IME input,
3364 // and then insert the text from the service, the same as TextEdit and Safari. 3411 // and then insert the text from the service, the same as TextEdit and Safari.
3365 [self confirmComposition]; 3412 [self confirmComposition];
3366 [self insertText:string]; 3413 [self insertText:string];
3367 return YES; 3414 return YES;
3368 } 3415 }
3369 3416
3370 @end 3417 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698