Bug 1209465 - Work around TextComposition workaround. r=esawin, a=lizzard
authorJim Chen <nchen@mozilla.com>
Fri, 06 Nov 2015 13:35:00 +0100
changeset 296692 5ffeff840220
parent 296691 e7f899e48fc6
child 296693 8b8a66145292
push id5292
push usercbook@mozilla.com
push date2015-11-11 10:02 +0000
treeherdermozilla-beta@5ffeff840220 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin, lizzard
bugs1209465
milestone43.0
Bug 1209465 - Work around TextComposition workaround. r=esawin, a=lizzard
widget/android/nsWindow.cpp
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1674,25 +1674,31 @@ nsWindow::GetIMEComposition()
 
 /*
     Remove the composition but leave the text content as-is
 */
 void
 nsWindow::RemoveIMEComposition()
 {
     // Remove composition on Gecko side
-    if (!GetIMEComposition()) {
+    const nsRefPtr<mozilla::TextComposition> composition(GetIMEComposition());
+    if (!composition) {
         return;
     }
 
     nsRefPtr<nsWindow> kungFuDeathGrip(this);
     AutoIMEMask selMask(mIMEMaskSelectionUpdate);
 
-    WidgetCompositionEvent compositionCommitEvent(true, eCompositionCommitAsIs,
-                                                  this);
+    // We have to use eCompositionCommit instead of eCompositionCommitAsIs
+    // because TextComposition has a workaround for eCompositionCommitAsIs
+    // that prevents compositions containing a single ideographic space
+    // character from working (see bug 1209465)..
+    WidgetCompositionEvent compositionCommitEvent(
+            true, eCompositionCommit, this);
+    compositionCommitEvent.mData = composition->String();
     InitEvent(compositionCommitEvent, nullptr);
     DispatchEvent(&compositionCommitEvent);
 }
 
 /*
  * Send dummy key events for pages that are unaware of input events,
  * to provide web compatibility for pages that depend on key events.
  * Our dummy key events have 0 as the keycode.
@@ -1856,20 +1862,17 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
                 event.mRanges = new TextRangeArray();
                 event.mRanges->AppendElement(range);
 
                 DispatchEvent(&event);
             }
 
             // Don't end composition when composing text.
             if (ae->Action() != AndroidGeckoEvent::IME_COMPOSE_TEXT) {
-                WidgetCompositionEvent compositionCommitEvent(
-                        true, eCompositionCommitAsIs, this);
-                InitEvent(compositionCommitEvent, nullptr);
-                DispatchEvent(&compositionCommitEvent);
+                RemoveIMEComposition();
             }
 
             if (mInputContext.mMayBeIMEUnaware) {
                 SendIMEDummyKeyEvents();
             }
 
             FlushIMEChanges();
             GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);