Bug 515142 - Make HTML5 parser never clone nodes. WHATWG spec SVN rev 2947. rs=sicking.
authorHenri Sivonen <hsivonen@iki.fi>
Mon, 21 Sep 2009 10:00:10 +0300
changeset 32947 f6df323122666baa1507fe3194014e70cbeb30c2
parent 32946 80dc1c31b175fdbfeea482af4aaede6aa5e2b57f
child 32948 cac6c26d9e5a9dd9990c1fa2ea59a54e762c99de
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs515142
milestone1.9.3a1pre
Bug 515142 - Make HTML5 parser never clone nodes. WHATWG spec SVN rev 2947. rs=sicking.
parser/html/nsHtml5AttributeName.cpp
parser/html/nsHtml5AttributeName.h
parser/html/nsHtml5HtmlAttributes.cpp
parser/html/nsHtml5HtmlAttributes.h
parser/html/nsHtml5Portability.cpp
parser/html/nsHtml5Portability.h
parser/html/nsHtml5ReleasableAttributeName.cpp
parser/html/nsHtml5ReleasableAttributeName.h
parser/html/nsHtml5StackNode.cpp
parser/html/nsHtml5StackNode.h
parser/html/nsHtml5Tokenizer.cpp
parser/html/nsHtml5TreeBuilder.cpp
parser/html/nsHtml5TreeBuilder.h
parser/html/nsHtml5TreeBuilderCppSupplement.h
--- a/parser/html/nsHtml5AttributeName.cpp
+++ b/parser/html/nsHtml5AttributeName.cpp
@@ -153,16 +153,22 @@ nsHtml5AttributeName::release()
 
 nsHtml5AttributeName::~nsHtml5AttributeName()
 {
   MOZ_COUNT_DTOR(nsHtml5AttributeName);
   nsHtml5Portability::releaseLocal(local[0]);
   delete[] local;
 }
 
+nsHtml5AttributeName* 
+nsHtml5AttributeName::cloneAttributeName()
+{
+  return this;
+}
+
 PRInt32 
 nsHtml5AttributeName::getUri(PRInt32 mode)
 {
   return uri[mode];
 }
 
 nsIAtom* 
 nsHtml5AttributeName::getLocal(PRInt32 mode)
--- a/parser/html/nsHtml5AttributeName.h
+++ b/parser/html/nsHtml5AttributeName.h
@@ -52,43 +52,47 @@ class nsHtml5ElementName;
 class nsHtml5HtmlAttributes;
 class nsHtml5UTF16Buffer;
 class nsHtml5StateSnapshot;
 class nsHtml5Portability;
 
 
 class nsHtml5AttributeName
 {
+  public:
+    static PRInt32* ALL_NO_NS;
   private:
-    static PRInt32* ALL_NO_NS;
     static PRInt32* XMLNS_NS;
     static PRInt32* XML_NS;
     static PRInt32* XLINK_NS;
+  public:
     static nsIAtom** ALL_NO_PREFIX;
+  private:
     static nsIAtom** XMLNS_PREFIX;
     static nsIAtom** XLINK_PREFIX;
     static nsIAtom** XML_PREFIX;
     static nsIAtom** SVG_DIFFERENT(nsIAtom* name, nsIAtom* camel);
     static nsIAtom** MATH_DIFFERENT(nsIAtom* name, nsIAtom* camel);
     static nsIAtom** COLONIFIED_LOCAL(nsIAtom* name, nsIAtom* suffix);
+  public:
     static nsIAtom** SAME_LOCAL(nsIAtom* name);
-  public:
     static nsHtml5AttributeName* nameByBuffer(PRUnichar* buf, PRInt32 offset, PRInt32 length);
   private:
     static PRInt32 bufToHash(PRUnichar* buf, PRInt32 len);
     PRInt32* uri;
     nsIAtom** local;
     nsIAtom** prefix;
   protected:
     nsHtml5AttributeName(PRInt32* uri, nsIAtom** local, nsIAtom** prefix);
   private:
     static nsHtml5AttributeName* createAttributeName(nsIAtom* name);
   public:
     virtual void release();
     ~nsHtml5AttributeName();
+    virtual nsHtml5AttributeName* cloneAttributeName();
     PRInt32 getUri(PRInt32 mode);
     nsIAtom* getLocal(PRInt32 mode);
     nsIAtom* getPrefix(PRInt32 mode);
     PRBool equalsAnother(nsHtml5AttributeName* another);
     static nsHtml5AttributeName* ATTR_D;
     static nsHtml5AttributeName* ATTR_K;
     static nsHtml5AttributeName* ATTR_R;
     static nsHtml5AttributeName* ATTR_X;
--- a/parser/html/nsHtml5HtmlAttributes.cpp
+++ b/parser/html/nsHtml5HtmlAttributes.cpp
@@ -218,16 +218,27 @@ nsHtml5HtmlAttributes::adjustForMath()
 }
 
 void 
 nsHtml5HtmlAttributes::adjustForSvg()
 {
   mode = NS_HTML5ATTRIBUTE_NAME_SVG;
 }
 
