| 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 // popup. A click outside the text field would cause the text field to drop | 529 // popup. A click outside the text field would cause the text field to drop |
| 530 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel | 530 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel |
| 531 // the popup anyway, so we're OK. | 531 // the popup anyway, so we're OK. |
| 532 | 532 |
| 533 const WebMouseEvent& event = | 533 const WebMouseEvent& event = |
| 534 WebInputEventFactory::mouseEvent(theEvent, self); | 534 WebInputEventFactory::mouseEvent(theEvent, self); |
| 535 if (renderWidgetHostView_->render_widget_host_) | 535 if (renderWidgetHostView_->render_widget_host_) |
| 536 renderWidgetHostView_->render_widget_host_->ForwardMouseEvent(event); | 536 renderWidgetHostView_->render_widget_host_->ForwardMouseEvent(event); |
| 537 } | 537 } |
| 538 | 538 |
| 539 - (void)setIgnoreKeyEvents:(BOOL)ignorekeyEvents { |
| 540 ignoreKeyEvents_ = ignorekeyEvents; |
| 541 } |
| 542 |
| 539 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 543 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { |
| 544 if (ignoreKeyEvents_) |
| 545 return NO; |
| 546 |
| 540 // We have some magic in |CrApplication sendEvent:| that always sends key | 547 // We have some magic in |CrApplication sendEvent:| that always sends key |
| 541 // 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. |
| 542 DCHECK([[self window] firstResponder] != self); | 549 DCHECK([[self window] firstResponder] != self); |
| 543 return NO; | 550 return NO; |
| 544 } | 551 } |
| 545 | 552 |
| 546 - (void)keyEvent:(NSEvent*)theEvent { | 553 - (void)keyEvent:(NSEvent*)theEvent { |
| 554 if (ignoreKeyEvents_) |
| 555 return; |
| 556 |
| 547 // TODO(avi): Possibly kill self? See RenderWidgetHostViewWin::OnKeyEvent and | 557 // TODO(avi): Possibly kill self? See RenderWidgetHostViewWin::OnKeyEvent and |
| 548 // http://b/issue?id=1192881 . | 558 // http://b/issue?id=1192881 . |
| 549 | 559 |
| 550 // Don't cancel child popups; the key events are probably what's triggering | 560 // Don't cancel child popups; the key events are probably what's triggering |
| 551 // the popup in the first place. | 561 // the popup in the first place. |
| 552 | 562 |
| 553 NativeWebKeyboardEvent event(theEvent); | 563 NativeWebKeyboardEvent event(theEvent); |
| 554 | 564 |
| 555 // Save the modifier keys so the insertText method can use it when it sends | 565 // Save the modifier keys so the insertText method can use it when it sends |
| 556 // a Char event, which is dispatched as an onkeypress() event of JavaScript. | 566 // a Char event, which is dispatched as an onkeypress() event of JavaScript. |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); | 1249 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); |
| 1240 } else { | 1250 } else { |
| 1241 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( | 1251 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( |
| 1242 UTF8ToUTF16([im_text UTF8String])); | 1252 UTF8ToUTF16([im_text UTF8String])); |
| 1243 } | 1253 } |
| 1244 renderWidgetHostView_->im_composing_ = false; | 1254 renderWidgetHostView_->im_composing_ = false; |
| 1245 } | 1255 } |
| 1246 | 1256 |
| 1247 @end | 1257 @end |
| 1248 | 1258 |
| OLD | NEW |