| 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 #import "base/chrome_application_mac.h" | 7 #import "base/chrome_application_mac.h" |
| 8 #include "base/histogram.h" | 8 #include "base/histogram.h" |
| 9 #import "base/scoped_nsobject.h" | 9 #import "base/scoped_nsobject.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 438 |
| 439 int window_num = [[parent_view_ window] windowNumber]; | 439 int window_num = [[parent_view_ window] windowNumber]; |
| 440 NSEvent* event = | 440 NSEvent* event = |
| 441 webkit_glue::EventWithMenuAction([menu_runner menuItemWasChosen], | 441 webkit_glue::EventWithMenuAction([menu_runner menuItemWasChosen], |
| 442 window_num, item_height, | 442 window_num, item_height, |
| 443 [menu_runner indexOfSelectedItem], | 443 [menu_runner indexOfSelectedItem], |
| 444 position, view_rect); | 444 position, view_rect); |
| 445 | 445 |
| 446 if ([menu_runner menuItemWasChosen]) { | 446 if ([menu_runner menuItemWasChosen]) { |
| 447 // Simulate a menu selection event. | 447 // Simulate a menu selection event. |
| 448 CHECK(cocoa_view_); | |
| 449 const WebMouseEvent& mouse_event = | 448 const WebMouseEvent& mouse_event = |
| 450 WebInputEventFactory::mouseEvent(event, cocoa_view_); | 449 WebInputEventFactory::mouseEvent(event, cocoa_view_); |
| 451 render_widget_host_->ForwardMouseEvent(mouse_event); | 450 render_widget_host_->ForwardMouseEvent(mouse_event); |
| 452 } else { | 451 } else { |
| 453 // Simulate a menu dismiss event. | 452 // Simulate a menu dismiss event. |
| 454 NativeWebKeyboardEvent keyboard_event(event); | 453 NativeWebKeyboardEvent keyboard_event(event); |
| 455 render_widget_host_->ForwardKeyboardEvent(keyboard_event); | 454 render_widget_host_->ForwardKeyboardEvent(keyboard_event); |
| 456 } | 455 } |
| 457 } | 456 } |
| 458 | 457 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 editCommand_helper_.reset(new RWHVMEditCommandHelper); | 594 editCommand_helper_.reset(new RWHVMEditCommandHelper); |
| 596 editCommand_helper_->AddEditingSelectorsToClass([self class]); | 595 editCommand_helper_->AddEditingSelectorsToClass([self class]); |
| 597 | 596 |
| 598 renderWidgetHostView_.reset(r); | 597 renderWidgetHostView_.reset(r); |
| 599 canBeKeyView_ = YES; | 598 canBeKeyView_ = YES; |
| 600 closeOnDeactivate_ = NO; | 599 closeOnDeactivate_ = NO; |
| 601 } | 600 } |
| 602 return self; | 601 return self; |
| 603 } | 602 } |
| 604 | 603 |
| 605 // Used only to diagnose the crash in http://crbug.com/31716 | |
| 606 // TODO(pamg): Remove when no longer needed. | |
| 607 - (void)dealloc { | |
| 608 renderWidgetHostView_->clear_cocoa_view(); | |
| 609 [super dealloc]; | |
| 610 } | |
| 611 | |
| 612 - (void)setCanBeKeyView:(BOOL)can { | 604 - (void)setCanBeKeyView:(BOOL)can { |
| 613 canBeKeyView_ = can; | 605 canBeKeyView_ = can; |
| 614 } | 606 } |
| 615 | 607 |
| 616 - (void)setCloseOnDeactivate:(BOOL)b { | 608 - (void)setCloseOnDeactivate:(BOOL)b { |
| 617 closeOnDeactivate_ = b; | 609 closeOnDeactivate_ = b; |
| 618 } | 610 } |
| 619 | 611 |
| 620 - (void)mouseEvent:(NSEvent*)theEvent { | 612 - (void)mouseEvent:(NSEvent*)theEvent { |
| 621 // Don't cancel child popups; killing them on a mouse click would prevent the | 613 // 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... |
| 1418 event.skip_in_browser = true; | 1410 event.skip_in_browser = true; |
| 1419 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); | 1411 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); |
| 1420 } else { | 1412 } else { |
| 1421 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( | 1413 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( |
| 1422 UTF8ToUTF16([im_text UTF8String])); | 1414 UTF8ToUTF16([im_text UTF8String])); |
| 1423 } | 1415 } |
| 1424 renderWidgetHostView_->im_composing_ = false; | 1416 renderWidgetHostView_->im_composing_ = false; |
| 1425 } | 1417 } |
| 1426 | 1418 |
| 1427 @end | 1419 @end |
| OLD | NEW |