+nsHtml5HtmlAttributes* 
+nsHtml5HtmlAttributes::cloneAttributes()
+{
+
+  nsHtml5HtmlAttributes* clone = new nsHtml5HtmlAttributes(0);
+  for (PRInt32 i = 0; i < length; i++) {
+    clone->addAttribute(names[i]->cloneAttributeName(), nsHtml5Portability::newStringFromString(values[i]));
+  }
+  return clone;
+}
+
 void
 nsHtml5HtmlAttributes::initializeStatics()
 {
   EMPTY_ATTRIBUTES = new nsHtml5HtmlAttributes(NS_HTML5ATTRIBUTE_NAME_HTML);
 }
 
 void
 nsHtml5HtmlAttributes::releaseStatics()
--- a/parser/html/nsHtml5HtmlAttributes.h
+++ b/parser/html/nsHtml5HtmlAttributes.h
@@ -78,16 +78,17 @@ class nsHtml5HtmlAttributes
     nsString* getValue(nsHtml5AttributeName* name);
     void addAttribute(nsHtml5AttributeName* name, nsString* value);
     void clear(PRInt32 m);
     void releaseValue(PRInt32 i);
     void clearWithoutReleasingContents();
     PRBool contains(nsHtml5AttributeName* name);
     void adjustForMath();
     void adjustForSvg();
+    nsHtml5HtmlAttributes* cloneAttributes();
     static void initializeStatics();
     static void releaseStatics();
 };
 
 #ifdef nsHtml5HtmlAttributes_cpp__
 nsHtml5HtmlAttributes* nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES = nsnull;
 #endif
 
--- a/parser/html/nsHtml5Portability.cpp
+++ b/parser/html/nsHtml5Portability.cpp
@@ -63,16 +63,23 @@ nsHtml5Portability::newEmptyString()
 nsString*
 nsHtml5Portability::newStringFromLiteral(const char* literal)
 {
   nsString* str = new nsString();
   str->AssignASCII(literal);
   return str;
 }
 
