diff --git a/widget/src/cocoa/ComplexTextInputPanel.h b/widget/src/cocoa/ComplexTextInputPanel.h index 80a247cc4fa..4f861c48a23 100644 --- a/widget/src/cocoa/ComplexTextInputPanel.h +++ b/widget/src/cocoa/ComplexTextInputPanel.h @@ -38,6 +38,7 @@ - (NSTextInputContext*)inputContext; - (BOOL)interpretKeyEvent:(NSEvent*)event string:(NSString**)string; +- (void)cancelComposition; @end diff --git a/widget/src/cocoa/ComplexTextInputPanel.mm b/widget/src/cocoa/ComplexTextInputPanel.mm index af6ba3e4f68..05965632f5e 100644 --- a/widget/src/cocoa/ComplexTextInputPanel.mm +++ b/widget/src/cocoa/ComplexTextInputPanel.mm @@ -83,8 +83,7 @@ - (void)keyboardInputSourceChanged:(NSNotification *)notification { - [mInputTextView setString:@""]; - [self orderOut:nil]; + [self cancelComposition]; } - (BOOL)interpretKeyEvent:(NSEvent*)event string:(NSString**)string @@ -119,4 +118,10 @@ return [mInputTextView inputContext]; } +- (void)cancelComposition +{ + [mInputTextView setString:@""]; + [self orderOut:nil]; +} + @end diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index 57790ba1cff..e8974933cfb 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -5365,9 +5365,15 @@ static const char* ToEscapedString(NSString* aString, nsCAutoString& aBuf) mGeckoChild->DispatchWindowEvent(pluginEvent); if (!mGeckoChild) return; - + if (!mPluginComplexTextInputRequested) { - // Ideally we'd cancel any TSM composition here. +#ifdef NP_NO_CARBON + [[ComplexTextInputPanel sharedComplexTextInputPanel] cancelComposition]; +#else + if (mPluginTSMDoc) { + ::FixTSMDocument(mPluginTSMDoc); + } +#endif return; }