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

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: Fixed nits Created 7 years, 11 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 unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 @property(nonatomic, assign) NSRange selectedRange; 139 @property(nonatomic, assign) NSRange selectedRange;
140 @property(nonatomic, assign) NSRange markedRange; 140 @property(nonatomic, assign) NSRange markedRange;
141 141
142 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event; 142 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event;
143 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; 143 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r;
144 - (void)setRWHVDelegate:(NSObject<RenderWidgetHostViewMacDelegate>*)delegate; 144 - (void)setRWHVDelegate:(NSObject<RenderWidgetHostViewMacDelegate>*)delegate;
145 - (void)gotUnhandledWheelEvent; 145 - (void)gotUnhandledWheelEvent;
146 - (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right; 146 - (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right;
147 - (void)setHasHorizontalScrollbar:(BOOL)has_horizontal_scrollbar; 147 - (void)setHasHorizontalScrollbar:(BOOL)has_horizontal_scrollbar;
148 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv; 148 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv;
149 - (void)cancelChildPopups;
150 - (void)windowDidChangeBackingProperties:(NSNotification*)notification; 149 - (void)windowDidChangeBackingProperties:(NSNotification*)notification;
151 - (void)windowChangedGlobalFrame:(NSNotification*)notification; 150 - (void)windowChangedGlobalFrame:(NSNotification*)notification;
152 - (void)checkForPluginImeCancellation; 151 - (void)checkForPluginImeCancellation;
153 - (void)updateTabBackingStoreScaleFactor; 152 - (void)updateTabBackingStoreScaleFactor;
154 - (NSRect)firstViewRectForCharacterRange:(NSRange)theRange 153 - (NSRect)firstViewRectForCharacterRange:(NSRange)theRange
155 actualRange:(NSRangePointer)actualRange; 154 actualRange:(NSRangePointer)actualRange;
156 @end 155 @end
157 156
158 // NSEvent subtype for scroll gestures events. 157 // NSEvent subtype for scroll gestures events.
159 static const short kIOHIDEventTypeScroll = 6; 158 static const short kIOHIDEventTypeScroll = 6;
160 159
161 // A window subclass that allows the fullscreen window to become main and gain 160 // A window subclass that allows the fullscreen window to become main and gain
162 // keyboard focus. This is only used for pepper flash. Normal fullscreen is 161 // keyboard focus. This is only used for pepper flash. Normal fullscreen is
163 // handled by the browser. 162 // handled by the browser.
164 @interface PepperFlashFullscreenWindow : UnderlayOpenGLHostingWindow 163 @interface PepperFlashFullscreenWindow : UnderlayOpenGLHostingWindow
165 @end 164 @end
166 165
167 @implementation PepperFlashFullscreenWindow 166 @implementation PepperFlashFullscreenWindow
168 167
169 - (BOOL)canBecomeKeyWindow { 168 - (BOOL)canBecomeKeyWindow {
170 return YES; 169 return YES;
171 } 170 }
172 171
173 - (BOOL)canBecomeMainWindow { 172 - (BOOL)canBecomeMainWindow {
174 return YES; 173 return YES;
175 } 174 }
176 175
177 @end 176 @end
178 177
178 @interface RenderWidgetPopupWindow : NSWindow {
179 // The event tap that allows monitoring of all events, to properly close with
180 // a click outside the bounds of the window.
181 id clickEventTap_;
182 }
183 @end
184
185 @implementation RenderWidgetPopupWindow
186
187 - (id)initWithContentRect:(NSRect)contentRect
188 styleMask:(NSUInteger)windowStyle
189 backing:(NSBackingStoreType)bufferingType
190 defer:(BOOL)deferCreation {
191 if (self = [super initWithContentRect:contentRect
192 styleMask:windowStyle
193 backing:bufferingType
194 defer:deferCreation]) {
195 [self setOpaque:NO];
196 [self setBackgroundColor:[NSColor clearColor]];
197 [self startObservingClicks];
198 }
199 return self;
200 }
201
202 - (void)close {
203 [self stopObservingClicks];
204 [super close];
205 }
206
207 // Gets called when the menubar is clicked.
208 // Needed because the local event monitor doesn't see the click on the menubar.
209 - (void)beganTracking:(NSNotification*)notification {
210 [self close];
211 }
212
213 // Install the callback.
214 - (void)startObservingClicks {
215 clickEventTap_ = [NSEvent addLocalMonitorForEventsMatchingMask:NSAnyEventMask
216 handler:^NSEvent* (NSEvent* event) {
217 if ([event window] == self)
218 return event;
219 NSEventType eventType = [event type];
220 if (eventType == NSLeftMouseDown || eventType == NSRightMouseDown)
221 [self close];
222 return event;
223 }];
224
225 NSNotificationCenter* notificationCenter =
226 [NSNotificationCenter defaultCenter];
227 [notificationCenter addObserver:self
228 selector:@selector(beganTracking:)
229 name:NSMenuDidBeginTrackingNotification
230 object:[NSApp mainMenu]];
231 }
232
233 // Remove the callback.
234 - (void)stopObservingClicks {
235 if (!clickEventTap_)
236 return;
237
238 [NSEvent removeMonitor:clickEventTap_];
239 clickEventTap_ = nil;
240
241 NSNotificationCenter* notificationCenter =
242 [NSNotificationCenter defaultCenter];
243 [notificationCenter removeObserver:self
244 name:NSMenuDidBeginTrackingNotification
245 object:[NSApp mainMenu]];
246 }
247
248 @end
249
179 namespace { 250 namespace {
180 251
181 // Maximum number of characters we allow in a tooltip. 252 // Maximum number of characters we allow in a tooltip.
182 const size_t kMaxTooltipLength = 1024; 253 const size_t kMaxTooltipLength = 1024;
183 254
184 // TODO(suzhe): Upstream this function. 255 // TODO(suzhe): Upstream this function.
185 WebKit::WebColor WebColorFromNSColor(NSColor *color) { 256 WebKit::WebColor WebColorFromNSColor(NSColor *color) {
186 CGFloat r, g, b, a; 257 CGFloat r, g, b, a;
187 [color getRed:&r green:&g blue:&b alpha:&a]; 258 [color getRed:&r green:&g blue:&b alpha:&a];
188 259
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 void RenderWidgetHostViewMac::InitAsChild( 407 void RenderWidgetHostViewMac::InitAsChild(
337 gfx::NativeView parent_view) { 408 gfx::NativeView parent_view) {
338 } 409 }
339 410
340 void RenderWidgetHostViewMac::InitAsPopup( 411 void RenderWidgetHostViewMac::InitAsPopup(
341 RenderWidgetHostView* parent_host_view, 412 RenderWidgetHostView* parent_host_view,
342 const gfx::Rect& pos) { 413 const gfx::Rect& pos) {
343 bool activatable = popup_type_ == WebKit::WebPopupTypeNone; 414 bool activatable = popup_type_ == WebKit::WebPopupTypeNone;
344 [cocoa_view_ setCloseOnDeactivate:YES]; 415 [cocoa_view_ setCloseOnDeactivate:YES];
345 [cocoa_view_ setCanBeKeyView:activatable ? YES : NO]; 416 [cocoa_view_ setCanBeKeyView:activatable ? YES : NO];
346 [parent_host_view->GetNativeView() addSubview:cocoa_view_];
347 417
348 NSPoint origin_global = NSPointFromCGPoint(pos.origin().ToCGPoint()); 418 NSPoint origin_global = NSPointFromCGPoint(pos.origin().ToCGPoint());
349 if ([[NSScreen screens] count] > 0) { 419 if ([[NSScreen screens] count] > 0) {
350 origin_global.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height - 420 origin_global.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height -
351 pos.height() - origin_global.y; 421 pos.height() - origin_global.y;
352 } 422 }
353 NSPoint origin_window = 423
354 [[cocoa_view_ window] convertScreenToBase:origin_global]; 424 popup_window_.reset([[RenderWidgetPopupWindow alloc]
355 NSPoint origin_view = 425 initWithContentRect:NSMakeRect(origin_global.x, origin_global.y,
356 [cocoa_view_ convertPoint:origin_window fromView:nil]; 426 pos.width(), pos.height())
357 NSRect initial_frame = NSMakeRect(origin_view.x, 427 styleMask:NSBorderlessWindowMask
358 origin_view.y, 428 backing:NSBackingStoreBuffered
359 pos.width(), 429 defer:NO]);
360 pos.height()); 430 [popup_window_ setLevel:NSPopUpMenuWindowLevel];
361 [cocoa_view_ setFrame:initial_frame]; 431 [popup_window_ setReleasedWhenClosed:NO];
432 [popup_window_ makeKeyAndOrderFront:nil];
433 [[popup_window_ contentView] addSubview:cocoa_view_];
434 [cocoa_view_ setFrame:[[popup_window_ contentView] bounds]];
435 [cocoa_view_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
436 [[NSNotificationCenter defaultCenter]
437 addObserver:cocoa_view_
438 selector:@selector(popupWindowWillClose:)
439 name:NSWindowWillCloseNotification
440 object:popup_window_];
362 } 441 }
363 442
364 // This function creates the fullscreen window and hides the dock and menubar if 443 // This function creates the fullscreen window and hides the dock and menubar if
365 // necessary. Note, this codepath is only used for pepper flash when 444 // necessary. Note, this codepath is only used for pepper flash when
366 // pp::FlashFullScreen::SetFullscreen() is called. If 445 // pp::FlashFullScreen::SetFullscreen() is called. If
367 // pp::FullScreen::SetFullscreen() is called then the entire browser window 446 // pp::FullScreen::SetFullscreen() is called then the entire browser window
368 // will enter fullscreen instead. 447 // will enter fullscreen instead.
369 void RenderWidgetHostViewMac::InitAsFullscreen( 448 void RenderWidgetHostViewMac::InitAsFullscreen(
370 RenderWidgetHostView* reference_host_view) { 449 RenderWidgetHostView* reference_host_view) {
371 fullscreen_parent_host_view_ = 450 fullscreen_parent_host_view_ =
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 if (rect.size().IsEmpty()) 539 if (rect.size().IsEmpty())
461 return; 540 return;
462 541
463 // Ignore the position of |rect| for non-popup rwhvs. This is because 542 // Ignore the position of |rect| for non-popup rwhvs. This is because
464 // background tabs do not have a window, but the window is required for the 543 // background tabs do not have a window, but the window is required for the
465 // coordinate conversions. Popups are always for a visible tab. 544 // coordinate conversions. Popups are always for a visible tab.
466 if (IsPopup()) { 545 if (IsPopup()) {
467 // The position of |rect| is screen coordinate system and we have to 546 // The position of |rect| is screen coordinate system and we have to
468 // consider Cocoa coordinate system is upside-down and also multi-screen. 547 // consider Cocoa coordinate system is upside-down and also multi-screen.
469 NSPoint origin_global = NSPointFromCGPoint(rect.origin().ToCGPoint()); 548 NSPoint origin_global = NSPointFromCGPoint(rect.origin().ToCGPoint());
549 NSSize size = NSMakeSize(rect.width(), rect.height());
550 size = [cocoa_view_ convertSize:size toView:nil];
470 if ([[NSScreen screens] count] > 0) { 551 if ([[NSScreen screens] count] > 0) {
471 NSSize size = NSMakeSize(rect.width(), rect.height());
472 size = [cocoa_view_ convertSize:size toView:nil];
473 NSScreen* screen = 552 NSScreen* screen =
474 static_cast<NSScreen*>([[NSScreen screens] objectAtIndex:0]); 553 static_cast<NSScreen*>([[NSScreen screens] objectAtIndex:0]);
475 origin_global.y = 554 origin_global.y =
476 NSHeight([screen frame]) - size.height - origin_global.y; 555 NSHeight([screen frame]) - size.height - origin_global.y;
477 } 556 }
478 557 [popup_window_ setFrame:NSMakeRect(origin_global.x, origin_global.y,
479 // Then |origin_global| is converted to client coordinate system. 558 size.width, size.height)
480 DCHECK([cocoa_view_ window]); 559 display:YES];
481 NSPoint origin_window =
482 [[cocoa_view_ window] convertScreenToBase:origin_global];
483 NSPoint origin_view =
484 [[cocoa_view_ superview] convertPoint:origin_window fromView:nil];
485 NSRect frame = NSMakeRect(origin_view.x, origin_view.y,
486 rect.width(), rect.height());
487 [cocoa_view_ setFrame:frame];
488 } else { 560 } else {
489 DCHECK([[cocoa_view_ superview] isKindOfClass:[BaseView class]]); 561 DCHECK([[cocoa_view_ superview] isKindOfClass:[BaseView class]]);
490 BaseView* superview = static_cast<BaseView*>([cocoa_view_ superview]); 562 BaseView* superview = static_cast<BaseView*>([cocoa_view_ superview]);
491 gfx::Rect rect2 = [superview flipNSRectToRect:[cocoa_view_ frame]]; 563 gfx::Rect rect2 = [superview flipNSRectToRect:[cocoa_view_ frame]];
492 rect2.set_width(rect.width()); 564 rect2.set_width(rect.width());
493 rect2.set_height(rect.height()); 565 rect2.set_height(rect.height());
494 [cocoa_view_ setFrame:[superview flipRectToNSRect:rect2]]; 566 [cocoa_view_ setFrame:[superview flipRectToNSRect:rect2]];
495 } 567 }
496 } 568 }
497 569
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 } 779 }
708 780
709 void RenderWidgetHostViewMac::RenderViewGone(base::TerminationStatus status, 781 void RenderWidgetHostViewMac::RenderViewGone(base::TerminationStatus status,
710 int error_code) { 782 int error_code) {
711 Destroy(); 783 Destroy();
712 } 784 }
713 785
714 void RenderWidgetHostViewMac::Destroy() { 786 void RenderWidgetHostViewMac::Destroy() {
715 AckPendingSwapBuffers(); 787 AckPendingSwapBuffers();
716 788
717 // On Windows, popups are implemented with a popup window style, so that when
718 // an event comes in that would "cancel" it, it receives the OnCancelMode
719 // message and can kill itself. Alas, on the Mac, views cannot capture events
720 // outside of themselves. On Windows, if Destroy is being called on a view,
721 // then the event causing the destroy had also cancelled any popups by the
722 // time Destroy() was called. On the Mac we have to destroy all the popups
723 // ourselves.
724
725 // Depth-first destroy all popups. Use ShutdownHost() to enforce
726 // deepest-first ordering.
727 for (NSView* subview in [cocoa_view_ subviews]) { 789 for (NSView* subview in [cocoa_view_ subviews]) {
728 if ([subview isKindOfClass:[RenderWidgetHostViewCocoa class]]) { 790 if ([subview isKindOfClass:[AcceleratedPluginView class]]) {
729 [static_cast<RenderWidgetHostViewCocoa*>(subview)
730 renderWidgetHostViewMac]->ShutdownHost();
731 } else if ([subview isKindOfClass:[AcceleratedPluginView class]]) {
732 [static_cast<AcceleratedPluginView*>(subview) 791 [static_cast<AcceleratedPluginView*>(subview)
733 onRenderWidgetHostViewGone]; 792 onRenderWidgetHostViewGone];
734 } 793 }
735 } 794 }
736 795
796 [[NSNotificationCenter defaultCenter]
797 removeObserver:cocoa_view_
798 name:NSWindowWillCloseNotification
799 object:popup_window_];
800
737 // We've been told to destroy. 801 // We've been told to destroy.
738 [cocoa_view_ retain]; 802 [cocoa_view_ retain];
739 [cocoa_view_ removeFromSuperview]; 803 [cocoa_view_ removeFromSuperview];
740 [cocoa_view_ autorelease]; 804 [cocoa_view_ autorelease];
741 805
806 [popup_window_ close];
807 popup_window_.autorelease();
808
742 [fullscreen_window_manager_ exitFullscreenMode]; 809 [fullscreen_window_manager_ exitFullscreenMode];
743 fullscreen_window_manager_.reset(); 810 fullscreen_window_manager_.reset();
744 [pepper_fullscreen_window_ close]; 811 [pepper_fullscreen_window_ close];
745 812
746 // This can be called as part of processing the window's responder 813 // This can be called as part of processing the window's responder
747 // chain, for instance |-performKeyEquivalent:|. In that case the 814 // chain, for instance |-performKeyEquivalent:|. In that case the
748 // object needs to survive until the stack unwinds. 815 // object needs to survive until the stack unwinds.
749 pepper_fullscreen_window_.autorelease(); 816 pepper_fullscreen_window_.autorelease();
750 817
751 // We get this call just before |render_widget_host_| deletes 818 // We get this call just before |render_widget_host_| deletes
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent); 2176 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent);
2110 } 2177 }
2111 2178
2112 if (endWheelMonitor_) { 2179 if (endWheelMonitor_) {
2113 [NSEvent removeMonitor:endWheelMonitor_]; 2180 [NSEvent removeMonitor:endWheelMonitor_];
2114 endWheelMonitor_ = nil; 2181 endWheelMonitor_ = nil;
2115 } 2182 }
2116 } 2183 }
2117 2184
2118 - (void)scrollWheel:(NSEvent*)event { 2185 - (void)scrollWheel:(NSEvent*)event {
2119 // Cancel popups before calling the delegate because even if the delegate eats
2120 // the event, it's still an explicit user action outside the popup.
2121 [self cancelChildPopups];
2122
2123 if (delegate_ && [delegate_ respondsToSelector:@selector(handleEvent:)]) { 2186 if (delegate_ && [delegate_ respondsToSelector:@selector(handleEvent:)]) {
2124 BOOL handled = [delegate_ handleEvent:event]; 2187 BOOL handled = [delegate_ handleEvent:event];
2125 if (handled) 2188 if (handled)
2126 return; 2189 return;
2127 } 2190 }
2128 2191
2129 // Use an NSEvent monitor to listen for the wheel-end end. This ensures that 2192 // Use an NSEvent monitor to listen for the wheel-end end. This ensures that
2130 // the event is received even when the mouse cursor is no longer over the view 2193 // the event is received even when the mouse cursor is no longer over the view
2131 // when the scrolling ends (e.g. if the tab was switched). This is necessary 2194 // when the scrolling ends (e.g. if the tab was switched). This is necessary
2132 // for ending rubber-banding in such cases. 2195 // for ending rubber-banding in such cases.
2133 if (base::mac::IsOSLionOrLater() && [event phase] == NSEventPhaseBegan && 2196 if (base::mac::IsOSLionOrLater() && [event phase] == NSEventPhaseBegan &&
2134 !endWheelMonitor_) { 2197 !endWheelMonitor_) {
2135 endWheelMonitor_ = 2198 endWheelMonitor_ =
2136 [NSEvent addLocalMonitorForEventsMatchingMask:NSScrollWheelMask 2199 [NSEvent addLocalMonitorForEventsMatchingMask:NSScrollWheelMask
2137 handler:^(NSEvent* blockEvent) { 2200 handler:^(NSEvent* blockEvent) {
2138 [self shortCircuitScrollWheelEvent:blockEvent]; 2201 [self shortCircuitScrollWheelEvent:blockEvent];
2139 return blockEvent; 2202 return blockEvent;
2140 }]; 2203 }];
2141 } 2204 }
2142 2205
2143 if (renderWidgetHostView_->render_widget_host_) { 2206 if (renderWidgetHostView_->render_widget_host_) {
2144 const WebMouseWheelEvent& webEvent = 2207 const WebMouseWheelEvent& webEvent =
2145 WebInputEventFactory::mouseWheelEvent(event, self); 2208 WebInputEventFactory::mouseWheelEvent(event, self);
2146 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent); 2209 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent);
2147 } 2210 }
2148 } 2211 }
2149 2212
2150 // See the comment in RenderWidgetHostViewMac::Destroy() about cancellation
2151 // events. On the Mac we must kill popups on outside events, thus this lovely
2152 // case of filicide caused by events on parent views.
2153 - (void)cancelChildPopups {
2154 // If this view can be the key view, it is not a popup. Therefore, if it has
2155 // any children, they are popups that need to be canceled.
2156 if (canBeKeyView_) {
2157 for (NSView* subview in [self subviews]) {
2158 if (![subview isKindOfClass:[RenderWidgetHostViewCocoa class]])
2159 continue; // Skip plugin views.
2160
2161 [static_cast<RenderWidgetHostViewCocoa*>(subview)
2162 renderWidgetHostViewMac]->KillSelf();
2163 }
2164 }
2165 }
2166
2167 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { 2213 - (void)viewWillMoveToWindow:(NSWindow*)newWindow {
2168 // We're messing with the window, so do this to ensure no flashes. This one 2214 // We're messing with the window, so do this to ensure no flashes. This one
2169 // prevents a flash when the current tab is closed. 2215 // prevents a flash when the current tab is closed.
2170 NSWindow* oldWindow = [self window]; 2216 NSWindow* oldWindow = [self window];
2171 [oldWindow disableScreenUpdatesUntilFlush]; 2217 [oldWindow disableScreenUpdatesUntilFlush];
2172 2218
2173 NSNotificationCenter* notificationCenter = 2219 NSNotificationCenter* notificationCenter =
2174 [NSNotificationCenter defaultCenter]; 2220 [NSNotificationCenter defaultCenter];
2175 if (oldWindow) { 2221 if (oldWindow) {
2176 [notificationCenter 2222 [notificationCenter
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3375 } 3421 }
3376 3422
3377 - (void)updateCursor:(NSCursor*)cursor { 3423 - (void)updateCursor:(NSCursor*)cursor {
3378 if (currentCursor_ == cursor) 3424 if (currentCursor_ == cursor)
3379 return; 3425 return;
3380 3426
3381 currentCursor_.reset(cursor, base::scoped_policy::RETAIN); 3427 currentCursor_.reset(cursor, base::scoped_policy::RETAIN);
3382 [[self window] invalidateCursorRectsForView:self]; 3428 [[self window] invalidateCursorRectsForView:self];
3383 } 3429 }
3384 3430
3431 - (void)popupWindowWillClose:(NSNotification *)notification {
3432 renderWidgetHostView_->KillSelf();
3433 }
3434
3385 @end 3435 @end
3386 3436
3387 // 3437 //
3388 // Supporting application services 3438 // Supporting application services
3389 // 3439 //
3390 @implementation RenderWidgetHostViewCocoa(NSServicesRequests) 3440 @implementation RenderWidgetHostViewCocoa(NSServicesRequests)
3391 3441
3392 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard 3442 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard
3393 types:(NSArray*)types { 3443 types:(NSArray*)types {
3394 const std::string& str = renderWidgetHostView_->selected_text(); 3444 const std::string& str = renderWidgetHostView_->selected_text();
(...skipping 11 matching lines...) Expand all
3406 if (!string) return NO; 3456 if (!string) return NO;
3407 3457
3408 // If the user is currently using an IME, confirm the IME input, 3458 // If the user is currently using an IME, confirm the IME input,
3409 // and then insert the text from the service, the same as TextEdit and Safari. 3459 // and then insert the text from the service, the same as TextEdit and Safari.
3410 [self confirmComposition]; 3460 [self confirmComposition];
3411 [self insertText:string]; 3461 [self insertText:string];
3412 return YES; 3462 return YES;
3413 } 3463 }
3414 3464
3415 @end 3465 @end
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698