Backed out changeset: d98cdb0cdd15
authorSerge Gautherie <sgautherie.bz@free.fr>
Fri, 05 Dec 2008 19:26:52 +0100
changeset 22387 488ed6c3dd5d1fd7fed48800cfabc114dd4cf331
parent 22368 d98cdb0cdd15b0e0a5a4cc592339c0e60c691c8a
child 22388 7f80a677ca91f8479ef871abe56614af5b61c3c3
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
milestone1.9.2a1pre
Backed out changeset: d98cdb0cdd15
content/html/document/src/nsHTMLDocument.cpp
content/html/document/src/nsHTMLDocument.h
content/html/document/src/nsIHTMLDocument.h
content/html/document/test/Makefile.in
content/html/document/test/test_bug440614.html
layout/generic/nsFrameFrame.cpp
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -3255,23 +3255,22 @@ NotifyEditableStateChange(nsINode *aNode
     NotifyEditableStateChange(child, aDocument, aEditable);
   }
 }
 
 void
 nsHTMLDocument::TearingDownEditor(nsIEditor *aEditor)
 {
   if (IsEditingOn()) {
-    EditingState oldState = mEditingState;
     mEditingState = eTearingDown;
 
     nsCOMPtr<nsIEditorStyleSheets> editorss = do_QueryInterface(aEditor);
     if (editorss) {
       editorss->RemoveOverrideStyleSheet(NS_LITERAL_STRING("resource://gre/res/contenteditable.css"));
-      if (oldState == eDesignMode)
+      if (mEditingState == eDesignMode)
         editorss->RemoveOverrideStyleSheet(NS_LITERAL_STRING("resource://gre/res/designmode.css"));
     }
   }
 }
 
 nsresult
 nsHTMLDocument::TurnEditingOff()
 {
@@ -3293,25 +3292,16 @@ nsHTMLDocument::TurnEditingOff()
   rv = editSession->TearDownEditorOnWindow(window);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mEditingState = eOff;
 
   return NS_OK;
 }
 
