Bug 1278084 part.3 TextComposition shouldn't decide composition string which is only an ideographic space as a placeholder r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 07 Jun 2016 21:25:24 +0900
changeset 376568 a57348d0a4df65e6ac8ed977ddb8f0c3b20cfcd9
parent 376567 5aa76723d276a4f33c663cd80b254d1a291c2bc2
child 523195 b9f20b64c2ffbf5645fdc627993719be4b9c07c0
push id20624
push usermasayuki@d-toybox.com
push dateWed, 08 Jun 2016 10:45:47 +0000
reviewersm_kato
bugs1278084
milestone49.0a1
Bug 1278084 part.3 TextComposition shouldn't decide composition string which is only an ideographic space as a placeholder r?m_kato Currently, when TextComposition tries to forcibly commit composition synchronously, it cancels the composition if there is only an ideographic space since legacy Chinese IMEs for Windows were used an ideographic space as a placeholder and shows actual composition string in its owning window (called reading window). However, Japanese TIPs basically use composition to input an ideographic space. Unfortunately, this intentional input of an ideographic space is always canceled if an editor commits to composition at every input event in TSF mode because TSF cannot commit during a call of ITextStore::RequestLock(). Additionally, we will enable e10s mode, then, on all platforms, requesting commit composition is handled asynchronously. Therefore, we should make the hack disabled in default settings now. If we'll find a way to distinguish if an ideographic space is a placeholder, we should recover this hack. Note that such input fields cannot handle such legacy IMEs, so, disabling the hack in default settings must be fine. MozReview-Commit-ID: IdBcfBxeJum
dom/events/TextComposition.cpp
modules/libpref/init/all.js
--- a/dom/events/TextComposition.cpp
+++ b/dom/events/TextComposition.cpp
@@ -262,20 +262,23 @@ TextComposition::DispatchCompositionEven
                                 aCompositionEvent->mRanges);
   }
   if (aCompositionEvent->mMessage == eCompositionCommitAsIs) {
     NS_ASSERTION(!aCompositionEvent->mRanges,
                  "mRanges of eCompositionCommitAsIs should be null");
     aCompositionEvent->mRanges = nullptr;
     NS_ASSERTION(aCompositionEvent->mData.IsEmpty(),
                  "mData of eCompositionCommitAsIs should be empty string");
-    if (mLastData == IDEOGRAPHIC_SPACE) {
-      // If the last data is an ideographic space (FullWidth space), it must be
+    bool removePlaceholderCharacter =
+      Preferences::GetBool("intl.ime.remove_placeholder_character_at_commit",
+                           false);
+    if (removePlaceholderCharacter && mLastData == IDEOGRAPHIC_SPACE) {
+      // If the last data is an ideographic space (FullWidth space), it might be
       // a placeholder character of some Chinese IME.  So, committing with
-      // this data must not be expected by users.  Let's use empty string.
+      // this data might not be expected by users.  Let's use empty string.
       aCompositionEvent->mData.Truncate();
     } else {
       aCompositionEvent->mData = mLastData;
     }
   } else if (aCompositionEvent->mMessage == eCompositionCommit) {
     NS_ASSERTION(!aCompositionEvent->mRanges,
                  "mRanges of eCompositionCommit should be null");
     aCompositionEvent->mRanges = nullptr;
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1972,16 +1972,22 @@ pref("font.language.group",             
 
 // Android-specific pref to use key-events-only mode for IME-unaware webapps.
 #ifdef MOZ_WIDGET_ANDROID
 pref("intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition", true);
 #else
 pref("intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition", false);
 #endif
 
+// If you use legacy Chinese IME which puts an ideographic space to composition
+// string as placeholder, this pref might be useful.  If this is true and when
+// web contents forcibly commits composition (e.g., moving focus), the
+// ideographic space will be ignored (i.e., commits with empty string).
+pref("intl.ime.remove_placeholder_character_at_commit", false);
+
 // these locales have right-to-left UI
 pref("intl.uidirection.ar", "rtl");
 pref("intl.uidirection.he", "rtl");
 pref("intl.uidirection.fa", "rtl");
 pref("intl.uidirection.ug", "rtl");
 pref("intl.uidirection.ur", "rtl");
 
 // use en-US hyphenation by default for content tagged with plain lang="en"