Bug 612529 part 2 - Rework how scopingness and specialness is handled in stack nodes; refresh the set of scoping elements to spec. rs=jonas, a=blocking2.0-betaN.
authorHenri Sivonen <hsivonen@iki.fi>
Thu, 09 Dec 2010 11:27:58 +0200
changeset 58957 16d8c6a5b5021cb056b5a8d0c720d04fb6e81ec5
parent 58956 941694c1b9c92b58d2b89f1b53e0c0d2d5dc7ac4
child 58958 944cd0847692e5fbacabb1936e40780f7684dfe8
push id17479
push userhsivonen@iki.fi
push dateThu, 09 Dec 2010 09:30:00 +0000
treeherdermozilla-central@b26cf63f51a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonas, blocking2
bugs612529
milestone2.0b8pre
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 612529 part 2 - Rework how scopingness and specialness is handled in stack nodes; refresh the set of scoping elements to spec. rs=jonas, a=blocking2.0-betaN.
parser/html/javasrc/AttributeName.java
parser/html/javasrc/ElementName.java
parser/html/javasrc/Portability.java
parser/html/javasrc/StackNode.java
parser/html/javasrc/StateSnapshot.java
parser/html/javasrc/Tokenizer.java
parser/html/javasrc/TreeBuilder.java
parser/html/nsHtml5AttributeName.cpp
parser/html/nsHtml5ElementName.cpp
parser/html/nsHtml5ElementName.h
parser/html/nsHtml5Portability.cpp
parser/html/nsHtml5Portability.h
parser/html/nsHtml5StackNode.cpp
parser/html/nsHtml5StackNode.h
parser/html/nsHtml5StateSnapshot.cpp
parser/html/nsHtml5Tokenizer.cpp
parser/html/nsHtml5TreeBuilder.cpp
parser/html/nsHtml5TreeBuilder.h
parser/htmlparser/tests/mochitest/html5_tree_construction_exceptions.js
parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests10.dat
parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests19.dat
--- a/parser/html/javasrc/AttributeName.java
+++ b/parser/html/javasrc/AttributeName.java
@@ -483,20 +483,16 @@ public final class AttributeName
         // No-op in Java.
         // Implement as |delete this;| in subclass.
     }
 
     /**
      * The C++ destructor.
      */
     @SuppressWarnings("unused") private void destructor() {
-        Portability.releaseLocal(local[0]); // this must be a no-op for static
-        // locals
-        // for non-static cases the other array slots contain the same pointer
-        // as weak references.
         Portability.deleteArray(local);
     }
 
     /**
      * Clones the attribute using an interner. Returns <code>this</code> in Java
      * and for non-dynamic instances in C++.
      * 
      * @param interner
--- a/parser/html/javasrc/ElementName.java
+++ b/parser/html/javasrc/ElementName.java
@@ -30,32 +30,66 @@ import nu.validator.htmlparser.annotatio
 import nu.validator.htmlparser.annotation.Virtual;
 import nu.validator.htmlparser.common.Interner;
 
 public final class ElementName
 // 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.
+     */
     public static final int CUSTOM = (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.
+     */
     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.
+     */
     public static final int SCOPING = (1 << 27);
 
+    /**
+     * The element is scoping as SVG.
+     */
+    public static final int SCOPING_AS_SVG = (1 << 26);
+
+    /**
+     * The element is scoping as MathML.
+     */
+    public static final int SCOPING_AS_MATHML = (1 << 25);
+
+    /**
+     * The element is an HTML integration point.
+     */
+    public static final int HTML_INTEGRATION_POINT = (1 << 24);
+
     public static final ElementName NULL_ELEMENT_NAME = new ElementName(null);
 
     public final @Local String name;
 
     public final @Local String camelCaseName;
-    
+
     /**
      * The lowest 7 bits are the dispatch group. The high bits are flags.
      */
     public final int flags;
 
     @Inline public int getFlags() {
         return flags;
     }
@@ -124,18 +158,16 @@ public final class ElementName
     
     @Virtual void release() {
         // No-op in Java. 
         // Implement as delete this in subclass.
         // Be sure to release the local name
     }
     
     @SuppressWarnings("unused") private void destructor() {
-        Portability.releaseLocal(name); // this must be a no-op for static locals
-        // for non-static cases the camel case contains the same pointer as a weak reference.
     }
 
     @Virtual public ElementName cloneElementName(Interner interner) {
         return this;
     }
     
     // START CODE ONLY USED FOR GENERATING CODE uncomment and run to regenerate
 
@@ -153,16 +185,22 @@ public final class ElementName
 //            buf.append(" | SPECIAL");
 //        }
 //        if ((flags & FOSTER_PARENTING) != 0) {
 //            buf.append(" | FOSTER_PARENTING");
 //        }
 //        if ((flags & SCOPING) != 0) {
 //            buf.append(" | SCOPING");
 //        }        
+//        if ((flags & SCOPING_AS_MATHML) != 0) {
+//            buf.append(" | SCOPING_AS_MATHML");
+//        }
+//        if ((flags & SCOPING_AS_SVG) != 0) {
+//            buf.append(" | SCOPING_AS_SVG");
+//        }
 //        return buf.toString();
 //    }
 //    
 //    private String constName() {
 //        char[] buf = new char[name.length()];
 //        for (int i = 0; i < name.length(); i++) {
 //            char c = name.charAt(i);
 //            if (c == '-') {
@@ -387,27 +425,27 @@ public final class ElementName
     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 GT = new ElementName("gt", "gt", TreeBuilder.OTHER);
     public static final ElementName HR = new ElementName("hr", "hr", TreeBuilder.HR | SPECIAL);
     public static final ElementName IN = new ElementName("in", "in", TreeBuilder.OTHER);
     public static final ElementName LI = new ElementName("li", "li", TreeBuilder.LI | SPECIAL);
     public static final ElementName LN = new ElementName("ln", "ln", TreeBuilder.OTHER);
     public static final ElementName LT = new ElementName("lt", "lt", TreeBuilder.OTHER);
-    public static final ElementName MI = new ElementName("mi", "mi", TreeBuilder.MI_MO_MN_MS_MTEXT);
-    public static final ElementName MN = new ElementName("mn", "mn", TreeBuilder.MI_MO_MN_MS_MTEXT);
-    public static final ElementName MO = new ElementName("mo", "mo", TreeBuilder.MI_MO_MN_MS_MTEXT);
-    public static final ElementName MS = new ElementName("ms", "ms", TreeBuilder.MI_MO_MN_MS_MTEXT);
+    public static final ElementName MI = new ElementName("mi", "mi", TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
+    public static final ElementName MN = new ElementName("mn", "mn", TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
+    public static final ElementName MO = new ElementName("mo", "mo", TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
+    public static final ElementName MS = new ElementName("ms", "ms", TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
     public static final ElementName OL = new ElementName("ol", "ol", TreeBuilder.UL_OR_OL_OR_DL | SPECIAL);
     public static final ElementName OR = new ElementName("or", "or", TreeBuilder.OTHER);
     public static final ElementName PI = new ElementName("pi", "pi", TreeBuilder.OTHER);
     public static final ElementName RP = new ElementName("rp", "rp", TreeBuilder.RT_OR_RP);
     public static final ElementName RT = new ElementName("rt", "rt", TreeBuilder.RT_OR_RP);
-    public static final ElementName TD = new ElementName("td", "td", TreeBuilder.TD_OR_TH | SCOPING);
-    public static final ElementName TH = new ElementName("th", "th", TreeBuilder.TD_OR_TH | SCOPING);
+    public static final ElementName TD = new ElementName("td", "td", TreeBuilder.TD_OR_TH | SPECIAL | SCOPING);
+    public static final ElementName TH = new ElementName("th", "th", TreeBuilder.TD_OR_TH | SPECIAL | SCOPING);
     public static final ElementName TR = new ElementName("tr", "tr", TreeBuilder.TR | SPECIAL | FOSTER_PARENTING);
     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 UL = new ElementName("ul", "ul", TreeBuilder.UL_OR_OL_OR_DL | SPECIAL);
     public static final ElementName AND = new ElementName("and", "and", TreeBuilder.OTHER);
     public static final ElementName ARG = new ElementName("arg", "arg", TreeBuilder.OTHER);
     public static final ElementName ABS = new ElementName("abs", "abs", TreeBuilder.OTHER);
     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);
@@ -460,24 +498,24 @@ public final class ElementName
     public static final ElementName BODY = new ElementName("body", "body", TreeBuilder.BODY | SPECIAL);
     public static final ElementName CARD = new ElementName("card", "card", TreeBuilder.OTHER);
     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 CITE = new ElementName("cite", "cite", TreeBuilder.OTHER);
     public static final ElementName CSCH = new ElementName("csch", "csch", TreeBuilder.OTHER);
     public static final ElementName COSH = new ElementName("cosh", "cosh", TreeBuilder.OTHER);
     public static final ElementName COTH = new ElementName("coth", "coth", TreeBuilder.OTHER);
     public static final ElementName CURL = new ElementName("curl", "curl", TreeBuilder.OTHER);
-    public static final ElementName DESC = new ElementName("desc", "desc", TreeBuilder.FOREIGNOBJECT_OR_DESC);
+    public static final ElementName DESC = new ElementName("desc", "desc", TreeBuilder.FOREIGNOBJECT_OR_DESC | SCOPING_AS_SVG);
     public static final ElementName DIFF = new ElementName("diff", "diff", TreeBuilder.OTHER);
     public static final ElementName DEFS = new ElementName("defs", "defs", TreeBuilder.OTHER);
     public static final ElementName FORM = new ElementName("form", "form", TreeBuilder.FORM | SPECIAL);
     public static final ElementName FONT = new ElementName("font", "font", TreeBuilder.FONT);
     public static final ElementName GRAD = new ElementName("grad", "grad", TreeBuilder.OTHER);
     public static final ElementName HEAD = new ElementName("head", "head", TreeBuilder.HEAD | SPECIAL);
-    public static final ElementName HTML = new ElementName("html", "html", TreeBuilder.HTML | SCOPING);
+    public static final ElementName HTML = new ElementName("html", "html", TreeBuilder.HTML | SPECIAL | SCOPING);
     public static final ElementName LINE = new ElementName("line", "line", TreeBuilder.OTHER);
     public static final ElementName LINK = new ElementName("link", "link", TreeBuilder.LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
     public static final ElementName LIST = new ElementName("list", "list", TreeBuilder.OTHER);
     public static final ElementName META = new ElementName("meta", "meta", TreeBuilder.META | SPECIAL);
     public static final ElementName MSUB = new ElementName("msub", "msub", TreeBuilder.OTHER);
     public static final ElementName MODE = new ElementName("mode", "mode", TreeBuilder.OTHER);
     public static final ElementName MATH = new ElementName("math", "math", TreeBuilder.MATH);
     public static final ElementName MARK = new ElementName("mark", "mark", TreeBuilder.OTHER);
@@ -525,40 +563,40 @@ public final class ElementName
     public static final ElementName LIMIT = new ElementName("limit", "limit", TreeBuilder.OTHER);
     public static final ElementName MFRAC = new ElementName("mfrac", "mfrac", TreeBuilder.OTHER);
     public static final ElementName MPATH = new ElementName("mpath", "mpath", TreeBuilder.OTHER);
     public static final ElementName METER = new ElementName("meter", "meter", TreeBuilder.OTHER);
     public static final ElementName MOVER = new ElementName("mover", "mover", TreeBuilder.OTHER);
     public static final ElementName MINUS = new ElementName("minus", "minus", TreeBuilder.OTHER);
     public static final ElementName MROOT = new ElementName("mroot", "mroot", TreeBuilder.OTHER);
     public static final ElementName MSQRT = new ElementName("msqrt", "msqrt", TreeBuilder.OTHER);
-    public static final ElementName MTEXT = new ElementName("mtext", "mtext", TreeBuilder.MI_MO_MN_MS_MTEXT);
+    public static final ElementName MTEXT = new ElementName("mtext", "mtext", TreeBuilder.MI_MO_MN_MS_MTEXT | SCOPING_AS_MATHML);
     public static final ElementName NOTIN = new ElementName("notin", "notin", TreeBuilder.OTHER);
     public static final ElementName PIECE = new ElementName("piece", "piece", TreeBuilder.OTHER);
     public static final ElementName PARAM = new ElementName("param", "param", TreeBuilder.PARAM_OR_SOURCE | SPECIAL);
     public static final ElementName POWER = new ElementName("power", "power", TreeBuilder.OTHER);
     public static final ElementName REALS = new ElementName("reals", "reals", TreeBuilder.OTHER);
     public static final ElementName STYLE = new ElementName("style", "style", TreeBuilder.STYLE | 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 THEAD = new ElementName("thead", "thead", TreeBuilder.TBODY_OR_THEAD_OR_TFOOT | SPECIAL | FOSTER_PARENTING);
-    public static final ElementName TABLE = new ElementName("table", "table", TreeBuilder.TABLE | FOSTER_PARENTING | SCOPING);
-    public static final ElementName TITLE = new ElementName("title", "title", TreeBuilder.TITLE | 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 TSPAN = new ElementName("tspan", "tspan", TreeBuilder.OTHER);
     public static final ElementName TIMES = new ElementName("times", "times", TreeBuilder.OTHER);
     public static final ElementName TFOOT = new ElementName("tfoot", "tfoot", TreeBuilder.TBODY_OR_THEAD_OR_TFOOT | SPECIAL | FOSTER_PARENTING);
     public static final ElementName TBODY = new ElementName("tbody", "tbody", TreeBuilder.TBODY_OR_THEAD_OR_TFOOT | SPECIAL | FOSTER_PARENTING);
     public static final ElementName UNION = new ElementName("union", "union", TreeBuilder.OTHER);
     public static final ElementName VKERN = new ElementName("vkern", "vkern", TreeBuilder.OTHER);
     public static final ElementName VIDEO = new ElementName("video", "video", TreeBuilder.OTHER);
     public static final ElementName ARCSEC = new ElementName("arcsec", "arcsec", TreeBuilder.OTHER);
     public static final ElementName ARCCSC = new ElementName("arccsc", "arccsc", TreeBuilder.OTHER);
     public static final ElementName ARCTAN = new ElementName("arctan", "arctan", TreeBuilder.OTHER);
     public static final ElementName ARCSIN = new ElementName("arcsin", "arcsin", TreeBuilder.OTHER);
     public static final ElementName ARCCOS = new ElementName("arccos", "arccos", TreeBuilder.OTHER);
-    public static final ElementName APPLET = new ElementName("applet", "applet", TreeBuilder.MARQUEE_OR_APPLET | SCOPING);
+    public static final ElementName APPLET = new ElementName("applet", "applet", TreeBuilder.MARQUEE_OR_APPLET | SPECIAL | SCOPING);
     public static final ElementName ARCCOT = new ElementName("arccot", "arccot", TreeBuilder.OTHER);
     public static final ElementName APPROX = new ElementName("approx", "approx", TreeBuilder.OTHER);
     public static final ElementName BUTTON = new ElementName("button", "button", TreeBuilder.BUTTON | SPECIAL);
     public static final ElementName CIRCLE = new ElementName("circle", "circle", TreeBuilder.OTHER);
     public static final ElementName CENTER = new ElementName("center", "center", TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
     public static final ElementName CURSOR = new ElementName("cursor", "cursor", TreeBuilder.OTHER);
     public static final ElementName CANVAS = new ElementName("canvas", "canvas", TreeBuilder.OTHER);
     public static final ElementName DIVIDE = new ElementName("divide", "divide", TreeBuilder.OTHER);
@@ -582,17 +620,17 @@ public final class ElementName
     public static final ElementName MGLYPH = new ElementName("mglyph", "mglyph", TreeBuilder.MGLYPH_OR_MALIGNMARK);
     public static final ElementName MEDIAN = new ElementName("median", "median", TreeBuilder.OTHER);
     public static final ElementName MUNDER = new ElementName("munder", "munder", TreeBuilder.OTHER);
     public static final ElementName MARKER = new ElementName("marker", "marker", TreeBuilder.OTHER);
     public static final ElementName MERROR = new ElementName("merror", "merror", TreeBuilder.OTHER);
     public static final ElementName MOMENT = new ElementName("moment", "moment", TreeBuilder.OTHER);
     public static final ElementName MATRIX = new ElementName("matrix", "matrix", TreeBuilder.OTHER);
     public static final ElementName OPTION = new ElementName("option", "option", TreeBuilder.OPTION);
-    public static final ElementName OBJECT = new ElementName("object", "object", TreeBuilder.OBJECT | SCOPING);
+    public static final ElementName OBJECT = new ElementName("object", "object", TreeBuilder.OBJECT | SPECIAL | SCOPING);
     public static final ElementName OUTPUT = new ElementName("output", "output", TreeBuilder.OUTPUT_OR_LABEL);
     public static final ElementName PRIMES = new ElementName("primes", "primes", TreeBuilder.OTHER);
     public static final ElementName SOURCE = new ElementName("source", "source", TreeBuilder.PARAM_OR_SOURCE);
     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 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 SWITCH = new ElementName("switch", "switch", TreeBuilder.OTHER);
     public static final ElementName SYMBOL = new ElementName("symbol", "symbol", TreeBuilder.OTHER);
     public static final ElementName SELECT = new ElementName("select", "select", TreeBuilder.SELECT | SPECIAL);
@@ -610,17 +648,17 @@ public final class ElementName
     public static final ElementName ARCCOTH = new ElementName("arccoth", "arccoth", TreeBuilder.OTHER);
     public static final ElementName ACRONYM = new ElementName("acronym", "acronym", TreeBuilder.OTHER);
     public static final ElementName ADDRESS = new ElementName("address", "address", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
     public static final ElementName BGSOUND = new ElementName("bgsound", "bgsound", TreeBuilder.LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
     public static final ElementName COMMAND = new ElementName("command", "command", TreeBuilder.COMMAND | SPECIAL);
     public static final ElementName COMPOSE = new ElementName("compose", "compose", TreeBuilder.OTHER);
     public static final ElementName CEILING = new ElementName("ceiling", "ceiling", TreeBuilder.OTHER);
     public static final ElementName CSYMBOL = new ElementName("csymbol", "csymbol", TreeBuilder.OTHER);
-    public static final ElementName CAPTION = new ElementName("caption", "caption", TreeBuilder.CAPTION | SCOPING);
+    public static final ElementName CAPTION = new ElementName("caption", "caption", TreeBuilder.CAPTION | SPECIAL | SCOPING);
     public static final ElementName DISCARD = new ElementName("discard", "discard", TreeBuilder.OTHER);
     public static final ElementName DECLARE = new ElementName("declare", "declare", TreeBuilder.OTHER);
     public static final ElementName DETAILS = new ElementName("details", "details", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
     public static final ElementName ELLIPSE = new ElementName("ellipse", "ellipse", TreeBuilder.OTHER);
     public static final ElementName FEFUNCA = new ElementName("fefunca", "feFuncA", TreeBuilder.OTHER);
     public static final ElementName FEFUNCB = new ElementName("fefuncb", "feFuncB", TreeBuilder.OTHER);
     public static final ElementName FEBLEND = new ElementName("feblend", "feBlend", TreeBuilder.OTHER);
     public static final ElementName FEFLOOD = new ElementName("feflood", "feFlood", TreeBuilder.OTHER);
@@ -631,17 +669,17 @@ public final class ElementName
     public static final ElementName HANDLER = new ElementName("handler", "handler", TreeBuilder.OTHER);
     public static final ElementName INVERSE = new ElementName("inverse", "inverse", TreeBuilder.OTHER);
     public static final ElementName IMPLIES = new ElementName("implies", "implies", TreeBuilder.OTHER);
     public static final ElementName ISINDEX = new ElementName("isindex", "isindex", TreeBuilder.ISINDEX | SPECIAL);
     public static final ElementName LOGBASE = new ElementName("logbase", "logbase", TreeBuilder.OTHER);
     public static final ElementName LISTING = new ElementName("listing", "listing", TreeBuilder.PRE_OR_LISTING | SPECIAL);
     public static final ElementName MFENCED = new ElementName("mfenced", "mfenced", TreeBuilder.OTHER);
     public static final ElementName MPADDED = new ElementName("mpadded", "mpadded", TreeBuilder.OTHER);
-    public static final ElementName MARQUEE = new ElementName("marquee", "marquee", TreeBuilder.MARQUEE_OR_APPLET | SCOPING);
+    public static final ElementName MARQUEE = new ElementName("marquee", "marquee", TreeBuilder.MARQUEE_OR_APPLET | SPECIAL | SCOPING);
     public static final ElementName MACTION = new ElementName("maction", "maction", TreeBuilder.OTHER);
     public static final ElementName MSUBSUP = new ElementName("msubsup", "msubsup", TreeBuilder.OTHER);
     public static final ElementName NOEMBED = new ElementName("noembed", "noembed", TreeBuilder.NOEMBED | SPECIAL);
     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 PRODUCT = new ElementName("product", "product", TreeBuilder.OTHER);
     public static final ElementName SETDIFF = new ElementName("setdiff", "setdiff", TreeBuilder.OTHER);
     public static final ElementName SECTION = new ElementName("section", "section", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
@@ -725,23 +763,23 @@ public final class ElementName
     public static final ElementName FETURBULENCE = new ElementName("feturbulence", "feTurbulence", TreeBuilder.OTHER);
     public static final ElementName FEPOINTLIGHT = new ElementName("fepointlight", "fePointLight", TreeBuilder.OTHER);
     public static final ElementName FEMORPHOLOGY = new ElementName("femorphology", "feMorphology", TreeBuilder.OTHER);
     public static final ElementName OUTERPRODUCT = new ElementName("outerproduct", "outerproduct", TreeBuilder.OTHER);
     public static final ElementName ANIMATEMOTION = new ElementName("animatemotion", "animateMotion", TreeBuilder.OTHER);
     public static final ElementName COLOR_PROFILE = new ElementName("color-profile", "color-profile", TreeBuilder.OTHER);
     public static final ElementName FONT_FACE_SRC = new ElementName("font-face-src", "font-face-src", TreeBuilder.OTHER);
     public static final ElementName FONT_FACE_URI = new ElementName("font-face-uri", "font-face-uri", TreeBuilder.OTHER);
-    public static final ElementName FOREIGNOBJECT = new ElementName("foreignobject", "foreignObject", TreeBuilder.FOREIGNOBJECT_OR_DESC);
+    public static final ElementName FOREIGNOBJECT = new ElementName("foreignobject", "foreignObject", TreeBuilder.FOREIGNOBJECT_OR_DESC | SCOPING_AS_SVG);
     public static final ElementName FECOLORMATRIX = new ElementName("fecolormatrix", "feColorMatrix", TreeBuilder.OTHER);
     public static final ElementName MISSING_GLYPH = new ElementName("missing-glyph", "missing-glyph", TreeBuilder.OTHER);
     public static final ElementName MMULTISCRIPTS = new ElementName("mmultiscripts", "mmultiscripts", TreeBuilder.OTHER);
     public static final ElementName SCALARPRODUCT = new ElementName("scalarproduct", "scalarproduct", TreeBuilder.OTHER);
     public static final ElementName VECTORPRODUCT = new ElementName("vectorproduct", "vectorproduct", TreeBuilder.OTHER);
-    public static final ElementName ANNOTATION_XML = new ElementName("annotation-xml", "annotation-xml", TreeBuilder.ANNOTATION_XML);
+    public static final ElementName ANNOTATION_XML = new ElementName("annotation-xml", "annotation-xml", TreeBuilder.ANNOTATION_XML | SCOPING_AS_MATHML);
     public static final ElementName DEFINITION_SRC = new ElementName("definition-src", "definition-src", TreeBuilder.OTHER);
     public static final ElementName FONT_FACE_NAME = new ElementName("font-face-name", "font-face-name", TreeBuilder.OTHER);
     public static final ElementName FEGAUSSIANBLUR = new ElementName("fegaussianblur", "feGaussianBlur", TreeBuilder.OTHER);
     public static final ElementName FEDISTANTLIGHT = new ElementName("fedistantlight", "feDistantLight", TreeBuilder.OTHER);
     public static final ElementName LINEARGRADIENT = new ElementName("lineargradient", "linearGradient", TreeBuilder.OTHER);
     public static final ElementName NATURALNUMBERS = new ElementName("naturalnumbers", "naturalnumbers", TreeBuilder.OTHER);
     public static final ElementName RADIALGRADIENT = new ElementName("radialgradient", "radialGradient", TreeBuilder.OTHER);
     public static final ElementName ANIMATETRANSFORM = new ElementName("animatetransform", "animateTransform", TreeBuilder.OTHER);
--- a/parser/html/javasrc/Portability.java
+++ b/parser/html/javasrc/Portability.java
@@ -69,41 +69,16 @@ public final class Portability {
     }
     
     // Deallocation methods
     
     public static void releaseString(String str) {
         // No-op in Java
     }
     
-    public static void retainLocal(@Local String local) {
-        // No-op in Java
-    }
-
-    /**
-     * This MUST be a no-op on locals that are known at compile time.
-     * @param local
-     */
-    public static void releaseLocal(@Local String local) {
-        // No-op in Java
-    }
-    
-    // [NOCPP[
-    // These are no longer used in Gecko. Need to decide what to do about these in the long term.    
-    
-    public static void retainElement(Object elt) {
-        // No-op in Java
-    }
-
-    public static void releaseElement(Object elt) {
-        // No-op in Java
-    }
-    
-    // ]NOCPP]
-    
     // Comparison methods
     
     public static boolean localEqualsBuffer(@Local String local, @NoLength char[] buf, int offset, int length) {
         if (local.length() != length) {
             return false;
         }
         for (int i = 0; i < length; i++) {
             if (local.charAt(i) != buf[offset + i]) {
--- a/parser/html/javasrc/StackNode.java
+++ b/parser/html/javasrc/StackNode.java
@@ -54,120 +54,151 @@ final class StackNode<T> {
     public boolean isScoping() {
         return (flags & ElementName.SCOPING) != 0;
     }
 
     public boolean isSpecial() {
         return (flags & ElementName.SPECIAL) != 0;
     }
 
-    public boolean isScopingOrSpecial() {
-        return (flags & (ElementName.SCOPING | ElementName.SPECIAL)) != 0;
-    }
-
     public boolean isFosterParenting() {
         return (flags & ElementName.FOSTER_PARENTING) != 0;
     }
 
     /**
-     * @param group
-     *            TODO
+     * Constructor for copying. This doesn't take another 
+     * <code>StackNode</code> because in C++ the caller is reponsible for
+     * reobtaining the local names from another interner.
+     * 
+     * @param flags
+     * @param ns
      * @param name
      * @param node
-     * @param scoping
-     * @param special
      * @param popName
-     *            TODO
+     * @param attributes
      */
-    StackNode(int flags, final @NsUri String ns, final @Local String name,
-            final T node, final @Local String popName, HtmlAttributes attributes) {
+    StackNode(int flags, @NsUri String ns, @Local String name,
+            T node, @Local String popName, HtmlAttributes attributes) {
         this.flags = flags;
         this.name = name;
         this.popName = popName;
         this.ns = ns;
         this.node = node;
         this.attributes = attributes;
         this.refcount = 1;
-        Portability.retainLocal(name);
-        Portability.retainLocal(popName);
-        Portability.retainElement(node);
-        // not retaining namespace for now
     }
 
     /**
+     * Short hand for well-known HTML elements.
+     * 
      * @param elementName
-     *            TODO
      * @param node
      */
-    StackNode(final @NsUri String ns, ElementName elementName, final T node) {
+    StackNode(ElementName elementName, T node) {
         this.flags = elementName.getFlags();
         this.name = elementName.name;
         this.popName = elementName.name;
-        this.ns = ns;
+        this.ns = "http://www.w3.org/1999/xhtml";
         this.node = node;
         this.attributes = null;
         this.refcount = 1;
-        Portability.retainLocal(name);
-        Portability.retainLocal(popName);
-        Portability.retainElement(node);
-        // not retaining namespace for now
+        assert !elementName.isCustom() : "Don't use this constructor for custom elements.";
     }
 
-    StackNode(final @NsUri String ns, ElementName elementName, final T node,
-            HtmlAttributes attributes) {
+    /**
+     * Constructor for HTML formatting elements.
+     * 
+     * @param elementName
+     * @param node
+     * @param attributes
+     */
+    StackNode(ElementName elementName, T node, HtmlAttributes attributes) {
         this.flags = elementName.getFlags();
         this.name = elementName.name;
         this.popName = elementName.name;
-        this.ns = ns;
+        this.ns = "http://www.w3.org/1999/xhtml";
         this.node = node;
         this.attributes = attributes;
         this.refcount = 1;
-        Portability.retainLocal(name);
-        Portability.retainLocal(popName);
-        Portability.retainElement(node);
-        // not retaining namespace for now
+        assert !elementName.isCustom() : "Don't use this constructor for custom elements.";
     }
 
-    StackNode(final @NsUri String ns, ElementName elementName, final T node,
-            @Local String popName) {
+    /**
+     * The common-case HTML constructor.
+     * 
+     * @param elementName
+     * @param node
+     * @param popName
+     */
+    StackNode(ElementName elementName, T node, @Local String popName) {
         this.flags = elementName.getFlags();
         this.name = elementName.name;
         this.popName = popName;
-        this.ns = ns;
+        this.ns = "http://www.w3.org/1999/xhtml";
+        this.node = node;
+        this.attributes = null;
+        this.refcount = 1;
+    }
+
+    /**
+     * Constructor for SVG elements. Note that the order of the arguments is
+     * what distinguishes this from the HTML constructor. This is ugly, but
+     * AFAICT the least disruptive way to make this work with Java's generics
+     * and without unnecessary branches. :-(
+     * 
+     * @param elementName
+     * @param popName
+     * @param node
+     */
+    StackNode(ElementName elementName, @Local String popName, T node) {
+        this.flags = prepareSvgFlags(elementName.getFlags());
+        this.name = elementName.name;
+        this.popName = popName;
+        this.ns = "http://www.w3.org/2000/svg";
         this.node = node;
         this.attributes = null;
         this.refcount = 1;
-        Portability.retainLocal(name);
-        Portability.retainLocal(popName);
-        Portability.retainElement(node);
-        // not retaining namespace for now
     }
 
-    StackNode(final @NsUri String ns, ElementName elementName, final T node,
-            @Local String popName, boolean scoping) {
-        this.flags = (scoping ? (elementName.getFlags() | ElementName.SCOPING)
-                : (elementName.getFlags() & ~ElementName.SCOPING))
-                & ~(ElementName.SPECIAL | ElementName.FOSTER_PARENTING);
+    /**
+     * Constructor for MathML.
+     * 
+     * @param elementName
+     * @param node
+     * @param popName
+     * @param markAsIntegrationPoint
+     */
+    StackNode(ElementName elementName, T node, @Local String popName,
+            boolean markAsIntegrationPoint) {
+        this.flags = prepareMathFlags(elementName.getFlags());
         this.name = elementName.name;
         this.popName = popName;
-        this.ns = ns;
+        this.ns = "http://www.w3.org/1998/Math/MathML";
         this.node = node;
         this.attributes = null;
         this.refcount = 1;
-        Portability.retainLocal(name);
-        Portability.retainLocal(popName);
-        Portability.retainElement(node);
-        // not retaining namespace for now
+    }
+    
+    private static int prepareSvgFlags(int flags) {
+        flags &= ~(ElementName.FOSTER_PARENTING | ElementName.SCOPING | ElementName.SPECIAL);
+        if ((flags & ElementName.SCOPING_AS_SVG) != 0) {
+            flags |= (ElementName.SCOPING | ElementName.SPECIAL | ElementName.HTML_INTEGRATION_POINT);
+        }
+        return flags;
     }
 
+    private static int prepareMathFlags(int flags) {
+        flags &= ~(ElementName.FOSTER_PARENTING | ElementName.SCOPING | ElementName.SPECIAL);
+        if ((flags & ElementName.SCOPING_AS_MATHML) != 0) {
+            flags |= (ElementName.SCOPING | ElementName.SPECIAL);
+        }
+        return flags;
+    }
+    
     @SuppressWarnings("unused") private void destructor() {
-        Portability.releaseLocal(name);
-        Portability.releaseLocal(popName);
-        Portability.releaseElement(node);
-        // not releasing namespace for now
         Portability.delete(attributes);
     }
 
     public void dropAttributes() {
         attributes = null;
     }
 
     // [NOCPP[
--- a/parser/html/javasrc/StateSnapshot.java
+++ b/parser/html/javasrc/StateSnapshot.java
@@ -185,11 +185,10 @@ public class StateSnapshot<T> implements
         for (int i = 0; i < stack.length; i++) {
             stack[i].release();
         }
         for (int i = 0; i < listOfActiveFormattingElements.length; i++) {
             if (listOfActiveFormattingElements[i] != null) {
                 listOfActiveFormattingElements[i].release();                
             }
         }
-        Portability.retainElement(formPointer);
     }
 }
--- a/parser/html/javasrc/Tokenizer.java
+++ b/parser/html/javasrc/Tokenizer.java
@@ -5722,17 +5722,16 @@ public class Tokenizer implements Locato
     
     protected int transition(int from, int to, boolean reconsume, int pos) throws SAXException {
         return to;
     }
 
     // ]NOCPP]
     
     private void initDoctypeFields() {
-        Portability.releaseLocal(doctypeName);
         doctypeName = "";
         if (systemIdentifier != null) {
             Portability.releaseString(systemIdentifier);
             systemIdentifier = null;
         }
         if (publicIdentifier != null) {
             Portability.releaseString(publicIdentifier);
             publicIdentifier = null;
@@ -6029,17 +6028,16 @@ public class Tokenizer implements Locato
                         emitComment(0, 0);
                     } else {
                         /* EOF Parse error. */
                         errEofInDoctype();
                         /*
                          * Create a new DOCTYPE token. Set its force-quirks flag
                          * to on.
                          */
-                        Portability.releaseLocal(doctypeName);
                         doctypeName = "";
                         if (systemIdentifier != null) {
                             Portability.releaseString(systemIdentifier);
                             systemIdentifier = null;
                         }
                         if (publicIdentifier != null) {
                             Portability.releaseString(publicIdentifier);
                             publicIdentifier = null;
@@ -6429,17 +6427,16 @@ public class Tokenizer implements Locato
 
     private void emitDoctypeToken(int pos) throws SAXException {
         cstart = pos + 1;
         tokenHandler.doctype(doctypeName, publicIdentifier, systemIdentifier,
                 forceQuirks);
         // It is OK and sufficient to release these here, since
         // there's no way out of the doctype states than through paths
         // that call this method.
-        Portability.releaseLocal(doctypeName);
         doctypeName = null;
         Portability.releaseString(publicIdentifier);
         publicIdentifier = null;
         Portability.releaseString(systemIdentifier);
         systemIdentifier = null;
     }
 
     @Inline protected char checkChar(@NoLength char[] buf, int pos)
@@ -6489,17 +6486,16 @@ public class Tokenizer implements Locato
         } else {
             tokenHandler.characters(val, 0, 1);
         }
     }
 
     public void end() throws SAXException {
         strBuf = null;
         longStrBuf = null;
-        Portability.releaseLocal(doctypeName);
         doctypeName = null;
         if (systemIdentifier != null) {
             Portability.releaseString(systemIdentifier);
             systemIdentifier = null;
         }
         if (publicIdentifier != null) {
             Portability.releaseString(publicIdentifier);
             publicIdentifier = null;
@@ -6637,17 +6633,16 @@ public class Tokenizer implements Locato
         candidate = other.candidate;
         strBufMark = other.strBufMark;
         prevValue = other.prevValue;
         value = other.value;
         seenDigits = other.seenDigits;
         endTag = other.endTag;
         shouldSuspend = false;
 
-        Portability.releaseLocal(doctypeName);
         if (other.doctypeName == null) {
             doctypeName = null;
         } else {
             doctypeName = Portability.newLocalFromLocal(other.doctypeName,
                     interner);
         }
 
         Portability.releaseString(systemIdentifier);
--- a/parser/html/javasrc/TreeBuilder.java
+++ b/parser/html/javasrc/TreeBuilder.java
@@ -504,41 +504,37 @@ public abstract class TreeBuilder<T> imp
     @SuppressWarnings("unchecked") public final void startTokenization(Tokenizer self) throws SAXException {
         tokenizer = self;
         stack = new StackNode[64];
         listOfActiveFormattingElements = new StackNode[64];
         needToDropLF = false;
         originalMode = INITIAL;
         currentPtr = -1;
         listPtr = -1;
-        Portability.releaseElement(formPointer);
         formPointer = null;
-        Portability.releaseElement(headPointer);
         headPointer = null;
-        Portability.releaseElement(deepTreeSurrogateParent);
         deepTreeSurrogateParent = null;
         // [NOCPP[
         html4 = false;
         idLocations.clear();
         wantingComments = wantsComments();
         // ]NOCPP]
         start(fragment);
         charBufferLen = 0;
         charBuffer = new char[1024];
         framesetOk = true;
         if (fragment) {
             T elt;
             if (contextNode != null) {
                 elt = contextNode;
-                Portability.retainElement(elt);
             } else {
                 elt = createHtmlElementSetAsRoot(tokenizer.emptyAttributes());
             }
             StackNode<T> node = new StackNode<T>(
-                    "http://www.w3.org/1999/xhtml", ElementName.HTML, elt);
+                    ElementName.HTML, elt);
             currentPtr++;
             stack[currentPtr] = node;
             resetTheInsertionMode();
             if ("title" == contextName || "textarea" == contextName) {
                 tokenizer.setStateAndEndTagExpectation(Tokenizer.RCDATA, contextName);
             } else if ("style" == contextName || "xmp" == contextName
                     || "iframe" == contextName || "noembed" == contextName
                     || "noframes" == contextName
@@ -547,21 +543,18 @@ public abstract class TreeBuilder<T> imp
             } else if ("plaintext" == contextName) {
                 tokenizer.setStateAndEndTagExpectation(Tokenizer.PLAINTEXT, contextName);
             } else if ("script" == contextName) {
                 tokenizer.setStateAndEndTagExpectation(Tokenizer.SCRIPT_DATA,
                         contextName);
             } else {
                 tokenizer.setStateAndEndTagExpectation(Tokenizer.DATA, contextName);
             }
-            Portability.releaseLocal(contextName);
             contextName = null;
-            Portability.releaseElement(contextNode);
             contextNode = null;
-            Portability.releaseElement(elt);
         } else {
             mode = INITIAL;
             inForeign = false;
         }
     }
 
     public final void doctype(@Local String name, String publicIdentifier,
             String systemIdentifier, boolean forceQuirks) throws SAXException {
@@ -1386,21 +1379,18 @@ public abstract class TreeBuilder<T> imp
         }
         /* Stop parsing. */
     }
 
     /**
      * @see nu.validator.htmlparser.common.TokenHandler#endTokenization()
      */
     public final void endTokenization() throws SAXException {
-        Portability.releaseElement(formPointer);
         formPointer = null;
-        Portability.releaseElement(headPointer);
         headPointer = null;
-        Portability.releaseElement(deepTreeSurrogateParent);
         deepTreeSurrogateParent = null;
         if (stack != null) {
             while (currentPtr > -1) {
                 stack[currentPtr].release();
                 currentPtr--;
             }
             stack = null;
         }
@@ -1500,58 +1490,57 @@ public abstract class TreeBuilder<T> imp
                                 }
                                 continue starttagloop;
                             }
                             // else fall thru
                         default:
                             if ("http://www.w3.org/2000/svg" == currNs) {
                                 attributes.adjustForSvg();
                                 if (selfClosing) {
-                                    appendVoidElementToCurrentMayFosterCamelCase(
-                                            currNs, elementName, attributes);
+                                    appendVoidElementToCurrentMayFosterSVG(
+                                            elementName, attributes);
                                     selfClosing = false;
                                 } else {
-                                    appendToCurrentNodeAndPushElementMayFosterCamelCase(
-                                            currNs, elementName, attributes);
+                                    appendToCurrentNodeAndPushElementMayFosterSVG(
+                                            elementName, attributes);
                                 }
                                 attributes = null; // CPP
                                 break starttagloop;
                             } else {
                                 attributes.adjustForMath();
                                 if (selfClosing) {
-                                    appendVoidElementToCurrentMayFoster(
-                                            currNs, elementName, attributes);
+                                    appendVoidElementToCurrentMayFosterMathML(
+                                            elementName, attributes);
                                     selfClosing = false;
                                 } else {
-                                    appendToCurrentNodeAndPushElementMayFosterNoScoping(
-                                            currNs, elementName, attributes);
+                                    appendToCurrentNodeAndPushElementMayFosterMathML(
+                                            elementName, attributes);
                                 }
                                 attributes = null; // CPP
                                 break starttagloop;
                             }
                     } // switch
                 } // foreignObject / annotation-xml
             }
             switch (mode) {
                 case IN_TABLE_BODY:
                     switch (group) {
                         case TR:
                             clearStackBackTo(findLastInTableScopeOrRootTbodyTheadTfoot());
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             mode = IN_ROW;
                             attributes = null; // CPP
                             break starttagloop;
                         case TD_OR_TH:
                             err("\u201C" + name
                                     + "\u201D start tag in table body.");
                             clearStackBackTo(findLastInTableScopeOrRootTbodyTheadTfoot());
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
                                     ElementName.TR,
                                     HtmlAttributes.EMPTY_ATTRIBUTES);
                             mode = IN_ROW;
                             continue;
                         case CAPTION:
                         case COL:
                         case COLGROUP:
                         case TBODY_OR_THEAD_OR_TFOOT:
@@ -1568,18 +1557,18 @@ public abstract class TreeBuilder<T> imp
                         default:
                             // fall through to IN_TABLE
                     }
                 case IN_ROW:
                     switch (group) {
                         case TD_OR_TH:
                             clearStackBackTo(findLastOrRoot(TreeBuilder.TR));
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             mode = IN_CELL;
                             insertMarker();
                             attributes = null; // CPP
                             break starttagloop;
                         case CAPTION:
                         case COL:
                         case COLGROUP:
                         case TBODY_OR_THEAD_OR_TFOOT:
@@ -1599,50 +1588,48 @@ public abstract class TreeBuilder<T> imp
                     }
                 case IN_TABLE:
                     intableloop: for (;;) {
                         switch (group) {
                             case CAPTION:
                                 clearStackBackTo(findLastOrRoot(TreeBuilder.TABLE));
                                 insertMarker();
                                 appendToCurrentNodeAndPushElement(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 mode = IN_CAPTION;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case COLGROUP:
                                 clearStackBackTo(findLastOrRoot(TreeBuilder.TABLE));
                                 appendToCurrentNodeAndPushElement(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 mode = IN_COLUMN_GROUP;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case COL:
                                 clearStackBackTo(findLastOrRoot(TreeBuilder.TABLE));
                                 appendToCurrentNodeAndPushElement(
-                                        "http://www.w3.org/1999/xhtml",
                                         ElementName.COLGROUP,
                                         HtmlAttributes.EMPTY_ATTRIBUTES);
                                 mode = IN_COLUMN_GROUP;
                                 continue starttagloop;
                             case TBODY_OR_THEAD_OR_TFOOT:
                                 clearStackBackTo(findLastOrRoot(TreeBuilder.TABLE));
                                 appendToCurrentNodeAndPushElement(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 mode = IN_TABLE_BODY;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case TR:
                             case TD_OR_TH:
                                 clearStackBackTo(findLastOrRoot(TreeBuilder.TABLE));
                                 appendToCurrentNodeAndPushElement(
-                                        "http://www.w3.org/1999/xhtml",
                                         ElementName.TBODY,
                                         HtmlAttributes.EMPTY_ATTRIBUTES);
                                 mode = IN_TABLE_BODY;
                                 continue starttagloop;
                             case TABLE:
                                 err("Start tag for \u201Ctable\u201D seen but the previous \u201Ctable\u201D is still open.");
                                 eltPos = findLastInTableScope(name);
                                 if (eltPos == TreeBuilder.NOT_FOUND_ON_STACK) {
@@ -1660,43 +1647,43 @@ public abstract class TreeBuilder<T> imp
                                 resetTheInsertionMode();
                                 continue starttagloop;
                             case SCRIPT:
                                 // XXX need to manage much more stuff
                                 // here if
                                 // supporting
                                 // document.write()
                                 appendToCurrentNodeAndPushElement(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 originalMode = mode;
                                 mode = TEXT;
                                 tokenizer.setStateAndEndTagExpectation(
                                         Tokenizer.SCRIPT_DATA, elementName);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case STYLE:
                                 appendToCurrentNodeAndPushElement(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 originalMode = mode;
                                 mode = TEXT;
                                 tokenizer.setStateAndEndTagExpectation(
                                         Tokenizer.RAWTEXT, elementName);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case INPUT:
                                 if (!Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString(
                                         "hidden",
                                         attributes.getValue(AttributeName.TYPE))) {
                                     break intableloop;
                                 }
                                 appendVoidElementToCurrent(
-                                        "http://www.w3.org/1999/xhtml", name,
-                                        attributes, formPointer);
+                                        name, attributes,
+                                        formPointer);
                                 selfClosing = false;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case FORM:
                                 if (formPointer != null) {
                                     err("Saw a \u201Cform\u201D start tag, but there was already an active \u201Cform\u201D element. Nested forms are not allowed. Ignoring the tag.");
                                     break starttagloop;
                                 } else {
@@ -1769,18 +1756,18 @@ public abstract class TreeBuilder<T> imp
                                     break starttagloop;
                                 } else {
                                     err("\u201Cframeset\u201D start tag seen.");
                                     detachFromParent(stack[1].node);
                                     while (currentPtr > 0) {
                                         pop();
                                     }
                                     appendToCurrentNodeAndPushElement(
-                                            "http://www.w3.org/1999/xhtml",
-                                            elementName, attributes);
+                                            elementName,
+                                            attributes);
                                     mode = IN_FRAMESET;
                                     attributes = null; // CPP
                                     break starttagloop;
                                 }
                             } else {
                                 err("Stray \u201Cframeset\u201D start tag.");
                                 break starttagloop;
                             }
@@ -1839,43 +1826,43 @@ public abstract class TreeBuilder<T> imp
                                 }
                                 break starttagloop;
                             case P:
                             case DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU:
                             case UL_OR_OL_OR_DL:
                             case ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_NAV_OR_SECTION_OR_SUMMARY:
                                 implicitlyCloseP();
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6:
                                 implicitlyCloseP();
                                 if (stack[currentPtr].getGroup() == H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6) {
                                     err("Heading cannot be a child of another heading.");
                                     pop();
                                 }
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case FIELDSET:
                                 implicitlyCloseP();
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes, formPointer);
+                                        elementName,
+                                        attributes, formPointer);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case PRE_OR_LISTING:
                                 implicitlyCloseP();
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 needToDropLF = true;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case FORM:
                                 if (formPointer != null) {
                                     err("Saw a \u201Cform\u201D start tag, but there was already an active \u201Cform\u201D element. Nested forms are not allowed. Ignoring the tag.");
                                     break starttagloop;
                                 } else {
@@ -1906,25 +1893,25 @@ public abstract class TreeBuilder<T> imp
                                                     && node.name != "p"
                                                     && node.name != "address" && node.name != "div")) {
                                         break;
                                     }
                                     eltPos--;
                                 }
                                 implicitlyCloseP();
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case PLAINTEXT:
                                 implicitlyCloseP();
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 tokenizer.setStateAndEndTagExpectation(
                                         Tokenizer.PLAINTEXT, elementName);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case A:
                                 int activeAPos = findInListOfActiveFormattingElementsContainsBetweenEndAndLastMarker("a");
                                 if (activeAPos != -1) {
                                     err("An \u201Ca\u201D start tag seen with already an active \u201Ca\u201D element.");
@@ -1935,38 +1922,38 @@ public abstract class TreeBuilder<T> imp
                                     activeAPos = findInListOfActiveFormattingElements(activeA);
                                     if (activeAPos != -1) {
                                         removeFromListOfActiveFormattingElements(activeAPos);
                                     }
                                     activeA.release();
                                 }
                                 reconstructTheActiveFormattingElements();
                                 appendToCurrentNodeAndPushFormattingElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U:
                             case FONT:
                                 reconstructTheActiveFormattingElements();
                                 maybeForgetEarlierDuplicateFormattingElement(elementName.name, attributes);
                                 appendToCurrentNodeAndPushFormattingElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case NOBR:
                                 reconstructTheActiveFormattingElements();
                                 if (TreeBuilder.NOT_FOUND_ON_STACK != findLastInScope("nobr")) {
                                     err("\u201Cnobr\u201D start tag seen when there was an open \u201Cnobr\u201D element in scope.");
                                     adoptionAgencyEndTag("nobr");
                                 }
                                 appendToCurrentNodeAndPushFormattingElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case BUTTON:
                                 eltPos = findLastInScope(name);
                                 if (eltPos != TreeBuilder.NOT_FOUND_ON_STACK) {
                                     err("\u201Cbutton\u201D start tag seen when there was an open \u201Cbutton\u201D element in scope.");
 
                                     generateImpliedEndTags();
@@ -1976,80 +1963,79 @@ public abstract class TreeBuilder<T> imp
                                     }
                                     while (currentPtr >= eltPos) {
                                         pop();
                                     }
                                     continue starttagloop;
                                 } else {
                                     reconstructTheActiveFormattingElements();
                                     appendToCurrentNodeAndPushElementMayFoster(
-                                            "http://www.w3.org/1999/xhtml",
-                                            elementName, attributes,
-                                            formPointer);
+                                            elementName,
+                                            attributes, formPointer);
                                     attributes = null; // CPP
                                     break starttagloop;
                                 }
                             case OBJECT:
                                 reconstructTheActiveFormattingElements();
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes, formPointer);
+                                        elementName,
+                                        attributes, formPointer);
                                 insertMarker();
                                 attributes = null; // CPP
                                 break starttagloop;
                             case MARQUEE_OR_APPLET:
                                 reconstructTheActiveFormattingElements();
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 insertMarker();
                                 attributes = null; // CPP
                                 break starttagloop;
                             case TABLE:
                                 // The only quirk. Blame Hixie and
                                 // Acid2.
                                 if (!quirks) {
                                     implicitlyCloseP();
                                 }
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 mode = IN_TABLE;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case BR:
                             case EMBED_OR_IMG:
                             case AREA_OR_WBR:
                                 reconstructTheActiveFormattingElements();
                                 // FALL THROUGH to PARAM_OR_SOURCE
                             case PARAM_OR_SOURCE:
                                 appendVoidElementToCurrentMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 selfClosing = false;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case HR:
                                 implicitlyCloseP();
                                 appendVoidElementToCurrentMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 selfClosing = false;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case IMAGE:
                                 err("Saw a start tag \u201Cimage\u201D.");
                                 elementName = ElementName.IMG;
                                 continue starttagloop;
                             case KEYGEN:
                             case INPUT:
                                 reconstructTheActiveFormattingElements();
                                 appendVoidElementToCurrentMayFoster(
-                                        "http://www.w3.org/1999/xhtml", name,
-                                        attributes, formPointer);
+                                        name, attributes,
+                                        formPointer);
                                 selfClosing = false;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case ISINDEX:
                                 err("\u201Cisindex\u201D seen.");
                                 if (formPointer != null) {
                                     break starttagloop;
                                 }
@@ -2062,21 +2048,19 @@ public abstract class TreeBuilder<T> imp
                                             attributes.getValue(actionIndex)
                                             // [NOCPP[
                                             , XmlViolationPolicy.ALLOW
                                     // ]NOCPP]
                                     );
                                 }
                                 appendToCurrentNodeAndPushFormElementMayFoster(formAttrs);
                                 appendVoidElementToCurrentMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
                                         ElementName.HR,
                                         HtmlAttributes.EMPTY_ATTRIBUTES);
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
                                         ElementName.LABEL,
                                         HtmlAttributes.EMPTY_ATTRIBUTES);
                                 int promptIndex = attributes.getIndex(AttributeName.PROMPT);
                                 if (promptIndex > -1) {
                                     @Auto char[] prompt = Portability.newCharArrayFromString(attributes.getValue(promptIndex));
                                     appendCharacters(stack[currentPtr].node,
                                             prompt, 0, prompt.length);
                                 } else {
@@ -2104,81 +2088,80 @@ public abstract class TreeBuilder<T> imp
                                                 , XmlViolationPolicy.ALLOW
                                         // ]NOCPP]
 
                                         );
                                     }
                                 }
                                 attributes.clearWithoutReleasingContents();
                                 appendVoidElementToCurrentMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        "input", inputAttributes, formPointer);
+                                        "input",
+                                        inputAttributes, formPointer);
                                 pop(); // label
                                 appendVoidElementToCurrentMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
                                         ElementName.HR,
                                         HtmlAttributes.EMPTY_ATTRIBUTES);
                                 pop(); // form
                                 selfClosing = false;
                                 // Portability.delete(formAttrs);
                                 // Portability.delete(inputAttributes);
                                 // Don't delete attributes, they are deleted
                                 // later
                                 break starttagloop;
                             case TEXTAREA:
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes, formPointer);
+                                        elementName,
+                                        attributes, formPointer);
                                 tokenizer.setStateAndEndTagExpectation(
                                         Tokenizer.RCDATA, elementName);
                                 originalMode = mode;
                                 mode = TEXT;
                                 needToDropLF = true;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case XMP:
                                 implicitlyCloseP();
                                 reconstructTheActiveFormattingElements();
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 originalMode = mode;
                                 mode = TEXT;
                                 tokenizer.setStateAndEndTagExpectation(
                                         Tokenizer.RAWTEXT, elementName);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case NOSCRIPT:
                                 if (!scriptingEnabled) {
                                     reconstructTheActiveFormattingElements();
                                     appendToCurrentNodeAndPushElementMayFoster(
-                                            "http://www.w3.org/1999/xhtml",
-                                            elementName, attributes);
+                                            elementName,
+                                            attributes);
                                     attributes = null; // CPP
                                     break starttagloop;
                                 } else {
                                     // fall through
                                 }
                             case NOFRAMES:
                             case IFRAME:
                             case NOEMBED:
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 originalMode = mode;
                                 mode = TEXT;
                                 tokenizer.setStateAndEndTagExpectation(
                                         Tokenizer.RAWTEXT, elementName);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case SELECT:
                                 reconstructTheActiveFormattingElements();
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes, formPointer);
+                                        elementName,
+                                        attributes, formPointer);
                                 switch (mode) {
                                     case IN_TABLE:
                                     case IN_CAPTION:
                                     case IN_COLUMN_GROUP:
                                     case IN_TABLE_BODY:
                                     case IN_ROW:
                                     case IN_CELL:
                                         mode = IN_SELECT_IN_TABLE;
@@ -2226,18 +2209,18 @@ public abstract class TreeBuilder<T> imp
                                  * Reconstruct the active formatting elements,
                                  * if any.
                                  */
                                 reconstructTheActiveFormattingElements();
                                 /*
                                  * Insert an HTML element for the token.
                                  */
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case RT_OR_RP:
                                 /*
                                  * If the stack of open elements has a ruby
                                  * element in scope, then generate implied end
                                  * tags. If the current node is not then a ruby
                                  * element, this is a parse error; pop all the
@@ -2247,53 +2230,59 @@ public abstract class TreeBuilder<T> imp
                                  * 
                                  * Insert an HTML element for the token.
                                  */
                                 eltPos = findLastInScope("ruby");
                                 if (eltPos != NOT_FOUND_ON_STACK) {
                                     generateImpliedEndTags();
                                 }
                                 if (eltPos != currentPtr) {
-                                    err("Unclosed children in \u201Cruby\u201D.");
+                                    if (errorHandler != null) {
+                                        if (eltPos != NOT_FOUND_ON_STACK) {
+
+                                            errNoCheck("Start tag \u201C"
+                                                    + name
+                                                    + "\u201D seen without a \u201Cruby\u201D element being open.");
+                                        } else {
+                                            errNoCheck("Unclosed children in \u201Cruby\u201D.");
+                                        }
+                                    }
                                     while (currentPtr > eltPos) {
                                         pop();
                                     }
                                 }
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case MATH:
                                 reconstructTheActiveFormattingElements();
                                 attributes.adjustForMath();
                                 if (selfClosing) {
-                                    appendVoidElementToCurrentMayFoster(
-                                            "http://www.w3.org/1998/Math/MathML",
+                                    appendVoidElementToCurrentMayFosterMathML(
                                             elementName, attributes);
                                     selfClosing = false;
                                 } else {
-                                    appendToCurrentNodeAndPushElementMayFoster(
-                                            "http://www.w3.org/1998/Math/MathML",
+                                    appendToCurrentNodeAndPushElementMayFosterMathML(
                                             elementName, attributes);
                                     inForeign = true;
                                 }
                                 attributes = null; // CPP
                                 break starttagloop;
                             case SVG:
                                 reconstructTheActiveFormattingElements();
                                 attributes.adjustForSvg();
                                 if (selfClosing) {
-                                    appendVoidElementToCurrentMayFosterCamelCase(
-                                            "http://www.w3.org/2000/svg",
-                                            elementName, attributes);
+                                    appendVoidElementToCurrentMayFosterSVG(
+                                            elementName,
+                                            attributes);
                                     selfClosing = false;
                                 } else {
-                                    appendToCurrentNodeAndPushElementMayFoster(
-                                            "http://www.w3.org/2000/svg",
+                                    appendToCurrentNodeAndPushElementMayFosterSVG(
                                             elementName, attributes);
                                     inForeign = true;
                                 }
                                 attributes = null; // CPP
                                 break starttagloop;
                             case CAPTION:
                             case COL:
                             case COLGROUP:
@@ -2303,25 +2292,25 @@ public abstract class TreeBuilder<T> imp
                             case FRAME:
                             case FRAMESET:
                             case HEAD:
                                 err("Stray start tag \u201C" + name + "\u201D.");
                                 break starttagloop;
                             case OUTPUT_OR_LABEL:
                                 reconstructTheActiveFormattingElements();
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes, formPointer);
+                                        elementName,
+                                        attributes, formPointer);
                                 attributes = null; // CPP
                                 break starttagloop;
                             default:
                                 reconstructTheActiveFormattingElements();
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 attributes = null; // CPP
                                 break starttagloop;
                         }
                     }
                 case IN_HEAD:
                     inheadloop: for (;;) {
                         switch (group) {
                             case HTML:
@@ -2329,71 +2318,71 @@ public abstract class TreeBuilder<T> imp
                                 if (!fragment) {
                                     addAttributesToHtml(attributes);
                                     attributes = null; // CPP
                                 }
                                 break starttagloop;
                             case BASE:
                             case COMMAND:
                                 appendVoidElementToCurrentMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 selfClosing = false;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case META:
                             case LINK_OR_BASEFONT_OR_BGSOUND:
                                 // Fall through to IN_HEAD_NOSCRIPT
                                 break inheadloop;
                             case TITLE:
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 originalMode = mode;
                                 mode = TEXT;
                                 tokenizer.setStateAndEndTagExpectation(
                                         Tokenizer.RCDATA, elementName);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case NOSCRIPT:
                                 if (scriptingEnabled) {
                                     appendToCurrentNodeAndPushElement(
-                                            "http://www.w3.org/1999/xhtml",
-                                            elementName, attributes);
+                                            elementName,
+                                            attributes);
                                     originalMode = mode;
                                     mode = TEXT;
                                     tokenizer.setStateAndEndTagExpectation(
                                             Tokenizer.RAWTEXT, elementName);
                                 } else {
                                     appendToCurrentNodeAndPushElementMayFoster(
-                                            "http://www.w3.org/1999/xhtml",
-                                            elementName, attributes);
+                                            elementName,
+                                            attributes);
                                     mode = IN_HEAD_NOSCRIPT;
                                 }
                                 attributes = null; // CPP
                                 break starttagloop;
                             case SCRIPT:
                                 // XXX need to manage much more stuff
                                 // here if
                                 // supporting
                                 // document.write()
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 originalMode = mode;
                                 mode = TEXT;
                                 tokenizer.setStateAndEndTagExpectation(
                                         Tokenizer.SCRIPT_DATA, elementName);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case STYLE:
                             case NOFRAMES:
                                 appendToCurrentNodeAndPushElementMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