-nsresult
-nsHTMLDocument::ReinitEditor()
-{
-  NS_ASSERTION(mEditingState != eOff, "Editor not inited.");
-  
-  TurnEditingOff();
-  return EditingStateChanged();
-}
-
 static PRBool HasPresShell(nsPIDOMWindow *aWindow)
 {
   nsIDocShell *docShell = aWindow->GetDocShell();
   if (!docShell)
     return PR_FALSE;
   nsCOMPtr<nsIPresShell> presShell;
   docShell->GetPresShell(getter_AddRefs(presShell));
   return presShell != nsnull;
--- a/content/html/document/src/nsHTMLDocument.h
+++ b/content/html/document/src/nsHTMLDocument.h
@@ -226,18 +226,16 @@ public:
 
   virtual already_AddRefed<nsIParser> GetFragmentParser() {
     return mFragmentParser.forget();
   }
   virtual void SetFragmentParser(nsIParser* aParser) {
     mFragmentParser = aParser;
   }
 
-  virtual nsresult ReinitEditor();
-  
   virtual nsresult SetEditingState(EditingState aState);
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
 protected:
   nsresult GetBodySize(PRInt32* aWidth,
                        PRInt32* aHeight);
 
--- a/content/html/document/src/nsIHTMLDocument.h
+++ b/content/html/document/src/nsIHTMLDocument.h
@@ -166,23 +166,16 @@ public:
   virtual EditingState GetEditingState() = 0;
 
   /**
    * Set the editing state of the document. Don't use this if you want
    * to enable/disable editing, call EditingStateChanged() or
    * 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
    * or a nodelist depending on if there are multiple nodes with the same
    * id.
    */
   virtual nsresult GetDocumentAllResult(const nsAString& aID,
                                         nsISupports** aResult) = 0;
--- a/content/html/document/test/Makefile.in
+++ b/content/html/document/test/Makefile.in
@@ -66,17 +66,16 @@ include $(topsrcdir)/config/rules.mk
 		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 \
 		test_bug445004.html \
 		bug445004-inner.js \
 		bug445004-outer-rel.html \
 		bug445004-outer-abs.html \
 		bug445004-outer-write.html \
deleted file mode 100644
--- a/content/html/document/test/test_bug440614.html
+++ /dev/null
@@ -1,103 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=440614
--->
-<head>
-  <title>Test for Bug 440614</title>
-  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=440614">Mozilla Bug 440614</a>
-<p id="display"></p>
-<div id="content">
-  <iframe></iframe>
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-var styleSheets = null;
-
-function checkStylesheets() {
-  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
-  // Evidently RemoveStyleSheet is the only method in nsIEditorStyleSheets
-  // that would throw. RemoveOverrideStyleSheet returns NS_OK even if the
-  // sheet is not there
-  var removed = 0;
-  try
-  {
-    styleSheets.removeStyleSheet("resource://gre/res/designmode.css");
-    removed++;
-  }
-  catch (ex) { }
-
-  try {
-    styleSheets.removeStyleSheet("resource://gre/res/contenteditable.css");
-    removed++;
-  }
-  catch (ex) { }
-
-  is(removed, 0, "Should have thrown if stylesheet was not there");
-}
-
-function runTest() {
-  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
-  const Ci = Components.interfaces;
-  const Cc = Components.classes;
-
-  /** Not really bug 440614, just found while fixing 440614 **/
-  var editframe = window.frames[0];
-  var editdoc = editframe.document;
-  var editor = null;
-  editdoc.write('');
-  editdoc.close();
-
-  editdoc.designMode='on';
-
-  // Hold the reference to the editor
-  editor = editframe.QueryInterface(Ci.nsIInterfaceRequestor)
-                        .getInterface(Ci.nsIWebNavigation)
-                        .QueryInterface(Ci.nsIInterfaceRequestor)
-                        .getInterface(Ci.nsIEditingSession)
-                        .getEditorForWindow(editframe);
-
-  styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
-
-  editdoc.designMode='off';
-  
-  checkStylesheets();
-  
-  // Let go
-  editor = null;
-  styleSheets = null;
-  
-  editdoc.body.contentEditable = true;
-  
-  // Hold the reference to the editor
-  editor = editframe.QueryInterface(Ci.nsIInterfaceRequestor)
-                        .getInterface(Ci.nsIWebNavigation)
-                        .QueryInterface(Ci.nsIInterfaceRequestor)
-                        .getInterface(Ci.nsIEditingSession)
-                        .getEditorForWindow(editframe);
-
-  styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
-  
-  editdoc.body.contentEditable = false;
-  
-  checkStylesheets();
-  
-  SimpleTest.finish();
-}
-
-//XXX I don't know if this is necessary, but we're dealing with iframes...
-SimpleTest.waitForExplicitFinish();
-addLoadEvent(runTest);
-
-</script>
-</pre>
-</body>
-</html>
--- a/layout/generic/nsFrameFrame.cpp
+++ b/layout/generic/nsFrameFrame.cpp
@@ -81,17 +81,17 @@
 #include "nsINameSpaceManager.h"
 #include "nsIWidget.h"
 #include "nsWeakReference.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMDocument.h"
 #include "nsIRenderingContext.h"
 #include "nsIFrameFrame.h"
 #include "nsAutoPtr.h"
-#include "nsIHTMLDocument.h"
+#include "nsIDOMNSHTMLDocument.h"
 #include "nsDisplayList.h"
 #include "nsUnicharUtils.h"
 #include "nsIReflowCallback.h"
 #include "nsIScrollableFrame.h"
 #include "nsIObjectLoadingContent.h"
 #include "nsLayoutUtils.h"
 
 #ifdef MOZ_XUL
@@ -970,25 +970,31 @@ nsSubDocumentFrame::ShowDocShell()
     baseWindow->Create();
 
     baseWindow->SetVisibility(PR_TRUE);
   }
 
   // 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 && 440614
+  // https://bugzilla.mozilla.org/show_bug.cgi?id=284245
   docShell->GetPresShell(getter_AddRefs(presShell));
   if (presShell) {
-    nsCOMPtr<nsIHTMLDocument> doc =
+    nsCOMPtr<nsIDOMNSHTMLDocument> doc =
       do_QueryInterface(presShell->GetDocument());
 
-    // Re-init the editor, if necessary
-    if (doc && doc->IsEditingOn())
-      doc->ReinitEditor();
+    if (doc) {
+      nsAutoString designMode;
+      doc->GetDesignMode(designMode);
+
+      if (designMode.EqualsLiteral("on")) {
+        doc->SetDesignMode(NS_LITERAL_STRING("off"));
+        doc->SetDesignMode(NS_LITERAL_STRING("on"));
+      }
+    }
   }
 
   return NS_OK;
 }
 
 nsresult
 nsSubDocumentFrame::CreateViewAndWidget(nsContentType aContentType)
 {