Bug 1333990: Part 2c.1 - Interrupt the XML flush loop after inserting document element. r?hsivonen draft
authorKris Maglione <maglione.k@gmail.com>
Wed, 15 Mar 2017 14:04:37 -0700
changeset 499608 a02fb4e13a7822d3e0c2eb24e64b1a2705f7ffb7
parent 499607 57dbae3233a179a82b2e0bd0326f8fb149cb6f74
child 499609 4e76adf54218c30e26a2d9449f4749492efbd4ca
child 499659 a06895de92c9780bd6e007ea8c0be38397451230
push id49456
push usermaglione.k@gmail.com
push dateThu, 16 Mar 2017 00:44:19 +0000
reviewershsivonen
bugs1333990
milestone54.0a1
Bug 1333990: Part 2c.1 - Interrupt the XML flush loop after inserting document element. r?hsivonen MozReview-Commit-ID: 8CslW407IaQ
dom/xml/nsXMLContentSink.cpp
--- a/dom/xml/nsXMLContentSink.cpp
+++ b/dom/xml/nsXMLContentSink.cpp
@@ -574,18 +574,16 @@ nsXMLContentSink::CloseElement(nsIConten
 
     // Now tell the script that it's ready to go. This may execute the script
     // or return true, or neither if the script doesn't need executing.
     bool block = sele->AttemptToExecute();
 
     // If the parser got blocked, make sure to return the appropriate rv.
     // I'm not sure if this is actually needed or not.
     if (mParser && !mParser->IsParserEnabled()) {
-      // XXX The HTML sink doesn't call BlockParser here, why do we?
-      GetParser()->BlockParser();
       block = true;
     }
 
     return block ? NS_ERROR_HTMLPARSER_BLOCK : NS_OK;
   }
 
   nsresult rv = NS_OK;
   if (nodeInfo->Equals(nsGkAtoms::meta, kNameSpaceID_XHTML) &&
@@ -1010,16 +1008,20 @@ nsXMLContentSink::HandleStartElement(con
   if (content != mDocElement && !mCurrentHead) {
     // This isn't the root and we're not inside an XHTML <head>.
     // Might need to start layout
     MaybeStartLayout(false);
   }
 
   if (content == mDocElement) {
     NotifyDocElementCreated(mDocument);
+
+    if (aInterruptable && NS_SUCCEEDED(result) && mParser && !mParser->IsParserEnabled()) {
+      return NS_ERROR_HTMLPARSER_BLOCK;
+    }
   }
 
   return aInterruptable && NS_SUCCEEDED(result) ? DidProcessATokenImpl() :
                                                   result;
 }
 
 NS_IMETHODIMP
 nsXMLContentSink::HandleEndElement(const char16_t *aName)