Bug 717560 input events during composition should be fired after auto batch is gone r=ehsan
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 13 Jan 2012 15:19:22 +0900
changeset 85628 2877e53c2d70d2c0e3ae57e95e9a4a1eaebb72d4
parent 85627 78e58e679fca654cfc28fa12127803b824e62487
child 85629 065691d7581cfc7100d6f9a3def53f7229f70126
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs717560
milestone12.0a1
Bug 717560 input events during composition should be fired after auto batch is gone r=ehsan
editor/libeditor/text/nsPlaintextEditor.cpp
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -964,16 +964,17 @@ nsPlaintextEditor::UpdateIMEComposition(
   //   For escape keypress, this causes an empty string to be passed
   //   twice, which freaks out the editor.
 
   // aCompositionString.IsEmpty() && !aTextRangeList:
   //   Some Chinese IMEs for Linux are always composition string and text range
   //   list are empty when listing the Chinese characters. In this case,
   //   we don't need to process composition string too. See bug 271815.
 
+  bool notifyEditorObservers = false;
   if (!aCompositionString.IsEmpty() || (mIMETextNode && aTextRangeList)) {
     mIMETextRangeList = aTextRangeList;
 
     nsAutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName);
 
     SetIsIMEComposing(); // We set mIsIMEComposing properly.
 
     rv = InsertText(aCompositionString);
@@ -987,19 +988,22 @@ nsPlaintextEditor::UpdateIMEComposition(
     // second part of 23558 fix:
     if (aCompositionString.IsEmpty()) {
       mIMETextNode = nsnull;
     }
 
     // If still composing, we should fire input event via observer.
     // Note that if committed, we don't need to notify it since it will be
     // notified at followed compositionend event.
-    if (mIsIMEComposing) {
-      NotifyEditorObservers();
-    }
+    // NOTE: We must notify after the auto batch will be gone.
+    notifyEditorObservers = mIsIMEComposing;
+  }
+
+  if (notifyEditorObservers) {
+    NotifyEditorObservers();
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsPlaintextEditor::GetDocumentIsEmpty(bool *aDocumentIsEmpty)
 {