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
--- 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 {