Bug 541078 - Turn editing off in BeginLoad(). r=bzbarsky.
authorHenri Sivonen <hsivonen@iki.fi>
Fri, 12 Mar 2010 12:29:46 +0200
changeset 39450 51d36e8f461d317fbac408ecccff447d1a26744e
parent 39449 befd1c73e3f118e5ea6dba5738ea32d33893a454
child 39451 a0061217d338e71dc9b87181bcaf2a50f54ffe97
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky
bugs541078
milestone1.9.3a3pre
Bug 541078 - Turn editing off in BeginLoad(). r=bzbarsky.
content/html/document/src/nsHTMLDocument.cpp
content/html/document/src/nsHTMLDocument.h
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -1065,16 +1065,31 @@ nsHTMLDocument::DocumentWriteTermination
 
     htmldoc->mParser = nsnull;
   }
 
   htmldoc->EndLoad();
 }
 
 void
+nsHTMLDocument::BeginLoad()
+{
+  if (IsEditingOn()) {
+    // Reset() blows away all event listeners in the document, and our
+    // editor relies heavily on those. Midas is turned on, to make it
+    // work, re-initialize it to give it a chance to add its event
+    // listeners again.
+
+    TurnEditingOff();
+    EditingStateChanged();
+  }
+  nsDocument::BeginLoad();
+}
+
+void
 nsHTMLDocument::EndLoad()
 {
   if (mParser && mWriteState != eDocumentClosed) {
     nsCOMPtr<nsIJSContextStack> stack =
       do_GetService("@mozilla.org/js/xpc/ContextStack;1");
 
     if (stack) {
       JSContext *cx = nsnull;
@@ -1980,26 +1995,16 @@ nsHTMLDocument::OpenCommon(const nsACStr
   }
 
   // Call Reset(), this will now do the full reset
   Reset(channel, group);
   if (baseURI) {
     mDocumentBaseURI = baseURI;
   }
 
-  if (IsEditingOn()) {
-    // Reset() blows away all event listeners in the document, and our
-    // editor relies heavily on those. Midas is turned on, to make it
-    // work, re-initialize it to give it a chance to add its event
-    // listeners again.
-
-    TurnEditingOff();
-    EditingStateChanged();
-  }
-
   // Store the security info of the caller now that we're done
   // resetting the document.
   mSecurityInfo = securityInfo;
 
   if (loadAsHtml5) {
     mParser = nsHtml5Module::NewHtml5Parser();
     rv = NS_OK;
   } else {
--- a/content/html/document/src/nsHTMLDocument.h
+++ b/content/html/document/src/nsHTMLDocument.h
@@ -96,16 +96,18 @@ public:
                                      nsIChannel* aChannel,
                                      nsILoadGroup* aLoadGroup,
                                      nsISupports* aContainer,
                                      nsIStreamListener **aDocListener,
                                      PRBool aReset = PR_TRUE,
                                      nsIContentSink* aSink = nsnull);
   virtual void StopDocumentLoad();
 
+  virtual void BeginLoad();
+
   virtual void EndLoad();
 
   virtual nsresult AddImageMap(nsIDOMHTMLMapElement* aMap);
 
   virtual void RemoveImageMap(nsIDOMHTMLMapElement* aMap);
 
   virtual nsIDOMHTMLMapElement *GetImageMap(const nsAString& aMapName);