-                                        elementName, attributes);
+                                        elementName,
+                                        attributes);
                                 originalMode = mode;
                                 mode = TEXT;
                                 tokenizer.setStateAndEndTagExpectation(
                                         Tokenizer.RAWTEXT, elementName);
                                 attributes = null; // CPP
                                 break starttagloop;
                             case HEAD:
                                 /* Parse error. */
@@ -2414,34 +2403,34 @@ public abstract class TreeBuilder<T> imp
                             err("Stray \u201Chtml\u201D start tag.");
                             if (!fragment) {
                                 addAttributesToHtml(attributes);
                                 attributes = null; // CPP
                             }
                             break starttagloop;
                         case LINK_OR_BASEFONT_OR_BGSOUND:
                             appendVoidElementToCurrentMayFoster(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             selfClosing = false;
                             attributes = null; // CPP
                             break starttagloop;
                         case META:
                             checkMetaCharset(attributes);
                             appendVoidElementToCurrentMayFoster(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             selfClosing = false;
                             attributes = null; // CPP
                             break starttagloop;
                         case STYLE:
                         case NOFRAMES:
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             originalMode = mode;
                             mode = TEXT;
                             tokenizer.setStateAndEndTagExpectation(
                                     Tokenizer.RAWTEXT, elementName);
                             attributes = null; // CPP
                             break starttagloop;
                         case HEAD:
                             err("Start tag for \u201Chead\u201D seen when \u201Chead\u201D was already open.");
@@ -2462,18 +2451,18 @@ public abstract class TreeBuilder<T> imp
                             err("Stray \u201Chtml\u201D start tag.");
                             if (!fragment) {
                                 addAttributesToHtml(attributes);
                                 attributes = null; // CPP
                             }
                             break starttagloop;
                         case COL:
                             appendVoidElementToCurrentMayFoster(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             selfClosing = false;
                             attributes = null; // CPP
                             break starttagloop;
                         default:
                             if (currentPtr == 0) {
                                 assert fragment;
                                 err("Garbage in \u201Ccolgroup\u201D fragment.");
                                 break starttagloop;
@@ -2514,30 +2503,30 @@ public abstract class TreeBuilder<T> imp
                                 attributes = null; // CPP
                             }
                             break starttagloop;
                         case OPTION:
                             if (isCurrent("option")) {
                                 pop();
                             }
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             attributes = null; // CPP
                             break starttagloop;
                         case OPTGROUP:
                             if (isCurrent("option")) {
                                 pop();
                             }
                             if (isCurrent("optgroup")) {
                                 pop();
                             }
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             attributes = null; // CPP
                             break starttagloop;
                         case SELECT:
                             err("\u201Cselect\u201D start tag where end tag expected.");
                             eltPos = findLastInTableScope(name);
                             if (eltPos == TreeBuilder.NOT_FOUND_ON_STACK) {
                                 assert fragment;
                                 err("No \u201Cselect\u201D in table scope.");
@@ -2566,18 +2555,18 @@ public abstract class TreeBuilder<T> imp
                             resetTheInsertionMode();
                             continue;
                         case SCRIPT:
                             // XXX need to manage much more stuff
                             // here if
                             // supporting
                             // document.write()
                             appendToCurrentNodeAndPushElementMayFoster(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             originalMode = mode;
                             mode = TEXT;
                             tokenizer.setStateAndEndTagExpectation(
                                     Tokenizer.SCRIPT_DATA, elementName);
                             attributes = null; // CPP
                             break starttagloop;
                         default:
                             err("Stray \u201C" + name + "\u201D start tag.");
@@ -2596,24 +2585,24 @@ public abstract class TreeBuilder<T> imp
                             err("Stray \u201C" + name + "\u201D start tag.");
                             mode = framesetOk ? FRAMESET_OK : IN_BODY;
                             continue;
                     }
                 case IN_FRAMESET:
                     switch (group) {
                         case FRAMESET:
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             attributes = null; // CPP
                             break starttagloop;
                         case FRAME:
                             appendVoidElementToCurrentMayFoster(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             selfClosing = false;
                             attributes = null; // CPP
                             break starttagloop;
                         default:
                             // fall through to AFTER_FRAMESET
                     }
                 case AFTER_FRAMESET:
                     switch (group) {
@@ -2621,18 +2610,18 @@ public abstract class TreeBuilder<T> imp
                             err("Stray \u201Chtml\u201D start tag.");
                             if (!fragment) {
                                 addAttributesToHtml(attributes);
                                 attributes = null; // CPP
                             }
                             break starttagloop;
                         case NOFRAMES:
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             originalMode = mode;
                             mode = TEXT;
                             tokenizer.setStateAndEndTagExpectation(
                                     Tokenizer.RAWTEXT, elementName);
                             attributes = null; // CPP
                             break starttagloop;
                         default:
                             err("Stray \u201C" + name + "\u201D start tag.");
@@ -2773,85 +2762,85 @@ public abstract class TreeBuilder<T> imp
                                 appendToCurrentNodeAndPushBodyElement(attributes);
                             }
                             framesetOk = false;
                             mode = IN_BODY;
                             attributes = null; // CPP
                             break starttagloop;
                         case FRAMESET:
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             mode = IN_FRAMESET;
                             attributes = null; // CPP
                             break starttagloop;
                         case BASE:
                             err("\u201Cbase\u201D element outside \u201Chead\u201D.");
                             pushHeadPointerOntoStack();
                             appendVoidElementToCurrentMayFoster(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             selfClosing = false;
                             pop(); // head
                             attributes = null; // CPP
                             break starttagloop;
                         case LINK_OR_BASEFONT_OR_BGSOUND:
                             err("\u201Clink\u201D element outside \u201Chead\u201D.");
                             pushHeadPointerOntoStack();
                             appendVoidElementToCurrentMayFoster(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             selfClosing = false;
                             pop(); // head
                             attributes = null; // CPP
                             break starttagloop;
                         case META:
                             err("\u201Cmeta\u201D element outside \u201Chead\u201D.");
                             checkMetaCharset(attributes);
                             pushHeadPointerOntoStack();
                             appendVoidElementToCurrentMayFoster(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             selfClosing = false;
                             pop(); // head
                             attributes = null; // CPP
                             break starttagloop;
                         case SCRIPT:
                             err("\u201Cscript\u201D element between \u201Chead\u201D and \u201Cbody\u201D.");
                             pushHeadPointerOntoStack();
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             originalMode = mode;
                             mode = TEXT;
                             tokenizer.setStateAndEndTagExpectation(
                                     Tokenizer.SCRIPT_DATA, elementName);
                             attributes = null; // CPP
                             break starttagloop;
                         case STYLE:
                         case NOFRAMES:
                             err("\u201C"
                                     + name
                                     + "\u201D element between \u201Chead\u201D and \u201Cbody\u201D.");
                             pushHeadPointerOntoStack();
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             originalMode = mode;
                             mode = TEXT;
                             tokenizer.setStateAndEndTagExpectation(
                                     Tokenizer.RAWTEXT, elementName);
                             attributes = null; // CPP
                             break starttagloop;
                         case TITLE:
                             err("\u201Ctitle\u201D element outside \u201Chead\u201D.");
                             pushHeadPointerOntoStack();
                             appendToCurrentNodeAndPushElement(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             originalMode = mode;
                             mode = TEXT;
                             tokenizer.setStateAndEndTagExpectation(
                                     Tokenizer.RCDATA, elementName);
                             attributes = null; // CPP
                             break starttagloop;
                         case HEAD:
                             err("Stray start tag \u201Chead\u201D.");
@@ -2882,18 +2871,18 @@ public abstract class TreeBuilder<T> imp
                             err("Stray \u201Chtml\u201D start tag.");
                             if (!fragment) {
                                 addAttributesToHtml(attributes);
                                 attributes = null; // CPP
                             }
                             break starttagloop;
                         case NOFRAMES:
                             appendToCurrentNodeAndPushElementMayFoster(
-                                    "http://www.w3.org/1999/xhtml",
-                                    elementName, attributes);
+                                    elementName,
+                                    attributes);
                             originalMode = mode;
                             mode = TEXT;
                             tokenizer.setStateAndEndTagExpectation(
                                     Tokenizer.SCRIPT_DATA, elementName);
                             attributes = null; // CPP
                             break starttagloop;
                         default:
                             err("Stray \u201C" + name + "\u201D start tag.");
@@ -3430,17 +3419,16 @@ public abstract class TreeBuilder<T> imp
                                 }
                             }
                             break endtagloop;
                         case FORM:
                             if (formPointer == null) {
                                 err("Stray end tag \u201C" + name + "\u201D.");
                                 break endtagloop;
                             }
-                            Portability.releaseElement(formPointer);
                             formPointer = null;
                             eltPos = findLastInScope(name);
                             if (eltPos == TreeBuilder.NOT_FOUND_ON_STACK) {
                                 err("Stray end tag \u201C" + name + "\u201D.");
                                 break endtagloop;
                             }
                             generateImpliedEndTags();
                             if (errorHandler != null && !isCurrent(name)) {
@@ -3460,17 +3448,16 @@ public abstract class TreeBuilder<T> imp
                                             + name
                                             + "\u201D in a foreign namespace context.");
                                     while (stack[currentPtr].ns != "http://www.w3.org/1999/xhtml") {
                                         pop();
                                     }
                                     inForeign = false;
                                 }
                                 appendVoidElementToCurrentMayFoster(
-                                        "http://www.w3.org/1999/xhtml",
                                         elementName,
                                         HtmlAttributes.EMPTY_ATTRIBUTES);
                                 break endtagloop;
                             }
                             generateImpliedEndTagsExceptFor("p");
                             assert eltPos != TreeBuilder.NOT_FOUND_ON_STACK;
                             if (errorHandler != null && eltPos != currentPtr) {
                                 errNoCheck("End tag for \u201Cp\u201D seen, but there were unclosed elements.");
@@ -3556,17 +3543,16 @@ public abstract class TreeBuilder<T> imp
                                         + "\u201D in a foreign namespace context.");
                                 while (stack[currentPtr].ns != "http://www.w3.org/1999/xhtml") {
                                     pop();
                                 }
                                 inForeign = false;
                             }
                             reconstructTheActiveFormattingElements();
                             appendVoidElementToCurrentMayFoster(
-                                    "http://www.w3.org/1999/xhtml",
                                     elementName,
                                     HtmlAttributes.EMPTY_ATTRIBUTES);
                             break endtagloop;
                         case AREA_OR_WBR:
                         case PARAM_OR_SOURCE:
                         case EMBED_OR_IMG:
                         case IMAGE:
                         case INPUT:
@@ -3612,17 +3598,17 @@ public abstract class TreeBuilder<T> imp
                                         errNoCheck("End tag \u201C"
                                                 + name
                                                 + "\u201D seen but there were unclosed elements.");
                                     }
                                     while (currentPtr >= eltPos) {
                                         pop();
                                     }
                                     break endtagloop;
-                                } else if (node.isScopingOrSpecial()) {
+                                } else if (node.isSpecial()) {
                                     err("Stray end tag \u201C" + name
                                             + "\u201D.");
                                     break endtagloop;
                                 }
                                 eltPos--;
                             }
                     }
                 case IN_COLUMN_GROUP:
