Bug 1437795 - Reset TextInputListener on nsTextEditorState::Clear(). r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 13 Feb 2018 17:45:34 +0900
changeset 754341 52c245ff2fc8ec1bf7b8415433bd755ff53231b2
parent 754160 6d8f470b2579e7570f14e3db557264dc075dd654
push id98829
push userbmo:m_kato@ga2.so-net.ne.jp
push dateTue, 13 Feb 2018 08:47:42 +0000
reviewersmasayuki
bugs1437795
milestone60.0a1
Bug 1437795 - Reset TextInputListener on nsTextEditorState::Clear(). r?masayuki nsTextEditorState is reusable object by HTMLInputElement. When it is unused, it will call Unlink method to remove dependency of HTMLInputElement etc. So we should reset TextInputListener on Editor too on Unlink because anyone might call nsTextEditorState from TextInputListener. MozReview-Commit-ID: DZFyIguJLLB
dom/html/nsTextEditorState.cpp
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -1116,16 +1116,20 @@ Element*
 nsTextEditorState::GetPreviewNode()
 {
   return mBoundFrame ? mBoundFrame->GetPreviewNode() : nullptr;
 }
 
 void
 nsTextEditorState::Clear()
 {
+  if (mTextEditor) {
+    mTextEditor->SetTextInputListener(nullptr);
+  }
+
   if (mBoundFrame) {
     // Oops, we still have a frame!
     // This should happen when the type of a text input control is being changed
     // to something which is not a text control.  In this case, we should pretend
     // that a frame is being destroyed, and clean up after ourselves properly.
     UnbindFromFrame(mBoundFrame);
     mTextEditor = nullptr;
   } else {