diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index ed004e822abf..e225e93a15f3 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -134,7 +134,8 @@ #include "nsIEditingSession.h" #include "nsIEditor.h" #include "nsNodeInfoManager.h" -#include "nsIEditor.h" +#include "nsIPlaintextEditor.h" +#include "nsIHTMLEditor.h" #include "nsIEditorDocShell.h" #include "nsIEditorStyleSheets.h" #include "nsIInlineSpellChecker.h" @@ -3264,6 +3265,22 @@ nsHTMLDocument::EditingStateChanged() nsCOMPtr editSession = do_GetInterface(docshell, &rv); NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr existingEditor; + editSession->GetEditorForWindow(window, getter_AddRefs(existingEditor)); + if (existingEditor) { + // We might already have an editor if it was set up for mail, let's see + // if this is actually the case. + nsCOMPtr htmlEditor = do_QueryInterface(existingEditor); + NS_ABORT_IF_FALSE(htmlEditor, "If we have an editor, it must be an HTML editor"); + PRUint32 flags = 0; + existingEditor->GetFlags(&flags); + if (flags & nsIPlaintextEditor::eEditorMailMask) { + // We already have a mail editor, then we should not attempt to create + // another one. + return NS_OK; + } + } + if (!HasPresShell(window)) { // We should not make the window editable or setup its editor. // It's probably style=display:none. diff --git a/editor/libeditor/html/tests/Makefile.in b/editor/libeditor/html/tests/Makefile.in index a717eb0dbd83..e31d22dab698 100644 --- a/editor/libeditor/html/tests/Makefile.in +++ b/editor/libeditor/html/tests/Makefile.in @@ -88,6 +88,7 @@ _DATA_FILES = \ _CHROME_TEST_FILES = \ test_bug490879.xul \ test_bug607584.xul \ + test_bug616590.xul \ green.png \ $(NULL) diff --git a/editor/libeditor/html/tests/test_bug616590.xul b/editor/libeditor/html/tests/test_bug616590.xul new file mode 100644 index 000000000000..c31a56f5c7fa --- /dev/null +++ b/editor/libeditor/html/tests/test_bug616590.xul @@ -0,0 +1,106 @@ + + + + + + +