@@ -4382,17 +4368,17 @@ public abstract class TreeBuilder<T> imp
             }
             // stackPos now points to the formatting element and it is in scope
             if (errorHandler != null && formattingEltStackPos != currentPtr) {
                 errNoCheck("End tag \u201C" + name + "\u201D violates nesting rules.");
             }
             int furthestBlockPos = formattingEltStackPos + 1;
             while (furthestBlockPos <= currentPtr) {
                 StackNode<T> node = stack[furthestBlockPos]; // weak ref
-                if (node.isScopingOrSpecial()) {
+                if (node.isSpecial()) {
                     break;
                 }
                 furthestBlockPos++;
             }
             if (furthestBlockPos > currentPtr) {
                 // no furthest block
                 while (currentPtr >= formattingEltStackPos) {
                     pop();
@@ -4440,17 +4426,16 @@ public abstract class TreeBuilder<T> imp
                 // stack
                 node.dropAttributes(); // adopt ownership to newNode
                 stack[nodePos] = newNode;
                 newNode.retain(); // retain for list
                 listOfActiveFormattingElements[nodeListPos] = newNode;
                 node.release(); // release from stack
                 node.release(); // release from list
                 node = newNode;
-                Portability.releaseElement(clone);
                 // } XXX AAA CHANGE
                 detachFromParent(lastNode.node);
                 appendElement(lastNode.node, node.node);
                 lastNode = node;
             }
             if (commonAncestor.isFosterParenting()) {
                 fatal();
                 detachFromParent(lastNode.node);
@@ -4476,17 +4461,16 @@ public abstract class TreeBuilder<T> imp
             appendElement(clone, furthestBlock.node);
             removeFromListOfActiveFormattingElements(formattingEltListPos);
             insertIntoListOfActiveFormattingElements(formattingClone, bookmark);
             assert formattingEltStackPos < furthestBlockPos;
             removeFromStack(formattingEltStackPos);
             // furthestBlockPos is now off by one and points to the slot after
             // it
             insertIntoStack(formattingClone, furthestBlockPos);
-            Portability.releaseElement(clone);
         }
         return true;
     }
 
     private void insertIntoStack(StackNode<T> node, int position)
             throws SAXException {
         assert currentPtr + 1 < stack.length;
         assert position <= currentPtr + 1;
@@ -4602,18 +4586,17 @@ public abstract class TreeBuilder<T> imp
         addAttributesToElement(stack[0].node, attributes);
     }
 
     private void pushHeadPointerOntoStack() throws SAXException {
         assert headPointer != null;
         assert !fragment;
         assert mode == AFTER_HEAD;
         fatal();
-        silentPush(new StackNode<T>("http://www.w3.org/1999/xhtml", ElementName.HEAD,
-                headPointer));
+        silentPush(new StackNode<T>(ElementName.HEAD, headPointer));
     }
 
     /**
      * @throws SAXException
      * 
      */
     private void reconstructTheActiveFormattingElements() throws SAXException {
         if (listPtr == -1) {
@@ -4797,282 +4780,285 @@ public abstract class TreeBuilder<T> imp
     // ]NOCPP]
 
     private void appendHtmlElementToDocumentAndPush(HtmlAttributes attributes)
             throws SAXException {
         // [NOCPP[
         checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         T elt = createHtmlElementSetAsRoot(attributes);
-        StackNode<T> node = new StackNode<T>("http://www.w3.org/1999/xhtml",
-                ElementName.HTML, elt);
+        StackNode<T> node = new StackNode<T>(ElementName.HTML,
+                elt);
         push(node);
-        Portability.releaseElement(elt);
     }
 
     private void appendHtmlElementToDocumentAndPush() throws SAXException {
         appendHtmlElementToDocumentAndPush(tokenizer.emptyAttributes());
     }
 
     private void appendToCurrentNodeAndPushHeadElement(HtmlAttributes attributes)
             throws SAXException {
         // [NOCPP[
         checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         T elt = createElement("http://www.w3.org/1999/xhtml", "head",
                 attributes);
         appendElement(elt, stack[currentPtr].node);
         headPointer = elt;
-        Portability.retainElement(headPointer);
-        StackNode<T> node = new StackNode<T>("http://www.w3.org/1999/xhtml",
-                ElementName.HEAD, elt);
+        StackNode<T> node = new StackNode<T>(ElementName.HEAD,
+                elt);
         push(node);
-        Portability.releaseElement(elt);
     }
 
     private void appendToCurrentNodeAndPushBodyElement(HtmlAttributes attributes)
             throws SAXException {
-        appendToCurrentNodeAndPushElement("http://www.w3.org/1999/xhtml",
-                ElementName.BODY, attributes);
+        appendToCurrentNodeAndPushElement(ElementName.BODY,
+                attributes);
     }
 
     private void appendToCurrentNodeAndPushBodyElement() throws SAXException {
         appendToCurrentNodeAndPushBodyElement(tokenizer.emptyAttributes());
     }
 
     private void appendToCurrentNodeAndPushFormElementMayFoster(
             HtmlAttributes attributes) throws SAXException {
         // [NOCPP[
         checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         T elt = createElement("http://www.w3.org/1999/xhtml", "form",
                 attributes);
         formPointer = elt;
-        Portability.retainElement(formPointer);
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             insertIntoFosterParent(elt);
         } else {
             appendElement(elt, current.node);
         }
-        StackNode<T> node = new StackNode<T>("http://www.w3.org/1999/xhtml",
-                ElementName.FORM, elt);
+        StackNode<T> node = new StackNode<T>(ElementName.FORM,
+                elt);
         push(node);
-        Portability.releaseElement(elt);
     }
 
     private void appendToCurrentNodeAndPushFormattingElementMayFoster(
-            @NsUri String ns, ElementName elementName, HtmlAttributes attributes)
+            ElementName elementName, HtmlAttributes attributes)
             throws SAXException {
         // [NOCPP[
-        checkAttributes(attributes, ns);
+        checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         // This method can't be called for custom elements
-        T elt = createElement(ns, elementName.name, attributes);
+        T elt = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes);
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             insertIntoFosterParent(elt);
         } else {
             appendElement(elt, current.node);
         }
