From 36ce1aa162e2388643ea0f5e554613bfff95352b Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 11 May 2011 13:52:45 +0900 Subject: [PATCH] Bug 651307 Don't commit composition string on plugins at changing input source r=smichaud --- modules/libpref/src/init/all.js | 2 ++ widget/src/cocoa/ComplexTextInputPanel.mm | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 9be6c159208e..7bd6b64234a1 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -2288,6 +2288,8 @@ pref("print.print_extra_margin", 90); // twips (90 twips is an eigth of an inch) // See bug 404131, topmost element wins to Dashboard on MacOSX. pref("ui.panel.default_level_parent", false); +pref("ui.plugin.cancel_composition_at_input_source_changed", false); + pref("mousewheel.system_scroll_override_on_root_content.enabled", false); # XP_MACOSX diff --git a/widget/src/cocoa/ComplexTextInputPanel.mm b/widget/src/cocoa/ComplexTextInputPanel.mm index 43b45c0f91a4..c3748dc71e44 100644 --- a/widget/src/cocoa/ComplexTextInputPanel.mm +++ b/widget/src/cocoa/ComplexTextInputPanel.mm @@ -26,6 +26,9 @@ */ #import "ComplexTextInputPanel.h" +#include "nsIPrefService.h" +#include "nsIPrefBranch.h" +#include "nsServiceManagerUtils.h" #define kInputWindowHeight 20 @@ -83,7 +86,23 @@ - (void)keyboardInputSourceChanged:(NSNotification *)notification { - [self cancelComposition]; + static PRInt8 sDoCancel = -1; + if (!sDoCancel || ![self inComposition]) { + return; + } + if (sDoCancel < 0) { + nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); + NS_ENSURE_TRUE(prefs, ); + PRBool cancelComposition = PR_FALSE; + nsresult rv = + prefs->GetBoolPref("ui.plugin.cancel_composition_at_input_source_changed", + &cancelComposition); + NS_ENSURE_SUCCESS(rv, ); + sDoCancel = cancelComposition ? 1 : 0; + } + if (sDoCancel) { + [self cancelComposition]; + } } - (BOOL)interpretKeyEvent:(NSEvent*)event string:(NSString**)string