Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Unified Diff: chrome/browser/renderer_host/render_widget_host_view_mac.mm

Issue 383004: A quick fix for Issue 26880.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/render_widget_host_view_mac.mm
===================================================================
--- chrome/browser/renderer_host/render_widget_host_view_mac.mm (revision 31543)
+++ chrome/browser/renderer_host/render_widget_host_view_mac.mm (working copy)
@@ -4,6 +4,10 @@
#include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
+#import <Carbon/Carbon.h>
+#include <ApplicationServices/ApplicationServices.h>
+#include <AvailabilityMacros.h>
+
#include "base/histogram.h"
#import "base/scoped_nsobject.h"
#include "base/string_util.h"
@@ -232,7 +236,14 @@
void RenderWidgetHostViewMac::IMEUpdateStatus(int control,
const gfx::Rect& caret_rect) {
// The renderer updates its IME status.
- // We need to control the input method according to the given message.
+#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5
+ // Complete the ongoing composition when a renderer finishes it.
+ // We need to use Carbon APIs to finish an ongoing composition since Leopard
+ // doesn't implement a Cocoa API -[NSTextInputContext discardMarkedText:]
+ // that discards the marked text.
+ if (control == IME_DISABLE || control == IME_COMPLETE_COMPOSITION)
+ ::FixTSMDocument(::TSMGetActiveDocument());
+#endif
// We need to convert the coordinate of the cursor rectangle sent from the
// renderer and save it. Our IME backend uses a coordinate system whose
@@ -573,26 +584,26 @@
// http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/EventOverview/HandlingKeyEvents/HandlingKeyEvents.html
// ). We only want to handle key equivalents if we're first responder.
if ([[self window] firstResponder] != self)
- return NO;
+ return NO;
- // If we return |NO| from this function, cocoa will send the key event to
- // the menu and only if the menu does not process the event to |keyDown:|. We
- // want to send the event to a renderer _before_ sending it to the menu, so
- // we need to return |YES| for all events that might be swallowed by the menu.
- // We do not return |YES| for every keypress because we don't get |keyDown:|
- // events for keys that we handle this way.
- NSUInteger modifierFlags = [theEvent modifierFlags];
- if ((modifierFlags & NSCommandKeyMask) == 0) {
- // Make sure the menu does not contain key equivalents that don't
- // contain cmd.
- DCHECK(![[NSApp mainMenu] performKeyEquivalent:theEvent]);
- return NO;
+ // If we return |NO| from this function, cocoa will send the key event to
+ // the menu and only if the menu does not process the event to |keyDown:|. We
+ // want to send the event to a renderer _before_ sending it to the menu, so
+ // we need to return |YES| for all events that might be swallowed by the menu.
+ // We do not return |YES| for every keypress because we don't get |keyDown:|
+ // events for keys that we handle this way.
+ NSUInteger modifierFlags = [theEvent modifierFlags];
+ if ((modifierFlags & NSCommandKeyMask) == 0) {
+ // Make sure the menu does not contain key equivalents that don't
+ // contain cmd.
+ DCHECK(![[NSApp mainMenu] performKeyEquivalent:theEvent]);
+ return NO;
}
- // Command key combinations are sent via performKeyEquivalent rather than
- // keyDown:. We just forward this on and if WebCore doesn't want to handle
- // it, we let the TabContentsView figure out how to reinject it.
- [self keyEvent:theEvent wasKeyEquivalent:YES];
+ // Command key combinations are sent via performKeyEquivalent rather than
+ // keyDown:. We just forward this on and if WebCore doesn't want to handle
+ // it, we let the TabContentsView figure out how to reinject it.
+ [self keyEvent:theEvent wasKeyEquivalent:YES];
return YES;
}
@@ -609,14 +620,14 @@
}
- (void)keyEvent:(NSEvent*)theEvent {
- [self keyEvent:theEvent wasKeyEquivalent:NO];
-}
+ [self keyEvent:theEvent wasKeyEquivalent:NO];
+}
-- (void)keyEvent:(NSEvent *)theEvent wasKeyEquivalent:(BOOL)equiv {
+- (void)keyEvent:(NSEvent *)theEvent wasKeyEquivalent:(BOOL)equiv {
if (ignoreKeyEvents_)
return;
- DCHECK([theEvent type] != NSKeyDown ||
+ DCHECK([theEvent type] != NSKeyDown ||
!equiv == !([theEvent modifierFlags] & NSCommandKeyMask));
scoped_nsobject<RenderWidgetHostViewCocoa> keepSelfAlive([self retain]);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698