Bug 1209465 - Work around TextComposition workaround. r=esawin, a=lizzard
authorJim Chen <nchen@mozilla.com>
Fri, 06 Nov 2015 13:35:00 +0100
changeset 298397 5ffeff840220ea554cc0f0333d4389676da2ae49
parent 298396 e7f899e48fc6dce46aa743f459c7db0b481fa181
child 298398 8b8a6614529292280d2d092b9277c7467abfd861
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [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);