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

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

Issue 339095: DeferredAutoreleasePool didn't work on Snow Leopard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.mm ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #include "base/histogram.h" 7 #include "base/histogram.h"
8 #include "base/scoped_nsobject.h" 8 #import "base/scoped_nsobject.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
11 #include "chrome/browser/browser_trial.h" 11 #include "chrome/browser/browser_trial.h"
12 #import "chrome/browser/cocoa/rwhvm_editcommand_helper.h" 12 #import "chrome/browser/cocoa/rwhvm_editcommand_helper.h"
13 #include "chrome/browser/renderer_host/backing_store.h" 13 #include "chrome/browser/renderer_host/backing_store.h"
14 #include "chrome/browser/renderer_host/render_process_host.h" 14 #include "chrome/browser/renderer_host/render_process_host.h"
15 #include "chrome/browser/renderer_host/render_widget_host.h" 15 #include "chrome/browser/renderer_host/render_widget_host.h"
16 #include "chrome/browser/spellchecker_platform_engine.h" 16 #include "chrome/browser/spellchecker_platform_engine.h"
17 #include "chrome/common/native_web_keyboard_event.h" 17 #include "chrome/common/native_web_keyboard_event.h"
18 #include "chrome/common/edit_command.h" 18 #include "chrome/common/edit_command.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 // then the event causing the destroy had also cancelled any popups by the 282 // then the event causing the destroy had also cancelled any popups by the
283 // time Destroy() was called. On the Mac we have to destroy all the popups 283 // time Destroy() was called. On the Mac we have to destroy all the popups
284 // ourselves. 284 // ourselves.
285 285
286 // Depth-first destroy all popups. Use ShutdownHost() to enforce deepest-first 286 // Depth-first destroy all popups. Use ShutdownHost() to enforce deepest-first
287 // ordering. 287 // ordering.
288 for (RenderWidgetHostViewCocoa* subview in [cocoa_view_ subviews]) { 288 for (RenderWidgetHostViewCocoa* subview in [cocoa_view_ subviews]) {
289 [subview renderWidgetHostViewMac]->ShutdownHost(); 289 [subview renderWidgetHostViewMac]->ShutdownHost();
290 } 290 }
291 291
292 // We've been told to destroy.
293 [cocoa_view_ retain];
294 [cocoa_view_ removeFromSuperview];
295 [cocoa_view_ autorelease];
296
292 // We get this call just before |render_widget_host_| deletes 297 // We get this call just before |render_widget_host_| deletes
293 // itself. But we are owned by |cocoa_view_|, which may be retained 298 // itself. But we are owned by |cocoa_view_|, which may be retained
294 // by some other code. Examples are TabContentsViewMac's 299 // by some other code. Examples are TabContentsViewMac's
295 // |latent_focus_view_| and TabWindowController's 300 // |latent_focus_view_| and TabWindowController's
296 // |cachedContentView_|. 301 // |cachedContentView_|.
297 render_widget_host_ = NULL; 302 render_widget_host_ = NULL;
298 } 303 }
299 304
300 // Called from the renderer to tell us what the tooltip text should be. It 305 // Called from the renderer to tell us what the tooltip text should be. It
301 // calls us frequently so we need to cache the value to prevent doing a lot 306 // calls us frequently so we need to cache the value to prevent doing a lot
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 // We have some magic in |CrApplication sendEvent:| that always sends key 547 // We have some magic in |CrApplication sendEvent:| that always sends key
543 // events to |keyEvent:| so that cocoa doesn't have a chance to intercept it. 548 // events to |keyEvent:| so that cocoa doesn't have a chance to intercept it.
544 DCHECK([[self window] firstResponder] != self); 549 DCHECK([[self window] firstResponder] != self);
545 return NO; 550 return NO;
546 } 551 }
547 552
548 - (void)keyEvent:(NSEvent*)theEvent { 553 - (void)keyEvent:(NSEvent*)theEvent {
549 if (ignoreKeyEvents_) 554 if (ignoreKeyEvents_)
550 return; 555 return;
551 556
552 // TODO(avi): Possibly kill self? See RenderWidgetHostViewWin::OnKeyEvent and 557 scoped_nsobject<RenderWidgetHostViewCocoa> keepSelfAlive([self retain]);
553 // http://b/issue?id=1192881 .
554 558
555 // Don't cancel child popups; the key events are probably what's triggering 559 // Don't cancel child popups; the key events are probably what's triggering
556 // the popup in the first place. 560 // the popup in the first place.
557 561
558 NativeWebKeyboardEvent event(theEvent); 562 NativeWebKeyboardEvent event(theEvent);
559 563
560 // Save the modifier keys so the insertText method can use it when it sends 564 // Save the modifier keys so the insertText method can use it when it sends
561 // a Char event, which is dispatched as an onkeypress() event of JavaScript. 565 // a Char event, which is dispatched as an onkeypress() event of JavaScript.
562 renderWidgetHostView_->im_modifiers_ = event.modifiers; 566 renderWidgetHostView_->im_modifiers_ = event.modifiers;
563 567
(...skipping 15 matching lines...) Expand all
579 [EditCommandMatcher matchEditCommands:&editCommands forEvent:theEvent]; 583 [EditCommandMatcher matchEditCommands:&editCommands forEvent:theEvent];
580 if (!editCommands.empty()) 584 if (!editCommands.empty())
581 widgetHost->ForwardEditCommandsForNextKeyEvent(editCommands); 585 widgetHost->ForwardEditCommandsForNextKeyEvent(editCommands);
582 widgetHost->ForwardKeyboardEvent(event); 586 widgetHost->ForwardKeyboardEvent(event);
583 } 587 }
584 588
585 // Dispatch a NSKeyDown event to an input method. 589 // Dispatch a NSKeyDown event to an input method.
586 // To send an onkeydown() event before an onkeypress() event, we should 590 // To send an onkeydown() event before an onkeypress() event, we should
587 // dispatch this NSKeyDown event AFTER sending it to the renderer. 591 // dispatch this NSKeyDown event AFTER sending it to the renderer.
588 // (See <https://bugs.webkit.org/show_bug.cgi?id=25119>). 592 // (See <https://bugs.webkit.org/show_bug.cgi?id=25119>).
589 if ([theEvent type] == NSKeyDown) 593 //
594 // If this object's retainCount is 1, the only reference is the one held by
595 // keepSelfAlive. All other references may have been destroyed in the
596 // RenderWidgetHost::ForwardKeyboardEvent call above if it resulted in tab
597 // closure. Were it not for that single reference, this object would
598 // already be deallocated. In that case, there's no point in calling
599 // -interpretKeyEvents:.
600 if ([self retainCount] > 1 && [theEvent type] == NSKeyDown)
590 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; 601 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
591 602
592 // Possibly autohide the cursor. 603 // Possibly autohide the cursor.
593 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent]) 604 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent])
594 [NSCursor setHiddenUntilMouseMoves:YES]; 605 [NSCursor setHiddenUntilMouseMoves:YES];
595 } 606 }
596 607
597 - (void)scrollWheel:(NSEvent *)theEvent { 608 - (void)scrollWheel:(NSEvent *)theEvent {
598 [self cancelChildPopups]; 609 [self cancelChildPopups];
599 610
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 base::Time::Now().ToDoubleT()); 1254 base::Time::Now().ToDoubleT());
1244 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); 1255 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event);
1245 } else { 1256 } else {
1246 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( 1257 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition(
1247 UTF8ToUTF16([im_text UTF8String])); 1258 UTF8ToUTF16([im_text UTF8String]));
1248 } 1259 }
1249 renderWidgetHostView_->im_composing_ = false; 1260 renderWidgetHostView_->im_composing_ = false;
1250 } 1261 }
1251 1262
1252 @end 1263 @end
1253
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698