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

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 closing child popups 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 22 matching lines...) Expand all
33 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" 33 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h"
34 #import "content/browser/renderer_host/text_input_client_mac.h" 34 #import "content/browser/renderer_host/text_input_client_mac.h"
35 #include "content/common/accessibility_messages.h" 35 #include "content/common/accessibility_messages.h"
36 #include "content/common/edit_command.h" 36 #include "content/common/edit_command.h"
37 #include "content/common/gpu/gpu_messages.h" 37 #include "content/common/gpu/gpu_messages.h"
38 #include "content/common/plugin_messages.h" 38 #include "content/common/plugin_messages.h"
39 #include "content/common/view_messages.h" 39 #include "content/common/view_messages.h"
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 "content/public/browser/web_contents_view_delegate.h"
Avi (use Gerrit) 2012/12/14 04:42:15 I don't think this is needed any more
43 #include "skia/ext/platform_canvas.h" 44 #include "skia/ext/platform_canvas.h"
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
46 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFact ory.h" 47 #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" 48 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFact ory.h"
48 #import "third_party/mozilla/ComplexTextInputPanel.h" 49 #import "third_party/mozilla/ComplexTextInputPanel.h"
49 #include "third_party/skia/include/core/SkColor.h" 50 #include "third_party/skia/include/core/SkColor.h"
51 #import "ui/base/cocoa/event_hook_application.h"
50 #import "ui/base/cocoa/fullscreen_window_manager.h" 52 #import "ui/base/cocoa/fullscreen_window_manager.h"
51 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" 53 #import "ui/base/cocoa/underlay_opengl_hosting_window.h"
52 #include "ui/base/keycodes/keyboard_codes.h" 54 #include "ui/base/keycodes/keyboard_codes.h"
53 #include "ui/base/layout.h" 55 #include "ui/base/layout.h"
54 #include "ui/gfx/point.h" 56 #include "ui/gfx/point.h"
55 #include "ui/gfx/rect_conversions.h" 57 #include "ui/gfx/rect_conversions.h"
56 #include "ui/gfx/size_conversions.h" 58 #include "ui/gfx/size_conversions.h"
57 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 59 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
58 #include "ui/surface/io_surface_support_mac.h" 60 #include "ui/surface/io_surface_support_mac.h"
59 #include "webkit/plugins/npapi/webplugin.h" 61 #include "webkit/plugins/npapi/webplugin.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 @property(nonatomic, assign) NSRange selectedRange; 132 @property(nonatomic, assign) NSRange selectedRange;
131 @property(nonatomic, assign) NSRange markedRange; 133 @property(nonatomic, assign) NSRange markedRange;
132 134
133 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event; 135 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event;
134 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; 136 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r;
135 - (void)setRWHVDelegate:(NSObject<RenderWidgetHostViewMacDelegate>*)delegate; 137 - (void)setRWHVDelegate:(NSObject<RenderWidgetHostViewMacDelegate>*)delegate;
136 - (void)gotUnhandledWheelEvent; 138 - (void)gotUnhandledWheelEvent;
137 - (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right; 139 - (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right;
138 - (void)setHasHorizontalScrollbar:(BOOL)has_horizontal_scrollbar; 140 - (void)setHasHorizontalScrollbar:(BOOL)has_horizontal_scrollbar;
139 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv; 141 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv;
140 - (void)cancelChildPopups;
141 - (void)windowDidChangeBackingProperties:(NSNotification*)notification; 142 - (void)windowDidChangeBackingProperties:(NSNotification*)notification;
142 - (void)windowChangedGlobalFrame:(NSNotification*)notification; 143 - (void)windowChangedGlobalFrame:(NSNotification*)notification;
143 - (void)checkForPluginImeCancellation; 144 - (void)checkForPluginImeCancellation;
144 - (void)updateTabBackingStoreScaleFactor; 145 - (void)updateTabBackingStoreScaleFactor;
145 - (NSRect)firstViewRectForCharacterRange:(NSRange)theRange 146 - (NSRect)firstViewRectForCharacterRange:(NSRange)theRange
146 actualRange:(NSRangePointer)actualRange; 147 actualRange:(NSRangePointer)actualRange;
147 @end 148 @end
148 149
149 // NSEvent subtype for scroll gestures events. 150 // NSEvent subtype for scroll gestures events.
150 static const short kIOHIDEventTypeScroll = 6; 151 static const short kIOHIDEventTypeScroll = 6;
151 152
152 // A window subclass that allows the fullscreen window to become main and gain 153 // 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 154 // keyboard focus. This is only used for pepper flash. Normal fullscreen is
154 // handled by the browser. 155 // handled by the browser.
155 @interface PepperFlashFullscreenWindow : UnderlayOpenGLHostingWindow 156 @interface PepperFlashFullscreenWindow : UnderlayOpenGLHostingWindow
156 @end 157 @end
157 158
158 @implementation PepperFlashFullscreenWindow 159 @implementation PepperFlashFullscreenWindow
159 160
160 - (BOOL)canBecomeKeyWindow { 161 - (BOOL)canBecomeKeyWindow {
161 return YES; 162 return YES;
162 } 163 }
163 164
164 - (BOOL)canBecomeMainWindow { 165 - (BOOL)canBecomeMainWindow {
165 return YES; 166 return YES;
166 } 167 }
167 168
168 @end 169 @end
169 170
171 @interface RenderWidgetPopupWindow : NSWindow<CrEventHookProtocol>
172 @end
173
174 @implementation RenderWidgetPopupWindow
175
176 - (id)initWithContentRect:(NSRect)contentRect
177 styleMask:(NSUInteger)windowStyle
178 backing:(NSBackingStoreType)bufferingType
179 defer:(BOOL)deferCreation {
180 if (self = [super initWithContentRect:contentRect
181 styleMask:windowStyle
182 backing:bufferingType
183 defer:deferCreation]) {
184 [self setOpaque:NO];
185 [self setBackgroundColor:[NSColor clearColor]];
186 [self startObservingClicks];
187 }
188 return self;
189 }
190
191 - (void)close {
192 [self stopObservingClicks];
193 [super close];
194 }
195
196 // Gets called for all events in application. Watching for a click outside the
197 // window so we can close.
198 - (void)hookForEvent:(NSEvent*)theEvent {
199 if ([theEvent window] == self)
200 return;
201 NSEventType eventType = [theEvent type];
202 if (eventType == NSLeftMouseDown || eventType == NSRightMouseDown)
203 [self close];
204 }
205
206 // Gets called when the menubar is clicked.
207 // Needed because the hookForEvent method doesn't see the click on the menubar.
208 - (void)begunTracking:(NSNotification*)notification {
209 [self close];
210 }
211
212 // Install the callback.
213 - (void)startObservingClicks {
214 CrEventHookApplication* app = static_cast<CrEventHookApplication*>(
215 [CrEventHookApplication sharedApplication]);
216 [app addEventHook:self];
217
218 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
219 [nc addObserver:self
220 selector:@selector(begunTracking:)
221 name:NSMenuDidBeginTrackingNotification
222 object:[NSApp mainMenu]];
223 }
224
225 // Remove the callback.
226 - (void)stopObservingClicks {
227 CrEventHookApplication* app = static_cast<CrEventHookApplication*>(
228 [CrEventHookApplication sharedApplication]);
229 [app removeEventHook:self];
230
231 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
232 [nc removeObserver:self
233 name:NSMenuDidBeginTrackingNotification
234 object:[NSApp mainMenu]];
235 }
236
237 @end
238
170 namespace { 239 namespace {
171 240
172 // Maximum number of characters we allow in a tooltip. 241 // Maximum number of characters we allow in a tooltip.
173 const size_t kMaxTooltipLength = 1024; 242 const size_t kMaxTooltipLength = 1024;
174 243
175 // TODO(suzhe): Upstream this function. 244 // TODO(suzhe): Upstream this function.
176 WebKit::WebColor WebColorFromNSColor(NSColor *color) { 245 WebKit::WebColor WebColorFromNSColor(NSColor *color) {
177 CGFloat r, g, b, a; 246 CGFloat r, g, b, a;
178 [color getRed:&r green:&g blue:&b alpha:&a]; 247 [color getRed:&r green:&g blue:&b alpha:&a];
179 248
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 void RenderWidgetHostViewMac::InitAsChild( 396 void RenderWidgetHostViewMac::InitAsChild(
328 gfx::NativeView parent_view) { 397 gfx::NativeView parent_view) {
329 } 398 }
330 399
331 void RenderWidgetHostViewMac::InitAsPopup( 400 void RenderWidgetHostViewMac::InitAsPopup(
332 RenderWidgetHostView* parent_host_view, 401 RenderWidgetHostView* parent_host_view,
333 const gfx::Rect& pos) { 402 const gfx::Rect& pos) {
334 bool activatable = popup_type_ == WebKit::WebPopupTypeNone; 403 bool activatable = popup_type_ == WebKit::WebPopupTypeNone;
335 [cocoa_view_ setCloseOnDeactivate:YES]; 404 [cocoa_view_ setCloseOnDeactivate:YES];
336 [cocoa_view_ setCanBeKeyView:activatable ? YES : NO]; 405 [cocoa_view_ setCanBeKeyView:activatable ? YES : NO];
337 [parent_host_view->GetNativeView() addSubview:cocoa_view_];
338 406
339 NSPoint origin_global = NSPointFromCGPoint(pos.origin().ToCGPoint()); 407 NSPoint origin_global = NSPointFromCGPoint(pos.origin().ToCGPoint());
340 if ([[NSScreen screens] count] > 0) { 408 if ([[NSScreen screens] count] > 0) {
341 origin_global.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height - 409 origin_global.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height -
342 pos.height() - origin_global.y; 410 pos.height() - origin_global.y;
343 } 411 }
344 NSPoint origin_window = 412
345 [[cocoa_view_ window] convertScreenToBase:origin_global]; 413 popup_window_.reset([[RenderWidgetPopupWindow alloc]
346 NSPoint origin_view = 414 initWithContentRect:NSMakeRect(origin_global.x, origin_global.y,
347 [cocoa_view_ convertPoint:origin_window fromView:nil]; 415 pos.width(), pos.height())
348 NSRect initial_frame = NSMakeRect(origin_view.x, 416 styleMask:NSBorderlessWindowMask
349 origin_view.y, 417 backing:NSBackingStoreBuffered
350 pos.width(), 418 defer:NO]);
351 pos.height()); 419 [popup_window_ setLevel:NSPopUpMenuWindowLevel];
352 [cocoa_view_ setFrame:initial_frame]; 420 [popup_window_ setReleasedWhenClosed:NO];
421 [popup_window_ makeKeyAndOrderFront:nil];
422 [[popup_window_ contentView] addSubview:cocoa_view_];
423 [cocoa_view_ setFrame:[[popup_window_ contentView] bounds]];
424 [cocoa_view_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
425 [[NSNotificationCenter defaultCenter]
426 addObserver:cocoa_view_
427 selector:@selector(popupWindowWillClose:)
428 name:NSWindowWillCloseNotification
429 object:popup_window_];
353 } 430 }
354 431
355 // This function creates the fullscreen window and hides the dock and menubar if 432 // 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 433 // necessary. Note, this codepath is only used for pepper flash when
357 // pp::FlashFullScreen::SetFullscreen() is called. If 434 // pp::FlashFullScreen::SetFullscreen() is called. If
358 // pp::FullScreen::SetFullscreen() is called then the entire browser window 435 // pp::FullScreen::SetFullscreen() is called then the entire browser window
359 // will enter fullscreen instead. 436 // will enter fullscreen instead.
360 void RenderWidgetHostViewMac::InitAsFullscreen( 437 void RenderWidgetHostViewMac::InitAsFullscreen(
361 RenderWidgetHostView* reference_host_view) { 438 RenderWidgetHostView* reference_host_view) {
362 fullscreen_parent_host_view_ = 439 fullscreen_parent_host_view_ =
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 if (rect.size().IsEmpty()) 528 if (rect.size().IsEmpty())
452 return; 529 return;
453 530
454 // Ignore the position of |rect| for non-popup rwhvs. This is because 531 // 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 532 // background tabs do not have a window, but the window is required for the
456 // coordinate conversions. Popups are always for a visible tab. 533 // coordinate conversions. Popups are always for a visible tab.
457 if (IsPopup()) { 534 if (IsPopup()) {
458 // The position of |rect| is screen coordinate system and we have to 535 // The position of |rect| is screen coordinate system and we have to
459 // consider Cocoa coordinate system is upside-down and also multi-screen. 536 // consider Cocoa coordinate system is upside-down and also multi-screen.
460 NSPoint origin_global = NSPointFromCGPoint(rect.origin().ToCGPoint()); 537 NSPoint origin_global = NSPointFromCGPoint(rect.origin().ToCGPoint());
538 NSSize size = NSMakeSize(rect.width(), rect.height());
539 size = [cocoa_view_ convertSize:size toView:nil];
461 if ([[NSScreen screens] count] > 0) { 540 if ([[NSScreen screens] count] > 0) {
462 NSSize size = NSMakeSize(rect.width(), rect.height());
463 size = [cocoa_view_ convertSize:size toView:nil];
464 NSScreen* screen = 541 NSScreen* screen =
465 static_cast<NSScreen*>([[NSScreen screens] objectAtIndex:0]); 542 static_cast<NSScreen*>([[NSScreen screens] objectAtIndex:0]);
466 origin_global.y = 543 origin_global.y =
467 NSHeight([screen frame]) - size.height - origin_global.y; 544 NSHeight([screen frame]) - size.height - origin_global.y;
468 } 545 }
469 546 [popup_window_ setFrame:NSMakeRect(origin_global.x, origin_global.y,
470 // Then |origin_global| is converted to client coordinate system. 547 size.width, size.height)
471 DCHECK([cocoa_view_ window]); 548 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 { 549 } else {
480 DCHECK([[cocoa_view_ superview] isKindOfClass:[BaseView class]]); 550 DCHECK([[cocoa_view_ superview] isKindOfClass:[BaseView class]]);
481 BaseView* superview = static_cast<BaseView*>([cocoa_view_ superview]); 551 BaseView* superview = static_cast<BaseView*>([cocoa_view_ superview]);
482 gfx::Rect rect2 = [superview flipNSRectToRect:[cocoa_view_ frame]]; 552 gfx::Rect rect2 = [superview flipNSRectToRect:[cocoa_view_ frame]];
483 rect2.set_width(rect.width()); 553 rect2.set_width(rect.width());
484 rect2.set_height(rect.height()); 554 rect2.set_height(rect.height());
485 [cocoa_view_ setFrame:[superview flipRectToNSRect:rect2]]; 555 [cocoa_view_ setFrame:[superview flipRectToNSRect:rect2]];
486 } 556 }
487 } 557 }
488 558
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 } 768 }
699 769
700 void RenderWidgetHostViewMac::RenderViewGone(base::TerminationStatus status, 770 void RenderWidgetHostViewMac::RenderViewGone(base::TerminationStatus status,
701 int error_code) { 771 int error_code) {
702 Destroy(); 772 Destroy();
703 } 773 }
704 774
705 void RenderWidgetHostViewMac::Destroy() { 775 void RenderWidgetHostViewMac::Destroy() {
706 AckPendingSwapBuffers(); 776 AckPendingSwapBuffers();
707 777
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]) { 778 for (NSView* subview in [cocoa_view_ subviews]) {
719 if ([subview isKindOfClass:[RenderWidgetHostViewCocoa class]]) { 779 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) 780 [static_cast<AcceleratedPluginView*>(subview)
724 onRenderWidgetHostViewGone]; 781 onRenderWidgetHostViewGone];
725 } 782 }
726 } 783 }
727 784
785 [[NSNotificationCenter defaultCenter]
786 removeObserver:cocoa_view_
787 name:NSWindowWillCloseNotification
788 object:popup_window_];
789
728 // We've been told to destroy. 790 // We've been told to destroy.
729 [cocoa_view_ retain]; 791 [cocoa_view_ retain];
730 [cocoa_view_ removeFromSuperview]; 792 [cocoa_view_ removeFromSuperview];
731 [cocoa_view_ autorelease]; 793 [cocoa_view_ autorelease];
732 794
795 [popup_window_ close];
796 popup_window_.autorelease();
797
733 [fullscreen_window_manager_ exitFullscreenMode]; 798 [fullscreen_window_manager_ exitFullscreenMode];
734 fullscreen_window_manager_.reset(); 799 fullscreen_window_manager_.reset();
735 [pepper_fullscreen_window_ close]; 800 [pepper_fullscreen_window_ close];
736 801
737 // This can be called as part of processing the window's responder 802 // This can be called as part of processing the window's responder
738 // chain, for instance |-performKeyEquivalent:|. In that case the 803 // chain, for instance |-performKeyEquivalent:|. In that case the
739 // object needs to survive until the stack unwinds. 804 // object needs to survive until the stack unwinds.
740 pepper_fullscreen_window_.autorelease(); 805 pepper_fullscreen_window_.autorelease();
741 806
742 // We get this call just before |render_widget_host_| deletes 807 // We get this call just before |render_widget_host_| deletes
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 widgetHost->ForwardKeyboardEvent(event); 2160 widgetHost->ForwardKeyboardEvent(event);
2096 } 2161 }
2097 } 2162 }
2098 2163
2099 // Possibly autohide the cursor. 2164 // Possibly autohide the cursor.
2100 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent]) 2165 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent])
2101 [NSCursor setHiddenUntilMouseMoves:YES]; 2166 [NSCursor setHiddenUntilMouseMoves:YES];
2102 } 2167 }
2103 2168
2104 - (void)scrollWheel:(NSEvent*)theEvent { 2169 - (void)scrollWheel:(NSEvent*)theEvent {
2105 // Cancel popups before calling the delegate because even if the delegate eats
2106 // the event, it's still an explicit user action outside the popup.
2107 [self cancelChildPopups];
2108
2109 if (delegate_ && [delegate_ respondsToSelector:@selector(handleEvent:)]) { 2170 if (delegate_ && [delegate_ respondsToSelector:@selector(handleEvent:)]) {
2110 BOOL handled = [delegate_ handleEvent:theEvent]; 2171 BOOL handled = [delegate_ handleEvent:theEvent];
2111 if (handled) 2172 if (handled)
2112 return; 2173 return;
2113 } 2174 }
2114 2175
2115 const WebMouseWheelEvent& event = 2176 const WebMouseWheelEvent& event =
2116 WebInputEventFactory::mouseWheelEvent(theEvent, self); 2177 WebInputEventFactory::mouseWheelEvent(theEvent, self);
2117 if (renderWidgetHostView_->render_widget_host_) 2178 if (renderWidgetHostView_->render_widget_host_)
2118 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(event); 2179 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(event);
2119 } 2180 }
2120 2181
2121 // See the comment in RenderWidgetHostViewMac::Destroy() about cancellation
2122 // events. On the Mac we must kill popups on outside events, thus this lovely
2123 // case of filicide caused by events on parent views.
2124 - (void)cancelChildPopups {
2125 // If this view can be the key view, it is not a popup. Therefore, if it has
2126 // any children, they are popups that need to be canceled.
2127 if (canBeKeyView_) {
2128 for (NSView* subview in [self subviews]) {
2129 if (![subview isKindOfClass:[RenderWidgetHostViewCocoa class]])
2130 continue; // Skip plugin views.
2131
2132 [static_cast<RenderWidgetHostViewCocoa*>(subview)
2133 renderWidgetHostViewMac]->KillSelf();
2134 }
2135 }
2136 }
2137
2138 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { 2182 - (void)viewWillMoveToWindow:(NSWindow*)newWindow {
2139 // We're messing with the window, so do this to ensure no flashes. This one 2183 // We're messing with the window, so do this to ensure no flashes. This one
2140 // prevents a flash when the current tab is closed. 2184 // prevents a flash when the current tab is closed.
2141 NSWindow* oldWindow = [self window]; 2185 NSWindow* oldWindow = [self window];
2142 [oldWindow disableScreenUpdatesUntilFlush]; 2186 [oldWindow disableScreenUpdatesUntilFlush];
2143 2187
2144 NSNotificationCenter* notificationCenter = 2188 NSNotificationCenter* notificationCenter =
2145 [NSNotificationCenter defaultCenter]; 2189 [NSNotificationCenter defaultCenter];
2146 if (oldWindow) { 2190 if (oldWindow) {
2147 [notificationCenter 2191 [notificationCenter
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3346 } 3390 }
3347 3391
3348 - (void)updateCursor:(NSCursor*)cursor { 3392 - (void)updateCursor:(NSCursor*)cursor {
3349 if (currentCursor_ == cursor) 3393 if (currentCursor_ == cursor)
3350 return; 3394 return;
3351 3395
3352 currentCursor_.reset(cursor, base::scoped_policy::RETAIN); 3396 currentCursor_.reset(cursor, base::scoped_policy::RETAIN);
3353 [[self window] invalidateCursorRectsForView:self]; 3397 [[self window] invalidateCursorRectsForView:self];
3354 } 3398 }
3355 3399
3400 - (void)popupWindowWillClose:(NSNotification *)notification {
3401 renderWidgetHostView_->KillSelf();
3402 }
3403
3356 @end 3404 @end
3357 3405
3358 // 3406 //
3359 // Supporting application services 3407 // Supporting application services
3360 // 3408 //
3361 @implementation RenderWidgetHostViewCocoa(NSServicesRequests) 3409 @implementation RenderWidgetHostViewCocoa(NSServicesRequests)
3362 3410
3363 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard 3411 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard
3364 types:(NSArray*)types { 3412 types:(NSArray*)types {
3365 const std::string& str = renderWidgetHostView_->selected_text(); 3413 const std::string& str = renderWidgetHostView_->selected_text();
(...skipping 11 matching lines...) Expand all
3377 if (!string) return NO; 3425 if (!string) return NO;
3378 3426
3379 // If the user is currently using an IME, confirm the IME input, 3427 // If the user is currently using an IME, confirm the IME input,
3380 // and then insert the text from the service, the same as TextEdit and Safari. 3428 // and then insert the text from the service, the same as TextEdit and Safari.
3381 [self confirmComposition]; 3429 [self confirmComposition];
3382 [self insertText:string]; 3430 [self insertText:string];
3383 return YES; 3431 return YES;
3384 } 3432 }
3385 3433
3386 @end 3434 @end
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | ui/base/cocoa/event_hook_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698