-        StackNode<T> node = new StackNode<T>(ns, elementName, elt,
-                attributes.cloneAttributes(null));
+        StackNode<T> node = new StackNode<T>(elementName, elt, attributes.cloneAttributes(null));
         push(node);
         append(node);
         node.retain(); // append doesn't retain itself
-        Portability.releaseElement(elt);
     }
 
-    private void appendToCurrentNodeAndPushElement(@NsUri String ns,
-            ElementName elementName, HtmlAttributes attributes)
+    private void appendToCurrentNodeAndPushElement(ElementName elementName,
+            HtmlAttributes attributes)
             throws SAXException {
         // [NOCPP[
-        checkAttributes(attributes, ns);
+        checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         // This method can't be called for custom elements
-        T elt = createElement(ns, elementName.name, attributes);
+        T elt = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes);
         appendElement(elt, stack[currentPtr].node);
-        StackNode<T> node = new StackNode<T>(ns, elementName, elt);
+        StackNode<T> node = new StackNode<T>(elementName, elt);
         push(node);
-        Portability.releaseElement(elt);
     }
 
-    private void appendToCurrentNodeAndPushElementMayFoster(@NsUri String ns,
-            ElementName elementName, HtmlAttributes attributes)
+    private void appendToCurrentNodeAndPushElementMayFoster(ElementName elementName,
+            HtmlAttributes attributes)
             throws SAXException {
         @Local String popName = elementName.name;
         // [NOCPP[
-        checkAttributes(attributes, ns);
+        checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         if (elementName.isCustom()) {
             popName = checkPopName(popName);
         }
         // ]NOCPP]
-        T elt = createElement(ns, popName, attributes);
+        T elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes);
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             insertIntoFosterParent(elt);
         } else {
             appendElement(elt, current.node);
         }
-        StackNode<T> node = new StackNode<T>(ns, elementName, elt, popName);
+        StackNode<T> node = new StackNode<T>(elementName, elt, popName);
         push(node);
-        Portability.releaseElement(elt);
     }
 
-    private void appendToCurrentNodeAndPushElementMayFosterNoScoping(
-            @NsUri String ns, ElementName elementName, HtmlAttributes attributes)
+    private void appendToCurrentNodeAndPushElementMayFosterMathML(
+            ElementName elementName, HtmlAttributes attributes)
             throws SAXException {
         @Local String popName = elementName.name;
         // [NOCPP[
-        checkAttributes(attributes, ns);
+        checkAttributes(attributes, "http://www.w3.org/1998/Math/MathML");
         if (elementName.isCustom()) {
             popName = checkPopName(popName);
         }
         // ]NOCPP]
-        T elt = createElement(ns, popName, attributes);
+        T elt = createElement("http://www.w3.org/1998/Math/MathML", popName,
+                attributes);
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             insertIntoFosterParent(elt);
         } else {
             appendElement(elt, current.node);
         }
-        StackNode<T> node = new StackNode<T>(ns, elementName, elt, popName,
-                false);
+        StackNode<T> node = new StackNode<T>(elementName, elt, popName, false);
         push(node);
-        Portability.releaseElement(elt);
     }
 
-    private void appendToCurrentNodeAndPushElementMayFosterCamelCase(
-            @NsUri String ns, ElementName elementName, HtmlAttributes attributes)
+    private void appendToCurrentNodeAndPushElementMayFosterSVG(
+            ElementName elementName, HtmlAttributes attributes)
             throws SAXException {
         @Local String popName = elementName.camelCaseName;
         // [NOCPP[
-        checkAttributes(attributes, ns);
+        checkAttributes(attributes, "http://www.w3.org/2000/svg");
         if (elementName.isCustom()) {
             popName = checkPopName(popName);
         }
         // ]NOCPP]
-        T elt = createElement(ns, popName, attributes);
+        T elt = createElement("http://www.w3.org/2000/svg", popName, attributes);
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             insertIntoFosterParent(elt);
         } else {
             appendElement(elt, current.node);
         }
-        StackNode<T> node = new StackNode<T>(ns, elementName, elt, popName,
-                ElementName.FOREIGNOBJECT == elementName);
+        StackNode<T> node = new StackNode<T>(elementName, popName, elt);
         push(node);
-        Portability.releaseElement(elt);
     }
 
-    private void appendToCurrentNodeAndPushElementMayFoster(@NsUri String ns,
-            ElementName elementName, HtmlAttributes attributes, T form)
+    private void appendToCurrentNodeAndPushElementMayFoster(ElementName elementName,
+            HtmlAttributes attributes, T form)
             throws SAXException {
         // [NOCPP[
-        checkAttributes(attributes, ns);
+        checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         // Can't be called for custom elements
-        T elt = createElement(ns, elementName.name, attributes, fragment ? null
+        T elt = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes, fragment ? null
                 : form);
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             insertIntoFosterParent(elt);
         } else {
             appendElement(elt, current.node);
         }
-        StackNode<T> node = new StackNode<T>(ns, elementName, elt);
+        StackNode<T> node = new StackNode<T>(elementName, elt);
         push(node);
-        Portability.releaseElement(elt);
     }
 
     private void appendVoidElementToCurrentMayFoster(
-            @NsUri String ns, @Local String name, HtmlAttributes attributes,
-            T form) throws SAXException {
+            @Local String name, HtmlAttributes attributes, T form) throws SAXException {
         // [NOCPP[
-        checkAttributes(attributes, ns);
+        checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         // Can't be called for custom elements
-        T elt = createElement(ns, name, attributes, fragment ? null : form);
+        T elt = createElement("http://www.w3.org/1999/xhtml", name, attributes, fragment ? null : form);
+        StackNode<T> current = stack[currentPtr];
+        if (current.isFosterParenting()) {
+            fatal();
+            insertIntoFosterParent(elt);
+        } else {
+            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)
+            throws SAXException {
+        @Local String popName = elementName.name;
+        // [NOCPP[
+        checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
+        if (elementName.isCustom()) {
+            popName = checkPopName(popName);
+        }
+        // ]NOCPP]
+        T elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes);
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             insertIntoFosterParent(elt);
         } else {
             appendElement(elt, current.node);
         }
-        elementPushed(ns, name, elt);
-        elementPopped(ns, name, elt);
-        Portability.releaseElement(elt);
+        elementPushed("http://www.w3.org/1999/xhtml", popName, elt);
+        elementPopped("http://www.w3.org/1999/xhtml", popName, elt);
     }
 
-    private void appendVoidElementToCurrentMayFoster(
-            @NsUri String ns, ElementName elementName, HtmlAttributes attributes)
+    private void appendVoidElementToCurrentMayFosterSVG(
+            ElementName elementName, HtmlAttributes attributes)
             throws SAXException {
-        @Local String popName = elementName.name;
+        @Local String popName = elementName.camelCaseName;
         // [NOCPP[
-        checkAttributes(attributes, ns);
+        checkAttributes(attributes, "http://www.w3.org/2000/svg");
         if (elementName.isCustom()) {
             popName = checkPopName(popName);
         }
         // ]NOCPP]
-        T elt = createElement(ns, popName, attributes);
+        T elt = createElement("http://www.w3.org/2000/svg", popName, attributes);
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             insertIntoFosterParent(elt);
         } else {
             appendElement(elt, current.node);
         }
-        elementPushed(ns, popName, elt);
-        elementPopped(ns, popName, elt);
-        Portability.releaseElement(elt);
+        elementPushed("http://www.w3.org/2000/svg", popName, elt);
+        elementPopped("http://www.w3.org/2000/svg", popName, elt);
     }
 
-    private void appendVoidElementToCurrentMayFosterCamelCase(
-            @NsUri String ns, ElementName elementName, HtmlAttributes attributes)
+    private void appendVoidElementToCurrentMayFosterMathML(
+            ElementName elementName, HtmlAttributes attributes)
             throws SAXException {
-        @Local String popName = elementName.camelCaseName;
+        @Local String popName = elementName.name;
         // [NOCPP[
-        checkAttributes(attributes, ns);
+        checkAttributes(attributes, "http://www.w3.org/1998/Math/MathML");
         if (elementName.isCustom()) {
             popName = checkPopName(popName);
         }
         // ]NOCPP]
-        T elt = createElement(ns, popName, attributes);
+        T elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes);
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             insertIntoFosterParent(elt);
         } else {
             appendElement(elt, current.node);
         }
-        elementPushed(ns, popName, elt);
-        elementPopped(ns, popName, elt);
-        Portability.releaseElement(elt);
+        elementPushed("http://www.w3.org/1998/Math/MathML", popName, elt);
+        elementPopped("http://www.w3.org/1998/Math/MathML", popName, elt);
     }
 
     private void appendVoidElementToCurrent(
-            @NsUri String ns, @Local String name, HtmlAttributes attributes,
-            T form) throws SAXException {
+            @Local String name, HtmlAttributes attributes, T form) throws SAXException {
         // [NOCPP[
-        checkAttributes(attributes, ns);
+        checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         // Can't be called for custom elements
-        T elt = createElement(ns, name, attributes, fragment ? null : form);
+        T elt = createElement("http://www.w3.org/1999/xhtml", name, attributes, fragment ? null : form);
         StackNode<T> current = stack[currentPtr];
         appendElement(elt, current.node);
-        elementPushed(ns, name, elt);
-        elementPopped(ns, name, elt);
-        Portability.releaseElement(elt);
+        elementPushed("http://www.w3.org/1999/xhtml", name, elt);
+        elementPopped("http://www.w3.org/1999/xhtml", name, elt);
     }
 
     private void appendVoidFormToCurrent(HtmlAttributes attributes) throws SAXException {
         // [NOCPP[
         checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         T elt = createElement("http://www.w3.org/1999/xhtml", "form",
                 attributes);
@@ -5245,20 +5231,18 @@ public abstract class TreeBuilder<T> imp
     /**
      * The argument MUST be an interned string or <code>null</code>.
      * 
      * @param context
      */
     public final void setFragmentContext(@Local String context,
             @NsUri String ns, T node, boolean quirks) {
         this.contextName = context;
-        Portability.retainLocal(context);
         this.contextNamespace = ns;
         this.contextNode = node;
-        Portability.retainElement(node);
         this.fragment = (contextName != null);
         this.quirks = quirks;
     }
 
     protected final T currentNode() {
         return stack[currentPtr].node;
     }
 
@@ -5402,17 +5386,16 @@ public abstract class TreeBuilder<T> imp
                         node.name, node.node, node.popName,
                         null);
                 stackCopy[i] = newNode;
             } else {
                 stackCopy[i] = listCopy[listIndex];
                 stackCopy[i].retain();
             }
         }
-        Portability.retainElement(formPointer);
         return new StateSnapshot<T>(stackCopy, listCopy, formPointer, headPointer, deepTreeSurrogateParent, mode, originalMode, framesetOk, inForeign, needToDropLF, quirks);
     }
 
     public boolean snapshotMatches(TreeBuilderState<T> snapshot) {
         StackNode<T>[] stackCopy = snapshot.getStack();
         int stackLen = snapshot.getStackLength();
         StackNode<T>[] listCopy = snapshot.getListOfActiveFormattingElements();
         int listLen = snapshot.getListOfActiveFormattingElementsLength();
@@ -5498,25 +5481,19 @@ public abstract class TreeBuilder<T> imp
                         Portability.newLocalFromLocal(node.popName, interner),
                         null);
                 stack[i] = newNode;
             } else {
                 stack[i] = listOfActiveFormattingElements[listIndex];
                 stack[i].retain();
             }
         }
-        Portability.releaseElement(formPointer);
         formPointer = snapshot.getFormPointer();
-        Portability.retainElement(formPointer);
-        Portability.releaseElement(headPointer);
         headPointer = snapshot.getHeadPointer();
-        Portability.retainElement(headPointer);
-        Portability.releaseElement(deepTreeSurrogateParent);
         deepTreeSurrogateParent = snapshot.getDeepTreeSurrogateParent();
-        Portability.retainElement(deepTreeSurrogateParent);
         mode = snapshot.getMode();
         originalMode = snapshot.getOriginalMode();
         framesetOk = snapshot.isFramesetOk();
         inForeign = snapshot.isInForeign();
         needToDropLF = snapshot.isNeedToDropLF();
         quirks = snapshot.isQuirks();
     }
 
--- a/parser/html/nsHtml5AttributeName.cpp
+++ b/parser/html/nsHtml5AttributeName.cpp
@@ -161,17 +161,16 @@ void
 nsHtml5AttributeName::release()
 {
 }
 
 
 nsHtml5AttributeName::~nsHtml5AttributeName()
 {
   MOZ_COUNT_DTOR(nsHtml5AttributeName);
-  nsHtml5Portability::releaseLocal(local[0]);
   delete[] local;
 }
 
 nsHtml5AttributeName* 
 nsHtml5AttributeName::cloneAttributeName(nsHtml5AtomTable* interner)
 {
   return this;
 }
--- a/parser/html/nsHtml5ElementName.cpp
+++ b/parser/html/nsHtml5ElementName.cpp
@@ -120,17 +120,16 @@ void
 nsHtml5ElementName::release()
 {
 }
 
 
 nsHtml5ElementName::~nsHtml5ElementName()
 {
   MOZ_COUNT_DTOR(nsHtml5ElementName);
-  nsHtml5Portability::releaseLocal(name);
 }
 
 nsHtml5ElementName* 
 nsHtml5ElementName::cloneElementName(nsHtml5AtomTable* interner)
 {
   return this;
 }
 