+nsString*
+nsHtml5Portability::newStringFromString(nsString* string) {
+  nsString* newStr = new nsString();
+  newStr->Assign(*string);
+  return newStr;
+}
+
 jArray<PRUnichar,PRInt32>
 nsHtml5Portability::newCharArrayFromLocal(nsIAtom* local)
 {
   nsAutoString temp;
   local->ToString(temp);
   PRInt32 len = temp.Length();
   jArray<PRUnichar,PRInt32> arr = jArray<PRUnichar,PRInt32>(len);
   memcpy(arr, temp.BeginReading(), len * sizeof(PRUnichar));
--- a/parser/html/nsHtml5Portability.h
+++ b/parser/html/nsHtml5Portability.h
@@ -57,16 +57,17 @@ class nsHtml5StateSnapshot;
 
 class nsHtml5Portability
 {
   public:
     static nsIAtom* newLocalNameFromBuffer(PRUnichar* buf, PRInt32 offset, PRInt32 length);
     static nsString* newStringFromBuffer(PRUnichar* buf, PRInt32 offset, PRInt32 length);
     static nsString* newEmptyString();
     static nsString* newStringFromLiteral(const char* literal);
+    static nsString* newStringFromString(nsString* string);
     static jArray<PRUnichar,PRInt32> newCharArrayFromLocal(nsIAtom* local);
     static jArray<PRUnichar,PRInt32> newCharArrayFromString(nsString* string);
     static void releaseString(nsString* str);
     static void retainLocal(nsIAtom* local);
     static void releaseLocal(nsIAtom* local);
     static void retainElement(nsIContent* elt);
     static void releaseElement(nsIContent* elt);
     static PRBool localEqualsBuffer(nsIAtom* local, PRUnichar* buf, PRInt32 offset, PRInt32 length);
--- a/parser/html/nsHtml5ReleasableAttributeName.cpp
+++ b/parser/html/nsHtml5ReleasableAttributeName.cpp
@@ -31,19 +31,30 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsHtml5ReleasableAttributeName.h"
+#include "nsHtml5Portability.h"
 
 nsHtml5ReleasableAttributeName::nsHtml5ReleasableAttributeName(PRInt32* uri, nsIAtom** local, nsIAtom** prefix)
   : nsHtml5AttributeName(uri, local, prefix)
 {
 }
 
+nsHtml5AttributeName*
+nsHtml5ReleasableAttributeName::cloneAttributeName()
+{
+  nsIAtom* l = getLocal(0);
+  nsHtml5Portability::retainLocal(l);
+  return new nsHtml5ReleasableAttributeName(nsHtml5AttributeName::ALL_NO_NS, 
+                                            nsHtml5AttributeName::SAME_LOCAL(l), 
+                                            nsHtml5AttributeName::ALL_NO_PREFIX);
+}
+
 void
 nsHtml5ReleasableAttributeName::release()
 {
   delete this;
 }
--- a/parser/html/nsHtml5ReleasableAttributeName.h
+++ b/parser/html/nsHtml5ReleasableAttributeName.h
@@ -39,12 +39,13 @@
 #define nsHtml5ReleasableAttributeName_h__
 
 #include "nsHtml5AttributeName.h"
 
 class nsHtml5ReleasableAttributeName : public nsHtml5AttributeName
 {
   public:
     nsHtml5ReleasableAttributeName(PRInt32* uri, nsIAtom** local, nsIAtom** prefix);
+    virtual nsHtml5AttributeName* cloneAttributeName();
     virtual void release();
 };
 
 #endif // nsHtml5ReleasableAttributeName_h__
--- a/parser/html/nsHtml5StackNode.cpp
+++ b/parser/html/nsHtml5StackNode.cpp
@@ -51,25 +51,26 @@
 #include "nsHtml5HtmlAttributes.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5StateSnapshot.h"
 #include "nsHtml5Portability.h"
 
 #include "nsHtml5StackNode.h"
 
 
-nsHtml5StackNode::nsHtml5StackNode(PRInt32 group, PRInt32 ns, nsIAtom* name, nsIContent* node, PRBool scoping, PRBool special, PRBool fosterParenting, nsIAtom* popName)
+nsHtml5StackNode::nsHtml5StackNode(PRInt32 group, PRInt32 ns, nsIAtom* name, nsIContent* node, PRBool scoping, PRBool special, PRBool fosterParenting, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
   : group(group),
     name(name),
     popName(popName),
     ns(ns),
     node(node),
     scoping(scoping),
     special(special),
     fosterParenting(fosterParenting),
+    attributes(attributes),
     refcount(1)
 {
   MOZ_COUNT_CTOR(nsHtml5StackNode);
   nsHtml5Portability::retainLocal(name);
   nsHtml5Portability::retainLocal(popName);
   nsHtml5Portability::retainElement(node);
 }
 
@@ -78,16 +79,36 @@ nsHtml5StackNode::nsHtml5StackNode(PRInt
   : group(elementName->group),
     name(elementName->name),
     popName(elementName->name),
     ns(ns),
     node(node),
     scoping(elementName->scoping),
     special(elementName->special),
     fosterParenting(elementName->fosterParenting),
+    attributes(nsnull),
+    refcount(1)
+{
+  MOZ_COUNT_CTOR(nsHtml5StackNode);
+  nsHtml5Portability::retainLocal(name);
+  nsHtml5Portability::retainLocal(popName);
+  nsHtml5Portability::retainElement(node);
+}
+
+
+nsHtml5StackNode::nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent* node, nsHtml5HtmlAttributes* attributes)
+  : group(elementName->group),
+    name(elementName->name),
+    popName(elementName->name),
+    ns(ns),
+    node(node),
+    scoping(elementName->scoping),
+    special(elementName->special),
+    fosterParenting(elementName->fosterParenting),
+    attributes(attributes),
     refcount(1)
 {
   MOZ_COUNT_CTOR(nsHtml5StackNode);
   nsHtml5Portability::retainLocal(name);
   nsHtml5Portability::retainLocal(popName);
   nsHtml5Portability::retainElement(node);
 }
 
@@ -96,16 +117,17 @@ nsHtml5StackNode::nsHtml5StackNode(PRInt
   : group(elementName->group),
     name(elementName->name),
     popName(popName),
     ns(ns),
     node(node),
     scoping(elementName->scoping),
     special(elementName->special),
     fosterParenting(elementName->fosterParenting),
+    attributes(nsnull),
     refcount(1)
 {
   MOZ_COUNT_CTOR(nsHtml5StackNode);
   nsHtml5Portability::retainLocal(name);
   nsHtml5Portability::retainLocal(popName);
   nsHtml5Portability::retainElement(node);
 }
 
@@ -114,31 +136,39 @@ nsHtml5StackNode::nsHtml5StackNode(PRInt
   : group(elementName->group),
     name(elementName->name),
     popName(popName),
     ns(ns),
     node(node),
     scoping(scoping),
     special(PR_FALSE),
     fosterParenting(PR_FALSE),
+    attributes(nsnull),
     refcount(1)
 {
   MOZ_COUNT_CTOR(nsHtml5StackNode);
   nsHtml5Portability::retainLocal(name);
   nsHtml5Portability::retainLocal(popName);
   nsHtml5Portability::retainElement(node);
 }
 
 
 nsHtml5StackNode::~nsHtml5StackNode()
 {
   MOZ_COUNT_DTOR(nsHtml5StackNode);
   nsHtml5Portability::releaseLocal(name);
   nsHtml5Portability::releaseLocal(popName);
   nsHtml5Portability::releaseElement(node);
+  delete attributes;
+}
+
+void 
+nsHtml5StackNode::dropAttributes()
+{
+  attributes = nsnull;
 }
 
 void 
 nsHtml5StackNode::retain()
 {
   refcount++;
 }
 
--- a/parser/html/nsHtml5StackNode.h
+++ b/parser/html/nsHtml5StackNode.h
@@ -63,24 +63,27 @@ class nsHtml5StackNode
     PRInt32 group;
     nsIAtom* name;
     nsIAtom* popName;
     PRInt32 ns;
     nsIContent* node;
     PRBool scoping;
     PRBool special;
     PRBool fosterParenting;
+    nsHtml5HtmlAttributes* attributes;
   private:
     PRInt32 refcount;
   public:
-    nsHtml5StackNode(PRInt32 group, PRInt32 ns, nsIAtom* name, nsIContent* node, PRBool scoping, PRBool special, PRBool fosterParenting, nsIAtom* popName);
+    nsHtml5StackNode(PRInt32 group, PRInt32 ns, nsIAtom* name, nsIContent* node, PRBool scoping, PRBool special, PRBool fosterParenting, nsIAtom* popName, nsHtml5HtmlAttributes* attributes);
     nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent* node);
+    nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent* node, nsHtml5HtmlAttributes* attributes);
     nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent* node, nsIAtom* popName);
     nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent* node, nsIAtom* popName, PRBool scoping);
     ~nsHtml5StackNode();
+    void dropAttributes();
     void retain();
     void release();
     static void initializeStatics();
     static void releaseStatics();
 
 #include "nsHtml5StackNodeHSupplement.h"
 };
 
