Bug 1357642 TextEditor::UpdateIMEComposition() shouldn't call NotifyEditorObservers(eNotifyEditorObserversOfBefore) by itself r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 16 Jun 2017 21:30:22 +0900
changeset 595582 6325860ac4a5258ccfea5245d69ee4e252d5613f
parent 595581 af8136e4fa88392fba6f02f44231c65437857fbf
child 633733 462b6a0b88088671137ed4f1cee0061561e97e9e
push id64370
push usermasayuki@d-toybox.com
push dateFri, 16 Jun 2017 12:39:17 +0000
reviewersm_kato
bugs1357642
milestone56.0a1
Bug 1357642 TextEditor::UpdateIMEComposition() shouldn't call NotifyEditorObservers(eNotifyEditorObserversOfBefore) by itself r?m_kato TextEditor::UpdateIMEComposition() uses AutoPlaceHolderBatch class which calls NotifyEditorObservers(eNotifyEditorObserversOfBefore) automatically when it's created. Therefore, it causes calling NotifyEditorObservers(eNotifyEditorObserversOfBefore) twice from TextEditor::UpdateIMEComposition(). MozReview-Commit-ID: DJqzmCtyHCf
editor/libeditor/TextEditor.cpp
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -872,24 +872,24 @@ TextEditor::UpdateIMEComposition(WidgetC
   //       of NotifiyEditorObservers(eNotifyEditorObserversOfEnd) or
   //       NotifiyEditorObservers(eNotifyEditorObserversOfCancel) which notifies
   //       TextComposition of a selection change.
   MOZ_ASSERT(!mPlaceholderBatch,
     "UpdateIMEComposition() must be called without place holder batch");
   TextComposition::CompositionChangeEventHandlingMarker
     compositionChangeEventHandlingMarker(mComposition, aCompsitionChangeEvent);
 
-  NotifyEditorObservers(eNotifyEditorObserversOfBefore);
-
   RefPtr<nsCaret> caretP = ps->GetCaret();
 
   nsresult rv;
   {
     AutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName);
 
+    MOZ_ASSERT(mIsInEditAction,
+      "AutoPlaceHolderBatch should've notified the observes of before-edit");
     rv = InsertText(aCompsitionChangeEvent->mData);
 
     if (caretP) {
       caretP->SetSelection(selection);
     }
   }
 
   // If still composing, we should fire input event via observer.