| 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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 582   // popup. A click outside the text field would cause the text field to drop | 582   // popup. A click outside the text field would cause the text field to drop | 
| 583   // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel | 583   // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel | 
| 584   // the popup anyway, so we're OK. | 584   // the popup anyway, so we're OK. | 
| 585 | 585 | 
| 586   const WebMouseEvent& event = | 586   const WebMouseEvent& event = | 
| 587       WebInputEventFactory::mouseEvent(theEvent, self); | 587       WebInputEventFactory::mouseEvent(theEvent, self); | 
| 588   if (renderWidgetHostView_->render_widget_host_) | 588   if (renderWidgetHostView_->render_widget_host_) | 
| 589     renderWidgetHostView_->render_widget_host_->ForwardMouseEvent(event); | 589     renderWidgetHostView_->render_widget_host_->ForwardMouseEvent(event); | 
| 590 } | 590 } | 
| 591 | 591 | 
| 592 - (void)setIgnoreKeyEvents:(BOOL)ignorekeyEvents { |  | 
| 593   ignoreKeyEvents_ = ignorekeyEvents; |  | 
| 594 } |  | 
| 595 |  | 
| 596 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 592 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 
| 597   if (ignoreKeyEvents_) |  | 
| 598     return NO; |  | 
| 599 |  | 
| 600   // |performKeyEquivalent:| is sent to all views of a window, not only down the | 593   // |performKeyEquivalent:| is sent to all views of a window, not only down the | 
| 601   // responder chain (cf. "Handling Key Equivalents" in | 594   // responder chain (cf. "Handling Key Equivalents" in | 
| 602   // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event
      Overview/HandlingKeyEvents/HandlingKeyEvents.html | 595   // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event
      Overview/HandlingKeyEvents/HandlingKeyEvents.html | 
| 603   // ). We only want to handle key equivalents if we're first responder. | 596   // ). We only want to handle key equivalents if we're first responder. | 
| 604   if ([[self window] firstResponder] != self) | 597   if ([[self window] firstResponder] != self) | 
| 605     return NO; | 598     return NO; | 
| 606 | 599 | 
| 607   // If we return |NO| from this function, cocoa will send the key event to | 600   // If we return |NO| from this function, cocoa will send the key event to | 
| 608   // the menu and only if the menu does not process the event to |keyDown:|. We | 601   // the menu and only if the menu does not process the event to |keyDown:|. We | 
| 609   // want to send the event to a renderer _before_ sending it to the menu, so | 602   // want to send the event to a renderer _before_ sending it to the menu, so | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 635   // equivalent that Cocoa uses for toggling the input langauge. In this case, | 628   // equivalent that Cocoa uses for toggling the input langauge. In this case, | 
| 636   // that's actually a good thing, though -- see http://crbug.com/26115 .) | 629   // that's actually a good thing, though -- see http://crbug.com/26115 .) | 
| 637   return YES; | 630   return YES; | 
| 638 } | 631 } | 
| 639 | 632 | 
| 640 - (void)keyEvent:(NSEvent*)theEvent { | 633 - (void)keyEvent:(NSEvent*)theEvent { | 
| 641   [self keyEvent:theEvent wasKeyEquivalent:NO]; | 634   [self keyEvent:theEvent wasKeyEquivalent:NO]; | 
| 642 } | 635 } | 
| 643 | 636 | 
| 644 - (void)keyEvent:(NSEvent *)theEvent wasKeyEquivalent:(BOOL)equiv { | 637 - (void)keyEvent:(NSEvent *)theEvent wasKeyEquivalent:(BOOL)equiv { | 
| 645   if (ignoreKeyEvents_) |  | 
| 646     return; |  | 
| 647 |  | 
| 648   DCHECK([theEvent type] != NSKeyDown || | 638   DCHECK([theEvent type] != NSKeyDown || | 
| 649          !equiv == !([theEvent modifierFlags] & NSCommandKeyMask)); | 639          !equiv == !([theEvent modifierFlags] & NSCommandKeyMask)); | 
| 650 | 640 | 
| 651   scoped_nsobject<RenderWidgetHostViewCocoa> keepSelfAlive([self retain]); | 641   scoped_nsobject<RenderWidgetHostViewCocoa> keepSelfAlive([self retain]); | 
| 652 | 642 | 
| 653   // Don't cancel child popups; the key events are probably what's triggering | 643   // Don't cancel child popups; the key events are probably what's triggering | 
| 654   // the popup in the first place. | 644   // the popup in the first place. | 
| 655 | 645 | 
| 656   NativeWebKeyboardEvent event(theEvent); | 646   NativeWebKeyboardEvent event(theEvent); | 
| 657 | 647 | 
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1387     event.skip_in_browser = true; | 1377     event.skip_in_browser = true; | 
| 1388     renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); | 1378     renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); | 
| 1389   } else { | 1379   } else { | 
| 1390     renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( | 1380     renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( | 
| 1391         UTF8ToUTF16([im_text UTF8String])); | 1381         UTF8ToUTF16([im_text UTF8String])); | 
| 1392   } | 1382   } | 
| 1393   renderWidgetHostView_->im_composing_ = false; | 1383   renderWidgetHostView_->im_composing_ = false; | 
| 1394 } | 1384 } | 
| 1395 | 1385 | 
| 1396 @end | 1386 @end | 
| OLD | NEW | 
|---|