--- a/parser/html/nsHtml5Tokenizer.cpp
+++ b/parser/html/nsHtml5Tokenizer.cpp
@@ -377,16 +377,17 @@ nsHtml5Tokenizer::attributeNameComplete(
     attributeName->release();
     attributeName = nsnull;
   }
 }
 
 void 
 nsHtml5Tokenizer::addAttributeWithoutValue()
 {
+
   if (!!attributeName) {
     attributes->addAttribute(attributeName, nsHtml5Portability::newEmptyString());
   }
 }
 
 void 
 nsHtml5Tokenizer::addAttributeWithValue()
 {
@@ -749,16 +750,17 @@ nsHtml5Tokenizer::stateLoop(PRInt32 stat
             case '\"': {
               clearLongStrBufForNextState();
               state = NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED;
               goto beforeattributevalueloop_end;
             }
             case '&': {
               clearLongStrBuf();
               state = NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED;
+
               reconsume = PR_TRUE;
               goto stateloop;
             }
             case '\'': {
               clearLongStrBufForNextState();
               state = NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED;
               goto stateloop;
             }
@@ -774,16 +776,17 @@ nsHtml5Tokenizer::stateLoop(PRInt32 stat
             case '\0': {
               c = 0xfffd;
             }
             case '<':
             case '=':
             default: {
               clearLongStrBufAndAppendCurrentC(c);
               state = NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED;
+
               goto stateloop;
             }
           }
         }
         beforeattributevalueloop_end: ;
       }
       case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
         for (; ; ) {
--- a/parser/html/nsHtml5TreeBuilder.cpp
+++ b/parser/html/nsHtml5TreeBuilder.cpp
@@ -3053,18 +3053,19 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag
       if (nodePos == formattingEltStackPos) {
         break;
       }
       if (nodePos == furthestBlockPos) {
         bookmark = nodeListPos + 1;
       }
 
 
-      nsIContent* clone = shallowClone(node->node);
-      nsHtml5StackNode* newNode = new nsHtml5StackNode(node->group, node->ns, node->name, clone, node->scoping, node->special, node->fosterParenting, node->popName);
+      nsIContent* clone = createElement(kNameSpaceID_XHTML, node->name, node->attributes->cloneAttributes());
+      nsHtml5StackNode* newNode = new nsHtml5StackNode(node->group, node->ns, node->name, clone, node->scoping, node->special, node->fosterParenting, node->popName, node->attributes);
+      node->dropAttributes();
       stack[nodePos] = newNode;
       newNode->retain();
       listOfActiveFormattingElements[nodeListPos] = newNode;
       node->release();
       node->release();
       node = newNode;
       nsHtml5Portability::releaseElement(clone);
       detachFromParent(lastNode->node);
@@ -3074,18 +3075,19 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag
     if (commonAncestor->fosterParenting) {
 
       detachFromParent(lastNode->node);
       insertIntoFosterParent(lastNode->node);
     } else {
       detachFromParent(lastNode->node);
       appendElement(lastNode->node, commonAncestor->node);
     }
-    nsIContent* clone = shallowClone(formattingElt->node);
-    nsHtml5StackNode* formattingClone = new nsHtml5StackNode(formattingElt->group, formattingElt->ns, formattingElt->name, clone, formattingElt->scoping, formattingElt->special, formattingElt->fosterParenting, formattingElt->popName);
+    nsIContent* clone = createElement(kNameSpaceID_XHTML, formattingElt->name, formattingElt->attributes->cloneAttributes());
+    nsHtml5StackNode* formattingClone = new nsHtml5StackNode(formattingElt->group, formattingElt->ns, formattingElt->name, clone, formattingElt->scoping, formattingElt->special, formattingElt->fosterParenting, formattingElt->popName, formattingElt->attributes);
+    formattingElt->dropAttributes();
     appendChildrenToNewParent(furthestBlock->node, clone);
     appendElement(clone, furthestBlock->node);
     removeFromListOfActiveFormattingElements(formattingEltListPos);
     insertIntoListOfActiveFormattingElements(formattingClone, bookmark);
 
     removeFromStack(formattingEltStackPos);
     insertIntoStack(formattingClone, furthestBlockPos);
     nsHtml5Portability::releaseElement(clone);
@@ -3220,18 +3222,19 @@ nsHtml5TreeBuilder::reconstructTheActive
     }
   }
   if (entryPos < listPtr) {
     flushCharacters();
   }
   while (entryPos < listPtr) {
     entryPos++;
     nsHtml5StackNode* entry = listOfActiveFormattingElements[entryPos];
-    nsIContent* clone = shallowClone(entry->node);
-    nsHtml5StackNode* entryClone = new nsHtml5StackNode(entry->group, entry->ns, entry->name, clone, entry->scoping, entry->special, entry->fosterParenting, entry->popName);
+    nsIContent* clone = createElement(kNameSpaceID_XHTML, entry->name, entry->attributes->cloneAttributes());
+    nsHtml5StackNode* entryClone = new nsHtml5StackNode(entry->group, entry->ns, entry->name, clone, entry->scoping, entry->special, entry->fosterParenting, entry->popName, entry->attributes);
+    entry->dropAttributes();
     nsHtml5StackNode* currentNode = stack[currentPtr];
     if (currentNode->fosterParenting) {
       insertIntoFosterParent(clone);
     } else {
       appendElement(clone, currentNode->node);
     }
     push(entryClone);
     listOfActiveFormattingElements[entryPos] = entryClone;
@@ -3353,17 +3356,17 @@ nsHtml5TreeBuilder::appendToCurrentNodeA
   nsIContent* elt = createElement(ns, elementName->name, attributes);
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->fosterParenting) {
 
     insertIntoFosterParent(elt);
   } else {
     appendElement(elt, current->node);
   }