@@ -555,27 +554,27 @@ nsHtml5ElementName::initializeStatics()
   ELT_H5 = new nsHtml5ElementName(nsHtml5Atoms::h5, nsHtml5Atoms::h5, NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_H6 = new nsHtml5ElementName(nsHtml5Atoms::h6, nsHtml5Atoms::h6, NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_GT = new nsHtml5ElementName(nsHtml5Atoms::gt, nsHtml5Atoms::gt, NS_HTML5TREE_BUILDER_OTHER);
   ELT_HR = new nsHtml5ElementName(nsHtml5Atoms::hr, nsHtml5Atoms::hr, NS_HTML5TREE_BUILDER_HR | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_IN = new nsHtml5ElementName(nsHtml5Atoms::in, nsHtml5Atoms::in, NS_HTML5TREE_BUILDER_OTHER);
   ELT_LI = new nsHtml5ElementName(nsHtml5Atoms::li, nsHtml5Atoms::li, NS_HTML5TREE_BUILDER_LI | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_LN = new nsHtml5ElementName(nsHtml5Atoms::ln, nsHtml5Atoms::ln, NS_HTML5TREE_BUILDER_OTHER);
   ELT_LT = new nsHtml5ElementName(nsHtml5Atoms::lt, nsHtml5Atoms::lt, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_MI = new nsHtml5ElementName(nsHtml5Atoms::mi, nsHtml5Atoms::mi, NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT);
-  ELT_MN = new nsHtml5ElementName(nsHtml5Atoms::mn, nsHtml5Atoms::mn, NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT);
-  ELT_MO = new nsHtml5ElementName(nsHtml5Atoms::mo, nsHtml5Atoms::mo, NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT);
-  ELT_MS = new nsHtml5ElementName(nsHtml5Atoms::ms, nsHtml5Atoms::ms, NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT);
+  ELT_MI = new nsHtml5ElementName(nsHtml5Atoms::mi, nsHtml5Atoms::mi, NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT | NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
+  ELT_MN = new nsHtml5ElementName(nsHtml5Atoms::mn, nsHtml5Atoms::mn, NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT | NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
+  ELT_MO = new nsHtml5ElementName(nsHtml5Atoms::mo, nsHtml5Atoms::mo, NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT | NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
+  ELT_MS = new nsHtml5ElementName(nsHtml5Atoms::ms, nsHtml5Atoms::ms, NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT | NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
   ELT_OL = new nsHtml5ElementName(nsHtml5Atoms::ol, nsHtml5Atoms::ol, NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_OR = new nsHtml5ElementName(nsHtml5Atoms::or_, nsHtml5Atoms::or_, NS_HTML5TREE_BUILDER_OTHER);
   ELT_PI = new nsHtml5ElementName(nsHtml5Atoms::pi, nsHtml5Atoms::pi, NS_HTML5TREE_BUILDER_OTHER);
   ELT_RP = new nsHtml5ElementName(nsHtml5Atoms::rp, nsHtml5Atoms::rp, NS_HTML5TREE_BUILDER_RT_OR_RP);
   ELT_RT = new nsHtml5ElementName(nsHtml5Atoms::rt, nsHtml5Atoms::rt, NS_HTML5TREE_BUILDER_RT_OR_RP);
-  ELT_TD = new nsHtml5ElementName(nsHtml5Atoms::td, nsHtml5Atoms::td, NS_HTML5TREE_BUILDER_TD_OR_TH | NS_HTML5ELEMENT_NAME_SCOPING);
-  ELT_TH = new nsHtml5ElementName(nsHtml5Atoms::th, nsHtml5Atoms::th, NS_HTML5TREE_BUILDER_TD_OR_TH | NS_HTML5ELEMENT_NAME_SCOPING);
+  ELT_TD = new nsHtml5ElementName(nsHtml5Atoms::td, nsHtml5Atoms::td, NS_HTML5TREE_BUILDER_TD_OR_TH | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_SCOPING);
+  ELT_TH = new nsHtml5ElementName(nsHtml5Atoms::th, nsHtml5Atoms::th, NS_HTML5TREE_BUILDER_TD_OR_TH | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_SCOPING);
   ELT_TR = new nsHtml5ElementName(nsHtml5Atoms::tr, nsHtml5Atoms::tr, NS_HTML5TREE_BUILDER_TR | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_FOSTER_PARENTING);
   ELT_TT = new nsHtml5ElementName(nsHtml5Atoms::tt, nsHtml5Atoms::tt, NS_HTML5TREE_BUILDER_B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_UL = new nsHtml5ElementName(nsHtml5Atoms::ul, nsHtml5Atoms::ul, NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_AND = new nsHtml5ElementName(nsHtml5Atoms::and_, nsHtml5Atoms::and_, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ARG = new nsHtml5ElementName(nsHtml5Atoms::arg, nsHtml5Atoms::arg, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ABS = new nsHtml5ElementName(nsHtml5Atoms::abs, nsHtml5Atoms::abs, NS_HTML5TREE_BUILDER_OTHER);
   ELT_BIG = new nsHtml5ElementName(nsHtml5Atoms::big, nsHtml5Atoms::big, NS_HTML5TREE_BUILDER_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(nsHtml5Atoms::bdo, nsHtml5Atoms::bdo, NS_HTML5TREE_BUILDER_OTHER);
@@ -628,24 +627,24 @@ nsHtml5ElementName::initializeStatics()
   ELT_BODY = new nsHtml5ElementName(nsHtml5Atoms::body, nsHtml5Atoms::body, NS_HTML5TREE_BUILDER_BODY | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_CARD = new nsHtml5ElementName(nsHtml5Atoms::card, nsHtml5Atoms::card, NS_HTML5TREE_BUILDER_OTHER);
   ELT_CODE = new nsHtml5ElementName(nsHtml5Atoms::code, nsHtml5Atoms::code, NS_HTML5TREE_BUILDER_B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_CITE = new nsHtml5ElementName(nsHtml5Atoms::cite, nsHtml5Atoms::cite, NS_HTML5TREE_BUILDER_OTHER);
   ELT_CSCH = new nsHtml5ElementName(nsHtml5Atoms::csch, nsHtml5Atoms::csch, NS_HTML5TREE_BUILDER_OTHER);
   ELT_COSH = new nsHtml5ElementName(nsHtml5Atoms::cosh, nsHtml5Atoms::cosh, NS_HTML5TREE_BUILDER_OTHER);
   ELT_COTH = new nsHtml5ElementName(nsHtml5Atoms::coth, nsHtml5Atoms::coth, NS_HTML5TREE_BUILDER_OTHER);
   ELT_CURL = new nsHtml5ElementName(nsHtml5Atoms::curl, nsHtml5Atoms::curl, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_DESC = new nsHtml5ElementName(nsHtml5Atoms::desc, nsHtml5Atoms::desc, NS_HTML5TREE_BUILDER_FOREIGNOBJECT_OR_DESC);
+  ELT_DESC = new nsHtml5ElementName(nsHtml5Atoms::desc, nsHtml5Atoms::desc, NS_HTML5TREE_BUILDER_FOREIGNOBJECT_OR_DESC | NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG);
   ELT_DIFF = new nsHtml5ElementName(nsHtml5Atoms::diff, nsHtml5Atoms::diff, NS_HTML5TREE_BUILDER_OTHER);
   ELT_DEFS = new nsHtml5ElementName(nsHtml5Atoms::defs, nsHtml5Atoms::defs, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FORM = new nsHtml5ElementName(nsHtml5Atoms::form, nsHtml5Atoms::form, NS_HTML5TREE_BUILDER_FORM | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_FONT = new nsHtml5ElementName(nsHtml5Atoms::font, nsHtml5Atoms::font, NS_HTML5TREE_BUILDER_FONT);
   ELT_GRAD = new nsHtml5ElementName(nsHtml5Atoms::grad, nsHtml5Atoms::grad, NS_HTML5TREE_BUILDER_OTHER);
   ELT_HEAD = new nsHtml5ElementName(nsHtml5Atoms::head, nsHtml5Atoms::head, NS_HTML5TREE_BUILDER_HEAD | NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_HTML = new nsHtml5ElementName(nsHtml5Atoms::html, nsHtml5Atoms::html, NS_HTML5TREE_BUILDER_HTML | NS_HTML5ELEMENT_NAME_SCOPING);
+  ELT_HTML = new nsHtml5ElementName(nsHtml5Atoms::html, nsHtml5Atoms::html, NS_HTML5TREE_BUILDER_HTML | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_SCOPING);
   ELT_LINE = new nsHtml5ElementName(nsHtml5Atoms::line, nsHtml5Atoms::line, NS_HTML5TREE_BUILDER_OTHER);
   ELT_LINK = new nsHtml5ElementName(nsHtml5Atoms::link, nsHtml5Atoms::link, NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_LIST = new nsHtml5ElementName(nsHtml5Atoms::list, nsHtml5Atoms::list, NS_HTML5TREE_BUILDER_OTHER);
   ELT_META = new nsHtml5ElementName(nsHtml5Atoms::meta, nsHtml5Atoms::meta, NS_HTML5TREE_BUILDER_META | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_MSUB = new nsHtml5ElementName(nsHtml5Atoms::msub, nsHtml5Atoms::msub, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MODE = new nsHtml5ElementName(nsHtml5Atoms::mode, nsHtml5Atoms::mode, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MATH = new nsHtml5ElementName(nsHtml5Atoms::math, nsHtml5Atoms::math, NS_HTML5TREE_BUILDER_MATH);
   ELT_MARK = new nsHtml5ElementName(nsHtml5Atoms::mark, nsHtml5Atoms::mark, NS_HTML5TREE_BUILDER_OTHER);
@@ -693,40 +692,40 @@ nsHtml5ElementName::initializeStatics()
   ELT_LIMIT = new nsHtml5ElementName(nsHtml5Atoms::limit, nsHtml5Atoms::limit, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MFRAC = new nsHtml5ElementName(nsHtml5Atoms::mfrac, nsHtml5Atoms::mfrac, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MPATH = new nsHtml5ElementName(nsHtml5Atoms::mpath, nsHtml5Atoms::mpath, NS_HTML5TREE_BUILDER_OTHER);
   ELT_METER = new nsHtml5ElementName(nsHtml5Atoms::meter, nsHtml5Atoms::meter, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MOVER = new nsHtml5ElementName(nsHtml5Atoms::mover, nsHtml5Atoms::mover, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MINUS = new nsHtml5ElementName(nsHtml5Atoms::minus, nsHtml5Atoms::minus, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MROOT = new nsHtml5ElementName(nsHtml5Atoms::mroot, nsHtml5Atoms::mroot, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MSQRT = new nsHtml5ElementName(nsHtml5Atoms::msqrt, nsHtml5Atoms::msqrt, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_MTEXT = new nsHtml5ElementName(nsHtml5Atoms::mtext, nsHtml5Atoms::mtext, NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT);
+  ELT_MTEXT = new nsHtml5ElementName(nsHtml5Atoms::mtext, nsHtml5Atoms::mtext, NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT | NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
   ELT_NOTIN = new nsHtml5ElementName(nsHtml5Atoms::notin, nsHtml5Atoms::notin, NS_HTML5TREE_BUILDER_OTHER);
   ELT_PIECE = new nsHtml5ElementName(nsHtml5Atoms::piece, nsHtml5Atoms::piece, NS_HTML5TREE_BUILDER_OTHER);
   ELT_PARAM = new nsHtml5ElementName(nsHtml5Atoms::param, nsHtml5Atoms::param, NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_POWER = new nsHtml5ElementName(nsHtml5Atoms::power, nsHtml5Atoms::power, NS_HTML5TREE_BUILDER_OTHER);
   ELT_REALS = new nsHtml5ElementName(nsHtml5Atoms::reals, nsHtml5Atoms::reals, NS_HTML5TREE_BUILDER_OTHER);
   ELT_STYLE = new nsHtml5ElementName(nsHtml5Atoms::style, nsHtml5Atoms::style, NS_HTML5TREE_BUILDER_STYLE | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_SMALL = new nsHtml5ElementName(nsHtml5Atoms::small_, nsHtml5Atoms::small_, NS_HTML5TREE_BUILDER_B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_THEAD = new nsHtml5ElementName(nsHtml5Atoms::thead, nsHtml5Atoms::thead, NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_FOSTER_PARENTING);
-  ELT_TABLE = new nsHtml5ElementName(nsHtml5Atoms::table, nsHtml5Atoms::table, NS_HTML5TREE_BUILDER_TABLE | NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING);
-  ELT_TITLE = new nsHtml5ElementName(nsHtml5Atoms::title, nsHtml5Atoms::title, NS_HTML5TREE_BUILDER_TITLE | NS_HTML5ELEMENT_NAME_SPECIAL);
+  ELT_TABLE = new nsHtml5ElementName(nsHtml5Atoms::table, nsHtml5Atoms::table, NS_HTML5TREE_BUILDER_TABLE | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING);
+  ELT_TITLE = new nsHtml5ElementName(nsHtml5Atoms::title, nsHtml5Atoms::title, NS_HTML5TREE_BUILDER_TITLE | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG);
   ELT_TSPAN = new nsHtml5ElementName(nsHtml5Atoms::tspan, nsHtml5Atoms::tspan, NS_HTML5TREE_BUILDER_OTHER);
   ELT_TIMES = new nsHtml5ElementName(nsHtml5Atoms::times, nsHtml5Atoms::times, NS_HTML5TREE_BUILDER_OTHER);
   ELT_TFOOT = new nsHtml5ElementName(nsHtml5Atoms::tfoot, nsHtml5Atoms::tfoot, NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_FOSTER_PARENTING);
   ELT_TBODY = new nsHtml5ElementName(nsHtml5Atoms::tbody, nsHtml5Atoms::tbody, NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_FOSTER_PARENTING);
   ELT_UNION = new nsHtml5ElementName(nsHtml5Atoms::union_, nsHtml5Atoms::union_, NS_HTML5TREE_BUILDER_OTHER);
   ELT_VKERN = new nsHtml5ElementName(nsHtml5Atoms::vkern, nsHtml5Atoms::vkern, NS_HTML5TREE_BUILDER_OTHER);
   ELT_VIDEO = new nsHtml5ElementName(nsHtml5Atoms::video, nsHtml5Atoms::video, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ARCSEC = new nsHtml5ElementName(nsHtml5Atoms::arcsec, nsHtml5Atoms::arcsec, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ARCCSC = new nsHtml5ElementName(nsHtml5Atoms::arccsc, nsHtml5Atoms::arccsc, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ARCTAN = new nsHtml5ElementName(nsHtml5Atoms::arctan, nsHtml5Atoms::arctan, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ARCSIN = new nsHtml5ElementName(nsHtml5Atoms::arcsin, nsHtml5Atoms::arcsin, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ARCCOS = new nsHtml5ElementName(nsHtml5Atoms::arccos, nsHtml5Atoms::arccos, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_APPLET = new nsHtml5ElementName(nsHtml5Atoms::applet, nsHtml5Atoms::applet, NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET | NS_HTML5ELEMENT_NAME_SCOPING);
+  ELT_APPLET = new nsHtml5ElementName(nsHtml5Atoms::applet, nsHtml5Atoms::applet, NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_SCOPING);
   ELT_ARCCOT = new nsHtml5ElementName(nsHtml5Atoms::arccot, nsHtml5Atoms::arccot, NS_HTML5TREE_BUILDER_OTHER);
   ELT_APPROX = new nsHtml5ElementName(nsHtml5Atoms::approx, nsHtml5Atoms::approx, NS_HTML5TREE_BUILDER_OTHER);
   ELT_BUTTON = new nsHtml5ElementName(nsHtml5Atoms::button, nsHtml5Atoms::button, NS_HTML5TREE_BUILDER_BUTTON | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_CIRCLE = new nsHtml5ElementName(nsHtml5Atoms::circle, nsHtml5Atoms::circle, NS_HTML5TREE_BUILDER_OTHER);
   ELT_CENTER = new nsHtml5ElementName(nsHtml5Atoms::center, nsHtml5Atoms::center, NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_CURSOR = new nsHtml5ElementName(nsHtml5Atoms::cursor, nsHtml5Atoms::cursor, NS_HTML5TREE_BUILDER_OTHER);
   ELT_CANVAS = new nsHtml5ElementName(nsHtml5Atoms::canvas, nsHtml5Atoms::canvas, NS_HTML5TREE_BUILDER_OTHER);
   ELT_DIVIDE = new nsHtml5ElementName(nsHtml5Atoms::divide, nsHtml5Atoms::divide, NS_HTML5TREE_BUILDER_OTHER);
@@ -750,17 +749,17 @@ nsHtml5ElementName::initializeStatics()
   ELT_MGLYPH = new nsHtml5ElementName(nsHtml5Atoms::mglyph, nsHtml5Atoms::mglyph, NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK);
   ELT_MEDIAN = new nsHtml5ElementName(nsHtml5Atoms::median, nsHtml5Atoms::median, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MUNDER = new nsHtml5ElementName(nsHtml5Atoms::munder, nsHtml5Atoms::munder, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MARKER = new nsHtml5ElementName(nsHtml5Atoms::marker, nsHtml5Atoms::marker, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MERROR = new nsHtml5ElementName(nsHtml5Atoms::merror, nsHtml5Atoms::merror, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MOMENT = new nsHtml5ElementName(nsHtml5Atoms::moment, nsHtml5Atoms::moment, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MATRIX = new nsHtml5ElementName(nsHtml5Atoms::matrix, nsHtml5Atoms::matrix, NS_HTML5TREE_BUILDER_OTHER);
   ELT_OPTION = new nsHtml5ElementName(nsHtml5Atoms::option, nsHtml5Atoms::option, NS_HTML5TREE_BUILDER_OPTION);
-  ELT_OBJECT = new nsHtml5ElementName(nsHtml5Atoms::object, nsHtml5Atoms::object, NS_HTML5TREE_BUILDER_OBJECT | NS_HTML5ELEMENT_NAME_SCOPING);
+  ELT_OBJECT = new nsHtml5ElementName(nsHtml5Atoms::object, nsHtml5Atoms::object, NS_HTML5TREE_BUILDER_OBJECT | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_SCOPING);
   ELT_OUTPUT = new nsHtml5ElementName(nsHtml5Atoms::output, nsHtml5Atoms::output, NS_HTML5TREE_BUILDER_OUTPUT_OR_LABEL);
   ELT_PRIMES = new nsHtml5ElementName(nsHtml5Atoms::primes, nsHtml5Atoms::primes, NS_HTML5TREE_BUILDER_OTHER);
   ELT_SOURCE = new nsHtml5ElementName(nsHtml5Atoms::source, nsHtml5Atoms::source, NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE);
   ELT_STRIKE = new nsHtml5ElementName(nsHtml5Atoms::strike, nsHtml5Atoms::strike, NS_HTML5TREE_BUILDER_B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_STRONG = new nsHtml5ElementName(nsHtml5Atoms::strong, nsHtml5Atoms::strong, NS_HTML5TREE_BUILDER_B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_SWITCH = new nsHtml5ElementName(nsHtml5Atoms::switch_, nsHtml5Atoms::switch_, NS_HTML5TREE_BUILDER_OTHER);
   ELT_SYMBOL = new nsHtml5ElementName(nsHtml5Atoms::symbol, nsHtml5Atoms::symbol, NS_HTML5TREE_BUILDER_OTHER);
   ELT_SELECT = new nsHtml5ElementName(nsHtml5Atoms::select, nsHtml5Atoms::select, NS_HTML5TREE_BUILDER_SELECT | NS_HTML5ELEMENT_NAME_SPECIAL);
@@ -778,17 +777,17 @@ nsHtml5ElementName::initializeStatics()
   ELT_ARCCOTH = new nsHtml5ElementName(nsHtml5Atoms::arccoth, nsHtml5Atoms::arccoth, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ACRONYM = new nsHtml5ElementName(nsHtml5Atoms::acronym, nsHtml5Atoms::acronym, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ADDRESS = new nsHtml5ElementName(nsHtml5Atoms::address, nsHtml5Atoms::address, NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_NAV_OR_SECTION_OR_SUMMARY | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_BGSOUND = new nsHtml5ElementName(nsHtml5Atoms::bgsound, nsHtml5Atoms::bgsound, NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_COMMAND = new nsHtml5ElementName(nsHtml5Atoms::command, nsHtml5Atoms::command, NS_HTML5TREE_BUILDER_COMMAND | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_COMPOSE = new nsHtml5ElementName(nsHtml5Atoms::compose, nsHtml5Atoms::compose, NS_HTML5TREE_BUILDER_OTHER);
   ELT_CEILING = new nsHtml5ElementName(nsHtml5Atoms::ceiling, nsHtml5Atoms::ceiling, NS_HTML5TREE_BUILDER_OTHER);
   ELT_CSYMBOL = new nsHtml5ElementName(nsHtml5Atoms::csymbol, nsHtml5Atoms::csymbol, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_CAPTION = new nsHtml5ElementName(nsHtml5Atoms::caption, nsHtml5Atoms::caption, NS_HTML5TREE_BUILDER_CAPTION | NS_HTML5ELEMENT_NAME_SCOPING);
+  ELT_CAPTION = new nsHtml5ElementName(nsHtml5Atoms::caption, nsHtml5Atoms::caption, NS_HTML5TREE_BUILDER_CAPTION | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_SCOPING);
   ELT_DISCARD = new nsHtml5ElementName(nsHtml5Atoms::discard, nsHtml5Atoms::discard, NS_HTML5TREE_BUILDER_OTHER);
   ELT_DECLARE = new nsHtml5ElementName(nsHtml5Atoms::declare, nsHtml5Atoms::declare, NS_HTML5TREE_BUILDER_OTHER);
   ELT_DETAILS = new nsHtml5ElementName(nsHtml5Atoms::details, nsHtml5Atoms::details, NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_NAV_OR_SECTION_OR_SUMMARY | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_ELLIPSE = new nsHtml5ElementName(nsHtml5Atoms::ellipse, nsHtml5Atoms::ellipse, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FEFUNCA = new nsHtml5ElementName(nsHtml5Atoms::fefunca, nsHtml5Atoms::feFuncA, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FEFUNCB = new nsHtml5ElementName(nsHtml5Atoms::fefuncb, nsHtml5Atoms::feFuncB, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FEBLEND = new nsHtml5ElementName(nsHtml5Atoms::feblend, nsHtml5Atoms::feBlend, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FEFLOOD = new nsHtml5ElementName(nsHtml5Atoms::feflood, nsHtml5Atoms::feFlood, NS_HTML5TREE_BUILDER_OTHER);
@@ -799,17 +798,17 @@ nsHtml5ElementName::initializeStatics()
   ELT_HANDLER = new nsHtml5ElementName(nsHtml5Atoms::handler, nsHtml5Atoms::handler, NS_HTML5TREE_BUILDER_OTHER);
   ELT_INVERSE = new nsHtml5ElementName(nsHtml5Atoms::inverse, nsHtml5Atoms::inverse, NS_HTML5TREE_BUILDER_OTHER);
   ELT_IMPLIES = new nsHtml5ElementName(nsHtml5Atoms::implies, nsHtml5Atoms::implies, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ISINDEX = new nsHtml5ElementName(nsHtml5Atoms::isindex, nsHtml5Atoms::isindex, NS_HTML5TREE_BUILDER_ISINDEX | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_LOGBASE = new nsHtml5ElementName(nsHtml5Atoms::logbase, nsHtml5Atoms::logbase, NS_HTML5TREE_BUILDER_OTHER);
   ELT_LISTING = new nsHtml5ElementName(nsHtml5Atoms::listing, nsHtml5Atoms::listing, NS_HTML5TREE_BUILDER_PRE_OR_LISTING | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_MFENCED = new nsHtml5ElementName(nsHtml5Atoms::mfenced, nsHtml5Atoms::mfenced, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MPADDED = new nsHtml5ElementName(nsHtml5Atoms::mpadded, nsHtml5Atoms::mpadded, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_MARQUEE = new nsHtml5ElementName(nsHtml5Atoms::marquee, nsHtml5Atoms::marquee, NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET | NS_HTML5ELEMENT_NAME_SCOPING);
+  ELT_MARQUEE = new nsHtml5ElementName(nsHtml5Atoms::marquee, nsHtml5Atoms::marquee, NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_SCOPING);
   ELT_MACTION = new nsHtml5ElementName(nsHtml5Atoms::maction, nsHtml5Atoms::maction, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MSUBSUP = new nsHtml5ElementName(nsHtml5Atoms::msubsup, nsHtml5Atoms::msubsup, NS_HTML5TREE_BUILDER_OTHER);
   ELT_NOEMBED = new nsHtml5ElementName(nsHtml5Atoms::noembed, nsHtml5Atoms::noembed, NS_HTML5TREE_BUILDER_NOEMBED | NS_HTML5ELEMENT_NAME_SPECIAL);
   ELT_POLYGON = new nsHtml5ElementName(nsHtml5Atoms::polygon, nsHtml5Atoms::polygon, NS_HTML5TREE_BUILDER_OTHER);
   ELT_PATTERN = new nsHtml5ElementName(nsHtml5Atoms::pattern, nsHtml5Atoms::pattern, NS_HTML5TREE_BUILDER_OTHER);
   ELT_PRODUCT = new nsHtml5ElementName(nsHtml5Atoms::product, nsHtml5Atoms::product, NS_HTML5TREE_BUILDER_OTHER);
   ELT_SETDIFF = new nsHtml5ElementName(nsHtml5Atoms::setdiff, nsHtml5Atoms::setdiff, NS_HTML5TREE_BUILDER_OTHER);
   ELT_SECTION = new nsHtml5ElementName(nsHtml5Atoms::section, nsHtml5Atoms::section, NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_NAV_OR_SECTION_OR_SUMMARY | NS_HTML5ELEMENT_NAME_SPECIAL);
@@ -893,23 +892,23 @@ nsHtml5ElementName::initializeStatics()
   ELT_FETURBULENCE = new nsHtml5ElementName(nsHtml5Atoms::feturbulence, nsHtml5Atoms::feTurbulence, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FEPOINTLIGHT = new nsHtml5ElementName(nsHtml5Atoms::fepointlight, nsHtml5Atoms::fePointLight, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FEMORPHOLOGY = new nsHtml5ElementName(nsHtml5Atoms::femorphology, nsHtml5Atoms::feMorphology, NS_HTML5TREE_BUILDER_OTHER);
   ELT_OUTERPRODUCT = new nsHtml5ElementName(nsHtml5Atoms::outerproduct, nsHtml5Atoms::outerproduct, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ANIMATEMOTION = new nsHtml5ElementName(nsHtml5Atoms::animatemotion, nsHtml5Atoms::animateMotion, NS_HTML5TREE_BUILDER_OTHER);
   ELT_COLOR_PROFILE = new nsHtml5ElementName(nsHtml5Atoms::color_profile, nsHtml5Atoms::color_profile, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FONT_FACE_SRC = new nsHtml5ElementName(nsHtml5Atoms::font_face_src, nsHtml5Atoms::font_face_src, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FONT_FACE_URI = new nsHtml5ElementName(nsHtml5Atoms::font_face_uri, nsHtml5Atoms::font_face_uri, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_FOREIGNOBJECT = new nsHtml5ElementName(nsHtml5Atoms::foreignobject, nsHtml5Atoms::foreignObject, NS_HTML5TREE_BUILDER_FOREIGNOBJECT_OR_DESC);
+  ELT_FOREIGNOBJECT = new nsHtml5ElementName(nsHtml5Atoms::foreignobject, nsHtml5Atoms::foreignObject, NS_HTML5TREE_BUILDER_FOREIGNOBJECT_OR_DESC | NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG);
   ELT_FECOLORMATRIX = new nsHtml5ElementName(nsHtml5Atoms::fecolormatrix, nsHtml5Atoms::feColorMatrix, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MISSING_GLYPH = new nsHtml5ElementName(nsHtml5Atoms::missing_glyph, nsHtml5Atoms::missing_glyph, NS_HTML5TREE_BUILDER_OTHER);
   ELT_MMULTISCRIPTS = new nsHtml5ElementName(nsHtml5Atoms::mmultiscripts, nsHtml5Atoms::mmultiscripts, NS_HTML5TREE_BUILDER_OTHER);
   ELT_SCALARPRODUCT = new nsHtml5ElementName(nsHtml5Atoms::scalarproduct, nsHtml5Atoms::scalarproduct, NS_HTML5TREE_BUILDER_OTHER);
   ELT_VECTORPRODUCT = new nsHtml5ElementName(nsHtml5Atoms::vectorproduct, nsHtml5Atoms::vectorproduct, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_ANNOTATION_XML = new nsHtml5ElementName(nsHtml5Atoms::annotation_xml, nsHtml5Atoms::annotation_xml, NS_HTML5TREE_BUILDER_ANNOTATION_XML);
+  ELT_ANNOTATION_XML = new nsHtml5ElementName(nsHtml5Atoms::annotation_xml, nsHtml5Atoms::annotation_xml, NS_HTML5TREE_BUILDER_ANNOTATION_XML | NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
   ELT_DEFINITION_SRC = new nsHtml5ElementName(nsHtml5Atoms::definition_src, nsHtml5Atoms::definition_src, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FONT_FACE_NAME = new nsHtml5ElementName(nsHtml5Atoms::font_face_name, nsHtml5Atoms::font_face_name, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FEGAUSSIANBLUR = new nsHtml5ElementName(nsHtml5Atoms::fegaussianblur, nsHtml5Atoms::feGaussianBlur, NS_HTML5TREE_BUILDER_OTHER);
   ELT_FEDISTANTLIGHT = new nsHtml5ElementName(nsHtml5Atoms::fedistantlight, nsHtml5Atoms::feDistantLight, NS_HTML5TREE_BUILDER_OTHER);
   ELT_LINEARGRADIENT = new nsHtml5ElementName(nsHtml5Atoms::lineargradient, nsHtml5Atoms::linearGradient, NS_HTML5TREE_BUILDER_OTHER);
   ELT_NATURALNUMBERS = new nsHtml5ElementName(nsHtml5Atoms::naturalnumbers, nsHtml5Atoms::naturalnumbers, NS_HTML5TREE_BUILDER_OTHER);
   ELT_RADIALGRADIENT = new nsHtml5ElementName(nsHtml5Atoms::radialgradient, nsHtml5Atoms::radialGradient, NS_HTML5TREE_BUILDER_OTHER);
   ELT_ANIMATETRANSFORM = new nsHtml5ElementName(nsHtml5Atoms::animatetransform, nsHtml5Atoms::animateTransform, NS_HTML5TREE_BUILDER_OTHER);
--- a/parser/html/nsHtml5ElementName.h
+++ b/parser/html/nsHtml5ElementName.h
@@ -480,12 +480,15 @@ class nsHtml5ElementName
     static void releaseStatics();
 };
 
 #define NS_HTML5ELEMENT_NAME_GROUP_MASK 127
 #define NS_HTML5ELEMENT_NAME_CUSTOM (1 << 30)
 #define NS_HTML5ELEMENT_NAME_SPECIAL (1 << 29)
 #define NS_HTML5ELEMENT_NAME_FOSTER_PARENTING (1 << 28)
 #define NS_HTML5ELEMENT_NAME_SCOPING (1 << 27)
+#define NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG (1 << 26)
+#define NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML (1 << 25)
+#define NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT (1 << 24)
 
 
 #endif
 
--- a/parser/html/nsHtml5Portability.cpp
+++ b/parser/html/nsHtml5Portability.cpp
@@ -110,28 +110,16 @@ nsHtml5Portability::newLocalFromLocal(ns
 }
 
 void
 nsHtml5Portability::releaseString(nsString* str)
 {
   delete str;
 }
 
-// XXX useless code
-void
-nsHtml5Portability::retainLocal(nsIAtom* local)
-{
-}
-
-// XXX useless code
-void
-nsHtml5Portability::releaseLocal(nsIAtom* local)
-{
-}
-
 PRBool
 nsHtml5Portability::localEqualsBuffer(nsIAtom* local, PRUnichar* buf, PRInt32 offset, PRInt32 length)
 {
   return local->Equals(nsDependentSubstring(buf + offset, buf + offset + length));
 }
 
 PRBool
 nsHtml5Portability::lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string)
--- a/parser/html/nsHtml5Portability.h
+++ b/parser/html/nsHtml5Portability.h
@@ -66,18 +66,16 @@ class nsHtml5Portability
     static nsString* newStringFromBuffer(PRUnichar* buf, PRInt32 offset, PRInt32 length);
     static nsString* newEmptyString();
     static nsString* newStringFromLiteral(const char* literal);
     static nsString* newStringFromString(nsString* string);
     static jArray<PRUnichar,PRInt32> newCharArrayFromLocal(nsIAtom* local);
     static jArray<PRUnichar,PRInt32> newCharArrayFromString(nsString* string);
     static nsIAtom* newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner);
     static void releaseString(nsString* str);
-    static void retainLocal(nsIAtom* local);
-    static void releaseLocal(nsIAtom* local);
     static PRBool localEqualsBuffer(nsIAtom* local, PRUnichar* buf, PRInt32 offset, PRInt32 length);
     static PRBool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string);
     static PRBool lowerCaseLiteralEqualsIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string);
     static PRBool literalEqualsString(const char* literal, nsString* string);
     static PRBool stringEqualsString(nsString* one, nsString* other);
     static void initializeStatics();
     static void releaseStatics();
 };
--- a/parser/html/nsHtml5StackNode.cpp
+++ b/parser/html/nsHtml5StackNode.cpp
@@ -73,114 +73,125 @@ nsHtml5StackNode::isScoping()
 
 PRBool 
 nsHtml5StackNode::isSpecial()
 {
   return (flags & NS_HTML5ELEMENT_NAME_SPECIAL);
 }
 
 PRBool 
-nsHtml5StackNode::isScopingOrSpecial()
-{
-  return (flags & (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL));
-}
-
-PRBool 
 nsHtml5StackNode::isFosterParenting()
 {
   return (flags & NS_HTML5ELEMENT_NAME_FOSTER_PARENTING);
 }
 
 
 nsHtml5StackNode::nsHtml5StackNode(PRInt32 flags, PRInt32 ns, nsIAtom* name, nsIContent** node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
   : flags(flags),
     name(name),
     popName(popName),
     ns(ns),
     node(node),
     attributes(attributes),
     refcount(1)
 {
   MOZ_COUNT_CTOR(nsHtml5StackNode);
-  nsHtml5Portability::retainLocal(name);
-  nsHtml5Portability::retainLocal(popName);
-  ;
 }
 
 
-nsHtml5StackNode::nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent** node)
+nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node)
   : flags(elementName->getFlags()),
     name(elementName->name),
     popName(elementName->name),
-    ns(ns),
+    ns(kNameSpaceID_XHTML),
     node(node),
     attributes(nsnull),
     refcount(1)
 {
   MOZ_COUNT_CTOR(nsHtml5StackNode);
-  nsHtml5Portability::retainLocal(name);
-  nsHtml5Portability::retainLocal(popName);
-  ;
+
 }
 
 
-nsHtml5StackNode::nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent** node, nsHtml5HtmlAttributes* attributes)
+nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsHtml5HtmlAttributes* attributes)
   : flags(elementName->getFlags()),
     name(elementName->name),
     popName(elementName->name),
-    ns(ns),
+    ns(kNameSpaceID_XHTML),
     node(node),
     attributes(attributes),
     refcount(1)
 {
   MOZ_COUNT_CTOR(nsHtml5StackNode);
-  nsHtml5Portability::retainLocal(name);
-  nsHtml5Portability::retainLocal(popName);
-  ;
+
 }
 
 
-nsHtml5StackNode::nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName)
+nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName)
   : flags(elementName->getFlags()),
     name(elementName->name),
     popName(popName),
-    ns(ns),
+    ns(kNameSpaceID_XHTML),
+    node(node),
+    attributes(nsnull),
+    refcount(1)
+{
+  MOZ_COUNT_CTOR(nsHtml5StackNode);
+}
+
+
+nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContent** node)
+  : flags(prepareSvgFlags(elementName->getFlags())),
+    name(elementName->name),
+    popName(popName),
+    ns(kNameSpaceID_SVG),
     node(node),
     attributes(nsnull),
     refcount(1)
 {
   MOZ_COUNT_CTOR(nsHtml5StackNode);
-  nsHtml5Portability::retainLocal(name);
-  nsHtml5Portability::retainLocal(popName);
-  ;
 }
 
 
-nsHtml5StackNode::nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, PRBool scoping)
-  : flags((scoping ? (elementName->getFlags() | NS_HTML5ELEMENT_NAME_SCOPING) : (elementName->getFlags() & ~NS_HTML5ELEMENT_NAME_SCOPING)) & ~(NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_FOSTER_PARENTING)),
+nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, PRBool markAsIntegrationPoint)
+  : flags(prepareMathFlags(elementName->getFlags())),
     name(elementName->name),
     popName(popName),
-    ns(ns),
+    ns(kNameSpaceID_MathML),
     node(node),
     attributes(nsnull),
     refcount(1)
 {
   MOZ_COUNT_CTOR(nsHtml5StackNode);
-  nsHtml5Portability::retainLocal(name);
-  nsHtml5Portability::retainLocal(popName);
-  ;
+}
+
+PRInt32 
+nsHtml5StackNode::prepareSvgFlags(PRInt32 flags)
+{
+  flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
+  if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG)) {
+    flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT);
+  }
+  return flags;
+}
+
+PRInt32 
+nsHtml5StackNode::prepareMathFlags(PRInt32 flags)
+{
+  flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
+  if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML)) {
+    flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
+  }
+  return flags;
 }
 
 
 nsHtml5StackNode::~nsHtml5StackNode()
 {
   MOZ_COUNT_DTOR(nsHtml5StackNode);
-  nsHtml5Portability::releaseLocal(name);
-  nsHtml5Portability::releaseLocal(popName);
-  ;
   delete attributes;
 }
 
 void 
 nsHtml5StackNode::dropAttributes()
 {
   attributes = nsnull;
 }
--- a/parser/html/nsHtml5StackNode.h
+++ b/parser/html/nsHtml5StackNode.h
@@ -76,23 +76,27 @@ class nsHtml5StackNode
     inline PRInt32 getFlags()
     {
       return flags;
     }
 
     PRInt32 getGroup();
     PRBool isScoping();
     PRBool isSpecial();
-    PRBool isScopingOrSpecial();
     PRBool isFosterParenting();
     nsHtml5StackNode(PRInt32 flags, PRInt32 ns, nsIAtom* name, nsIContent** node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes);
-    nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent** node);
-    nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent** node, nsHtml5HtmlAttributes* attributes);
-    nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName);
-    nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, PRBool scoping);
+    nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node);
+    nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsHtml5HtmlAttributes* attributes);
+    nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName);
+    nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContent** node);
+    nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, PRBool markAsIntegrationPoint);
+  private:
+    static PRInt32 prepareSvgFlags(PRInt32 flags);
+    static PRInt32 prepareMathFlags(PRInt32 flags);
+  public:
     ~nsHtml5StackNode();
     void dropAttributes();
     void retain();
     void release();
     static void initializeStatics();
     static void releaseStatics();
 };
 
--- a/parser/html/nsHtml5StateSnapshot.cpp
+++ b/parser/html/nsHtml5StateSnapshot.cpp
@@ -160,17 +160,16 @@ nsHtml5StateSnapshot::~nsHtml5StateSnaps
   for (PRInt32 i = 0; i < stack.length; i++) {
     stack[i]->release();
   }
   for (PRInt32 i = 0; i < listOfActiveFormattingElements.length; i++) {
     if (listOfActiveFormattingElements[i]) {
       listOfActiveFormattingElements[i]->release();
     }
   }
-  ;
 }
 
 void
 nsHtml5StateSnapshot::initializeStatics()
 {
 }
 
 void
--- a/parser/html/nsHtml5Tokenizer.cpp
+++ b/parser/html/nsHtml5Tokenizer.cpp
@@ -3266,17 +3266,16 @@ nsHtml5Tokenizer::stateLoop(PRInt32 stat
   stateSave = state;
   returnStateSave = returnState;
   return pos;
 }
 
 void 
 nsHtml5Tokenizer::initDoctypeFields()
 {
-  nsHtml5Portability::releaseLocal(doctypeName);
   doctypeName = nsHtml5Atoms::emptystring;
   if (systemIdentifier) {
     nsHtml5Portability::releaseString(systemIdentifier);
     systemIdentifier = nsnull;
   }
   if (publicIdentifier) {
     nsHtml5Portability::releaseString(publicIdentifier);
     publicIdentifier = nsnull;
@@ -3436,17 +3435,16 @@ nsHtml5Tokenizer::eof()
         NS_HTML5_BREAK(eofloop);
       }
       case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE: {
         if (index < 6) {
 
           emitComment(0, 0);
         } else {
 
-          nsHtml5Portability::releaseLocal(doctypeName);
           doctypeName = nsHtml5Atoms::emptystring;
           if (systemIdentifier) {
             nsHtml5Portability::releaseString(systemIdentifier);
             systemIdentifier = nsnull;
           }
           if (publicIdentifier) {
             nsHtml5Portability::releaseString(publicIdentifier);
             publicIdentifier = nsnull;
@@ -3667,17 +3665,16 @@ nsHtml5Tokenizer::eof()
   return;
 }
 
 void 
 nsHtml5Tokenizer::emitDoctypeToken(PRInt32 pos)
 {
   cstart = pos + 1;
   tokenHandler->doctype(doctypeName, publicIdentifier, systemIdentifier, forceQuirks);
-  nsHtml5Portability::releaseLocal(doctypeName);
   doctypeName = nsnull;
   nsHtml5Portability::releaseString(publicIdentifier);
   publicIdentifier = nsnull;
   nsHtml5Portability::releaseString(systemIdentifier);
   systemIdentifier = nsnull;
 }
 
 PRBool 
@@ -3710,17 +3707,16 @@ nsHtml5Tokenizer::emitOrAppendOne(const 
   }
 }
 
 void 
 nsHtml5Tokenizer::end()
 {
   strBuf = nsnull;
   longStrBuf = nsnull;
-  nsHtml5Portability::releaseLocal(doctypeName);
   doctypeName = nsnull;
   if (systemIdentifier) {
     nsHtml5Portability::releaseString(systemIdentifier);
     systemIdentifier = nsnull;
   }
   if (publicIdentifier) {
     nsHtml5Portability::releaseString(publicIdentifier);
     publicIdentifier = nsnull;
@@ -3816,17 +3812,16 @@ nsHtml5Tokenizer::loadState(nsHtml5Token
   hi = other->hi;
   candidate = other->candidate;
   strBufMark = other->strBufMark;
   prevValue = other->prevValue;
   value = other->value;
   seenDigits = other->seenDigits;
   endTag = other->endTag;
   shouldSuspend = PR_FALSE;
-  nsHtml5Portability::releaseLocal(doctypeName);
   if (!other->doctypeName) {
     doctypeName = nsnull;
   } else {
     doctypeName = nsHtml5Portability::newLocalFromLocal(other->doctypeName, interner);
   }
   nsHtml5Portability::releaseString(systemIdentifier);
   if (!other->systemIdentifier) {
     systemIdentifier = nsnull;
--- a/parser/html/nsHtml5TreeBuilder.cpp
+++ b/parser/html/nsHtml5TreeBuilder.cpp
@@ -73,54 +73,47 @@ nsHtml5TreeBuilder::startTokenization(ns
 {
   tokenizer = self;
   stack = jArray<nsHtml5StackNode*,PRInt32>::newJArray(64);
   listOfActiveFormattingElements = jArray<nsHtml5StackNode*,PRInt32>::newJArray(64);
   needToDropLF = PR_FALSE;
   originalMode = NS_HTML5TREE_BUILDER_INITIAL;
   currentPtr = -1;
   listPtr = -1;
-  ;
   formPointer = nsnull;
-  ;
   headPointer = nsnull;
-  ;
   deepTreeSurrogateParent = nsnull;
   start(fragment);
   charBufferLen = 0;
   charBuffer = jArray<PRUnichar,PRInt32>::newJArray(1024);
   framesetOk = PR_TRUE;
   if (fragment) {
     nsIContent** elt;
     if (contextNode) {
       elt = contextNode;
-      ;
     } else {
       elt = createHtmlElementSetAsRoot(tokenizer->emptyAttributes());
     }
-    nsHtml5StackNode* node = new nsHtml5StackNode(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_HTML, elt);
+    nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HTML, elt);
     currentPtr++;
     stack[currentPtr] = node;
     resetTheInsertionMode();
     if (nsHtml5Atoms::title == contextName || nsHtml5Atoms::textarea == contextName) {
       tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RCDATA, contextName);
     } else if (nsHtml5Atoms::style == contextName || nsHtml5Atoms::xmp == contextName || nsHtml5Atoms::iframe == contextName || nsHtml5Atoms::noembed == contextName || nsHtml5Atoms::noframes == contextName || (scriptingEnabled && nsHtml5Atoms::noscript == contextName)) {
       tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, contextName);
     } else if (nsHtml5Atoms::plaintext == contextName) {
       tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_PLAINTEXT, contextName);
     } else if (nsHtml5Atoms::script == contextName) {
       tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, contextName);
     } else {
       tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_DATA, contextName);
     }
-    nsHtml5Portability::releaseLocal(contextName);
     contextName = nsnull;
-    ;
     contextNode = nsnull;
-    ;
   } else {
     mode = NS_HTML5TREE_BUILDER_INITIAL;
     inForeign = PR_FALSE;
   }
 }
 
 void 
 nsHtml5TreeBuilder::doctype(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, PRBool forceQuirks)
@@ -532,21 +525,18 @@ nsHtml5TreeBuilder::eof()
   if (!fragment) {
     popOnEof();
   }
 }
 
 void 
 nsHtml5TreeBuilder::endTokenization()
 {
-  ;
   formPointer = nsnull;
-  ;
   headPointer = nsnull;
-  ;
   deepTreeSurrogateParent = nsnull;
   if (stack) {
     while (currentPtr > -1) {
       stack[currentPtr]->release();
       currentPtr--;
     }
     stack = nsnull;
   }
@@ -618,52 +608,52 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
               }
               NS_HTML5_CONTINUE(starttagloop);
             }
           }
           default: {
             if (kNameSpaceID_SVG == currNs) {
               attributes->adjustForSvg();
               if (selfClosing) {
-                appendVoidElementToCurrentMayFosterCamelCase(currNs, elementName, attributes);
+                appendVoidElementToCurrentMayFosterSVG(elementName, attributes);
                 selfClosing = PR_FALSE;
               } else {
-                appendToCurrentNodeAndPushElementMayFosterCamelCase(currNs, elementName, attributes);
+                appendToCurrentNodeAndPushElementMayFosterSVG(elementName, attributes);
               }
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             } else {
               attributes->adjustForMath();
               if (selfClosing) {
-                appendVoidElementToCurrentMayFoster(currNs, elementName, attributes);
+                appendVoidElementToCurrentMayFosterMathML(elementName, attributes);
                 selfClosing = PR_FALSE;
               } else {
-                appendToCurrentNodeAndPushElementMayFosterNoScoping(currNs, elementName, attributes);
+                appendToCurrentNodeAndPushElementMayFosterMathML(elementName, attributes);
               }
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
           }
         }
       }
     }
     switch(mode) {
       case NS_HTML5TREE_BUILDER_IN_TABLE_BODY: {
         switch(group) {
           case NS_HTML5TREE_BUILDER_TR: {
             clearStackBackTo(findLastInTableScopeOrRootTbodyTheadTfoot());
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElement(elementName, attributes);
             mode = NS_HTML5TREE_BUILDER_IN_ROW;
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_TD_OR_TH: {
 
             clearStackBackTo(findLastInTableScopeOrRootTbodyTheadTfoot());
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_TR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
+            appendToCurrentNodeAndPushElement(nsHtml5ElementName::ELT_TR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
             mode = NS_HTML5TREE_BUILDER_IN_ROW;
             continue;
           }
           case NS_HTML5TREE_BUILDER_CAPTION:
           case NS_HTML5TREE_BUILDER_COL:
           case NS_HTML5TREE_BUILDER_COLGROUP:
           case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT: {
             eltPos = findLastInTableScopeOrRootTbodyTheadTfoot();
@@ -680,17 +670,17 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
           default:
             ; // fall through
         }
       }
       case NS_HTML5TREE_BUILDER_IN_ROW: {
         switch(group) {
           case NS_HTML5TREE_BUILDER_TD_OR_TH: {
             clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TR));
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElement(elementName, attributes);
             mode = NS_HTML5TREE_BUILDER_IN_CELL;
             insertMarker();
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_CAPTION:
           case NS_HTML5TREE_BUILDER_COL:
           case NS_HTML5TREE_BUILDER_COLGROUP:
@@ -712,45 +702,45 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
         }
       }
       case NS_HTML5TREE_BUILDER_IN_TABLE: {
         for (; ; ) {
           switch(group) {
             case NS_HTML5TREE_BUILDER_CAPTION: {
               clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE));
               insertMarker();
-              appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElement(elementName, attributes);
               mode = NS_HTML5TREE_BUILDER_IN_CAPTION;
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_COLGROUP: {
               clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE));
-              appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElement(elementName, attributes);
               mode = NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP;
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_COL: {
               clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE));
-              appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_COLGROUP, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
+              appendToCurrentNodeAndPushElement(nsHtml5ElementName::ELT_COLGROUP, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
               mode = NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP;
               NS_HTML5_CONTINUE(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT: {
               clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE));
-              appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElement(elementName, attributes);
               mode = NS_HTML5TREE_BUILDER_IN_TABLE_BODY;
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_TR:
             case NS_HTML5TREE_BUILDER_TD_OR_TH: {
               clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE));
-              appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_TBODY, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
+              appendToCurrentNodeAndPushElement(nsHtml5ElementName::ELT_TBODY, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
               mode = NS_HTML5TREE_BUILDER_IN_TABLE_BODY;
               NS_HTML5_CONTINUE(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_TABLE: {
 
               eltPos = findLastInTableScope(name);
               if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
 
@@ -760,36 +750,36 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
 
               while (currentPtr >= eltPos) {
                 pop();
               }
               resetTheInsertionMode();
               NS_HTML5_CONTINUE(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_SCRIPT: {
-              appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElement(elementName, attributes);
               originalMode = mode;
               mode = NS_HTML5TREE_BUILDER_TEXT;
               tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, elementName);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_STYLE: {
-              appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElement(elementName, attributes);
               originalMode = mode;
               mode = NS_HTML5TREE_BUILDER_TEXT;
               tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_INPUT: {
               if (!nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("hidden", attributes->getValue(nsHtml5AttributeName::ATTR_TYPE))) {
                 NS_HTML5_BREAK(intableloop);
               }
-              appendVoidElementToCurrent(kNameSpaceID_XHTML, name, attributes, formPointer);
+              appendVoidElementToCurrent(name, attributes, formPointer);
               selfClosing = PR_FALSE;
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_FORM: {
               if (formPointer) {
 
                 NS_HTML5_BREAK(starttagloop);
@@ -864,17 +854,17 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
 
                 NS_HTML5_BREAK(starttagloop);
               } else {
 
                 detachFromParent(stack[1]->node);
                 while (currentPtr > 0) {
                   pop();
                 }
-                appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+                appendToCurrentNodeAndPushElement(elementName, attributes);
                 mode = NS_HTML5TREE_BUILDER_IN_FRAMESET;
                 attributes = nsnull;
                 NS_HTML5_BREAK(starttagloop);
               }
             } else {
 
               NS_HTML5_BREAK(starttagloop);
             }
@@ -932,39 +922,39 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
               }
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_P:
             case NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU:
             case NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL:
             case NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_NAV_OR_SECTION_OR_SUMMARY: {
               implicitlyCloseP();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6: {
               implicitlyCloseP();
               if (stack[currentPtr]->getGroup() == NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6) {
 
                 pop();
               }
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_FIELDSET: {
               implicitlyCloseP();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes, formPointer);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_PRE_OR_LISTING: {
               implicitlyCloseP();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               needToDropLF = PR_TRUE;
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_FORM: {
               if (formPointer) {
 
                 NS_HTML5_BREAK(starttagloop);
@@ -988,23 +978,23 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
                   }
                   break;
                 } else if (node->isScoping() || (node->isSpecial() && node->name != nsHtml5Atoms::p && node->name != nsHtml5Atoms::address && node->name != nsHtml5Atoms::div)) {
                   break;
                 }
                 eltPos--;
               }
               implicitlyCloseP();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_PLAINTEXT: {
               implicitlyCloseP();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_PLAINTEXT, elementName);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_A: {
               PRInt32 activeAPos = findInListOfActiveFormattingElementsContainsBetweenEndAndLastMarker(nsHtml5Atoms::a);
               if (activeAPos != -1) {
 
@@ -1014,123 +1004,123 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
                 removeFromStack(activeA);
                 activeAPos = findInListOfActiveFormattingElements(activeA);
                 if (activeAPos != -1) {
                   removeFromListOfActiveFormattingElements(activeAPos);
                 }
                 activeA->release();
               }
               reconstructTheActiveFormattingElements();
-              appendToCurrentNodeAndPushFormattingElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushFormattingElementMayFoster(elementName, attributes);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U:
             case NS_HTML5TREE_BUILDER_FONT: {
               reconstructTheActiveFormattingElements();
               maybeForgetEarlierDuplicateFormattingElement(elementName->name, attributes);
-              appendToCurrentNodeAndPushFormattingElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushFormattingElementMayFoster(elementName, attributes);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_NOBR: {
               reconstructTheActiveFormattingElements();
               if (NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK != findLastInScope(nsHtml5Atoms::nobr)) {
 
                 adoptionAgencyEndTag(nsHtml5Atoms::nobr);
               }
-              appendToCurrentNodeAndPushFormattingElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushFormattingElementMayFoster(elementName, attributes);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_BUTTON: {
               eltPos = findLastInScope(name);
               if (eltPos != NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
 
                 generateImpliedEndTags();
 
                 while (currentPtr >= eltPos) {
                   pop();
                 }
                 NS_HTML5_CONTINUE(starttagloop);
               } else {
                 reconstructTheActiveFormattingElements();
-                appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes, formPointer);
+                appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
                 attributes = nsnull;
                 NS_HTML5_BREAK(starttagloop);
               }
             }
             case NS_HTML5TREE_BUILDER_OBJECT: {
               reconstructTheActiveFormattingElements();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes, formPointer);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
               insertMarker();
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET: {
               reconstructTheActiveFormattingElements();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               insertMarker();
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_TABLE: {
               if (!quirks) {
                 implicitlyCloseP();
               }
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               mode = NS_HTML5TREE_BUILDER_IN_TABLE;
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_BR:
             case NS_HTML5TREE_BUILDER_EMBED_OR_IMG:
             case NS_HTML5TREE_BUILDER_AREA_OR_WBR: {
               reconstructTheActiveFormattingElements();
             }
             case NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE: {
-              appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendVoidElementToCurrentMayFoster(elementName, attributes);
               selfClosing = PR_FALSE;
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_HR: {
               implicitlyCloseP();
-              appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendVoidElementToCurrentMayFoster(elementName, attributes);
               selfClosing = PR_FALSE;
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_IMAGE: {
 
               elementName = nsHtml5ElementName::ELT_IMG;
               NS_HTML5_CONTINUE(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_KEYGEN:
             case NS_HTML5TREE_BUILDER_INPUT: {
               reconstructTheActiveFormattingElements();
-              appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, name, attributes, formPointer);
+              appendVoidElementToCurrentMayFoster(name, attributes, formPointer);
               selfClosing = PR_FALSE;
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_ISINDEX: {
 
               if (formPointer) {
                 NS_HTML5_BREAK(starttagloop);
               }
               implicitlyCloseP();
               nsHtml5HtmlAttributes* formAttrs = new nsHtml5HtmlAttributes(0);
               PRInt32 actionIndex = attributes->getIndex(nsHtml5AttributeName::ATTR_ACTION);
               if (actionIndex > -1) {
                 formAttrs->addAttribute(nsHtml5AttributeName::ATTR_ACTION, attributes->getValue(actionIndex));
               }
               appendToCurrentNodeAndPushFormElementMayFoster(formAttrs);
-              appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_HR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_LABEL, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
+              appendVoidElementToCurrentMayFoster(nsHtml5ElementName::ELT_HR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
+              appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName::ELT_LABEL, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
               PRInt32 promptIndex = attributes->getIndex(nsHtml5AttributeName::ATTR_PROMPT);
               if (promptIndex > -1) {
                 autoJArray<PRUnichar,PRInt32> prompt = nsHtml5Portability::newCharArrayFromString(attributes->getValue(promptIndex));
                 appendCharacters(stack[currentPtr]->node, prompt, 0, prompt.length);
               } else {
                 appendIsindexPrompt(stack[currentPtr]->node);
               }
               nsHtml5HtmlAttributes* inputAttributes = new nsHtml5HtmlAttributes(0);
@@ -1139,64 +1129,64 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
                 nsHtml5AttributeName* attributeQName = attributes->getAttributeName(i);
                 if (nsHtml5AttributeName::ATTR_NAME == attributeQName || nsHtml5AttributeName::ATTR_PROMPT == attributeQName) {
                   attributes->releaseValue(i);
                 } else if (nsHtml5AttributeName::ATTR_ACTION != attributeQName) {
                   inputAttributes->addAttribute(attributeQName, attributes->getValue(i));
                 }
               }
               attributes->clearWithoutReleasingContents();
-              appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, nsHtml5Atoms::input, inputAttributes, formPointer);
+              appendVoidElementToCurrentMayFoster(nsHtml5Atoms::input, inputAttributes, formPointer);
               pop();
-              appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_HR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
+              appendVoidElementToCurrentMayFoster(nsHtml5ElementName::ELT_HR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
               pop();
               selfClosing = PR_FALSE;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_TEXTAREA: {
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes, formPointer);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
               tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RCDATA, elementName);
               originalMode = mode;
               mode = NS_HTML5TREE_BUILDER_TEXT;
               needToDropLF = PR_TRUE;
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_XMP: {
               implicitlyCloseP();
               reconstructTheActiveFormattingElements();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               originalMode = mode;
               mode = NS_HTML5TREE_BUILDER_TEXT;
               tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_NOSCRIPT: {
               if (!scriptingEnabled) {
                 reconstructTheActiveFormattingElements();
-                appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+                appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
                 attributes = nsnull;
                 NS_HTML5_BREAK(starttagloop);
               } else {
               }
             }
             case NS_HTML5TREE_BUILDER_NOFRAMES:
             case NS_HTML5TREE_BUILDER_IFRAME:
             case NS_HTML5TREE_BUILDER_NOEMBED: {
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               originalMode = mode;
               mode = NS_HTML5TREE_BUILDER_TEXT;
               tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_SELECT: {
               reconstructTheActiveFormattingElements();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes, formPointer);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
               switch(mode) {
                 case NS_HTML5TREE_BUILDER_IN_TABLE:
                 case NS_HTML5TREE_BUILDER_IN_CAPTION:
                 case NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP:
                 case NS_HTML5TREE_BUILDER_IN_TABLE_BODY:
                 case NS_HTML5TREE_BUILDER_IN_ROW:
                 case NS_HTML5TREE_BUILDER_IN_CELL: {
                   mode = NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE;
@@ -1229,56 +1219,56 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
                       NS_HTML5_BREAK(optionendtagloop);
                     }
                     eltPos--;
                   }
                 }
                 optionendtagloop_end: ;
               }
               reconstructTheActiveFormattingElements();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_RT_OR_RP: {
               eltPos = findLastInScope(nsHtml5Atoms::ruby);
               if (eltPos != NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
                 generateImpliedEndTags();
               }
               if (eltPos != currentPtr) {
 
                 while (currentPtr > eltPos) {
                   pop();
                 }
               }
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_MATH: {
               reconstructTheActiveFormattingElements();
               attributes->adjustForMath();
               if (selfClosing) {
-                appendVoidElementToCurrentMayFoster(kNameSpaceID_MathML, elementName, attributes);
+                appendVoidElementToCurrentMayFosterMathML(elementName, attributes);
                 selfClosing = PR_FALSE;
               } else {
-                appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_MathML, elementName, attributes);
+                appendToCurrentNodeAndPushElementMayFosterMathML(elementName, attributes);
                 inForeign = PR_TRUE;
               }
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_SVG: {
               reconstructTheActiveFormattingElements();
               attributes->adjustForSvg();
               if (selfClosing) {
-                appendVoidElementToCurrentMayFosterCamelCase(kNameSpaceID_SVG, elementName, attributes);
+                appendVoidElementToCurrentMayFosterSVG(elementName, attributes);
                 selfClosing = PR_FALSE;
               } else {
-                appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_SVG, elementName, attributes);
+                appendToCurrentNodeAndPushElementMayFosterSVG(elementName, attributes);
                 inForeign = PR_TRUE;
               }
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_CAPTION:
             case NS_HTML5TREE_BUILDER_COL:
             case NS_HTML5TREE_BUILDER_COLGROUP:
@@ -1288,23 +1278,23 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
             case NS_HTML5TREE_BUILDER_FRAME:
             case NS_HTML5TREE_BUILDER_FRAMESET:
             case NS_HTML5TREE_BUILDER_HEAD: {
 
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_OUTPUT_OR_LABEL: {
               reconstructTheActiveFormattingElements();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes, formPointer);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             default: {
               reconstructTheActiveFormattingElements();
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
           }
         }
         inbodyloop_end: ;
       }
       case NS_HTML5TREE_BUILDER_IN_HEAD: {
@@ -1315,57 +1305,57 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
               if (!fragment) {
                 addAttributesToHtml(attributes);
                 attributes = nsnull;
               }
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_BASE:
             case NS_HTML5TREE_BUILDER_COMMAND: {
-              appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendVoidElementToCurrentMayFoster(elementName, attributes);
               selfClosing = PR_FALSE;
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_META:
             case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND: {
               NS_HTML5_BREAK(inheadloop);
             }
             case NS_HTML5TREE_BUILDER_TITLE: {
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               originalMode = mode;
               mode = NS_HTML5TREE_BUILDER_TEXT;
               tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RCDATA, elementName);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_NOSCRIPT: {
               if (scriptingEnabled) {
-                appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+                appendToCurrentNodeAndPushElement(elementName, attributes);
                 originalMode = mode;
                 mode = NS_HTML5TREE_BUILDER_TEXT;
                 tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
               } else {
-                appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+                appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
                 mode = NS_HTML5TREE_BUILDER_IN_HEAD_NOSCRIPT;
               }
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_SCRIPT: {
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               originalMode = mode;
               mode = NS_HTML5TREE_BUILDER_TEXT;
               tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, elementName);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_STYLE:
             case NS_HTML5TREE_BUILDER_NOFRAMES: {
-              appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+              appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               originalMode = mode;
               mode = NS_HTML5TREE_BUILDER_TEXT;
               tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
               attributes = nsnull;
               NS_HTML5_BREAK(starttagloop);
             }
             case NS_HTML5TREE_BUILDER_HEAD: {
 
@@ -1386,31 +1376,31 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
 
             if (!fragment) {
               addAttributesToHtml(attributes);
               attributes = nsnull;
             }
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND: {
-            appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+            appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = PR_FALSE;
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_META: {
             checkMetaCharset(attributes);
-            appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+            appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = PR_FALSE;
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_STYLE:
           case NS_HTML5TREE_BUILDER_NOFRAMES: {
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElement(elementName, attributes);
             originalMode = mode;
             mode = NS_HTML5TREE_BUILDER_TEXT;
             tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_HEAD: {
 
@@ -1434,17 +1424,17 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
 
             if (!fragment) {
               addAttributesToHtml(attributes);
               attributes = nsnull;
             }
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_COL: {
-            appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+            appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = PR_FALSE;
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           default: {
             if (!currentPtr) {
 
 
@@ -1488,28 +1478,28 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
               attributes = nsnull;
             }
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_OPTION: {
             if (isCurrent(nsHtml5Atoms::option)) {
               pop();
             }
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElement(elementName, attributes);
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_OPTGROUP: {
             if (isCurrent(nsHtml5Atoms::option)) {
               pop();
             }
             if (isCurrent(nsHtml5Atoms::optgroup)) {
               pop();
             }
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElement(elementName, attributes);
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_SELECT: {
 
             eltPos = findLastInTableScope(name);
             if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
 
@@ -1534,17 +1524,17 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
             }
             while (currentPtr >= eltPos) {
               pop();
             }
             resetTheInsertionMode();
             continue;
           }
           case NS_HTML5TREE_BUILDER_SCRIPT: {
-            appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
             originalMode = mode;
             mode = NS_HTML5TREE_BUILDER_TEXT;
             tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, elementName);
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           default: {
 
@@ -1567,22 +1557,22 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
             mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
             continue;
           }
         }
       }
       case NS_HTML5TREE_BUILDER_IN_FRAMESET: {
         switch(group) {
           case NS_HTML5TREE_BUILDER_FRAMESET: {
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElement(elementName, attributes);
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_FRAME: {
-            appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+            appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = PR_FALSE;
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           default:
             ; // fall through
         }
       }
@@ -1592,17 +1582,17 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
 
             if (!fragment) {
               addAttributesToHtml(attributes);
               attributes = nsnull;
             }
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_NOFRAMES: {
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElement(elementName, attributes);
             originalMode = mode;
             mode = NS_HTML5TREE_BUILDER_TEXT;
             tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           default: {
 
@@ -1674,74 +1664,74 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
               appendToCurrentNodeAndPushBodyElement(attributes);
             }
             framesetOk = PR_FALSE;
             mode = NS_HTML5TREE_BUILDER_IN_BODY;
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_FRAMESET: {
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElement(elementName, attributes);
             mode = NS_HTML5TREE_BUILDER_IN_FRAMESET;
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_BASE: {
 
             pushHeadPointerOntoStack();
-            appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+            appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = PR_FALSE;
             pop();
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND: {
 
             pushHeadPointerOntoStack();
-            appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+            appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = PR_FALSE;
             pop();
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_META: {
 
             checkMetaCharset(attributes);
             pushHeadPointerOntoStack();
-            appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+            appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = PR_FALSE;
             pop();
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_SCRIPT: {
 
             pushHeadPointerOntoStack();
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElement(elementName, attributes);
             originalMode = mode;
             mode = NS_HTML5TREE_BUILDER_TEXT;
             tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, elementName);
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_STYLE:
           case NS_HTML5TREE_BUILDER_NOFRAMES: {
 
             pushHeadPointerOntoStack();
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElement(elementName, attributes);
             originalMode = mode;
             mode = NS_HTML5TREE_BUILDER_TEXT;
             tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_TITLE: {
 
             pushHeadPointerOntoStack();
-            appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElement(elementName, attributes);
             originalMode = mode;
             mode = NS_HTML5TREE_BUILDER_TEXT;
             tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RCDATA, elementName);
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_HEAD: {
 
@@ -1778,17 +1768,17 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
 
             if (!fragment) {
               addAttributesToHtml(attributes);
               attributes = nsnull;
             }
             NS_HTML5_BREAK(starttagloop);
           }
           case NS_HTML5TREE_BUILDER_NOFRAMES: {
-            appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes);
+            appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
             originalMode = mode;
             mode = NS_HTML5TREE_BUILDER_TEXT;
             tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, elementName);
             attributes = nsnull;
             NS_HTML5_BREAK(starttagloop);
           }
           default: {
 
@@ -2321,17 +2311,16 @@ nsHtml5TreeBuilder::endTag(nsHtml5Elemen
             }
             NS_HTML5_BREAK(endtagloop);
           }
           case NS_HTML5TREE_BUILDER_FORM: {
             if (!formPointer) {
 
               NS_HTML5_BREAK(endtagloop);
             }
-            ;
             formPointer = nsnull;
             eltPos = findLastInScope(name);
             if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
 
               NS_HTML5_BREAK(endtagloop);
             }
             generateImpliedEndTags();
 
@@ -2344,17 +2333,17 @@ nsHtml5TreeBuilder::endTag(nsHtml5Elemen
 
               if (inForeign) {
 
                 while (stack[currentPtr]->ns != kNameSpaceID_XHTML) {
                   pop();
                 }
                 inForeign = PR_FALSE;
               }
-              appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
+              appendVoidElementToCurrentMayFoster(elementName, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
               NS_HTML5_BREAK(endtagloop);
             }
             generateImpliedEndTagsExceptFor(nsHtml5Atoms::p);
 
 
             while (currentPtr >= eltPos) {
               pop();
             }
@@ -2411,17 +2400,17 @@ nsHtml5TreeBuilder::endTag(nsHtml5Elemen
             if (inForeign) {
 
               while (stack[currentPtr]->ns != kNameSpaceID_XHTML) {
                 pop();
               }
               inForeign = PR_FALSE;
             }
             reconstructTheActiveFormattingElements();
-            appendVoidElementToCurrentMayFoster(kNameSpaceID_XHTML, elementName, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
+            appendVoidElementToCurrentMayFoster(elementName, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
             NS_HTML5_BREAK(endtagloop);
           }
           case NS_HTML5TREE_BUILDER_AREA_OR_WBR:
           case NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE:
           case NS_HTML5TREE_BUILDER_EMBED_OR_IMG:
           case NS_HTML5TREE_BUILDER_IMAGE:
           case NS_HTML5TREE_BUILDER_INPUT:
           case NS_HTML5TREE_BUILDER_KEYGEN:
@@ -2461,17 +2450,17 @@ nsHtml5TreeBuilder::endTag(nsHtml5Elemen
               nsHtml5StackNode* node = stack[eltPos];
               if (node->name == name) {
                 generateImpliedEndTags();
 
                 while (currentPtr >= eltPos) {
                   pop();
                 }
                 NS_HTML5_BREAK(endtagloop);
-              } else if (node->isScopingOrSpecial()) {
+              } else if (node->isSpecial()) {
 
                 NS_HTML5_BREAK(endtagloop);
               }
               eltPos--;
             }
           }
         }
       }
@@ -3217,17 +3206,17 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag
     if (!inScope) {
 
       return PR_TRUE;
     }
 
     PRInt32 furthestBlockPos = formattingEltStackPos + 1;
     while (furthestBlockPos <= currentPtr) {
       nsHtml5StackNode* node = stack[furthestBlockPos];
-      if (node->isScopingOrSpecial()) {
+      if (node->isSpecial()) {
         break;
       }
       furthestBlockPos++;
     }
     if (furthestBlockPos > currentPtr) {
       while (currentPtr >= formattingEltStackPos) {
         pop();
       }
@@ -3263,17 +3252,16 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag
       nsHtml5StackNode* newNode = new nsHtml5StackNode(node->getFlags(), node->ns, node->name, clone, node->popName, node->attributes);
       node->dropAttributes();
       stack[nodePos] = newNode;
       newNode->retain();
       listOfActiveFormattingElements[nodeListPos] = newNode;
       node->release();
       node->release();
       node = newNode;
-      ;
       detachFromParent(lastNode->node);
       appendElement(lastNode->node, node->node);
       lastNode = node;
     }
     if (commonAncestor->isFosterParenting()) {
 
       detachFromParent(lastNode->node);
       insertIntoFosterParent(lastNode->node);
@@ -3286,17 +3274,16 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag
     formattingElt->dropAttributes();
     appendChildrenToNewParent(furthestBlock->node, clone);
     appendElement(clone, furthestBlock->node);
     removeFromListOfActiveFormattingElements(formattingEltListPos);
     insertIntoListOfActiveFormattingElements(formattingClone, bookmark);
 
     removeFromStack(formattingEltStackPos);
     insertIntoStack(formattingClone, furthestBlockPos);
-    ;
   }
   return PR_TRUE;
 }
 
 void 
 nsHtml5TreeBuilder::insertIntoStack(nsHtml5StackNode* node, PRInt32 position)
 {
 
@@ -3410,17 +3397,17 @@ nsHtml5TreeBuilder::addAttributesToHtml(
 
 void 
 nsHtml5TreeBuilder::pushHeadPointerOntoStack()
 {
 
 
 
 
-  silentPush(new nsHtml5StackNode(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_HEAD, headPointer));
+  silentPush(new nsHtml5StackNode(nsHtml5ElementName::ELT_HEAD, headPointer));
 }
 
 void 
 nsHtml5TreeBuilder::reconstructTheActiveFormattingElements()
 {
   if (listPtr == -1) {
     return;
   }
@@ -3513,223 +3500,224 @@ nsHtml5TreeBuilder::popOnEof()
   elementPopped(node->ns, node->popName, node->node);
   node->release();
 }
 
 void 
 nsHtml5TreeBuilder::appendHtmlElementToDocumentAndPush(nsHtml5HtmlAttributes* attributes)
 {
   nsIContent** elt = createHtmlElementSetAsRoot(attributes);
-  nsHtml5StackNode* node = new nsHtml5StackNode(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_HTML, elt);
+  nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HTML, elt);
   push(node);
-  ;
 }
 
 void 
 nsHtml5TreeBuilder::appendHtmlElementToDocumentAndPush()
 {
   appendHtmlElementToDocumentAndPush(tokenizer->emptyAttributes());
 }
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes* attributes)
 {
   nsIContent** elt = createElement(kNameSpaceID_XHTML, nsHtml5Atoms::head, attributes);
   appendElement(elt, stack[currentPtr]->node);
   headPointer = elt;
-  ;
-  nsHtml5StackNode* node = new nsHtml5StackNode(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_HEAD, elt);
+  nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HEAD, elt);
   push(node);
-  ;
 }
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushBodyElement(nsHtml5HtmlAttributes* attributes)
 {
-  appendToCurrentNodeAndPushElement(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_BODY, attributes);
+  appendToCurrentNodeAndPushElement(nsHtml5ElementName::ELT_BODY, attributes);
 }
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushBodyElement()
 {
   appendToCurrentNodeAndPushBodyElement(tokenizer->emptyAttributes());
 }
 
 void 
 nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormElementMayFoster(nsHtml5HtmlAttributes* attributes)
 {
   nsIContent** elt = createElement(kNameSpaceID_XHTML, nsHtml5Atoms::form, attributes);
   formPointer = elt;
-  ;
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
     insertIntoFosterParent(elt);
   } else {
     appendElement(elt, current->node);
   }
-  nsHtml5StackNode* node = new nsHtml5StackNode(kNameSpaceID_XHTML, nsHtml5ElementName::ELT_FORM, elt);
+  nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_FORM, elt);
   push(node);
-  ;
 }
 
 void 
-nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormattingElementMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
+nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormattingElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
-  nsIContent** elt = createElement(ns, elementName->name, attributes);
+  nsIContent** elt = createElement(kNameSpaceID_XHTML, elementName->name, attributes);
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
     insertIntoFosterParent(elt);
   } else {
     appendElement(elt, current->node);
   }
-  nsHtml5StackNode* node = new nsHtml5StackNode(ns, elementName, elt, attributes->cloneAttributes(nsnull));
+  nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, attributes->cloneAttributes(nsnull));
   push(node);
   append(node);
   node->retain();
-  ;
 }
 
 void 
-nsHtml5TreeBuilder::appendToCurrentNodeAndPushElement(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
+nsHtml5TreeBuilder::appendToCurrentNodeAndPushElement(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
-  nsIContent** elt = createElement(ns, elementName->name, attributes);
+  nsIContent** elt = createElement(kNameSpaceID_XHTML, elementName->name, attributes);
   appendElement(elt, stack[currentPtr]->node);
-  nsHtml5StackNode* node = new nsHtml5StackNode(ns, elementName, elt);
+  nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt);
   push(node);
-  ;
 }
 
 void 
-nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
+nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
   nsIAtom* popName = elementName->name;
-  nsIContent** elt = createElement(ns, popName, attributes);
+  nsIContent** elt = createElement(kNameSpaceID_XHTML, popName, attributes);
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
     insertIntoFosterParent(elt);
   } else {
     appendElement(elt, current->node);
   }
-  nsHtml5StackNode* node = new nsHtml5StackNode(ns, elementName, elt, popName);
+  nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, popName);
   push(node);
-  ;
 }
 
 void 
-nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterNoScoping(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
+nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
   nsIAtom* popName = elementName->name;
-  nsIContent** elt = createElement(ns, popName, attributes);
+  nsIContent** elt = createElement(kNameSpaceID_MathML, popName, attributes);
+  nsHtml5StackNode* current = stack[currentPtr];
+  if (current->isFosterParenting()) {
+
+    insertIntoFosterParent(elt);
+  } else {
+    appendElement(elt, current->node);
+  }
+  nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, popName, PR_FALSE);
+  push(node);
+}
+
+void 
+nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
+{
+  nsIAtom* popName = elementName->camelCaseName;
+  nsIContent** elt = createElement(kNameSpaceID_SVG, popName, attributes);
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
     insertIntoFosterParent(elt);
   } else {
     appendElement(elt, current->node);
   }
-  nsHtml5StackNode* node = new nsHtml5StackNode(ns, elementName, elt, popName, PR_FALSE);
+  nsHtml5StackNode* node = new nsHtml5StackNode(elementName, popName, elt);
   push(node);
-  ;
 }
 
 void 
-nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterCamelCase(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
+nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContent** form)
 {
-  nsIAtom* popName = elementName->camelCaseName;
-  nsIContent** elt = createElement(ns, popName, attributes);
+  nsIContent** elt = createElement(kNameSpaceID_XHTML, elementName->name, attributes, fragment ? nsnull : form);
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
     insertIntoFosterParent(elt);
   } else {
     appendElement(elt, current->node);
   }
-  nsHtml5StackNode* node = new nsHtml5StackNode(ns, elementName, elt, popName, nsHtml5ElementName::ELT_FOREIGNOBJECT == elementName);
+  nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt);
   push(node);
-  ;
 }
 
 void 
-nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContent** form)
+nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form)
 {
-  nsIContent** elt = createElement(ns, elementName->name, attributes, fragment ? nsnull : form);
-  nsHtml5StackNode* current = stack[currentPtr];
-  if (current->isFosterParenting()) {
-
-    insertIntoFosterParent(elt);
-  } else {
-    appendElement(elt, current->node);
-  }
-  nsHtml5StackNode* node = new nsHtml5StackNode(ns, elementName, elt);
-  push(node);
-  ;
-}
-
-void 
-nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form)
-{
-  nsIContent** elt = createElement(ns, name, attributes, fragment ? nsnull : form);
+  nsIContent** elt = createElement(kNameSpaceID_XHTML, name, attributes, fragment ? nsnull : form);
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
     insertIntoFosterParent(elt);
   } else {
     appendElement(elt, current->node);
   }
-  elementPushed(ns, name, elt);
-  elementPopped(ns, name, elt);
-  ;
+  elementPushed(kNameSpaceID_XHTML, name, elt);
+  elementPopped(kNameSpaceID_XHTML, name, elt);
 }
 
 void 
-nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
+nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
   nsIAtom* popName = elementName->name;
-  nsIContent** elt = createElement(ns, popName, attributes);
+  nsIContent** elt = createElement(kNameSpaceID_XHTML, popName, attributes);
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
     insertIntoFosterParent(elt);
   } else {
     appendElement(elt, current->node);
   }
-  elementPushed(ns, popName, elt);
-  elementPopped(ns, popName, elt);
-  ;
+  elementPushed(kNameSpaceID_XHTML, popName, elt);
+  elementPopped(kNameSpaceID_XHTML, popName, elt);
 }
 
 void 
-nsHtml5TreeBuilder::appendVoidElementToCurrentMayFosterCamelCase(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
+nsHtml5TreeBuilder::appendVoidElementToCurrentMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
   nsIAtom* popName = elementName->camelCaseName;
-  nsIContent** elt = createElement(ns, popName, attributes);
+  nsIContent** elt = createElement(kNameSpaceID_SVG, popName, attributes);
   nsHtml5StackNode* current = stack[currentPtr];
   if (current->isFosterParenting()) {
 
     insertIntoFosterParent(elt);
   } else {
     appendElement(elt, current->node);
   }
-  elementPushed(ns, popName, elt);
-  elementPopped(ns, popName, elt);
-  ;
+  elementPushed(kNameSpaceID_SVG, popName, elt);
+  elementPopped(kNameSpaceID_SVG, popName, elt);
 }
 
 void 
-nsHtml5TreeBuilder::appendVoidElementToCurrent(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form)
+nsHtml5TreeBuilder::appendVoidElementToCurrentMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
 {
-  nsIContent** elt = createElement(ns, name, attributes, fragment ? nsnull : form);
+  nsIAtom* popName = elementName->name;
+  nsIContent** elt = createElement(kNameSpaceID_MathML, popName, attributes);
+  nsHtml5StackNode* current = stack[currentPtr];
+  if (current->isFosterParenting()) {
+
+    insertIntoFosterParent(elt);
+  } else {
+    appendElement(elt, current->node);
+  }
+  elementPushed(kNameSpaceID_MathML, popName, elt);
+  elementPopped(kNameSpaceID_MathML, popName, elt);
+}
+
+void 
+nsHtml5TreeBuilder::appendVoidElementToCurrent(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form)
+{
+  nsIContent** elt = createElement(kNameSpaceID_XHTML, name, attributes, fragment ? nsnull : form);
   nsHtml5StackNode* current = stack[currentPtr];
   appendElement(elt, current->node);
-  elementPushed(ns, name, elt);
-  elementPopped(ns, name, elt);
-  ;
+  elementPushed(kNameSpaceID_XHTML, name, elt);
+  elementPopped(kNameSpaceID_XHTML, name, elt);
 }
 
 void 
 nsHtml5TreeBuilder::appendVoidFormToCurrent(nsHtml5HtmlAttributes* attributes)
 {
   nsIContent** elt = createElement(kNameSpaceID_XHTML, nsHtml5Atoms::form, attributes);
   formPointer = elt;
   nsHtml5StackNode* current = stack[currentPtr];
@@ -3749,20 +3737,18 @@ nsHtml5TreeBuilder::cdataSectionAllowed(
 {
   return inForeign && currentPtr >= 0 && stack[currentPtr]->ns != kNameSpaceID_XHTML;
 }
 
 void 
 nsHtml5TreeBuilder::setFragmentContext(nsIAtom* context, PRInt32 ns, nsIContent** node, PRBool quirks)
 {
   this->contextName = context;
-  nsHtml5Portability::retainLocal(context);
   this->contextNamespace = ns;
   this->contextNode = node;
-  ;
   this->fragment = (!!contextName);
   this->quirks = quirks;
 }
 
 nsIContent** 
 nsHtml5TreeBuilder::currentNode()
 {
   return stack[currentPtr]->node;
@@ -3849,17 +3835,16 @@ nsHtml5TreeBuilder::newSnapshot()
     if (listIndex == -1) {
       nsHtml5StackNode* newNode = new nsHtml5StackNode(node->getFlags(), node->ns, node->name, node->node, node->popName, nsnull);
       stackCopy[i] = newNode;
     } else {
       stackCopy[i] = listCopy[listIndex];
       stackCopy[i]->retain();
     }
   }
-  ;
   return new nsHtml5StateSnapshot(stackCopy, listCopy, formPointer, headPointer, deepTreeSurrogateParent, mode, originalMode, framesetOk, inForeign, needToDropLF, quirks);
 }
 
 PRBool 
 nsHtml5TreeBuilder::snapshotMatches(nsAHtml5TreeBuilderState* snapshot)
 {
   jArray<nsHtml5StackNode*,PRInt32> stackCopy = snapshot->getStack();
   PRInt32 stackLen = snapshot->getStackLength();
@@ -3924,25 +3909,19 @@ nsHtml5TreeBuilder::loadState(nsAHtml5Tr
     if (listIndex == -1) {
       nsHtml5StackNode* newNode = new nsHtml5StackNode(node->getFlags(), node->ns, nsHtml5Portability::newLocalFromLocal(node->name, interner), node->node, nsHtml5Portability::newLocalFromLocal(node->popName, interner), nsnull);
       stack[i] = newNode;
     } else {
       stack[i] = listOfActiveFormattingElements[listIndex];
       stack[i]->retain();
     }
   }
-  ;
   formPointer = snapshot->getFormPointer();
-  ;
-  ;
   headPointer = snapshot->getHeadPointer();
-  ;
-  ;
   deepTreeSurrogateParent = snapshot->getDeepTreeSurrogateParent();
-  ;
   mode = snapshot->getMode();
   originalMode = snapshot->getOriginalMode();
   framesetOk = snapshot->isFramesetOk();
   inForeign = snapshot->isInForeign();
   needToDropLF = snapshot->isNeedToDropLF();
   quirks = snapshot->isQuirks();
 }
 
--- a/parser/html/nsHtml5TreeBuilder.h
+++ b/parser/html/nsHtml5TreeBuilder.h
@@ -170,26 +170,27 @@ class nsHtml5TreeBuilder : public nsAHtm
     void silentPop();
     void popOnEof();
     void appendHtmlElementToDocumentAndPush(nsHtml5HtmlAttributes* attributes);
     void appendHtmlElementToDocumentAndPush();
     void appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes* attributes);
     void appendToCurrentNodeAndPushBodyElement(nsHtml5HtmlAttributes* attributes);
     void appendToCurrentNodeAndPushBodyElement();
     void appendToCurrentNodeAndPushFormElementMayFoster(nsHtml5HtmlAttributes* attributes);
-    void appendToCurrentNodeAndPushFormattingElementMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
-    void appendToCurrentNodeAndPushElement(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
-    void appendToCurrentNodeAndPushElementMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
-    void appendToCurrentNodeAndPushElementMayFosterNoScoping(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
-    void appendToCurrentNodeAndPushElementMayFosterCamelCase(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
-    void appendToCurrentNodeAndPushElementMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContent** form);
-    void appendVoidElementToCurrentMayFoster(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form);
-    void appendVoidElementToCurrentMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
-    void appendVoidElementToCurrentMayFosterCamelCase(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
-    void appendVoidElementToCurrent(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form);
+    void appendToCurrentNodeAndPushFormattingElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
+    void appendToCurrentNodeAndPushElement(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
+    void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
+    void appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
+    void appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
+    void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContent** form);
+    void appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** 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, nsIContent** form);
     void appendVoidFormToCurrent(nsHtml5HtmlAttributes* attributes);
   protected:
     void accumulateCharacters(const PRUnichar* buf, PRInt32 start, PRInt32 length);
     void requestSuspension();
     nsIContent** createElement(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes);
     nsIContent** createElement(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form);
     nsIContent** createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* attributes);
     void detachFromParent(nsIContent** element);
--- a/parser/htmlparser/tests/mochitest/html5_tree_construction_exceptions.js
+++ b/parser/htmlparser/tests/mochitest/html5_tree_construction_exceptions.js
@@ -12,9 +12,10 @@ var html5Exceptions = {
   "<body><svg><foreignObject>\u0000filler\u0000text" : true, // Bug 612527
   "<svg>\u0000</svg><frameset>" : true, // Bug 612527
   "<svg>\u0000 </svg><frameset>" : true, // Bug 612527
   "<option><span><option>" : true, // Bug 612528
   "<math><annotation-xml encoding=\"application/xhtml+xml\"><div>" : true, // Bug 612529
   "<math><annotation-xml encoding=\"aPPlication/xhtmL+xMl\"><div>" : true, // Bug 612529
   "<math><annotation-xml encoding=\"text/html\"><div>" : true, // Bug 612529
   "<math><annotation-xml encoding=\"Text/htmL\"><div>" : true, // Bug 612529
+  "<!doctype html><div><body><frameset>" : true, // Bug 614241
 }
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests10.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests10.dat
@@ -542,16 +542,42 @@ 36: End of file in a foreign namespace c
 |   <body>
 |     <svg svg>
 |       <svg desc>
 |         <svg svg>
 |         <ul>
 |           "a"
 
 #data
+<!DOCTYPE html><p><svg><desc><p>
+#errors
+#document
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|   <body>
+|     <p>
+|       <svg svg>
+|         <svg desc>
+|           <p>
+
+#data
+<!DOCTYPE html><p><svg><title><p>
+#errors
+#document
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|   <body>
+|     <p>
+|       <svg svg>
+|         <svg title>
+|           <p>
+
+#data
 <div><svg><path><foreignObject><p></foreignObject><p>
 #errors
 #document
 | <html>
 |   <head>
 |   <body>
 |     <div>
 |       <svg svg>
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests19.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests19.dat
@@ -373,32 +373,74 @@
 #document
 | <!DOCTYPE html>
 | <html>
 |   <head>
 |   <body>
 |     <p>
 |       <math math>
 |         <math mi>
-|     <p>
-|     <h1>
+|           <p>
+|           <h1>
 
 #data
-<!doctype html><p><math><mi><p><h1>
+<!doctype html><p><math><mo><p><h1>
+#errors
+#document
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|   <body>
+|     <p>
+|       <math math>
+|         <math mo>
+|           <p>
+|           <h1>
+
+#data
+<!doctype html><p><math><mn><p><h1>
 #errors
 #document
 | <!DOCTYPE html>
 | <html>
 |   <head>
 |   <body>
 |     <p>
 |       <math math>
-|         <math mi>
+|         <math mn>
+|           <p>
+|           <h1>
+
+#data
+<!doctype html><p><math><ms><p><h1>
+#errors
+#document
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|   <body>
 |     <p>
-|     <h1>
+|       <math math>
+|         <math ms>
+|           <p>
+|           <h1>
+
+#data
+<!doctype html><p><math><mtext><p><h1>
+#errors
+#document
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|   <body>
+|     <p>
+|       <math math>
+|         <math mtext>
+|           <p>
+|           <h1>
 
 #data
 <!doctype html><frameset></noframes>
 #errors
 #document
 | <!DOCTYPE html>
 | <html>
 |   <head>
@@ -826,16 +868,35 @@
 #errors
 #document
 | <html>
 |   <head>
 |   <body>
 |     "a "
 
 #data
+<!doctype html><div><frameset>
+#errors
+#document
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|   <frameset>
+
+#data
+<!doctype html><div><body><frameset>
+#errors
+#document
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|   <body>
+|     <div>
+
+#data
 <!doctype html><p><math></p>a
 #errors
 #document
 | <!DOCTYPE html>
 | <html>
 |   <head>
 |   <body>
 |     <p>
@@ -849,17 +910,18 @@
 | <!DOCTYPE html>
 | <html>
 |   <head>
 |   <body>
 |     <p>
 |       <math math>
 |         <math mn>
 |           <span>
-|     "a"
+|             <p>
+|             "a"
 
 #data
 <!doctype html><math></html>
 #errors
 #document
 | <!DOCTYPE html>
 | <html>
 |   <head>