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

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