-  nsHtml5StackNode* node = new nsHtml5StackNode(ns, elementName, elt);
+  nsHtml5StackNode* node = new nsHtml5StackNode(ns, elementName, elt, attributes->cloneAttributes());
   push(node);
   append(node);
   node->retain();
   nsHtml5Portability::releaseElement(elt);
 }
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushElement(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
--- a/parser/html/nsHtml5TreeBuilder.h
+++ b/parser/html/nsHtml5TreeBuilder.h
@@ -71,17 +71,16 @@ class nsHtml5TreeBuilder
     static jArray<PRUnichar,PRInt32> ISINDEX_PROMPT;
     static jArray<const char*,PRInt32> QUIRKY_PUBLIC_IDS;
     PRInt32 mode;
     PRInt32 originalMode;
     PRInt32 foreignFlag;
   protected:
     nsHtml5Tokenizer* tokenizer;
   private:
-    nsHtml5TreeBuilder* documentModeHandler;
     PRBool scriptingEnabled;
     PRBool needToDropLF;
     PRBool fragment;
     nsIAtom* contextName;
     PRInt32 contextNamespace;
     nsIContent* contextNode;
     jArray<nsHtml5StackNode*,PRInt32> stack;
     PRInt32 currentPtr;
@@ -179,17 +178,16 @@ class nsHtml5TreeBuilder
     void accumulateCharacters(PRUnichar* buf, PRInt32 start, PRInt32 length);
     void accumulateCharacter(PRUnichar c);
     void requestSuspension();
     nsIContent* createElement(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes);
     nsIContent* createElement(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent* form);
     nsIContent* createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* attributes);
     void detachFromParent(nsIContent* element);
     PRBool hasChildren(nsIContent* element);
