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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user