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 @@ -3241,22 +3241,23 @@ NotifyEditableStateChange(child, aDocument, aEditable); } } void 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")); } } } nsresult nsHTMLDocument::TurnEditingOff() { 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 @@ -65,15 +65,16 @@ bug369370-popup.png \ test_bug380383.html \ test_bug386495.html \ test_bug391777.html \ test_bug402680.html \ test_bug403868.html \ test_bug403868.xhtml \ test_bug404320.html \ + test_bug440614.html \ test_form-parsing.html \ test_viewport.html \ test_documentAll.html \ $(NULL) libs:: $(_TEST_FILES) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) 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 @@ -82,16 +82,17 @@ #include "nsIWidget.h" #include "nsWeakReference.h" #include "nsIDOMWindow.h" #include "nsIDOMDocument.h" #include "nsIRenderingContext.h" #include "nsIFrameFrame.h" #include "nsAutoPtr.h" #include "nsIDOMNSHTMLDocument.h" +#include "nsIHTMLDocument.h" #include "nsDisplayList.h" #include "nsUnicharUtils.h" #include "nsIReflowCallback.h" #include "nsIScrollableFrame.h" #include "nsIObjectLoadingContent.h" #include "nsLayoutUtils.h" #ifdef MOZ_XUL @@ -971,26 +972,35 @@ } // 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 docShell->GetPresShell(getter_AddRefs(presShell)); if (presShell) { - nsCOMPtr doc = + nsCOMPtr doc = do_QueryInterface(presShell->GetDocument()); - if (doc) { + if (doc && doc->IsEditingOn()) { + nsCOMPtr nsdoc = do_QueryInterface(doc); nsAutoString designMode; - doc->GetDesignMode(designMode); + nsdoc->GetDesignMode(designMode); + + // This is verging on hackish, but we REALLY need it to + // reset the editor (bug 440614) + doc->SetEditingState(nsIHTMLDocument::eOff); if (designMode.EqualsLiteral("on")) { - doc->SetDesignMode(NS_LITERAL_STRING("off")); - doc->SetDesignMode(NS_LITERAL_STRING("on")); + nsdoc->SetDesignMode(NS_LITERAL_STRING("off")); + nsdoc->SetDesignMode(NS_LITERAL_STRING("on")); + } + else { + nsdoc->SetDesignMode(NS_LITERAL_STRING("on")); + nsdoc->SetDesignMode(NS_LITERAL_STRING("off")); } } } return NS_OK; } nsresult