Bug 1443902 - Reinitilize selection after destroying nsIEditingSession. r=masayuki

When setting contenteditable to false, editing session destroys HTMLEditor.
Destroying HTMLEditor means that selection visibility is reset by
FinalizeSelection.

So after calling TearDownEditorOnWindow on nsHTMLDocument, we should initialize
selection visibility if current focus is text control that has editor.

MozReview-Commit-ID: 4V8kZtOtKO3
This commit is contained in:
Makoto Kato
2018-07-09 16:53:47 +09:00
parent c629251107
commit bb97f78ad4
12 changed files with 181 additions and 0 deletions

View File

@@ -2339,6 +2339,20 @@ nsHTMLDocument::TurnEditingOff()
mEditingState = eOff;
// Editor resets selection since it is being destroyed. But if focus is
// still into editable control, we have to initialize selection again.
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
Element* element = fm->GetFocusedElement();
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(element);
if (txtCtrl) {
RefPtr<TextEditor> textEditor = txtCtrl->GetTextEditor();
if (textEditor) {
textEditor->ReinitializeSelection(*element);
}
}
}
return NS_OK;
}