-    nsIContent* shallowClone(nsIContent* element);
     void appendElement(nsIContent* child, nsIContent* newParent);
     void appendChildrenToNewParent(nsIContent* oldParent, nsIContent* newParent);
     void insertFosterParentedChild(nsIContent* child, nsIContent* table, nsIContent* stackParent);
     void insertFosterParentedCharacters(PRUnichar* buf, PRInt32 start, PRInt32 length, nsIContent* table, nsIContent* stackParent);
     void appendCharacters(nsIContent* parent, PRUnichar* buf, PRInt32 start, PRInt32 length);
     void appendComment(nsIContent* parent, PRUnichar* buf, PRInt32 start, PRInt32 length);
     void appendCommentToDocument(PRUnichar* buf, PRInt32 start, PRInt32 length);
     void addAttributesToElement(nsIContent* element, nsHtml5HtmlAttributes* attributes);
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -136,26 +136,16 @@ nsHtml5TreeBuilder::createHtmlElementSet
 void
 nsHtml5TreeBuilder::detachFromParent(nsIContent* aElement)
 {
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   // XXX if null, OOM!
   treeOp->Init(eTreeOpDetach, aElement);
 }
 
-nsIContent*
-nsHtml5TreeBuilder::shallowClone(nsIContent* aElement)
-{
-  nsINode* clone;
-  aElement->Clone(aElement->NodeInfo(), &clone);
-  // XXX nsresult
-  NS_ASSERTION(clone->IsNodeOfType(nsINode::eCONTENT), "Cloning an element didn't yield a content node.");
-  return static_cast<nsIContent*>(clone);
-}
-
 void
 nsHtml5TreeBuilder::appendElement(nsIContent* aChild, nsIContent* aParent)
 {
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   // XXX if null, OOM!
   treeOp->Init(aChild, aParent);
 }