Bug 483155 - Put content creator function pointers onto nsHtml5ElementName. r=smaug
authorHenri Sivonen <hsivonen@hsivonen.fi>
Tue, 04 Jul 2017 11:00:03 +0300
changeset 423601 048ed01b19e02008b7f8161d70bbf2dbcab15be4
parent 423600 518e73ca3d423862b039bbbf3546fc28d18cf3dd
child 423602 67963f1a665ab4d8e5797027b9c3de58708eb245
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs483155
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 483155 - Put content creator function pointers onto nsHtml5ElementName. r=smaug MozReview-Commit-ID: E2AAx7Zz2UF
dom/base/nsNameSpaceManager.cpp
dom/base/nsNodeInfoManager.cpp
dom/base/nsNodeInfoManager.h
dom/html/HTMLElement.cpp
dom/html/nsGenericHTMLElement.h
dom/html/nsHTMLContentSink.cpp
dom/svg/SVGElementFactory.cpp
dom/svg/SVGElementFactory.h
dom/svg/SVGTagList.h
dom/svg/moz.build
parser/html/java/README.txt
parser/html/javasrc/ElementName.java
parser/html/javasrc/StackNode.java
parser/html/javasrc/Tokenizer.java
parser/html/javasrc/TreeBuilder.java
parser/html/moz.build
parser/html/nsHtml5AttributeName.cpp
parser/html/nsHtml5AttributeName.h
parser/html/nsHtml5ContentCreatorFunction.h
parser/html/nsHtml5ElementName.cpp
parser/html/nsHtml5ElementName.h
parser/html/nsHtml5Highlighter.cpp
parser/html/nsHtml5Highlighter.h
parser/html/nsHtml5MetaScanner.cpp
parser/html/nsHtml5MetaScanner.h
parser/html/nsHtml5Portability.h
parser/html/nsHtml5StackNode.cpp
parser/html/nsHtml5StackNode.h
parser/html/nsHtml5StateSnapshot.cpp
parser/html/nsHtml5StateSnapshot.h
parser/html/nsHtml5Tokenizer.cpp
parser/html/nsHtml5TreeBuilder.cpp
parser/html/nsHtml5TreeBuilder.h
parser/html/nsHtml5TreeBuilderCppSupplement.h
parser/html/nsHtml5TreeOperation.cpp
parser/html/nsHtml5TreeOperation.h
parser/html/nsHtml5UTF16Buffer.cpp
parser/html/nsHtml5UTF16Buffer.h
parser/htmlparser/nsHTMLTagList.h
--- a/dom/base/nsNameSpaceManager.cpp
+++ b/dom/base/nsNameSpaceManager.cpp
@@ -10,17 +10,16 @@
  */
 
 #include "nsNameSpaceManager.h"
 
 #include "nscore.h"
 #include "mozilla/dom/NodeInfo.h"
 #include "nsCOMArray.h"
 #include "nsContentCreatorFunctions.h"
-#include "nsContentUtils.h"
 #include "nsGkAtoms.h"
 #include "nsIDocument.h"
 #include "nsString.h"
 #include "mozilla/dom/NodeInfo.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/dom/XBLChildrenElement.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/Preferences.h"
@@ -185,54 +184,30 @@ NS_NewElement(Element** aResult,
 #ifdef MOZ_XUL
   if (ns == kNameSpaceID_XUL) {
     return NS_NewXULElement(aResult, ni.forget());
   }
 #endif
   if (ns == kNameSpaceID_MathML) {
     // If the mathml.disabled pref. is true, convert all MathML nodes into
     // disabled MathML nodes by swapping the namespace.
-    nsNameSpaceManager* nsmgr = nsNameSpaceManager::GetInstance();
-    if ((nsmgr && !nsmgr->mMathMLDisabled) ||
-        nsContentUtils::IsSystemPrincipal(ni->GetDocument()->NodePrincipal())) {
+    if (ni->NodeInfoManager()->MathMLEnabled()) {
       return NS_NewMathMLElement(aResult, ni.forget());
     }
 
     RefPtr<mozilla::dom::NodeInfo> genericXMLNI =
       ni->NodeInfoManager()->
       GetNodeInfo(ni->NameAtom(), ni->GetPrefixAtom(),
         kNameSpaceID_disabled_MathML, ni->NodeType(), ni->GetExtraName());
     return NS_NewXMLElement(aResult, genericXMLNI.forget());
   }
   if (ns == kNameSpaceID_SVG) {
     // If the svg.disabled pref. is true, convert all SVG nodes into
     // disabled SVG nodes by swapping the namespace.
-    nsNameSpaceManager* nsmgr = nsNameSpaceManager::GetInstance();
-    nsCOMPtr<nsILoadInfo> loadInfo;
-    bool SVGEnabled = false;
-
-    if (nsmgr && !nsmgr->mSVGDisabled) {
-      SVGEnabled = true;
-    } else {
-      nsCOMPtr<nsIChannel> channel = ni->GetDocument()->GetChannel();
-      // We don't have a channel for SVGs constructed inside a SVG script
-      if (channel) {
-        loadInfo  = channel->GetLoadInfo();
-      }
-    }
-    if (SVGEnabled ||
-        nsContentUtils::IsSystemPrincipal(ni->GetDocument()->NodePrincipal()) ||
-        (loadInfo &&
-         (loadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_IMAGE ||
-         loadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_OTHER) &&
-         (nsContentUtils::IsSystemPrincipal(loadInfo->LoadingPrincipal()) ||
-          nsContentUtils::IsSystemPrincipal(loadInfo->TriggeringPrincipal())
-         )
-        )
-       ) {
+    if (ni->NodeInfoManager()->SVGEnabled()) {
       return NS_NewSVGElement(aResult, ni.forget(), aFromParser);
     }
     RefPtr<mozilla::dom::NodeInfo> genericXMLNI =
       ni->NodeInfoManager()->
       GetNodeInfo(ni->NameAtom(), ni->GetPrefixAtom(),
         kNameSpaceID_disabled_SVG, ni->NodeType(), ni->GetExtraName());
     return NS_NewXMLElement(aResult, genericXMLNI.forget());
   }
--- a/dom/base/nsNodeInfoManager.cpp
+++ b/dom/base/nsNodeInfoManager.cpp
@@ -113,17 +113,19 @@ static PLHashAllocOps allocOps =
   { AllocTable, FreeTable, AllocEntry, FreeEntry };
 
 nsNodeInfoManager::nsNodeInfoManager()
   : mDocument(nullptr),
     mNonDocumentNodeInfos(0),
     mTextNodeInfo(nullptr),
     mCommentNodeInfo(nullptr),
     mDocumentNodeInfo(nullptr),
-    mRecentlyUsedNodeInfos{}
+    mRecentlyUsedNodeInfos{},
+    mSVGEnabled(eTriUnset),
+    mMathMLEnabled(eTriUnset)
 {
   nsLayoutStatics::AddRef();
 
   if (gNodeInfoManagerLeakPRLog)
     MOZ_LOG(gNodeInfoManagerLeakPRLog, LogLevel::Debug,
            ("NODEINFOMANAGER %p created", this));
 
   mNodeInfoHash = PL_NewHashTable(32, GetNodeInfoInnerHashValue,
@@ -458,8 +460,51 @@ nsNodeInfoManager::RemoveNodeInfo(NodeIn
 
 #ifdef DEBUG
   bool ret =
 #endif
   PL_HashTableRemove(mNodeInfoHash, &aNodeInfo->mInner);
 
   NS_POSTCONDITION(ret, "Can't find mozilla::dom::NodeInfo to remove!!!");
 }
+
+bool
+nsNodeInfoManager::InternalSVGEnabled()
+{
+  // If the svg.disabled pref. is true, convert all SVG nodes into
+  // disabled SVG nodes by swapping the namespace.
+  nsNameSpaceManager* nsmgr = nsNameSpaceManager::GetInstance();
+  nsCOMPtr<nsILoadInfo> loadInfo;
+  bool SVGEnabled = false;
+
+  if (nsmgr && !nsmgr->mSVGDisabled) {
+    SVGEnabled = true;
+  } else {
+    nsCOMPtr<nsIChannel> channel = mDocument->GetChannel();
+    // We don't have a channel for SVGs constructed inside a SVG script
+    if (channel) {
+      loadInfo = channel->GetLoadInfo();
+    }
+  }
+  bool conclusion =
+    (SVGEnabled || nsContentUtils::IsSystemPrincipal(mPrincipal) ||
+     (loadInfo &&
+      (loadInfo->GetExternalContentPolicyType() ==
+         nsIContentPolicy::TYPE_IMAGE ||
+       loadInfo->GetExternalContentPolicyType() ==
+         nsIContentPolicy::TYPE_OTHER) &&
+      (nsContentUtils::IsSystemPrincipal(loadInfo->LoadingPrincipal()) ||
+       nsContentUtils::IsSystemPrincipal(loadInfo->TriggeringPrincipal()))));
+  mSVGEnabled = conclusion ? eTriTrue : eTriFalse;
+  return conclusion;
+}
+
+bool
+nsNodeInfoManager::InternalMathMLEnabled()
+{
+  // If the mathml.disabled pref. is true, convert all MathML nodes into
+  // disabled MathML nodes by swapping the namespace.
+  nsNameSpaceManager* nsmgr = nsNameSpaceManager::GetInstance();
+  bool conclusion = ((nsmgr && !nsmgr->mMathMLDisabled) ||
+                     nsContentUtils::IsSystemPrincipal(mPrincipal));
+  mMathMLEnabled = conclusion ? eTriTrue : eTriFalse;
+  return conclusion;
+}
--- a/dom/base/nsNodeInfoManager.h
+++ b/dom/base/nsNodeInfoManager.h
@@ -104,16 +104,43 @@ public:
 
   void RemoveNodeInfo(mozilla::dom::NodeInfo *aNodeInfo);
 
   nsBindingManager* GetBindingManager() const
   {
     return mBindingManager;
   }
 
+  enum Tri
+  {
+    eTriUnset = 0,
+    eTriFalse,
+    eTriTrue
+  };
+
+  /**
+   * Returns true if SVG nodes in this document have real SVG semantics.
+   */
+  bool SVGEnabled()
+  {
+    return mSVGEnabled == eTriTrue
+             ? true
+             : mSVGEnabled == eTriFalse ? false : InternalSVGEnabled();
+  }
+
+  /**
+   * Returns true if MathML nodes in this document have real MathML semantics.
+   */
+  bool MathMLEnabled()
+  {
+    return mMathMLEnabled == eTriTrue
+             ? true
+             : mMathMLEnabled == eTriFalse ? false : InternalMathMLEnabled();
+  }
+
 protected:
   friend class nsDocument;
   friend class nsXULPrototypeDocument;
   friend nsresult NS_NewDOMDocumentType(nsIDOMDocumentType** ,
                                         nsNodeInfoManager *,
                                         nsIAtom *,
                                         const nsAString& ,
                                         const nsAString& ,
@@ -125,21 +152,26 @@ protected:
   void SetDocumentPrincipal(nsIPrincipal *aPrincipal);
 
 private:
   static int NodeInfoInnerKeyCompare(const void *key1, const void *key2);
   static PLHashNumber GetNodeInfoInnerHashValue(const void *key);
   static int DropNodeInfoDocument(PLHashEntry *he, int hashIndex,
                                      void *arg);
 
+  bool InternalSVGEnabled();
+  bool InternalMathMLEnabled();
+
   PLHashTable *mNodeInfoHash;
   nsIDocument * MOZ_NON_OWNING_REF mDocument; // WEAK
   uint32_t mNonDocumentNodeInfos;
   nsCOMPtr<nsIPrincipal> mPrincipal; // Never null after Init() succeeds.
   nsCOMPtr<nsIPrincipal> mDefaultPrincipal; // Never null after Init() succeeds
   mozilla::dom::NodeInfo * MOZ_NON_OWNING_REF mTextNodeInfo; // WEAK to avoid circular ownership
   mozilla::dom::NodeInfo * MOZ_NON_OWNING_REF mCommentNodeInfo; // WEAK to avoid circular ownership
   mozilla::dom::NodeInfo * MOZ_NON_OWNING_REF mDocumentNodeInfo; // WEAK to avoid circular ownership
   RefPtr<nsBindingManager> mBindingManager;
   mozilla::dom::NodeInfo* mRecentlyUsedNodeInfos[RECENTLY_USED_NODEINFOS_SIZE];
+  Tri mSVGEnabled;
+  Tri mMathMLEnabled;
 };
 
 #endif /* nsNodeInfoManager_h___ */
--- a/dom/html/HTMLElement.cpp
+++ b/dom/html/HTMLElement.cpp
@@ -48,8 +48,17 @@ HTMLElement::WrapNode(JSContext *aCx, JS
 // Here, we expand 'NS_IMPL_NS_NEW_HTML_ELEMENT()' by hand.
 // (Calling the macro directly (with no args) produces compiler warnings.)
 nsGenericHTMLElement*
 NS_NewHTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                   mozilla::dom::FromParser aFromParser)
 {
   return new mozilla::dom::HTMLElement(aNodeInfo);
 }
+
+// Distinct from the above in order to have function pointer that compared unequal
+// to a function pointer to the above.
+nsGenericHTMLElement*
+NS_NewCustomElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
+                    mozilla::dom::FromParser aFromParser)
+{
+  return new mozilla::dom::HTMLElement(aNodeInfo);
+}
--- a/dom/html/nsGenericHTMLElement.h
+++ b/dom/html/nsGenericHTMLElement.h
@@ -1466,16 +1466,25 @@ protected:
   {                                                                                               \
     return SetAttrHelper(nsGkAtoms::_atom, aValue);                                               \
   }
 
 #define NS_INTERFACE_MAP_ENTRY_IF_TAG(_interface, _tag)                       \
   NS_INTERFACE_MAP_ENTRY_CONDITIONAL(_interface,                              \
                                      mNodeInfo->Equals(nsGkAtoms::_tag))
 
+namespace mozilla {
+namespace dom {
+
+typedef nsGenericHTMLElement* (*HTMLContentCreatorFunction)(
+  already_AddRefed<mozilla::dom::NodeInfo>&&,
+  mozilla::dom::FromParser aFromParser);
+
+} // namespace dom
+} // namespace mozilla
 
 /**
  * A macro to declare the NS_NewHTMLXXXElement() functions.
  */
 #define NS_DECLARE_NS_NEW_HTML_ELEMENT(_elementName)                       \
 namespace mozilla {                                                        \
 namespace dom {                                                            \
 class HTML##_elementName##Element;                                         \
@@ -1514,16 +1523,23 @@ NS_NewHTML##_elementName##Element(alread
 }
 
 // Here, we expand 'NS_DECLARE_NS_NEW_HTML_ELEMENT()' by hand.
 // (Calling the macro directly (with no args) produces compiler warnings.)
 nsGenericHTMLElement*
 NS_NewHTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                   mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
 
+// Distinct from the above in order to have function pointer that compared unequal
+// to a function pointer to the above.
+nsGenericHTMLElement*
+NS_NewCustomElement(
+  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
+  mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
+
 NS_DECLARE_NS_NEW_HTML_ELEMENT(Shared)
 NS_DECLARE_NS_NEW_HTML_ELEMENT(SharedList)
 
 NS_DECLARE_NS_NEW_HTML_ELEMENT(Anchor)
 NS_DECLARE_NS_NEW_HTML_ELEMENT(Area)
 NS_DECLARE_NS_NEW_HTML_ELEMENT(Audio)
 NS_DECLARE_NS_NEW_HTML_ELEMENT(BR)
 NS_DECLARE_NS_NEW_HTML_ELEMENT(Body)
--- a/dom/html/nsHTMLContentSink.cpp
+++ b/dom/html/nsHTMLContentSink.cpp
@@ -78,31 +78,27 @@
 #include "mozAutoDocUpdate.h"
 #include "nsTextNode.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
 
-typedef nsGenericHTMLElement*
-  (*contentCreatorCallback)(already_AddRefed<mozilla::dom::NodeInfo>&&,
-                            FromParser aFromParser);
-
 nsGenericHTMLElement*
 NS_NewHTMLNOTUSEDElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                          FromParser aFromParser)
 {
   NS_NOTREACHED("The element ctor should never be called");
   return nullptr;
 }
 
 #define HTML_TAG(_tag, _classname, _interfacename) NS_NewHTML##_classname##Element,
 #define HTML_OTHER(_tag) NS_NewHTMLNOTUSEDElement,
-static const contentCreatorCallback sContentCreatorCallbacks[] = {
+static const HTMLContentCreatorFunction sHTMLContentCreatorFunctions[] = {
   NS_NewHTMLUnknownElement,
 #include "nsHTMLTagList.h"
 #undef HTML_TAG
 #undef HTML_OTHER
   NS_NewHTMLUnknownElement
 };
 
 class SinkContext;
@@ -274,17 +270,17 @@ already_AddRefed<nsGenericHTMLElement>
 CreateHTMLElement(uint32_t aNodeType,
                   already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                   FromParser aFromParser)
 {
   NS_ASSERTION(aNodeType <= NS_HTML_TAG_MAX ||
                aNodeType == eHTMLTag_userdefined,
                "aNodeType is out of bounds");
 
-  contentCreatorCallback cb = sContentCreatorCallbacks[aNodeType];
+  HTMLContentCreatorFunction cb = sHTMLContentCreatorFunctions[aNodeType];
 
   NS_ASSERTION(cb != NS_NewHTMLNOTUSEDElement,
                "Don't know how to construct tag element!");
 
   RefPtr<nsGenericHTMLElement> result = cb(Move(aNodeInfo), aFromParser);
 
   return result.forget();
 }
--- a/dom/svg/SVGElementFactory.cpp
+++ b/dom/svg/SVGElementFactory.cpp
@@ -10,56 +10,48 @@
 #include "mozilla/dom/NodeInfo.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/FromParser.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 // Hash table that maps nsIAtom* SVG tags to an offset index
-// within the array sContentCreatorCallbacks (offset by TABLE_VALUE_OFFSET)
+// within the array sSVGContentCreatorFunctions (offset by TABLE_VALUE_OFFSET)
 static PLHashTable* sTagAtomTable = nullptr;
 
 // We don't want to store 0 in the hash table as a return value of 0 from
 // PL_HashTableLookupConst indicates that the value is not found
 #define TABLE_VALUE_OFFSET 1
 
-#define SVG_TAG(_tag, _classname) \
-nsresult \
-NS_NewSVG##_classname##Element(nsIContent** aResult, \
-                               already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); \
-\
-static inline nsresult \
-Create##_classname##Element(nsIContent** aResult, \
-                            already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, \
-                            FromParser aFromParser) \
-{ \
-  return NS_NewSVG##_classname##Element(aResult, mozilla::Move(aNodeInfo)); \
-}
+#define SVG_TAG(_tag, _classname)                                              \
+  nsresult NS_NewSVG##_classname##Element(                                     \
+    nsIContent** aResult,                                                      \
+    already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);                     \
+                                                                               \
+  nsresult NS_NewSVG##_classname##Element(                                     \
+    nsIContent** aResult,                                                      \
+    already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,                      \
+    FromParser aFromParser)                                                    \
+  {                                                                            \
+    return NS_NewSVG##_classname##Element(aResult, mozilla::Move(aNodeInfo));  \
+  }
 
-#define SVG_FROM_PARSER_TAG(_tag, _classname) \
-nsresult \
-NS_NewSVG##_classname##Element(nsIContent** aResult, \
-                               already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, \
-                               FromParser aFromParser);
+#define SVG_FROM_PARSER_TAG(_tag, _classname)
+
 #include "SVGTagList.h"
 #undef SVG_TAG
 #undef SVG_FROM_PARSER_TAG
 
 nsresult
 NS_NewSVGElement(Element** aResult,
                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
-typedef nsresult
-  (*contentCreatorCallback)(nsIContent** aResult,
-                            already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
-                            FromParser aFromParser);
-
-static const contentCreatorCallback sContentCreatorCallbacks[] = {
-#define SVG_TAG(_tag, _classname) Create##_classname##Element,
+static const SVGContentCreatorFunction sSVGContentCreatorFunctions[] = {
+#define SVG_TAG(_tag, _classname) NS_NewSVG##_classname##Element,
 #define SVG_FROM_PARSER_TAG(_tag, _classname)  NS_NewSVG##_classname##Element,
 #include "SVGTagList.h"
 #undef SVG_TAG
 #undef SVG_FROM_PARSER_TAG
 };
 
 enum SVGTag {
 #define SVG_TAG(_tag, _classname) eSVGTag_##_tag,
@@ -119,19 +111,31 @@ NS_NewSVGElement(Element** aResult, alre
   void* tag = PL_HashTableLookupConst(sTagAtomTable, name);
   if (tag) {
     int32_t index = NS_PTR_TO_INT32(tag) - TABLE_VALUE_OFFSET;
     if (index < 0 || index >= eSVGTag_Count) {
       NS_WARNING("About to index out of array bounds - crashing instead");
       MOZ_CRASH();
     }
 
-    contentCreatorCallback cb = sContentCreatorCallbacks[index];
+    SVGContentCreatorFunction cb = sSVGContentCreatorFunctions[index];
 
     nsCOMPtr<nsIContent> content;
     nsresult rv = cb(getter_AddRefs(content), ni.forget(), aFromParser);
     *aResult = content.forget().take()->AsElement();
     return rv;
   }
 
   // if we don't know what to create, just create a standard svg element:
   return NS_NewSVGElement(aResult, ni.forget());
 }
+
+nsresult
+NS_NewSVGUnknownElement(nsIContent** aResult,
+                        already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
+                        FromParser aFromParser)
+{
+  RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
+  nsCOMPtr<Element> element;
+  nsresult rv = NS_NewSVGElement(getter_AddRefs(element), ni.forget());
+  element.forget(aResult);
+  return rv;
+}
--- a/dom/svg/SVGElementFactory.h
+++ b/dom/svg/SVGElementFactory.h
@@ -13,12 +13,37 @@ namespace mozilla {
 namespace dom {
 
 class SVGElementFactory {
 public:
   static void Init();
   static void Shutdown();
 };
 
+typedef nsresult (*SVGContentCreatorFunction)(
+  nsIContent** aResult,
+  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
+  mozilla::dom::FromParser aFromParser);
+
 } // namespace dom
 } // namespace mozilla
 
+#define SVG_TAG(_tag, _classname)                                              \
+  nsresult NS_NewSVG##_classname##Element(                                     \
+    nsIContent** aResult,                                                      \
+    already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,                      \
+    mozilla::dom::FromParser aFromParser);
+
+#define SVG_FROM_PARSER_TAG(_tag, _classname)                                  \
+  nsresult NS_NewSVG##_classname##Element(                                     \
+    nsIContent** aResult,                                                      \
+    already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,                      \
+    mozilla::dom::FromParser aFromParser);
+#include "SVGTagList.h"
+#undef SVG_TAG
+#undef SVG_FROM_PARSER_TAG
+
+nsresult
+NS_NewSVGUnknownElement(nsIContent** aResult,
+                        already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
+                        mozilla::dom::FromParser aFromParser);
+
 #endif /* mozilla_dom_SVGElementFactory_h */
--- a/dom/svg/SVGTagList.h
+++ b/dom/svg/SVGTagList.h
@@ -4,17 +4,24 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /******
 
   This file contains the list of all SVG tags.
 
   It is designed to be used as inline input to SVGElementFactory.cpp
-  *only* through the magic of C preprocessing.
+  through the magic of C preprocessing.
+
+  Additionally, it is consumed by the self-regeneration code in
+  ElementName.java from which nsHtml5ElementName.cpp/h is translated.
+  See parser/html/java/README.txt.
+
+  If you edit this list, you need to re-run ElementName.java
+  self-regeneration and the HTML parser Java to C++ translation.
 
   All entries must be enclosed in the macro SVG_TAG or SVG_FROM_PARSER_TAG
   which will have cruel and unusual things done to them.
 
   SVG_FROM_PARSER_TAG is used where the element creation method takes
   a FromParser argument, and SVG_TAG where it does not.
 
   It is recommended (but not strictly necessary) to keep all entries
--- a/dom/svg/moz.build
+++ b/dom/svg/moz.build
@@ -12,16 +12,17 @@ MOCHITEST_MANIFESTS += ['test/mochitest.
 EXPORTS += [
     'nsSVGClass.h',
     'nsSVGElement.h',
     'nsSVGFeatures.h',
     'SVGAttrValueWrapper.h',
     'SVGContentUtils.h',
     'SVGPreserveAspectRatio.h',
     'SVGStringList.h',
+    'SVGTagList.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'nsSVGAnimatedTransformList.h',
     'SVGAElement.h',
     'SVGAngle.h',
     'SVGAnimatedAngle.h',
     'SVGAnimatedBoolean.h',
@@ -37,16 +38,17 @@ EXPORTS.mozilla.dom += [
     'SVGAnimateTransformElement.h',
     'SVGAnimationElement.h',
     'SVGCircleElement.h',
     'SVGClipPathElement.h',
     'SVGComponentTransferFunctionElement.h',
     'SVGDefsElement.h',
     'SVGDescElement.h',
     'SVGDocument.h',
+    'SVGElementFactory.h',
     'SVGEllipseElement.h',
     'SVGFEBlendElement.h',
     'SVGFEColorMatrixElement.h',
     'SVGFEComponentTransferElement.h',
     'SVGFECompositeElement.h',
     'SVGFEConvolveMatrixElement.h',
     'SVGFEDiffuseLightingElement.h',
     'SVGFEDisplacementMapElement.h',
--- a/parser/html/java/README.txt
+++ b/parser/html/java/README.txt
@@ -1,46 +1,93 @@
 If this is your first time building the HTML5 parser, you need to execute the
 following commands (from this directory) to bootstrap the translation:
 
   make sync             # fetch remote source files and licenses
-  make translate        # perform the Java-to-C++ translation from the remote 
+  make translate        # perform the Java-to-C++ translation from the remote
                         # sources
   make named_characters # Generate tables for named character tokenization
 
 If you make changes to the translator or the javaparser, you can rebuild by
 retyping 'make' in this directory.  If you make changes to the HTML5 Java
-implementation, you can retranslate the Java sources from the htmlparser 
+implementation, you can retranslate the Java sources from the htmlparser
 repository by retyping 'make translate' in this directory.
 
 The makefile supports the following targets:
 
 sync_htmlparser:
-  Retrieves the HTML parser and Java to C++ translator sources from Mozilla's 
+  Retrieves the HTML parser and Java to C++ translator sources from Mozilla's
   htmlparser repository.
 sync_javaparser:
   Retrieves the javaparser sources from GitHub.
 sync:
   Runs both sync_javaparser and sync_htmlparser.
 javaparser:
-  Builds the javaparser library retrieved earlier by sync_javaparser. 
+  Builds the javaparser library retrieved earlier by sync_javaparser.
 translator:
-  Runs the javaparser target and then builds the Java to C++ translator from 
+  Runs the javaparser target and then builds the Java to C++ translator from
   sources retrieved earlier by sync_htmlparser.
 libs:
   The default target. Alias for translator
 translate:
-  Runs the translator target and then translates the HTML parser sources 
+  Runs the translator target and then translates the HTML parser sources
   retrieved by sync_htmlparser copying the Java sources to ../javasrc.
-translate_from_snapshot: 
-  Runs the translator target and then translates the HTML parser sources 
+translate_from_snapshot:
+  Runs the translator target and then translates the HTML parser sources
   stored in ../javasrc.
 named_characters:
   Generates data tables for named character tokenization.
 clean_javaparser:
   Removes the build products of the javaparser target.
 clean_htmlparser:
   Removes the build products of the translator target.
 clean:
   Runs both clean_javaparser and clean_htmlparser.
 
+## How to add an attribute
+
+# starting from the root of a mozilla-central checkout
+cd parser/html/java/
+make sync
+# now you have a clone of https://hg.mozilla.org/projects/htmlparser/ in parser/html/java/htmlparser/
+cd htmlparser/src/
+$EDITOR nu/validator/htmlparser/impl/AttributeName.java
+# Search for the word "uncomment" and uncomment stuff according to the comments that talk about uncommenting
+# Duplicate the declaration a normal attribute (nothings special in SVG mode, etc.). Let's use "alt", since it's the first one.
+# In the duplicate, replace ALT with the new name in all caps and "alt" with the new name in quotes in lower case.
+# Search for "ALT,", duplicate that line and change the duplicate to say the new name in all caps followed by comma.
+# Save.
+javac nu/validator/htmlparser/impl/AttributeName.java
+java nu.validator.htmlparser.impl.AttributeName
+# Copy and paste the output into nu/validator/htmlparser/impl/AttributeName.java replacing the text below the comment "START GENERATED CODE" and above the very last "}".
+# Recomment the bits that you uncommented earlier.
+# Save.
+cd ../.. # Back to parser/html/java/
+make translate
+cd ../../..
+./mach clang-format
+
+## How to add an element
+
+# First, add an entry to parser/htmlparser/nsHTMLTagList.h or dom/svg/SVGTagList.h!
+# Then, starting from the root of a mozilla-central checkout
+cd parser/html/java/
+make sync
+# now you have a clone of https://hg.mozilla.org/projects/htmlparser/ in parser/html/java/htmlparser/
+cd htmlparser/src/
+$EDITOR nu/validator/htmlparser/impl/ElementName.java
+# Search for the word "uncomment" and uncomment stuff according to the comments that talk about uncommenting
+# Duplicate the declaration a normal element. Let's use "bdo", since it's the first normal one.
+# In the duplicate, replace BDO with the new name in all caps and "bdo" with the new name in quotes in lower case (twice).
+# Search for "BDO,", duplicate that line and change the duplicate to say the new name in all caps followed by comma.
+# Save.
+javac nu/validator/htmlparser/impl/ElementName.java
+java nu.validator.htmlparser.impl.ElementName ../../../../../parser/htmlparser/nsHTMLTagList.h ../../../../../dom/svg/SVGTagList.h
+# Copy and paste the output into nu/validator/htmlparser/impl/ElementName.java replacing the text below the comment "START GENERATED CODE" and above the very last "}".
+# Recomment the bits that you uncommented earlier.
+# Save.
+cd ../.. # Back to parser/html/java/
+make translate
+cd ../../..
+./mach clang-format
+
 Ben Newman (23 September 2009)
-Henri Sivonen (11 August 2016)
+Henri Sivonen (10 August 2017)
--- a/parser/html/javasrc/ElementName.java
+++ b/parser/html/javasrc/ElementName.java
@@ -17,53 +17,69 @@
  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
 
 package nu.validator.htmlparser.impl;
 
+// uncomment to regenerate self
+//import java.io.BufferedReader;
+//import java.io.File;
+//import java.io.FileInputStream;
+//import java.io.IOException;
+//import java.io.InputStreamReader;
+//import java.util.Arrays;
+//import java.util.Collections;
+//import java.util.HashMap;
+//import java.util.LinkedList;
+//import java.util.List;
+//import java.util.Map;
+//import java.util.Map.Entry;
+//import java.util.regex.Matcher;
+//import java.util.regex.Pattern;
+
 import nu.validator.htmlparser.annotation.Inline;
 import nu.validator.htmlparser.annotation.Local;
 import nu.validator.htmlparser.annotation.NoLength;
 import nu.validator.htmlparser.annotation.Unsigned;
 import nu.validator.htmlparser.common.Interner;
 
 public final class ElementName
-// uncomment when regenerating self
+        // uncomment when regenerating self
 //        implements Comparable<ElementName>
 {
 
     /**
      * The mask for extracting the dispatch group.
      */
     public static final int GROUP_MASK = 127;
 
     /**
-     * Indicates that the element is not a pre-interned element. Forbidden
-     * on preinterned elements.
+     * Indicates that the element is not a pre-interned element. Forbidden on
+     * preinterned elements.
      */
     public static final int NOT_INTERNED = (1 << 30);
 
     /**
-     * Indicates that the element is in the "special" category. This bit
-     * should not be pre-set on MathML or SVG specials--only on HTML specials.
+     * Indicates that the element is in the "special" category. This bit should
+     * not be pre-set on MathML or SVG specials--only on HTML specials.
      */
     public static final int SPECIAL = (1 << 29);
 
     /**
      * The element is foster-parenting. This bit should be pre-set on elements
      * that are foster-parenting as HTML.
      */
     public static final int FOSTER_PARENTING = (1 << 28);
 
     /**
-     * The element is scoping. This bit should be pre-set on elements
-     * that are scoping as HTML.
+     * The element is scoping. This bit should be pre-set on elements that are
+     * scoping as HTML.
      */
     public static final int SCOPING = (1 << 27);
 
     /**
      * The element is scoping as SVG.
      */
     public static final int SCOPING_AS_SVG = (1 << 26);
 
@@ -81,29 +97,41 @@ public final class ElementName
      * The element has an optional end tag.
      */
     public static final int OPTIONAL_END_TAG = (1 << 23);
 
     private @Local String name;
 
     private @Local String camelCaseName;
 
+    // CPPONLY: private @HtmlCreator Object htmlCreator;
+
+    // CPPONLY: private @SvgCreator Object svgCreator;
+
     /**
      * The lowest 7 bits are the dispatch group. The high bits are flags.
      */
     public final int flags;
 
     @Inline public @Local String getName() {
         return name;
     }
 
     @Inline public @Local String getCamelCaseName() {
         return camelCaseName;
     }
 
+    // CPPONLY: @Inline public @HtmlCreator Object getHtmlCreator() {
+    // CPPONLY: return htmlCreator;
+    // CPPONLY: }
+
+    // CPPONLY: @Inline public @SvgCreator Object getSvgCreator() {
+    // CPPONLY: return svgCreator;
+    // CPPONLY: }
+
     @Inline public int getFlags() {
         return flags;
     }
 
     @Inline public int getGroup() {
         return flags & ElementName.GROUP_MASK;
     }
 
@@ -124,17 +152,18 @@ public final class ElementName
             } else {
                 return i;
             }
         }
 
         return -1;
     }
 
-    @Inline static ElementName elementNameByBuffer(@NoLength char[] buf, int offset, int length, Interner interner) {
+    @Inline static ElementName elementNameByBuffer(@NoLength char[] buf,
+            int offset, int length, Interner interner) {
         @Unsigned int hash = ElementName.bufToHash(buf, length);
         int[] hashes;
         hashes = ElementName.ELEMENT_HASHES;
         int index = levelOrderBinarySearch(hashes, hash);
         if (index < 0) {
             return null;
         } else {
             ElementName elementName = ElementName.ELEMENT_NAMES[index];
@@ -149,17 +178,18 @@ public final class ElementName
     /**
      * This method has to return a unique positive integer for each well-known
      * lower-cased element name.
      *
      * @param buf
      * @param len
      * @return
      */
-    @Inline private static @Unsigned int bufToHash(@NoLength char[] buf, int length) {
+    @Inline private static @Unsigned int bufToHash(@NoLength char[] buf,
+            int length) {
         @Unsigned int len = length;
         @Unsigned int first = buf[0];
         first <<= 19;
         @Unsigned int second = 1 << 23;
         @Unsigned int third = 0;
         @Unsigned int fourth = 0;
         @Unsigned int fifth = 0;
         if (length >= 4) {
@@ -179,52 +209,163 @@ public final class ElementName
         } else if (length == 2) {
             second = buf[1];
             second <<= 24;
         }
         return len + first + second + third + fourth + fifth;
     }
 
     private ElementName(@Local String name, @Local String camelCaseName,
+            // CPPONLY: @HtmlCreator Object htmlCreator, @SvgCreator Object
+            // CPPONLY: svgCreator,
             int flags) {
         this.name = name;
         this.camelCaseName = camelCaseName;
+        // CPPONLY: this.htmlCreator = htmlCreator;
+        // CPPONLY: this.svgCreator = svgCreator;
         this.flags = flags;
     }
 
     public ElementName() {
         this.name = null;
         this.camelCaseName = null;
+        // CPPONLY: this.htmlCreator = NS_NewHTMLUnknownElement;
+        // CPPONLY: this.svgCreator = NS_NewSVGUnknownElement;
         this.flags = TreeBuilder.OTHER | NOT_INTERNED;
     }
 
     public void destructor() {
         // The translator adds refcount debug code here.
     }
 
-    @Inline public void setNameForNonInterned(@Local String name) {
+    @Inline public void setNameForNonInterned(@Local String name
+    // CPPONLY: , boolean custom
+    ) {
         // No need to worry about refcounting the local name, because in the
         // C++ case the scoped atom table remembers its own atoms.
         this.name = name;
         this.camelCaseName = name;
+        // CPPONLY: if (custom) {
+        // CPPONLY: this.htmlCreator = NS_NewCustomElement;
+        // CPPONLY: } else {
+        // CPPONLY: this.htmlCreator = NS_NewHTMLUnknownElement;
+        // CPPONLY: }
         // The assertion below relies on TreeBuilder.OTHER being zero!
         // TreeBuilder.OTHER isn't referenced here, because it would create
         // a circular C++ header dependency given that this method is inlined.
         assert this.flags == ElementName.NOT_INTERNED;
     }
 
-    public static final ElementName ANNOTATION_XML = new ElementName("annotation-xml", "annotation-xml", TreeBuilder.ANNOTATION_XML | SCOPING_AS_MATHML);
+    // CPPONLY: @Inline public boolean isCustom() {
+    // CPPONLY: return this.htmlCreator == NS_NewCustomElement;
+    // CPPONLY: }
+
+    public static final ElementName ANNOTATION_XML = new ElementName(
+            "annotation-xml", "annotation-xml",
+            // CPPONLY: NS_NewHTMLUnknownElement, NS_NewSVGUnknownElement,
+            TreeBuilder.ANNOTATION_XML | SCOPING_AS_MATHML);
 
     // START CODE ONLY USED FOR GENERATING CODE uncomment and run to regenerate
 
+//    private static final Pattern HTML_TAG_DEF = Pattern.compile(
+//            "^HTML_TAG\\(([^,]+),\\s*([^,]+),\\s*[^,]+\\).*$");
+//
+//    private static final Pattern HTML_HTMLELEMENT_TAG_DEF = Pattern.compile(
+//            "^HTML_HTMLELEMENT_TAG\\(([^\\)]+)\\).*$");
+//
+//    private static final Pattern SVG_TAG_DEF = Pattern.compile(
+//            "^SVG_(?:FROM_PARSER_)?TAG\\(([^,]+),\\s*([^\\)]+)\\).*$");
+//
+//    private static final Map<String, String> htmlMap = new HashMap<String, String>();
+//
+//    private static final Map<String, String> svgMap = new HashMap<String, String>();
+//
+//    private static void ingestHtmlTags(File htmlList) throws IOException {
+//        // This doesn't need to be efficient, so let's make it easy to write.
+//        BufferedReader htmlReader = new BufferedReader(
+//                new InputStreamReader(new FileInputStream(htmlList), "utf-8"));
+//        try {
+//            String line;
+//            while ((line = htmlReader.readLine()) != null) {
+//                if (!line.startsWith("HTML_")) {
+//                    continue;
+//                }
+//                if (line.startsWith("HTML_OTHER")) {
+//                    continue;
+//                }
+//                Matcher m = HTML_TAG_DEF.matcher(line);
+//                if (m.matches()) {
+//                    String iface = m.group(2);
+//                    if ("Unknown".equals(iface)) {
+//                        continue;
+//                    }
+//                    htmlMap.put(m.group(1), "NS_NewHTML" + iface + "Element");
+//                } else {
+//                    m = HTML_HTMLELEMENT_TAG_DEF.matcher(line);
+//                    if (!m.matches()) {
+//                        throw new RuntimeException(
+//                                "Malformed HTML element definition: " + line);
+//                    }
+//                    htmlMap.put(m.group(1), "NS_NewHTMLElement");
+//                }
+//            }
+//        } finally {
+//            htmlReader.close();
+//        }
+//    }
+//
+//    private static void ingestSvgTags(File svgList) throws IOException {
+//        // This doesn't need to be efficient, so let's make it easy to write.
+//        BufferedReader svgReader = new BufferedReader(
+//                new InputStreamReader(new FileInputStream(svgList), "utf-8"));
+//        try {
+//            String line;
+//            while ((line = svgReader.readLine()) != null) {
+//                if (!line.startsWith("SVG_")) {
+//                    continue;
+//                }
+//                Matcher m = SVG_TAG_DEF.matcher(line);
+//                if (!m.matches()) {
+//                    throw new RuntimeException(
+//                            "Malformed SVG element definition: " + line);
+//                }
+//                String name = m.group(1);
+//                if ("svgSwitch".equals(name)) {
+//                    name = "switch";
+//                }
+//                svgMap.put(name, "NS_NewSVG" + m.group(2) + "Element");
+//            }
+//        } finally {
+//            svgReader.close();
+//        }
+//    }
+//
+//    private static String htmlCreator(String name) {
+//        String creator = htmlMap.remove(name);
+//        if (creator != null) {
+//            return creator;
+//        }
+//        return "NS_NewHTMLUnknownElement";
+//    }
+//
+//    private static String svgCreator(String name) {
+//        String creator = svgMap.remove(name);
+//        if (creator != null) {
+//            return creator;
+//        }
+//        return "NS_NewSVGUnknownElement";
+//    }
+//
 //    /**
 //     * @see java.lang.Object#toString()
 //     */
 //    @Override public String toString() {
-//        return "(\"" + name + "\", \"" + camelCaseName + "\", " + decomposedFlags() + ")";
+//        return "(\"" + name + "\", \"" + camelCaseName + "\", \n// CPP"
+//                + "ONLY: " + htmlCreator(name) + ",\n//CPP" + "ONLY: "
+//                + svgCreator(camelCaseName) + ", \n" + decomposedFlags() + ")";
 //    }
 //
 //    private String decomposedFlags() {
 //        StringBuilder buf = new StringBuilder("TreeBuilder.");
 //        buf.append(treeBuilderGroupToName());
 //        if ((flags & SPECIAL) != 0) {
 //            buf.append(" | SPECIAL");
 //        }
@@ -247,17 +388,19 @@ public final class ElementName
 //    }
 //
 //    private String constName() {
 //        char[] buf = new char[name.length()];
 //        for (int i = 0; i < name.length(); i++) {
 //            char c = name.charAt(i);
 //            if (c == '-') {
 //                if (!"annotation-xml".equals(name)) {
-//                    throw new RuntimeException("Non-annotation-xml element name with hyphen: " + name);
+//                    throw new RuntimeException(
+//                            "Non-annotation-xml element name with hyphen: "
+//                                    + name);
 //                }
 //                buf[i] = '_';
 //            } else if (c >= '0' && c <= '9') {
 //                buf[i] = c;
 //            } else {
 //                buf[i] = (char) (c - 0x20);
 //            }
 //        }
@@ -307,18 +450,16 @@ public final class ElementName
 //            case TreeBuilder.FRAME:
 //                return "FRAME";
 //            case TreeBuilder.FRAMESET:
 //                return "FRAMESET";
 //            case TreeBuilder.IMAGE:
 //                return "IMAGE";
 //            case TreeBuilder.INPUT:
 //                return "INPUT";
-//            case TreeBuilder.ISINDEX:
-//                return "ISINDEX";
 //            case TreeBuilder.LI:
 //                return "LI";
 //            case TreeBuilder.LINK_OR_BASEFONT_OR_BGSOUND:
 //                return "LINK_OR_BASEFONT_OR_BGSOUND";
 //            case TreeBuilder.MATH:
 //                return "MATH";
 //            case TreeBuilder.META:
 //                return "META";
@@ -439,668 +580,1272 @@ public final class ElementName
 //        if (depth > 0) {
 //            fillLevelOrderArray(sorted, depth - 1, rootIdx * 2 + 2, levelOrder);
 //        }
 //    }
 //
 //    /**
 //     * Regenerate self
 //     *
-//     * @param args
+//     * The args should be the paths to m-c files
+//     * parser/htmlparser/nsHTMLTagList.h and dom/svg/SVGTagList.h.
 //     */
 //    public static void main(String[] args) {
+//        File htmlList = new File(args[0]);
+//        File svgList = new File(args[1]);
+//        try {
+//            ingestHtmlTags(htmlList);
+//        } catch (IOException e) {
+//            throw new RuntimeException(e);
+//        }
+//        try {
+//            ingestSvgTags(svgList);
+//        } catch (IOException e) {
+//            throw new RuntimeException(e);
+//        }
+//
 //        Arrays.sort(ELEMENT_NAMES);
 //        for (int i = 0; i < ELEMENT_NAMES.length; i++) {
 //            int hash = ELEMENT_NAMES[i].hash();
 //            if (hash < 0) {
 //                System.err.println("Negative hash: " + ELEMENT_NAMES[i].name);
 //                return;
 //            }
 //            for (int j = i + 1; j < ELEMENT_NAMES.length; j++) {
 //                if (hash == ELEMENT_NAMES[j].hash()) {
-//                    System.err.println("Hash collision: " + ELEMENT_NAMES[i].name
-//                            + ", " + ELEMENT_NAMES[j].name);
+//                    System.err.println(
+//                            "Hash collision: " + ELEMENT_NAMES[i].name + ", "
+//                                    + ELEMENT_NAMES[j].name);
 //                    return;
 //                }
 //            }
 //        }
 //        for (int i = 0; i < ELEMENT_NAMES.length; i++) {
 //            ElementName el = ELEMENT_NAMES[i];
-//            System.out.println("public static final ElementName "
-//                    + el.constName() + " = new ElementName" + el.toString()
-//                    + ";");
+//            System.out.println(
+//                    "public static final ElementName " + el.constName()
+//                            + " = new ElementName" + el.toString() + ";");
 //        }
 //
 //        LinkedList<ElementName> sortedNames = new LinkedList<ElementName>();
 //        Collections.addAll(sortedNames, ELEMENT_NAMES);
 //        ElementName[] levelOrder = new ElementName[ELEMENT_NAMES.length];
-//        int bstDepth = (int) Math.ceil(Math.log(ELEMENT_NAMES.length) / Math.log(2));
+//        int bstDepth = (int) Math.ceil(
+//                Math.log(ELEMENT_NAMES.length) / Math.log(2));
 //        fillLevelOrderArray(sortedNames, bstDepth, 0, levelOrder);
 //
-//        System.out.println("private final static @NoLength ElementName[] ELEMENT_NAMES = {");
+//        System.out.println(
+//                "private final static @NoLength ElementName[] ELEMENT_NAMES = {");
 //        for (int i = 0; i < levelOrder.length; i++) {
 //            ElementName el = levelOrder[i];
 //            System.out.println(el.constName() + ",");
 //        }
 //        System.out.println("};");
 //        System.out.println("private final static int[] ELEMENT_HASHES = {");
 //        for (int i = 0; i < levelOrder.length; i++) {
 //            ElementName el = levelOrder[i];
 //            System.out.println(Integer.toString(el.hash()) + ",");
 //        }
 //        System.out.println("};");
+//
+//        for (Entry<String, String> entry : htmlMap.entrySet()) {
+//            System.err.println("Missing HTML element: " + entry.getKey());
+//        }
+//        for (Entry<String, String> entry : svgMap.entrySet()) {
+//            System.err.println("Missing SVG element: " + entry.getKey());
+//        }
 //    }
 
     // START GENERATED CODE
-    public static final ElementName BIG = new ElementName("big", "big", TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-    public static final ElementName BDO = new ElementName("bdo", "bdo", TreeBuilder.OTHER);
-    public static final ElementName COL = new ElementName("col", "col", TreeBuilder.COL | SPECIAL);
-    public static final ElementName DEL = new ElementName("del", "del", TreeBuilder.OTHER);
-    public static final ElementName DFN = new ElementName("dfn", "dfn", TreeBuilder.OTHER);
-    public static final ElementName DIR = new ElementName("dir", "dir", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName DIV = new ElementName("div", "div", TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
-    public static final ElementName IMG = new ElementName("img", "img", TreeBuilder.IMG | SPECIAL);
-    public static final ElementName INS = new ElementName("ins", "ins", TreeBuilder.OTHER);
-    public static final ElementName KBD = new ElementName("kbd", "kbd", TreeBuilder.OTHER);
-    public static final ElementName MAP = new ElementName("map", "map", TreeBuilder.OTHER);
-    public static final ElementName NAV = new ElementName("nav", "nav", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName PRE = new ElementName("pre", "pre", TreeBuilder.PRE_OR_LISTING | SPECIAL);
-    public static final ElementName A = new ElementName("a", "a", TreeBuilder.A);
-    public static final ElementName B = new ElementName("b", "b", TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-    public static final ElementName RTC = new ElementName("rtc", "rtc", TreeBuilder.RB_OR_RTC | OPTIONAL_END_TAG);
-    public static final ElementName SUB = new ElementName("sub", "sub", TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
-    public static final ElementName SVG = new ElementName("svg", "svg", TreeBuilder.SVG);
-    public static final ElementName SUP = new ElementName("sup", "sup", TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
-    public static final ElementName SET = new ElementName("set", "set", TreeBuilder.OTHER);
-    public static final ElementName USE = new ElementName("use", "use", TreeBuilder.OTHER);
-    public static final ElementName VAR = new ElementName("var", "var", TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
-    public static final ElementName G = new ElementName("g", "g", TreeBuilder.OTHER);
-    public static final ElementName WBR = new ElementName("wbr", "wbr", TreeBuilder.AREA_OR_WBR | SPECIAL);
-    public static final ElementName XMP = new ElementName("xmp", "xmp", TreeBuilder.XMP | SPECIAL);
-    public static final ElementName I = new ElementName("i", "i", TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-    public static final ElementName P = new ElementName("p", "p", TreeBuilder.P | SPECIAL | OPTIONAL_END_TAG);
-    public static final ElementName Q = new ElementName("q", "q", TreeBuilder.OTHER);
-    public static final ElementName S = new ElementName("s", "s", TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-    public static final ElementName U = new ElementName("u", "u", TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-    public static final ElementName H1 = new ElementName("h1", "h1", TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
-    public static final ElementName H2 = new ElementName("h2", "h2", TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
-    public static final ElementName H3 = new ElementName("h3", "h3", TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
-    public static final ElementName H4 = new ElementName("h4", "h4", TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
-    public static final ElementName H5 = new ElementName("h5", "h5", TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
-    public static final ElementName H6 = new ElementName("h6", "h6", TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
-    public static final ElementName AREA = new ElementName("area", "area", TreeBuilder.AREA_OR_WBR | SPECIAL);
-    public static final ElementName FEFUNCA = new ElementName("fefunca", "feFuncA", TreeBuilder.OTHER);
-    public static final ElementName METADATA = new ElementName("metadata", "metadata", TreeBuilder.OTHER);
-    public static final ElementName META = new ElementName("meta", "meta", TreeBuilder.META | SPECIAL);
-    public static final ElementName TEXTAREA = new ElementName("textarea", "textarea", TreeBuilder.TEXTAREA | SPECIAL);
-    public static final ElementName FEFUNCB = new ElementName("fefuncb", "feFuncB", TreeBuilder.OTHER);
-    public static final ElementName RB = new ElementName("rb", "rb", TreeBuilder.RB_OR_RTC | OPTIONAL_END_TAG);
-    public static final ElementName DESC = new ElementName("desc", "desc", TreeBuilder.FOREIGNOBJECT_OR_DESC | SCOPING_AS_SVG);
-    public static final ElementName DD = new ElementName("dd", "dd", TreeBuilder.DD_OR_DT | SPECIAL | OPTIONAL_END_TAG);
-    public static final ElementName BGSOUND = new ElementName("bgsound", "bgsound", TreeBuilder.LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
-    public static final ElementName EMBED = new ElementName("embed", "embed", TreeBuilder.EMBED | SPECIAL);
-    public static final ElementName FEBLEND = new ElementName("feblend", "feBlend", TreeBuilder.OTHER);
-    public static final ElementName FEFLOOD = new ElementName("feflood", "feFlood", TreeBuilder.OTHER);
-    public static final ElementName HEAD = new ElementName("head", "head", TreeBuilder.HEAD | SPECIAL | OPTIONAL_END_TAG);
-    public static final ElementName LEGEND = new ElementName("legend", "legend", TreeBuilder.OTHER);
-    public static final ElementName NOEMBED = new ElementName("noembed", "noembed", TreeBuilder.NOEMBED | SPECIAL);
-    public static final ElementName TD = new ElementName("td", "td", TreeBuilder.TD_OR_TH | SPECIAL | SCOPING | OPTIONAL_END_TAG);
-    public static final ElementName THEAD = new ElementName("thead", "thead", TreeBuilder.TBODY_OR_THEAD_OR_TFOOT | SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
-    public static final ElementName ASIDE = new ElementName("aside", "aside", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName ARTICLE = new ElementName("article", "article", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName ANIMATE = new ElementName("animate", "animate", TreeBuilder.OTHER);
-    public static final ElementName BASE = new ElementName("base", "base", TreeBuilder.BASE | SPECIAL);
-    public static final ElementName BLOCKQUOTE = new ElementName("blockquote", "blockquote", TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
-    public static final ElementName CODE = new ElementName("code", "code", TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-    public static final ElementName CIRCLE = new ElementName("circle", "circle", TreeBuilder.OTHER);
-    public static final ElementName CITE = new ElementName("cite", "cite", TreeBuilder.OTHER);
-    public static final ElementName ELLIPSE = new ElementName("ellipse", "ellipse", TreeBuilder.OTHER);
-    public static final ElementName FETURBULENCE = new ElementName("feturbulence", "feTurbulence", TreeBuilder.OTHER);
-    public static final ElementName FEMERGENODE = new ElementName("femergenode", "feMergeNode", TreeBuilder.OTHER);
-    public static final ElementName FEIMAGE = new ElementName("feimage", "feImage", TreeBuilder.OTHER);
-    public static final ElementName FEMERGE = new ElementName("femerge", "feMerge", TreeBuilder.OTHER);
-    public static final ElementName FETILE = new ElementName("fetile", "feTile", TreeBuilder.OTHER);
-    public static final ElementName FRAME = new ElementName("frame", "frame", TreeBuilder.FRAME | SPECIAL);
-    public static final ElementName FIGURE = new ElementName("figure", "figure", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName FECOMPOSITE = new ElementName("fecomposite", "feComposite", TreeBuilder.OTHER);
-    public static final ElementName IMAGE = new ElementName("image", "image", TreeBuilder.IMAGE);
-    public static final ElementName IFRAME = new ElementName("iframe", "iframe", TreeBuilder.IFRAME | SPECIAL);
-    public static final ElementName LINE = new ElementName("line", "line", TreeBuilder.OTHER);
-    public static final ElementName MARQUEE = new ElementName("marquee", "marquee", TreeBuilder.MARQUEE_OR_APPLET | SPECIAL | SCOPING);
-    public static final ElementName POLYLINE = new ElementName("polyline", "polyline", TreeBuilder.OTHER);
-    public static final ElementName PICTURE = new ElementName("picture", "picture", TreeBuilder.OTHER);
-    public static final ElementName SOURCE = new ElementName("source", "source", TreeBuilder.PARAM_OR_SOURCE_OR_TRACK);
-    public static final ElementName STRIKE = new ElementName("strike", "strike", TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-    public static final ElementName STYLE = new ElementName("style", "style", TreeBuilder.STYLE | SPECIAL);
-    public static final ElementName TABLE = new ElementName("table", "table", TreeBuilder.TABLE | SPECIAL | FOSTER_PARENTING | SCOPING);
-    public static final ElementName TITLE = new ElementName("title", "title", TreeBuilder.TITLE | SPECIAL | SCOPING_AS_SVG);
-    public static final ElementName TIME = new ElementName("time", "time", TreeBuilder.OTHER);
-    public static final ElementName TEMPLATE = new ElementName("template", "template", TreeBuilder.TEMPLATE | SPECIAL | SCOPING);
-    public static final ElementName ALTGLYPHDEF = new ElementName("altglyphdef", "altGlyphDef", TreeBuilder.OTHER);
-    public static final ElementName GLYPHREF = new ElementName("glyphref", "glyphRef", TreeBuilder.OTHER);
-    public static final ElementName DIALOG = new ElementName("dialog", "dialog", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName FEFUNCG = new ElementName("fefuncg", "feFuncG", TreeBuilder.OTHER);
-    public static final ElementName FEDIFFUSELIGHTING = new ElementName("fediffuselighting", "feDiffuseLighting", TreeBuilder.OTHER);
-    public static final ElementName FESPECULARLIGHTING = new ElementName("fespecularlighting", "feSpecularLighting", TreeBuilder.OTHER);
-    public static final ElementName LISTING = new ElementName("listing", "listing", TreeBuilder.PRE_OR_LISTING | SPECIAL);
-    public static final ElementName STRONG = new ElementName("strong", "strong", TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-    public static final ElementName ALTGLYPH = new ElementName("altglyph", "altGlyph", TreeBuilder.OTHER);
-    public static final ElementName CLIPPATH = new ElementName("clippath", "clipPath", TreeBuilder.OTHER);
-    public static final ElementName MGLYPH = new ElementName("mglyph", "mglyph", TreeBuilder.MGLYPH_OR_MALIGNMARK);
-    public static final ElementName MATH = new ElementName("math", "math", TreeBuilder.MATH);
-    public static final ElementName MPATH = new ElementName("mpath", "mpath", TreeBuilder.OTHER);
-    public static final ElementName PATH = new ElementName("path", "path", TreeBuilder.OTHER);
-    public static final ElementName TH = new ElementName("th", "th", TreeBuilder.TD_OR_TH | SPECIAL | SCOPING | OPTIONAL_END_TAG);
-    public static final ElementName SWITCH = new ElementName("switch", "switch", TreeBuilder.OTHER);
-    public static final ElementName TEXTPATH = new ElementName("textpath", "textPath", TreeBuilder.OTHER);
-    public static final ElementName LI = new ElementName("li", "li", TreeBuilder.LI | SPECIAL | OPTIONAL_END_TAG);
-    public static final ElementName MI = new ElementName("mi", "mi", TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
-    public static final ElementName LINK = new ElementName("link", "link", TreeBuilder.LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
-    public static final ElementName MARK = new ElementName("mark", "mark", TreeBuilder.OTHER);
-    public static final ElementName MALIGNMARK = new ElementName("malignmark", "malignmark", TreeBuilder.MGLYPH_OR_MALIGNMARK);
-    public static final ElementName MASK = new ElementName("mask", "mask", TreeBuilder.OTHER);
-    public static final ElementName TRACK = new ElementName("track", "track", TreeBuilder.PARAM_OR_SOURCE_OR_TRACK | SPECIAL);
-    public static final ElementName DL = new ElementName("dl", "dl", TreeBuilder.UL_OR_OL_OR_DL | SPECIAL);
-    public static final ElementName HTML = new ElementName("html", "html", TreeBuilder.HTML | SPECIAL | SCOPING | OPTIONAL_END_TAG);
-    public static final ElementName OL = new ElementName("ol", "ol", TreeBuilder.UL_OR_OL_OR_DL | SPECIAL);
-    public static final ElementName LABEL = new ElementName("label", "label", TreeBuilder.OTHER);
-    public static final ElementName UL = new ElementName("ul", "ul", TreeBuilder.UL_OR_OL_OR_DL | SPECIAL);
-    public static final ElementName SMALL = new ElementName("small", "small", TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-    public static final ElementName SYMBOL = new ElementName("symbol", "symbol", TreeBuilder.OTHER);
-    public static final ElementName ALTGLYPHITEM = new ElementName("altglyphitem", "altGlyphItem", TreeBuilder.OTHER);
-    public static final ElementName ANIMATETRANSFORM = new ElementName("animatetransform", "animateTransform", TreeBuilder.OTHER);
-    public static final ElementName ACRONYM = new ElementName("acronym", "acronym", TreeBuilder.OTHER);
-    public static final ElementName EM = new ElementName("em", "em", TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-    public static final ElementName FORM = new ElementName("form", "form", TreeBuilder.FORM | SPECIAL);
-    public static final ElementName MENUITEM = new ElementName("menuitem", "menuitem", TreeBuilder.MENUITEM);
-    public static final ElementName PARAM = new ElementName("param", "param", TreeBuilder.PARAM_OR_SOURCE_OR_TRACK | SPECIAL);
-    public static final ElementName ANIMATEMOTION = new ElementName("animatemotion", "animateMotion", TreeBuilder.OTHER);
-    public static final ElementName BUTTON = new ElementName("button", "button", TreeBuilder.BUTTON | SPECIAL);
-    public static final ElementName CAPTION = new ElementName("caption", "caption", TreeBuilder.CAPTION | SPECIAL | SCOPING);
-    public static final ElementName FIGCAPTION = new ElementName("figcaption", "figcaption", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName MN = new ElementName("mn", "mn", TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
-    public static final ElementName KEYGEN = new ElementName("keygen", "keygen", TreeBuilder.KEYGEN);
-    public static final ElementName MAIN = new ElementName("main", "main", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName OPTION = new ElementName("option", "option", TreeBuilder.OPTION | OPTIONAL_END_TAG);
-    public static final ElementName POLYGON = new ElementName("polygon", "polygon", TreeBuilder.OTHER);
-    public static final ElementName PATTERN = new ElementName("pattern", "pattern", TreeBuilder.OTHER);
-    public static final ElementName SPAN = new ElementName("span", "span", TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
-    public static final ElementName SECTION = new ElementName("section", "section", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName TSPAN = new ElementName("tspan", "tspan", TreeBuilder.OTHER);
-    public static final ElementName AUDIO = new ElementName("audio", "audio", TreeBuilder.OTHER);
-    public static final ElementName MO = new ElementName("mo", "mo", TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
-    public static final ElementName VIDEO = new ElementName("video", "video", TreeBuilder.OTHER);
-    public static final ElementName COLGROUP = new ElementName("colgroup", "colgroup", TreeBuilder.COLGROUP | SPECIAL | OPTIONAL_END_TAG);
-    public static final ElementName FEDISPLACEMENTMAP = new ElementName("fedisplacementmap", "feDisplacementMap", TreeBuilder.OTHER);
-    public static final ElementName HGROUP = new ElementName("hgroup", "hgroup", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName RP = new ElementName("rp", "rp", TreeBuilder.RT_OR_RP | OPTIONAL_END_TAG);
-    public static final ElementName OPTGROUP = new ElementName("optgroup", "optgroup", TreeBuilder.OPTGROUP | OPTIONAL_END_TAG);
-    public static final ElementName SAMP = new ElementName("samp", "samp", TreeBuilder.OTHER);
-    public static final ElementName STOP = new ElementName("stop", "stop", TreeBuilder.OTHER);
-    public static final ElementName BR = new ElementName("br", "br", TreeBuilder.BR | SPECIAL);
-    public static final ElementName ABBR = new ElementName("abbr", "abbr", TreeBuilder.OTHER);
-    public static final ElementName ANIMATECOLOR = new ElementName("animatecolor", "animateColor", TreeBuilder.OTHER);
-    public static final ElementName CENTER = new ElementName("center", "center", TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
-    public static final ElementName HR = new ElementName("hr", "hr", TreeBuilder.HR | SPECIAL);
-    public static final ElementName FEFUNCR = new ElementName("fefuncr", "feFuncR", TreeBuilder.OTHER);
-    public static final ElementName FECOMPONENTTRANSFER = new ElementName("fecomponenttransfer", "feComponentTransfer", TreeBuilder.OTHER);
-    public static final ElementName FILTER = new ElementName("filter", "filter", TreeBuilder.OTHER);
-    public static final ElementName FOOTER = new ElementName("footer", "footer", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName FEGAUSSIANBLUR = new ElementName("fegaussianblur", "feGaussianBlur", TreeBuilder.OTHER);
-    public static final ElementName HEADER = new ElementName("header", "header", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName MARKER = new ElementName("marker", "marker", TreeBuilder.OTHER);
-    public static final ElementName METER = new ElementName("meter", "meter", TreeBuilder.OTHER);
-    public static final ElementName NOBR = new ElementName("nobr", "nobr", TreeBuilder.NOBR);
-    public static final ElementName TR = new ElementName("tr", "tr", TreeBuilder.TR | SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
-    public static final ElementName ADDRESS = new ElementName("address", "address", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName CANVAS = new ElementName("canvas", "canvas", TreeBuilder.OTHER);
-    public static final ElementName DEFS = new ElementName("defs", "defs", TreeBuilder.OTHER);
-    public static final ElementName DETAILS = new ElementName("details", "details", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName MS = new ElementName("ms", "ms", TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
-    public static final ElementName NOFRAMES = new ElementName("noframes", "noframes", TreeBuilder.NOFRAMES | SPECIAL);
-    public static final ElementName PROGRESS = new ElementName("progress", "progress", TreeBuilder.OTHER);
-    public static final ElementName DT = new ElementName("dt", "dt", TreeBuilder.DD_OR_DT | SPECIAL | OPTIONAL_END_TAG);
-    public static final ElementName APPLET = new ElementName("applet", "applet", TreeBuilder.MARQUEE_OR_APPLET | SPECIAL | SCOPING);
-    public static final ElementName BASEFONT = new ElementName("basefont", "basefont", TreeBuilder.LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
-    public static final ElementName FOREIGNOBJECT = new ElementName("foreignobject", "foreignObject", TreeBuilder.FOREIGNOBJECT_OR_DESC | SCOPING_AS_SVG);
-    public static final ElementName FIELDSET = new ElementName("fieldset", "fieldset", TreeBuilder.FIELDSET | SPECIAL);
-    public static final ElementName FRAMESET = new ElementName("frameset", "frameset", TreeBuilder.FRAMESET | SPECIAL);
-    public static final ElementName FEOFFSET = new ElementName("feoffset", "feOffset", TreeBuilder.OTHER);
-    public static final ElementName FESPOTLIGHT = new ElementName("fespotlight", "feSpotLight", TreeBuilder.OTHER);
-    public static final ElementName FEPOINTLIGHT = new ElementName("fepointlight", "fePointLight", TreeBuilder.OTHER);
-    public static final ElementName FEDISTANTLIGHT = new ElementName("fedistantlight", "feDistantLight", TreeBuilder.OTHER);
-    public static final ElementName FONT = new ElementName("font", "font", TreeBuilder.FONT);
-    public static final ElementName INPUT = new ElementName("input", "input", TreeBuilder.INPUT | SPECIAL);
-    public static final ElementName LINEARGRADIENT = new ElementName("lineargradient", "linearGradient", TreeBuilder.OTHER);
-    public static final ElementName MTEXT = new ElementName("mtext", "mtext", TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
-    public static final ElementName NOSCRIPT = new ElementName("noscript", "noscript", TreeBuilder.NOSCRIPT | SPECIAL);
-    public static final ElementName RT = new ElementName("rt", "rt", TreeBuilder.RT_OR_RP | OPTIONAL_END_TAG);
-    public static final ElementName OBJECT = new ElementName("object", "object", TreeBuilder.OBJECT | SPECIAL | SCOPING);
-    public static final ElementName OUTPUT = new ElementName("output", "output", TreeBuilder.OUTPUT);
-    public static final ElementName PLAINTEXT = new ElementName("plaintext", "plaintext", TreeBuilder.PLAINTEXT | SPECIAL);
-    public static final ElementName TT = new ElementName("tt", "tt", TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-    public static final ElementName RECT = new ElementName("rect", "rect", TreeBuilder.OTHER);
-    public static final ElementName RADIALGRADIENT = new ElementName("radialgradient", "radialGradient", TreeBuilder.OTHER);
-    public static final ElementName SELECT = new ElementName("select", "select", TreeBuilder.SELECT | SPECIAL);
-    public static final ElementName SCRIPT = new ElementName("script", "script", TreeBuilder.SCRIPT | SPECIAL);
-    public static final ElementName TFOOT = new ElementName("tfoot", "tfoot", TreeBuilder.TBODY_OR_THEAD_OR_TFOOT | SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
-    public static final ElementName TEXT = new ElementName("text", "text", TreeBuilder.OTHER);
-    public static final ElementName MENU = new ElementName("menu", "menu", TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
-    public static final ElementName FEDROPSHADOW = new ElementName("fedropshadow", "feDropShadow", TreeBuilder.OTHER);
-    public static final ElementName VIEW = new ElementName("view", "view", TreeBuilder.OTHER);
-    public static final ElementName FECOLORMATRIX = new ElementName("fecolormatrix", "feColorMatrix", TreeBuilder.OTHER);
-    public static final ElementName FECONVOLVEMATRIX = new ElementName("feconvolvematrix", "feConvolveMatrix", TreeBuilder.OTHER);
-    public static final ElementName BODY = new ElementName("body", "body", TreeBuilder.BODY | SPECIAL | OPTIONAL_END_TAG);
-    public static final ElementName FEMORPHOLOGY = new ElementName("femorphology", "feMorphology", TreeBuilder.OTHER);
-    public static final ElementName RUBY = new ElementName("ruby", "ruby", TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
-    public static final ElementName SUMMARY = new ElementName("summary", "summary", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
-    public static final ElementName TBODY = new ElementName("tbody", "tbody", TreeBuilder.TBODY_OR_THEAD_OR_TFOOT | SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
-    private final static @NoLength ElementName[] ELEMENT_NAMES = {
-    KEYGEN,
-    FETURBULENCE,
-    FIELDSET,
-    H2,
-    MATH,
-    HEADER,
-    RECT,
-    RTC,
-    FEBLEND,
-    STYLE,
-    LABEL,
-    SAMP,
-    DETAILS,
-    LINEARGRADIENT,
-    VIEW,
-    IMG,
-    WBR,
-    META,
-    ARTICLE,
-    IMAGE,
-    FEFUNCG,
-    LINK,
-    FORM,
-    AUDIO,
-    FECOMPONENTTRANSFER,
-    TR,
-    DT,
-    FEPOINTLIGHT,
-    OBJECT,
-    TFOOT,
-    FEMORPHOLOGY,
-    DEL,
-    NAV,
-    SET,
-    Q,
-    H6,
-    DESC,
-    NOEMBED,
-    CODE,
-    FETILE,
-    POLYLINE,
-    TEMPLATE,
-    STRONG,
-    SWITCH,
-    TRACK,
-    ALTGLYPHITEM,
-    BUTTON,
-    PATTERN,
-    FEDISPLACEMENTMAP,
-    ANIMATECOLOR,
-    FOOTER,
-    METER,
-    CANVAS,
-    NOFRAMES,
-    BASEFONT,
-    FEOFFSET,
-    FONT,
-    NOSCRIPT,
-    PLAINTEXT,
-    SELECT,
-    MENU,
-    FECONVOLVEMATRIX,
-    SUMMARY,
-    BDO,
-    DIR,
-    KBD,
-    A,
-    SVG,
-    VAR,
-    I,
-    U,
-    H4,
-    FEFUNCA,
-    FEFUNCB,
-    BGSOUND,
-    HEAD,
-    THEAD,
-    BASE,
-    CITE,
-    FEIMAGE,
-    FIGURE,
-    LINE,
-    SOURCE,
-    TITLE,
-    GLYPHREF,
-    FESPECULARLIGHTING,
-    CLIPPATH,
-    PATH,
-    LI,
-    MALIGNMARK,
-    HTML,
-    SMALL,
-    ACRONYM,
-    PARAM,
-    FIGCAPTION,
-    OPTION,
-    SECTION,
-    VIDEO,
-    RP,
-    BR,
-    HR,
-    FILTER,
-    FEGAUSSIANBLUR,
-    MARKER,
-    NOBR,
-    ADDRESS,
-    DEFS,
-    MS,
-    PROGRESS,
-    APPLET,
-    FOREIGNOBJECT,
-    FRAMESET,
-    FESPOTLIGHT,
-    FEDISTANTLIGHT,
-    INPUT,
-    MTEXT,
-    RT,
-    OUTPUT,
-    TT,
-    RADIALGRADIENT,
-    SCRIPT,
-    TEXT,
-    FEDROPSHADOW,
-    FECOLORMATRIX,
-    BODY,
-    RUBY,
-    TBODY,
-    BIG,
-    COL,
-    DFN,
-    DIV,
-    INS,
-    MAP,
-    PRE,
-    B,
-    SUB,
-    SUP,
-    USE,
-    G,
-    XMP,
-    P,
-    S,
-    H1,
-    H3,
-    H5,
-    AREA,
-    METADATA,
-    TEXTAREA,
-    RB,
-    DD,
-    EMBED,
-    FEFLOOD,
-    LEGEND,
-    TD,
-    ASIDE,
-    ANIMATE,
-    BLOCKQUOTE,
-    CIRCLE,
-    ELLIPSE,
-    FEMERGENODE,
-    FEMERGE,
-    FRAME,
-    FECOMPOSITE,
-    IFRAME,
-    MARQUEE,
-    PICTURE,
-    STRIKE,
-    TABLE,
-    TIME,
-    ALTGLYPHDEF,
-    DIALOG,
-    FEDIFFUSELIGHTING,
-    LISTING,
-    ALTGLYPH,
-    MGLYPH,
-    MPATH,
-    TH,
-    TEXTPATH,
-    MI,
-    MARK,
-    MASK,
-    DL,
-    OL,
-    UL,
-    SYMBOL,
-    ANIMATETRANSFORM,
-    EM,
-    MENUITEM,
-    ANIMATEMOTION,
-    CAPTION,
-    MN,
-    MAIN,
-    POLYGON,
-    SPAN,
-    TSPAN,
-    MO,
-    COLGROUP,
-    HGROUP,
-    OPTGROUP,
-    STOP,
-    ABBR,
-    CENTER,
-    FEFUNCR,
-    };
-    private final static int[] ELEMENT_HASHES = {
-    1903302038,
-    1749656156,
-    2001349704,
-    893386754,
-    1803929812,
-    1968836118,
-    2007601444,
-    59821379,
-    1733054663,
-    1756625221,
-    1870268949,
-    1941178676,
-    1983633431,
-    2004635806,
-    2060065124,
-    55104723,
-    62450211,
-    1686491348,
-    1747176599,
-    1751288021,
-    1783210839,
-    1853642948,
-    1884120164,
-    1914900309,
-    1967788867,
-    1973420034,
-    1998585858,
-    2001392796,
-    2006028454,
-    2008851557,
-    2085266636,
-    52485715,
-    57733651,
-    60354131,
-    67633153,
-    960495618,
-    1715310660,
-    1737099991,
-    1748100148,
-    1749801286,
-    1755076808,
-    1757268168,
-    1790207270,
-    1806806678,
-    1857653029,
-    1881288348,
-    1898753862,
-    1906135367,
-    1934172497,
-    1965334268,
-    1967795958,
-    1971465813,
-    1982935782,
-    1988763672,
-    1999397992,
-    2001349736,
-    2001495140,
-    2005719336,
-    2006896969,
-    2008125638,
-    2021937364,
-    2068523856,
-    2092255447,
-    51438659,
-    52488851,
-    56151587,
-    59244545,
-    60347747,
-    61925907,
-    63438849,
-    69730305,
-    926941186,
-    1682547543,
-    1699324759,
-    1730965751,
-    1733890180,
-    1740181637,
-    1747814436,
-    1748359220,
-    1749715159,
-    1749905526,
-    1752979652,
-    1756474198,
-    1757146773,
-    1766992520,
-    1783388498,
-    1798686984,
-    1805502724,
-    1818230786,
-    1854228698,
-    1868312196,
-    1874053333,
-    1881613047,
-    1889085973,
-    1900845386,
-    1905563974,
-    1907661127,
-    1925844629,
-    1938817026,
-    1963982850,
-    1967128578,
-    1967795910,
-    1968053806,
-    1971461414,
-    1971938532,
-    1982173479,
-    1983533124,
-    1986527234,
-    1990037800,
-    1998724870,
-    2001309869,
-    2001349720,
-    2001392795,
-    2001392798,
-    2003183333,
-    2005324101,
-    2005925890,
-    2006329158,
-    2006974466,
-    2007781534,
-    2008340774,
-    2008994116,
-    2051837468,
-    2068523853,
-    2083120164,
-    2091479332,
-    2092557349,
-    51434643,
-    51961587,
-    52486755,
-    52490899,
-    55110883,
-    57206291,
-    58773795,
-    59768833,
-    60345171,
-    60352339,
-    61395251,
-    62390273,
-    62973651,
-    67108865,
-    68681729,
-    876609538,
-    910163970,
-    943718402,
-    1679960596,
-    1686489160,
-    1689922072,
-    1703936002,
-    1730150402,
-    1732381397,
-    1733076167,
-    1736200310,
-    1738539010,
-    1747048757,
-    1747306711,
-    1747838298,
-    1748225318,
-    1749395095,
-    1749673195,
-    1749723735,
-    1749813541,
-    1749932347,
-    1751386406,
-    1753362711,
-    1755148615,
-    1756600614,
-    1757137429,
-    1757157700,
-    1763839627,
-    1782357526,
-    1783388497,
-    1786534215,
-    1797585096,
-    1803876550,
-    1803929861,
-    1805647874,
-    1807599880,
-    1818755074,
-    1854228692,
-    1854245076,
-    1864368130,
-    1870135298,
-    1873281026,
-    1874102998,
-    1881498736,
-    1881669634,
-    1887579800,
-    1898223949,
-    1899272519,
-    1902641154,
-    1904412884,
-    1906087319,
-    1907435316,
-    1907959605,
-    1919418370,
-    1932928296,
-    1935549734,
-    1939219752,
-    1941221172,
-    1965115924,
-    1966223078,
-    1967760215,
-    };
+    public static final ElementName BIG = new ElementName("big", "big",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+
+    public static final ElementName BDO = new ElementName("bdo", "bdo",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName COL = new ElementName("col", "col",
+            // CPPONLY: NS_NewHTMLTableColElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.COL | SPECIAL);
+
+    public static final ElementName DEL = new ElementName("del", "del",
+            // CPPONLY: NS_NewHTMLModElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName DFN = new ElementName("dfn", "dfn",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName DIR = new ElementName("dir", "dir",
+            // CPPONLY: NS_NewHTMLSharedElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName DIV = new ElementName("div", "div",
+            // CPPONLY: NS_NewHTMLDivElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
+
+    public static final ElementName IMG = new ElementName("img", "img",
+            // CPPONLY: NS_NewHTMLImageElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.IMG | SPECIAL);
+
+    public static final ElementName INS = new ElementName("ins", "ins",
+            // CPPONLY: NS_NewHTMLModElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName KBD = new ElementName("kbd", "kbd",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName MAP = new ElementName("map", "map",
+            // CPPONLY: NS_NewHTMLMapElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName NAV = new ElementName("nav", "nav",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName PRE = new ElementName("pre", "pre",
+            // CPPONLY: NS_NewHTMLPreElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.PRE_OR_LISTING | SPECIAL);
+
+    public static final ElementName A = new ElementName("a", "a",
+            // CPPONLY: NS_NewHTMLAnchorElement,
+            // CPPONLY: NS_NewSVGAElement,
+            TreeBuilder.A);
+
+    public static final ElementName B = new ElementName("b", "b",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+
+    public static final ElementName RTC = new ElementName("rtc", "rtc",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.RB_OR_RTC | OPTIONAL_END_TAG);
+
+    public static final ElementName SUB = new ElementName("sub", "sub",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
+
+    public static final ElementName SVG = new ElementName("svg", "svg",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGSVGElement,
+            TreeBuilder.SVG);
+
+    public static final ElementName SUP = new ElementName("sup", "sup",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
+
+    public static final ElementName SET = new ElementName("set", "set",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGSetElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName USE = new ElementName("use", "use",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUseElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName VAR = new ElementName("var", "var",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
+
+    public static final ElementName G = new ElementName("g", "g",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGGElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName WBR = new ElementName("wbr", "wbr",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.AREA_OR_WBR | SPECIAL);
+
+    public static final ElementName XMP = new ElementName("xmp", "xmp",
+            // CPPONLY: NS_NewHTMLPreElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.XMP | SPECIAL);
+
+    public static final ElementName I = new ElementName("i", "i",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+
+    public static final ElementName P = new ElementName("p", "p",
+            // CPPONLY: NS_NewHTMLParagraphElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.P | SPECIAL | OPTIONAL_END_TAG);
+
+    public static final ElementName Q = new ElementName("q", "q",
+            // CPPONLY: NS_NewHTMLSharedElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName S = new ElementName("s", "s",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+
+    public static final ElementName U = new ElementName("u", "u",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+
+    public static final ElementName H1 = new ElementName("h1", "h1",
+            // CPPONLY: NS_NewHTMLHeadingElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
+
+    public static final ElementName H2 = new ElementName("h2", "h2",
+            // CPPONLY: NS_NewHTMLHeadingElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
+
+    public static final ElementName H3 = new ElementName("h3", "h3",
+            // CPPONLY: NS_NewHTMLHeadingElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
+
+    public static final ElementName H4 = new ElementName("h4", "h4",
+            // CPPONLY: NS_NewHTMLHeadingElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
+
+    public static final ElementName H5 = new ElementName("h5", "h5",
+            // CPPONLY: NS_NewHTMLHeadingElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
+
+    public static final ElementName H6 = new ElementName("h6", "h6",
+            // CPPONLY: NS_NewHTMLHeadingElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
+
+    public static final ElementName AREA = new ElementName("area", "area",
+            // CPPONLY: NS_NewHTMLAreaElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.AREA_OR_WBR | SPECIAL);
+
+    public static final ElementName DATA = new ElementName("data", "data",
+            // CPPONLY: NS_NewHTMLDataElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FEFUNCA = new ElementName("fefunca",
+            "feFuncA",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEFuncAElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName METADATA = new ElementName("metadata",
+            "metadata",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGMetadataElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName META = new ElementName("meta", "meta",
+            // CPPONLY: NS_NewHTMLMetaElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.META | SPECIAL);
+
+    public static final ElementName TEXTAREA = new ElementName("textarea",
+            "textarea",
+            // CPPONLY: NS_NewHTMLTextAreaElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.TEXTAREA | SPECIAL);
+
+    public static final ElementName FEFUNCB = new ElementName("fefuncb",
+            "feFuncB",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEFuncBElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName RB = new ElementName("rb", "rb",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.RB_OR_RTC | OPTIONAL_END_TAG);
+
+    public static final ElementName DESC = new ElementName("desc", "desc",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGDescElement,
+            TreeBuilder.FOREIGNOBJECT_OR_DESC | SCOPING_AS_SVG);
+
+    public static final ElementName DD = new ElementName("dd", "dd",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.DD_OR_DT | SPECIAL | OPTIONAL_END_TAG);
+
+    public static final ElementName BGSOUND = new ElementName("bgsound",
+            "bgsound",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
+
+    public static final ElementName EMBED = new ElementName("embed", "embed",
+            // CPPONLY: NS_NewHTMLEmbedElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.EMBED | SPECIAL);
+
+    public static final ElementName FEBLEND = new ElementName("feblend",
+            "feBlend",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEBlendElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FEFLOOD = new ElementName("feflood",
+            "feFlood",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEFloodElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName HEAD = new ElementName("head", "head",
+            // CPPONLY: NS_NewHTMLSharedElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.HEAD | SPECIAL | OPTIONAL_END_TAG);
+
+    public static final ElementName LEGEND = new ElementName("legend", "legend",
+            // CPPONLY: NS_NewHTMLLegendElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName NOEMBED = new ElementName("noembed",
+            "noembed",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.NOEMBED | SPECIAL);
+
+    public static final ElementName TD = new ElementName("td", "td",
+            // CPPONLY: NS_NewHTMLTableCellElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.TD_OR_TH | SPECIAL | SCOPING | OPTIONAL_END_TAG);
+
+    public static final ElementName THEAD = new ElementName("thead", "thead",
+            // CPPONLY: NS_NewHTMLTableSectionElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.TBODY_OR_THEAD_OR_TFOOT | SPECIAL | FOSTER_PARENTING
+                    | OPTIONAL_END_TAG);
+
+    public static final ElementName ASIDE = new ElementName("aside", "aside",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName ARTICLE = new ElementName("article",
+            "article",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName ANIMATE = new ElementName("animate",
+            "animate",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGAnimateElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName BASE = new ElementName("base", "base",
+            // CPPONLY: NS_NewHTMLSharedElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.BASE | SPECIAL);
+
+    public static final ElementName BLOCKQUOTE = new ElementName("blockquote",
+            "blockquote",
+            // CPPONLY: NS_NewHTMLSharedElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
+
+    public static final ElementName CODE = new ElementName("code", "code",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+
+    public static final ElementName CIRCLE = new ElementName("circle", "circle",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGCircleElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName CITE = new ElementName("cite", "cite",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName ELLIPSE = new ElementName("ellipse",
+            "ellipse",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGEllipseElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FETURBULENCE = new ElementName(
+            "feturbulence", "feTurbulence",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFETurbulenceElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FEMERGENODE = new ElementName("femergenode",
+            "feMergeNode",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEMergeNodeElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FEIMAGE = new ElementName("feimage",
+            "feImage",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEImageElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FEMERGE = new ElementName("femerge",
+            "feMerge",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEMergeElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FETILE = new ElementName("fetile", "feTile",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFETileElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FRAME = new ElementName("frame", "frame",
+            // CPPONLY: NS_NewHTMLFrameElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.FRAME | SPECIAL);
+
+    public static final ElementName FIGURE = new ElementName("figure", "figure",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName FECOMPOSITE = new ElementName("fecomposite",
+            "feComposite",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFECompositeElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName IMAGE = new ElementName("image", "image",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGImageElement,
+            TreeBuilder.IMAGE);
+
+    public static final ElementName IFRAME = new ElementName("iframe", "iframe",
+            // CPPONLY: NS_NewHTMLIFrameElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.IFRAME | SPECIAL);
+
+    public static final ElementName LINE = new ElementName("line", "line",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGLineElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName MARQUEE = new ElementName("marquee",
+            "marquee",
+            // CPPONLY: NS_NewHTMLDivElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.MARQUEE_OR_APPLET | SPECIAL | SCOPING);
+
+    public static final ElementName POLYLINE = new ElementName("polyline",
+            "polyline",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGPolylineElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName PICTURE = new ElementName("picture",
+            "picture",
+            // CPPONLY: NS_NewHTMLPictureElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName SOURCE = new ElementName("source", "source",
+            // CPPONLY: NS_NewHTMLSourceElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.PARAM_OR_SOURCE_OR_TRACK);
+
+    public static final ElementName STRIKE = new ElementName("strike", "strike",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+
+    public static final ElementName STYLE = new ElementName("style", "style",
+            // CPPONLY: NS_NewHTMLStyleElement,
+            // CPPONLY: NS_NewSVGStyleElement,
+            TreeBuilder.STYLE | SPECIAL);
+
+    public static final ElementName TABLE = new ElementName("table", "table",
+            // CPPONLY: NS_NewHTMLTableElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.TABLE | SPECIAL | FOSTER_PARENTING | SCOPING);
+
+    public static final ElementName TITLE = new ElementName("title", "title",
+            // CPPONLY: NS_NewHTMLTitleElement,
+            // CPPONLY: NS_NewSVGTitleElement,
+            TreeBuilder.TITLE | SPECIAL | SCOPING_AS_SVG);
+
+    public static final ElementName TIME = new ElementName("time", "time",
+            // CPPONLY: NS_NewHTMLTimeElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName TEMPLATE = new ElementName("template",
+            "template",
+            // CPPONLY: NS_NewHTMLTemplateElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.TEMPLATE | SPECIAL | SCOPING);
+
+    public static final ElementName ALTGLYPHDEF = new ElementName("altglyphdef",
+            "altGlyphDef",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName GLYPHREF = new ElementName("glyphref",
+            "glyphRef",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName DIALOG = new ElementName("dialog", "dialog",
+            // CPPONLY: NS_NewHTMLDialogElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName FEFUNCG = new ElementName("fefuncg",
+            "feFuncG",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEFuncGElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FEDIFFUSELIGHTING = new ElementName(
+            "fediffuselighting", "feDiffuseLighting",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEDiffuseLightingElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FESPECULARLIGHTING = new ElementName(
+            "fespecularlighting", "feSpecularLighting",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFESpecularLightingElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName LISTING = new ElementName("listing",
+            "listing",
+            // CPPONLY: NS_NewHTMLPreElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.PRE_OR_LISTING | SPECIAL);
+
+    public static final ElementName STRONG = new ElementName("strong", "strong",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+
+    public static final ElementName ALTGLYPH = new ElementName("altglyph",
+            "altGlyph",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName CLIPPATH = new ElementName("clippath",
+            "clipPath",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGClipPathElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName MGLYPH = new ElementName("mglyph", "mglyph",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.MGLYPH_OR_MALIGNMARK);
+
+    public static final ElementName MATH = new ElementName("math", "math",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.MATH);
+
+    public static final ElementName MPATH = new ElementName("mpath", "mpath",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGMPathElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName PATH = new ElementName("path", "path",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGPathElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName TH = new ElementName("th", "th",
+            // CPPONLY: NS_NewHTMLTableCellElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.TD_OR_TH | SPECIAL | SCOPING | OPTIONAL_END_TAG);
+
+    public static final ElementName SWITCH = new ElementName("switch", "switch",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGSwitchElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName TEXTPATH = new ElementName("textpath",
+            "textPath",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGTextPathElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName LI = new ElementName("li", "li",
+            // CPPONLY: NS_NewHTMLLIElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.LI | SPECIAL | OPTIONAL_END_TAG);
+
+    public static final ElementName MI = new ElementName("mi", "mi",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
+
+    public static final ElementName LINK = new ElementName("link", "link",
+            // CPPONLY: NS_NewHTMLLinkElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
+
+    public static final ElementName MARK = new ElementName("mark", "mark",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName MALIGNMARK = new ElementName("malignmark",
+            "malignmark",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.MGLYPH_OR_MALIGNMARK);
+
+    public static final ElementName MASK = new ElementName("mask", "mask",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGMaskElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName TRACK = new ElementName("track", "track",
+            // CPPONLY: NS_NewHTMLTrackElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.PARAM_OR_SOURCE_OR_TRACK | SPECIAL);
+
+    public static final ElementName DL = new ElementName("dl", "dl",
+            // CPPONLY: NS_NewHTMLSharedListElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.UL_OR_OL_OR_DL | SPECIAL);
+
+    public static final ElementName HTML = new ElementName("html", "html",
+            // CPPONLY: NS_NewHTMLSharedElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.HTML | SPECIAL | SCOPING | OPTIONAL_END_TAG);
+
+    public static final ElementName OL = new ElementName("ol", "ol",
+            // CPPONLY: NS_NewHTMLSharedListElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.UL_OR_OL_OR_DL | SPECIAL);
+
+    public static final ElementName LABEL = new ElementName("label", "label",
+            // CPPONLY: NS_NewHTMLLabelElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName UL = new ElementName("ul", "ul",
+            // CPPONLY: NS_NewHTMLSharedListElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.UL_OR_OL_OR_DL | SPECIAL);
+
+    public static final ElementName SMALL = new ElementName("small", "small",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+
+    public static final ElementName SYMBOL = new ElementName("symbol", "symbol",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGSymbolElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName ALTGLYPHITEM = new ElementName(
+            "altglyphitem", "altGlyphItem",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName ANIMATETRANSFORM = new ElementName(
+            "animatetransform", "animateTransform",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGAnimateTransformElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName ACRONYM = new ElementName("acronym",
+            "acronym",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName EM = new ElementName("em", "em",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+
+    public static final ElementName FORM = new ElementName("form", "form",
+            // CPPONLY: NS_NewHTMLFormElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.FORM | SPECIAL);
+
+    public static final ElementName MENUITEM = new ElementName("menuitem",
+            "menuitem",
+            // CPPONLY: NS_NewHTMLMenuItemElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.MENUITEM);
+
+    public static final ElementName PARAM = new ElementName("param", "param",
+            // CPPONLY: NS_NewHTMLSharedElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.PARAM_OR_SOURCE_OR_TRACK | SPECIAL);
+
+    public static final ElementName ANIMATEMOTION = new ElementName(
+            "animatemotion", "animateMotion",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGAnimateMotionElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName BUTTON = new ElementName("button", "button",
+            // CPPONLY: NS_NewHTMLButtonElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.BUTTON | SPECIAL);
+
+    public static final ElementName CAPTION = new ElementName("caption",
+            "caption",
+            // CPPONLY: NS_NewHTMLTableCaptionElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.CAPTION | SPECIAL | SCOPING);
+
+    public static final ElementName FIGCAPTION = new ElementName("figcaption",
+            "figcaption",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName MN = new ElementName("mn", "mn",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
+
+    public static final ElementName KEYGEN = new ElementName("keygen", "keygen",
+            // CPPONLY: NS_NewHTMLSpanElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.KEYGEN);
+
+    public static final ElementName MAIN = new ElementName("main", "main",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName OPTION = new ElementName("option", "option",
+            // CPPONLY: NS_NewHTMLOptionElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OPTION | OPTIONAL_END_TAG);
+
+    public static final ElementName POLYGON = new ElementName("polygon",
+            "polygon",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGPolygonElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName PATTERN = new ElementName("pattern",
+            "pattern",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGPatternElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName SPAN = new ElementName("span", "span",
+            // CPPONLY: NS_NewHTMLSpanElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
+
+    public static final ElementName SECTION = new ElementName("section",
+            "section",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName TSPAN = new ElementName("tspan", "tspan",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGTSpanElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName AUDIO = new ElementName("audio", "audio",
+            // CPPONLY: NS_NewHTMLAudioElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName MO = new ElementName("mo", "mo",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
+
+    public static final ElementName VIDEO = new ElementName("video", "video",
+            // CPPONLY: NS_NewHTMLVideoElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName COLGROUP = new ElementName("colgroup",
+            "colgroup",
+            // CPPONLY: NS_NewHTMLTableColElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.COLGROUP | SPECIAL | OPTIONAL_END_TAG);
+
+    public static final ElementName FEDISPLACEMENTMAP = new ElementName(
+            "fedisplacementmap", "feDisplacementMap",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEDisplacementMapElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName HGROUP = new ElementName("hgroup", "hgroup",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName RP = new ElementName("rp", "rp",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.RT_OR_RP | OPTIONAL_END_TAG);
+
+    public static final ElementName OPTGROUP = new ElementName("optgroup",
+            "optgroup",
+            // CPPONLY: NS_NewHTMLOptGroupElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OPTGROUP | OPTIONAL_END_TAG);
+
+    public static final ElementName SAMP = new ElementName("samp", "samp",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName STOP = new ElementName("stop", "stop",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGStopElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName BR = new ElementName("br", "br",
+            // CPPONLY: NS_NewHTMLBRElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.BR | SPECIAL);
+
+    public static final ElementName ABBR = new ElementName("abbr", "abbr",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName ANIMATECOLOR = new ElementName(
+            "animatecolor", "animateColor",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName CENTER = new ElementName("center", "center",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
+
+    public static final ElementName HR = new ElementName("hr", "hr",
+            // CPPONLY: NS_NewHTMLHRElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.HR | SPECIAL);
+
+    public static final ElementName FEFUNCR = new ElementName("fefuncr",
+            "feFuncR",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEFuncRElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FECOMPONENTTRANSFER = new ElementName(
+            "fecomponenttransfer", "feComponentTransfer",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEComponentTransferElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FILTER = new ElementName("filter", "filter",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFilterElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FOOTER = new ElementName("footer", "footer",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName FEGAUSSIANBLUR = new ElementName(
+            "fegaussianblur", "feGaussianBlur",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEGaussianBlurElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName HEADER = new ElementName("header", "header",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName MARKER = new ElementName("marker", "marker",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGMarkerElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName METER = new ElementName("meter", "meter",
+            // CPPONLY: NS_NewHTMLMeterElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName NOBR = new ElementName("nobr", "nobr",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.NOBR);
+
+    public static final ElementName TR = new ElementName("tr", "tr",
+            // CPPONLY: NS_NewHTMLTableRowElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.TR | SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
+
+    public static final ElementName ADDRESS = new ElementName("address",
+            "address",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName CANVAS = new ElementName("canvas", "canvas",
+            // CPPONLY: NS_NewHTMLCanvasElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName DEFS = new ElementName("defs", "defs",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGDefsElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName DETAILS = new ElementName("details",
+            "details",
+            // CPPONLY: NS_NewHTMLDetailsElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName MS = new ElementName("ms", "ms",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
+
+    public static final ElementName NOFRAMES = new ElementName("noframes",
+            "noframes",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.NOFRAMES | SPECIAL);
+
+    public static final ElementName PROGRESS = new ElementName("progress",
+            "progress",
+            // CPPONLY: NS_NewHTMLProgressElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName DT = new ElementName("dt", "dt",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.DD_OR_DT | SPECIAL | OPTIONAL_END_TAG);
+
+    public static final ElementName APPLET = new ElementName("applet", "applet",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.MARQUEE_OR_APPLET | SPECIAL | SCOPING);
+
+    public static final ElementName BASEFONT = new ElementName("basefont",
+            "basefont",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
+
+    public static final ElementName CONTENT = new ElementName("content",
+            "content",
+            // CPPONLY: NS_NewHTMLContentElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName DATALIST = new ElementName("datalist",
+            "datalist",
+            // CPPONLY: NS_NewHTMLDataListElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FOREIGNOBJECT = new ElementName(
+            "foreignobject", "foreignObject",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGForeignObjectElement,
+            TreeBuilder.FOREIGNOBJECT_OR_DESC | SCOPING_AS_SVG);
+
+    public static final ElementName FIELDSET = new ElementName("fieldset",
+            "fieldset",
+            // CPPONLY: NS_NewHTMLFieldSetElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.FIELDSET | SPECIAL);
+
+    public static final ElementName FRAMESET = new ElementName("frameset",
+            "frameset",
+            // CPPONLY: NS_NewHTMLFrameSetElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.FRAMESET | SPECIAL);
+
+    public static final ElementName FEOFFSET = new ElementName("feoffset",
+            "feOffset",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEOffsetElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FESPOTLIGHT = new ElementName("fespotlight",
+            "feSpotLight",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFESpotLightElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FEPOINTLIGHT = new ElementName(
+            "fepointlight", "fePointLight",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEPointLightElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FEDISTANTLIGHT = new ElementName(
+            "fedistantlight", "feDistantLight",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEDistantLightElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FONT = new ElementName("font", "font",
+            // CPPONLY: NS_NewHTMLFontElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.FONT);
+
+    public static final ElementName INPUT = new ElementName("input", "input",
+            // CPPONLY: NS_NewHTMLInputElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.INPUT | SPECIAL);
+
+    public static final ElementName LINEARGRADIENT = new ElementName(
+            "lineargradient", "linearGradient",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGLinearGradientElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName MTEXT = new ElementName("mtext", "mtext",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
+
+    public static final ElementName NOSCRIPT = new ElementName("noscript",
+            "noscript",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.NOSCRIPT | SPECIAL);
+
+    public static final ElementName RT = new ElementName("rt", "rt",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.RT_OR_RP | OPTIONAL_END_TAG);
+
+    public static final ElementName OBJECT = new ElementName("object", "object",
+            // CPPONLY: NS_NewHTMLObjectElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OBJECT | SPECIAL | SCOPING);
+
+    public static final ElementName OUTPUT = new ElementName("output", "output",
+            // CPPONLY: NS_NewHTMLOutputElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OUTPUT);
+
+    public static final ElementName PLAINTEXT = new ElementName("plaintext",
+            "plaintext",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.PLAINTEXT | SPECIAL);
+
+    public static final ElementName TT = new ElementName("tt", "tt",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+
+    public static final ElementName RECT = new ElementName("rect", "rect",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGRectElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName RADIALGRADIENT = new ElementName(
+            "radialgradient", "radialGradient",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGRadialGradientElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName SELECT = new ElementName("select", "select",
+            // CPPONLY: NS_NewHTMLSelectElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.SELECT | SPECIAL);
+
+    public static final ElementName SCRIPT = new ElementName("script", "script",
+            // CPPONLY: NS_NewHTMLScriptElement,
+            // CPPONLY: NS_NewSVGScriptElement,
+            TreeBuilder.SCRIPT | SPECIAL);
+
+    public static final ElementName TFOOT = new ElementName("tfoot", "tfoot",
+            // CPPONLY: NS_NewHTMLTableSectionElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.TBODY_OR_THEAD_OR_TFOOT | SPECIAL | FOSTER_PARENTING
+                    | OPTIONAL_END_TAG);
+
+    public static final ElementName TEXT = new ElementName("text", "text",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGTextElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName MENU = new ElementName("menu", "menu",
+            // CPPONLY: NS_NewHTMLMenuElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
+
+    public static final ElementName FEDROPSHADOW = new ElementName(
+            "fedropshadow", "feDropShadow",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEDropShadowElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName SHADOW = new ElementName("shadow", "shadow",
+            // CPPONLY: NS_NewHTMLShadowElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName VIEW = new ElementName("view", "view",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGViewElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FECOLORMATRIX = new ElementName(
+            "fecolormatrix", "feColorMatrix",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEColorMatrixElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName FECONVOLVEMATRIX = new ElementName(
+            "feconvolvematrix", "feConvolveMatrix",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEConvolveMatrixElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName BODY = new ElementName("body", "body",
+            // CPPONLY: NS_NewHTMLBodyElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.BODY | SPECIAL | OPTIONAL_END_TAG);
+
+    public static final ElementName FEMORPHOLOGY = new ElementName(
+            "femorphology", "feMorphology",
+            // CPPONLY: NS_NewHTMLUnknownElement,
+            // CPPONLY: NS_NewSVGFEMorphologyElement,
+            TreeBuilder.OTHER);
+
+    public static final ElementName RUBY = new ElementName("ruby", "ruby",
+            // CPPONLY: NS_NewHTMLElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
+
+    public static final ElementName SUMMARY = new ElementName("summary",
+            "summary",
+            // CPPONLY: NS_NewHTMLSummaryElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY
+                    | SPECIAL);
+
+    public static final ElementName TBODY = new ElementName("tbody", "tbody",
+            // CPPONLY: NS_NewHTMLTableSectionElement,
+            // CPPONLY: NS_NewSVGUnknownElement,
+            TreeBuilder.TBODY_OR_THEAD_OR_TFOOT | SPECIAL | FOSTER_PARENTING
+                    | OPTIONAL_END_TAG);
+
+    private final static @NoLength ElementName[] ELEMENT_NAMES = { MN, ELLIPSE,
+            FRAMESET, H2, MGLYPH, NOBR, RADIALGRADIENT, RTC, EMBED, STRIKE, OL,
+            OPTGROUP, PROGRESS, MTEXT, VIEW, IMG, WBR, METADATA, ASIDE,
+            FECOMPOSITE, DIALOG, MI, EM, TSPAN, FEFUNCR, DEFS, CONTENT,
+            FEDISTANTLIGHT, OUTPUT, TEXT, FEMORPHOLOGY, DEL, NAV, SET, Q, H6,
+            RB, LEGEND, BLOCKQUOTE, FEMERGE, MARQUEE, TIME, LISTING, TH, MASK,
+            SYMBOL, ANIMATEMOTION, POLYGON, COLGROUP, ABBR, FEGAUSSIANBLUR,
+            ADDRESS, MS, APPLET, FOREIGNOBJECT, FESPOTLIGHT, INPUT, RT, TT,
+            SCRIPT, FEDROPSHADOW, FECONVOLVEMATRIX, SUMMARY, BDO, DIR, KBD, A,
+            SVG, VAR, I, U, H4, DATA, TEXTAREA, DD, FEFLOOD, TD, ANIMATE,
+            CIRCLE, FEMERGENODE, FRAME, IFRAME, PICTURE, TABLE, ALTGLYPHDEF,
+            FEDIFFUSELIGHTING, ALTGLYPH, MPATH, TEXTPATH, MARK, DL, UL,
+            ANIMATETRANSFORM, MENUITEM, CAPTION, MAIN, SPAN, MO, HGROUP, STOP,
+            CENTER, FILTER, MARKER, TR, CANVAS, DETAILS, NOFRAMES, DT, BASEFONT,
+            DATALIST, FIELDSET, FEOFFSET, FEPOINTLIGHT, FONT, LINEARGRADIENT,
+            NOSCRIPT, OBJECT, PLAINTEXT, RECT, SELECT, TFOOT, MENU, SHADOW,
+            FECOLORMATRIX, BODY, RUBY, TBODY, BIG, COL, DFN, DIV, INS, MAP, PRE,
+            B, SUB, SUP, USE, G, XMP, P, S, H1, H3, H5, AREA, FEFUNCA, META,
+            FEFUNCB, DESC, BGSOUND, FEBLEND, HEAD, NOEMBED, THEAD, ARTICLE,
+            BASE, CODE, CITE, FETURBULENCE, FEIMAGE, FETILE, FIGURE, IMAGE,
+            LINE, POLYLINE, SOURCE, STYLE, TITLE, TEMPLATE, GLYPHREF, FEFUNCG,
+            FESPECULARLIGHTING, STRONG, CLIPPATH, MATH, PATH, SWITCH, LI, LINK,
+            MALIGNMARK, TRACK, HTML, LABEL, SMALL, ALTGLYPHITEM, ACRONYM, FORM,
+            PARAM, BUTTON, FIGCAPTION, KEYGEN, OPTION, PATTERN, SECTION, AUDIO,
+            VIDEO, FEDISPLACEMENTMAP, RP, SAMP, BR, ANIMATECOLOR, HR,
+            FECOMPONENTTRANSFER, FOOTER, HEADER, METER, };
+
+    private final static int[] ELEMENT_HASHES = { 1902641154, 1749395095,
+            2001349720, 893386754, 1803876550, 1971938532, 2007781534, 59821379,
+            1732381397, 1756600614, 1870135298, 1939219752, 1990037800,
+            2005324101, 2060065124, 55104723, 62450211, 1686489160, 1747048757,
+            1749932347, 1782357526, 1818755074, 1881669634, 1907959605,
+            1967760215, 1983533124, 1999917383, 2001392798, 2006329158,
+            2008994116, 2085266636, 52485715, 57733651, 60354131, 67633153,
+            960495618, 1703936002, 1736200310, 1747838298, 1749723735,
+            1753362711, 1757157700, 1786534215, 1805647874, 1854245076,
+            1874102998, 1898223949, 1906087319, 1932928296, 1965115924,
+            1968053806, 1982173479, 1986527234, 1998724870, 2001309869,
+            2001392795, 2003183333, 2005925890, 2006974466, 2008340774,
+            2051837468, 2068523856, 2092255447, 51438659, 52488851, 56151587,
+            59244545, 60347747, 61925907, 63438849, 69730305, 926941186,
+            1681770564, 1689922072, 1730150402, 1733076167, 1738539010,
+            1747306711, 1748225318, 1749673195, 1749813541, 1751386406,
+            1755148615, 1757137429, 1763839627, 1783388497, 1797585096,
+            1803929861, 1807599880, 1854228692, 1864368130, 1873281026,
+            1881498736, 1887579800, 1899272519, 1904412884, 1907435316,
+            1919418370, 1935549734, 1941221172, 1966223078, 1967795910,
+            1971461414, 1973420034, 1982935782, 1983633431, 1988763672,
+            1998585858, 1999397992, 2000525512, 2001349704, 2001349736,
+            2001392796, 2001495140, 2004635806, 2005719336, 2006028454,
+            2006896969, 2007601444, 2008125638, 2008851557, 2021937364,
+            2058653206, 2068523853, 2083120164, 2091479332, 2092557349,
+            51434643, 51961587, 52486755, 52490899, 55110883, 57206291,
+            58773795, 59768833, 60345171, 60352339, 61395251, 62390273,
+            62973651, 67108865, 68681729, 876609538, 910163970, 943718402,
+            1679960596, 1682547543, 1686491348, 1699324759, 1715310660,
+            1730965751, 1733054663, 1733890180, 1737099991, 1740181637,
+            1747176599, 1747814436, 1748100148, 1748359220, 1749656156,
+            1749715159, 1749801286, 1749905526, 1751288021, 1752979652,
+            1755076808, 1756474198, 1756625221, 1757146773, 1757268168,
+            1766992520, 1783210839, 1783388498, 1790207270, 1798686984,
+            1803929812, 1805502724, 1806806678, 1818230786, 1853642948,
+            1854228698, 1857653029, 1868312196, 1870268949, 1874053333,
+            1881288348, 1881613047, 1884120164, 1889085973, 1898753862,
+            1900845386, 1903302038, 1905563974, 1906135367, 1907661127,
+            1914900309, 1925844629, 1934172497, 1938817026, 1941178676,
+            1963982850, 1965334268, 1967128578, 1967788867, 1967795958,
+            1968836118, 1971465813, };
+
 }
--- a/parser/html/javasrc/StackNode.java
+++ b/parser/html/javasrc/StackNode.java
@@ -43,16 +43,21 @@ final class StackNode<T> {
 
     T node;
 
     // Only used on the list of formatting elements
     HtmlAttributes attributes;
 
     private int refcount = 0;
 
+    /*
+     *  Only valid for formatting elements
+     */
+    // CPPONLY: private @HtmlCreator Object htmlCreator;
+
     // [NOCPP[
 
     private TaintableLocatorImpl locator;
 
     public TaintableLocatorImpl getLocator() {
         return locator;
     }
 
@@ -90,42 +95,51 @@ final class StackNode<T> {
 
     // ]NOCPP]
 
     StackNode(int idxInTreeBuilder) {
         this.idxInTreeBuilder = idxInTreeBuilder;
         this.refcount = 0;
     }
 
+    // CPPONLY: public @HtmlCreator Object getHtmlCreator() {
+    // CPPONLY:     return htmlCreator;
+    // CPPONLY: }
+
     /**
      * Setter for copying. This doesn't take another <code>StackNode</code>
      * because in C++ the caller is responsible for reobtaining the local names
      * from another interner.
      *
      * @param flags
      * @param ns
      * @param name
      * @param node
      * @param popName
      * @param attributes
      */
     void setValues(int flags, @NsUri String ns, @Local String name, T node,
-            @Local String popName, HtmlAttributes attributes
+            @Local String popName, HtmlAttributes attributes,
+            // CPPONLY: @HtmlCreator Object htmlCreator
             // [NOCPP[
-            , TaintableLocatorImpl locator
+            TaintableLocatorImpl locator
             // ]NOCPP]
     ) {
         assert isUnused();
         this.flags = flags;
         this.name = name;
         this.popName = popName;
         this.ns = ns;
         this.node = node;
         this.attributes = attributes;
         this.refcount = 1;
+        /*
+         * Need to track creator for formatting elements when copying.
+         */
+        // CPPONLY: this.htmlCreator = htmlCreator;
         // [NOCPP[
         this.locator = locator;
         // ]NOCPP]
     }
 
     /**
      * Short hand for well-known HTML elements.
      *
@@ -141,16 +155,20 @@ final class StackNode<T> {
         this.flags = elementName.getFlags();
         this.name = elementName.getName();
         this.popName = elementName.getName();
         this.ns = "http://www.w3.org/1999/xhtml";
         this.node = node;
         this.attributes = null;
         this.refcount = 1;
         assert elementName.isInterned() : "Don't use this constructor for custom elements.";
+        /*
+         * Not used for formatting elements, so no need to track creator.
+         */
+        // CPPONLY: this.htmlCreator = null;
         // [NOCPP[
         this.locator = locator;
         // ]NOCPP]
     }
 
     /**
      * Setter for HTML formatting elements.
      *
@@ -167,16 +185,21 @@ final class StackNode<T> {
         this.flags = elementName.getFlags();
         this.name = elementName.getName();
         this.popName = elementName.getName();
         this.ns = "http://www.w3.org/1999/xhtml";
         this.node = node;
         this.attributes = attributes;
         this.refcount = 1;
         assert elementName.isInterned() : "Don't use this constructor for custom elements.";
+        /*
+         * Need to track creator for formatting elements in order to be able
+         * to clone them.
+         */
+        // CPPONLY: this.htmlCreator = elementName.getHtmlCreator();
         // [NOCPP[
         this.locator = locator;
         // ]NOCPP]
     }
 
     /**
      * The common-case HTML setter.
      *
@@ -192,16 +215,20 @@ final class StackNode<T> {
         assert isUnused();
         this.flags = elementName.getFlags();
         this.name = elementName.getName();
         this.popName = popName;
         this.ns = "http://www.w3.org/1999/xhtml";
         this.node = node;
         this.attributes = null;
         this.refcount = 1;
+        /*
+         * Not used for formatting elements, so no need to track creator.
+         */
+        // CPPONLY: this.htmlCreator = null;
         // [NOCPP[
         this.locator = locator;
         // ]NOCPP]
     }
 
     /**
      * Setter for SVG elements. Note that the order of the arguments is
      * what distinguishes this from the HTML setter. This is ugly, but
@@ -220,16 +247,20 @@ final class StackNode<T> {
         assert isUnused();
         this.flags = prepareSvgFlags(elementName.getFlags());
         this.name = elementName.getName();
         this.popName = popName;
         this.ns = "http://www.w3.org/2000/svg";
         this.node = node;
         this.attributes = null;
         this.refcount = 1;
+        /*
+         * Not used for formatting elements, so no need to track creator.
+         */
+        // CPPONLY: this.htmlCreator = null;
         // [NOCPP[
         this.locator = locator;
         // ]NOCPP]
     }
 
     /**
      * Setter for MathML.
      *
@@ -248,16 +279,20 @@ final class StackNode<T> {
         this.flags = prepareMathFlags(elementName.getFlags(),
                 markAsIntegrationPoint);
         this.name = elementName.getName();
         this.popName = popName;
         this.ns = "http://www.w3.org/1998/Math/MathML";
         this.node = node;
         this.attributes = null;
         this.refcount = 1;
+        /*
+         * Not used for formatting elements, so no need to track creator.
+         */
+        // CPPONLY: this.htmlCreator = null;
         // [NOCPP[
         this.locator = locator;
         // ]NOCPP]
     }
 
     private static int prepareSvgFlags(int flags) {
         flags &= ~(ElementName.FOSTER_PARENTING | ElementName.SCOPING
                 | ElementName.SPECIAL | ElementName.OPTIONAL_END_TAG);
--- a/parser/html/javasrc/Tokenizer.java
+++ b/parser/html/javasrc/Tokenizer.java
@@ -1115,25 +1115,29 @@ public class Tokenizer implements Locato
     private void strBufToElementNameString() {
         if (containsHyphen) {
             // We've got a custom element or annotation-xml.
             @Local String annotationName = ElementName.ANNOTATION_XML.getName();
             if (Portability.localEqualsBuffer(annotationName, strBuf, 0, strBufLen)) {
                 tagName = ElementName.ANNOTATION_XML;
             } else {
                 nonInternedTagName.setNameForNonInterned(Portability.newLocalNameFromBuffer(strBuf, 0, strBufLen,
-                        interner));
+                        interner)
+                        // CPPONLY: , true
+                        );
                 tagName = nonInternedTagName;
             }
         } else {
             tagName = ElementName.elementNameByBuffer(strBuf, 0, strBufLen,
                     interner);
             if (tagName == null) {
                 nonInternedTagName.setNameForNonInterned(Portability.newLocalNameFromBuffer(strBuf, 0, strBufLen,
-                    interner));
+                    interner)
+                        // CPPONLY: , false
+                        );
                 tagName = nonInternedTagName;
             }
         }
         containsHyphen = false;
         clearStrBufAfterUse();
     }
 
     private int emitCurrentTagToken(boolean selfClosing, int pos)
@@ -6681,17 +6685,19 @@ public class Tokenizer implements Locato
             Portability.releaseString(systemIdentifier);
             systemIdentifier = null;
         }
         if (publicIdentifier != null) {
             Portability.releaseString(publicIdentifier);
             publicIdentifier = null;
         }
         tagName = null;
-        nonInternedTagName.setNameForNonInterned(null);
+        nonInternedTagName.setNameForNonInterned(null
+                // CPPONLY: , false
+                );
         attributeName = null;
         // CPPONLY: nonInternedAttributeName.setNameForNonInterned(null);
         tokenHandler.endTokenization();
         if (attributes != null) {
             // [NOCPP[
             attributes = null;
             // ]NOCPP]
             // CPPONLY: attributes.clear(mappingLangToXmlLang);
@@ -6831,17 +6837,19 @@ public class Tokenizer implements Locato
         if (other.tagName == null) {
             tagName = null;
         } else if (other.tagName.isInterned()) {
             tagName = other.tagName;
         } else {
             // In the C++ case, the atoms in the other tokenizer are from a
             // different tokenizer-scoped atom table. Therefore, we have to
             // obtain the correspoding atom from our own atom table.
-            nonInternedTagName.setNameForNonInterned(Portability.newLocalFromLocal(other.tagName.getName(), interner));
+            nonInternedTagName.setNameForNonInterned(Portability.newLocalFromLocal(other.tagName.getName(), interner)
+                    // CPPONLY: , other.tagName.isCustom()
+                    );
             tagName = nonInternedTagName;
         }
 
         // [NOCPP[
         attributeName = other.attributeName;
         // ]NOCPP]
         // CPPONLY: if (other.attributeName == null) {
         // CPPONLY:     attributeName = null;
--- a/parser/html/javasrc/TreeBuilder.java
+++ b/parser/html/javasrc/TreeBuilder.java
@@ -478,16 +478,28 @@ public abstract class TreeBuilder<T> imp
      * 1.0 as fatal.
      *
      * @throws SAXException
      * @throws SAXParseException
      */
     protected void fatal() throws SAXException {
     }
 
+    // CPPONLY: @Inline private @Creator Object htmlCreator(@HtmlCreator Object htmlCreator) {
+    // CPPONLY:     @Creator Object creator;
+    // CPPONLY:     creator.html = htmlCreator;
+    // CPPONLY:     return creator;
+    // CPPONLY: }
+    // CPPONLY:
+    // CPPONLY: @Inline private @Creator Object svgCreator(@SvgCreator Object svgCreator) {
+    // CPPONLY:     @Creator Object creator;
+    // CPPONLY:     creator.svg = svgCreator;
+    // CPPONLY:     return creator;
+    // CPPONLY: }
+
     // [NOCPP[
 
     protected final void fatal(Exception e) throws SAXException {
         SAXParseException spe = new SAXParseException(e.getMessage(),
                 tokenizer, e);
         if (errorHandler != null) {
             errorHandler.fatalError(spe);
         }
@@ -724,17 +736,18 @@ public abstract class TreeBuilder<T> imp
             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);
+            // CPPONLY: tokenizer.emptyAttributes(), null,
+            // CPPONLY: svgCreator(NS_NewSVGSVGElement));
             // CPPONLY: StackNode<T> node = createStackNode(ElementName.SVG,
             // CPPONLY: "svg",
             // CPPONLY: elt);
             // CPPONLY: currentPtr++;
             // CPPONLY: stack[currentPtr] = node;
             // CPPONLY: }
         }
     }
@@ -1977,18 +1990,18 @@ public abstract class TreeBuilder<T> imp
                                 break starttagloop;
                             case INPUT:
                                 errStartTagInTable(name);
                                 if (!Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString(
                                         "hidden",
                                         attributes.getValue(AttributeName.TYPE))) {
                                     break intableloop;
                                 }
-                                appendVoidElementToCurrent(
-                                        name, attributes,
+                                appendVoidInputToCurrent(
+                                        attributes,
                                         formPointer);
                                 selfClosing = false;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case FORM:
                                 if (formPointer != null || isTemplateContents()) {
                                     errFormWhenFormOpen();
                                     break starttagloop;
@@ -2340,17 +2353,17 @@ public abstract class TreeBuilder<T> imp
                                 errImage();
                                 elementName = ElementName.IMG;
                                 continue starttagloop;
                             case IMG:
                             case KEYGEN:
                             case INPUT:
                                 reconstructTheActiveFormattingElements();
                                 appendVoidElementToCurrentMayFoster(
-                                        name, attributes,
+                                        elementName, attributes,
                                         formPointer);
                                 selfClosing = false;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case TEXTAREA:
                                 appendToCurrentNodeAndPushElementMayFoster(
                                         elementName,
                                         attributes, formPointer);
@@ -4748,19 +4761,22 @@ public abstract class TreeBuilder<T> imp
                 // now node is both on stack and in the list
                 if (nodePos == furthestBlockPos) {
                     bookmark = nodeListPos + 1;
                 }
                 // if (hasChildren(node.node)) { XXX AAA CHANGE
                 assert node == listOfActiveFormattingElements[nodeListPos];
                 assert node == stack[nodePos];
                 T clone = createElement("http://www.w3.org/1999/xhtml",
-                        node.name, node.attributes.cloneAttributes(null), commonAncestor.node);
+                        node.name, node.attributes.cloneAttributes(null), commonAncestor.node
+                        // CPPONLY: , htmlCreator(node.getHtmlCreator())
+                        );
                 StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
                         node.name, clone, node.popName, node.attributes
+                        // CPPONLY: , node.getHtmlCreator()
                         // [NOCPP[
                         , node.getLocator()
                         // ]NOCPP]
                 ); // creation ownership goes to stack
                 node.dropAttributes(); // adopt ownership to newNode
                 stack[nodePos] = newNode;
                 newNode.retain(); // retain for list
                 listOfActiveFormattingElements[nodeListPos] = newNode;
@@ -4777,21 +4793,24 @@ public abstract class TreeBuilder<T> imp
                 detachFromParent(lastNode.node);
                 insertIntoFosterParent(lastNode.node);
             } else {
                 detachFromParent(lastNode.node);
                 appendElement(lastNode.node, commonAncestor.node);
             }
             T clone = createElement("http://www.w3.org/1999/xhtml",
                     formattingElt.name,
-                    formattingElt.attributes.cloneAttributes(null), furthestBlock.node);
+                    formattingElt.attributes.cloneAttributes(null), furthestBlock.node
+                    // CPPONLY: , htmlCreator(formattingElt.getHtmlCreator())
+                    );
             StackNode<T> formattingClone = createStackNode(
                     formattingElt.getFlags(), formattingElt.ns,
                     formattingElt.name, clone, formattingElt.popName,
                     formattingElt.attributes
+                    // CPPONLY: , formattingElt.getHtmlCreator()
                     // [NOCPP[
                     , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
                     // ]NOCPP]
             ); // Ownership transfers to stack below
             formattingElt.dropAttributes(); // transfer ownership to
                                             // formattingClone
             appendChildrenToNewParent(furthestBlock.node, clone);
             appendElement(clone, furthestBlock.node);
@@ -4961,26 +4980,31 @@ public abstract class TreeBuilder<T> imp
         while (entryPos < listPtr) {
             entryPos++;
             StackNode<T> entry = listOfActiveFormattingElements[entryPos];
             StackNode<T> currentNode = stack[currentPtr];
 
             T clone;
             if (currentNode.isFosterParenting()) {
                 clone = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", entry.name,
-                        entry.attributes.cloneAttributes(null));
+                        entry.attributes.cloneAttributes(null)
+                        // CPPONLY: , htmlCreator(entry.getHtmlCreator())
+                        );
             } else {
                 clone = createElement("http://www.w3.org/1999/xhtml", entry.name,
-                        entry.attributes.cloneAttributes(null), currentNode.node);
+                        entry.attributes.cloneAttributes(null), currentNode.node
+                        // CPPONLY: , htmlCreator(entry.getHtmlCreator())
+                        );
                 appendElement(clone, currentNode.node);
             }
 
             StackNode<T> entryClone = createStackNode(entry.getFlags(),
                     entry.ns, entry.name, clone, entry.popName,
                     entry.attributes
+                    // CPPONLY: , entry.getHtmlCreator()
                     // [NOCPP[
                     , entry.getLocator()
                     // ]NOCPP]
             );
 
             entry.dropAttributes(); // transfer ownership to entryClone
 
             push(entryClone);
@@ -5024,22 +5048,24 @@ public abstract class TreeBuilder<T> imp
         // Create a new stack node and return it.
         stackNodes[stackNodesIdx] = new StackNode<T>(stackNodesIdx);
         numStackNodes++;
         return stackNodes[stackNodesIdx++];
     }
 
     private StackNode<T> createStackNode(int flags, @NsUri String ns, @Local String name, T node,
             @Local String popName, HtmlAttributes attributes
+            // CPPONLY: , @HtmlCreator Object htmlCreator
             // [NOCPP[
             , TaintableLocatorImpl locator
             // ]NOCPP]
     ) {
         StackNode<T> instance = getUnusedStackNode();
         instance.setValues(flags, ns, name, node, popName, attributes
+                // CPPONLY: , htmlCreator
                 // [NOCPP[
                 , locator
                 // ]NOCPP]
         );
         return instance;
     }
 
     private StackNode<T> createStackNode(ElementName elementName, T node
@@ -5122,33 +5148,43 @@ public abstract class TreeBuilder<T> imp
             return;
         }
 
         StackNode<T> node = stack[tablePos];
         insertFosterParentedChild(child, node.node, stack[tablePos - 1].node);
     }
 
     private T createAndInsertFosterParentedElement(@NsUri String ns, @Local String name,
-            HtmlAttributes attributes) throws SAXException {
-        return createAndInsertFosterParentedElement(ns, name, attributes, null);
+            HtmlAttributes attributes
+            // CPPONLY: , @Creator Object creator
+            ) throws SAXException {
+        return createAndInsertFosterParentedElement(ns, name, attributes, null
+                // CPPONLY: , creator
+                );
     }
 
     private T createAndInsertFosterParentedElement(@NsUri String ns, @Local String name,
-            HtmlAttributes attributes, T form) throws SAXException {
+            HtmlAttributes attributes, T form
+            // CPPONLY: , @Creator Object creator
+            ) throws SAXException {
         int tablePos = findLastOrRoot(TreeBuilder.TABLE);
         int templatePos = findLastOrRoot(TreeBuilder.TEMPLATE);
 
         if (templatePos >= tablePos) {
-            T child = createElement(ns, name, attributes, form, stack[templatePos].node);
+            T child = createElement(ns, name, attributes, form, stack[templatePos].node
+                    // CPPONLY: , creator
+                    );
             appendElement(child, stack[templatePos].node);
             return child;
         }
 
         StackNode<T> node = stack[tablePos];
-        return createAndInsertFosterParentedElement(ns, name, attributes, form, node.node, stack[tablePos - 1].node);
+        return createAndInsertFosterParentedElement(ns, name, attributes, form, node.node, stack[tablePos - 1].node
+                // CPPONLY: , creator
+                );
     }
 
     private boolean isInStack(StackNode<T> node) {
         for (int i = currentPtr; i >= 0; i--) {
             if (stack[i] == node) {
                 return true;
             }
         }
@@ -5296,17 +5332,22 @@ public abstract class TreeBuilder<T> imp
     }
 
     private void appendToCurrentNodeAndPushHeadElement(HtmlAttributes attributes)
             throws SAXException {
         // [NOCPP[
         checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         T currentNode = stack[currentPtr].node;
-        T elt = createElement("http://www.w3.org/1999/xhtml", "head", attributes, currentNode);
+        T elt = createElement("http://www.w3.org/1999/xhtml", "head", attributes, currentNode
+                /*
+                 * head uses NS_NewHTMLSharedElement creator
+                 */
+                // CPPONLY: , htmlCreator(NS_NewHTMLSharedElement)
+                );
         appendElement(elt, currentNode);
         headPointer = elt;
         StackNode<T> node = createStackNode(ElementName.HEAD,
                 elt
                 // [NOCPP[
                 , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
         // ]NOCPP]
         );
@@ -5328,19 +5369,23 @@ public abstract class TreeBuilder<T> imp
         // [NOCPP[
         checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
 
         T elt;
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
-            elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", "form", attributes);
+            elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", "form", attributes
+                    // CPPONLY: , htmlCreator(NS_NewHTMLFormElement)
+                    );
         } else {
-            elt = createElement("http://www.w3.org/1999/xhtml", "form", attributes, current.node);
+            elt = createElement("http://www.w3.org/1999/xhtml", "form", attributes, current.node
+                    // CPPONLY: , htmlCreator(NS_NewHTMLFormElement)
+                    );
             appendElement(elt, current.node);
         }
 
         if (!isTemplateContents()) {
             formPointer = elt;
         }
 
         StackNode<T> node = createStackNode(ElementName.FORM,
@@ -5361,19 +5406,23 @@ public abstract class TreeBuilder<T> imp
         // This method can't be called for custom elements
         HtmlAttributes clone = attributes.cloneAttributes(null);
         // Attributes must not be read after calling createElement, because
         // createElement may delete attributes in C++.
         T elt;
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
-            elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes);
+            elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes
+                    // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
+                    );
         } else {
-            elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, current.node);
+            elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, current.node
+                    // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
+                    );
             appendElement(elt, current.node);
         }
         StackNode<T> node = createStackNode(elementName, elt, clone
                 // [NOCPP[
                 , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
         // ]NOCPP]
         );
         push(node);
@@ -5384,17 +5433,19 @@ public abstract class TreeBuilder<T> imp
     private void appendToCurrentNodeAndPushElement(ElementName elementName,
             HtmlAttributes attributes)
             throws SAXException {
         // [NOCPP[
         checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         // This method can't be called for custom elements
         T currentNode = stack[currentPtr].node;
-        T elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, currentNode);
+        T elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, currentNode
+                // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
+                );
         appendElement(elt, currentNode);
         if (ElementName.TEMPLATE == elementName) {
             elt = getDocumentFragmentForTemplate(elt);
         }
         StackNode<T> node = createStackNode(elementName, elt
                 // [NOCPP[
                 , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
         // ]NOCPP]
@@ -5411,19 +5462,23 @@ public abstract class TreeBuilder<T> imp
         if (!elementName.isInterned()) {
             popName = checkPopName(popName);
         }
         // ]NOCPP]
         T elt;
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
-            elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", popName, attributes);
+            elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", popName, attributes
+                    // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
+                    );
         } else {
-            elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node);
+            elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node
+                    // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
+                    );
             appendElement(elt, current.node);
         }
         StackNode<T> node = createStackNode(elementName, elt, popName
                 // [NOCPP[
                 , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
         // ]NOCPP]
         );
         push(node);
@@ -5445,19 +5500,23 @@ public abstract class TreeBuilder<T> imp
             markAsHtmlIntegrationPoint = true;
         }
         // Attributes must not be read after calling createElement(), since
         // createElement may delete the object in C++.
         T elt;
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
-            elt = createAndInsertFosterParentedElement("http://www.w3.org/1998/Math/MathML", popName, attributes);
+            elt = createAndInsertFosterParentedElement("http://www.w3.org/1998/Math/MathML", popName, attributes
+                    // CPPONLY: , htmlCreator(null)
+                    );
         } else {
-            elt  = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node);
+            elt  = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node
+                    // CPPONLY: , htmlCreator(null)
+                    );
             appendElement(elt, current.node);
         }
         StackNode<T> node = createStackNode(elementName, elt, popName,
                 markAsHtmlIntegrationPoint
                 // [NOCPP[
                 , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
         // ]NOCPP]
         );
@@ -5494,19 +5553,23 @@ public abstract class TreeBuilder<T> imp
         if (!elementName.isInterned()) {
             popName = checkPopName(popName);
         }
         // ]NOCPP]
         T elt;
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
-            elt = createAndInsertFosterParentedElement("http://www.w3.org/2000/svg", popName, attributes);
+            elt = createAndInsertFosterParentedElement("http://www.w3.org/2000/svg", popName, attributes
+                    // CPPONLY: , svgCreator(elementName.getSvgCreator())
+                    );
         } else {
-            elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node);
+            elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node
+                    // CPPONLY: , svgCreator(elementName.getSvgCreator())
+                    );
             appendElement(elt, current.node);
         }
         StackNode<T> node = createStackNode(elementName, popName, elt
                 // [NOCPP[
                 , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
         // ]NOCPP]
         );
         push(node);
@@ -5520,46 +5583,55 @@ public abstract class TreeBuilder<T> imp
         // ]NOCPP]
         // Can't be called for custom elements
         T elt;
         T formOwner = form == null || fragment || isTemplateContents() ? null : form;
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.getName(),
-                    attributes, formOwner);
+                    attributes, formOwner
+                    // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
+                    );
         } else {
             elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(),
-                    attributes, formOwner, current.node);
+                    attributes, formOwner, current.node
+                    // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
+                    );
             appendElement(elt, current.node);
         }
         StackNode<T> node = createStackNode(elementName, elt
                 // [NOCPP[
                 , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
         // ]NOCPP]
         );
         push(node);
     }
 
     private void appendVoidElementToCurrentMayFoster(
-            @Local String name, HtmlAttributes attributes, T form) throws SAXException {
+            ElementName elementName, HtmlAttributes attributes, T form) throws SAXException {
+        @Local String name = elementName.getName();
         // [NOCPP[
         checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         // Can't be called for custom elements
         T elt;
         T formOwner = form == null || fragment || isTemplateContents() ? null : form;
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", name,
-                    attributes, formOwner);
+                    attributes, formOwner
+                    // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
+                    );
         } else {
             elt = createElement("http://www.w3.org/1999/xhtml", name,
-                    attributes, formOwner, current.node);
+                    attributes, formOwner, current.node
+                    // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
+                    );
             appendElement(elt, current.node);
         }
         elementPushed("http://www.w3.org/1999/xhtml", name, elt);
         elementPopped("http://www.w3.org/1999/xhtml", name, elt);
     }
 
     private void appendVoidElementToCurrentMayFoster(
             ElementName elementName, HtmlAttributes attributes)
@@ -5570,19 +5642,23 @@ public abstract class TreeBuilder<T> imp
         if (!elementName.isInterned()) {
             popName = checkPopName(popName);
         }
         // ]NOCPP]
         T elt;
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
-            elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", popName, attributes);
+            elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", popName, attributes
+                    // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
+                    );
         } else {
-            elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node);
+            elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node
+                    // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
+                    );
             appendElement(elt, current.node);
         }
         elementPushed("http://www.w3.org/1999/xhtml", popName, elt);
         elementPopped("http://www.w3.org/1999/xhtml", popName, elt);
     }
 
     private void appendVoidElementToCurrentMayFosterSVG(
             ElementName elementName, HtmlAttributes attributes)
@@ -5593,19 +5669,23 @@ public abstract class TreeBuilder<T> imp
         if (!elementName.isInterned()) {
             popName = checkPopName(popName);
         }
         // ]NOCPP]
         T elt;
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
-            elt = createAndInsertFosterParentedElement("http://www.w3.org/2000/svg", popName, attributes);
+            elt = createAndInsertFosterParentedElement("http://www.w3.org/2000/svg", popName, attributes
+                    // CPPONLY: , svgCreator(elementName.getSvgCreator())
+                    );
         } else {
-            elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node);
+            elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node
+                    // CPPONLY: , svgCreator(elementName.getSvgCreator())
+                    );
             appendElement(elt, current.node);
         }
         elementPushed("http://www.w3.org/2000/svg", popName, elt);
         elementPopped("http://www.w3.org/2000/svg", popName, elt);
     }
 
     private void appendVoidElementToCurrentMayFosterMathML(
             ElementName elementName, HtmlAttributes attributes)
@@ -5616,46 +5696,53 @@ public abstract class TreeBuilder<T> imp
         if (!elementName.isInterned()) {
             popName = checkPopName(popName);
         }
         // ]NOCPP]
         T elt;
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
-            elt = createAndInsertFosterParentedElement("http://www.w3.org/1998/Math/MathML", popName, attributes);
+            elt = createAndInsertFosterParentedElement("http://www.w3.org/1998/Math/MathML", popName, attributes
+                    // CPPONLY: , htmlCreator(null)
+                    );
         } else {
-            elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node);
+            elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node
+                    // CPPONLY: , htmlCreator(null)
+                    );
             appendElement(elt, current.node);
         }
         elementPushed("http://www.w3.org/1998/Math/MathML", popName, elt);
         elementPopped("http://www.w3.org/1998/Math/MathML", popName, elt);
     }
 
-    private void appendVoidElementToCurrent(
-            @Local String name, HtmlAttributes attributes, T form) throws SAXException {
+    private void appendVoidInputToCurrent(HtmlAttributes attributes, T form) throws SAXException {
         // [NOCPP[
         checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         // Can't be called for custom elements
         T currentNode = stack[currentPtr].node;
-        T elt = createElement("http://www.w3.org/1999/xhtml", name, attributes,
-                form == null || fragment || isTemplateContents() ? null : form, currentNode);
+        T elt = createElement("http://www.w3.org/1999/xhtml", "input", attributes,
+                form == null || fragment || isTemplateContents() ? null : form, currentNode
+                        // CPPONLY: , htmlCreator(NS_NewHTMLInputElement)
+                        );
         appendElement(elt, currentNode);
-        elementPushed("http://www.w3.org/1999/xhtml", name, elt);
-        elementPopped("http://www.w3.org/1999/xhtml", name, elt);
+        elementPushed("http://www.w3.org/1999/xhtml", "input", elt);
+        elementPopped("http://www.w3.org/1999/xhtml", "input", elt);
     }
 
     private void appendVoidFormToCurrent(HtmlAttributes attributes) throws SAXException {
         // [NOCPP[
         checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         T currentNode = stack[currentPtr].node;
         T elt = createElement("http://www.w3.org/1999/xhtml", "form",
-                attributes, currentNode);
+                attributes, currentNode
+                // CPPONLY: , htmlCreator(NS_NewHTMLFormElement)
+                );
         formPointer = elt;
         // ownership transferred to form pointer
         appendElement(elt, currentNode);
         elementPushed("http://www.w3.org/1999/xhtml", "form", elt);
         elementPopped("http://www.w3.org/1999/xhtml", "form", elt);
     }
 
     // [NOCPP[
@@ -5697,21 +5784,27 @@ public abstract class TreeBuilder<T> imp
 
     // ------------------------------- //
 
     protected final void requestSuspension() {
         tokenizer.requestSuspension();
     }
 
     protected abstract T createElement(@NsUri String ns, @Local String name,
-            HtmlAttributes attributes, T intendedParent) throws SAXException;
+            HtmlAttributes attributes, T intendedParent
+            // CPPONLY: , @Creator Object creator
+            ) throws SAXException;
 
     protected T createElement(@NsUri String ns, @Local String name,
-            HtmlAttributes attributes, T form, T intendedParent) throws SAXException {
-        return createElement("http://www.w3.org/1999/xhtml", name, attributes, intendedParent);
+            HtmlAttributes attributes, T form, T intendedParent
+            // CPPONLY: , @Creator Object creator
+            ) throws SAXException {
+        return createElement("http://www.w3.org/1999/xhtml", name, attributes, intendedParent
+                // CPPONLY: , creator
+                );
     }
 
     protected abstract T createHtmlElementSetAsRoot(HtmlAttributes attributes)
             throws SAXException;
 
     protected abstract void detachFromParent(T element) throws SAXException;
 
     protected abstract boolean hasChildren(T element) throws SAXException;
@@ -5730,17 +5823,19 @@ public abstract class TreeBuilder<T> imp
     // [NOCPP[
 
     protected abstract T createAndInsertFosterParentedElement(@NsUri String ns, @Local String name,
             HtmlAttributes attributes, T table, T stackParent) throws SAXException;
 
     // ]NOCPP]
 
     protected T createAndInsertFosterParentedElement(@NsUri String ns, @Local String name,
-            HtmlAttributes attributes, T form, T table, T stackParent) throws SAXException {
+            HtmlAttributes attributes, T form, T table, T stackParent
+            // CPPONLY: , @Creator Object creator
+            ) throws SAXException {
         return createAndInsertFosterParentedElement(ns, name, attributes, table, stackParent);
     };
 
     protected abstract void insertFosterParentedCharacters(
             @NoLength char[] buf, int start, int length, T table, T stackParent)
             throws SAXException;
 
     protected abstract void appendCharacters(T parent, @NoLength char[] buf,
@@ -6011,16 +6106,17 @@ public abstract class TreeBuilder<T> imp
         StackNode<T>[] listCopy = new StackNode[listPtr + 1];
         for (int i = 0; i < listCopy.length; i++) {
             StackNode<T> node = listOfActiveFormattingElements[i];
             if (node != null) {
                 StackNode<T> newNode = new StackNode<T>(-1);
                 newNode.setValues(node.getFlags(), node.ns,
                         node.name, node.node, node.popName,
                         node.attributes.cloneAttributes(null)
+                        // CPPONLY: , node.getHtmlCreator()
                         // [NOCPP[
                         , node.getLocator()
                         // ]NOCPP]
                 );
                 listCopy[i] = newNode;
             } else {
                 listCopy[i] = null;
             }
@@ -6029,16 +6125,17 @@ public abstract class TreeBuilder<T> imp
         for (int i = 0; i < stackCopy.length; i++) {
             StackNode<T> node = stack[i];
             int listIndex = findInListOfActiveFormattingElements(node);
             if (listIndex == -1) {
                 StackNode<T> newNode = new StackNode<T>(-1);
                 newNode.setValues(node.getFlags(), node.ns,
                         node.name, node.node, node.popName,
                         null
+                        // CPPONLY: , node.getHtmlCreator()
                         // [NOCPP[
                         , node.getLocator()
                         // ]NOCPP]
                 );
                 stackCopy[i] = newNode;
             } else {
                 stackCopy[i] = listCopy[listIndex];
                 stackCopy[i].retain();
@@ -6134,16 +6231,17 @@ public abstract class TreeBuilder<T> imp
 
         for (int i = 0; i < listLen; i++) {
             StackNode<T> node = listCopy[i];
             if (node != null) {
                 StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
                         Portability.newLocalFromLocal(node.name, interner), node.node,
                         Portability.newLocalFromLocal(node.popName, interner),
                         node.attributes.cloneAttributes(null)
+                        // CPPONLY: , node.getHtmlCreator()
                         // [NOCPP[
                         , node.getLocator()
                 // ]NOCPP]
                 );
                 listOfActiveFormattingElements[i] = newNode;
             } else {
                 listOfActiveFormattingElements[i] = null;
             }
@@ -6151,16 +6249,17 @@ public abstract class TreeBuilder<T> imp
         for (int i = 0; i < stackLen; i++) {
             StackNode<T> node = stackCopy[i];
             int listIndex = findInArray(node, listCopy);
             if (listIndex == -1) {
                 StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
                         Portability.newLocalFromLocal(node.name, interner), node.node,
                         Portability.newLocalFromLocal(node.popName, interner),
                         null
+                        // CPPONLY: , node.getHtmlCreator()
                         // [NOCPP[
                         , node.getLocator()
                 // ]NOCPP]
                 );
                 stack[i] = newNode;
             } else {
                 stack[i] = listOfActiveFormattingElements[listIndex];
                 stack[i].retain();
--- a/parser/html/moz.build
+++ b/parser/html/moz.build
@@ -15,16 +15,17 @@ EXPORTS += [
     'jArray.h',
     'nsAHtml5TreeBuilderState.h',
     'nsAHtml5TreeOpSink.h',
     'nsHtml5ArrayCopy.h',
     'nsHtml5AtomTable.h',
     'nsHtml5AttributeEntry.h',
     'nsHtml5AttributeName.h',
     'nsHtml5ByteReadable.h',
+    'nsHtml5ContentCreatorFunction.h',
     'nsHtml5DependentUTF16Buffer.h',
     'nsHtml5DocumentBuilder.h',
     'nsHtml5DocumentMode.h',
     'nsHtml5HtmlAttributes.h',
     'nsHtml5Macros.h',
     'nsHtml5MetaScanner.h',
     'nsHtml5MetaScannerHSupplement.h',
     'nsHtml5Module.h',
--- a/parser/html/nsHtml5AttributeName.cpp
+++ b/parser/html/nsHtml5AttributeName.cpp
@@ -36,16 +36,17 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 #include "nsHtml5ElementName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5MetaScanner.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5StateSnapshot.h"
--- a/parser/html/nsHtml5AttributeName.h
+++ b/parser/html/nsHtml5AttributeName.h
@@ -37,16 +37,17 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 class nsHtml5StreamParser;
 
 class nsHtml5ElementName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
 class nsHtml5UTF16Buffer;
new file mode 100644
--- /dev/null
+++ b/parser/html/nsHtml5ContentCreatorFunction.h
@@ -0,0 +1,17 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef nsHtml5ContentCreatorFunction_h
+#define nsHtml5ContentCreatorFunction_h
+
+#include "nsGenericHTMLElement.h"
+#include "mozilla/dom/SVGElementFactory.h"
+
+union nsHtml5ContentCreatorFunction
+{
+  mozilla::dom::HTMLContentCreatorFunction html;
+  mozilla::dom::SVGContentCreatorFunction svg;
+};
+
+#endif // nsHtml5ContentCreatorFunction_h
--- a/parser/html/nsHtml5ElementName.cpp
+++ b/parser/html/nsHtml5ElementName.cpp
@@ -36,40 +36,49 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 #include "nsHtml5AttributeName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5MetaScanner.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5StateSnapshot.h"
 #include "nsHtml5Portability.h"
 
 #include "nsHtml5ElementName.h"
 
-
-nsHtml5ElementName::nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, int32_t flags)
-  : name(name),
-    camelCaseName(camelCaseName),
-    flags(flags)
+nsHtml5ElementName::nsHtml5ElementName(
+  nsIAtom* name,
+  nsIAtom* camelCaseName,
+  mozilla::dom::HTMLContentCreatorFunction htmlCreator,
+  mozilla::dom::SVGContentCreatorFunction svgCreator,
+  int32_t flags)
+  : name(name)
+  , camelCaseName(camelCaseName)
+  , htmlCreator(htmlCreator)
+  , svgCreator(svgCreator)
+  , flags(flags)
 {
   MOZ_COUNT_CTOR(nsHtml5ElementName);
 }
 
 nsHtml5ElementName::nsHtml5ElementName()
   : name(nullptr)
   , camelCaseName(nullptr)
+  , htmlCreator(NS_NewHTMLUnknownElement)
+  , svgCreator(NS_NewSVGUnknownElement)
   , flags(nsHtml5TreeBuilder::OTHER | NOT_INTERNED)
 {
   MOZ_COUNT_CTOR(nsHtml5ElementName);
 }
 
 
 nsHtml5ElementName::~nsHtml5ElementName()
 {
@@ -109,16 +118,17 @@ nsHtml5ElementName* nsHtml5ElementName::
 nsHtml5ElementName* nsHtml5ElementName::ELT_U = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_H1 = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_H2 = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_H3 = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_H4 = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_H5 = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_H6 = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_AREA = nullptr;
+nsHtml5ElementName* nsHtml5ElementName::ELT_DATA = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FEFUNCA = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_METADATA = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_META = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_TEXTAREA = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FEFUNCB = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_RB = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_DESC = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_DD = nullptr;
@@ -242,16 +252,18 @@ nsHtml5ElementName* nsHtml5ElementName::
 nsHtml5ElementName* nsHtml5ElementName::ELT_DEFS = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_DETAILS = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_MS = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_NOFRAMES = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_PROGRESS = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_DT = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_APPLET = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_BASEFONT = nullptr;
+nsHtml5ElementName* nsHtml5ElementName::ELT_CONTENT = nullptr;
+nsHtml5ElementName* nsHtml5ElementName::ELT_DATALIST = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FOREIGNOBJECT = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FIELDSET = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FRAMESET = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FEOFFSET = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FESPOTLIGHT = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FEPOINTLIGHT = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FEDISTANTLIGHT = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FONT = nullptr;
@@ -267,840 +279,1367 @@ nsHtml5ElementName* nsHtml5ElementName::
 nsHtml5ElementName* nsHtml5ElementName::ELT_RECT = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_RADIALGRADIENT = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_SELECT = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_SCRIPT = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_TFOOT = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_TEXT = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_MENU = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FEDROPSHADOW = nullptr;
+nsHtml5ElementName* nsHtml5ElementName::ELT_SHADOW = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_VIEW = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FECOLORMATRIX = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FECONVOLVEMATRIX = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_BODY = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_FEMORPHOLOGY = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_RUBY = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_SUMMARY = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_TBODY = nullptr;
 nsHtml5ElementName** nsHtml5ElementName::ELEMENT_NAMES = 0;
 static int32_t const ELEMENT_HASHES_DATA[] = {
-  1903302038, 1749656156, 2001349704, 893386754,  1803929812, 1968836118,
-  2007601444, 59821379,   1733054663, 1756625221, 1870268949, 1941178676,
-  1983633431, 2004635806, 2060065124, 55104723,   62450211,   1686491348,
-  1747176599, 1751288021, 1783210839, 1853642948, 1884120164, 1914900309,
-  1967788867, 1973420034, 1998585858, 2001392796, 2006028454, 2008851557,
+  1902641154, 1749395095, 2001349720, 893386754,  1803876550, 1971938532,
+  2007781534, 59821379,   1732381397, 1756600614, 1870135298, 1939219752,
+  1990037800, 2005324101, 2060065124, 55104723,   62450211,   1686489160,
+  1747048757, 1749932347, 1782357526, 1818755074, 1881669634, 1907959605,
+  1967760215, 1983533124, 1999917383, 2001392798, 2006329158, 2008994116,
   2085266636, 52485715,   57733651,   60354131,   67633153,   960495618,
-  1715310660, 1737099991, 1748100148, 1749801286, 1755076808, 1757268168,
-  1790207270, 1806806678, 1857653029, 1881288348, 1898753862, 1906135367,
-  1934172497, 1965334268, 1967795958, 1971465813, 1982935782, 1988763672,
-  1999397992, 2001349736, 2001495140, 2005719336, 2006896969, 2008125638,
-  2021937364, 2068523856, 2092255447, 51438659,   52488851,   56151587,
+  1703936002, 1736200310, 1747838298, 1749723735, 1753362711, 1757157700,
+  1786534215, 1805647874, 1854245076, 1874102998, 1898223949, 1906087319,
+  1932928296, 1965115924, 1968053806, 1982173479, 1986527234, 1998724870,
+  2001309869, 2001392795, 2003183333, 2005925890, 2006974466, 2008340774,
+  2051837468, 2068523856, 2092255447, 51438659,   52488851,   56151587,
   59244545,   60347747,   61925907,   63438849,   69730305,   926941186,
-  1682547543, 1699324759, 1730965751, 1733890180, 1740181637, 1747814436,
-  1748359220, 1749715159, 1749905526, 1752979652, 1756474198, 1757146773,
-  1766992520, 1783388498, 1798686984, 1805502724, 1818230786, 1854228698,
-  1868312196, 1874053333, 1881613047, 1889085973, 1900845386, 1905563974,
-  1907661127, 1925844629, 1938817026, 1963982850, 1967128578, 1967795910,
-  1968053806, 1971461414, 1971938532, 1982173479, 1983533124, 1986527234,
-  1990037800, 1998724870, 2001309869, 2001349720, 2001392795, 2001392798,
-  2003183333, 2005324101, 2005925890, 2006329158, 2006974466, 2007781534,
-  2008340774, 2008994116, 2051837468, 2068523853, 2083120164, 2091479332,
+  1681770564, 1689922072, 1730150402, 1733076167, 1738539010, 1747306711,
+  1748225318, 1749673195, 1749813541, 1751386406, 1755148615, 1757137429,
+  1763839627, 1783388497, 1797585096, 1803929861, 1807599880, 1854228692,
+  1864368130, 1873281026, 1881498736, 1887579800, 1899272519, 1904412884,
+  1907435316, 1919418370, 1935549734, 1941221172, 1966223078, 1967795910,
+  1971461414, 1973420034, 1982935782, 1983633431, 1988763672, 1998585858,
+  1999397992, 2000525512, 2001349704, 2001349736, 2001392796, 2001495140,
+  2004635806, 2005719336, 2006028454, 2006896969, 2007601444, 2008125638,
+  2008851557, 2021937364, 2058653206, 2068523853, 2083120164, 2091479332,
   2092557349, 51434643,   51961587,   52486755,   52490899,   55110883,
   57206291,   58773795,   59768833,   60345171,   60352339,   61395251,
   62390273,   62973651,   67108865,   68681729,   876609538,  910163970,
-  943718402,  1679960596, 1686489160, 1689922072, 1703936002, 1730150402,
-  1732381397, 1733076167, 1736200310, 1738539010, 1747048757, 1747306711,
-  1747838298, 1748225318, 1749395095, 1749673195, 1749723735, 1749813541,
-  1749932347, 1751386406, 1753362711, 1755148615, 1756600614, 1757137429,
-  1757157700, 1763839627, 1782357526, 1783388497, 1786534215, 1797585096,
-  1803876550, 1803929861, 1805647874, 1807599880, 1818755074, 1854228692,
-  1854245076, 1864368130, 1870135298, 1873281026, 1874102998, 1881498736,
-  1881669634, 1887579800, 1898223949, 1899272519, 1902641154, 1904412884,
-  1906087319, 1907435316, 1907959605, 1919418370, 1932928296, 1935549734,
-  1939219752, 1941221172, 1965115924, 1966223078, 1967760215
+  943718402,  1679960596, 1682547543, 1686491348, 1699324759, 1715310660,
+  1730965751, 1733054663, 1733890180, 1737099991, 1740181637, 1747176599,
+  1747814436, 1748100148, 1748359220, 1749656156, 1749715159, 1749801286,
+  1749905526, 1751288021, 1752979652, 1755076808, 1756474198, 1756625221,
+  1757146773, 1757268168, 1766992520, 1783210839, 1783388498, 1790207270,
+  1798686984, 1803929812, 1805502724, 1806806678, 1818230786, 1853642948,
+  1854228698, 1857653029, 1868312196, 1870268949, 1874053333, 1881288348,
+  1881613047, 1884120164, 1889085973, 1898753862, 1900845386, 1903302038,
+  1905563974, 1906135367, 1907661127, 1914900309, 1925844629, 1934172497,
+  1938817026, 1941178676, 1963982850, 1965334268, 1967128578, 1967788867,
+  1967795958, 1968836118, 1971465813
 };
 staticJArray<int32_t,int32_t> nsHtml5ElementName::ELEMENT_HASHES = { ELEMENT_HASHES_DATA, MOZ_ARRAY_LENGTH(ELEMENT_HASHES_DATA) };
 void
 nsHtml5ElementName::initializeStatics()
 {
   ELT_ANNOTATION_XML = new nsHtml5ElementName(
     nsGkAtoms::annotation_xml_,
     nsGkAtoms::annotation_xml_,
+    NS_NewHTMLUnknownElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::ANNOTATION_XML | SCOPING_AS_MATHML);
   ELT_BIG = new nsHtml5ElementName(
     nsGkAtoms::big,
     nsGkAtoms::big,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
       B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-  ELT_BDO = new nsHtml5ElementName(
-    nsGkAtoms::bdo, nsGkAtoms::bdo, nsHtml5TreeBuilder::OTHER);
-  ELT_COL = new nsHtml5ElementName(
-    nsGkAtoms::col, nsGkAtoms::col, nsHtml5TreeBuilder::COL | SPECIAL);
-  ELT_DEL = new nsHtml5ElementName(
-    nsGkAtoms::del, nsGkAtoms::del, nsHtml5TreeBuilder::OTHER);
-  ELT_DFN = new nsHtml5ElementName(
-    nsGkAtoms::dfn, nsGkAtoms::dfn, nsHtml5TreeBuilder::OTHER);
+  ELT_BDO = new nsHtml5ElementName(nsGkAtoms::bdo,
+                                   nsGkAtoms::bdo,
+                                   NS_NewHTMLElement,
+                                   NS_NewSVGUnknownElement,
+                                   nsHtml5TreeBuilder::OTHER);
+  ELT_COL = new nsHtml5ElementName(nsGkAtoms::col,
+                                   nsGkAtoms::col,
+                                   NS_NewHTMLTableColElement,
+                                   NS_NewSVGUnknownElement,
+                                   nsHtml5TreeBuilder::COL | SPECIAL);
+  ELT_DEL = new nsHtml5ElementName(nsGkAtoms::del,
+                                   nsGkAtoms::del,
+                                   NS_NewHTMLModElement,
+                                   NS_NewSVGUnknownElement,
+                                   nsHtml5TreeBuilder::OTHER);
+  ELT_DFN = new nsHtml5ElementName(nsGkAtoms::dfn,
+                                   nsGkAtoms::dfn,
+                                   NS_NewHTMLElement,
+                                   NS_NewSVGUnknownElement,
+                                   nsHtml5TreeBuilder::OTHER);
   ELT_DIR = new nsHtml5ElementName(
     nsGkAtoms::dir,
     nsGkAtoms::dir,
+    NS_NewHTMLSharedElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
   ELT_DIV = new nsHtml5ElementName(
     nsGkAtoms::div,
     nsGkAtoms::div,
+    NS_NewHTMLDivElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
-  ELT_IMG = new nsHtml5ElementName(
-    nsGkAtoms::img, nsGkAtoms::img, nsHtml5TreeBuilder::IMG | SPECIAL);
-  ELT_INS = new nsHtml5ElementName(
-    nsGkAtoms::ins, nsGkAtoms::ins, nsHtml5TreeBuilder::OTHER);
-  ELT_KBD = new nsHtml5ElementName(
-    nsGkAtoms::kbd, nsGkAtoms::kbd, nsHtml5TreeBuilder::OTHER);
-  ELT_MAP = new nsHtml5ElementName(
-    nsGkAtoms::map, nsGkAtoms::map, nsHtml5TreeBuilder::OTHER);
+  ELT_IMG = new nsHtml5ElementName(nsGkAtoms::img,
+                                   nsGkAtoms::img,
+                                   NS_NewHTMLImageElement,
+                                   NS_NewSVGUnknownElement,
+                                   nsHtml5TreeBuilder::IMG | SPECIAL);
+  ELT_INS = new nsHtml5ElementName(nsGkAtoms::ins,
+                                   nsGkAtoms::ins,
+                                   NS_NewHTMLModElement,
+                                   NS_NewSVGUnknownElement,
+                                   nsHtml5TreeBuilder::OTHER);
+  ELT_KBD = new nsHtml5ElementName(nsGkAtoms::kbd,
+                                   nsGkAtoms::kbd,
+                                   NS_NewHTMLElement,
+                                   NS_NewSVGUnknownElement,
+                                   nsHtml5TreeBuilder::OTHER);
+  ELT_MAP = new nsHtml5ElementName(nsGkAtoms::map,
+                                   nsGkAtoms::map,
+                                   NS_NewHTMLMapElement,
+                                   NS_NewSVGUnknownElement,
+                                   nsHtml5TreeBuilder::OTHER);
   ELT_NAV = new nsHtml5ElementName(
     nsGkAtoms::nav,
     nsGkAtoms::nav,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
   ELT_PRE =
     new nsHtml5ElementName(nsGkAtoms::pre,
                            nsGkAtoms::pre,
+                           NS_NewHTMLPreElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::PRE_OR_LISTING | SPECIAL);
-  ELT_A =
-    new nsHtml5ElementName(nsGkAtoms::a, nsGkAtoms::a, nsHtml5TreeBuilder::A);
+  ELT_A = new nsHtml5ElementName(nsGkAtoms::a,
+                                 nsGkAtoms::a,
+                                 NS_NewHTMLAnchorElement,
+                                 NS_NewSVGAElement,
+                                 nsHtml5TreeBuilder::A);
   ELT_B = new nsHtml5ElementName(
     nsGkAtoms::b,
     nsGkAtoms::b,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
       B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_RTC =
     new nsHtml5ElementName(nsGkAtoms::rtc,
                            nsGkAtoms::rtc,
+                           NS_NewHTMLElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::RB_OR_RTC | OPTIONAL_END_TAG);
   ELT_SUB = new nsHtml5ElementName(
     nsGkAtoms::sub,
     nsGkAtoms::sub,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
-  ELT_SVG = new nsHtml5ElementName(
-    nsGkAtoms::svg, nsGkAtoms::svg, nsHtml5TreeBuilder::SVG);
+  ELT_SVG = new nsHtml5ElementName(nsGkAtoms::svg,
+                                   nsGkAtoms::svg,
+                                   NS_NewHTMLUnknownElement,
+                                   NS_NewSVGSVGElement,
+                                   nsHtml5TreeBuilder::SVG);
   ELT_SUP = new nsHtml5ElementName(
     nsGkAtoms::sup,
     nsGkAtoms::sup,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
-  ELT_SET = new nsHtml5ElementName(
-    nsGkAtoms::set_, nsGkAtoms::set_, nsHtml5TreeBuilder::OTHER);
-  ELT_USE = new nsHtml5ElementName(
-    nsGkAtoms::use, nsGkAtoms::use, nsHtml5TreeBuilder::OTHER);
+  ELT_SET = new nsHtml5ElementName(nsGkAtoms::set_,
+                                   nsGkAtoms::set_,
+                                   NS_NewHTMLUnknownElement,
+                                   NS_NewSVGSetElement,
+                                   nsHtml5TreeBuilder::OTHER);
+  ELT_USE = new nsHtml5ElementName(nsGkAtoms::use,
+                                   nsGkAtoms::use,
+                                   NS_NewHTMLUnknownElement,
+                                   NS_NewSVGUseElement,
+                                   nsHtml5TreeBuilder::OTHER);
   ELT_VAR = new nsHtml5ElementName(
     nsGkAtoms::var,
     nsGkAtoms::var,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
-  ELT_G = new nsHtml5ElementName(
-    nsGkAtoms::g, nsGkAtoms::g, nsHtml5TreeBuilder::OTHER);
-  ELT_WBR = new nsHtml5ElementName(
-    nsGkAtoms::wbr, nsGkAtoms::wbr, nsHtml5TreeBuilder::AREA_OR_WBR | SPECIAL);
-  ELT_XMP = new nsHtml5ElementName(
-    nsGkAtoms::xmp, nsGkAtoms::xmp, nsHtml5TreeBuilder::XMP | SPECIAL);
+  ELT_G = new nsHtml5ElementName(nsGkAtoms::g,
+                                 nsGkAtoms::g,
+                                 NS_NewHTMLUnknownElement,
+                                 NS_NewSVGGElement,
+                                 nsHtml5TreeBuilder::OTHER);
+  ELT_WBR = new nsHtml5ElementName(nsGkAtoms::wbr,
+                                   nsGkAtoms::wbr,
+                                   NS_NewHTMLElement,
+                                   NS_NewSVGUnknownElement,
+                                   nsHtml5TreeBuilder::AREA_OR_WBR | SPECIAL);
+  ELT_XMP = new nsHtml5ElementName(nsGkAtoms::xmp,
+                                   nsGkAtoms::xmp,
+                                   NS_NewHTMLPreElement,
+                                   NS_NewSVGUnknownElement,
+                                   nsHtml5TreeBuilder::XMP | SPECIAL);
   ELT_I = new nsHtml5ElementName(
     nsGkAtoms::i,
     nsGkAtoms::i,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
       B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_P =
     new nsHtml5ElementName(nsGkAtoms::p,
                            nsGkAtoms::p,
+                           NS_NewHTMLParagraphElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::P | SPECIAL | OPTIONAL_END_TAG);
-  ELT_Q = new nsHtml5ElementName(
-    nsGkAtoms::q, nsGkAtoms::q, nsHtml5TreeBuilder::OTHER);
+  ELT_Q = new nsHtml5ElementName(nsGkAtoms::q,
+                                 nsGkAtoms::q,
+                                 NS_NewHTMLSharedElement,
+                                 NS_NewSVGUnknownElement,
+                                 nsHtml5TreeBuilder::OTHER);
   ELT_S = new nsHtml5ElementName(
     nsGkAtoms::s,
     nsGkAtoms::s,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
       B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_U = new nsHtml5ElementName(
     nsGkAtoms::u,
     nsGkAtoms::u,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
       B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_H1 = new nsHtml5ElementName(
     nsGkAtoms::h1,
     nsGkAtoms::h1,
+    NS_NewHTMLHeadingElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
   ELT_H2 = new nsHtml5ElementName(
     nsGkAtoms::h2,
     nsGkAtoms::h2,
+    NS_NewHTMLHeadingElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
   ELT_H3 = new nsHtml5ElementName(
     nsGkAtoms::h3,
     nsGkAtoms::h3,
+    NS_NewHTMLHeadingElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
   ELT_H4 = new nsHtml5ElementName(
     nsGkAtoms::h4,
     nsGkAtoms::h4,
+    NS_NewHTMLHeadingElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
   ELT_H5 = new nsHtml5ElementName(
     nsGkAtoms::h5,
     nsGkAtoms::h5,
+    NS_NewHTMLHeadingElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
   ELT_H6 = new nsHtml5ElementName(
     nsGkAtoms::h6,
     nsGkAtoms::h6,
+    NS_NewHTMLHeadingElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
   ELT_AREA = new nsHtml5ElementName(nsGkAtoms::area,
                                     nsGkAtoms::area,
+                                    NS_NewHTMLAreaElement,
+                                    NS_NewSVGUnknownElement,
                                     nsHtml5TreeBuilder::AREA_OR_WBR | SPECIAL);
-  ELT_FEFUNCA = new nsHtml5ElementName(
-    nsGkAtoms::fefunca, nsGkAtoms::feFuncA, nsHtml5TreeBuilder::OTHER);
-  ELT_METADATA = new nsHtml5ElementName(
-    nsGkAtoms::metadata, nsGkAtoms::metadata, nsHtml5TreeBuilder::OTHER);
-  ELT_META = new nsHtml5ElementName(
-    nsGkAtoms::meta, nsGkAtoms::meta, nsHtml5TreeBuilder::META | SPECIAL);
+  ELT_DATA = new nsHtml5ElementName(nsGkAtoms::data,
+                                    nsGkAtoms::data,
+                                    NS_NewHTMLDataElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::OTHER);
+  ELT_FEFUNCA = new nsHtml5ElementName(nsGkAtoms::fefunca,
+                                       nsGkAtoms::feFuncA,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGFEFuncAElement,
+                                       nsHtml5TreeBuilder::OTHER);
+  ELT_METADATA = new nsHtml5ElementName(nsGkAtoms::metadata,
+                                        nsGkAtoms::metadata,
+                                        NS_NewHTMLUnknownElement,
+                                        NS_NewSVGMetadataElement,
+                                        nsHtml5TreeBuilder::OTHER);
+  ELT_META = new nsHtml5ElementName(nsGkAtoms::meta,
+                                    nsGkAtoms::meta,
+                                    NS_NewHTMLMetaElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::META | SPECIAL);
   ELT_TEXTAREA = new nsHtml5ElementName(nsGkAtoms::textarea,
                                         nsGkAtoms::textarea,
+                                        NS_NewHTMLTextAreaElement,
+                                        NS_NewSVGUnknownElement,
                                         nsHtml5TreeBuilder::TEXTAREA | SPECIAL);
-  ELT_FEFUNCB = new nsHtml5ElementName(
-    nsGkAtoms::fefuncb, nsGkAtoms::feFuncB, nsHtml5TreeBuilder::OTHER);
+  ELT_FEFUNCB = new nsHtml5ElementName(nsGkAtoms::fefuncb,
+                                       nsGkAtoms::feFuncB,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGFEFuncBElement,
+                                       nsHtml5TreeBuilder::OTHER);
   ELT_RB =
     new nsHtml5ElementName(nsGkAtoms::rb,
                            nsGkAtoms::rb,
+                           NS_NewHTMLElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::RB_OR_RTC | OPTIONAL_END_TAG);
   ELT_DESC = new nsHtml5ElementName(nsGkAtoms::desc,
                                     nsGkAtoms::desc,
+                                    NS_NewHTMLUnknownElement,
+                                    NS_NewSVGDescElement,
                                     nsHtml5TreeBuilder::FOREIGNOBJECT_OR_DESC |
                                       SCOPING_AS_SVG);
   ELT_DD = new nsHtml5ElementName(nsGkAtoms::dd,
                                   nsGkAtoms::dd,
+                                  NS_NewHTMLElement,
+                                  NS_NewSVGUnknownElement,
                                   nsHtml5TreeBuilder::DD_OR_DT | SPECIAL |
                                     OPTIONAL_END_TAG);
   ELT_BGSOUND = new nsHtml5ElementName(
     nsGkAtoms::bgsound,
     nsGkAtoms::bgsound,
+    NS_NewHTMLUnknownElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
-  ELT_EMBED = new nsHtml5ElementName(
-    nsGkAtoms::embed, nsGkAtoms::embed, nsHtml5TreeBuilder::EMBED | SPECIAL);
-  ELT_FEBLEND = new nsHtml5ElementName(
-    nsGkAtoms::feblend, nsGkAtoms::feBlend, nsHtml5TreeBuilder::OTHER);
-  ELT_FEFLOOD = new nsHtml5ElementName(
-    nsGkAtoms::feflood, nsGkAtoms::feFlood, nsHtml5TreeBuilder::OTHER);
+  ELT_EMBED = new nsHtml5ElementName(nsGkAtoms::embed,
+                                     nsGkAtoms::embed,
+                                     NS_NewHTMLEmbedElement,
+                                     NS_NewSVGUnknownElement,
+                                     nsHtml5TreeBuilder::EMBED | SPECIAL);
+  ELT_FEBLEND = new nsHtml5ElementName(nsGkAtoms::feblend,
+                                       nsGkAtoms::feBlend,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGFEBlendElement,
+                                       nsHtml5TreeBuilder::OTHER);
+  ELT_FEFLOOD = new nsHtml5ElementName(nsGkAtoms::feflood,
+                                       nsGkAtoms::feFlood,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGFEFloodElement,
+                                       nsHtml5TreeBuilder::OTHER);
   ELT_HEAD = new nsHtml5ElementName(nsGkAtoms::head,
                                     nsGkAtoms::head,
+                                    NS_NewHTMLSharedElement,
+                                    NS_NewSVGUnknownElement,
                                     nsHtml5TreeBuilder::HEAD | SPECIAL |
                                       OPTIONAL_END_TAG);
-  ELT_LEGEND = new nsHtml5ElementName(
-    nsGkAtoms::legend, nsGkAtoms::legend, nsHtml5TreeBuilder::OTHER);
+  ELT_LEGEND = new nsHtml5ElementName(nsGkAtoms::legend,
+                                      nsGkAtoms::legend,
+                                      NS_NewHTMLLegendElement,
+                                      NS_NewSVGUnknownElement,
+                                      nsHtml5TreeBuilder::OTHER);
   ELT_NOEMBED = new nsHtml5ElementName(nsGkAtoms::noembed,
                                        nsGkAtoms::noembed,
+                                       NS_NewHTMLElement,
+                                       NS_NewSVGUnknownElement,
                                        nsHtml5TreeBuilder::NOEMBED | SPECIAL);
   ELT_TD = new nsHtml5ElementName(nsGkAtoms::td,
                                   nsGkAtoms::td,
+                                  NS_NewHTMLTableCellElement,
+                                  NS_NewSVGUnknownElement,
                                   nsHtml5TreeBuilder::TD_OR_TH | SPECIAL |
                                     SCOPING | OPTIONAL_END_TAG);
   ELT_THEAD =
     new nsHtml5ElementName(nsGkAtoms::thead,
                            nsGkAtoms::thead,
+                           NS_NewHTMLTableSectionElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::TBODY_OR_THEAD_OR_TFOOT |
                              SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
   ELT_ASIDE = new nsHtml5ElementName(
     nsGkAtoms::aside,
     nsGkAtoms::aside,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
   ELT_ARTICLE = new nsHtml5ElementName(
     nsGkAtoms::article,
     nsGkAtoms::article,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
-  ELT_ANIMATE = new nsHtml5ElementName(
-    nsGkAtoms::animate, nsGkAtoms::animate, nsHtml5TreeBuilder::OTHER);
-  ELT_BASE = new nsHtml5ElementName(
-    nsGkAtoms::base, nsGkAtoms::base, nsHtml5TreeBuilder::BASE | SPECIAL);
+  ELT_ANIMATE = new nsHtml5ElementName(nsGkAtoms::animate,
+                                       nsGkAtoms::animate,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGAnimateElement,
+                                       nsHtml5TreeBuilder::OTHER);
+  ELT_BASE = new nsHtml5ElementName(nsGkAtoms::base,
+                                    nsGkAtoms::base,
+                                    NS_NewHTMLSharedElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::BASE | SPECIAL);
   ELT_BLOCKQUOTE = new nsHtml5ElementName(
     nsGkAtoms::blockquote,
     nsGkAtoms::blockquote,
+    NS_NewHTMLSharedElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
   ELT_CODE = new nsHtml5ElementName(
     nsGkAtoms::code,
     nsGkAtoms::code,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
       B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-  ELT_CIRCLE = new nsHtml5ElementName(
-    nsGkAtoms::circle, nsGkAtoms::circle, nsHtml5TreeBuilder::OTHER);
-  ELT_CITE = new nsHtml5ElementName(
-    nsGkAtoms::cite, nsGkAtoms::cite, nsHtml5TreeBuilder::OTHER);
-  ELT_ELLIPSE = new nsHtml5ElementName(
-    nsGkAtoms::ellipse, nsGkAtoms::ellipse, nsHtml5TreeBuilder::OTHER);
+  ELT_CIRCLE = new nsHtml5ElementName(nsGkAtoms::circle,
+                                      nsGkAtoms::circle,
+                                      NS_NewHTMLUnknownElement,
+                                      NS_NewSVGCircleElement,
+                                      nsHtml5TreeBuilder::OTHER);
+  ELT_CITE = new nsHtml5ElementName(nsGkAtoms::cite,
+                                    nsGkAtoms::cite,
+                                    NS_NewHTMLElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::OTHER);
+  ELT_ELLIPSE = new nsHtml5ElementName(nsGkAtoms::ellipse,
+                                       nsGkAtoms::ellipse,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGEllipseElement,
+                                       nsHtml5TreeBuilder::OTHER);
   ELT_FETURBULENCE = new nsHtml5ElementName(nsGkAtoms::feturbulence,
                                             nsGkAtoms::feTurbulence,
+                                            NS_NewHTMLUnknownElement,
+                                            NS_NewSVGFETurbulenceElement,
                                             nsHtml5TreeBuilder::OTHER);
-  ELT_FEMERGENODE = new nsHtml5ElementName(
-    nsGkAtoms::femergenode, nsGkAtoms::feMergeNode, nsHtml5TreeBuilder::OTHER);
-  ELT_FEIMAGE = new nsHtml5ElementName(
-    nsGkAtoms::feimage, nsGkAtoms::feImage, nsHtml5TreeBuilder::OTHER);
-  ELT_FEMERGE = new nsHtml5ElementName(
-    nsGkAtoms::femerge, nsGkAtoms::feMerge, nsHtml5TreeBuilder::OTHER);
-  ELT_FETILE = new nsHtml5ElementName(
-    nsGkAtoms::fetile, nsGkAtoms::feTile, nsHtml5TreeBuilder::OTHER);
-  ELT_FRAME = new nsHtml5ElementName(
-    nsGkAtoms::frame, nsGkAtoms::frame, nsHtml5TreeBuilder::FRAME | SPECIAL);
+  ELT_FEMERGENODE = new nsHtml5ElementName(nsGkAtoms::femergenode,
+                                           nsGkAtoms::feMergeNode,
+                                           NS_NewHTMLUnknownElement,
+                                           NS_NewSVGFEMergeNodeElement,
+                                           nsHtml5TreeBuilder::OTHER);
+  ELT_FEIMAGE = new nsHtml5ElementName(nsGkAtoms::feimage,
+                                       nsGkAtoms::feImage,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGFEImageElement,
+                                       nsHtml5TreeBuilder::OTHER);
+  ELT_FEMERGE = new nsHtml5ElementName(nsGkAtoms::femerge,
+                                       nsGkAtoms::feMerge,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGFEMergeElement,
+                                       nsHtml5TreeBuilder::OTHER);
+  ELT_FETILE = new nsHtml5ElementName(nsGkAtoms::fetile,
+                                      nsGkAtoms::feTile,
+                                      NS_NewHTMLUnknownElement,
+                                      NS_NewSVGFETileElement,
+                                      nsHtml5TreeBuilder::OTHER);
+  ELT_FRAME = new nsHtml5ElementName(nsGkAtoms::frame,
+                                     nsGkAtoms::frame,
+                                     NS_NewHTMLFrameElement,
+                                     NS_NewSVGUnknownElement,
+                                     nsHtml5TreeBuilder::FRAME | SPECIAL);
   ELT_FIGURE = new nsHtml5ElementName(
     nsGkAtoms::figure,
     nsGkAtoms::figure,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
-  ELT_FECOMPOSITE = new nsHtml5ElementName(
-    nsGkAtoms::fecomposite, nsGkAtoms::feComposite, nsHtml5TreeBuilder::OTHER);
-  ELT_IMAGE = new nsHtml5ElementName(
-    nsGkAtoms::image, nsGkAtoms::image, nsHtml5TreeBuilder::IMAGE);
-  ELT_IFRAME = new nsHtml5ElementName(
-    nsGkAtoms::iframe, nsGkAtoms::iframe, nsHtml5TreeBuilder::IFRAME | SPECIAL);
-  ELT_LINE = new nsHtml5ElementName(
-    nsGkAtoms::line, nsGkAtoms::line, nsHtml5TreeBuilder::OTHER);
+  ELT_FECOMPOSITE = new nsHtml5ElementName(nsGkAtoms::fecomposite,
+                                           nsGkAtoms::feComposite,
+                                           NS_NewHTMLUnknownElement,
+                                           NS_NewSVGFECompositeElement,
+                                           nsHtml5TreeBuilder::OTHER);
+  ELT_IMAGE = new nsHtml5ElementName(nsGkAtoms::image,
+                                     nsGkAtoms::image,
+                                     NS_NewHTMLElement,
+                                     NS_NewSVGImageElement,
+                                     nsHtml5TreeBuilder::IMAGE);
+  ELT_IFRAME = new nsHtml5ElementName(nsGkAtoms::iframe,
+                                      nsGkAtoms::iframe,
+                                      NS_NewHTMLIFrameElement,
+                                      NS_NewSVGUnknownElement,
+                                      nsHtml5TreeBuilder::IFRAME | SPECIAL);
+  ELT_LINE = new nsHtml5ElementName(nsGkAtoms::line,
+                                    nsGkAtoms::line,
+                                    NS_NewHTMLUnknownElement,
+                                    NS_NewSVGLineElement,
+                                    nsHtml5TreeBuilder::OTHER);
   ELT_MARQUEE = new nsHtml5ElementName(nsGkAtoms::marquee,
                                        nsGkAtoms::marquee,
+                                       NS_NewHTMLDivElement,
+                                       NS_NewSVGUnknownElement,
                                        nsHtml5TreeBuilder::MARQUEE_OR_APPLET |
                                          SPECIAL | SCOPING);
-  ELT_POLYLINE = new nsHtml5ElementName(
-    nsGkAtoms::polyline, nsGkAtoms::polyline, nsHtml5TreeBuilder::OTHER);
-  ELT_PICTURE = new nsHtml5ElementName(
-    nsGkAtoms::picture, nsGkAtoms::picture, nsHtml5TreeBuilder::OTHER);
+  ELT_POLYLINE = new nsHtml5ElementName(nsGkAtoms::polyline,
+                                        nsGkAtoms::polyline,
+                                        NS_NewHTMLUnknownElement,
+                                        NS_NewSVGPolylineElement,
+                                        nsHtml5TreeBuilder::OTHER);
+  ELT_PICTURE = new nsHtml5ElementName(nsGkAtoms::picture,
+                                       nsGkAtoms::picture,
+                                       NS_NewHTMLPictureElement,
+                                       NS_NewSVGUnknownElement,
+                                       nsHtml5TreeBuilder::OTHER);
   ELT_SOURCE =
     new nsHtml5ElementName(nsGkAtoms::source,
                            nsGkAtoms::source,
+                           NS_NewHTMLSourceElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::PARAM_OR_SOURCE_OR_TRACK);
   ELT_STRIKE = new nsHtml5ElementName(
     nsGkAtoms::strike,
     nsGkAtoms::strike,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
       B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-  ELT_STYLE = new nsHtml5ElementName(
-    nsGkAtoms::style, nsGkAtoms::style, nsHtml5TreeBuilder::STYLE | SPECIAL);
+  ELT_STYLE = new nsHtml5ElementName(nsGkAtoms::style,
+                                     nsGkAtoms::style,
+                                     NS_NewHTMLStyleElement,
+                                     NS_NewSVGStyleElement,
+                                     nsHtml5TreeBuilder::STYLE | SPECIAL);
   ELT_TABLE = new nsHtml5ElementName(nsGkAtoms::table,
                                      nsGkAtoms::table,
+                                     NS_NewHTMLTableElement,
+                                     NS_NewSVGUnknownElement,
                                      nsHtml5TreeBuilder::TABLE | SPECIAL |
                                        FOSTER_PARENTING | SCOPING);
   ELT_TITLE = new nsHtml5ElementName(nsGkAtoms::title,
                                      nsGkAtoms::title,
+                                     NS_NewHTMLTitleElement,
+                                     NS_NewSVGTitleElement,
                                      nsHtml5TreeBuilder::TITLE | SPECIAL |
                                        SCOPING_AS_SVG);
-  ELT_TIME = new nsHtml5ElementName(
-    nsGkAtoms::time, nsGkAtoms::time, nsHtml5TreeBuilder::OTHER);
+  ELT_TIME = new nsHtml5ElementName(nsGkAtoms::time,
+                                    nsGkAtoms::time,
+                                    NS_NewHTMLTimeElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::OTHER);
   ELT_TEMPLATE =
     new nsHtml5ElementName(nsGkAtoms::_template,
                            nsGkAtoms::_template,
+                           NS_NewHTMLTemplateElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::TEMPLATE | SPECIAL | SCOPING);
-  ELT_ALTGLYPHDEF = new nsHtml5ElementName(
-    nsGkAtoms::altglyphdef, nsGkAtoms::altGlyphDef, nsHtml5TreeBuilder::OTHER);
-  ELT_GLYPHREF = new nsHtml5ElementName(
-    nsGkAtoms::glyphref, nsGkAtoms::glyphRef, nsHtml5TreeBuilder::OTHER);
+  ELT_ALTGLYPHDEF = new nsHtml5ElementName(nsGkAtoms::altglyphdef,
+                                           nsGkAtoms::altGlyphDef,
+                                           NS_NewHTMLUnknownElement,
+                                           NS_NewSVGUnknownElement,
+                                           nsHtml5TreeBuilder::OTHER);
+  ELT_GLYPHREF = new nsHtml5ElementName(nsGkAtoms::glyphref,
+                                        nsGkAtoms::glyphRef,
+                                        NS_NewHTMLUnknownElement,
+                                        NS_NewSVGUnknownElement,
+                                        nsHtml5TreeBuilder::OTHER);
   ELT_DIALOG = new nsHtml5ElementName(
     nsGkAtoms::dialog,
     nsGkAtoms::dialog,
+    NS_NewHTMLDialogElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
-  ELT_FEFUNCG = new nsHtml5ElementName(
-    nsGkAtoms::fefuncg, nsGkAtoms::feFuncG, nsHtml5TreeBuilder::OTHER);
-  ELT_FEDIFFUSELIGHTING = new nsHtml5ElementName(nsGkAtoms::fediffuselighting,
-                                                 nsGkAtoms::feDiffuseLighting,
-                                                 nsHtml5TreeBuilder::OTHER);
-  ELT_FESPECULARLIGHTING = new nsHtml5ElementName(nsGkAtoms::fespecularlighting,
-                                                  nsGkAtoms::feSpecularLighting,
-                                                  nsHtml5TreeBuilder::OTHER);
+  ELT_FEFUNCG = new nsHtml5ElementName(nsGkAtoms::fefuncg,
+                                       nsGkAtoms::feFuncG,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGFEFuncGElement,
+                                       nsHtml5TreeBuilder::OTHER);
+  ELT_FEDIFFUSELIGHTING =
+    new nsHtml5ElementName(nsGkAtoms::fediffuselighting,
+                           nsGkAtoms::feDiffuseLighting,
+                           NS_NewHTMLUnknownElement,
+                           NS_NewSVGFEDiffuseLightingElement,
+                           nsHtml5TreeBuilder::OTHER);
+  ELT_FESPECULARLIGHTING =
+    new nsHtml5ElementName(nsGkAtoms::fespecularlighting,
+                           nsGkAtoms::feSpecularLighting,
+                           NS_NewHTMLUnknownElement,
+                           NS_NewSVGFESpecularLightingElement,
+                           nsHtml5TreeBuilder::OTHER);
   ELT_LISTING =
     new nsHtml5ElementName(nsGkAtoms::listing,
                            nsGkAtoms::listing,
+                           NS_NewHTMLPreElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::PRE_OR_LISTING | SPECIAL);
   ELT_STRONG = new nsHtml5ElementName(
     nsGkAtoms::strong,
     nsGkAtoms::strong,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
       B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-  ELT_ALTGLYPH = new nsHtml5ElementName(
-    nsGkAtoms::altglyph, nsGkAtoms::altGlyph, nsHtml5TreeBuilder::OTHER);
-  ELT_CLIPPATH = new nsHtml5ElementName(
-    nsGkAtoms::clippath, nsGkAtoms::clipPath, nsHtml5TreeBuilder::OTHER);
+  ELT_ALTGLYPH = new nsHtml5ElementName(nsGkAtoms::altglyph,
+                                        nsGkAtoms::altGlyph,
+                                        NS_NewHTMLUnknownElement,
+                                        NS_NewSVGUnknownElement,
+                                        nsHtml5TreeBuilder::OTHER);
+  ELT_CLIPPATH = new nsHtml5ElementName(nsGkAtoms::clippath,
+                                        nsGkAtoms::clipPath,
+                                        NS_NewHTMLUnknownElement,
+                                        NS_NewSVGClipPathElement,
+                                        nsHtml5TreeBuilder::OTHER);
   ELT_MGLYPH = new nsHtml5ElementName(nsGkAtoms::mglyph_,
                                       nsGkAtoms::mglyph_,
+                                      NS_NewHTMLUnknownElement,
+                                      NS_NewSVGUnknownElement,
                                       nsHtml5TreeBuilder::MGLYPH_OR_MALIGNMARK);
-  ELT_MATH = new nsHtml5ElementName(
-    nsGkAtoms::math, nsGkAtoms::math, nsHtml5TreeBuilder::MATH);
-  ELT_MPATH = new nsHtml5ElementName(
-    nsGkAtoms::mpath, nsGkAtoms::mpath, nsHtml5TreeBuilder::OTHER);
-  ELT_PATH = new nsHtml5ElementName(
-    nsGkAtoms::path, nsGkAtoms::path, nsHtml5TreeBuilder::OTHER);
+  ELT_MATH = new nsHtml5ElementName(nsGkAtoms::math,
+                                    nsGkAtoms::math,
+                                    NS_NewHTMLUnknownElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::MATH);
+  ELT_MPATH = new nsHtml5ElementName(nsGkAtoms::mpath,
+                                     nsGkAtoms::mpath,
+                                     NS_NewHTMLUnknownElement,
+                                     NS_NewSVGMPathElement,
+                                     nsHtml5TreeBuilder::OTHER);
+  ELT_PATH = new nsHtml5ElementName(nsGkAtoms::path,
+                                    nsGkAtoms::path,
+                                    NS_NewHTMLUnknownElement,
+                                    NS_NewSVGPathElement,
+                                    nsHtml5TreeBuilder::OTHER);
   ELT_TH = new nsHtml5ElementName(nsGkAtoms::th,
                                   nsGkAtoms::th,
+                                  NS_NewHTMLTableCellElement,
+                                  NS_NewSVGUnknownElement,
                                   nsHtml5TreeBuilder::TD_OR_TH | SPECIAL |
                                     SCOPING | OPTIONAL_END_TAG);
-  ELT_SWITCH = new nsHtml5ElementName(
-    nsGkAtoms::svgSwitch, nsGkAtoms::svgSwitch, nsHtml5TreeBuilder::OTHER);
-  ELT_TEXTPATH = new nsHtml5ElementName(
-    nsGkAtoms::textpath, nsGkAtoms::textPath, nsHtml5TreeBuilder::OTHER);
+  ELT_SWITCH = new nsHtml5ElementName(nsGkAtoms::svgSwitch,
+                                      nsGkAtoms::svgSwitch,
+                                      NS_NewHTMLUnknownElement,
+                                      NS_NewSVGSwitchElement,
+                                      nsHtml5TreeBuilder::OTHER);
+  ELT_TEXTPATH = new nsHtml5ElementName(nsGkAtoms::textpath,
+                                        nsGkAtoms::textPath,
+                                        NS_NewHTMLUnknownElement,
+                                        NS_NewSVGTextPathElement,
+                                        nsHtml5TreeBuilder::OTHER);
   ELT_LI =
     new nsHtml5ElementName(nsGkAtoms::li,
                            nsGkAtoms::li,
+                           NS_NewHTMLLIElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::LI | SPECIAL | OPTIONAL_END_TAG);
   ELT_MI = new nsHtml5ElementName(nsGkAtoms::mi_,
                                   nsGkAtoms::mi_,
+                                  NS_NewHTMLUnknownElement,
+                                  NS_NewSVGUnknownElement,
                                   nsHtml5TreeBuilder::MI_MO_MN_MS_MTEXT |
                                     SCOPING_AS_MATHML);
   ELT_LINK = new nsHtml5ElementName(
     nsGkAtoms::link,
     nsGkAtoms::link,
+    NS_NewHTMLLinkElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
-  ELT_MARK = new nsHtml5ElementName(
-    nsGkAtoms::mark, nsGkAtoms::mark, nsHtml5TreeBuilder::OTHER);
+  ELT_MARK = new nsHtml5ElementName(nsGkAtoms::mark,
+                                    nsGkAtoms::mark,
+                                    NS_NewHTMLElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::OTHER);
   ELT_MALIGNMARK =
     new nsHtml5ElementName(nsGkAtoms::malignmark_,
                            nsGkAtoms::malignmark_,
+                           NS_NewHTMLUnknownElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::MGLYPH_OR_MALIGNMARK);
-  ELT_MASK = new nsHtml5ElementName(
-    nsGkAtoms::mask, nsGkAtoms::mask, nsHtml5TreeBuilder::OTHER);
+  ELT_MASK = new nsHtml5ElementName(nsGkAtoms::mask,
+                                    nsGkAtoms::mask,
+                                    NS_NewHTMLUnknownElement,
+                                    NS_NewSVGMaskElement,
+                                    nsHtml5TreeBuilder::OTHER);
   ELT_TRACK = new nsHtml5ElementName(
     nsGkAtoms::track,
     nsGkAtoms::track,
+    NS_NewHTMLTrackElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::PARAM_OR_SOURCE_OR_TRACK | SPECIAL);
-  ELT_DL = new nsHtml5ElementName(
-    nsGkAtoms::dl, nsGkAtoms::dl, nsHtml5TreeBuilder::UL_OR_OL_OR_DL | SPECIAL);
+  ELT_DL = new nsHtml5ElementName(nsGkAtoms::dl,
+                                  nsGkAtoms::dl,
+                                  NS_NewHTMLSharedListElement,
+                                  NS_NewSVGUnknownElement,
+                                  nsHtml5TreeBuilder::UL_OR_OL_OR_DL | SPECIAL);
   ELT_HTML = new nsHtml5ElementName(nsGkAtoms::html,
                                     nsGkAtoms::html,
+                                    NS_NewHTMLSharedElement,
+                                    NS_NewSVGUnknownElement,
                                     nsHtml5TreeBuilder::HTML | SPECIAL |
                                       SCOPING | OPTIONAL_END_TAG);
-  ELT_OL = new nsHtml5ElementName(
-    nsGkAtoms::ol, nsGkAtoms::ol, nsHtml5TreeBuilder::UL_OR_OL_OR_DL | SPECIAL);
-  ELT_LABEL = new nsHtml5ElementName(
-    nsGkAtoms::label, nsGkAtoms::label, nsHtml5TreeBuilder::OTHER);
-  ELT_UL = new nsHtml5ElementName(
-    nsGkAtoms::ul, nsGkAtoms::ul, nsHtml5TreeBuilder::UL_OR_OL_OR_DL | SPECIAL);
+  ELT_OL = new nsHtml5ElementName(nsGkAtoms::ol,
+                                  nsGkAtoms::ol,
+                                  NS_NewHTMLSharedListElement,
+                                  NS_NewSVGUnknownElement,
+                                  nsHtml5TreeBuilder::UL_OR_OL_OR_DL | SPECIAL);
+  ELT_LABEL = new nsHtml5ElementName(nsGkAtoms::label,
+                                     nsGkAtoms::label,
+                                     NS_NewHTMLLabelElement,
+                                     NS_NewSVGUnknownElement,
+                                     nsHtml5TreeBuilder::OTHER);
+  ELT_UL = new nsHtml5ElementName(nsGkAtoms::ul,
+                                  nsGkAtoms::ul,
+                                  NS_NewHTMLSharedListElement,
+                                  NS_NewSVGUnknownElement,
+                                  nsHtml5TreeBuilder::UL_OR_OL_OR_DL | SPECIAL);
   ELT_SMALL = new nsHtml5ElementName(
     nsGkAtoms::small,
     nsGkAtoms::small,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
       B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-  ELT_SYMBOL = new nsHtml5ElementName(
-    nsGkAtoms::symbol, nsGkAtoms::symbol, nsHtml5TreeBuilder::OTHER);
+  ELT_SYMBOL = new nsHtml5ElementName(nsGkAtoms::symbol,
+                                      nsGkAtoms::symbol,
+                                      NS_NewHTMLUnknownElement,
+                                      NS_NewSVGSymbolElement,
+                                      nsHtml5TreeBuilder::OTHER);
   ELT_ALTGLYPHITEM = new nsHtml5ElementName(nsGkAtoms::altglyphitem,
                                             nsGkAtoms::altGlyphItem,
+                                            NS_NewHTMLUnknownElement,
+                                            NS_NewSVGUnknownElement,
                                             nsHtml5TreeBuilder::OTHER);
-  ELT_ANIMATETRANSFORM = new nsHtml5ElementName(nsGkAtoms::animatetransform,
-                                                nsGkAtoms::animateTransform,
-                                                nsHtml5TreeBuilder::OTHER);
-  ELT_ACRONYM = new nsHtml5ElementName(
-    nsGkAtoms::acronym, nsGkAtoms::acronym, nsHtml5TreeBuilder::OTHER);
+  ELT_ANIMATETRANSFORM =
+    new nsHtml5ElementName(nsGkAtoms::animatetransform,
+                           nsGkAtoms::animateTransform,
+                           NS_NewHTMLUnknownElement,
+                           NS_NewSVGAnimateTransformElement,
+                           nsHtml5TreeBuilder::OTHER);
+  ELT_ACRONYM = new nsHtml5ElementName(nsGkAtoms::acronym,
+                                       nsGkAtoms::acronym,
+                                       NS_NewHTMLElement,
+                                       NS_NewSVGUnknownElement,
+                                       nsHtml5TreeBuilder::OTHER);
   ELT_EM = new nsHtml5ElementName(
     nsGkAtoms::em,
     nsGkAtoms::em,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
       B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-  ELT_FORM = new nsHtml5ElementName(
-    nsGkAtoms::form, nsGkAtoms::form, nsHtml5TreeBuilder::FORM | SPECIAL);
-  ELT_MENUITEM = new nsHtml5ElementName(
-    nsGkAtoms::menuitem, nsGkAtoms::menuitem, nsHtml5TreeBuilder::MENUITEM);
+  ELT_FORM = new nsHtml5ElementName(nsGkAtoms::form,
+                                    nsGkAtoms::form,
+                                    NS_NewHTMLFormElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::FORM | SPECIAL);
+  ELT_MENUITEM = new nsHtml5ElementName(nsGkAtoms::menuitem,
+                                        nsGkAtoms::menuitem,
+                                        NS_NewHTMLMenuItemElement,
+                                        NS_NewSVGUnknownElement,
+                                        nsHtml5TreeBuilder::MENUITEM);
   ELT_PARAM = new nsHtml5ElementName(
     nsGkAtoms::param,
     nsGkAtoms::param,
+    NS_NewHTMLSharedElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::PARAM_OR_SOURCE_OR_TRACK | SPECIAL);
   ELT_ANIMATEMOTION = new nsHtml5ElementName(nsGkAtoms::animatemotion,
                                              nsGkAtoms::animateMotion,
+                                             NS_NewHTMLUnknownElement,
+                                             NS_NewSVGAnimateMotionElement,
                                              nsHtml5TreeBuilder::OTHER);
-  ELT_BUTTON = new nsHtml5ElementName(
-    nsGkAtoms::button, nsGkAtoms::button, nsHtml5TreeBuilder::BUTTON | SPECIAL);
+  ELT_BUTTON = new nsHtml5ElementName(nsGkAtoms::button,
+                                      nsGkAtoms::button,
+                                      NS_NewHTMLButtonElement,
+                                      NS_NewSVGUnknownElement,
+                                      nsHtml5TreeBuilder::BUTTON | SPECIAL);
   ELT_CAPTION =
     new nsHtml5ElementName(nsGkAtoms::caption,
                            nsGkAtoms::caption,
+                           NS_NewHTMLTableCaptionElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::CAPTION | SPECIAL | SCOPING);
   ELT_FIGCAPTION = new nsHtml5ElementName(
     nsGkAtoms::figcaption,
     nsGkAtoms::figcaption,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
   ELT_MN = new nsHtml5ElementName(nsGkAtoms::mn_,
                                   nsGkAtoms::mn_,
+                                  NS_NewHTMLUnknownElement,
+                                  NS_NewSVGUnknownElement,
                                   nsHtml5TreeBuilder::MI_MO_MN_MS_MTEXT |
                                     SCOPING_AS_MATHML);
-  ELT_KEYGEN = new nsHtml5ElementName(
-    nsGkAtoms::keygen, nsGkAtoms::keygen, nsHtml5TreeBuilder::KEYGEN);
+  ELT_KEYGEN = new nsHtml5ElementName(nsGkAtoms::keygen,
+                                      nsGkAtoms::keygen,
+                                      NS_NewHTMLSpanElement,
+                                      NS_NewSVGUnknownElement,
+                                      nsHtml5TreeBuilder::KEYGEN);
   ELT_MAIN = new nsHtml5ElementName(
     nsGkAtoms::main,
     nsGkAtoms::main,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
   ELT_OPTION =
     new nsHtml5ElementName(nsGkAtoms::option,
                            nsGkAtoms::option,
+                           NS_NewHTMLOptionElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::OPTION | OPTIONAL_END_TAG);
-  ELT_POLYGON = new nsHtml5ElementName(
-    nsGkAtoms::polygon, nsGkAtoms::polygon, nsHtml5TreeBuilder::OTHER);
-  ELT_PATTERN = new nsHtml5ElementName(
-    nsGkAtoms::pattern, nsGkAtoms::pattern, nsHtml5TreeBuilder::OTHER);
+  ELT_POLYGON = new nsHtml5ElementName(nsGkAtoms::polygon,
+                                       nsGkAtoms::polygon,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGPolygonElement,
+                                       nsHtml5TreeBuilder::OTHER);
+  ELT_PATTERN = new nsHtml5ElementName(nsGkAtoms::pattern,
+                                       nsGkAtoms::pattern,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGPatternElement,
+                                       nsHtml5TreeBuilder::OTHER);
   ELT_SPAN = new nsHtml5ElementName(
     nsGkAtoms::span,
     nsGkAtoms::span,
+    NS_NewHTMLSpanElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
   ELT_SECTION = new nsHtml5ElementName(
     nsGkAtoms::section,
     nsGkAtoms::section,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
-  ELT_TSPAN = new nsHtml5ElementName(
-    nsGkAtoms::tspan, nsGkAtoms::tspan, nsHtml5TreeBuilder::OTHER);
-  ELT_AUDIO = new nsHtml5ElementName(
-    nsGkAtoms::audio, nsGkAtoms::audio, nsHtml5TreeBuilder::OTHER);
+  ELT_TSPAN = new nsHtml5ElementName(nsGkAtoms::tspan,
+                                     nsGkAtoms::tspan,
+                                     NS_NewHTMLUnknownElement,
+                                     NS_NewSVGTSpanElement,
+                                     nsHtml5TreeBuilder::OTHER);
+  ELT_AUDIO = new nsHtml5ElementName(nsGkAtoms::audio,
+                                     nsGkAtoms::audio,
+                                     NS_NewHTMLAudioElement,
+                                     NS_NewSVGUnknownElement,
+                                     nsHtml5TreeBuilder::OTHER);
   ELT_MO = new nsHtml5ElementName(nsGkAtoms::mo_,
                                   nsGkAtoms::mo_,
+                                  NS_NewHTMLUnknownElement,
+                                  NS_NewSVGUnknownElement,
                                   nsHtml5TreeBuilder::MI_MO_MN_MS_MTEXT |
                                     SCOPING_AS_MATHML);
-  ELT_VIDEO = new nsHtml5ElementName(
-    nsGkAtoms::video, nsGkAtoms::video, nsHtml5TreeBuilder::OTHER);
+  ELT_VIDEO = new nsHtml5ElementName(nsGkAtoms::video,
+                                     nsGkAtoms::video,
+                                     NS_NewHTMLVideoElement,
+                                     NS_NewSVGUnknownElement,
+                                     nsHtml5TreeBuilder::OTHER);
   ELT_COLGROUP = new nsHtml5ElementName(nsGkAtoms::colgroup,
                                         nsGkAtoms::colgroup,
+                                        NS_NewHTMLTableColElement,
+                                        NS_NewSVGUnknownElement,
                                         nsHtml5TreeBuilder::COLGROUP | SPECIAL |
                                           OPTIONAL_END_TAG);
-  ELT_FEDISPLACEMENTMAP = new nsHtml5ElementName(nsGkAtoms::fedisplacementmap,
-                                                 nsGkAtoms::feDisplacementMap,
-                                                 nsHtml5TreeBuilder::OTHER);
+  ELT_FEDISPLACEMENTMAP =
+    new nsHtml5ElementName(nsGkAtoms::fedisplacementmap,
+                           nsGkAtoms::feDisplacementMap,
+                           NS_NewHTMLUnknownElement,
+                           NS_NewSVGFEDisplacementMapElement,
+                           nsHtml5TreeBuilder::OTHER);
   ELT_HGROUP = new nsHtml5ElementName(
     nsGkAtoms::hgroup,
     nsGkAtoms::hgroup,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
   ELT_RP =
     new nsHtml5ElementName(nsGkAtoms::rp,
                            nsGkAtoms::rp,
+                           NS_NewHTMLElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::RT_OR_RP | OPTIONAL_END_TAG);
   ELT_OPTGROUP =
     new nsHtml5ElementName(nsGkAtoms::optgroup,
                            nsGkAtoms::optgroup,
+                           NS_NewHTMLOptGroupElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::OPTGROUP | OPTIONAL_END_TAG);
-  ELT_SAMP = new nsHtml5ElementName(
-    nsGkAtoms::samp, nsGkAtoms::samp, nsHtml5TreeBuilder::OTHER);
-  ELT_STOP = new nsHtml5ElementName(
-    nsGkAtoms::stop, nsGkAtoms::stop, nsHtml5TreeBuilder::OTHER);
-  ELT_BR = new nsHtml5ElementName(
-    nsGkAtoms::br, nsGkAtoms::br, nsHtml5TreeBuilder::BR | SPECIAL);
-  ELT_ABBR = new nsHtml5ElementName(
-    nsGkAtoms::abbr, nsGkAtoms::abbr, nsHtml5TreeBuilder::OTHER);
+  ELT_SAMP = new nsHtml5ElementName(nsGkAtoms::samp,
+                                    nsGkAtoms::samp,
+                                    NS_NewHTMLElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::OTHER);
+  ELT_STOP = new nsHtml5ElementName(nsGkAtoms::stop,
+                                    nsGkAtoms::stop,
+                                    NS_NewHTMLUnknownElement,
+                                    NS_NewSVGStopElement,
+                                    nsHtml5TreeBuilder::OTHER);
+  ELT_BR = new nsHtml5ElementName(nsGkAtoms::br,
+                                  nsGkAtoms::br,
+                                  NS_NewHTMLBRElement,
+                                  NS_NewSVGUnknownElement,
+                                  nsHtml5TreeBuilder::BR | SPECIAL);
+  ELT_ABBR = new nsHtml5ElementName(nsGkAtoms::abbr,
+                                    nsGkAtoms::abbr,
+                                    NS_NewHTMLElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::OTHER);
   ELT_ANIMATECOLOR = new nsHtml5ElementName(nsGkAtoms::animatecolor,
                                             nsGkAtoms::animateColor,
+                                            NS_NewHTMLUnknownElement,
+                                            NS_NewSVGUnknownElement,
                                             nsHtml5TreeBuilder::OTHER);
   ELT_CENTER = new nsHtml5ElementName(
     nsGkAtoms::center,
     nsGkAtoms::center,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
-  ELT_HR = new nsHtml5ElementName(
-    nsGkAtoms::hr, nsGkAtoms::hr, nsHtml5TreeBuilder::HR | SPECIAL);
-  ELT_FEFUNCR = new nsHtml5ElementName(
-    nsGkAtoms::fefuncr, nsGkAtoms::feFuncR, nsHtml5TreeBuilder::OTHER);
+  ELT_HR = new nsHtml5ElementName(nsGkAtoms::hr,
+                                  nsGkAtoms::hr,
+                                  NS_NewHTMLHRElement,
+                                  NS_NewSVGUnknownElement,
+                                  nsHtml5TreeBuilder::HR | SPECIAL);
+  ELT_FEFUNCR = new nsHtml5ElementName(nsGkAtoms::fefuncr,
+                                       nsGkAtoms::feFuncR,
+                                       NS_NewHTMLUnknownElement,
+                                       NS_NewSVGFEFuncRElement,
+                                       nsHtml5TreeBuilder::OTHER);
   ELT_FECOMPONENTTRANSFER =
     new nsHtml5ElementName(nsGkAtoms::fecomponenttransfer,
                            nsGkAtoms::feComponentTransfer,
+                           NS_NewHTMLUnknownElement,
+                           NS_NewSVGFEComponentTransferElement,
                            nsHtml5TreeBuilder::OTHER);
-  ELT_FILTER = new nsHtml5ElementName(
-    nsGkAtoms::filter, nsGkAtoms::filter, nsHtml5TreeBuilder::OTHER);
+  ELT_FILTER = new nsHtml5ElementName(nsGkAtoms::filter,
+                                      nsGkAtoms::filter,
+                                      NS_NewHTMLUnknownElement,
+                                      NS_NewSVGFilterElement,
+                                      nsHtml5TreeBuilder::OTHER);
   ELT_FOOTER = new nsHtml5ElementName(
     nsGkAtoms::footer,
     nsGkAtoms::footer,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
   ELT_FEGAUSSIANBLUR = new nsHtml5ElementName(nsGkAtoms::fegaussianblur,
                                               nsGkAtoms::feGaussianBlur,
+                                              NS_NewHTMLUnknownElement,
+                                              NS_NewSVGFEGaussianBlurElement,
                                               nsHtml5TreeBuilder::OTHER);
   ELT_HEADER = new nsHtml5ElementName(
     nsGkAtoms::header,
     nsGkAtoms::header,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
-  ELT_MARKER = new nsHtml5ElementName(
-    nsGkAtoms::marker, nsGkAtoms::marker, nsHtml5TreeBuilder::OTHER);
-  ELT_METER = new nsHtml5ElementName(
-    nsGkAtoms::meter, nsGkAtoms::meter, nsHtml5TreeBuilder::OTHER);
-  ELT_NOBR = new nsHtml5ElementName(
-    nsGkAtoms::nobr, nsGkAtoms::nobr, nsHtml5TreeBuilder::NOBR);
+  ELT_MARKER = new nsHtml5ElementName(nsGkAtoms::marker,
+                                      nsGkAtoms::marker,
+                                      NS_NewHTMLUnknownElement,
+                                      NS_NewSVGMarkerElement,
+                                      nsHtml5TreeBuilder::OTHER);
+  ELT_METER = new nsHtml5ElementName(nsGkAtoms::meter,
+                                     nsGkAtoms::meter,
+                                     NS_NewHTMLMeterElement,
+                                     NS_NewSVGUnknownElement,
+                                     nsHtml5TreeBuilder::OTHER);
+  ELT_NOBR = new nsHtml5ElementName(nsGkAtoms::nobr,
+                                    nsGkAtoms::nobr,
+                                    NS_NewHTMLElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::NOBR);
   ELT_TR = new nsHtml5ElementName(nsGkAtoms::tr,
                                   nsGkAtoms::tr,
+                                  NS_NewHTMLTableRowElement,
+                                  NS_NewSVGUnknownElement,
                                   nsHtml5TreeBuilder::TR | SPECIAL |
                                     FOSTER_PARENTING | OPTIONAL_END_TAG);
   ELT_ADDRESS = new nsHtml5ElementName(
     nsGkAtoms::address,
     nsGkAtoms::address,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
-  ELT_CANVAS = new nsHtml5ElementName(
-    nsGkAtoms::canvas, nsGkAtoms::canvas, nsHtml5TreeBuilder::OTHER);
-  ELT_DEFS = new nsHtml5ElementName(
-    nsGkAtoms::defs, nsGkAtoms::defs, nsHtml5TreeBuilder::OTHER);
+  ELT_CANVAS = new nsHtml5ElementName(nsGkAtoms::canvas,
+                                      nsGkAtoms::canvas,
+                                      NS_NewHTMLCanvasElement,
+                                      NS_NewSVGUnknownElement,
+                                      nsHtml5TreeBuilder::OTHER);
+  ELT_DEFS = new nsHtml5ElementName(nsGkAtoms::defs,
+                                    nsGkAtoms::defs,
+                                    NS_NewHTMLUnknownElement,
+                                    NS_NewSVGDefsElement,
+                                    nsHtml5TreeBuilder::OTHER);
   ELT_DETAILS = new nsHtml5ElementName(
     nsGkAtoms::details,
     nsGkAtoms::details,
+    NS_NewHTMLDetailsElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
   ELT_MS = new nsHtml5ElementName(nsGkAtoms::ms_,
                                   nsGkAtoms::ms_,
+                                  NS_NewHTMLUnknownElement,
+                                  NS_NewSVGUnknownElement,
                                   nsHtml5TreeBuilder::MI_MO_MN_MS_MTEXT |
                                     SCOPING_AS_MATHML);
   ELT_NOFRAMES = new nsHtml5ElementName(nsGkAtoms::noframes,
                                         nsGkAtoms::noframes,
+                                        NS_NewHTMLElement,
+                                        NS_NewSVGUnknownElement,
                                         nsHtml5TreeBuilder::NOFRAMES | SPECIAL);
-  ELT_PROGRESS = new nsHtml5ElementName(
-    nsGkAtoms::progress, nsGkAtoms::progress, nsHtml5TreeBuilder::OTHER);
+  ELT_PROGRESS = new nsHtml5ElementName(nsGkAtoms::progress,
+                                        nsGkAtoms::progress,
+                                        NS_NewHTMLProgressElement,
+                                        NS_NewSVGUnknownElement,
+                                        nsHtml5TreeBuilder::OTHER);
   ELT_DT = new nsHtml5ElementName(nsGkAtoms::dt,
                                   nsGkAtoms::dt,
+                                  NS_NewHTMLElement,
+                                  NS_NewSVGUnknownElement,
                                   nsHtml5TreeBuilder::DD_OR_DT | SPECIAL |
                                     OPTIONAL_END_TAG);
   ELT_APPLET = new nsHtml5ElementName(nsGkAtoms::applet,
                                       nsGkAtoms::applet,
+                                      NS_NewHTMLUnknownElement,
+                                      NS_NewSVGUnknownElement,
                                       nsHtml5TreeBuilder::MARQUEE_OR_APPLET |
                                         SPECIAL | SCOPING);
   ELT_BASEFONT = new nsHtml5ElementName(
     nsGkAtoms::basefont,
     nsGkAtoms::basefont,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
+  ELT_CONTENT = new nsHtml5ElementName(nsGkAtoms::content,
+                                       nsGkAtoms::content,
+                                       NS_NewHTMLContentElement,
+                                       NS_NewSVGUnknownElement,
+                                       nsHtml5TreeBuilder::OTHER);
+  ELT_DATALIST = new nsHtml5ElementName(nsGkAtoms::datalist,
+                                        nsGkAtoms::datalist,
+                                        NS_NewHTMLDataListElement,
+                                        NS_NewSVGUnknownElement,
+                                        nsHtml5TreeBuilder::OTHER);
   ELT_FOREIGNOBJECT = new nsHtml5ElementName(
     nsGkAtoms::foreignobject,
     nsGkAtoms::foreignObject,
+    NS_NewHTMLUnknownElement,
+    NS_NewSVGForeignObjectElement,
     nsHtml5TreeBuilder::FOREIGNOBJECT_OR_DESC | SCOPING_AS_SVG);
   ELT_FIELDSET = new nsHtml5ElementName(nsGkAtoms::fieldset,
                                         nsGkAtoms::fieldset,
+                                        NS_NewHTMLFieldSetElement,
+                                        NS_NewSVGUnknownElement,
                                         nsHtml5TreeBuilder::FIELDSET | SPECIAL);
   ELT_FRAMESET = new nsHtml5ElementName(nsGkAtoms::frameset,
                                         nsGkAtoms::frameset,
+                                        NS_NewHTMLFrameSetElement,
+                                        NS_NewSVGUnknownElement,
                                         nsHtml5TreeBuilder::FRAMESET | SPECIAL);
-  ELT_FEOFFSET = new nsHtml5ElementName(
-    nsGkAtoms::feoffset, nsGkAtoms::feOffset, nsHtml5TreeBuilder::OTHER);
-  ELT_FESPOTLIGHT = new nsHtml5ElementName(
-    nsGkAtoms::fespotlight, nsGkAtoms::feSpotLight, nsHtml5TreeBuilder::OTHER);
+  ELT_FEOFFSET = new nsHtml5ElementName(nsGkAtoms::feoffset,
+                                        nsGkAtoms::feOffset,
+                                        NS_NewHTMLUnknownElement,
+                                        NS_NewSVGFEOffsetElement,
+                                        nsHtml5TreeBuilder::OTHER);
+  ELT_FESPOTLIGHT = new nsHtml5ElementName(nsGkAtoms::fespotlight,
+                                           nsGkAtoms::feSpotLight,
+                                           NS_NewHTMLUnknownElement,
+                                           NS_NewSVGFESpotLightElement,
+                                           nsHtml5TreeBuilder::OTHER);
   ELT_FEPOINTLIGHT = new nsHtml5ElementName(nsGkAtoms::fepointlight,
                                             nsGkAtoms::fePointLight,
+                                            NS_NewHTMLUnknownElement,
+                                            NS_NewSVGFEPointLightElement,
                                             nsHtml5TreeBuilder::OTHER);
   ELT_FEDISTANTLIGHT = new nsHtml5ElementName(nsGkAtoms::fedistantlight,
                                               nsGkAtoms::feDistantLight,
+                                              NS_NewHTMLUnknownElement,
+                                              NS_NewSVGFEDistantLightElement,
                                               nsHtml5TreeBuilder::OTHER);
-  ELT_FONT = new nsHtml5ElementName(
-    nsGkAtoms::font, nsGkAtoms::font, nsHtml5TreeBuilder::FONT);
-  ELT_INPUT = new nsHtml5ElementName(
-    nsGkAtoms::input, nsGkAtoms::input, nsHtml5TreeBuilder::INPUT | SPECIAL);
+  ELT_FONT = new nsHtml5ElementName(nsGkAtoms::font,
+                                    nsGkAtoms::font,
+                                    NS_NewHTMLFontElement,
+                                    NS_NewSVGUnknownElement,
+                                    nsHtml5TreeBuilder::FONT);
+  ELT_INPUT = new nsHtml5ElementName(nsGkAtoms::input,
+                                     nsGkAtoms::input,
+                                     NS_NewHTMLInputElement,
+                                     NS_NewSVGUnknownElement,
+                                     nsHtml5TreeBuilder::INPUT | SPECIAL);
   ELT_LINEARGRADIENT = new nsHtml5ElementName(nsGkAtoms::lineargradient,
                                               nsGkAtoms::linearGradient,
+                                              NS_NewHTMLUnknownElement,
+                                              NS_NewSVGLinearGradientElement,
                                               nsHtml5TreeBuilder::OTHER);
   ELT_MTEXT = new nsHtml5ElementName(nsGkAtoms::mtext_,
                                      nsGkAtoms::mtext_,
+                                     NS_NewHTMLUnknownElement,
+                                     NS_NewSVGUnknownElement,
                                      nsHtml5TreeBuilder::MI_MO_MN_MS_MTEXT |
                                        SCOPING_AS_MATHML);
   ELT_NOSCRIPT = new nsHtml5ElementName(nsGkAtoms::noscript,
                                         nsGkAtoms::noscript,
+                                        NS_NewHTMLElement,
+                                        NS_NewSVGUnknownElement,
                                         nsHtml5TreeBuilder::NOSCRIPT | SPECIAL);
   ELT_RT =
     new nsHtml5ElementName(nsGkAtoms::rt,
                            nsGkAtoms::rt,
+                           NS_NewHTMLElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::RT_OR_RP | OPTIONAL_END_TAG);
   ELT_OBJECT =
     new nsHtml5ElementName(nsGkAtoms::object,
                            nsGkAtoms::object,
+                           NS_NewHTMLObjectElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::OBJECT | SPECIAL | SCOPING);
-  ELT_OUTPUT = new nsHtml5ElementName(
-    nsGkAtoms::output, nsGkAtoms::output, nsHtml5TreeBuilder::OUTPUT);
+  ELT_OUTPUT = new nsHtml5ElementName(nsGkAtoms::output,
+                                      nsGkAtoms::output,
+                                      NS_NewHTMLOutputElement,
+                                      NS_NewSVGUnknownElement,
+                                      nsHtml5TreeBuilder::OUTPUT);
   ELT_PLAINTEXT =
     new nsHtml5ElementName(nsGkAtoms::plaintext,
                            nsGkAtoms::plaintext,
+                           NS_NewHTMLElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::PLAINTEXT | SPECIAL);
   ELT_TT = new nsHtml5ElementName(
     nsGkAtoms::tt,
     nsGkAtoms::tt,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
       B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
-  ELT_RECT = new nsHtml5ElementName(
-    nsGkAtoms::rect, nsGkAtoms::rect, nsHtml5TreeBuilder::OTHER);
+  ELT_RECT = new nsHtml5ElementName(nsGkAtoms::rect,
+                                    nsGkAtoms::rect,
+                                    NS_NewHTMLUnknownElement,
+                                    NS_NewSVGRectElement,
+                                    nsHtml5TreeBuilder::OTHER);
   ELT_RADIALGRADIENT = new nsHtml5ElementName(nsGkAtoms::radialgradient,
                                               nsGkAtoms::radialGradient,
+                                              NS_NewHTMLUnknownElement,
+                                              NS_NewSVGRadialGradientElement,
                                               nsHtml5TreeBuilder::OTHER);
-  ELT_SELECT = new nsHtml5ElementName(
-    nsGkAtoms::select, nsGkAtoms::select, nsHtml5TreeBuilder::SELECT | SPECIAL);
-  ELT_SCRIPT = new nsHtml5ElementName(
-    nsGkAtoms::script, nsGkAtoms::script, nsHtml5TreeBuilder::SCRIPT | SPECIAL);
+  ELT_SELECT = new nsHtml5ElementName(nsGkAtoms::select,
+                                      nsGkAtoms::select,
+                                      NS_NewHTMLSelectElement,
+                                      NS_NewSVGUnknownElement,
+                                      nsHtml5TreeBuilder::SELECT | SPECIAL);
+  ELT_SCRIPT = new nsHtml5ElementName(nsGkAtoms::script,
+                                      nsGkAtoms::script,
+                                      NS_NewHTMLScriptElement,
+                                      NS_NewSVGScriptElement,
+                                      nsHtml5TreeBuilder::SCRIPT | SPECIAL);
   ELT_TFOOT =
     new nsHtml5ElementName(nsGkAtoms::tfoot,
                            nsGkAtoms::tfoot,
+                           NS_NewHTMLTableSectionElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::TBODY_OR_THEAD_OR_TFOOT |
                              SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
-  ELT_TEXT = new nsHtml5ElementName(
-    nsGkAtoms::text, nsGkAtoms::text, nsHtml5TreeBuilder::OTHER);
+  ELT_TEXT = new nsHtml5ElementName(nsGkAtoms::text,
+                                    nsGkAtoms::text,
+                                    NS_NewHTMLUnknownElement,
+                                    NS_NewSVGTextElement,
+                                    nsHtml5TreeBuilder::OTHER);
   ELT_MENU = new nsHtml5ElementName(
     nsGkAtoms::menu,
     nsGkAtoms::menu,
+    NS_NewHTMLMenuElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
   ELT_FEDROPSHADOW = new nsHtml5ElementName(nsGkAtoms::fedropshadow,
                                             nsGkAtoms::feDropShadow,
+                                            NS_NewHTMLUnknownElement,
+                                            NS_NewSVGFEDropShadowElement,
                                             nsHtml5TreeBuilder::OTHER);
-  ELT_VIEW = new nsHtml5ElementName(
-    nsGkAtoms::view, nsGkAtoms::view, nsHtml5TreeBuilder::OTHER);
+  ELT_SHADOW = new nsHtml5ElementName(nsGkAtoms::shadow,
+                                      nsGkAtoms::shadow,
+                                      NS_NewHTMLShadowElement,
+                                      NS_NewSVGUnknownElement,
+                                      nsHtml5TreeBuilder::OTHER);
+  ELT_VIEW = new nsHtml5ElementName(nsGkAtoms::view,
+                                    nsGkAtoms::view,
+                                    NS_NewHTMLUnknownElement,
+                                    NS_NewSVGViewElement,
+                                    nsHtml5TreeBuilder::OTHER);
   ELT_FECOLORMATRIX = new nsHtml5ElementName(nsGkAtoms::fecolormatrix,
                                              nsGkAtoms::feColorMatrix,
+                                             NS_NewHTMLUnknownElement,
+                                             NS_NewSVGFEColorMatrixElement,
                                              nsHtml5TreeBuilder::OTHER);
-  ELT_FECONVOLVEMATRIX = new nsHtml5ElementName(nsGkAtoms::feconvolvematrix,
-                                                nsGkAtoms::feConvolveMatrix,
-                                                nsHtml5TreeBuilder::OTHER);
+  ELT_FECONVOLVEMATRIX =
+    new nsHtml5ElementName(nsGkAtoms::feconvolvematrix,
+                           nsGkAtoms::feConvolveMatrix,
+                           NS_NewHTMLUnknownElement,
+                           NS_NewSVGFEConvolveMatrixElement,
+                           nsHtml5TreeBuilder::OTHER);
   ELT_BODY = new nsHtml5ElementName(nsGkAtoms::body,
                                     nsGkAtoms::body,
+                                    NS_NewHTMLBodyElement,
+                                    NS_NewSVGUnknownElement,
                                     nsHtml5TreeBuilder::BODY | SPECIAL |
                                       OPTIONAL_END_TAG);
   ELT_FEMORPHOLOGY = new nsHtml5ElementName(nsGkAtoms::femorphology,
                                             nsGkAtoms::feMorphology,
+                                            NS_NewHTMLUnknownElement,
+                                            NS_NewSVGFEMorphologyElement,
                                             nsHtml5TreeBuilder::OTHER);
   ELT_RUBY = new nsHtml5ElementName(
     nsGkAtoms::ruby,
     nsGkAtoms::ruby,
+    NS_NewHTMLElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
   ELT_SUMMARY = new nsHtml5ElementName(
     nsGkAtoms::summary,
     nsGkAtoms::summary,
+    NS_NewHTMLSummaryElement,
+    NS_NewSVGUnknownElement,
     nsHtml5TreeBuilder::
         ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
       SPECIAL);
   ELT_TBODY =
     new nsHtml5ElementName(nsGkAtoms::tbody,
                            nsGkAtoms::tbody,
+                           NS_NewHTMLTableSectionElement,
+                           NS_NewSVGUnknownElement,
                            nsHtml5TreeBuilder::TBODY_OR_THEAD_OR_TFOOT |
                              SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
-  ELEMENT_NAMES = new nsHtml5ElementName*[203];
-  ELEMENT_NAMES[0] = ELT_KEYGEN;
-  ELEMENT_NAMES[1] = ELT_FETURBULENCE;
-  ELEMENT_NAMES[2] = ELT_FIELDSET;
+  ELEMENT_NAMES = new nsHtml5ElementName*[207];
+  ELEMENT_NAMES[0] = ELT_MN;
+  ELEMENT_NAMES[1] = ELT_ELLIPSE;
+  ELEMENT_NAMES[2] = ELT_FRAMESET;
   ELEMENT_NAMES[3] = ELT_H2;
-  ELEMENT_NAMES[4] = ELT_MATH;
-  ELEMENT_NAMES[5] = ELT_HEADER;
-  ELEMENT_NAMES[6] = ELT_RECT;
+  ELEMENT_NAMES[4] = ELT_MGLYPH;
+  ELEMENT_NAMES[5] = ELT_NOBR;
+  ELEMENT_NAMES[6] = ELT_RADIALGRADIENT;
   ELEMENT_NAMES[7] = ELT_RTC;
-  ELEMENT_NAMES[8] = ELT_FEBLEND;
-  ELEMENT_NAMES[9] = ELT_STYLE;
-  ELEMENT_NAMES[10] = ELT_LABEL;
-  ELEMENT_NAMES[11] = ELT_SAMP;
-  ELEMENT_NAMES[12] = ELT_DETAILS;
-  ELEMENT_NAMES[13] = ELT_LINEARGRADIENT;
+  ELEMENT_NAMES[8] = ELT_EMBED;
+  ELEMENT_NAMES[9] = ELT_STRIKE;
+  ELEMENT_NAMES[10] = ELT_OL;
+  ELEMENT_NAMES[11] = ELT_OPTGROUP;
+  ELEMENT_NAMES[12] = ELT_PROGRESS;
+  ELEMENT_NAMES[13] = ELT_MTEXT;
   ELEMENT_NAMES[14] = ELT_VIEW;
   ELEMENT_NAMES[15] = ELT_IMG;
   ELEMENT_NAMES[16] = ELT_WBR;
-  ELEMENT_NAMES[17] = ELT_META;
-  ELEMENT_NAMES[18] = ELT_ARTICLE;
-  ELEMENT_NAMES[19] = ELT_IMAGE;
-  ELEMENT_NAMES[20] = ELT_FEFUNCG;
-  ELEMENT_NAMES[21] = ELT_LINK;
-  ELEMENT_NAMES[22] = ELT_FORM;
-  ELEMENT_NAMES[23] = ELT_AUDIO;
-  ELEMENT_NAMES[24] = ELT_FECOMPONENTTRANSFER;
-  ELEMENT_NAMES[25] = ELT_TR;
-  ELEMENT_NAMES[26] = ELT_DT;
-  ELEMENT_NAMES[27] = ELT_FEPOINTLIGHT;
-  ELEMENT_NAMES[28] = ELT_OBJECT;
-  ELEMENT_NAMES[29] = ELT_TFOOT;
+  ELEMENT_NAMES[17] = ELT_METADATA;
+  ELEMENT_NAMES[18] = ELT_ASIDE;
+  ELEMENT_NAMES[19] = ELT_FECOMPOSITE;
+  ELEMENT_NAMES[20] = ELT_DIALOG;
+  ELEMENT_NAMES[21] = ELT_MI;
+  ELEMENT_NAMES[22] = ELT_EM;
+  ELEMENT_NAMES[23] = ELT_TSPAN;
+  ELEMENT_NAMES[24] = ELT_FEFUNCR;
+  ELEMENT_NAMES[25] = ELT_DEFS;
+  ELEMENT_NAMES[26] = ELT_CONTENT;
+  ELEMENT_NAMES[27] = ELT_FEDISTANTLIGHT;
+  ELEMENT_NAMES[28] = ELT_OUTPUT;
+  ELEMENT_NAMES[29] = ELT_TEXT;
   ELEMENT_NAMES[30] = ELT_FEMORPHOLOGY;
   ELEMENT_NAMES[31] = ELT_DEL;
   ELEMENT_NAMES[32] = ELT_NAV;
   ELEMENT_NAMES[33] = ELT_SET;
   ELEMENT_NAMES[34] = ELT_Q;
   ELEMENT_NAMES[35] = ELT_H6;
-  ELEMENT_NAMES[36] = ELT_DESC;
-  ELEMENT_NAMES[37] = ELT_NOEMBED;
-  ELEMENT_NAMES[38] = ELT_CODE;
-  ELEMENT_NAMES[39] = ELT_FETILE;
-  ELEMENT_NAMES[40] = ELT_POLYLINE;
-  ELEMENT_NAMES[41] = ELT_TEMPLATE;
-  ELEMENT_NAMES[42] = ELT_STRONG;
-  ELEMENT_NAMES[43] = ELT_SWITCH;
-  ELEMENT_NAMES[44] = ELT_TRACK;
-  ELEMENT_NAMES[45] = ELT_ALTGLYPHITEM;
-  ELEMENT_NAMES[46] = ELT_BUTTON;
-  ELEMENT_NAMES[47] = ELT_PATTERN;
-  ELEMENT_NAMES[48] = ELT_FEDISPLACEMENTMAP;
-  ELEMENT_NAMES[49] = ELT_ANIMATECOLOR;
-  ELEMENT_NAMES[50] = ELT_FOOTER;
-  ELEMENT_NAMES[51] = ELT_METER;
-  ELEMENT_NAMES[52] = ELT_CANVAS;
-  ELEMENT_NAMES[53] = ELT_NOFRAMES;
-  ELEMENT_NAMES[54] = ELT_BASEFONT;
-  ELEMENT_NAMES[55] = ELT_FEOFFSET;
-  ELEMENT_NAMES[56] = ELT_FONT;
-  ELEMENT_NAMES[57] = ELT_NOSCRIPT;
-  ELEMENT_NAMES[58] = ELT_PLAINTEXT;
-  ELEMENT_NAMES[59] = ELT_SELECT;
-  ELEMENT_NAMES[60] = ELT_MENU;
+  ELEMENT_NAMES[36] = ELT_RB;
+  ELEMENT_NAMES[37] = ELT_LEGEND;
+  ELEMENT_NAMES[38] = ELT_BLOCKQUOTE;
+  ELEMENT_NAMES[39] = ELT_FEMERGE;
+  ELEMENT_NAMES[40] = ELT_MARQUEE;
+  ELEMENT_NAMES[41] = ELT_TIME;
+  ELEMENT_NAMES[42] = ELT_LISTING;
+  ELEMENT_NAMES[43] = ELT_TH;
+  ELEMENT_NAMES[44] = ELT_MASK;
+  ELEMENT_NAMES[45] = ELT_SYMBOL;
+  ELEMENT_NAMES[46] = ELT_ANIMATEMOTION;
+  ELEMENT_NAMES[47] = ELT_POLYGON;
+  ELEMENT_NAMES[48] = ELT_COLGROUP;
+  ELEMENT_NAMES[49] = ELT_ABBR;
+  ELEMENT_NAMES[50] = ELT_FEGAUSSIANBLUR;
+  ELEMENT_NAMES[51] = ELT_ADDRESS;
+  ELEMENT_NAMES[52] = ELT_MS;
+  ELEMENT_NAMES[53] = ELT_APPLET;
+  ELEMENT_NAMES[54] = ELT_FOREIGNOBJECT;
+  ELEMENT_NAMES[55] = ELT_FESPOTLIGHT;
+  ELEMENT_NAMES[56] = ELT_INPUT;
+  ELEMENT_NAMES[57] = ELT_RT;
+  ELEMENT_NAMES[58] = ELT_TT;
+  ELEMENT_NAMES[59] = ELT_SCRIPT;
+  ELEMENT_NAMES[60] = ELT_FEDROPSHADOW;
   ELEMENT_NAMES[61] = ELT_FECONVOLVEMATRIX;
   ELEMENT_NAMES[62] = ELT_SUMMARY;
   ELEMENT_NAMES[63] = ELT_BDO;
   ELEMENT_NAMES[64] = ELT_DIR;
   ELEMENT_NAMES[65] = ELT_KBD;
   ELEMENT_NAMES[66] = ELT_A;
   ELEMENT_NAMES[67] = ELT_SVG;
   ELEMENT_NAMES[68] = ELT_VAR;
   ELEMENT_NAMES[69] = ELT_I;
   ELEMENT_NAMES[70] = ELT_U;
   ELEMENT_NAMES[71] = ELT_H4;
-  ELEMENT_NAMES[72] = ELT_FEFUNCA;
-  ELEMENT_NAMES[73] = ELT_FEFUNCB;
-  ELEMENT_NAMES[74] = ELT_BGSOUND;
-  ELEMENT_NAMES[75] = ELT_HEAD;
-  ELEMENT_NAMES[76] = ELT_THEAD;
-  ELEMENT_NAMES[77] = ELT_BASE;
-  ELEMENT_NAMES[78] = ELT_CITE;
-  ELEMENT_NAMES[79] = ELT_FEIMAGE;
-  ELEMENT_NAMES[80] = ELT_FIGURE;
-  ELEMENT_NAMES[81] = ELT_LINE;
-  ELEMENT_NAMES[82] = ELT_SOURCE;
-  ELEMENT_NAMES[83] = ELT_TITLE;
-  ELEMENT_NAMES[84] = ELT_GLYPHREF;
-  ELEMENT_NAMES[85] = ELT_FESPECULARLIGHTING;
-  ELEMENT_NAMES[86] = ELT_CLIPPATH;
-  ELEMENT_NAMES[87] = ELT_PATH;
-  ELEMENT_NAMES[88] = ELT_LI;
-  ELEMENT_NAMES[89] = ELT_MALIGNMARK;
-  ELEMENT_NAMES[90] = ELT_HTML;
-  ELEMENT_NAMES[91] = ELT_SMALL;
-  ELEMENT_NAMES[92] = ELT_ACRONYM;
-  ELEMENT_NAMES[93] = ELT_PARAM;
-  ELEMENT_NAMES[94] = ELT_FIGCAPTION;
-  ELEMENT_NAMES[95] = ELT_OPTION;
-  ELEMENT_NAMES[96] = ELT_SECTION;
-  ELEMENT_NAMES[97] = ELT_VIDEO;
-  ELEMENT_NAMES[98] = ELT_RP;
-  ELEMENT_NAMES[99] = ELT_BR;
-  ELEMENT_NAMES[100] = ELT_HR;
+  ELEMENT_NAMES[72] = ELT_DATA;
+  ELEMENT_NAMES[73] = ELT_TEXTAREA;
+  ELEMENT_NAMES[74] = ELT_DD;
+  ELEMENT_NAMES[75] = ELT_FEFLOOD;
+  ELEMENT_NAMES[76] = ELT_TD;
+  ELEMENT_NAMES[77] = ELT_ANIMATE;
+  ELEMENT_NAMES[78] = ELT_CIRCLE;
+  ELEMENT_NAMES[79] = ELT_FEMERGENODE;
+  ELEMENT_NAMES[80] = ELT_FRAME;
+  ELEMENT_NAMES[81] = ELT_IFRAME;
+  ELEMENT_NAMES[82] = ELT_PICTURE;
+  ELEMENT_NAMES[83] = ELT_TABLE;
+  ELEMENT_NAMES[84] = ELT_ALTGLYPHDEF;
+  ELEMENT_NAMES[85] = ELT_FEDIFFUSELIGHTING;
+  ELEMENT_NAMES[86] = ELT_ALTGLYPH;
+  ELEMENT_NAMES[87] = ELT_MPATH;
+  ELEMENT_NAMES[88] = ELT_TEXTPATH;
+  ELEMENT_NAMES[89] = ELT_MARK;
+  ELEMENT_NAMES[90] = ELT_DL;
+  ELEMENT_NAMES[91] = ELT_UL;
+  ELEMENT_NAMES[92] = ELT_ANIMATETRANSFORM;
+  ELEMENT_NAMES[93] = ELT_MENUITEM;
+  ELEMENT_NAMES[94] = ELT_CAPTION;
+  ELEMENT_NAMES[95] = ELT_MAIN;
+  ELEMENT_NAMES[96] = ELT_SPAN;
+  ELEMENT_NAMES[97] = ELT_MO;
+  ELEMENT_NAMES[98] = ELT_HGROUP;
+  ELEMENT_NAMES[99] = ELT_STOP;
+  ELEMENT_NAMES[100] = ELT_CENTER;
   ELEMENT_NAMES[101] = ELT_FILTER;
-  ELEMENT_NAMES[102] = ELT_FEGAUSSIANBLUR;
-  ELEMENT_NAMES[103] = ELT_MARKER;
-  ELEMENT_NAMES[104] = ELT_NOBR;
-  ELEMENT_NAMES[105] = ELT_ADDRESS;
-  ELEMENT_NAMES[106] = ELT_DEFS;
-  ELEMENT_NAMES[107] = ELT_MS;
-  ELEMENT_NAMES[108] = ELT_PROGRESS;
-  ELEMENT_NAMES[109] = ELT_APPLET;
-  ELEMENT_NAMES[110] = ELT_FOREIGNOBJECT;
-  ELEMENT_NAMES[111] = ELT_FRAMESET;
-  ELEMENT_NAMES[112] = ELT_FESPOTLIGHT;
-  ELEMENT_NAMES[113] = ELT_FEDISTANTLIGHT;
-  ELEMENT_NAMES[114] = ELT_INPUT;
-  ELEMENT_NAMES[115] = ELT_MTEXT;
-  ELEMENT_NAMES[116] = ELT_RT;
-  ELEMENT_NAMES[117] = ELT_OUTPUT;
-  ELEMENT_NAMES[118] = ELT_TT;
-  ELEMENT_NAMES[119] = ELT_RADIALGRADIENT;
-  ELEMENT_NAMES[120] = ELT_SCRIPT;
-  ELEMENT_NAMES[121] = ELT_TEXT;
-  ELEMENT_NAMES[122] = ELT_FEDROPSHADOW;
+  ELEMENT_NAMES[102] = ELT_MARKER;
+  ELEMENT_NAMES[103] = ELT_TR;
+  ELEMENT_NAMES[104] = ELT_CANVAS;
+  ELEMENT_NAMES[105] = ELT_DETAILS;
+  ELEMENT_NAMES[106] = ELT_NOFRAMES;
+  ELEMENT_NAMES[107] = ELT_DT;
+  ELEMENT_NAMES[108] = ELT_BASEFONT;
+  ELEMENT_NAMES[109] = ELT_DATALIST;
+  ELEMENT_NAMES[110] = ELT_FIELDSET;
+  ELEMENT_NAMES[111] = ELT_FEOFFSET;
+  ELEMENT_NAMES[112] = ELT_FEPOINTLIGHT;
+  ELEMENT_NAMES[113] = ELT_FONT;
+  ELEMENT_NAMES[114] = ELT_LINEARGRADIENT;
+  ELEMENT_NAMES[115] = ELT_NOSCRIPT;
+  ELEMENT_NAMES[116] = ELT_OBJECT;
+  ELEMENT_NAMES[117] = ELT_PLAINTEXT;
+  ELEMENT_NAMES[118] = ELT_RECT;
+  ELEMENT_NAMES[119] = ELT_SELECT;
+  ELEMENT_NAMES[120] = ELT_TFOOT;
+  ELEMENT_NAMES[121] = ELT_MENU;
+  ELEMENT_NAMES[122] = ELT_SHADOW;
   ELEMENT_NAMES[123] = ELT_FECOLORMATRIX;
   ELEMENT_NAMES[124] = ELT_BODY;
   ELEMENT_NAMES[125] = ELT_RUBY;
   ELEMENT_NAMES[126] = ELT_TBODY;
   ELEMENT_NAMES[127] = ELT_BIG;
   ELEMENT_NAMES[128] = ELT_COL;
   ELEMENT_NAMES[129] = ELT_DFN;
   ELEMENT_NAMES[130] = ELT_DIV;
@@ -1114,73 +1653,77 @@ nsHtml5ElementName::initializeStatics()
   ELEMENT_NAMES[138] = ELT_G;
   ELEMENT_NAMES[139] = ELT_XMP;
   ELEMENT_NAMES[140] = ELT_P;
   ELEMENT_NAMES[141] = ELT_S;
   ELEMENT_NAMES[142] = ELT_H1;
   ELEMENT_NAMES[143] = ELT_H3;
   ELEMENT_NAMES[144] = ELT_H5;
   ELEMENT_NAMES[145] = ELT_AREA;
-  ELEMENT_NAMES[146] = ELT_METADATA;
-  ELEMENT_NAMES[147] = ELT_TEXTAREA;
-  ELEMENT_NAMES[148] = ELT_RB;
-  ELEMENT_NAMES[149] = ELT_DD;
-  ELEMENT_NAMES[150] = ELT_EMBED;
-  ELEMENT_NAMES[151] = ELT_FEFLOOD;
-  ELEMENT_NAMES[152] = ELT_LEGEND;
-  ELEMENT_NAMES[153] = ELT_TD;
-  ELEMENT_NAMES[154] = ELT_ASIDE;
-  ELEMENT_NAMES[155] = ELT_ANIMATE;
-  ELEMENT_NAMES[156] = ELT_BLOCKQUOTE;
-  ELEMENT_NAMES[157] = ELT_CIRCLE;
-  ELEMENT_NAMES[158] = ELT_ELLIPSE;
-  ELEMENT_NAMES[159] = ELT_FEMERGENODE;
-  ELEMENT_NAMES[160] = ELT_FEMERGE;
-  ELEMENT_NAMES[161] = ELT_FRAME;
-  ELEMENT_NAMES[162] = ELT_FECOMPOSITE;
-  ELEMENT_NAMES[163] = ELT_IFRAME;
-  ELEMENT_NAMES[164] = ELT_MARQUEE;
-  ELEMENT_NAMES[165] = ELT_PICTURE;
-  ELEMENT_NAMES[166] = ELT_STRIKE;
-  ELEMENT_NAMES[167] = ELT_TABLE;
-  ELEMENT_NAMES[168] = ELT_TIME;
-  ELEMENT_NAMES[169] = ELT_ALTGLYPHDEF;
-  ELEMENT_NAMES[170] = ELT_DIALOG;
-  ELEMENT_NAMES[171] = ELT_FEDIFFUSELIGHTING;
-  ELEMENT_NAMES[172] = ELT_LISTING;
-  ELEMENT_NAMES[173] = ELT_ALTGLYPH;
-  ELEMENT_NAMES[174] = ELT_MGLYPH;
-  ELEMENT_NAMES[175] = ELT_MPATH;
-  ELEMENT_NAMES[176] = ELT_TH;
-  ELEMENT_NAMES[177] = ELT_TEXTPATH;
-  ELEMENT_NAMES[178] = ELT_MI;
-  ELEMENT_NAMES[179] = ELT_MARK;
-  ELEMENT_NAMES[180] = ELT_MASK;
-  ELEMENT_NAMES[181] = ELT_DL;
-  ELEMENT_NAMES[182] = ELT_OL;
-  ELEMENT_NAMES[183] = ELT_UL;
-  ELEMENT_NAMES[184] = ELT_SYMBOL;
-  ELEMENT_NAMES[185] = ELT_ANIMATETRANSFORM;
-  ELEMENT_NAMES[186] = ELT_EM;
-  ELEMENT_NAMES[187] = ELT_MENUITEM;
-  ELEMENT_NAMES[188] = ELT_ANIMATEMOTION;
-  ELEMENT_NAMES[189] = ELT_CAPTION;
-  ELEMENT_NAMES[190] = ELT_MN;
-  ELEMENT_NAMES[191] = ELT_MAIN;
-  ELEMENT_NAMES[192] = ELT_POLYGON;
-  ELEMENT_NAMES[193] = ELT_SPAN;
-  ELEMENT_NAMES[194] = ELT_TSPAN;
-  ELEMENT_NAMES[195] = ELT_MO;
-  ELEMENT_NAMES[196] = ELT_COLGROUP;
-  ELEMENT_NAMES[197] = ELT_HGROUP;
-  ELEMENT_NAMES[198] = ELT_OPTGROUP;
-  ELEMENT_NAMES[199] = ELT_STOP;
-  ELEMENT_NAMES[200] = ELT_ABBR;
-  ELEMENT_NAMES[201] = ELT_CENTER;
-  ELEMENT_NAMES[202] = ELT_FEFUNCR;
+  ELEMENT_NAMES[146] = ELT_FEFUNCA;
+  ELEMENT_NAMES[147] = ELT_META;
+  ELEMENT_NAMES[148] = ELT_FEFUNCB;
+  ELEMENT_NAMES[149] = ELT_DESC;
+  ELEMENT_NAMES[150] = ELT_BGSOUND;
+  ELEMENT_NAMES[151] = ELT_FEBLEND;
+  ELEMENT_NAMES[152] = ELT_HEAD;
+  ELEMENT_NAMES[153] = ELT_NOEMBED;
+  ELEMENT_NAMES[154] = ELT_THEAD;
+  ELEMENT_NAMES[155] = ELT_ARTICLE;
+  ELEMENT_NAMES[156] = ELT_BASE;
+  ELEMENT_NAMES[157] = ELT_CODE;
+  ELEMENT_NAMES[158] = ELT_CITE;
+  ELEMENT_NAMES[159] = ELT_FETURBULENCE;
+  ELEMENT_NAMES[160] = ELT_FEIMAGE;
+  ELEMENT_NAMES[161] = ELT_FETILE;
+  ELEMENT_NAMES[162] = ELT_FIGURE;
+  ELEMENT_NAMES[163] = ELT_IMAGE;
+  ELEMENT_NAMES[164] = ELT_LINE;
+  ELEMENT_NAMES[165] = ELT_POLYLINE;
+  ELEMENT_NAMES[166] = ELT_SOURCE;
+  ELEMENT_NAMES[167] = ELT_STYLE;
+  ELEMENT_NAMES[168] = ELT_TITLE;
+  ELEMENT_NAMES[169] = ELT_TEMPLATE;
+  ELEMENT_NAMES[170] = ELT_GLYPHREF;
+  ELEMENT_NAMES[171] = ELT_FEFUNCG;
+  ELEMENT_NAMES[172] = ELT_FESPECULARLIGHTING;
+  ELEMENT_NAMES[173] = ELT_STRONG;
+  ELEMENT_NAMES[174] = ELT_CLIPPATH;
+  ELEMENT_NAMES[175] = ELT_MATH;
+  ELEMENT_NAMES[176] = ELT_PATH;
+  ELEMENT_NAMES[177] = ELT_SWITCH;
+  ELEMENT_NAMES[178] = ELT_LI;
+  ELEMENT_NAMES[179] = ELT_LINK;
+  ELEMENT_NAMES[180] = ELT_MALIGNMARK;
+  ELEMENT_NAMES[181] = ELT_TRACK;
+  ELEMENT_NAMES[182] = ELT_HTML;
+  ELEMENT_NAMES[183] = ELT_LABEL;
+  ELEMENT_NAMES[184] = ELT_SMALL;
+  ELEMENT_NAMES[185] = ELT_ALTGLYPHITEM;
+  ELEMENT_NAMES[186] = ELT_ACRONYM;
+  ELEMENT_NAMES[187] = ELT_FORM;
+  ELEMENT_NAMES[188] = ELT_PARAM;
+  ELEMENT_NAMES[189] = ELT_BUTTON;
+  ELEMENT_NAMES[190] = ELT_FIGCAPTION;
+  ELEMENT_NAMES[191] = ELT_KEYGEN;
+  ELEMENT_NAMES[192] = ELT_OPTION;
+  ELEMENT_NAMES[193] = ELT_PATTERN;
+  ELEMENT_NAMES[194] = ELT_SECTION;
+  ELEMENT_NAMES[195] = ELT_AUDIO;
+  ELEMENT_NAMES[196] = ELT_VIDEO;
+  ELEMENT_NAMES[197] = ELT_FEDISPLACEMENTMAP;
+  ELEMENT_NAMES[198] = ELT_RP;
+  ELEMENT_NAMES[199] = ELT_SAMP;
+  ELEMENT_NAMES[200] = ELT_BR;
+  ELEMENT_NAMES[201] = ELT_ANIMATECOLOR;
+  ELEMENT_NAMES[202] = ELT_HR;
+  ELEMENT_NAMES[203] = ELT_FECOMPONENTTRANSFER;
+  ELEMENT_NAMES[204] = ELT_FOOTER;
+  ELEMENT_NAMES[205] = ELT_HEADER;
+  ELEMENT_NAMES[206] = ELT_METER;
 }
 
 void
 nsHtml5ElementName::releaseStatics()
 {
   delete ELT_ANNOTATION_XML;
   delete ELT_BIG;
   delete ELT_BDO;
@@ -1214,16 +1757,17 @@ nsHtml5ElementName::releaseStatics()
   delete ELT_U;
   delete ELT_H1;
   delete ELT_H2;
   delete ELT_H3;
   delete ELT_H4;
   delete ELT_H5;
   delete ELT_H6;
   delete ELT_AREA;
+  delete ELT_DATA;
   delete ELT_FEFUNCA;
   delete ELT_METADATA;
   delete ELT_META;
   delete ELT_TEXTAREA;
   delete ELT_FEFUNCB;
   delete ELT_RB;
   delete ELT_DESC;
   delete ELT_DD;
@@ -1347,16 +1891,18 @@ nsHtml5ElementName::releaseStatics()
   delete ELT_DEFS;
   delete ELT_DETAILS;
   delete ELT_MS;
   delete ELT_NOFRAMES;
   delete ELT_PROGRESS;
   delete ELT_DT;
   delete ELT_APPLET;
   delete ELT_BASEFONT;
+  delete ELT_CONTENT;
+  delete ELT_DATALIST;
   delete ELT_FOREIGNOBJECT;
   delete ELT_FIELDSET;
   delete ELT_FRAMESET;
   delete ELT_FEOFFSET;
   delete ELT_FESPOTLIGHT;
   delete ELT_FEPOINTLIGHT;
   delete ELT_FEDISTANTLIGHT;
   delete ELT_FONT;
@@ -1372,16 +1918,17 @@ nsHtml5ElementName::releaseStatics()
   delete ELT_RECT;
   delete ELT_RADIALGRADIENT;
   delete ELT_SELECT;
   delete ELT_SCRIPT;
   delete ELT_TFOOT;
   delete ELT_TEXT;
   delete ELT_MENU;
   delete ELT_FEDROPSHADOW;
+  delete ELT_SHADOW;
   delete ELT_VIEW;
   delete ELT_FECOLORMATRIX;
   delete ELT_FECONVOLVEMATRIX;
   delete ELT_BODY;
   delete ELT_FEMORPHOLOGY;
   delete ELT_RUBY;
   delete ELT_SUMMARY;
   delete ELT_TBODY;
--- a/parser/html/nsHtml5ElementName.h
+++ b/parser/html/nsHtml5ElementName.h
@@ -37,16 +37,17 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 class nsHtml5StreamParser;
 
 class nsHtml5AttributeName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
 class nsHtml5UTF16Buffer;
@@ -73,48 +74,60 @@ public:
 
   static const int32_t HTML_INTEGRATION_POINT = (1 << 24);
 
   static const int32_t OPTIONAL_END_TAG = (1 << 23);
 
 private:
   nsIAtom* name;
   nsIAtom* camelCaseName;
+  mozilla::dom::HTMLContentCreatorFunction htmlCreator;
+  mozilla::dom::SVGContentCreatorFunction svgCreator;
 
 public:
   int32_t flags;
   inline nsIAtom* getName() { return name; }
 
   inline nsIAtom* getCamelCaseName() { return camelCaseName; }
 
+  inline mozilla::dom::HTMLContentCreatorFunction getHtmlCreator()
+  {
+    return htmlCreator;
+  }
+
+  inline mozilla::dom::SVGContentCreatorFunction getSvgCreator()
+  {
+    return svgCreator;
+  }
+
   inline int32_t getFlags() { return flags; }
 
   inline int32_t getGroup() { return flags & nsHtml5ElementName::GROUP_MASK; }
 
   inline bool isInterned()
   {
     return !(flags & nsHtml5ElementName::NOT_INTERNED);
-  }
+    }
 
-  inline static int32_t levelOrderBinarySearch(jArray<int32_t, int32_t> data,
-                                               int32_t key)
-  {
-    int32_t n = data.length;
-    int32_t i = 0;
-    while (i < n) {
-      int32_t val = data[i];
-      if (val < key) {
-        i = 2 * i + 2;
-      } else if (val > key) {
-        i = 2 * i + 1;
-      } else {
-        return i;
+    inline static int32_t levelOrderBinarySearch(jArray<int32_t, int32_t> data,
+                                                 int32_t key)
+    {
+      int32_t n = data.length;
+      int32_t i = 0;
+      while (i < n) {
+        int32_t val = data[i];
+        if (val < key) {
+          i = 2 * i + 2;
+        } else if (val > key) {
+          i = 2 * i + 1;
+        } else {
+          return i;
+        }
       }
-    }
-    return -1;
+      return -1;
     }
 
     inline static nsHtml5ElementName* elementNameByBuffer(
       char16_t* buf,
       int32_t offset,
       int32_t length,
       nsHtml5AtomTable* interner)
     {
@@ -161,27 +174,39 @@ public:
         third <<= 9;
       } else if (length == 2) {
         second = buf[1];
         second <<= 24;
       }
       return len + first + second + third + fourth + fifth;
     }
 
-    nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, int32_t flags);
+    nsHtml5ElementName(nsIAtom* name,
+                       nsIAtom* camelCaseName,
+                       mozilla::dom::HTMLContentCreatorFunction htmlCreator,
+                       mozilla::dom::SVGContentCreatorFunction svgCreator,
+                       int32_t flags);
+
   public:
     nsHtml5ElementName();
     ~nsHtml5ElementName();
-    inline void setNameForNonInterned(nsIAtom* name)
+    inline void setNameForNonInterned(nsIAtom* name, bool custom)
     {
       this->name = name;
       this->camelCaseName = name;
+      if (custom) {
+        this->htmlCreator = NS_NewCustomElement;
+      } else {
+        this->htmlCreator = NS_NewHTMLUnknownElement;
+      }
       MOZ_ASSERT(this->flags == nsHtml5ElementName::NOT_INTERNED);
     }
 
+    inline bool isCustom() { return this->htmlCreator == NS_NewCustomElement; }
+
     static nsHtml5ElementName* ELT_ANNOTATION_XML;
     static nsHtml5ElementName* ELT_BIG;
     static nsHtml5ElementName* ELT_BDO;
     static nsHtml5ElementName* ELT_COL;
     static nsHtml5ElementName* ELT_DEL;
     static nsHtml5ElementName* ELT_DFN;
     static nsHtml5ElementName* ELT_DIR;
     static nsHtml5ElementName* ELT_DIV;
@@ -210,16 +235,17 @@ public:
     static nsHtml5ElementName* ELT_U;
     static nsHtml5ElementName* ELT_H1;
     static nsHtml5ElementName* ELT_H2;
     static nsHtml5ElementName* ELT_H3;
     static nsHtml5ElementName* ELT_H4;
     static nsHtml5ElementName* ELT_H5;
     static nsHtml5ElementName* ELT_H6;
     static nsHtml5ElementName* ELT_AREA;
+    static nsHtml5ElementName* ELT_DATA;
     static nsHtml5ElementName* ELT_FEFUNCA;
     static nsHtml5ElementName* ELT_METADATA;
     static nsHtml5ElementName* ELT_META;
     static nsHtml5ElementName* ELT_TEXTAREA;
     static nsHtml5ElementName* ELT_FEFUNCB;
     static nsHtml5ElementName* ELT_RB;
     static nsHtml5ElementName* ELT_DESC;
     static nsHtml5ElementName* ELT_DD;
@@ -343,16 +369,18 @@ public:
     static nsHtml5ElementName* ELT_DEFS;
     static nsHtml5ElementName* ELT_DETAILS;
     static nsHtml5ElementName* ELT_MS;
     static nsHtml5ElementName* ELT_NOFRAMES;
     static nsHtml5ElementName* ELT_PROGRESS;
     static nsHtml5ElementName* ELT_DT;
     static nsHtml5ElementName* ELT_APPLET;
     static nsHtml5ElementName* ELT_BASEFONT;
+    static nsHtml5ElementName* ELT_CONTENT;
+    static nsHtml5ElementName* ELT_DATALIST;
     static nsHtml5ElementName* ELT_FOREIGNOBJECT;
     static nsHtml5ElementName* ELT_FIELDSET;
     static nsHtml5ElementName* ELT_FRAMESET;
     static nsHtml5ElementName* ELT_FEOFFSET;
     static nsHtml5ElementName* ELT_FESPOTLIGHT;
     static nsHtml5ElementName* ELT_FEPOINTLIGHT;
     static nsHtml5ElementName* ELT_FEDISTANTLIGHT;
     static nsHtml5ElementName* ELT_FONT;
@@ -368,16 +396,17 @@ public:
     static nsHtml5ElementName* ELT_RECT;
     static nsHtml5ElementName* ELT_RADIALGRADIENT;
     static nsHtml5ElementName* ELT_SELECT;
     static nsHtml5ElementName* ELT_SCRIPT;
     static nsHtml5ElementName* ELT_TFOOT;
     static nsHtml5ElementName* ELT_TEXT;
     static nsHtml5ElementName* ELT_MENU;
     static nsHtml5ElementName* ELT_FEDROPSHADOW;
+    static nsHtml5ElementName* ELT_SHADOW;
     static nsHtml5ElementName* ELT_VIEW;
     static nsHtml5ElementName* ELT_FECOLORMATRIX;
     static nsHtml5ElementName* ELT_FECONVOLVEMATRIX;
     static nsHtml5ElementName* ELT_BODY;
     static nsHtml5ElementName* ELT_FEMORPHOLOGY;
     static nsHtml5ElementName* ELT_RUBY;
     static nsHtml5ElementName* ELT_SUMMARY;
     static nsHtml5ElementName* ELT_TBODY;
--- a/parser/html/nsHtml5Highlighter.cpp
+++ b/parser/html/nsHtml5Highlighter.cpp
@@ -75,45 +75,52 @@ nsHtml5Highlighter::~nsHtml5Highlighter(
 void
 nsHtml5Highlighter::Start(const nsAutoString& aTitle)
 {
   // Doctype
   mOpQueue.AppendElement()->Init(nsGkAtoms::html, EmptyString(), EmptyString());
 
   mOpQueue.AppendElement()->Init(STANDARDS_MODE);
 
-  nsIContent** root = CreateElement(nsGkAtoms::html, nullptr, nullptr);
+  // <html> uses NS_NewHTMLSharedElement creator
+  nsIContent** root =
+    CreateElement(nsGkAtoms::html, nullptr, nullptr, NS_NewHTMLSharedElement);
   mOpQueue.AppendElement()->Init(eTreeOpAppendToDocument, root);
   mStack.AppendElement(root);
 
-  Push(nsGkAtoms::head, nullptr);
+  // <head> uses NS_NewHTMLSharedElement creator
+  Push(nsGkAtoms::head, nullptr, NS_NewHTMLSharedElement);
 
-  Push(nsGkAtoms::title, nullptr);
+  Push(nsGkAtoms::title, nullptr, NS_NewHTMLTitleElement);
   // XUL will add the "Source of: " prefix.
   uint32_t length = aTitle.Length();
   if (length > INT32_MAX) {
     length = INT32_MAX;
   }
   AppendCharacters(aTitle.BeginReading(), 0, (int32_t)length);
   Pop(); // title
 
-  Push(nsGkAtoms::link, nsHtml5ViewSourceUtils::NewLinkAttributes());
+  Push(nsGkAtoms::link,
+       nsHtml5ViewSourceUtils::NewLinkAttributes(),
+       NS_NewHTMLLinkElement);
 
   mOpQueue.AppendElement()->Init(eTreeOpUpdateStyleSheet, CurrentNode());
 
   Pop(); // link
 
   Pop(); // head
 
-  Push(nsGkAtoms::body, nsHtml5ViewSourceUtils::NewBodyAttributes());
+  Push(nsGkAtoms::body,
+       nsHtml5ViewSourceUtils::NewBodyAttributes(),
+       NS_NewHTMLBodyElement);
 
   nsHtml5HtmlAttributes* preAttrs = new nsHtml5HtmlAttributes(0);
   nsHtml5String preId = nsHtml5Portability::newStringFromLiteral("line1");
   preAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, preId, -1);
-  Push(nsGkAtoms::pre, preAttrs);
+  Push(nsGkAtoms::pre, preAttrs, NS_NewHTMLPreElement);
 
   StartCharacters();
 
   mOpQueue.AppendElement()->Init(eTreeOpStartLayout);
 }
 
 int32_t
 nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
@@ -488,17 +495,17 @@ nsHtml5Highlighter::DropBuffer(int32_t a
   FlushChars();
   mBuffer = nullptr;
 }
 
 void
 nsHtml5Highlighter::StartSpan()
 {
   FlushChars();
-  Push(nsGkAtoms::span, nullptr);
+  Push(nsGkAtoms::span, nullptr, NS_NewHTMLSpanElement);
   ++mInlinesOpen;
 }
 
 void
 nsHtml5Highlighter::StartSpan(const char16_t* aClass)
 {
   StartSpan();
   AddClass(aClass);
@@ -512,17 +519,17 @@ nsHtml5Highlighter::EndSpanOrA()
   --mInlinesOpen;
 }
 
 void
 nsHtml5Highlighter::StartCharacters()
 {
   NS_PRECONDITION(!mInCharacters, "Already in characters!");
   FlushChars();
-  Push(nsGkAtoms::span, nullptr);
+  Push(nsGkAtoms::span, nullptr, NS_NewHTMLSpanElement);
   mCurrentRun = CurrentNode();
   mInCharacters = true;
 }
 
 void
 nsHtml5Highlighter::EndCharactersAndStartMarkupRun()
 {
   NS_PRECONDITION(mInCharacters, "Not in characters!");
@@ -533,17 +540,17 @@ nsHtml5Highlighter::EndCharactersAndStar
   StartSpan();
   mCurrentRun = CurrentNode();
 }
 
 void
 nsHtml5Highlighter::StartA()
 {
   FlushChars();
-  Push(nsGkAtoms::a, nullptr);
+  Push(nsGkAtoms::a, nullptr, NS_NewHTMLAnchorElement);
   AddClass(sAttributeValue);
   ++mInlinesOpen;
 }
 
 void
 nsHtml5Highlighter::FinishTag()
 {
   while (mInlinesOpen > 1) {
@@ -575,17 +582,17 @@ nsHtml5Highlighter::FlushChars()
         case '\n': {
           ++i;
           if (mCStart < i) {
             int32_t len = i - mCStart;
             AppendCharacters(buf, mCStart, len);
             mCStart = i;
           }
           ++mLineNumber;
-          Push(nsGkAtoms::span, nullptr);
+          Push(nsGkAtoms::span, nullptr, NS_NewHTMLSpanElement);
           nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
           NS_ASSERTION(treeOp, "Tree op allocation failed.");
           treeOp->InitAddLineNumberId(CurrentNode(), mLineNumber);
           Pop();
           break;
         }
         default:
           ++i;
@@ -650,44 +657,51 @@ nsHtml5Highlighter::AllocateContentHandl
   }
 #ifdef DEBUG
   mHandles[mHandlesUsed] = reinterpret_cast<nsIContent*>(uintptr_t(0xC0DEDBAD));
 #endif
   return &mHandles[mHandlesUsed++];
 }
 
 nsIContent**
-nsHtml5Highlighter::CreateElement(nsIAtom* aName,
-                                  nsHtml5HtmlAttributes* aAttributes,
-                                  nsIContent** aIntendedParent)
+nsHtml5Highlighter::CreateElement(
+  nsIAtom* aName,
+  nsHtml5HtmlAttributes* aAttributes,
+  nsIContent** aIntendedParent,
+  mozilla::dom::HTMLContentCreatorFunction aCreator)
 {
   NS_PRECONDITION(aName, "Got null name.");
+  nsHtml5ContentCreatorFunction creator;
+  creator.html = aCreator;
   nsIContent** content = AllocateContentHandle();
   mOpQueue.AppendElement()->Init(kNameSpaceID_XHTML,
                                  aName,
                                  aAttributes,
                                  content,
                                  aIntendedParent,
-                                 true);
+                                 true,
+                                 creator);
   return content;
 }
 
 nsIContent**
 nsHtml5Highlighter::CurrentNode()
 {
   NS_PRECONDITION(mStack.Length() >= 1, "Must have something on stack.");
   return mStack[mStack.Length() - 1];
 }
 
 void
 nsHtml5Highlighter::Push(nsIAtom* aName,
-                         nsHtml5HtmlAttributes* aAttributes)
+                         nsHtml5HtmlAttributes* aAttributes,
+                         mozilla::dom::HTMLContentCreatorFunction aCreator)
 {
   NS_PRECONDITION(mStack.Length() >= 1, "Pushing without root.");
-  nsIContent** elt = CreateElement(aName, aAttributes, CurrentNode()); // Don't inline below!
+  nsIContent** elt = CreateElement(
+    aName, aAttributes, CurrentNode(), aCreator); // Don't inline below!
   mOpQueue.AppendElement()->Init(eTreeOpAppend, elt, CurrentNode());
   mStack.AppendElement(elt);
 }
 
 void
 nsHtml5Highlighter::Pop()
 {
   NS_PRECONDITION(mStack.Length() >= 2, "Popping when stack too short.");
--- a/parser/html/nsHtml5Highlighter.h
+++ b/parser/html/nsHtml5Highlighter.h
@@ -222,38 +222,44 @@ class nsHtml5Highlighter
 
     /**
      * Enqueues an element creation tree operation.
      *
      * @param aName the name of the element
      * @param aAttributes the attribute holder (ownership will be taken) or
      *        nullptr for no attributes
      * @param aIntendedParent the intended parent node for the created element
+     * @param aCreator the content creator function
      * @return the handle for the element that will be created
      */
-    nsIContent** CreateElement(nsIAtom* aName,
-                               nsHtml5HtmlAttributes* aAttributes,
-                               nsIContent** aIntendedParent);
+    nsIContent** CreateElement(
+      nsIAtom* aName,
+      nsHtml5HtmlAttributes* aAttributes,
+      nsIContent** aIntendedParent,
+      mozilla::dom::HTMLContentCreatorFunction aCreator);
 
     /**
      * Gets the handle for the current node. May be called only after the
      * root element has been set.
      *
      * @return the handle for the current node
      */
     nsIContent** CurrentNode();
 
     /**
      * Create an element and push it (its handle) on the stack.
      *
      * @param aName the name of the element
      * @param aAttributes the attribute holder (ownership will be taken) or
      *        nullptr for no attributes
+     * @param aCreator the content creator function
      */
-    void Push(nsIAtom* aName, nsHtml5HtmlAttributes* aAttributes);
+    void Push(nsIAtom* aName,
+              nsHtml5HtmlAttributes* aAttributes,
+              mozilla::dom::HTMLContentCreatorFunction aCreator);
 
     /**
      * Pops the current node off the stack.
      */
     void Pop();
 
     /**
      * Appends text content to the current node.
--- a/parser/html/nsHtml5MetaScanner.cpp
+++ b/parser/html/nsHtml5MetaScanner.cpp
@@ -37,16 +37,17 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 #include "nsHtml5AttributeName.h"
 #include "nsHtml5ElementName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5StateSnapshot.h"
--- a/parser/html/nsHtml5MetaScanner.h
+++ b/parser/html/nsHtml5MetaScanner.h
@@ -38,16 +38,17 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 class nsHtml5StreamParser;
 
 class nsHtml5AttributeName;
 class nsHtml5ElementName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5UTF16Buffer;
--- a/parser/html/nsHtml5Portability.h
+++ b/parser/html/nsHtml5Portability.h
@@ -36,16 +36,17 @@
 #include "nsTraceRefcnt.h"
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 class nsHtml5StreamParser;
 
 class nsHtml5AttributeName;
 class nsHtml5ElementName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
--- a/parser/html/nsHtml5StackNode.cpp
+++ b/parser/html/nsHtml5StackNode.cpp
@@ -37,16 +37,17 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 #include "nsHtml5AttributeName.h"
 #include "nsHtml5ElementName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5MetaScanner.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5StateSnapshot.h"
@@ -86,48 +87,58 @@ nsHtml5StackNode::isHtmlIntegrationPoint
 
 nsHtml5StackNode::nsHtml5StackNode(int32_t idxInTreeBuilder)
   : idxInTreeBuilder(idxInTreeBuilder)
   , refcount(0)
 {
   MOZ_COUNT_CTOR(nsHtml5StackNode);
 }
 
+mozilla::dom::HTMLContentCreatorFunction
+nsHtml5StackNode::getHtmlCreator()
+{
+  return htmlCreator;
+}
+
 void
-nsHtml5StackNode::setValues(int32_t flags,
-                            int32_t ns,
-                            nsIAtom* name,
-                            nsIContentHandle* node,
-                            nsIAtom* popName,
-                            nsHtml5HtmlAttributes* attributes)
+nsHtml5StackNode::setValues(
+  int32_t flags,
+  int32_t ns,
+  nsIAtom* name,
+  nsIContentHandle* node,
+  nsIAtom* popName,
+  nsHtml5HtmlAttributes* attributes,
+  mozilla::dom::HTMLContentCreatorFunction htmlCreator)
 {
   MOZ_ASSERT(isUnused());
   this->flags = flags;
   this->name = name;
   this->popName = popName;
   this->ns = ns;
   this->node = node;
   this->attributes = attributes;
   this->refcount = 1;
+  this->htmlCreator = htmlCreator;
 }
 
 void
 nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
                             nsIContentHandle* node)
 {
   MOZ_ASSERT(isUnused());
   this->flags = elementName->getFlags();
   this->name = elementName->getName();
   this->popName = elementName->getName();
   this->ns = kNameSpaceID_XHTML;
   this->node = node;
   this->attributes = nullptr;
   this->refcount = 1;
   MOZ_ASSERT(elementName->isInterned(),
              "Don't use this constructor for custom elements.");
+  this->htmlCreator = nullptr;
 }
 
 void
 nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
                             nsIContentHandle* node,
                             nsHtml5HtmlAttributes* attributes)
 {
   MOZ_ASSERT(isUnused());
@@ -135,46 +146,49 @@ nsHtml5StackNode::setValues(nsHtml5Eleme
   this->name = elementName->getName();
   this->popName = elementName->getName();
   this->ns = kNameSpaceID_XHTML;
   this->node = node;
   this->attributes = attributes;
   this->refcount = 1;
   MOZ_ASSERT(elementName->isInterned(),
              "Don't use this constructor for custom elements.");
+  this->htmlCreator = elementName->getHtmlCreator();
 }
 
 void
 nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
                             nsIContentHandle* node,
                             nsIAtom* popName)
 {
   MOZ_ASSERT(isUnused());
   this->flags = elementName->getFlags();
   this->name = elementName->getName();
   this->popName = popName;
   this->ns = kNameSpaceID_XHTML;
   this->node = node;
   this->attributes = nullptr;
   this->refcount = 1;
+  this->htmlCreator = nullptr;
 }
 
 void
 nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
                             nsIAtom* popName,
                             nsIContentHandle* node)
 {
   MOZ_ASSERT(isUnused());
   this->flags = prepareSvgFlags(elementName->getFlags());
   this->name = elementName->getName();
   this->popName = popName;
   this->ns = kNameSpaceID_SVG;
   this->node = node;
   this->attributes = nullptr;
   this->refcount = 1;
+  this->htmlCreator = nullptr;
 }
 
 void
 nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
                             nsIContentHandle* node,
                             nsIAtom* popName,
                             bool markAsIntegrationPoint)
 {
@@ -182,16 +196,17 @@ nsHtml5StackNode::setValues(nsHtml5Eleme
   this->flags =
     prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint);
   this->name = elementName->getName();
   this->popName = popName;
   this->ns = kNameSpaceID_MathML;
   this->node = node;
   this->attributes = nullptr;
   this->refcount = 1;
+  this->htmlCreator = nullptr;
 }
 
 int32_t 
 nsHtml5StackNode::prepareSvgFlags(int32_t flags)
 {
   flags &=
     ~(nsHtml5ElementName::FOSTER_PARENTING | nsHtml5ElementName::SCOPING |
       nsHtml5ElementName::SPECIAL | nsHtml5ElementName::OPTIONAL_END_TAG);
--- a/parser/html/nsHtml5StackNode.h
+++ b/parser/html/nsHtml5StackNode.h
@@ -38,16 +38,17 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 class nsHtml5StreamParser;
 
 class nsHtml5AttributeName;
 class nsHtml5ElementName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
@@ -63,34 +64,38 @@ class nsHtml5StackNode
     int32_t flags;
     nsIAtom* name;
     nsIAtom* popName;
     int32_t ns;
     nsIContentHandle* node;
     nsHtml5HtmlAttributes* attributes;
   private:
     int32_t refcount;
+    mozilla::dom::HTMLContentCreatorFunction htmlCreator;
+
   public:
     inline int32_t getFlags()
     {
       return flags;
     }
 
     int32_t getGroup();
     bool isScoping();
     bool isSpecial();
     bool isFosterParenting();
     bool isHtmlIntegrationPoint();
     explicit nsHtml5StackNode(int32_t idxInTreeBuilder);
+    mozilla::dom::HTMLContentCreatorFunction getHtmlCreator();
     void setValues(int32_t flags,
                    int32_t ns,
                    nsIAtom* name,
                    nsIContentHandle* node,
                    nsIAtom* popName,
-                   nsHtml5HtmlAttributes* attributes);
+                   nsHtml5HtmlAttributes* attributes,
+                   mozilla::dom::HTMLContentCreatorFunction htmlCreator);
     void setValues(nsHtml5ElementName* elementName, nsIContentHandle* node);
     void setValues(nsHtml5ElementName* elementName,
                    nsIContentHandle* node,
                    nsHtml5HtmlAttributes* attributes);
     void setValues(nsHtml5ElementName* elementName,
                    nsIContentHandle* node,
                    nsIAtom* popName);
     void setValues(nsHtml5ElementName* elementName,
--- a/parser/html/nsHtml5StateSnapshot.cpp
+++ b/parser/html/nsHtml5StateSnapshot.cpp
@@ -36,16 +36,17 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 #include "nsHtml5AttributeName.h"
 #include "nsHtml5ElementName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5MetaScanner.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5UTF16Buffer.h"
--- a/parser/html/nsHtml5StateSnapshot.h
+++ b/parser/html/nsHtml5StateSnapshot.h
@@ -37,16 +37,17 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 class nsHtml5StreamParser;
 
 class nsHtml5AttributeName;
 class nsHtml5ElementName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
--- a/parser/html/nsHtml5Tokenizer.cpp
+++ b/parser/html/nsHtml5Tokenizer.cpp
@@ -290,26 +290,28 @@ nsHtml5Tokenizer::strBufToElementNameStr
   if (containsHyphen) {
     nsIAtom* annotationName = nsHtml5ElementName::ELT_ANNOTATION_XML->getName();
     if (nsHtml5Portability::localEqualsBuffer(
           annotationName, strBuf, 0, strBufLen)) {
       tagName = nsHtml5ElementName::ELT_ANNOTATION_XML;
     } else {
       nonInternedTagName->setNameForNonInterned(
         nsHtml5Portability::newLocalNameFromBuffer(
-          strBuf, 0, strBufLen, interner));
+          strBuf, 0, strBufLen, interner),
+        true);
       tagName = nonInternedTagName;
     }
   } else {
     tagName =
       nsHtml5ElementName::elementNameByBuffer(strBuf, 0, strBufLen, interner);
     if (!tagName) {
       nonInternedTagName->setNameForNonInterned(
         nsHtml5Portability::newLocalNameFromBuffer(
-          strBuf, 0, strBufLen, interner));
+          strBuf, 0, strBufLen, interner),
+        false);
       tagName = nonInternedTagName;
     }
   }
   containsHyphen = false;
   clearStrBufAfterUse();
 }
 
 int32_t 
@@ -1801,16 +1803,17 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
               charRefBufMark = charRefBufLen;
             }
             NS_HTML5_BREAK(outer);
           }
           if (hi < lo) {
             NS_HTML5_BREAK(outer);
           }
           appendCharRefBuf(c);
+          continue;
         }
         outer_end: ;
         if (candidate == -1) {
           if (P::reportErrors) {
             errNoNamedCharacterMatch();
           }
           emitOrAppendCharRefBuf(returnState);
           if (!(returnState & DATA_AND_RCDATA_MASK)) {
@@ -4349,16 +4352,17 @@ nsHtml5Tokenizer::eof()
             } else {
               NS_HTML5_BREAK(loloop);
             }
           }
           loloop_end: ;
           if (hi < lo) {
             NS_HTML5_BREAK(outer);
           }
+          continue;
         }
         outer_end: ;
         if (candidate == -1) {
           errNoNamedCharacterMatch();
           emitOrAppendCharRefBuf(returnState);
           state = returnState;
           NS_HTML5_CONTINUE(eofloop);
         } else {
@@ -4428,16 +4432,17 @@ nsHtml5Tokenizer::eof()
       case DATA:
       default: {
         NS_HTML5_BREAK(eofloop);
       }
     }
   }
   eofloop_end: ;
   tokenHandler->eof();
+  return;
 }
 
 void 
 nsHtml5Tokenizer::emitDoctypeToken(int32_t pos)
 {
   cstart = pos + 1;
   tokenHandler->doctype(doctypeName, publicIdentifier, systemIdentifier, forceQuirks);
   doctypeName = nullptr;
@@ -4486,17 +4491,17 @@ nsHtml5Tokenizer::end()
     systemIdentifier.Release();
     systemIdentifier = nullptr;
   }
   if (publicIdentifier) {
     publicIdentifier.Release();
     publicIdentifier = nullptr;
   }
   tagName = nullptr;
-  nonInternedTagName->setNameForNonInterned(nullptr);
+  nonInternedTagName->setNameForNonInterned(nullptr, false);
   attributeName = nullptr;
   nonInternedAttributeName->setNameForNonInterned(nullptr);
   tokenHandler->endTokenization();
   if (attributes) {
     attributes->clear(0);
   }
 }
 
@@ -4592,17 +4597,18 @@ nsHtml5Tokenizer::loadState(nsHtml5Token
   containsHyphen = other->containsHyphen;
   if (!other->tagName) {
     tagName = nullptr;
   } else if (other->tagName->isInterned()) {
     tagName = other->tagName;
   } else {
     nonInternedTagName->setNameForNonInterned(
       nsHtml5Portability::newLocalFromLocal(other->tagName->getName(),
-                                            interner));
+                                            interner),
+      other->tagName->isCustom());
     tagName = nonInternedTagName;
   }
   if (!other->attributeName) {
     attributeName = nullptr;
   } else if (other->attributeName->isInterned()) {
     attributeName = other->attributeName;
   } else {
     nonInternedAttributeName->setNameForNonInterned(
--- a/parser/html/nsHtml5TreeBuilder.cpp
+++ b/parser/html/nsHtml5TreeBuilder.cpp
@@ -164,17 +164,18 @@ nsHtml5TreeBuilder::startTokenization(ns
     contextName = nullptr;
     contextNode = nullptr;
   } else {
     mode = INITIAL;
     if (tokenizer->isViewingXmlSource()) {
       nsIContentHandle* elt = createElement(kNameSpaceID_SVG,
                                             nsGkAtoms::svg,
                                             tokenizer->emptyAttributes(),
-                                            nullptr);
+                                            nullptr,
+                                            svgCreator(NS_NewSVGSVGElement));
       nsHtml5StackNode* node =
         createStackNode(nsHtml5ElementName::ELT_SVG, nsGkAtoms::svg, elt);
       currentPtr++;
       stack[currentPtr] = node;
     }
   }
 }
 
@@ -199,16 +200,17 @@ nsHtml5TreeBuilder::doctype(nsIAtom* nam
       documentModeInternal(ALMOST_STANDARDS_MODE, publicIdentifier, systemIdentifier, false);
     } else {
       documentModeInternal(STANDARDS_MODE, publicIdentifier, systemIdentifier, false);
     }
     mode = BEFORE_HTML;
     return;
   }
   errStrayDoctype();
+  return;
 }
 
 void 
 nsHtml5TreeBuilder::comment(char16_t* buf, int32_t start, int32_t length)
 {
   needToDropLF = false;
   if (!isInForeign()) {
     switch(mode) {
@@ -226,16 +228,17 @@ nsHtml5TreeBuilder::comment(char16_t* bu
       }
       default: {
         break;
       }
     }
   }
   flushCharacters();
   appendComment(stack[currentPtr]->node, buf, start, length);
+  return;
 }
 
 void 
 nsHtml5TreeBuilder::characters(const char16_t* buf, int32_t start, int32_t length)
 {
   if (tokenizer->isViewingXmlSource()) {
     return;
   }
@@ -927,17 +930,17 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
             case INPUT: {
               errStartTagInTable(name);
               if (!nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("hidden", attributes->getValue(nsHtml5AttributeName::ATTR_TYPE))) {
                 NS_HTML5_BREAK(intableloop);
               }
-              appendVoidElementToCurrent(name, attributes, formPointer);
+              appendVoidInputToCurrent(attributes, formPointer);
               selfClosing = false;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
             case FORM: {
               if (!!formPointer || isTemplateContents()) {
                 errFormWhenFormOpen();
                 NS_HTML5_BREAK(starttagloop);
@@ -1287,17 +1290,18 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
               errImage();
               elementName = nsHtml5ElementName::ELT_IMG;
               NS_HTML5_CONTINUE(starttagloop);
             }
             case IMG:
             case KEYGEN:
             case INPUT: {
               reconstructTheActiveFormattingElements();
-              appendVoidElementToCurrentMayFoster(name, attributes, formPointer);
+              appendVoidElementToCurrentMayFoster(
+                elementName, attributes, formPointer);
               selfClosing = false;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
             case TEXTAREA: {
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
               tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::RCDATA,
                                                       elementName);
@@ -3336,16 +3340,17 @@ nsHtml5TreeBuilder::closeTheCell(int32_t
   if (!!MOZ_UNLIKELY(mViewSource) && eltPos != currentPtr) {
     errUnclosedElementsCell(eltPos);
   }
   while (currentPtr >= eltPos) {
     pop();
   }
   clearTheListOfActiveFormattingElementsUpToTheLastMarker();
   mode = IN_ROW;
+  return;
 }
 
 int32_t 
 nsHtml5TreeBuilder::findLastInTableScopeTdTh()
 {
   for (int32_t i = currentPtr; i > 0; i--) {
     nsIAtom* name = stack[i]->name;
     if (stack[i]->ns == kNameSpaceID_XHTML) {
@@ -3701,23 +3706,29 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag
         furthestBlockPos--;
         continue;
       }
       if (nodePos == furthestBlockPos) {
         bookmark = nodeListPos + 1;
       }
       MOZ_ASSERT(node == listOfActiveFormattingElements[nodeListPos]);
       MOZ_ASSERT(node == stack[nodePos]);
-      nsIContentHandle* clone = createElement(kNameSpaceID_XHTML, node->name, node->attributes->cloneAttributes(nullptr), commonAncestor->node);
+      nsIContentHandle* clone =
+        createElement(kNameSpaceID_XHTML,
+                      node->name,
+                      node->attributes->cloneAttributes(nullptr),
+                      commonAncestor->node,
+                      htmlCreator(node->getHtmlCreator()));
       nsHtml5StackNode* newNode = createStackNode(node->getFlags(),
                                                   node->ns,
                                                   node->name,
                                                   clone,
                                                   node->popName,
-                                                  node->attributes);
+                                                  node->attributes,
+                                                  node->getHtmlCreator());
       node->dropAttributes();
       stack[nodePos] = newNode;
       newNode->retain();
       listOfActiveFormattingElements[nodeListPos] = newNode;
       node->release(this);
       node->release(this);
       node = newNode;
       detachFromParent(lastNode->node);
@@ -3727,24 +3738,30 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag
     if (commonAncestor->isFosterParenting()) {
 
       detachFromParent(lastNode->node);
       insertIntoFosterParent(lastNode->node);
     } else {
       detachFromParent(lastNode->node);
       appendElement(lastNode->node, commonAncestor->node);
     }
-    nsIContentHandle* clone = createElement(kNameSpaceID_XHTML, formattingElt->name, formattingElt->attributes->cloneAttributes(nullptr), furthestBlock->node);
+    nsIContentHandle* clone =
+      createElement(kNameSpaceID_XHTML,
+                    formattingElt->name,
+                    formattingElt->attributes->cloneAttributes(nullptr),
+                    furthestBlock->node,
+                    htmlCreator(formattingElt->getHtmlCreator()));
     nsHtml5StackNode* formattingClone =
       createStackNode(formattingElt->getFlags(),
                       formattingElt->ns,
                       formattingElt->name,
                       clone,
                       formattingElt->popName,
-                      formattingElt->attributes);
+                      formattingElt->attributes,
+                      formattingElt->getHtmlCreator());
     formattingElt->dropAttributes();
     appendChildrenToNewParent(furthestBlock->node, clone);
     appendElement(clone, furthestBlock->node);
     removeFromListOfActiveFormattingElements(formattingEltListPos);
     insertIntoListOfActiveFormattingElements(formattingClone, bookmark);
     MOZ_ASSERT(formattingEltStackPos < furthestBlockPos);
     removeFromStack(formattingEltStackPos);
     insertIntoStack(formattingClone, furthestBlockPos);
@@ -3897,27 +3914,36 @@ nsHtml5TreeBuilder::reconstructTheActive
     }
   }
   while (entryPos < listPtr) {
     entryPos++;
     nsHtml5StackNode* entry = listOfActiveFormattingElements[entryPos];
     nsHtml5StackNode* currentNode = stack[currentPtr];
     nsIContentHandle* clone;
     if (currentNode->isFosterParenting()) {
-      clone = createAndInsertFosterParentedElement(kNameSpaceID_XHTML, entry->name, entry->attributes->cloneAttributes(nullptr));
+      clone = createAndInsertFosterParentedElement(
+        kNameSpaceID_XHTML,
+        entry->name,
+        entry->attributes->cloneAttributes(nullptr),
+        htmlCreator(entry->getHtmlCreator()));
     } else {
-      clone = createElement(kNameSpaceID_XHTML, entry->name, entry->attributes->cloneAttributes(nullptr), currentNode->node);
+      clone = createElement(kNameSpaceID_XHTML,
+                            entry->name,
+                            entry->attributes->cloneAttributes(nullptr),
+                            currentNode->node,
+                            htmlCreator(entry->getHtmlCreator()));
       appendElement(clone, currentNode->node);
     }
     nsHtml5StackNode* entryClone = createStackNode(entry->getFlags(),
                                                    entry->ns,
                                                    entry->name,
                                                    clone,
                                                    entry->popName,
-                                                   entry->attributes);
+                                                   entry->attributes,
+                                                   entry->getHtmlCreator());
     entry->dropAttributes();
     push(entryClone);
     listOfActiveFormattingElements[entryPos] = entryClone;
     entry->release(this);
     entryClone->retain();
   }
 }
 
@@ -3948,25 +3974,27 @@ nsHtml5TreeBuilder::getUnusedStackNode()
   nsHtml5ArrayCopy::arraycopy(stackNodes, newStack, stackNodes.length);
   stackNodes = newStack;
   stackNodes[stackNodesIdx] = new nsHtml5StackNode(stackNodesIdx);
   numStackNodes++;
   return stackNodes[stackNodesIdx++];
 }
 
 nsHtml5StackNode*
-nsHtml5TreeBuilder::createStackNode(int32_t flags,
-                                    int32_t ns,
-                                    nsIAtom* name,
-                                    nsIContentHandle* node,
-                                    nsIAtom* popName,
-                                    nsHtml5HtmlAttributes* attributes)
+nsHtml5TreeBuilder::createStackNode(
+  int32_t flags,
+  int32_t ns,
+  nsIAtom* name,
+  nsIContentHandle* node,
+  nsIAtom* popName,
+  nsHtml5HtmlAttributes* attributes,
+  mozilla::dom::HTMLContentCreatorFunction htmlCreator)
 {
   nsHtml5StackNode* instance = getUnusedStackNode();
-  instance->setValues(flags, ns, name, node, popName, attributes);
+  instance->setValues(flags, ns, name, node, popName, attributes, htmlCreator);
   return instance;
 }
 
 nsHtml5StackNode*
 nsHtml5TreeBuilder::createStackNode(nsHtml5ElementName* elementName,
                                     nsIContentHandle* node)
 {
   nsHtml5StackNode* instance = getUnusedStackNode();
@@ -4023,34 +4051,46 @@ nsHtml5TreeBuilder::insertIntoFosterPare
   if (templatePos >= tablePos) {
     appendElement(child, stack[templatePos]->node);
     return;
   }
   nsHtml5StackNode* node = stack[tablePos];
   insertFosterParentedChild(child, node->node, stack[tablePos - 1]->node);
 }
 
-nsIContentHandle* 
-nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes)
+nsIContentHandle*
+nsHtml5TreeBuilder::createAndInsertFosterParentedElement(
+  int32_t ns,
+  nsIAtom* name,
+  nsHtml5HtmlAttributes* attributes,
+  nsHtml5ContentCreatorFunction creator)
 {
-  return createAndInsertFosterParentedElement(ns, name, attributes, nullptr);
+  return createAndInsertFosterParentedElement(
+    ns, name, attributes, nullptr, creator);
 }
 
-nsIContentHandle* 
-nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form)
+nsIContentHandle*
+nsHtml5TreeBuilder::createAndInsertFosterParentedElement(
+  int32_t ns,
+  nsIAtom* name,
+  nsHtml5HtmlAttributes* attributes,
+  nsIContentHandle* form,
+  nsHtml5ContentCreatorFunction creator)
 {
   int32_t tablePos = findLastOrRoot(nsHtml5TreeBuilder::TABLE);
   int32_t templatePos = findLastOrRoot(nsHtml5TreeBuilder::TEMPLATE);
   if (templatePos >= tablePos) {
-    nsIContentHandle* child = createElement(ns, name, attributes, form, stack[templatePos]->node);
+    nsIContentHandle* child = createElement(
+      ns, name, attributes, form, stack[templatePos]->node, creator);
     appendElement(child, stack[templatePos]->node);
     return child;
   }
   nsHtml5StackNode* node = stack[tablePos];
-  return createAndInsertFosterParentedElement(ns, name, attributes, form, node->node, stack[tablePos - 1]->node);
+  return createAndInsertFosterParentedElement(
+    ns, name, attributes, form, node->node, stack[tablePos - 1]->node, creator);
 }
 
 bool 
 nsHtml5TreeBuilder::isInStack(nsHtml5StackNode* node)
 {
   for (int32_t i = currentPtr; i >= 0; i--) {
     if (stack[i] == node) {
       return true;
@@ -4108,18 +4148,21 @@ nsHtml5TreeBuilder::appendHtmlElementToD
 {
   appendHtmlElementToDocumentAndPush(tokenizer->emptyAttributes());
 }
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes* attributes)
 {
   nsIContentHandle* currentNode = stack[currentPtr]->node;
-  nsIContentHandle* elt =
-    createElement(kNameSpaceID_XHTML, nsGkAtoms::head, attributes, currentNode);
+  nsIContentHandle* elt = createElement(kNameSpaceID_XHTML,
+                                        nsGkAtoms::head,
+                                        attributes,
+                                        currentNode,
+                                        htmlCreator(NS_NewHTMLSharedElement));
   appendElement(elt, currentNode);
   headPointer = elt;
   nsHtml5StackNode* node = createStackNode(nsHtml5ElementName::ELT_HEAD, elt);
   push(node);
 }
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushBodyElement(nsHtml5HtmlAttributes* attributes)
@@ -4135,21 +4178,27 @@ nsHtml5TreeBuilder::appendToCurrentNodeA
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormElementMayFoster(nsHtml5HtmlAttributes* attributes)
 {
   nsIContentHandle* elt;
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
-    elt = createAndInsertFosterParentedElement(
-      kNameSpaceID_XHTML, nsGkAtoms::form, attributes);
+    elt =
+      createAndInsertFosterParentedElement(kNameSpaceID_XHTML,
+                                           nsGkAtoms::form,
+                                           attributes,
+                                           htmlCreator(NS_NewHTMLFormElement));
   } else {
-    elt = createElement(
-      kNameSpaceID_XHTML, nsGkAtoms::form, attributes, current->node);
+    elt = createElement(kNameSpaceID_XHTML,
+                        nsGkAtoms::form,
+                        attributes,
+                        current->node,
+                        htmlCreator(NS_NewHTMLFormElement));
     appendElement(elt, current->node);
   }
   if (!isTemplateContents()) {
     formPointer = elt;
   }
   nsHtml5StackNode* node = createStackNode(nsHtml5ElementName::ELT_FORM, elt);
   push(node);
 }
@@ -4158,53 +4207,71 @@ void
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormattingElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
   nsHtml5HtmlAttributes* clone = attributes->cloneAttributes(nullptr);
   nsIContentHandle* elt;
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
     elt = createAndInsertFosterParentedElement(
-      kNameSpaceID_XHTML, elementName->getName(), attributes);
+      kNameSpaceID_XHTML,
+      elementName->getName(),
+      attributes,
+      htmlCreator(elementName->getHtmlCreator()));
   } else {
-    elt = createElement(
-      kNameSpaceID_XHTML, elementName->getName(), attributes, current->node);
+    elt = createElement(kNameSpaceID_XHTML,
+                        elementName->getName(),
+                        attributes,
+                        current->node,
+                        htmlCreator(elementName->getHtmlCreator()));
     appendElement(elt, current->node);
   }
   nsHtml5StackNode* node = createStackNode(elementName, elt, clone);
   push(node);
   append(node);
   node->retain();
 }
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushElement(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
   nsIContentHandle* currentNode = stack[currentPtr]->node;
-  nsIContentHandle* elt = createElement(
-    kNameSpaceID_XHTML, elementName->getName(), attributes, currentNode);
+  nsIContentHandle* elt =
+    createElement(kNameSpaceID_XHTML,
+                  elementName->getName(),
+                  attributes,
+                  currentNode,
+                  htmlCreator(elementName->getHtmlCreator()));
   appendElement(elt, currentNode);
   if (nsHtml5ElementName::ELT_TEMPLATE == elementName) {
     elt = getDocumentFragmentForTemplate(elt);
   }
   nsHtml5StackNode* node = createStackNode(elementName, elt);
   push(node);
 }
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
   nsIAtom* popName = elementName->getName();
   nsIContentHandle* elt;
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
-    elt = createAndInsertFosterParentedElement(kNameSpaceID_XHTML, popName, attributes);
+    elt = createAndInsertFosterParentedElement(
+      kNameSpaceID_XHTML,
+      popName,
+      attributes,
+      htmlCreator(elementName->getHtmlCreator()));
   } else {
-    elt = createElement(kNameSpaceID_XHTML, popName, attributes, current->node);
+    elt = createElement(kNameSpaceID_XHTML,
+                        popName,
+                        attributes,
+                        current->node,
+                        htmlCreator(elementName->getHtmlCreator()));
     appendElement(elt, current->node);
   }
   nsHtml5StackNode* node = createStackNode(elementName, elt, popName);
   push(node);
 }
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
@@ -4213,19 +4280,24 @@ nsHtml5TreeBuilder::appendToCurrentNodeA
   bool markAsHtmlIntegrationPoint = false;
   if (nsHtml5ElementName::ELT_ANNOTATION_XML == elementName && annotationXmlEncodingPermitsHtml(attributes)) {
     markAsHtmlIntegrationPoint = true;
   }
   nsIContentHandle* elt;
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
-    elt = createAndInsertFosterParentedElement(kNameSpaceID_MathML, popName, attributes);
+    elt = createAndInsertFosterParentedElement(
+      kNameSpaceID_MathML, popName, attributes, htmlCreator(nullptr));
   } else {
-    elt = createElement(kNameSpaceID_MathML, popName, attributes, current->node);
+    elt = createElement(kNameSpaceID_MathML,
+                        popName,
+                        attributes,
+                        current->node,
+                        htmlCreator(nullptr));
     appendElement(elt, current->node);
   }
   nsHtml5StackNode* node =
     createStackNode(elementName, elt, popName, markAsHtmlIntegrationPoint);
   push(node);
 }
 
 bool 
@@ -4242,131 +4314,189 @@ nsHtml5TreeBuilder::annotationXmlEncodin
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
   nsIAtom* popName = elementName->getCamelCaseName();
   nsIContentHandle* elt;
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
-    elt = createAndInsertFosterParentedElement(kNameSpaceID_SVG, popName, attributes);
+    elt = createAndInsertFosterParentedElement(
+      kNameSpaceID_SVG,
+      popName,
+      attributes,
+      svgCreator(elementName->getSvgCreator()));
   } else {
-    elt = createElement(kNameSpaceID_SVG, popName, attributes, current->node);
+    elt = createElement(kNameSpaceID_SVG,
+                        popName,
+                        attributes,
+                        current->node,
+                        svgCreator(elementName->getSvgCreator()));
     appendElement(elt, current->node);
   }
   nsHtml5StackNode* node = createStackNode(elementName, popName, elt);
   push(node);
 }
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form)
 {
   nsIContentHandle* elt;
   nsIContentHandle* formOwner = !form || fragment || isTemplateContents() ? nullptr : form;
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
     elt = createAndInsertFosterParentedElement(
-      kNameSpaceID_XHTML, elementName->getName(), attributes, formOwner);
+      kNameSpaceID_XHTML,
+      elementName->getName(),
+      attributes,
+      formOwner,
+      htmlCreator(elementName->getHtmlCreator()));
   } else {
     elt = createElement(kNameSpaceID_XHTML,
                         elementName->getName(),
                         attributes,
                         formOwner,
-                        current->node);
+                        current->node,
+                        htmlCreator(elementName->getHtmlCreator()));
     appendElement(elt, current->node);
   }
   nsHtml5StackNode* node = createStackNode(elementName, elt);
   push(node);
 }
 
-void 
-nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form)
+void
+nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(
+  nsHtml5ElementName* elementName,
+  nsHtml5HtmlAttributes* attributes,
+  nsIContentHandle* form)
 {
+  nsIAtom* name = elementName->getName();
   nsIContentHandle* elt;
   nsIContentHandle* formOwner = !form || fragment || isTemplateContents() ? nullptr : form;
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
-    elt = createAndInsertFosterParentedElement(kNameSpaceID_XHTML, name, attributes, formOwner);
+    elt = createAndInsertFosterParentedElement(
+      kNameSpaceID_XHTML,
+      name,
+      attributes,
+      formOwner,
+      htmlCreator(elementName->getHtmlCreator()));
   } else {
-    elt = createElement(kNameSpaceID_XHTML, name, attributes, formOwner, current->node);
+    elt = createElement(kNameSpaceID_XHTML,
+                        name,
+                        attributes,
+                        formOwner,
+                        current->node,
+                        htmlCreator(elementName->getHtmlCreator()));
     appendElement(elt, current->node);
   }
   elementPushed(kNameSpaceID_XHTML, name, elt);
   elementPopped(kNameSpaceID_XHTML, name, elt);
 }
 
 void 
 nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
   nsIAtom* popName = elementName->getName();
   nsIContentHandle* elt;
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
-    elt = createAndInsertFosterParentedElement(kNameSpaceID_XHTML, popName, attributes);
+    elt = createAndInsertFosterParentedElement(
+      kNameSpaceID_XHTML,
+      popName,
+      attributes,
+      htmlCreator(elementName->getHtmlCreator()));
   } else {
-    elt = createElement(kNameSpaceID_XHTML, popName, attributes, current->node);
+    elt = createElement(kNameSpaceID_XHTML,
+                        popName,
+                        attributes,
+                        current->node,
+                        htmlCreator(elementName->getHtmlCreator()));
     appendElement(elt, current->node);
   }
   elementPushed(kNameSpaceID_XHTML, popName, elt);
   elementPopped(kNameSpaceID_XHTML, popName, elt);
 }
 
 void 
 nsHtml5TreeBuilder::appendVoidElementToCurrentMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
   nsIAtom* popName = elementName->getCamelCaseName();
   nsIContentHandle* elt;
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
-    elt = createAndInsertFosterParentedElement(kNameSpaceID_SVG, popName, attributes);
+    elt = createAndInsertFosterParentedElement(
+      kNameSpaceID_SVG,
+      popName,
+      attributes,
+      svgCreator(elementName->getSvgCreator()));
   } else {
-    elt = createElement(kNameSpaceID_SVG, popName, attributes, current->node);
+    elt = createElement(kNameSpaceID_SVG,
+                        popName,
+                        attributes,
+                        current->node,
+                        svgCreator(elementName->getSvgCreator()));
     appendElement(elt, current->node);
   }
   elementPushed(kNameSpaceID_SVG, popName, elt);
   elementPopped(kNameSpaceID_SVG, popName, elt);
 }
 
 void 
 nsHtml5TreeBuilder::appendVoidElementToCurrentMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
   nsIAtom* popName = elementName->getName();
   nsIContentHandle* elt;
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
-    elt = createAndInsertFosterParentedElement(kNameSpaceID_MathML, popName, attributes);
+    elt = createAndInsertFosterParentedElement(
+      kNameSpaceID_MathML, popName, attributes, htmlCreator(nullptr));
   } else {
-    elt = createElement(kNameSpaceID_MathML, popName, attributes, current->node);
+    elt = createElement(kNameSpaceID_MathML,
+                        popName,
+                        attributes,
+                        current->node,
+                        htmlCreator(nullptr));
     appendElement(elt, current->node);
   }
   elementPushed(kNameSpaceID_MathML, popName, elt);
   elementPopped(kNameSpaceID_MathML, popName, elt);
 }
 
-void 
-nsHtml5TreeBuilder::appendVoidElementToCurrent(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form)
+void
+nsHtml5TreeBuilder::appendVoidInputToCurrent(nsHtml5HtmlAttributes* attributes,
+                                             nsIContentHandle* form)
 {
   nsIContentHandle* currentNode = stack[currentPtr]->node;
-  nsIContentHandle* elt = createElement(kNameSpaceID_XHTML, name, attributes, !form || fragment || isTemplateContents() ? nullptr : form, currentNode);
+  nsIContentHandle* elt =
+    createElement(kNameSpaceID_XHTML,
+                  nsGkAtoms::input,
+                  attributes,
+                  !form || fragment || isTemplateContents() ? nullptr : form,
+                  currentNode,
+                  htmlCreator(NS_NewHTMLInputElement));
   appendElement(elt, currentNode);
-  elementPushed(kNameSpaceID_XHTML, name, elt);
-  elementPopped(kNameSpaceID_XHTML, name, elt);
+  elementPushed(kNameSpaceID_XHTML, nsGkAtoms::input, elt);
+  elementPopped(kNameSpaceID_XHTML, nsGkAtoms::input, elt);
 }
 
 void 
 nsHtml5TreeBuilder::appendVoidFormToCurrent(nsHtml5HtmlAttributes* attributes)
 {
   nsIContentHandle* currentNode = stack[currentPtr]->node;
-  nsIContentHandle* elt =
-    createElement(kNameSpaceID_XHTML, nsGkAtoms::form, attributes, currentNode);
+  nsIContentHandle* elt = createElement(kNameSpaceID_XHTML,
+                                        nsGkAtoms::form,
+                                        attributes,
+                                        currentNode,
+                                        htmlCreator(NS_NewHTMLFormElement));
   formPointer = elt;
   appendElement(elt, currentNode);
   elementPushed(kNameSpaceID_XHTML, nsGkAtoms::form, elt);
   elementPopped(kNameSpaceID_XHTML, nsGkAtoms::form, elt);
 }
 
 void 
 nsHtml5TreeBuilder::requestSuspension()
@@ -4481,34 +4611,36 @@ nsHtml5TreeBuilder::newSnapshot()
     nsHtml5StackNode* node = listOfActiveFormattingElements[i];
     if (node) {
       nsHtml5StackNode* newNode = new nsHtml5StackNode(-1);
       newNode->setValues(node->getFlags(),
                          node->ns,
                          node->name,
                          node->node,
                          node->popName,
-                         node->attributes->cloneAttributes(nullptr));
+                         node->attributes->cloneAttributes(nullptr),
+                         node->getHtmlCreator());
       listCopy[i] = newNode;
     } else {
       listCopy[i] = nullptr;
     }
   }
   jArray<nsHtml5StackNode*,int32_t> stackCopy = jArray<nsHtml5StackNode*,int32_t>::newJArray(currentPtr + 1);
   for (int32_t i = 0; i < stackCopy.length; i++) {
     nsHtml5StackNode* node = stack[i];
     int32_t listIndex = findInListOfActiveFormattingElements(node);
     if (listIndex == -1) {
       nsHtml5StackNode* newNode = new nsHtml5StackNode(-1);
       newNode->setValues(node->getFlags(),
                          node->ns,
                          node->name,
                          node->node,
                          node->popName,
-                         nullptr);
+                         nullptr,
+                         node->getHtmlCreator());
       stackCopy[i] = newNode;
     } else {
       stackCopy[i] = listCopy[listIndex];
       stackCopy[i]->retain();
     }
   }
   jArray<int32_t,int32_t> templateModeStackCopy = jArray<int32_t,int32_t>::newJArray(templateModePtr + 1);
   nsHtml5ArrayCopy::arraycopy(templateModeStack, templateModeStackCopy, templateModeStackCopy.length);
@@ -4583,33 +4715,35 @@ nsHtml5TreeBuilder::loadState(nsAHtml5Tr
     nsHtml5StackNode* node = listCopy[i];
     if (node) {
       nsHtml5StackNode* newNode = createStackNode(
         node->getFlags(),
         node->ns,
         nsHtml5Portability::newLocalFromLocal(node->name, interner),
         node->node,
         nsHtml5Portability::newLocalFromLocal(node->popName, interner),
-        node->attributes->cloneAttributes(nullptr));
+        node->attributes->cloneAttributes(nullptr),
+        node->getHtmlCreator());
       listOfActiveFormattingElements[i] = newNode;
     } else {
       listOfActiveFormattingElements[i] = nullptr;
     }
   }
   for (int32_t i = 0; i < stackLen; i++) {
     nsHtml5StackNode* node = stackCopy[i];
     int32_t listIndex = findInArray(node, listCopy);
     if (listIndex == -1) {
       nsHtml5StackNode* newNode = createStackNode(
         node->getFlags(),
         node->ns,
         nsHtml5Portability::newLocalFromLocal(node->name, interner),
         node->node,
         nsHtml5Portability::newLocalFromLocal(node->popName, interner),
-        nullptr);
+        nullptr,
+        node->getHtmlCreator());
       stack[i] = newNode;
     } else {
       stack[i] = listOfActiveFormattingElements[listIndex];
       stack[i]->retain();
     }
   }
   nsHtml5ArrayCopy::arraycopy(templateModeStackCopy, templateModeStack, templateModeStackLen);
   formPointer = snapshot->getFormPointer();
--- a/parser/html/nsHtml5TreeBuilder.h
+++ b/parser/html/nsHtml5TreeBuilder.h
@@ -310,16 +310,32 @@ class nsHtml5TreeBuilder : public nsAHtm
     nsIContentHandle* headPointer;
     nsIContentHandle* deepTreeSurrogateParent;
   protected:
     autoJArray<char16_t,int32_t> charBuffer;
     int32_t charBufferLen;
   private:
     bool quirks;
     bool isSrcdocDocument;
+    inline nsHtml5ContentCreatorFunction htmlCreator(
+      mozilla::dom::HTMLContentCreatorFunction htmlCreator)
+    {
+      nsHtml5ContentCreatorFunction creator;
+      creator.html = htmlCreator;
+      return creator;
+    }
+
+    inline nsHtml5ContentCreatorFunction svgCreator(
+      mozilla::dom::SVGContentCreatorFunction svgCreator)
+    {
+      nsHtml5ContentCreatorFunction creator;
+      creator.svg = svgCreator;
+      return creator;
+    }
+
   public:
     void startTokenization(nsHtml5Tokenizer* self);
     void doctype(nsIAtom* name,
                  nsHtml5String publicIdentifier,
                  nsHtml5String systemIdentifier,
                  bool forceQuirks);
     void comment(char16_t* buf, int32_t start, int32_t length);
     void characters(const char16_t* buf, int32_t start, int32_t length);
@@ -401,40 +417,51 @@ class nsHtml5TreeBuilder : public nsAHtm
     bool addAttributesToBody(nsHtml5HtmlAttributes* attributes);
     void addAttributesToHtml(nsHtml5HtmlAttributes* attributes);
     void pushHeadPointerOntoStack();
     void reconstructTheActiveFormattingElements();
   public:
     void notifyUnusedStackNode(int32_t idxInStackNodes);
   private:
     nsHtml5StackNode* getUnusedStackNode();
-    nsHtml5StackNode* createStackNode(int32_t flags,
-                                      int32_t ns,
-                                      nsIAtom* name,
-                                      nsIContentHandle* node,
-                                      nsIAtom* popName,
-                                      nsHtml5HtmlAttributes* attributes);
+    nsHtml5StackNode* createStackNode(
+      int32_t flags,
+      int32_t ns,
+      nsIAtom* name,
+      nsIContentHandle* node,
+      nsIAtom* popName,
+      nsHtml5HtmlAttributes* attributes,
+      mozilla::dom::HTMLContentCreatorFunction htmlCreator);
     nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
                                       nsIContentHandle* node);
     nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
                                       nsIContentHandle* node,
                                       nsHtml5HtmlAttributes* attributes);
     nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
                                       nsIContentHandle* node,
                                       nsIAtom* popName);
     nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
                                       nsIAtom* popName,
                                       nsIContentHandle* node);
     nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
                                       nsIContentHandle* node,
                                       nsIAtom* popName,
                                       bool markAsIntegrationPoint);
     void insertIntoFosterParent(nsIContentHandle* child);
-    nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes);
-    nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
+    nsIContentHandle* createAndInsertFosterParentedElement(
+      int32_t ns,
+      nsIAtom* name,
+      nsHtml5HtmlAttributes* attributes,
+      nsHtml5ContentCreatorFunction creator);
+    nsIContentHandle* createAndInsertFosterParentedElement(
+      int32_t ns,
+      nsIAtom* name,
+      nsHtml5HtmlAttributes* attributes,
+      nsIContentHandle* form,
+      nsHtml5ContentCreatorFunction creator);
     bool isInStack(nsHtml5StackNode* node);
     void popTemplateMode();
     void pop();
     void silentPop();
     void popOnEof();
     void appendHtmlElementToDocumentAndPush(nsHtml5HtmlAttributes* attributes);
     void appendHtmlElementToDocumentAndPush();
     void appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes* attributes);
@@ -443,34 +470,53 @@ class nsHtml5TreeBuilder : public nsAHtm
     void appendToCurrentNodeAndPushFormElementMayFoster(nsHtml5HtmlAttributes* attributes);
     void appendToCurrentNodeAndPushFormattingElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
     void appendToCurrentNodeAndPushElement(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
     void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
     void appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
     bool annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes);
     void appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
     void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
-    void appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
+    void appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName,
+                                             nsHtml5HtmlAttributes* attributes,
+                                             nsIContentHandle* form);
     void appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
     void appendVoidElementToCurrentMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
     void appendVoidElementToCurrentMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
-    void appendVoidElementToCurrent(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
+    void appendVoidInputToCurrent(nsHtml5HtmlAttributes* attributes,
+                                  nsIContentHandle* form);
     void appendVoidFormToCurrent(nsHtml5HtmlAttributes* attributes);
   protected:
     void accumulateCharacters(const char16_t* buf, int32_t start, int32_t length);
     void requestSuspension();
-    nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* intendedParent);
-    nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* intendedParent);
+    nsIContentHandle* createElement(int32_t ns,
+                                    nsIAtom* name,
+                                    nsHtml5HtmlAttributes* attributes,
+                                    nsIContentHandle* intendedParent,
+                                    nsHtml5ContentCreatorFunction creator);
+    nsIContentHandle* createElement(int32_t ns,
+                                    nsIAtom* name,
+                                    nsHtml5HtmlAttributes* attributes,
+                                    nsIContentHandle* form,
+                                    nsIContentHandle* intendedParent,
+                                    nsHtml5ContentCreatorFunction creator);
     nsIContentHandle* createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* attributes);
     void detachFromParent(nsIContentHandle* element);
     bool hasChildren(nsIContentHandle* element);
     void appendElement(nsIContentHandle* child, nsIContentHandle* newParent);
     void appendChildrenToNewParent(nsIContentHandle* oldParent, nsIContentHandle* newParent);
     void insertFosterParentedChild(nsIContentHandle* child, nsIContentHandle* table, nsIContentHandle* stackParent);
-    nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* table, nsIContentHandle* stackParent);
+    nsIContentHandle* createAndInsertFosterParentedElement(
+      int32_t ns,
+      nsIAtom* name,
+      nsHtml5HtmlAttributes* attributes,
+      nsIContentHandle* form,
+      nsIContentHandle* table,
+      nsIContentHandle* stackParent,
+      nsHtml5ContentCreatorFunction creator);
     ;void insertFosterParentedCharacters(char16_t* buf, int32_t start, int32_t length, nsIContentHandle* table, nsIContentHandle* stackParent);
     void appendCharacters(nsIContentHandle* parent, char16_t* buf, int32_t start, int32_t length);
     void appendComment(nsIContentHandle* parent, char16_t* buf, int32_t start, int32_t length);
     void appendCommentToDocument(char16_t* buf, int32_t start, int32_t length);
     void addAttributesToElement(nsIContentHandle* element, nsHtml5HtmlAttributes* attributes);
     void markMalformedIfScript(nsIContentHandle* elt);
     void start(bool fragmentMode);
     void end();
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -63,19 +63,21 @@ nsHtml5TreeBuilder::nsHtml5TreeBuilder(n
 nsHtml5TreeBuilder::~nsHtml5TreeBuilder()
 {
   MOZ_COUNT_DTOR(nsHtml5TreeBuilder);
   NS_ASSERTION(!mActive, "nsHtml5TreeBuilder deleted without ever calling end() on it!");
   mOpQueue.Clear();
 }
 
 nsIContentHandle*
-nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
+nsHtml5TreeBuilder::createElement(int32_t aNamespace,
+                                  nsIAtom* aName,
                                   nsHtml5HtmlAttributes* aAttributes,
-                                  nsIContentHandle* aIntendedParent)
+                                  nsIContentHandle* aIntendedParent,
+                                  nsHtml5ContentCreatorFunction aCreator)
 {
   NS_PRECONDITION(aAttributes, "Got null attributes.");
   NS_PRECONDITION(aName, "Got null name.");
   NS_PRECONDITION(aNamespace == kNameSpaceID_XHTML || 
                   aNamespace == kNameSpaceID_SVG || 
                   aNamespace == kNameSpaceID_MathML,
                   "Bogus namespace.");
 
@@ -86,39 +88,55 @@ nsHtml5TreeBuilder::createElement(int32_
       static_cast<nsIContent*>(aIntendedParent) : nullptr;
 
     // intendedParent == nullptr is a special case where the
     // intended parent is the document.
     nsNodeInfoManager* nodeInfoManager = intendedParent ?
        intendedParent->OwnerDoc()->NodeInfoManager() :
        mBuilder->GetNodeInfoManager();
 
-    nsIContent* elem =
-      nsHtml5TreeOperation::CreateElement(aNamespace,
-                                          name,
-                                          aAttributes,
-                                          mozilla::dom::FROM_PARSER_FRAGMENT,
-                                          nodeInfoManager,
-                                          mBuilder);
+    nsIContent* elem;
+    if (aNamespace == kNameSpaceID_XHTML) {
+      elem = nsHtml5TreeOperation::CreateHTMLElement(
+        name,
+        aAttributes,
+        mozilla::dom::FROM_PARSER_FRAGMENT,
+        nodeInfoManager,
+        mBuilder,
+        aCreator.html);
+    } else if (aNamespace == kNameSpaceID_SVG) {
+      elem = nsHtml5TreeOperation::CreateSVGElement(
+        name,
+        aAttributes,
+        mozilla::dom::FROM_PARSER_FRAGMENT,
+        nodeInfoManager,
+        mBuilder,
+        aCreator.svg);
+    } else {
+      MOZ_ASSERT(aNamespace == kNameSpaceID_MathML);
+      elem = nsHtml5TreeOperation::CreateMathMLElement(
+        name, aAttributes, nodeInfoManager, mBuilder);
+    }
     if (MOZ_UNLIKELY(aAttributes != tokenizer->GetAttributes() &&
                      aAttributes != nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES)) {
       delete aAttributes;
     }
     return elem;
   }
 
   nsIContentHandle* content = AllocateContentHandle();
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(aNamespace,
                aName,
                aAttributes,
                content,
                aIntendedParent,
-               !!mSpeculativeLoadStage);
+               !!mSpeculativeLoadStage,
+               aCreator);
   // mSpeculativeLoadStage is non-null only in the off-the-main-thread
   // tree builder, which handles the network stream
 
   // Start wall of code for speculative loading and line numbers
 
   if (mSpeculativeLoadStage) {
     switch (aNamespace) {
       case kNameSpaceID_XHTML:
@@ -340,91 +358,99 @@ nsHtml5TreeBuilder::createElement(int32_
   }
 
   // End wall of code for speculative loading
   
   return content;
 }
 
 nsIContentHandle*
-nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
+nsHtml5TreeBuilder::createElement(int32_t aNamespace,
+                                  nsIAtom* aName,
                                   nsHtml5HtmlAttributes* aAttributes,
                                   nsIContentHandle* aFormElement,
-                                  nsIContentHandle* aIntendedParent)
+                                  nsIContentHandle* aIntendedParent,
+                                  nsHtml5ContentCreatorFunction aCreator)
 {
-  nsIContentHandle* content = createElement(aNamespace, aName, aAttributes,
-                                            aIntendedParent);
+  nsIContentHandle* content =
+    createElement(aNamespace, aName, aAttributes, aIntendedParent, aCreator);
   if (aFormElement) {
     if (mBuilder) {
       nsHtml5TreeOperation::SetFormElement(static_cast<nsIContent*>(content),
         static_cast<nsIContent*>(aFormElement));
     } else {
       nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
       NS_ASSERTION(treeOp, "Tree op allocation failed.");
       treeOp->Init(eTreeOpSetFormElement, content, aFormElement);
     }
   }
   return content;
 }
 
 nsIContentHandle*
 nsHtml5TreeBuilder::createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* aAttributes)
 {
-  nsIContentHandle* content =
-    createElement(kNameSpaceID_XHTML, nsGkAtoms::html, aAttributes, nullptr);
+  nsHtml5ContentCreatorFunction creator;
+  // <html> uses NS_NewHTMLSharedElement creator
+  creator.html = NS_NewHTMLSharedElement;
+  nsIContentHandle* content = createElement(
+    kNameSpaceID_XHTML, nsGkAtoms::html, aAttributes, nullptr, creator);
   if (mBuilder) {
     nsresult rv = nsHtml5TreeOperation::AppendToDocument(static_cast<nsIContent*>(content),
                                                          mBuilder);
     if (NS_FAILED(rv)) {
       MarkAsBrokenAndRequestSuspension(rv);
     }
   } else {
     nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
     NS_ASSERTION(treeOp, "Tree op allocation failed.");
     treeOp->Init(eTreeOpAppendToDocument, content);
   }
   return content;
 }
 
 nsIContentHandle*
-nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t aNamespace, nsIAtom* aName,
-                                                         nsHtml5HtmlAttributes* aAttributes,
-                                                         nsIContentHandle* aFormElement,
-                                                         nsIContentHandle* aTable,
-                                                         nsIContentHandle* aStackParent)
+nsHtml5TreeBuilder::createAndInsertFosterParentedElement(
+  int32_t aNamespace,
+  nsIAtom* aName,
+  nsHtml5HtmlAttributes* aAttributes,
+  nsIContentHandle* aFormElement,
+  nsIContentHandle* aTable,
+  nsIContentHandle* aStackParent,
+  nsHtml5ContentCreatorFunction aCreator)
 {
   NS_PRECONDITION(aTable, "Null table");
   NS_PRECONDITION(aStackParent, "Null stack parent");
 
   if (mBuilder) {
     // Get the foster parent to use as the intended parent when creating
     // the child element.
     nsIContent* fosterParent = nsHtml5TreeOperation::GetFosterParent(
       static_cast<nsIContent*>(aTable),
       static_cast<nsIContent*>(aStackParent));
 
-    nsIContentHandle* child = createElement(aNamespace, aName, aAttributes,
-      aFormElement, fosterParent);
+    nsIContentHandle* child = createElement(
+      aNamespace, aName, aAttributes, aFormElement, fosterParent, aCreator);
 
     insertFosterParentedChild(child, aTable, aStackParent);
 
     return child;
   }
 
   // Tree op to get the foster parent that we use as the intended parent
   // when creating the child element.
   nsHtml5TreeOperation* fosterParentTreeOp = mOpQueue.AppendElement();
   NS_ASSERTION(fosterParentTreeOp, "Tree op allocation failed.");
   nsIContentHandle* fosterParentHandle = AllocateContentHandle();
   fosterParentTreeOp->Init(eTreeOpGetFosterParent, aTable,
                            aStackParent, fosterParentHandle);
 
   // Create the element with the correct intended parent.
-  nsIContentHandle* child = createElement(aNamespace, aName, aAttributes,
-    aFormElement, fosterParentHandle);
+  nsIContentHandle* child = createElement(
+    aNamespace, aName, aAttributes, aFormElement, fosterParentHandle, aCreator);
 
   // Insert the child into the foster parent.
   insertFosterParentedChild(child, aTable, aStackParent);
 
   return child;
 }
 
 void
--- a/parser/html/nsHtml5TreeOperation.cpp
+++ b/parser/html/nsHtml5TreeOperation.cpp
@@ -83,18 +83,21 @@ nsHtml5TreeOperation::nsHtml5TreeOperati
 nsHtml5TreeOperation::~nsHtml5TreeOperation()
 {
   MOZ_COUNT_DTOR(nsHtml5TreeOperation);
   NS_ASSERTION(mOpCode != eTreeOpUninitialized, "Uninitialized tree op.");
   switch(mOpCode) {
     case eTreeOpAddAttributes:
       delete mTwo.attributes;
       break;
-    case eTreeOpCreateElementNetwork:
-    case eTreeOpCreateElementNotNetwork:
+    case eTreeOpCreateHTMLElementNetwork:
+    case eTreeOpCreateHTMLElementNotNetwork:
+    case eTreeOpCreateSVGElementNetwork:
+    case eTreeOpCreateSVGElementNotNetwork:
+    case eTreeOpCreateMathMLElement:
       delete mThree.attributes;
       break;
     case eTreeOpAppendDoctypeToDocument:
       delete mTwo.stringPair;
       break;
     case eTreeOpFosterParentText:
     case eTreeOpAppendText:
     case eTreeOpAppendComment:
@@ -323,42 +326,49 @@ nsHtml5TreeOperation::AddAttributes(nsIC
       node->SetAttr(
         nsuri, localName, aAttributes->getPrefixNoBoundsCheck(i), value, true);
       // XXX what to do with nsresult?
     }
   }
   return NS_OK;
 }
 
-
 nsIContent*
-nsHtml5TreeOperation::CreateElement(int32_t aNs,
-                                    nsIAtom* aName,
-                                    nsHtml5HtmlAttributes* aAttributes,
-                                    mozilla::dom::FromParser aFromParser,
-                                    nsNodeInfoManager* aNodeInfoManager,
-                                    nsHtml5DocumentBuilder* aBuilder)
+nsHtml5TreeOperation::CreateHTMLElement(
+  nsIAtom* aName,
+  nsHtml5HtmlAttributes* aAttributes,
+  mozilla::dom::FromParser aFromParser,
+  nsNodeInfoManager* aNodeInfoManager,
+  nsHtml5DocumentBuilder* aBuilder,
+  mozilla::dom::HTMLContentCreatorFunction aCreator)
 {
-  bool isKeygen = (aName == nsGkAtoms::keygen && aNs == kNameSpaceID_XHTML);
+  bool isKeygen = (aName == nsGkAtoms::keygen);
   if (MOZ_UNLIKELY(isKeygen)) {
     aName = nsGkAtoms::select;
+    aCreator = NS_NewHTMLSelectElement;
   }
 
-  nsCOMPtr<dom::Element> newElement;
-  RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->
-    GetNodeInfo(aName, nullptr, aNs, nsIDOMNode::ELEMENT_NODE);
+  RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
+    aName, nullptr, kNameSpaceID_XHTML, nsIDOMNode::ELEMENT_NODE);
   NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
-  NS_NewElement(getter_AddRefs(newElement),
-                nodeInfo.forget(),
-                aFromParser);
-  NS_ASSERTION(newElement, "Element creation created null pointer.");
+
+  nsCOMPtr<dom::Element> newElement = aCreator(nodeInfo.forget(), aFromParser);
+
+  MOZ_ASSERT(newElement, "Element creation created null pointer.");
 
   dom::Element* newContent = newElement;
   aBuilder->HoldElement(newElement.forget());
 
+  if (aCreator == NS_NewCustomElement) {
+    // Not inlining the call below into NS_NewCustomElement itself, because
+    // in the near future, the code here will need to break out of an update
+    // batch here.
+    nsContentUtils::SetupCustomElement(newContent);
+  }
+
   if (MOZ_UNLIKELY(aName == nsGkAtoms::style || aName == nsGkAtoms::link)) {
     nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(newContent));
     if (ssle) {
       ssle->InitStyleLinkElement(false);
       ssle->SetEnableUpdates(false);
     }
   } else if (MOZ_UNLIKELY(isKeygen)) {
     // Adapted from CNavDTD
@@ -381,28 +391,25 @@ nsHtml5TreeOperation::CreateElement(int3
                         nullptr,
                         theAttribute,
                         false);
 
     RefPtr<dom::NodeInfo> optionNodeInfo = aNodeInfoManager->GetNodeInfo(
       nsGkAtoms::option, nullptr, kNameSpaceID_XHTML, nsIDOMNode::ELEMENT_NODE);
 
     for (uint32_t i = 0; i < theContent.Length(); ++i) {
-      nsCOMPtr<dom::Element> optionElt;
       RefPtr<dom::NodeInfo> ni = optionNodeInfo;
-      NS_NewElement(getter_AddRefs(optionElt),
-                    ni.forget(),
-                    aFromParser);
+      nsCOMPtr<dom::Element> optionElt =
+        NS_NewHTMLOptionElement(ni.forget(), aFromParser);
       RefPtr<nsTextNode> optionText = new nsTextNode(aNodeInfoManager);
       (void) optionText->SetText(theContent[i], false);
       optionElt->AppendChildTo(optionText, false);
       newContent->AppendChildTo(optionElt, false);
-      // XXXsmaug Shouldn't we call this after adding all the child nodes.
-      newContent->DoneAddingChildren(false);
     }
+    newContent->DoneAddingChildren(false);
   }
 
   if (!aAttributes) {
     return newContent;
   }
 
   int32_t len = aAttributes->getLength();
   for (int32_t i = 0; i < len; i++) {
@@ -410,18 +417,17 @@ nsHtml5TreeOperation::CreateElement(int3
     // local name is never null
     nsCOMPtr<nsIAtom> localName =
       Reget(aAttributes->getLocalNameNoBoundsCheck(i));
     nsCOMPtr<nsIAtom> prefix = aAttributes->getPrefixNoBoundsCheck(i);
     int32_t nsuri = aAttributes->getURINoBoundsCheck(i);
 
     nsString value; // Not Auto, because using it to hold nsStringBuffer*
     aAttributes->getValueNoBoundsCheck(i).ToString(value);
-    if (aNs == kNameSpaceID_XHTML && nsGkAtoms::a == aName &&
-        nsGkAtoms::name == localName) {
+    if (nsGkAtoms::a == aName && nsGkAtoms::name == localName) {
       // This is an HTML5-incompliant Geckoism.
       // Remove when fixing bug 582361
       NS_ConvertUTF16toUTF8 cname(value);
       NS_ConvertUTF8toUTF16 uv(nsUnescape(cname.BeginWriting()));
       newContent->SetAttr(nsuri,
                           localName,
                           prefix,
                           uv,
@@ -437,16 +443,127 @@ nsHtml5TreeOperation::CreateElement(int3
       if (kNameSpaceID_None == nsuri && !prefix && nsGkAtoms::is == localName) {
         nsContentUtils::SetupCustomElement(newContent, &value);
       }
     }
   }
   return newContent;
 }
 
+nsIContent*
+nsHtml5TreeOperation::CreateSVGElement(
+  nsIAtom* aName,
+  nsHtml5HtmlAttributes* aAttributes,
+  mozilla::dom::FromParser aFromParser,
+  nsNodeInfoManager* aNodeInfoManager,
+  nsHtml5DocumentBuilder* aBuilder,
+  mozilla::dom::SVGContentCreatorFunction aCreator)
+{
+  nsCOMPtr<nsIContent> newElement;
+  if (MOZ_LIKELY(aNodeInfoManager->SVGEnabled())) {
+    RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
+      aName, nullptr, kNameSpaceID_SVG, nsIDOMNode::ELEMENT_NODE);
+    MOZ_ASSERT(nodeInfo, "Got null nodeinfo.");
+
+    mozilla::DebugOnly<nsresult> rv =
+      aCreator(getter_AddRefs(newElement), nodeInfo.forget(), aFromParser);
+    MOZ_ASSERT(NS_SUCCEEDED(rv) && newElement);
+  } else {
+    RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
+      aName, nullptr, kNameSpaceID_disabled_SVG, nsIDOMNode::ELEMENT_NODE);
+    MOZ_ASSERT(nodeInfo, "Got null nodeinfo.");
+
+    // The mismatch between NS_NewXMLElement and SVGContentCreatorFunction
+    // argument types is annoying.
+    nsCOMPtr<dom::Element> xmlElement;
+    mozilla::DebugOnly<nsresult> rv =
+      NS_NewXMLElement(getter_AddRefs(xmlElement), nodeInfo.forget());
+    MOZ_ASSERT(NS_SUCCEEDED(rv) && xmlElement);
+    newElement = xmlElement;
+  }
+
+  dom::Element* newContent = newElement->AsElement();
+  aBuilder->HoldElement(newElement.forget());
+
+  if (MOZ_UNLIKELY(aName == nsGkAtoms::style)) {
+    nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(newContent));
+    if (ssle) {
+      ssle->InitStyleLinkElement(false);
+      ssle->SetEnableUpdates(false);
+    }
+  }
+
+  if (!aAttributes) {
+    return newContent;
+  }
+
+  int32_t len = aAttributes->getLength();
+  for (int32_t i = 0; i < len; i++) {
+    // prefix doesn't need regetting. it is always null or a static atom
+    // local name is never null
+    nsCOMPtr<nsIAtom> localName =
+      Reget(aAttributes->getLocalNameNoBoundsCheck(i));
+    nsCOMPtr<nsIAtom> prefix = aAttributes->getPrefixNoBoundsCheck(i);
+    int32_t nsuri = aAttributes->getURINoBoundsCheck(i);
+
+    nsString value; // Not Auto, because using it to hold nsStringBuffer*
+    aAttributes->getValueNoBoundsCheck(i).ToString(value);
+    newContent->SetAttr(nsuri, localName, prefix, value, false);
+  }
+  return newContent;
+}
+
+nsIContent*
+nsHtml5TreeOperation::CreateMathMLElement(nsIAtom* aName,
+                                          nsHtml5HtmlAttributes* aAttributes,
+                                          nsNodeInfoManager* aNodeInfoManager,
+                                          nsHtml5DocumentBuilder* aBuilder)
+{
+  nsCOMPtr<dom::Element> newElement;
+  if (MOZ_LIKELY(aNodeInfoManager->MathMLEnabled())) {
+    RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
+      aName, nullptr, kNameSpaceID_MathML, nsIDOMNode::ELEMENT_NODE);
+    NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
+
+    mozilla::DebugOnly<nsresult> rv =
+      NS_NewMathMLElement(getter_AddRefs(newElement), nodeInfo.forget());
+    MOZ_ASSERT(NS_SUCCEEDED(rv) && newElement);
+  } else {
+    RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
+      aName, nullptr, kNameSpaceID_disabled_MathML, nsIDOMNode::ELEMENT_NODE);
+    NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
+
+    mozilla::DebugOnly<nsresult> rv =
+      NS_NewXMLElement(getter_AddRefs(newElement), nodeInfo.forget());
+    MOZ_ASSERT(NS_SUCCEEDED(rv) && newElement);
+  }
+
+  dom::Element* newContent = newElement;
+  aBuilder->HoldElement(newElement.forget());
+
+  if (!aAttributes) {
+    return newContent;
+  }
+
+  int32_t len = aAttributes->getLength();
+  for (int32_t i = 0; i < len; i++) {
+    // prefix doesn't need regetting. it is always null or a static atom
+    // local name is never null
+    nsCOMPtr<nsIAtom> localName =
+      Reget(aAttributes->getLocalNameNoBoundsCheck(i));
+    nsCOMPtr<nsIAtom> prefix = aAttributes->getPrefixNoBoundsCheck(i);
+    int32_t nsuri = aAttributes->getURINoBoundsCheck(i);
+
+    nsString value; // Not Auto, because using it to hold nsStringBuffer*
+    aAttributes->getValueNoBoundsCheck(i).ToString(value);
+    newContent->SetAttr(nsuri, localName, prefix, value, false);
+  }
+  return newContent;
+}
+
 void
 nsHtml5TreeOperation::SetFormElement(nsIContent* aNode, nsIContent* aParent)
 {
   nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(aNode));
   nsCOMPtr<nsIDOMHTMLImageElement> domImageElement = do_QueryInterface(aNode);
   // NS_ASSERTION(formControl, "Form-associated element did not implement nsIFormControl.");
   // TODO: uncomment the above line when <keygen> (bug 101019) is supported by Gecko
   nsCOMPtr<nsIDOMHTMLFormElement> formElement(do_QueryInterface(aParent));
@@ -653,38 +770,78 @@ nsHtml5TreeOperation::Perform(nsHtml5Tre
       nsIContent* node = *(mOne.node);
       nsHtml5HtmlAttributes* attributes = mTwo.attributes;
       return AddAttributes(node, attributes, aBuilder);
     }
     case eTreeOpDocumentMode: {
       aBuilder->SetDocumentMode(mOne.mode);
       return NS_OK;
     }
-    case eTreeOpCreateElementNetwork:
-    case eTreeOpCreateElementNotNetwork: {
+    case eTreeOpCreateHTMLElementNetwork:
+    case eTreeOpCreateHTMLElementNotNetwork: {
       nsIContent** target = mOne.node;
-      int32_t ns = mFour.integer;
+      mozilla::dom::HTMLContentCreatorFunction creator = mFour.htmlCreator;
+      nsCOMPtr<nsIAtom> name = Reget(mTwo.atom);
+      nsHtml5HtmlAttributes* attributes = mThree.attributes;
+      nsIContent* intendedParent = mFive.node ? *(mFive.node) : nullptr;
+
+      // intendedParent == nullptr is a special case where the
+      // intended parent is the document.
+      nsNodeInfoManager* nodeInfoManager =
+        intendedParent ? intendedParent->OwnerDoc()->NodeInfoManager()
+                       : aBuilder->GetNodeInfoManager();
+
+      *target = CreateHTMLElement(name,
+                                  attributes,
+                                  mOpCode == eTreeOpCreateHTMLElementNetwork
+                                    ? dom::FROM_PARSER_NETWORK
+                                    : dom::FROM_PARSER_DOCUMENT_WRITE,
+                                  nodeInfoManager,
+                                  aBuilder,
+                                  creator);
+      return NS_OK;
+    }
+    case eTreeOpCreateSVGElementNetwork:
+    case eTreeOpCreateSVGElementNotNetwork: {
+      nsIContent** target = mOne.node;
+      mozilla::dom::SVGContentCreatorFunction creator = mFour.svgCreator;
+      nsCOMPtr<nsIAtom> name = Reget(mTwo.atom);
+      nsHtml5HtmlAttributes* attributes = mThree.attributes;
+      nsIContent* intendedParent = mFive.node ? *(mFive.node) : nullptr;
+
+      // intendedParent == nullptr is a special case where the
+      // intended parent is the document.
+      nsNodeInfoManager* nodeInfoManager =
+        intendedParent ? intendedParent->OwnerDoc()->NodeInfoManager()
+                       : aBuilder->GetNodeInfoManager();
+
+      *target = CreateSVGElement(name,
+                                 attributes,
+                                 mOpCode == eTreeOpCreateSVGElementNetwork
+                                   ? dom::FROM_PARSER_NETWORK
+                                   : dom::FROM_PARSER_DOCUMENT_WRITE,
+                                 nodeInfoManager,
+                                 aBuilder,
+                                 creator);
+      return NS_OK;
+    }
+    case eTreeOpCreateMathMLElement: {
+      nsIContent** target = mOne.node;
       nsCOMPtr<nsIAtom> name = Reget(mTwo.atom);
       nsHtml5HtmlAttributes* attributes = mThree.attributes;
       nsIContent* intendedParent = mFive.node ? *(mFive.node) : nullptr;
 
       // intendedParent == nullptr is a special case where the
       // intended parent is the document.
       nsNodeInfoManager* nodeInfoManager = intendedParent ?
          intendedParent->OwnerDoc()->NodeInfoManager() :
          aBuilder->GetNodeInfoManager();
 
-      *target = CreateElement(ns,
-                              name,
-                              attributes,
-                              mOpCode == eTreeOpCreateElementNetwork ?
-                                dom::FROM_PARSER_NETWORK :
-                                dom::FROM_PARSER_DOCUMENT_WRITE,
-                              nodeInfoManager,
-                              aBuilder);
+      *target =
+        CreateMathMLElement(name, attributes, nodeInfoManager, aBuilder);
       return NS_OK;
     }
     case eTreeOpSetFormElement: {
       nsIContent* node = *(mOne.node);
       nsIContent* parent = *(mTwo.node);
       SetFormElement(node, parent);
       return NS_OK;
     }
--- a/parser/html/nsHtml5TreeOperation.h
+++ b/parser/html/nsHtml5TreeOperation.h
@@ -12,28 +12,32 @@
 
 class nsIContent;
 class nsHtml5TreeOpExecutor;
 class nsHtml5DocumentBuilder;
 namespace mozilla {
 class Encoding;
 }
 
-enum eHtml5TreeOperation {
+enum eHtml5TreeOperation
+{
   eTreeOpUninitialized,
   // main HTML5 ops
   eTreeOpAppend,
   eTreeOpDetach,
   eTreeOpAppendChildrenToNewParent,
   eTreeOpFosterParent,
   eTreeOpAppendToDocument,
   eTreeOpAddAttributes,
   eTreeOpDocumentMode,
-  eTreeOpCreateElementNetwork,
-  eTreeOpCreateElementNotNetwork,
+  eTreeOpCreateHTMLElementNetwork,
+  eTreeOpCreateHTMLElementNotNetwork,
+  eTreeOpCreateSVGElementNetwork,
+  eTreeOpCreateSVGElementNotNetwork,
+  eTreeOpCreateMathMLElement,
   eTreeOpSetFormElement,
   eTreeOpAppendText,
   eTreeOpFosterParentText,
   eTreeOpAppendComment,
   eTreeOpAppendCommentToDocument,
   eTreeOpAppendDoctypeToDocument,
   eTreeOpGetDocumentFragmentForTemplate,
   eTreeOpGetFosterParent,
@@ -142,22 +146,36 @@ class nsHtml5TreeOperation final {
                                  nsIContent* aParent,
                                  nsIContent* aTable,
                                  nsHtml5DocumentBuilder* aBuilder);
 
     static nsresult AddAttributes(nsIContent* aNode,
                                   nsHtml5HtmlAttributes* aAttributes,
                                   nsHtml5DocumentBuilder* aBuilder);
 
-    static nsIContent* CreateElement(int32_t aNs,
-                                     nsIAtom* aName,
-                                     nsHtml5HtmlAttributes* aAttributes,
-                                     mozilla::dom::FromParser aFromParser,
-                                     nsNodeInfoManager* aNodeInfoManager,
-                                     nsHtml5DocumentBuilder* aBuilder);
+    static nsIContent* CreateHTMLElement(
+      nsIAtom* aName,
+      nsHtml5HtmlAttributes* aAttributes,
+      mozilla::dom::FromParser aFromParser,
+      nsNodeInfoManager* aNodeInfoManager,
+      nsHtml5DocumentBuilder* aBuilder,
+      mozilla::dom::HTMLContentCreatorFunction aCreator);
+
+    static nsIContent* CreateSVGElement(
+      nsIAtom* aName,
+      nsHtml5HtmlAttributes* aAttributes,
+      mozilla::dom::FromParser aFromParser,
+      nsNodeInfoManager* aNodeInfoManager,
+      nsHtml5DocumentBuilder* aBuilder,
+      mozilla::dom::SVGContentCreatorFunction aCreator);
+
+    static nsIContent* CreateMathMLElement(nsIAtom* aName,
+                                           nsHtml5HtmlAttributes* aAttributes,
+                                           nsNodeInfoManager* aNodeInfoManager,
+                                           nsHtml5DocumentBuilder* aBuilder);
 
     static void SetFormElement(nsIContent* aNode, nsIContent* aParent);
 
     static nsresult AppendIsindexPrompt(nsIContent* parent,
                                         nsHtml5DocumentBuilder* aBuilder);
 
     static nsresult FosterParentText(nsIContent* aStackParent,
                                      char16_t* aBuffer,
@@ -304,32 +322,41 @@ class nsHtml5TreeOperation final {
     {
       NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
         "Op code must be uninitialized when initializing.");
       NS_PRECONDITION(aNode, "Initialized tree op with null node.");
       mOpCode = eTreeOpRunScript;
       mOne.node = static_cast<nsIContent**>(aNode);
       mTwo.state = nullptr;
     }
-    
-    inline void Init(int32_t aNamespace, 
-                     nsIAtom* aName, 
+
+    inline void Init(int32_t aNamespace,
+                     nsIAtom* aName,
                      nsHtml5HtmlAttributes* aAttributes,
                      nsIContentHandle* aTarget,
                      nsIContentHandle* aIntendedParent,
-                     bool aFromNetwork)
+                     bool aFromNetwork,
+                     nsHtml5ContentCreatorFunction aCreator)
     {
       NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
         "Op code must be uninitialized when initializing.");
       NS_PRECONDITION(aName, "Initialized tree op with null name.");
       NS_PRECONDITION(aTarget, "Initialized tree op with null target node.");
-      mOpCode = aFromNetwork ?
-                eTreeOpCreateElementNetwork :
-                eTreeOpCreateElementNotNetwork;
-      mFour.integer = aNamespace;
+      if (aNamespace == kNameSpaceID_XHTML) {
+        mOpCode = aFromNetwork ? eTreeOpCreateHTMLElementNetwork
+                               : eTreeOpCreateHTMLElementNotNetwork;
+        mFour.htmlCreator = aCreator.html;
+      } else if (aNamespace == kNameSpaceID_SVG) {
+        mOpCode = aFromNetwork ? eTreeOpCreateSVGElementNetwork
+                               : eTreeOpCreateSVGElementNotNetwork;
+        mFour.svgCreator = aCreator.svg;
+      } else {
+        MOZ_ASSERT(aNamespace == kNameSpaceID_MathML);
+        mOpCode = eTreeOpCreateMathMLElement;
+      }
       mFive.node = static_cast<nsIContent**>(aIntendedParent);
       mOne.node = static_cast<nsIContent**>(aTarget);
       mTwo.atom = aName;
       if (aAttributes == nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
         mThree.attributes = nullptr;
       } else {
         mThree.attributes = aAttributes;
       }
@@ -529,12 +556,14 @@ class nsHtml5TreeOperation final {
       nsHtml5DocumentMode             mode;
       char16_t*                       unicharPtr;
       char*                           charPtr;
       nsHtml5TreeOperationStringPair* stringPair;
       nsAHtml5TreeBuilderState*       state;
       int32_t                         integer;
       nsresult                        result;
       const Encoding*                 encoding;
+      mozilla::dom::HTMLContentCreatorFunction htmlCreator;
+      mozilla::dom::SVGContentCreatorFunction svgCreator;
     } mOne, mTwo, mThree, mFour, mFive;
 };
 
 #endif // nsHtml5TreeOperation_h
--- a/parser/html/nsHtml5UTF16Buffer.cpp
+++ b/parser/html/nsHtml5UTF16Buffer.cpp
@@ -36,16 +36,17 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 #include "nsHtml5AttributeName.h"
 #include "nsHtml5ElementName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5MetaScanner.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5StateSnapshot.h"
--- a/parser/html/nsHtml5UTF16Buffer.h
+++ b/parser/html/nsHtml5UTF16Buffer.h
@@ -37,16 +37,17 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsGkAtoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5Portability.h"
+#include "nsHtml5ContentCreatorFunction.h"
 
 class nsHtml5StreamParser;
 
 class nsHtml5AttributeName;
 class nsHtml5ElementName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
--- a/parser/htmlparser/nsHTMLTagList.h
+++ b/parser/htmlparser/nsHTMLTagList.h
@@ -7,16 +7,22 @@
 
 /******
 
   This file contains the list of all HTML tags.
   See nsHTMLTags.h for access to the enum values for tags.
 
   It is designed to be used as input to various places that will define the
   HTML_TAG macro in useful ways through the magic of C preprocessing.
+  Additionally, it is consumed by the self-regeneration code in
+  ElementName.java from which nsHtml5ElementName.cpp/h is translated.
+  See parser/html/java/README.txt.
+
+  If you edit this list, you need to re-run ElementName.java
+  self-regeneration and the HTML parser Java to C++ translation.
 
   All entries must be enclosed in the macro HTML_TAG which will have cruel
   and unusual things done to it.
 
   It is recommended (but not strictly necessary) to keep all entries
   in alphabetical order.
 
   The first argument to HTML_TAG is the tag name. The second argument is the