| 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 #import "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" |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 initialIndex:selected_item]; | 412 initialIndex:selected_item]; |
| 413 } | 413 } |
| 414 | 414 |
| 415 int window_num = [[parent_view_ window] windowNumber]; | 415 int window_num = [[parent_view_ window] windowNumber]; |
| 416 NSEvent* event = | 416 NSEvent* event = |
| 417 webkit_glue::EventWithMenuAction([menu_runner menuItemWasChosen], | 417 webkit_glue::EventWithMenuAction([menu_runner menuItemWasChosen], |
| 418 window_num, item_height, | 418 window_num, item_height, |
| 419 [menu_runner indexOfSelectedItem], | 419 [menu_runner indexOfSelectedItem], |
| 420 position, view_rect); | 420 position, view_rect); |
| 421 | 421 |
| 422 // CHECK()s inserted to diagnose the crash in http://crbug.com/31716 |
| 423 // TODO(pamg): Remove when no longer needed. |
| 424 CHECK(render_widget_host_); |
| 422 if ([menu_runner menuItemWasChosen]) { | 425 if ([menu_runner menuItemWasChosen]) { |
| 423 // Simulate a menu selection event. | 426 // Simulate a menu selection event. |
| 427 CHECK(cocoa_view_); |
| 424 const WebMouseEvent& mouse_event = | 428 const WebMouseEvent& mouse_event = |
| 425 WebInputEventFactory::mouseEvent(event, cocoa_view_); | 429 WebInputEventFactory::mouseEvent(event, cocoa_view_); |
| 426 render_widget_host_->ForwardMouseEvent(mouse_event); | 430 render_widget_host_->ForwardMouseEvent(mouse_event); |
| 427 } else { | 431 } else { |
| 428 // Simulate a menu dismiss event. | 432 // Simulate a menu dismiss event. |
| 429 NativeWebKeyboardEvent keyboard_event(event); | 433 NativeWebKeyboardEvent keyboard_event(event); |
| 430 render_widget_host_->ForwardKeyboardEvent(keyboard_event); | 434 render_widget_host_->ForwardKeyboardEvent(keyboard_event); |
| 431 } | 435 } |
| 432 } | 436 } |
| 433 | 437 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 editCommand_helper_.reset(new RWHVMEditCommandHelper); | 574 editCommand_helper_.reset(new RWHVMEditCommandHelper); |
| 571 editCommand_helper_->AddEditingSelectorsToClass([self class]); | 575 editCommand_helper_->AddEditingSelectorsToClass([self class]); |
| 572 | 576 |
| 573 renderWidgetHostView_.reset(r); | 577 renderWidgetHostView_.reset(r); |
| 574 canBeKeyView_ = YES; | 578 canBeKeyView_ = YES; |
| 575 closeOnDeactivate_ = NO; | 579 closeOnDeactivate_ = NO; |
| 576 } | 580 } |
| 577 return self; | 581 return self; |
| 578 } | 582 } |
| 579 | 583 |
| 584 // Used only to diagnose the crash in http://crbug.com/31716 |
| 585 // TODO(pamg): Remove when no longer needed. |
| 586 - (void)dealloc { |
| 587 renderWidgetHostView_->clear_cocoa_view(); |
| 588 [super dealloc]; |
| 589 } |
| 590 |
| 580 - (void)setCanBeKeyView:(BOOL)can { | 591 - (void)setCanBeKeyView:(BOOL)can { |
| 581 canBeKeyView_ = can; | 592 canBeKeyView_ = can; |
| 582 } | 593 } |
| 583 | 594 |
| 584 - (void)setCloseOnDeactivate:(BOOL)b { | 595 - (void)setCloseOnDeactivate:(BOOL)b { |
| 585 closeOnDeactivate_ = b; | 596 closeOnDeactivate_ = b; |
| 586 } | 597 } |
| 587 | 598 |
| 588 - (void)mouseEvent:(NSEvent*)theEvent { | 599 - (void)mouseEvent:(NSEvent*)theEvent { |
| 589 // Don't cancel child popups; killing them on a mouse click would prevent the | 600 // Don't cancel child popups; killing them on a mouse click would prevent the |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 event.skip_in_browser = true; | 1397 event.skip_in_browser = true; |
| 1387 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); | 1398 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); |
| 1388 } else { | 1399 } else { |
| 1389 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( | 1400 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( |
| 1390 UTF8ToUTF16([im_text UTF8String])); | 1401 UTF8ToUTF16([im_text UTF8String])); |
| 1391 } | 1402 } |
| 1392 renderWidgetHostView_->im_composing_ = false; | 1403 renderWidgetHostView_->im_composing_ = false; |
| 1393 } | 1404 } |
| 1394 | 1405 |
| 1395 @end | 1406 @end |
| OLD | NEW |