Bug 1278084 part.3 TextComposition shouldn't decide composition string which is only an ideographic space as a placeholder r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 07 Jun 2016 21:25:24 +0900
changeset 343320 598a325005ad71019f610490b464c0c238b580ef
parent 343319 33fa68d6823f6f516a2eb6bbb78e7ce99b9e6630
child 343321 85bb94bb8c3e98b79c3efe3b71bd4b8d8854d0aa
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1278084
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
@@ -1975,16 +1975,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"