OLD | NEW |
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 #include "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" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | |
297 // We get this call just before |render_widget_host_| deletes | 292 // We get this call just before |render_widget_host_| deletes |
298 // itself. But we are owned by |cocoa_view_|, which may be retained | 293 // itself. But we are owned by |cocoa_view_|, which may be retained |
299 // by some other code. Examples are TabContentsViewMac's | 294 // by some other code. Examples are TabContentsViewMac's |
300 // |latent_focus_view_| and TabWindowController's | 295 // |latent_focus_view_| and TabWindowController's |
301 // |cachedContentView_|. | 296 // |cachedContentView_|. |
302 render_widget_host_ = NULL; | 297 render_widget_host_ = NULL; |
303 } | 298 } |
304 | 299 |
305 // Called from the renderer to tell us what the tooltip text should be. It | 300 // Called from the renderer to tell us what the tooltip text should be. It |
306 // calls us frequently so we need to cache the value to prevent doing a lot | 301 // calls us frequently so we need to cache the value to prevent doing a lot |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 } | 532 } |
538 | 533 |
539 - (void)setIgnoreKeyEvents:(BOOL)ignorekeyEvents { | 534 - (void)setIgnoreKeyEvents:(BOOL)ignorekeyEvents { |
540 ignoreKeyEvents_ = ignorekeyEvents; | 535 ignoreKeyEvents_ = ignorekeyEvents; |
541 } | 536 } |
542 | 537 |
543 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 538 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { |
544 if (ignoreKeyEvents_) | 539 if (ignoreKeyEvents_) |
545 return NO; | 540 return NO; |
546 | 541 |
547 // We have some magic in |CrApplication sendEvent:| that always sends key | 542 // We have some magic in |CrApplication sendEvent:| that always sends key |
548 // events to |keyEvent:| so that cocoa doesn't have a chance to intercept it. | 543 // events to |keyEvent:| so that cocoa doesn't have a chance to intercept it. |
549 DCHECK([[self window] firstResponder] != self); | 544 DCHECK([[self window] firstResponder] != self); |
550 return NO; | 545 return NO; |
551 } | 546 } |
552 | 547 |
553 - (void)keyEvent:(NSEvent*)theEvent { | 548 - (void)keyEvent:(NSEvent*)theEvent { |
554 if (ignoreKeyEvents_) | 549 if (ignoreKeyEvents_) |
555 return; | 550 return; |
556 | 551 |
557 // TODO(avi): Possibly kill self? See RenderWidgetHostViewWin::OnKeyEvent and | 552 // TODO(avi): Possibly kill self? See RenderWidgetHostViewWin::OnKeyEvent and |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); | 1244 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); |
1250 } else { | 1245 } else { |
1251 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( | 1246 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( |
1252 UTF8ToUTF16([im_text UTF8String])); | 1247 UTF8ToUTF16([im_text UTF8String])); |
1253 } | 1248 } |
1254 renderWidgetHostView_->im_composing_ = false; | 1249 renderWidgetHostView_->im_composing_ = false; |
1255 } | 1250 } |
1256 | 1251 |
1257 @end | 1252 @end |
1258 | 1253 |
OLD | NEW |