Bug 1602944 - Move setting context to null. r=alchen, a=RyanVM
authorHenri Sivonen <hsivonen@hsivonen.fi>
Fri, 03 Jan 2020 14:28:37 +0000
changeset 524419 3b3f5444c5478582bc4a91237d1761b0868181ae
parent 524418 83b95131e4d6ea0c68b03f5f82f38de66147c99a
child 524420 bbe50b89b01899bce2ba1402982f510e603f4618
push id765
push userryanvm@gmail.com
push dateTue, 14 Jan 2020 22:56:39 +0000
treeherdermozilla-esr68@3b3f5444c547 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersalchen, RyanVM
bugs1602944
milestone68.5.0
Bug 1602944 - Move setting context to null. r=alchen, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D57965
parser/html/javasrc/TreeBuilder.java
parser/html/nsHtml5TreeBuilder.cpp
--- a/parser/html/javasrc/TreeBuilder.java
+++ b/parser/html/javasrc/TreeBuilder.java
@@ -714,18 +714,16 @@ public abstract class TreeBuilder<T> imp
                 } else if ("plaintext" == contextName) {
                     tokenizer.setState(Tokenizer.PLAINTEXT);
                 } else if ("script" == contextName) {
                     tokenizer.setState(Tokenizer.SCRIPT_DATA);
                 } else {
                     tokenizer.setState(Tokenizer.DATA);
                 }
             }
-            contextName = null;
-            contextNode = null;
         } else {
             mode = INITIAL;
             // If we are viewing XML source, put a foreign element permanently
             // on the stack so that cdataSectionAllowed() returns true.
             // CPPONLY: if (tokenizer.isViewingXmlSource()) {
             // CPPONLY: T elt = createElement("http://www.w3.org/2000/svg",
             // CPPONLY: "svg",
             // CPPONLY: tokenizer.emptyAttributes(), null,
@@ -1626,16 +1624,18 @@ public abstract class TreeBuilder<T> imp
     }
 
     /**
      * @see nu.validator.htmlparser.common.TokenHandler#endTokenization()
      */
     public final void endTokenization() throws SAXException {
         formPointer = null;
         headPointer = null;
+        contextName = null;
+        contextNode = null;
         templateModeStack = null;
         if (stack != null) {
             while (currentPtr > -1) {
                 stack[currentPtr].release(this);
                 currentPtr--;
             }
             stack = null;
         }
--- a/parser/html/nsHtml5TreeBuilder.cpp
+++ b/parser/html/nsHtml5TreeBuilder.cpp
@@ -204,18 +204,16 @@ void nsHtml5TreeBuilder::startTokenizati
       } else if (nsGkAtoms::plaintext == contextName) {
         tokenizer->setState(nsHtml5Tokenizer::PLAINTEXT);
       } else if (nsGkAtoms::script == contextName) {
         tokenizer->setState(nsHtml5Tokenizer::SCRIPT_DATA);
       } else {
         tokenizer->setState(nsHtml5Tokenizer::DATA);
       }
     }
-    contextName = nullptr;
-    contextNode = nullptr;
   } else {
     mode = INITIAL;
     if (tokenizer->isViewingXmlSource()) {
       nsIContentHandle* elt = createElement(
           kNameSpaceID_SVG, nsGkAtoms::svg, tokenizer->emptyAttributes(),
           nullptr, svgCreator(NS_NewSVGSVGElement));
       nsHtml5StackNode* node =
           createStackNode(nsHtml5ElementName::ELT_SVG, nsGkAtoms::svg, elt);
@@ -646,16 +644,18 @@ eofloop_end:;
   if (!fragment) {
     popOnEof();
   }
 }
 
 void nsHtml5TreeBuilder::endTokenization() {
   formPointer = nullptr;
   headPointer = nullptr;
+  contextName = nullptr;
+  contextNode = nullptr;
   templateModeStack = nullptr;
   if (stack) {
     while (currentPtr > -1) {
       stack[currentPtr]->release(this);
       currentPtr--;
     }
     stack = nullptr;
   }