diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -3260,12 +3260,13 @@ nsHTMLDocument::TearingDownEditor(nsIEditor *aEditor) { if (IsEditingOn()) { + EditingState oldState = mEditingState; mEditingState = eTearingDown; nsCOMPtr editorss = do_QueryInterface(aEditor); if (editorss) { editorss->RemoveOverrideStyleSheet(NS_LITERAL_STRING("resource://gre/res/contenteditable.css")); - if (mEditingState == eDesignMode) + if (oldState == eDesignMode) editorss->RemoveOverrideStyleSheet(NS_LITERAL_STRING("resource://gre/res/designmode.css")); } } @@ -3295,6 +3296,15 @@ mEditingState = eOff; return NS_OK; +} + +nsresult +nsHTMLDocument::ReinitEditor() +{ + NS_ASSERTION(mEditingState != eOff, "Editor not inited."); + + TurnEditingOff(); + return EditingStateChanged(); } static PRBool HasPresShell(nsPIDOMWindow *aWindow) diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -231,6 +231,8 @@ mFragmentParser = aParser; } + virtual nsresult ReinitEditor(); + virtual nsresult SetEditingState(EditingState aState); virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; diff --git a/content/html/document/src/nsIHTMLDocument.h b/content/html/document/src/nsIHTMLDocument.h --- a/content/html/document/src/nsIHTMLDocument.h +++ b/content/html/document/src/nsIHTMLDocument.h @@ -171,6 +171,13 @@ * SetDesignMode(). */ virtual nsresult SetEditingState(EditingState aState) = 0; + + /** + * Re-inits the editor. Editing must be on from contentEditable or designMode + * when calling this. + * Required because of the way the editor works. (bug 440614) + */ + virtual nsresult ReinitEditor() = 0; /** * Returns the result of document.all[aID] which can either be a node diff --git a/content/html/document/test/Makefile.in b/content/html/document/test/Makefile.in --- a/content/html/document/test/Makefile.in +++ b/content/html/document/test/Makefile.in @@ -71,6 +71,7 @@ test_bug403868.html \ test_bug403868.xhtml \ test_bug404320.html \ + test_bug440614.html \ test_form-parsing.html \ test_viewport.html \ test_documentAll.html \ diff --git a/content/html/document/test/test_bug440614.html b/content/html/document/test/test_bug440614.html new file mode 100644 --- /dev/null +++ b/content/html/document/test/test_bug440614.html @@ -0,0 +1,103 @@ + + + + + Test for Bug 440614 + + + + + +Mozilla Bug 440614 +

+
+ +
+
+
+
+ + diff --git a/layout/generic/nsFrameFrame.cpp b/layout/generic/nsFrameFrame.cpp --- a/layout/generic/nsFrameFrame.cpp +++ b/layout/generic/nsFrameFrame.cpp @@ -86,7 +86,7 @@ #include "nsIRenderingContext.h" #include "nsIFrameFrame.h" #include "nsAutoPtr.h" -#include "nsIDOMNSHTMLDocument.h" +#include "nsIHTMLDocument.h" #include "nsDisplayList.h" #include "nsUnicharUtils.h" #include "nsIReflowCallback.h" @@ -975,21 +975,15 @@ // Trigger editor re-initialization if midas is turned on in the // sub-document. This shouldn't be necessary, but given the way our // editor works, it is. See - // https://bugzilla.mozilla.org/show_bug.cgi?id=284245 + // https://bugzilla.mozilla.org/show_bug.cgi?id=284245 && 440614 docShell->GetPresShell(getter_AddRefs(presShell)); if (presShell) { - nsCOMPtr doc = + nsCOMPtr doc = do_QueryInterface(presShell->GetDocument()); - if (doc) { - nsAutoString designMode; - doc->GetDesignMode(designMode); - - if (designMode.EqualsLiteral("on")) { - doc->SetDesignMode(NS_LITERAL_STRING("off")); - doc->SetDesignMode(NS_LITERAL_STRING("on")); - } - } + // Re-init the editor, if necessary + if (doc && doc->IsEditingOn()) + doc->ReinitEditor(); } return NS_OK;